Skip to content

feat(cuda-module): expose concrete kernel signatures - #1252

Merged
nihalpasham merged 6 commits into
NVlabs:mainfrom
lucifer1004:feat/cuda-module-signatures-1251
Sep 24, 2026
Merged

nihalpasham merged 6 commits into
NVlabs:mainfrom
lucifer1004:feat/cuda-module-signatures-1251

Conversation

@lucifer1004

@lucifer1004 lucifer1004 commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

What this adds

Expose static host metadata for concrete kernel entries: PTX entry name, ordered source arguments and the carriers used by generated launchers.

source slice argument -> one descriptor -> pointer + length carriers

A kernel named step exports step_CUDA_SIGNATURE. Constants retain the kernel's visibility and configuration, and nested modules keep their own metadata.

What we fixed

  • Primitive aliases and shadowed names produce opaque host layout metadata. Absolute ::core::primitive and ::std::primitive paths retain scalar identity.
  • Lifetime-only kernels remain valid; case-distinct and raw kernel names remain distinct.
  • Updated the prerequisite stack to the merged codegen: support grid-constant kernel parameters #1225 implementation, retaining its full descriptor ABI and unsafe host launch contracts.

Verification

At 54afbfa4, hosted tests, lint/format checks, guards, docs/book and example compilation passed. CodeQL was still running at the final review check.

  • Complete cuda-host and cuda-macros suites passed with default and all features.
  • Semantic tests cover aliases, same-size shadowing, lifetimes, case-distinct names, raw identifiers, configuration and nested modules.
  • Strict Clippy and formatting passed.

Scope

Descriptors cover concrete entries and host launch carriers. They do not describe the complete device ABI or prove that a dynamic launch is safe. Generic entry registries and launch binders remain separate work.

Two inherited merge commits (f3850f30, e918d680) still lack DCO trailers. Their sign-off history needs resolving before landing; the new maintainer commit is signed off.

Partially addresses #1251.

Let #[kernel] declarations mark immutable reference parameters as grid constants, derive the generated host launch ABI from the same declaration, and carry pointee layout through MIR and LLVM lowering.

Emit LLVM byval alignment and NVVM grid_constant metadata, with compiler and SM120 contract coverage.

Signed-off-by: Zihua Wu <13583761+lucifer1004@users.noreply.github.com>
Signed-off-by: Zihua Wu <13583761+lucifer1004@users.noreply.github.com>
Signed-off-by: Zihua Wu <13583761+lucifer1004@users.noreply.github.com>
@nihalpasham nihalpasham added Depends Blocked on another PR/issue or an upstream dependency device-apis User-facing device-side and kernel-authoring APIs (cuda-device, cuda-macros) host-apis Host-side runtime APIs (cuda-host, cuda-core, cuda-async) needs-changes Review found changes required before this PR can land labels Sep 15, 2026

@nihalpasham nihalpasham 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.

Reviewed draft 64333820: changes requested on the metadata changes.

  • Scalar identity cannot come from the identifier text:
type f32 = u32;
kernel(value: f32)
  launcher: u32       descriptor: F32
  • Use resolved type identity, or opaque metadata where identity is unproven. Equal-size aliases also fail, so a size check is insufficient.
  • Preserve lifetime scope and distinct names: PhantomData<&'a ()> and step / STEP compile on the parent but fail with the new module constants.
  • Keep the draft blocked on #1225, and sign/complete DCO on the revised stack.

Ordinary host/macro tests pass; independent host-only controls confirm these three boundaries. #1251 remains partial.

Integrate current main to retain the merged grid-constant ABI and launch safety fixes. Keep ambiguous scalar spellings opaque, erase function lifetimes only for host layout queries, and preserve case in generated signature names.

Signed-off-by: nihalpasham <nihalp@nvidia.com>
nihalpasham
nihalpasham previously approved these changes Sep 24, 2026

@nihalpasham nihalpasham 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.

I fixed the metadata blockers in 54afbfa4 and brought the branch onto the merged #1225 implementation:

  • Ambiguous scalar names now report opaque layout metadata. Qualified core::primitive/std::primitive paths retain their scalar identity, so a shadowed f32 cannot be reported as a float.
  • Lifetime-only signatures retain valid layout queries.
  • Generated signature names preserve case; step and STEP no longer collide.
  • Added semantic regressions for aliases, lifetimes, raw names, configuration and nested modules.

The host and macro suites pass with default and all features, along with strict Clippy and formatting. The remaining diff is metadata only; current grid-constant ABI and unsafe launch contracts are preserved. This is a partial answer to #1251, not a complete device ABI or a safe dynamic launch binder.

@nihalpasham nihalpasham 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.

I fixed the metadata blockers in 54afbfa4 and brought the branch onto the merged #1225 implementation:

  • Ambiguous scalar names now report opaque layout metadata. Qualified core::primitive/std::primitive paths retain their scalar identity, so a shadowed f32 cannot be reported as a float.
  • Lifetime-only signatures retain valid layout queries.
  • Generated signature names preserve case; step and STEP no longer collide.
  • Added semantic regressions for aliases, lifetimes, raw names, configuration and nested modules.

The host and macro suites pass with default and all features, along with strict Clippy and formatting. The remaining diff is metadata only; current grid-constant ABI and unsafe launch contracts are preserved. This is a partial answer to #1251, not a complete device ABI or a safe dynamic launch binder.

At 54afbfa4, hosted tests, lint/format checks, guards, docs/book and example compilation passed. CodeQL was still running at the final review check.

@nihalpasham
nihalpasham marked this pull request as ready for review September 24, 2026 14:37
@nihalpasham
nihalpasham merged commit 806289e into NVlabs:main Sep 24, 2026
55 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Depends Blocked on another PR/issue or an upstream dependency device-apis User-facing device-side and kernel-authoring APIs (cuda-device, cuda-macros) host-apis Host-side runtime APIs (cuda-host, cuda-core, cuda-async) needs-changes Review found changes required before this PR can land

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants