Skip to content

Add experimental per-trace and batched mode refinement - #4

Open
jimsweeney wants to merge 16 commits into
NVIDIA:mainfrom
jimsweeney:xray-lp-refinement
Open

jimsweeney wants to merge 16 commits into
NVIDIA:mainfrom
jimsweeney:xray-lp-refinement

Conversation

@jimsweeney

@jimsweeney jimsweeney commented Sep 16, 2026 •

Copy link
Copy Markdown

Adds optional nonlinear refinement for XRay linear-prediction modes, with residual-spectrum initialization for missing modes and batched NumPy/CuPy solves. Fit results include reconstruction, convergence and local uncertainty estimates; benchmark reports retain convergence counts and residual quality. The lpmr command writes an offline comparison page with the actual noise-free input, fitted modes and solver status.

The tools use an unconstrained damped-mode model and remain experimental, alongside the existing constrained production fitter. The guide explains initialization, uncertainty assumptions, convergence limits and timing boundaries. Validation supplies a known mode count; production detector acceptance and end-to-end speedup remain separate work. Includes the corrected diagnostics from #2, which should land first.

Validation: 2,970 full CPU tests, 69 focused refinement/visualization tests including CuPy, and all nine CI-selected GPU cases passed. An independent numerical review and a 114-trace comparison covered noise, close/coincident modes, difficult starts, distortions and long records; expected nonconvergence and local minima are retained in the results. Full lint/hooks and an isolated final-wheel CLI/offline-render smoke passed. The existing GPU CI job now includes three XRay time-scale parity cases.

Refs #1, #2.

@tpn tpn changed the title Add nonlinear refinement of linear-prediction modes, per trace and batched (refs #1) Add experimental per-trace and batched mode refinement Sep 24, 2026
@tpn
tpn force-pushed the xray-lp-refinement branch from f052bdf to 647fa99 Compare September 24, 2026 22:25
@tpn
tpn requested review from melo-gonzo and tpn as code owners September 24, 2026 22:25
@coderabbitai

coderabbitai Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are limited based on label configuration.

🏷️ Required labels (at least one): 1
  • ai-review

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: Repository: NVIDIA/cuPhoton/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4cfa22d5-9c47-4265-b96d-569a029c70de

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@tpn

tpn commented Sep 25, 2026

Copy link
Copy Markdown
Collaborator

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

@tpn
tpn force-pushed the xray-lp-refinement branch from 647fa99 to 67887d4 Compare September 28, 2026 20:52
@copy-pr-bot

copy-pr-bot Bot commented Sep 28, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@tpn
tpn force-pushed the xray-lp-refinement branch 2 times, most recently from 7d9c016 to 4150197 Compare October 1, 2026 01:42
@tpn

tpn commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator

/ok to test 4150197

@tpn
tpn force-pushed the xray-lp-refinement branch 3 times, most recently from a873a86 to f01f5a7 Compare October 9, 2026 20:44
@tpn
tpn changed the base branch from main to codex/ci-python-ecr-20261009 October 9, 2026 21:08
@tpn
tpn force-pushed the xray-lp-refinement branch 3 times, most recently from 0a8ca02 to 824edd0 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
jimsweeney and others added 6 commits October 16, 2026 11:44
Adds cuphoton.xray.synthetic_validation: a fixture of known damped modes
(the synthetic_trace modes plus white Gaussian noise), Cramer-Rao bounds
from the exact Fisher information of the same model, a Monte Carlo sweep
that reports per-mode bias, standard deviation and rmse of every
parameter against the bound together with the mode-loss rate, optional
model-mismatch traces with a residual-to-noise ratio, and a
schema_version 1 summary (config, runtime via runtime_metadata, results
per condition with attempted/successful/failed trials, artifacts).

The linear-prediction-validate (lpv) command runs the sweep and, with
--output-dir, writes summary.json and a Bokeh figure outside the
checkout. Documented in docs/xray/LINEAR-PREDICTION-VALIDATION.md.

The sweep is the reproducer for the mode loss discussed in NVIDIA#1: a lightly
damped mode whose fitted decay crosses zero under noise is dropped by
the
root filter. No default behaviour changes.

Refs NVIDIA#1

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014wyj5iPSHmtR3vSTvJWKfw
Signed-off-by: James Sweeney <jmsweene@gmail.com>
Signed-off-by: Trent Nelson <trentn@nvidia.com>
Keep small-trial summaries valid JSON, integrate the requested chirp,
and retain floating parameters for Fisher derivatives. Match nearby
modes globally and reject incompatible combined sweep settings.

Signed-off-by: Trent Nelson <trentn@nvidia.com>
Use the same amplitude and phase convention for truth, fitted modes,
and summary metadata so equivalent modes have zero parameter error.

Signed-off-by: Trent Nelson <trentn@nvidia.com>
Keep text formatting separate from command setup and execution.

Signed-off-by: Trent Nelson <trentn@nvidia.com>
Reject invalid numerical inputs before trials and distinguish
estimator exceptions from mode loss in the text report. Record
revisions only for tracked source checkouts, together with tracked-
file dirtiness.

Embed plot resources for offline use without changing Bokeh output
state. Clarify numerical Fisher bounds and conditional scatter, and
anchor the Gaussian distortion envelope at the first sample.

Signed-off-by: Trent Nelson <trentn@nvidia.com>
Report unidentifiable modes with the validation error context. Clarify
that the frequency standard-deviation bound uses the square root of
the closed-form variance.

Signed-off-by: Trent Nelson <trentn@nvidia.com>
tpn and others added 10 commits October 16, 2026 11:44
Signed-off-by: Trent Nelson <trentn@nvidia.com>
Give probe, validation, and benchmark results their own text formatting.
Keep batch aggregation and validation orchestration in the owning
modules, with commands routing reports through their injected output.

Signed-off-by: Trent Nelson <trentn@nvidia.com>
Use analytic derivatives and scaled singular values to reject
unidentifiable model parameters before reporting Cramer-Rao bounds.
Normalize frequency signs with phases so equivalent traces report
the same recovery and parameter statistics.

Signed-off-by: Trent Nelson <trentn@nvidia.com>
Keep recovered-mode count and frequency error ahead of decay error.
Compare assignment costs exactly so decay only resolves frequency ties,
including reversed modes and extra fitted candidates.

Signed-off-by: Trent Nelson <trentn@nvidia.com>
cuphoton.xray.mode_refinement refines the damped-mode model by nonlinear
least squares from the linear-prediction result (analytic Jacobian,
scipy.optimize.least_squares), seeding a mode the root filter dropped
from the residual spectrum; RefinedModes carries Jacobian uncertainties
and the residual rms. cuphoton.xray.mode_refinement_batched runs the
same Levenberg-Marquardt for a batch of traces on NumPy or CuPy and
matches the per-trace solver to about 1e-8.

linear-prediction-validate gains --refine, which adds the refined
estimator to the sweep and the summary;
linear-prediction-refine-benchmark (lprb) times the SciPy loop against
the batched solver on NumPy and CuPy (best of --repeat, transfers
excluded, warm-up call). examples/xray_lp_modes_review.py writes a Bokeh
review page of traces, reconstructions and modes. Documented in
docs/xray/LINEAR-PREDICTION-REFINEMENT.md with RTX 4050 numbers.

Overlaps the fit-diagnostics, iterative-fitting and GPU-batching work
the maintainers describe in NVIDIA#1; posted so the overlap can be sorted out.

Refs NVIDIA#1

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014wyj5iPSHmtR3vSTvJWKfw
Signed-off-by: James Sweeney <jmsweene@gmail.com>
Signed-off-by: Trent Nelson <trentn@nvidia.com>
Keep LP modal parameters relative to the first sample during refinement.
Recognize stationary starts and use positive diagonal damping so a
zero-amplitude mode does not make the batch solve singular.

Signed-off-by: Trent Nelson <trentn@nvidia.com>
Normalize Jacobian columns for batched solves and require a small
gradient to converge. Estimate local uncertainty with a rank-aware SVD
and report unavailable uncertainties for rank-deficient fits.

Signed-off-by: Trent Nelson <trentn@nvidia.com>
Keep the reproducible harness and explain the experimental fit scope,
local uncertainty assumptions, and convergence limits. Remove fixed-run
accuracy statistics and laptop timing tables.

Signed-off-by: Trent Nelson <trentn@nvidia.com>
Signed-off-by: Trent Nelson <trentn@nvidia.com>
Reject malformed fit inputs, seed from complete residual traces and keep
reported models consistent with canonical phases. Report convergence
alongside fit comparisons. Expose offline mode review through the CLI.

Exercise XRay CPU/CuPy parity in the existing GPU job.

Signed-off-by: Trent Nelson <trentn@nvidia.com>
@tpn
tpn force-pushed the xray-lp-refinement branch from 824edd0 to f342338 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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants