Skip to content

Fix silent training and NumPy sampling parameters - #36

Merged
dev-rinchin merged 3 commits into
masterfrom
fix/sampling-scalars-and-silent-training
Oct 30, 2026
Merged

dev-rinchin merged 3 commits into
masterfrom
fix/sampling-scalars-and-silent-training

Conversation

@dev-rinchin

@dev-rinchin dev-rinchin commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Fix silent training and NumPy sampling parameters

GradientBoosting.fit() currently raises ZeroDivisionError when verbose=0, and treats NumPy sampling scalars such as colsample=np.float64(0.5) as callbacks, producing an unrelated AttributeError. These failures also affect SketchBoost through the shared implementation.

This change allows silent training and accepts Python/NumPy real numeric sampling rates consistently. For example, verbose=0, colsample=np.float32(0.5), subsample=np.float64(0.5) now completes training.

Changes

  • Guard iteration progress logging with verbose > 0. Validation metrics, history, and early stopping still run when logging is disabled; positive logging intervals keep their existing behavior.
  • Recognize sampling rates with numbers.Real instead of exact Python type comparisons. Accept rates in (0, 1]; reject invalid ranges, NaN/infinities, booleans, arrays, and unsupported objects with parameter-specific errors before training.
  • Normalize validated rates to Python float before constructing BaseSampler, preventing NumPy 2 from casting large axis lengths to float16 and overflowing.
  • Preserve callable custom samplers implementing the callback lifecycle, including objects that do not inherit Callback.
  • Update the GradientBoosting and SketchBoost parameter documentation and add regression coverage.

Validation

  • Before the fixes, four selected regression cases reproduced both original exceptions: NumPy float64 for each sampling parameter, and verbose=0 with/without evaluation sets.
  • After the fixes, the full test suite passed: 120 passed on Linux with an NVIDIA A100, Python 3.10.22, NumPy 2.2.6, and CuPy 13.6.0.
  • Coverage includes Python/NumPy numeric types, invalid rates/types, custom sampler identity and lifecycle, simultaneous row/column sampling in GradientBoosting and SketchBoost, positive logging intervals, validation history, and early stopping with logging disabled.
  • Float16 regressions cover both sampling axes at lengths 65,504, 65,520, and 100,000, plus public training on 100,000 rows compared with a Python-float control. The 100,000-element cases for both axes reproduced OverflowError before normalization and pass afterward.
  • Predictions and metric histories are compared with control runs using ordinary Python sampling rates and enabled logging, with appropriate floating-point tolerances.
  • Changed Python files parse with Python 3.8 syntax; git diff --check passes. Other Python versions and operating systems were not executed.
  • Test output contains existing CuPy scatter_add deprecation warnings.

Command:

CUDA_VISIBLE_DEVICES=1 /tmp/pyboost-issue25-venv/bin/python -m pytest -q tests

Fixes #33
Fixes #27

Guard the logging interval when verbose is non-positive while preserving validation metrics and early stopping. Add logging and GPU training regressions.

Fixes #33
Recognize real numeric scalars, validate rates in (0, 1], and reject unsupported objects before training. Preserve callable sampler callbacks and document the parameter contract.

Add GPU regressions for numeric types, invalid values, custom sampler lifecycles, and simultaneous row/column sampling in GradientBoosting and SketchBoost.

Fixes #27
Convert validated real sampling rates to Python float so NumPy 2 does not cast large row or column counts to float16 and overflow. Add boundary checks for both sampling axes and a 100,000-row training regression against a Python-float control.
@dev-rinchin
dev-rinchin merged commit 6e4ceac into master Oct 30, 2026
2 checks passed
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.

Training fails with ZeroDivisionError when verbose=0 NumPy scalar values in colsample and subsample are incorrectly treated as callbacks

1 participant