Skip to content

[Train V2] Fold v2.LightGBMTrainer API into the public trainer class as an alternate constructor#51265

Merged
justinvyu merged 17 commits intoray-project:masterfrom
hongpeng-guo:hpguo/lightgbm_v2_api
Apr 9, 2025
Merged

[Train V2] Fold v2.LightGBMTrainer API into the public trainer class as an alternate constructor#51265
justinvyu merged 17 commits intoray-project:masterfrom
hongpeng-guo:hpguo/lightgbm_v2_api

Conversation

@hongpeng-guo
Copy link
Copy Markdown
Contributor

@hongpeng-guo hongpeng-guo commented Mar 11, 2025

Summary

This PR is a follow-up of #50045, which folds the new LightGBM API into ray.train.lightgbm.LightGBMTrainer so that users don't need to change their imports to use the new custom train function API.

Before/after

Before, the ray.train.lightgbm.v2 is needed to use the custom train function API.

from ray.train.lightgbm import LightGBMTrainer as OldLightGBMTrainer

OldLightGBMTrainer(params={...}, datasets={...})

from ray.train.lightgbm.v2 import LightGBMTrainer as NewLightGBMTrainer

def train_fn_per_worker(config):
    lightgbm.train(...)

NewLightGBMTrainer(train_fn_per_worker)

Now, the same import can toggle between the 2 APIs (the old API slated to be deprecated).

from ray.train.lightgbm import LightGBMTrainer

LightGBMTrainer(train_fn_per_worker)
LightGBMTrainer(params={...}, datasets={...})  # deprecated

Related issue number

#50042

Signed-off-by: Hongpeng Guo <hpguo@anyscale.com>
Signed-off-by: Hongpeng Guo <hpguo@anyscale.com>
Signed-off-by: Hongpeng Guo <hpguo@anyscale.com>
Signed-off-by: Hongpeng Guo <hpguo@anyscale.com>
Signed-off-by: Hongpeng Guo <hpguo@anyscale.com>
Signed-off-by: Hongpeng Guo <hpguo@anyscale.com>
Signed-off-by: Hongpeng Guo <hpguo@anyscale.com>
@hongpeng-guo hongpeng-guo added the go add ONLY when ready to merge, run all tests label Mar 13, 2025
@hongpeng-guo
Copy link
Copy Markdown
Contributor Author

cc @justinvyu

Signed-off-by: Justin Yu <justinvyu@anyscale.com>
Signed-off-by: Justin Yu <justinvyu@anyscale.com>
Copy link
Copy Markdown
Contributor

@justinvyu justinvyu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐲

@justinvyu justinvyu enabled auto-merge (squash) April 9, 2025 20:21
@justinvyu justinvyu merged commit a6e0f80 into ray-project:master Apr 9, 2025
6 checks passed
han-steve pushed a commit to han-steve/ray that referenced this pull request Apr 11, 2025
…s as an alternate constructor (ray-project#51265)

This PR is a follow-up of ray-project#50045,
which folds the new LightGBM API into
`ray.train.lightgbm.LightGBMTrainer` so that users don't need to change
their imports to use the new custom train function API.

---------

Signed-off-by: Hongpeng Guo <hpguo@anyscale.com>
Signed-off-by: Justin Yu <justinvyu@anyscale.com>
Co-authored-by: Justin Yu <justinvyu@anyscale.com>
Signed-off-by: Steve Han <stevehan2001@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-backlog go add ONLY when ready to merge, run all tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants