Skip to content

feat(multitask): configurable LightGBM n_jobs (default 1) + clear code-scanning #214#380

Merged
bartzbeielstein merged 3 commits into
developfrom
feat/lgbm-n-jobs
Jun 13, 2026
Merged

feat(multitask): configurable LightGBM n_jobs (default 1) + clear code-scanning #214#380
bartzbeielstein merged 3 commits into
developfrom
feat/lgbm-n-jobs

Conversation

@bartzbeielstein

Copy link
Copy Markdown
Collaborator

What

Make the LightGBM thread count used by the multitask forecaster factories configurable via a new config.lgbm_n_jobs field, and clear CodeQL code-scanning alert #214.

lgbm_n_jobs (feat)

  • New ConfigMulti.lgbm_n_jobs: int = 1 (inherited by ConfigEntsoe; added to the PipelineConfig protocol).
  • default_lgbm_forecaster_factory and quantile_lgbm_forecaster_factory now pass n_jobs=getattr(config, "lgbm_n_jobs", 1) to LGBMRegressor (the getattr default keeps config-like objects that predate the field working).
  • Why default 1: on heterogeneous-core CPUs (Apple Silicon's P+E cores) LightGBM's all-core OpenMP anti-scales — the per-tree fork-join barrier stalls on the slow efficiency cores. With n_jobs=1 the backtesting heuristic (select_n_jobs_backtesting) instead parallelises the CV folds across processes, which scales cleanly (~3× faster end-to-end tuning measured on an M4 Max). On many-core homogeneous machines (e.g. Linux Xeon) set lgbm_n_jobs=-1 to restore all-core in-model threading.

code-scanning #214 (fix)

  • py/unused-global-variable on _LAST_REQUEST_MONOTONIC (the 22.4.1 Open-Meteo throttle). Now held in a one-element list mutated in place under the lock — no global rebind, identical runtime behaviour.

Tests

  • New: default factory + quantile factory honour lgbm_n_jobs (and default to 1).
  • Updated throttle-spacing test to the list form.
  • Full suite: 2642 passed, 1 skipped; ruff clean.

🤖 Generated with Claude Code

bartzbeielstein and others added 3 commits June 13, 2026 23:09
The lgbm forecaster factories (default_lgbm_forecaster_factory,
quantile_lgbm_forecaster_factory) now read config.lgbm_n_jobs and forward it
to LGBMRegressor(n_jobs=...). Default is 1: on heterogeneous-core CPUs (e.g.
Apple Silicon's performance + efficiency cores) LightGBM's all-core OpenMP
anti-scales (the fork-join barrier stalls on the slow E-cores). With n_jobs=1
the backtesting heuristic (select_n_jobs_backtesting) instead parallelises the
CV folds across processes, which scales cleanly (~3x faster end-to-end tuning
on an M4 Max). On many-core homogeneous machines (e.g. Linux Xeon) set
lgbm_n_jobs=-1 to restore all-core in-model threading.

New field on ConfigMulti (inherited by ConfigEntsoe) and the PipelineConfig
protocol; factories read it via getattr(config, "lgbm_n_jobs", 1) so
config-like objects predating the field keep working.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…l-variable)

_throttle_open_meteo rebinding the module-level _LAST_REQUEST_MONOTONIC through
`global` tripped CodeQL's py/unused-global-variable (code-scanning alert #214).
Hold the last-request monotonic time in a one-element list mutated in place
under the lock instead: identical runtime behaviour, no global rebind. Updates
the throttle-spacing test to the list form.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sync docs/reference with the new ConfigMulti/ConfigEntsoe.lgbm_n_jobs field and
the updated lgbm factory docstrings (API Reference In Sync gate).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@bartzbeielstein bartzbeielstein merged commit ba45606 into develop Jun 13, 2026
10 checks passed
@bartzbeielstein bartzbeielstein deleted the feat/lgbm-n-jobs branch June 13, 2026 21:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant