Skip to content

Expose n_iter_ in SVC/SVR#7461

Merged
rapids-bot[bot] merged 1 commit intorapidsai:mainfrom
jcrist:svm-n-iter
Nov 7, 2025
Merged

Expose n_iter_ in SVC/SVR#7461
rapids-bot[bot] merged 1 commit intorapidsai:mainfrom
jcrist:svm-n-iter

Conversation

@jcrist
Copy link
Copy Markdown
Member

@jcrist jcrist commented Nov 7, 2025

This PR exposes n_iter_ in our SVC and SVR estimators.

While doing so, we also deprecate the old meaning of max_iter (max outer iterations) in favor of a new meaning (max total iterations). This new meaning aligns with sklearn's implementation, easing interop between the two.

The deprecation cycle is implemented as:

  • 25.12: If a user passes in a non-default integer value, a warning is raised informing them of the deprecated meaning. The old behavior is still applied. To opt in to the new behavior (and silence the warning) they can pass an instance of TotalIters (an int subclass) instead. The n_iter_ attribute reflects the number of total iterations.
  • 26.02: The TotalIters wrapper will be deprecated. A bare integer will now mean "max total iterations".
  • 26.04: The TotalIters wrapper will be fully removed.

Fixes #7439. Part of #6966.

@jcrist jcrist self-assigned this Nov 7, 2025
@jcrist jcrist added the Cython / Python Cython or Python issue label Nov 7, 2025
@jcrist jcrist requested review from a team as code owners November 7, 2025 17:49
@jcrist jcrist added improvement Improvement / enhancement to an existing function breaking Breaking change labels Nov 7, 2025
@jcrist jcrist requested a review from dantegd November 7, 2025 17:49
@jcrist jcrist added CUDA/C++ cuml-accel Issues related to cuml.accel algo: svm labels Nov 7, 2025
@jcrist jcrist requested a review from csadorf November 7, 2025 17:49
Comment thread python/cuml/cuml/svm/svr.py Outdated
Comment thread python/cuml/cuml/svm/svm_base.pyx
Comment thread python/cuml/cuml/svm/svm_base.pyx
Comment thread python/cuml/cuml/svm/svc.py Outdated
Comment thread cpp/include/cuml/svm/svm_parameter.h Outdated
Comment thread cpp/src/svm/smosolver.cuh
This PR exposes `n_iter_` in our `SVC` and `SVR` estimators.

While doing so, we also deprecate the old meaning of `max_iter` (max
outer iterations) in favor of a new meaning (max _total_ iterations).
This new meaning aligns with sklearn's implementation, easing interop
between the two.

The deprecation cycle is implemented as:

- 25.12: If a user passes in a non-default integer value, a warning
  is raised informing them of the deprecated meaning. The old behavior
  is still applied. To opt in to the new behavior (and silence the
  warning) they can pass an instance of `TotalIters` (an `int` subclass)
  instead. The `n_iter_` attribute reflects the number of total
  iterations.
- 26.02: The `TotalIters` wrapper will be deprecated. A bare integer
  will now mean "max total iterations".
- 26.04: The `TotalIters` wrapper will be fully removed.
@jcrist
Copy link
Copy Markdown
Member Author

jcrist commented Nov 7, 2025

/merge

@rapids-bot rapids-bot Bot merged commit 8782643 into rapidsai:main Nov 7, 2025
106 checks passed
@jcrist jcrist deleted the svm-n-iter branch November 7, 2025 21:00
rapids-bot Bot pushed a commit that referenced this pull request Dec 12, 2025
…uctor (#7604)

closes #7603 

Fixes missing `epsilon` and `svmType` fields in the `SVC` class constructor's aggregate initialization of `SvmParameter`.

After #7461 added `max_outer_iter` to `SvmParameter`, the constructor in `svc.cu` was updated but still omitted the final two fields:

```C++
// Before (missing epsilon and svmType):
--param(SvmParameter{C, cache_size, max_outer_iter, -1, nochange_steps, tol, verbosity})

// After (explicit initialization):
++param(SvmParameter{C, cache_size, max_outer_iter, -1, nochange_steps, tol, verbosity, 0, C_SVC})
```
While C++ value-initializes omitted aggregate members to zero, this behavior can vary across compilers and build configurations. The missing `svmType` field caused intermittent CI failures in `SmoSolverTest/0.SvcTest` with the error:

> "Incorrect training: cannot calculate the constant in the decision function"

This occurred because an undefined `svmType` value could cause the SMO solver to misinterpret training data, leading to invalid support vector selection.

Authors:
  - Dante Gama Dessavre (https://github.com/dantegd)

Approvers:
  - Divye Gala (https://github.com/divyegala)
  - Simon Adorf (https://github.com/csadorf)

URL: #7604
rapids-bot Bot pushed a commit that referenced this pull request Dec 15, 2025
This is the 2nd part of the deprecation plan for changing the behavior of `max_iter` for `SVC`/`SVR`. Previously we added a `TotalIters` wrapper so users could opt-in to the new behavior, now we make the new behavior the default and deprecate the wrapper. `max_iter` now always places a limit on _total iterations_ in the solver.

Follow-up to #7461.

Authors:
  - Jim Crist-Harif (https://github.com/jcrist)

Approvers:
  - Dante Gama Dessavre (https://github.com/dantegd)

URL: #7612
mani-builds pushed a commit to mani-builds/cuml that referenced this pull request Jan 11, 2026
…uctor (rapidsai#7604)

closes rapidsai#7603 

Fixes missing `epsilon` and `svmType` fields in the `SVC` class constructor's aggregate initialization of `SvmParameter`.

After rapidsai#7461 added `max_outer_iter` to `SvmParameter`, the constructor in `svc.cu` was updated but still omitted the final two fields:

```C++
// Before (missing epsilon and svmType):
--param(SvmParameter{C, cache_size, max_outer_iter, -1, nochange_steps, tol, verbosity})

// After (explicit initialization):
++param(SvmParameter{C, cache_size, max_outer_iter, -1, nochange_steps, tol, verbosity, 0, C_SVC})
```
While C++ value-initializes omitted aggregate members to zero, this behavior can vary across compilers and build configurations. The missing `svmType` field caused intermittent CI failures in `SmoSolverTest/0.SvcTest` with the error:

> "Incorrect training: cannot calculate the constant in the decision function"

This occurred because an undefined `svmType` value could cause the SMO solver to misinterpret training data, leading to invalid support vector selection.

Authors:
  - Dante Gama Dessavre (https://github.com/dantegd)

Approvers:
  - Divye Gala (https://github.com/divyegala)
  - Simon Adorf (https://github.com/csadorf)

URL: rapidsai#7604
mani-builds pushed a commit to mani-builds/cuml that referenced this pull request Jan 11, 2026
This is the 2nd part of the deprecation plan for changing the behavior of `max_iter` for `SVC`/`SVR`. Previously we added a `TotalIters` wrapper so users could opt-in to the new behavior, now we make the new behavior the default and deprecate the wrapper. `max_iter` now always places a limit on _total iterations_ in the solver.

Follow-up to rapidsai#7461.

Authors:
  - Jim Crist-Harif (https://github.com/jcrist)

Approvers:
  - Dante Gama Dessavre (https://github.com/dantegd)

URL: rapidsai#7612
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

algo: svm breaking Breaking change CUDA/C++ cuml-accel Issues related to cuml.accel Cython / Python Cython or Python issue improvement Improvement / enhancement to an existing function

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Switch max_iter in SVR/SVC to apply to _total_ iterations, not just outer iterations

3 participants