Repository navigation
Construct a disjoint slice when a kernel builds one - #670
Merged
nihalpasham merged 1 commit intoAug 6, 2026
Merged
nihalpasham merged 1 commit into
nihalpasham merged 1 commit into
Conversation
`DisjointSlice::from_raw_parts` writes a struct literal. The literal
usually folds into its use before import, and it survives whenever the
slice crosses a call the optimiser keeps, such as a `#[device]` helper
taking `&mut DisjointSlice`. The type translator gives the ADT its own
slice type rather than a struct, so the aggregate arm took it for a
scalar-lowered newtype, looked for the one field carrying the collapsed
scalar type, found none, and refused the program:
Scalar-lowered ADT expected exactly one runtime field, found 0
Add `mir.construct_disjoint_slice`, taking the data pointer, the element
count and the runtime layout words the index space carries.
`mir.construct_slice` cannot serve: its result is a `MirSliceType` and
its arity is fixed at two, while a runtime row width adds a word after
`{ ptr, len }`. Lowering is the same insert chain one field longer,
built through `make_disjoint_slice_struct` so the field order cannot
drift from the layout `resolve_aggregate_slots` indexes identically.
Field selection in the importer is positional, and the op's verifier
checks it against the result type: the data pointer must point to the
element type, the length must be an integer, and each remaining operand
must match the index space's layout types in order. A reordered or
retyped field therefore fails verification rather than writing a row
width into the length slot.
Tests: the reported repro as `disjoint_from_raw_parts`, alongside a
runtime row width of 37 so the three-word form runs on GPU; lowering
unit tests pinning both slot layouts; verifier unit tests for a missing
space operand, a surplus one, a mismatched width type and a plain slice
result.
Closes NVIDIA#667.
Collaborator
|
Verified the new op and the fix on hardware:
Closes #667. |
nihalpasham
approved these changes
Aug 6, 2026
nihalpasham
added a commit
that referenced
this pull request
Aug 6, 2026
…test verdict requires Merging #670 (new example) and #665 (stricter smoketest verdicts) in the same batch left this example failing the standard-category check: both kernels verify to exact match but nothing prints SUCCESS/PASS/Complete, and the stricter harness rightly no longer rescues such a log.
vyncint
added a commit
to vyncint/cuda-oxide
that referenced
this pull request
Aug 6, 2026
scripts/smoketest.sh assumes two things about the examples that nothing verified, and neither is reachable without a GPU: the compile-only lane collapses every category into verdict_compile, so it exercises neither classify() nor the standard-category success marker. A `standard` example that verifies its results but prints no SUCCESS/PASS/Complete marker is reported as FAIL (no success marker). That landed two days ago: 981b9eb added a marker to disjoint_from_raw_parts on main after NVIDIA#670 (the new example) and NVIDIA#665 (stricter verdicts) merged in one batch. Nothing in an example's own directory says a marker is required, and its author cannot see the consequence without hardware. Separately, classify() falls through to `standard` for anything its seven arrays do not claim, so a misspelled or renamed entry does not fail -- it matches nothing and the example quietly gets the wrong verdict rules. All 45 entries across the 11 arrays are valid today, so that half is preventive. Add scripts/check-example-smoketest-contract.sh and run it from status-guard.yml, next to the existing guard that keeps ERROR_EXAMPLES and STATUS.md in step. It reads sources only: no cargo, no toolkit, no LLVM. The guard duplicates two of verdict_standard's greps, so it pins that coupling: if smoketest.sh stops grepping SUCCESS|PASS|Complete, or changes the skip pattern, the guard says so instead of quietly checking a contract that no longer exists. Following NVIDIA#643 it also fails closed on a missing python3 and on a parse self-test, rather than reporting success from a check that could not run. Fixes NVIDIA#682 Signed-off-by: Vyncint Ng <[email protected]>
nihalpasham
pushed a commit
that referenced
this pull request
Aug 7, 2026
…#683) scripts/smoketest.sh assumes two things about the examples that nothing verified, and neither is reachable without a GPU: the compile-only lane collapses every category into verdict_compile, so it exercises neither classify() nor the standard-category success marker. A `standard` example that verifies its results but prints no SUCCESS/PASS/Complete marker is reported as FAIL (no success marker). That landed two days ago: 981b9eb added a marker to disjoint_from_raw_parts on main after #670 (the new example) and #665 (stricter verdicts) merged in one batch. Nothing in an example's own directory says a marker is required, and its author cannot see the consequence without hardware. Separately, classify() falls through to `standard` for anything its seven arrays do not claim, so a misspelled or renamed entry does not fail -- it matches nothing and the example quietly gets the wrong verdict rules. All 45 entries across the 11 arrays are valid today, so that half is preventive. Add scripts/check-example-smoketest-contract.sh and run it from status-guard.yml, next to the existing guard that keeps ERROR_EXAMPLES and STATUS.md in step. It reads sources only: no cargo, no toolkit, no LLVM. The guard duplicates two of verdict_standard's greps, so it pins that coupling: if smoketest.sh stops grepping SUCCESS|PASS|Complete, or changes the skip pattern, the guard says so instead of quietly checking a contract that no longer exists. Following #643 it also fails closed on a missing python3 and on a parse self-test, rather than reporting success from a check that could not run. Fixes #682 Signed-off-by: Vyncint Ng <[email protected]>
alejandro-soto-franco
deleted the
fix/disjoint-slice-aggregate-construction
branch
September 9, 2026 17:08
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Building a
DisjointSliceinside a kernel fails device codegen whenever the construction survives optimisation, which it does as soon as the slice crosses a call.What
DisjointSlice::from_raw_partsfails device codegen when the slice crosses a#[device]boundary:The constructor writes a struct literal. That literal usually folds into its use before import, and it survives whenever the slice crosses a call the optimiser keeps. The type translator gives the ADT its own slice type rather than a struct, so the aggregate arm took it for a scalar-lowered newtype, looked for the one field carrying the collapsed scalar type, and found none.
How
mir.construct_disjoint_slicetakes the data pointer, the element count and the runtime layout words the index space carries.mir.construct_slicecannot serve: its result is aMirSliceTypeand its arity is fixed at two, while a runtime row width adds a word after{ ptr, len }.Lowering is the same insert chain one field longer, built through
make_disjoint_slice_structso the field order cannot drift from the layoutresolve_aggregate_slotsindexes identically.Field selection in the importer is positional, and the op's verifier checks it against the result type: the data pointer must point to the element type, the length must be an integer, and each remaining operand must match the index space's layout types in order. A reordered or retyped field fails verification rather than writing a row width into the length slot.
Testing
On an RTX 5060 (sm_120):
disjoint_from_raw_partscovers both shapes. The two-word form increments 4096 elements, and the three-word form scales 888 elements at a row width of 37, which is neither a power of two nor a multiple of the block width. Every element's expected value depends on its own index, so a constant write or a misaddressed element reports a mismatch. Both exact.cargo test --workspaceandcargo clippy --workspace --all-targetsclean.Closes #667.