Skip to content

Validate checkpoint contracts before constructing xScan models - #105

Merged
tpn merged 1 commit into
mainfrom
codex/checkpoint-preflight-20261019
Oct 20, 2026
Merged

tpn merged 1 commit into
mainfrom
codex/checkpoint-preflight-20261019

Conversation

@tpn

@tpn tpn commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator

The xScan device pipeline and stage benchmark checked checkpoint dimensions and feature identity after constructing, transferring, and optionally compiling the model. An incompatible checkpoint could therefore incur expensive setup before reporting the mismatch.

Let the loader run the existing contract validator immediately after checkpoint deserialization, and use it in both consumers. Existing policy, model, device, and file-identity checks remain in place. This change does not limit checkpoint deserialization or valid model sizes.

Validation: 106 focused tests passed; 50 optional GPU tests skipped. The regression exercises the real loader for both consumers and rejects incompatible image size and feature identity before model construction. All repository pre-commit checks passed.

@tpn
tpn requested a review from melo-gonzo as a code owner October 19, 2026 16:39
@tpn tpn added the ai-review Request a focused CodeRabbit review label Oct 19, 2026
@tpn

tpn commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@tpn
tpn force-pushed the codex/checkpoint-preflight-20261019 branch from 80065a0 to 0564170 Compare October 19, 2026 16:43
@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration
  • Configuration used: Repository: NVIDIA/cuPhoton/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Enterprise
  • Run ID: 1b3bbfb4-1342-4907-a6c4-5350975d1c4a
📥 Commits

Reviewing files that changed from the base of the PR and between 0564170 and 5c0421d.

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

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: 002a3929-686d-455a-bf9e-ba4c4c43e061
📥 Commits

Reviewing files that changed from the base of the PR and between ffb1d38 and 0564170.

📒 Files selected for processing: 5
  • src/cuphoton/xscan/device_pipeline.py
  • src/cuphoton/xscan/pipeline_benchmark/stages.py
  • src/cuphoton/xscan/training.py
  • tests/xscan/test_device_pipeline.py
  • tests/xscan/test_tensor_inference.py

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

📝 Walkthrough

The model loader now accepts an optional checkpoint validator and calls it before model construction. Worker initialization and benchmark setup pass checkpoint-contract validation to the loader. Tests cover validation order and callback behavior.

Changes: Checkpoint validation

Layer / File(s) Summary
Add a loader validation hook
src/cuphoton/xscan/training.py, tests/xscan/test_tensor_inference.py
load_model_from_checkpoint accepts an optional validator and invokes it on the loaded checkpoint before building the model. Tests check that the callback receives the returned checkpoint once.
Wire validation into worker and benchmark setup
src/cuphoton/xscan/device_pipeline.py, src/cuphoton/xscan/pipeline_benchmark/stages.py, tests/xscan/test_device_pipeline.py
Worker initialization and benchmark setup pass checkpoint-contract validation to the loader. Tests check that image-size and feature-identity mismatches raise before model construction.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 05641

Checkpoint contract checks now run before model construction in both setup paths. No actionable issue remains from this review.

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.
  • 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 Oct 19, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Already reviewed the last commit. Use @coderabbitai full review to rerun a review of the entire changeset.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@melo-gonzo melo-gonzo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM. Checkpoint contracts now fail before model construction while preserving existing loader behavior. Focused CPU tests, rejection probes, and both selected GPU pipeline tests passed. Deserialization still precedes validation.

Let the checkpoint loader run an optional validator after
deserialization and before model construction. Bind the worker and
benchmark contract checks there so incompatible dimensions or feature
identities fail early.

Signed-off-by: Trent Nelson <trentn@nvidia.com>
@tpn
tpn force-pushed the codex/checkpoint-preflight-20261019 branch from 0564170 to 5c0421d Compare October 20, 2026 02:10
@tpn
tpn merged commit 0dc772a into main Oct 20, 2026
116 of 127 checks passed
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.

2 participants