Skip to content

feat(tracking): configurable ILP solver backend preference (enable cuOpt) - #9

Merged
JoOkuma merged 4 commits into
royerlab:mainfrom
aliddell:feat/configurable-solver-preference
Oct 16, 2026
Merged

JoOkuma merged 4 commits into
royerlab:mainfrom
aliddell:feat/configurable-solver-preference

Conversation

@aliddell

Copy link
Copy Markdown
Contributor

What

Add an optional solver_preference to ILPSolverConfig and thread it through solve_tracking into tracksdata's ILPSolver and the two-pass TrackletSolver (including the internal tracklet-linkage solver instance).

This lets a user choose an alternate ILP backend (in our case, NVIDIA cuOpt) instead of Gurobi, given either a single backend name or an ordered list (e.g. "gurobi" or ["gurobi", "cuopt", "scip"]). Names are matched, case-insensitive, by tracksdata.

Outcome

Run the tracking ILP on a non-Gurobi backend (e.g. cuOpt on GPU) through config alone, so sites without a Gurobi license can still solve large graphs (SCIP is too slow).

Behavior / backward compatibility

  • Default None preserves current behavior: tracksdata keeps its default order (Gurobi then SCIP).
  • The preference is forwarded only when set; when None, the kwarg is not passed, so installs on older tracksdata are unaffected.
  • The second-pass linkage solver in TrackletSolver.solve reads the inherited _solver_preference defensively (getattr(..., None)) and forwards it only when present, so both passes honor the same backend.
  • ILPSolverConfig.default() is unchanged.

Runtime requirement (important)

solver_preference requires tracksdata with PR #343, and the cuopt backend additionally requires ilpy >= 0.6.0. hoct currently pins tracksdata>=0.1.0rc4 (resolves to rc11 today, which does not carry #343). This PR is safe on that pin (default None changes nothing).

Follow-up: bump the tracksdata pin to the first release that includes #343; until then, a non-None solver_preference fails at solver construction on the pinned tracksdata.

Tests

src/hoct/_tests/test_solver_preference.py mocks tracksdata's solver classes and asserts the constructor kwargs at all three construction sites, so it passes regardless of whether the installed tracksdata carries #343. No real ilpy/Gurobi/cuOpt solve runs.

🤖 Generated with Claude Code

Add an optional `solver_preference` to `ILPSolverConfig` and forward it
through `solve_tracking` into tracksdata's `ILPSolver` and the two-pass
`TrackletSolver`, including the internal linkage-pass solver. This lets a
user select an alternate ILP backend (for example NVIDIA cuOpt) instead of
Gurobi, as an ordered list of backend names.

The default is None, which preserves current behavior: tracksdata uses its
own default order (Gurobi then SCIP). The preference is only forwarded when
set, so older tracksdata (without PR #343) is unaffected. The linkage pass
reads the inherited `_solver_preference` defensively.

Add a hermetic test that mocks tracksdata's solver, so it does not depend on
the installed tracksdata carrying PR #343.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@JoOkuma JoOkuma left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hi @aliddell , I have the impression that

        # Older tracksdata has no `_solver_preference`; omit the kwarg then.
        _pref = getattr(self, "_solver_preference", None)

This might be necessary in _solver.py; can you check?

@codecov-commenter

Copy link
Copy Markdown

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

Add tests that model a pre-#343 tracksdata whose ILPSolver rejects
`solver_preference`: the default config constructs both passes without
the kwarg, and opting into a preference surfaces the TypeError instead
of being dropped. Note the compat intent at the forward guard in
_solver.py. Addresses review feedback on royerlab#9.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@aliddell

Copy link
Copy Markdown
Contributor Author

Hi @aliddell , I have the impression that

        # Older tracksdata has no `_solver_preference`; omit the kwarg then.
        _pref = getattr(self, "_solver_preference", None)

This might be necessary in _solver.py; can you check?

I added some tests for the case of the older tracksdata. test_default_config_constructs_on_pre343_tracksdata models a tracksdata whose ILPSolver rejects solver_preference (pre-tracksdata#343) and shows both passes construct with the default config, because _solver.py only forwards the kwarg when it is set. test_preference_on_pre343_tracksdata_surfaces_error shows that opting into a preference on the older tracksdata raises TypeError instead of being dropped silently. I also added a short comment at the forward guard in _solver.py. lmk if that answers your concern.

aliddell and others added 2 commits October 15, 2026 11:05
Collapse the raise onto one line to satisfy `ruff format --check`.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@JoOkuma
JoOkuma merged commit 282ba43 into royerlab:main Oct 16, 2026
6 checks passed
@aliddell
aliddell deleted the feat/configurable-solver-preference branch October 16, 2026 03:04
JoOkuma pushed a commit that referenced this pull request Nov 9, 2026
Add tests that model a pre-#343 tracksdata whose ILPSolver rejects
`solver_preference`: the default config constructs both passes without
the kwarg, and opting into a preference surfaces the TypeError instead
of being dropped. Note the compat intent at the forward guard in
_solver.py. Addresses review feedback on #9.
JoOkuma added a commit that referenced this pull request Nov 9, 2026
feat(tracking): configurable ILP solver backend preference (enable cuOpt)
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.

4 participants