Skip to content

Reuse compacted row indices in the xFit solver - #71

Open
tpn wants to merge 1 commit into
mainfrom
codex/xfit-index-reuse-20260929
Open

tpn wants to merge 1 commit into
mainfrom
codex/xfit-index-reuse-20260929

Conversation

@tpn

@tpn tpn commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Repeated Boolean indexing in the xFit Levenberg–Marquardt solver makes CuPy compact the same mask and synchronize its selected-row count for each array. Compute the row indices once per selection and reuse them across the parameters, residuals, derivatives and accepted steps. The arithmetic, row order and termination rules stay the same.

A matched single-worker GB200 experiment reduced median batch time from 375.051 to 331.110 seconds (1.133× throughput). Each of three measured rounds processed 32 distinct synthetic image pairs twice, with 256 fits per pair occurrence; timing included output writes and validation. The benchmarked solver matches this change byte-for-byte.

Validation

  • make test-cpu: 2,760 passed; 188 optional tests skipped.
  • uv lock --check, uv run --locked --extra dev pre-commit run --all-files, make lint and make build: passed.
  • Solver and iterative CuPy Gaussian, finite-difference and stamp parity tests: 36 passed on RTX PRO 6000 with CUDA 13.2, on both Python 3.13 and 3.14t.
  • Two additional device-result tests fail at an existing dataclasses.replace() exception-type assertion; reproduced against unchanged main. Their numerical parity assertions pass.

Repository hygiene

  • No credentials, private paths, local datasets, notebook outputs, or generated run artifacts were added.
  • Large binary artifacts are excluded.
  • Security-sensitive information is not included.
  • No public API or behavior changes require documentation.
  • No new dependencies were added.

@tpn
tpn requested a review from melo-gonzo as a code owner September 29, 2026 15:32
@coderabbitai

coderabbitai Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: NVIDIA/cuPhoton/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Enterprise
  • Run ID: d9298e88-e488-454e-aa9e-88bd2cb25960
📥 Commits

Reviewing files that changed from the base of the PR and between 7156d58 and 27ca03d.

📒 Files selected for processing: 2
  • src/cuphoton/xfit/solver.py
  • tests/xfit/test_solver.py

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 10 remain after this review.

📝 Walkthrough

The solver now uses integer row positions to filter arrays across normal-equation, Jacobian, convergence, step, and accepted-step paths. New tests compare batched results with independent solves and check behavior when one solver step is non-finite.

Changes: Solver row filtering

Layer / File(s) Summary
Row-indexed solver iteration
src/cuphoton/xfit/solver.py, tests/xfit/test_solver.py
The solver uses integer indices across row filtering and accepted-trial updates. Tests cover mixed batches across dtypes and normal-equation paths, and a non-finite step in one row.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 27ca0

No merge-blocking issue is identified in the row-index filtering change; merge after normal checks.

Pre-merge checks: Passed 2
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.

Comment @coderabbitai help to get the list of available commands.

@tpn tpn added the ai-review Request a focused CodeRabbit review label Sep 29, 2026
@tpn
tpn force-pushed the codex/xfit-index-reuse-20260929 branch 2 times, most recently from 15dc343 to 9843894 Compare October 9, 2026 20:43
@tpn
tpn changed the base branch from main to codex/ci-python-ecr-20261009 October 9, 2026 21:08
@tpn
tpn force-pushed the codex/xfit-index-reuse-20260929 branch 2 times, most recently from aab6c3a to 7156d58 Compare October 15, 2026 18:05
@tpn
tpn changed the base branch from codex/ci-python-ecr-20261009 to main October 15, 2026 18:06
Compute integer row indices once per selection and reuse them across
aligned solver arrays. This avoids repeated Boolean-mask compaction
and its host synchronization on CuPy.

Cover mixed termination and failure paths with per-row parity checks.

Signed-off-by: Trent Nelson <trentn@nvidia.com>
@tpn
tpn force-pushed the codex/xfit-index-reuse-20260929 branch from 7156d58 to 27ca03d Compare October 16, 2026 18:47

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-review Request a focused CodeRabbit review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant