Repository navigation
Conversation
Signed-off-by: kaix-nv <[email protected]>
|
/claude review |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe sparsity policy now validates decay tensors directly, converts them to CPU ChangesDecay policy validation and rounding
Estimated code review effort: 2 (Simple) | ~12 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to The updated decay validation and rounding behavior is covered by matching tests and documentation, with no current merge-blocking risk identified. 🚥 Pre-merge checks | ✅ 6✅ Passed checks (6 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
| cast_dtypes = tuple(dict.fromkeys((storage_dtype, tensor.dtype))) | ||
| cast_dtypes = tuple( | ||
| dtype | ||
| for dtype in cast_dtypes | ||
| if not any( | ||
| dtype != other and _dtype_exactly_contains(other, dtype) for other in cast_dtypes | ||
| ) | ||
| ) |
There was a problem hiding this comment.
[SUGGESTION] The containment filter is correct for every dtype pair reachable here, but it is built as an O(n²) any() scan plus a second rebinding of cast_dtypes over a tuple that can never hold more than two entries — and it can in principle produce an empty tuple.
Two things worth tightening:
-
Readability / single assignment.
cast_dtypesis assigned twice in a row, and the reader has to work out that_dtype_exactly_contains(other, dtype)dropsdtype(the wider dtype) rather thanother. The three reachable outcomes — drop storage, drop live, keep both — are easier to read stated directly. -
The empty-tuple case yields zero slack, silently. If both dtypes were dropped, the
forloop never executes,upperstays equal tovalues, and the function returns exactly0._storage_cast_horizon_boundswould then demand bit-exact horizon agreement, and the resultingApplyModeErrorwould point at the parameters rather than at the dtype pair. That requires two distinct dtypes with identical(max, eps, tiny*eps), which no currenttorchfloat dtype pair satisfies (I checked the fp8 variants —e5m2/e5m2fnuzmatch onmaxandepsbut differ in smallest subnormal), so this is not a live bug. It is a sharp edge that disappears for free with an explicit branch.
Both are addressed by replacing the two statements with:
live_dtype = tensor.dtype
if _dtype_exactly_contains(live_dtype, storage_dtype):
cast_dtypes = (live_dtype,)
elif _dtype_exactly_contains(storage_dtype, live_dtype):
cast_dtypes = (storage_dtype,)
else:
cast_dtypes = (storage_dtype, live_dtype)This also subsumes the dict.fromkeys dedup: when the dtypes are equal both predicates hold, the first branch wins, and the result is the single-dtype tuple the old code produced. Non-blocking.
There was a problem hiding this comment.
Addressed in #2393. The containment scan is replaced with the explicit three-way branch, which guarantees one or two bound dtypes and makes the keep-live, keep-storage, and compose-both cases direct.
|
Claude review summary Scope: full review (the trigger comment carried no scoping instructions). 3 files changed / +35 −16 — all three reviewed: Findings — CRITICAL: 0, IMPORTANT: 0, SUGGESTION: 1 What I verified
The filter drops the right dtype. The tightening cannot cause false rejections of previously-valid policies — the main backward-compat risk I looked for, since
In every narrowed row the dropped leg is exact for that value, so the retained inverse bound Helper removal is clean. Docs match the code. The rewritten paragraph in The one suggestion Inline on Not flagged Two pre-existing items I looked at and deliberately left alone, since neither is introduced here and CONTRIBUTING asks for surgical changes: Risk: low. A narrow, well-tested numerical tightening in a single private helper, with the new FP16/BF16 widening regressions pinning the behavior. The author reports 27 passed / 1 skipped locally; I could not execute the suite in this sandbox, so the numerical reasoning above is analytical rather than empirical. 🤖 Generated with Claude Code |
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## feature/dasc-state-sparsity-review-contract-cleanup #2392 +/- ##
========================================================================================
+ Coverage 68.74% 78.78% +10.03%
========================================================================================
Files 548 548
Lines 64220 64228 +8
========================================================================================
+ Hits 44151 50600 +6449
+ Misses 20069 13628 -6441
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Addresses the final non-blocking review suggestion on #2392. Changes: - replace the generic containment filter with an explicit three-way dtype selection - guarantee a non-empty bound tuple - make the exact outcomes obvious: keep live, keep storage, or compose both Validation: - focused DASC tests: 27 passed, 1 skipped (optional Megatron dependency) - pre-commit on the touched file: passed Commit is ED25519-signed and carries a matching Signed-off-by trailer. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - Improved numerical handling when determining storage rounding behavior across different data types. - Ensured cast sequences are selected according to exact representability between live and storage formats. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Signed-off-by: kaix-nv <[email protected]>
6456c40
into
feature/dasc-state-sparsity-review-contract-cleanup
Addresses the final numerical-bound and cleanup review findings.
Changes:
Validation:
Commit is ED25519-signed and carries a matching Signed-off-by trailer.
Summary by CodeRabbit
Bug Fixes
Tests
Documentation