You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
qlib fails with TypeError when using LightGBM 4.0+ because the code passes None to lgb.early_stopping(), which no longer accepts None starting from LightGBM 4.0.
Error message:
TypeError: early_stopping_round should be an integer. Got 'NoneType'
To Reproduce
Prerequisites: This bug is currently masked by issue #2130. You need to apply the fix from PR #2213 first.
File "qlib/contrib/rolling/ddgda.py", line 249, in _dump_meta_ipt
internal_data.setup(trainer=TrainerR)
File "qlib/contrib/meta/data_selection/dataset.py", line 85, in setup
trainer.train(gen_task)
File "qlib/model/trainer.py", line 271, in train
rec = train_func(task, experiment_name, recorder_name=self.default_rec_name, **kwargs)
File "qlib/model/trainer.py", line 127, in task_train
_exe_task(task_config)
File "qlib/model/trainer.py", line 49, in _exe_task
auto_filter_kwargs(model.fit)(dataset, reweighter=reweighter)
File "qlib/contrib/model/gbdt.py", line 71, in fit
early_stopping_callback = lgb.early_stopping(
self.early_stopping_rounds if early_stopping_rounds is None else early_stopping_rounds
)
TypeError: early_stopping_round should be an integer. Got 'NoneType'
Expected Behavior
The DDG-DA workflow should run successfully without raising a TypeError. When early_stopping_rounds=None, the model should train without early stopping (for the full num_boost_round iterations).
qlib/contrib/model/gbdt.py (line 71-73) - must fix
qlib/contrib/rolling/ddgda.py (line 244) - must fix
qlib/contrib/model/highfreq_gdbt_model.py (line 127) - should fix (for robustness)
Note:qlib/contrib/model/double_ensemble.py (line 110-111) already handles this correctly by checking if early_stopping_rounds is truthy before creating the callback.
🐛 Bug Description
qlib fails with
TypeErrorwhen using LightGBM 4.0+ because the code passesNonetolgb.early_stopping(), which no longer acceptsNonestarting from LightGBM 4.0.Error message:
To Reproduce
Prerequisites: This bug is currently masked by issue #2130. You need to apply the fix from PR #2213 first.
Steps to reproduce the behavior:
cd examples/benchmarks_dynamic/DDG-DAFull stack trace:
Expected Behavior
The DDG-DA workflow should run successfully without raising a
TypeError. Whenearly_stopping_rounds=None, the model should train without early stopping (for the fullnum_boost_rounditerations).Screenshot
N/A (Error is in terminal output)
Environment
System Information (collected via scripts/collect_info.py)
Additional Notes
Root Cause
File:
qlib/contrib/model/gbdt.py(lines 71-73)The code directly passes
early_stopping_roundstolgb.early_stopping()without checking if it'sNone:File:
qlib/contrib/rolling/ddgda.py(line 244)The DDG-DA workflow explicitly sets
early_stopping_rounds: Noneto disable early stopping:LightGBM Breaking Change
Starting from LightGBM 4.0, the
lgb.early_stopping()function enforces type checking and no longer acceptsNone:Noneto disable early stoppingTypeErroronNoneReference: https://github.com/microsoft/LightGBM/releases/tag/v4.0.0
Affected Files
qlib/contrib/model/gbdt.py(line 71-73) - must fixqlib/contrib/rolling/ddgda.py(line 244) - must fixqlib/contrib/model/highfreq_gdbt_model.py(line 127) - should fix (for robustness)Note:
qlib/contrib/model/double_ensemble.py(line 110-111) already handles this correctly by checking ifearly_stopping_roundsis truthy before creating the callback.Relationship to Other Issues
These are two independent bugs that both affect the DDG-DA workflow.