Skip to content

Feature/numba integration - #99

Merged
lenarddome merged 35 commits into
mainfrom
feature/numba-integration
Sep 30, 2026
Merged

lenarddome merged 35 commits into
mainfrom
feature/numba-integration

Conversation

@lenarddome

Copy link
Copy Markdown
Collaborator

Summary

Makes model fitting in cpm much faster, with the public API unchanged. numba is an optional extra (pip install "cpm-toolbox[numba]"); without it, cpm runs the same code as plain Python.

  • The built-in applications (RLRW, HybridMBMF, PTSM, PTSM1992, PTSM2025) compute all trials of a participant at once. Fitting them is 90-220× faster with numba and 11-23× faster without, with the same results as main.
  • New: cpm.generators.SessionWrapper, for your own models that compute all trials at once, and cpm.models.kernels, the formulas of the cpm.models classes as functions numba can compile.
  • Faster priors, per-trial Wrapper runs, losses and meta-d', with identical results.
  • Fixes EmpiricalBayes and VariationalBayes discarding the updated population priors after the first evaluation. Hierarchical results change. numpy.random.seed now also reproduces their later chains.
  • Adds a test workflow: Linux on Python 3.11-3.14, Windows and macOS on 3.14, each with and without numba, plus runs on the lowest allowed versions and on pre-releases.
  • Adds a News section to the docs, and how-to guides on numba and on speeding up your own model.

Other behaviour changes are listed in CHANGELOG.md under 0.26.0.dev0.

Testing

  • The outputs of the former per-trial applications are stored in the tests, and both backends must reproduce them exactly.
  • The full test suite passes with numba, without it, and with NUMBA_DISABLE_JIT=1. The docs build passes with warnings treated as errors.
  • This is the first run of the new test workflow. The lowest-versions job is untested; I'll raise any lower bound that fails.

🤖 Generated with Claude Code

lenarddome and others added 30 commits September 24, 2026 17:35
…d form

Also fixes cpm.hierarchical discarding its population priors after the first evaluation.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…sion per call

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
numba is optional; without it, the same code runs as plain Python.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Results are unchanged, except that Softmax no longer overflows.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Each application computes all trials in one loop, compiled with numba if it is installed.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…piled loops

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…the docs

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Their outputs predated the population-prior fix.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…oth bounds

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

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…reset fixes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e used

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…used imports

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lenarddome and others added 5 commits September 29, 2026 14:56
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…andas objects

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lenarddome
lenarddome merged commit 638454f into main Sep 30, 2026
17 checks passed
@lenarddome
lenarddome deleted the feature/numba-integration branch October 2, 2026 16:22
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