You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
#[cuda_module] and #[kernel] emit host-only code, so a device-only kernel crate still needs cuda.h #701
#[cuda_module] and #[kernel] emit host-only code into the consumer crate — LoadedModule, load/load_named/from_module, the launch/prepare-launch/constant methods, and the CudaKernel marker impl. All of it names ::cuda_host / ::cuda_core, so a crate that only compiles kernels and never loads or launches anything still has to depend on cuda-host → cuda-core → cuda-bindings → cuda.h. That makes a device-only kernel crate unbuildable anywhere without a CUDA toolkit, including on a developer machine doing a type-check.
Proposed API / behavior
[dependencies]
cuda-device = "0.2"cuda-macros = { version = "0.2", default-features = false } # no `host`
#[kernel]pubfnscale(out:*mutf32,n:usize){/* ... */}// compiles with no cuda-host in the tree
Alternatives considered
Adding cuda-host purely to satisfy the expansion, which is what we do today; it pulls bindgen and a cuda.h requirement into a crate that emits no host code. Splitting the kernels into a crate that avoids #[cuda_module] doesn't help, because bare #[kernel] emits impl cuda_host::CudaKernel too.
Additional context
The async feature in cuda-macros/src/lib.rs already gates emitted host items the same way, so there is an in-file precedent for the shape.
No host crates in the graph.cargo metadata resolves 8 packages — cuda-device, cuda-macros, reserved-oxide-symbols, proc-macro2, quote, syn, unicode-ident, and the crate itself. cuda-host, cuda-core and cuda-bindings are absent, so there is no cuda.h requirement to inherit.
It type-checks with no CUDA toolkit.cargo check succeeds with CUDA_HOME, CUDA_TOOLKIT_PATH and LIBRARY_PATH all unset. (It needs the pinned nightly from rust-toolchain.toml, since cuda-macros uses proc_macro_def_site — unrelated to this issue.)
The manifest comment added by #702 also documents the mixed-graph trap this shape carries: proc-macro features unify per build graph, so a device-only crate consumed by a host application has to forward the feature itself (host = ["dep:cuda-host", "cuda-macros/host"]) or the expansion emits cuda_host:: paths it cannot resolve.
One gap worth noting, which is why I am commenting rather than just asking you to close: nothing in the tree exercises the device-only configuration. No example or CI leg builds with default-features = false, and the failure mode above is exactly the kind that returns quietly. Happy to add a fixture crate plus a guard script wired into check-guards / status-guard.yml if you want that; it needs no GPU and no toolkit, which is the point.
Closing: the behavior this asked for landed in #702 (device-only kernel crates build with --no-default-features, no cuda.h needed), and the one item left in this thread was coverage, which #844 adds:
ci: cover the device-only kernel build that #702 made possible #844: CI now builds an out-of-workspace device-only fixture on every PR, so the gate cannot silently regress (cargo-hack could not express this check: cuda-macros dev-depends on cuda-host, which feature unification turns back on).
Activity
vyncint commentedon Aug 12, 2026
This appears to be resolved by #702, which put the generated host surface behind a default-on
hostfeature — the exact shape proposed here.Verified on
15fa9d9dwith a throwaway crate outside the repo, taking the dependency lines from this issue verbatim:Both halves of the ask hold:
cargo metadataresolves 8 packages —cuda-device,cuda-macros,reserved-oxide-symbols,proc-macro2,quote,syn,unicode-ident, and the crate itself.cuda-host,cuda-coreandcuda-bindingsare absent, so there is nocuda.hrequirement to inherit.cargo checksucceeds withCUDA_HOME,CUDA_TOOLKIT_PATHandLIBRARY_PATHall unset. (It needs the pinned nightly fromrust-toolchain.toml, sincecuda-macrosusesproc_macro_def_site— unrelated to this issue.)The manifest comment added by #702 also documents the mixed-graph trap this shape carries: proc-macro features unify per build graph, so a device-only crate consumed by a host application has to forward the feature itself (
host = ["dep:cuda-host", "cuda-macros/host"]) or the expansion emitscuda_host::paths it cannot resolve.One gap worth noting, which is why I am commenting rather than just asking you to close: nothing in the tree exercises the device-only configuration. No example or CI leg builds with
default-features = false, and the failure mode above is exactly the kind that returns quietly. Happy to add a fixture crate plus a guard script wired intocheck-guards/status-guard.ymlif you want that; it needs no GPU and no toolkit, which is the point.ci: cover the device-only kernel build that #702 made possible (#844)
nihalpasham commentedon Aug 13, 2026
Closing: the behavior this asked for landed in #702 (device-only kernel crates build with
--no-default-features, no cuda.h needed), and the one item left in this thread was coverage, which #844 adds:hostfeature #702:#[cuda_module]/#[kernel]gate their host-side expansion behind thehostfeature;ci: nothing checks the formatting of the device-only fixture (#1027)
ci: clippy skips three nested example workspaces and the device-only …
ci: cargo-deny reaches two of the three non-example workspace roots (#…
fix(ci): the license inventory guard reads two of the three workspace…