Repository navigation
fix(codegen): reject invalid device architecture hints on both backends - #1256
Merged
Merged
Conversation
This was referenced Sep 19, 2026
…targets A device hint names the GPU in this machine. Preserve that distinction in a DeviceArch type: require sm_ spelling and reject family targets, whose compatibility set does not identify the detected device. Delegate capability and suffix grammar to CudaArch, preserving explicit compute_ and family compilation targets. All in-tree detected-device spellings remain representable. Signed-off-by: Sam, Joochul Chang <[email protected]>
Advisory hints may yield to a feature floor; they must not silently swallow virtual architectures or malformed input. Parse once at the frontend boundary, retain invalid values for one TargetSelection diagnostic, and validate before IKET can promote the hint to a hard target. Thread typed hints through both backends and reuse the rustc frontend value in mir-importer. Preserve explicit compute_ and family targets, no-hint feature floors, and every in-tree producer. Tests pin equal errors on both paths and the IKET ordering, including a positive control against the old source. Both 226-example container builds pass and all 624 collected artifacts are byte-identical. Signed-off-by: Sam, Joochul Chang <[email protected]>
Construct a private validated backend view once before IKET handling. Derive its DeviceArch from the same options and remove the raw hint from downstream controls, preventing callers from pairing invalid options with an absent proof. PTX generation and both resolvers now consume the proven hint without repeating fallible extraction. Move malformed-hint tests to shared entry and pin error precedence, real target propagation, and IKET provenance. Preserve explicit targets, feature floors, and frontend parsing. Validation: unit suites, all-targets codegen tests, clippy, formatting, guards, and 226 compile-only examples pass. Of 624 artifacts, 623 are byte-identical; the remaining PTX declaration-order difference reproduces from unchanged baseline IR with the same llc (both hashes observed in 12 runs). Signed-off-by: Sam, Joochul Chang <[email protected]>
Signed-off-by: nihalp <[email protected]>
nihalpasham
force-pushed
the
device-hint-spelling
branch
from
September 23, 2026 06:09
66c9bf6 to
617d13f
Compare
nihalpasham
approved these changes
Sep 23, 2026
Collaborator
There was a problem hiding this comment.
I kept the single typed hint boundary and added a regression for caller-supplied hints overriding the environment. Invalid hints now fail before either backend or IKET promotion, while explicit compilation targets keep their existing behavior.
The codegen, target and importer suites, strict Clippy and docs pass on the rebased branch. The IKET example also passes on RTX 5090 with automatic device detection. All seven hosted workflows passed at 617d13f4.
This addresses #1189.
vyncint
added a commit
to vyncint/cuda-oxide
that referenced
this pull request
Oct 11, 2026
Since NVIDIA#1256 the backend validates CUDA_OXIDE_DEVICE_ARCH once, at its input boundary, and hands selection a DeviceArch: a hint that does not parse is an error before either backend chooses a target. The three readings of a malformed hint this stack used to pin -- the floor resolver and the PTX selector ignoring it, the NVVM selector rejecting it -- no longer exist, so that test was dropped rather than carried forward. What the floor depends on now is narrower. cuda-device's build script reads the same variable with `parse::<DeviceArch>().ok()`, so its floor matches selection exactly when the boundary accepts the values that parse and rejects the rest. The new test asks both about the same inputs -- valid, blank, padded, bare, too short, virtual and family spellings -- and fails if they disagree. Making the boundary trim its input fails it on `" sm_86"`, which the build script would leave out while the backend selected it. The resolver's doc no longer says malformed hints are ignored, since the hint now reaches it parsed. Signed-off-by: Vyncint Ng <[email protected]>
vyncint
added a commit
to vyncint/cuda-oxide
that referenced
this pull request
Oct 22, 2026
Since NVIDIA#1256 the backend validates CUDA_OXIDE_DEVICE_ARCH once, at its input boundary, and hands selection a DeviceArch: a hint that does not parse is an error before either backend chooses a target. The three readings of a malformed hint this stack used to pin -- the floor resolver and the PTX selector ignoring it, the NVVM selector rejecting it -- no longer exist, so that test was dropped rather than carried forward. What the floor depends on now is narrower. cuda-device's build script reads the same variable with `parse::<DeviceArch>().ok()`, so its floor matches selection exactly when the boundary accepts the values that parse and rejects the rest. The new test asks both about the same inputs -- valid, blank, padded, bare, too short, virtual and family spellings -- and fails if they disagree. Making the boundary trim its input fails it on `" sm_86"`, which the build script would leave out while the backend selected it. The resolver's doc no longer says malformed hints are ignored, since the hint now reaches it parsed. Signed-off-by: Vyncint Ng <[email protected]>
vyncint
added a commit
to vyncint/cuda-oxide
that referenced
this pull request
Oct 30, 2026
Since NVIDIA#1256 the backend validates CUDA_OXIDE_DEVICE_ARCH once, at its input boundary, and hands selection a DeviceArch: a hint that does not parse is an error before either backend chooses a target. The three readings of a malformed hint this stack used to pin -- the floor resolver and the PTX selector ignoring it, the NVVM selector rejecting it -- no longer exist, so that test was dropped rather than carried forward. What the floor depends on now is narrower. cuda-device's build script reads the same variable with `parse::<DeviceArch>().ok()`, so its floor matches selection exactly when the boundary accepts the values that parse and rejects the rest. The new test asks both about the same inputs -- valid, blank, padded, bare, too short, virtual and family spellings -- and fails if they disagree. Making the boundary trim its input fails it on `" sm_86"`, which the build script would leave out while the backend selected it. The resolver's doc no longer says malformed hints are ignored, since the hint now reaches it parsed. Signed-off-by: Vyncint Ng <[email protected]>
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.
What this fixes
A device hint identifies the local GPU. The PTX and NVVM paths previously treated
compute_120differently; IKET could promote the unvalidated string into an explicit target.DeviceArchacceptssm_<capability>with an optionalasuffix. The shared pipeline validates the hint before materialization, while valid hints remain advisory and explicit compilation targets retain their existing vocabulary.Maintainer follow-up
Rebased onto current main and added an isolated-process regression proving that a supplied typed hint still overrides an invalid environment hint. Absence continues to consult the environment.
Verification
compute_, family and non-Unicode hints; both backends and IKET are covered.617d13f4. The IKET example passed on RTX 5090 with automatic device detection, checking 1,024 elements.Closes #1189.