Skip to content

build: depend on the shared host crates by path at tip of tree - #1466

Merged
elibol merged 1 commit into
NVIDIA:mainfrom
elibol:build/host-crates-tip-of-tree
Oct 9, 2026
Merged

elibol merged 1 commit into
NVIDIA:mainfrom
elibol:build/host-crates-tip-of-tree

Conversation

@elibol

@elibol elibol commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator

First PR under #1459.

cuda-oxide depends on the shared host crates by path, but the dependency lines also carried version = "=0.4.0", and check-shared-crate-pin.sh required that exact string in all 234 example workspaces and in the cargo oxide new scaffold. Every host-crate release therefore meant editing cuda-oxide's manifest, every example manifest, the scaffold constant, and the license inventory before the tree was consistent again.

This drops the version requirement from every in-tree path dependency on cuda-bindings, cuda-core, and cuda-async: the three workspace lines and 238 lines across the example manifests. A path dependency with no version always resolves to the sibling directory, so cuda-oxide now tracks the host crates at tip of tree. Nothing in this tree that depends on them (cuda-host, cuda-macros, the examples) is published, so nothing needs the version. Lockfiles are unchanged; the touched example workspaces still pass cargo metadata --locked.

check-shared-crate-pin.sh keeps its name and its CI job but checks the new invariant: the four root crates agree on a version, in-tree manifests name the host crates as path dependencies with no version, and the scaffold's SHARED_HOST_CRATES_VERSION, the one place a crates.io version lives (out-of-tree projects cannot use the git-root paths), equals the root crates' version. It rejects a reintroduced version field; I checked that by hand. Deriving the scaffold constant from the root manifests at build time is the next PR under #1459.

The four host-crate rows in dependency-licenses.csv now record path instead of a version number; check-dependency-licenses.sh compares names only, so they remain valid.

cuda-oxide path-depends on cuda-bindings, cuda-core, and cuda-async at the
git root, but the dependency lines also carried version = "=0.4.0", and
check-shared-crate-pin.sh required that exact string in every example
workspace and in the cargo oxide new scaffold. A host-crate release meant
editing this manifest, 234 example manifests, the scaffold constant, and the
license inventory before the tree was consistent again.

Drop the version requirement from every in-tree path dependency on the host
crates. A path dependency with no version resolves to the sibling directory,
so cuda-oxide tracks the host crates at tip of tree, and nothing in this tree
that depends on them is published, so nothing needs the version. Lockfiles
are unchanged.

check-shared-crate-pin.sh keeps its name and CI job but checks the new
invariant: the four root crates agree on a version, in-tree manifests name
the host crates as path dependencies with no version, and the scaffold's
SHARED_HOST_CRATES_VERSION, the one place a crates.io version lives for
out-of-tree projects, equals the root crates' version.

The four host-crate rows in dependency-licenses.csv record "path" instead of
a version number; the checker compares names only.

First PR under NVIDIA#1459.

Signed-off-by: Melih Elibol <[email protected]>
@elibol elibol added the build-related Build scripts, toolchain discovery, or compilation setup label Oct 9, 2026
@elibol
elibol requested a review from nihalpasham as a code owner October 9, 2026 00:14
@elibol elibol added cuda-oxide SIMT programming model: rustc backend, cargo oxide, cuda-device, cuda-host, book runtime Shared runtime crates: cuda-bindings, cuda-core, cuda-core-derive, cuda-async; Tile and SIMT co-own labels Oct 9, 2026
@elibol elibol added build-related Build scripts, toolchain discovery, or compilation setup cuda-oxide SIMT programming model: rustc backend, cargo oxide, cuda-device, cuda-host, book runtime Shared runtime crates: cuda-bindings, cuda-core, cuda-core-derive, cuda-async; Tile and SIMT co-own labels Oct 9, 2026
@elibol
elibol removed request for cryos and roivanov October 9, 2026 00:16
@nihalpasham

nihalpasham commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

Thanks, @elibol - removing the repeated in-tree version requirements looks good to me.

I'm comfortable treating this build cleanup independently of #1460 and #1461. I'll handle changes to cargo-oxide, including how cargo oxide new gets the runtime version for generated projects.

One small suggestion: please keep the script checking whether a required dependency is missing from Cargo.toml. The updated script misses that case. Cargo would still report the error later, so this doesn’t block the PR.

This partially addresses #1459.

@elibol
elibol merged commit bafffe4 into NVIDIA:main Oct 9, 2026
60 checks passed
nihalpasham added a commit that referenced this pull request Oct 15, 2026
…t source (#1488)

## What this adds

`cargo oxide new` wrote a manifest that took `cuda-device` and
`cuda-host` from the repository's git URL but `cuda-core` (and
`cuda-async` with `--async`) from crates.io 0.4.0. `cuda-host` depends
on `cuda-core` by path inside that checkout, so every scaffolded project
resolved two `cuda-core` packages and the code `#[cuda_module]`
generates failed to type-check. The templates now name every CUDA crate
from the same git source, so cargo resolves one copy of each.

```text
Before:  cuda-host = { git = <repo> }   cuda-core = "0.4.0"
         Cargo.lock: cuda-core x2 (registry + git), cuda-bindings x2, cuda-core-derive x2
         error[E0308]: expected `cuda_core::simt::context::CudaContext`, found `CudaContext`
         7 errors sync, 13 errors async; nothing runs

After:   cuda-host = { git = <repo> }   cuda-core = { git = <repo> }   cuda-async = { git = <repo> }
         Cargo.lock: cuda-core x1, cuda-bindings x1, cuda-core-derive x1, all at one commit
         PASSED: all 1024 elements correct
```

```rust
#[cuda_module]
mod kernels {
    #[kernel]
    pub fn vecadd(a: &[f32], b: &[f32], mut c: DisjointSlice<f32>) { /* ... */ }
}
let module = unsafe { kernels::load(&ctx)? }; // generated code names cuda-host's CudaContext
```

## What we fixed

- Both templates take `cuda-core` and `cuda-async` from `GIT_REPO`, the
source `cuda-host` comes from; `SHARED_HOST_CRATES_VERSION` is gone.
- `check-shared-crate-pin.sh` section 3 requires `git = "{GIT_REPO}"` on
every host-crate line in the templates and rejects a crates.io
requirement there.
- New test `scaffold_takes_every_cuda_crate_from_one_git_source` asserts
every `cuda-*` line in both templates names the same git source as
`cuda-device`.
- The manifest comment and the status-guard step name that still
described a crates.io scaffold now describe the git source.

## Scaffold dependency contract

Every CUDA crate in a new project comes from one git source with no
version requirement. The first build locks all of them to one commit of
that repository, and `cargo update` moves them together. A crates.io
`cuda-core` or `cuda-async` beside a git `cuda-host` is always a second
crate and does not compile.

<details><summary>Implementation</summary>

- The regression began at bd6c3ce (#29, 2026-10-01), which moved
`cuda-oxide` from crates.io `cuda-core` 0.3.1 onto the git-root path
copies while the scaffold kept its crates.io constant; #1466 only
dropped the `version = "=0.4.0"` qualifier. Lockfiles resolved at the
commit before #29 hold one `cuda-core`; at #29, before #1466 and at
#1466 they hold two.
- Cargo identifies a package by name, version and source. A path
dependency declared inside a git-sourced crate resolves to that git
source, and nothing unifies it with a registry copy, so the scaffold has
to name `cuda-core` from the source `cuda-host` uses.
- This is the pre-#1102 form of the template minus `cuda-bindings`,
which no user code names and which `cuda-core` pulls by path.
- The failures are identity mismatches on `CudaContext`, `CudaModule`,
`DeviceBuffer` and the `DriverError` closure: 6 E0308 plus 1 E0277 in
the sync template; 9 E0308, 3 E0277 and 1 E0599 in the async one.
- This supersedes the #1466 plan to derive the scaffold's version from
the root manifests: with no version in the template there is nothing to
derive.

</details>

## Verification

Checked at `180770a9`:

- ✅ `cargo test -p cargo-oxide --all-targets`: 244 passed. With the old
template lines restored and the new tests kept, 3 scaffold tests fail.
- ✅ `cargo clippy -p cargo-oxide --all-targets -- -D warnings`, `cargo
fmt --check` and rustdoc with `-D warnings` clean.
- ✅ All 18 `check-*.sh` guards pass. `check-shared-crate-pin.sh` rejects
four reintroduced forms (`cuda-core = "0.4.0"`, `{ version = "0.4.0" }`,
a different git URL, `cuda-async = "0.4.0"`) with exit 1.
- ✅ Baseline: main's `cargo oxide new` for both templates fails to
build, 7 and 13 errors, with two `cuda-core`, `cuda-bindings` and
`cuda-core-derive` per lockfile (and two `cuda-async`).
- ✅ Fix: `cargo oxide new` then `cargo oxide run` for both templates on
an RTX 5090 (sm_120a, CUDA 13.4): `PASSED: all 1024 elements correct`,
`compute-sanitizer --tool memcheck` 0 errors, one `cuda-core` per
lockfile and zero registry `cuda-*` packages. Same result on the
author's RTX 5060 Laptop (sm_120, CUDA 13.3).
- ✅ Merges cleanly with #1489 in either order; after both, every
template line names `https://github.com/NVIDIA/cuda-rust.git`.

## Caveats

- The test and guard compare the git URL only. A `rev`, `branch` or
`tag` added to one line still resolves a second `cuda-core`, even at the
same commit; a follow-up tightens the comparison to the full source.
- No CI job compiles a scaffolded project, which is how the broken
template survived from 2026-10-01; a scaffold compile gate is a separate
follow-up.
- The GPU runs used a cached backend; the standalone backend build from
the scaffold's git checkout is unchanged by this PR and was not re-run
here.
- `GIT_REPO` still names `NVlabs/cuda-oxide`, which GitHub redirects;
#1489 renames it.

Closes #1459.

---------

Signed-off-by: Alejandro Soto Franco <[email protected]>
Signed-off-by: nihalpasham <[email protected]>
Co-authored-by: nihalpasham <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build-related Build scripts, toolchain discovery, or compilation setup cuda-oxide SIMT programming model: rustc backend, cargo oxide, cuda-device, cuda-host, book runtime Shared runtime crates: cuda-bindings, cuda-core, cuda-core-derive, cuda-async; Tile and SIMT co-own

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants