Skip to content

fix(cargo-oxide): scaffold and clone from NVIDIA/cuda-rust - #1489

Merged
nihalpasham merged 2 commits into
NVIDIA:mainfrom
alejandro-soto-franco:fix/cargo-oxide-cuda-rust-url
Oct 15, 2026
Merged

nihalpasham merged 2 commits into
NVIDIA:mainfrom
alejandro-soto-franco:fix/cargo-oxide-cuda-rust-url

Conversation

@alejandro-soto-franco

@alejandro-soto-franco alejandro-soto-franco commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

What this adds

cargo oxide new writes the repository address of cuda-device and cuda-host into every new project's manifest, and the backend fallback clone fetches the same address when no cuda-oxide dependency pins a commit. Both still named the pre-move NVlabs/cuda-oxide repository, which resolves only through GitHub's redirect and leaves every new lockfile recording the old source. Both now name NVIDIA/cuda-rust.

cargo oxide new demo

Before  cuda-device = { git = "https://github.com/NVlabs/cuda-oxide.git" }
        source = "git+https://github.com/NVlabs/cuda-oxide.git#bc46b1ff..."   (via redirect)
        checkout ~/.cargo/git/checkouts/cuda-oxide-<hash>/bc46b1f/

After   cuda-device = { git = "https://github.com/NVIDIA/cuda-rust.git" }
        source = "git+https://github.com/NVIDIA/cuda-rust.git#bc46b1ff..."    (direct)
        checkout ~/.cargo/git/checkouts/cuda-rust-<hash>/bc46b1f/
cargo oxide new demo && cd demo
cargo oxide build   # builds the backend from the checkout Cargo made for cuda-device

What we fixed

  • GIT_REPO in scaffold.rs, interpolated into both scaffold templates, now reads https://github.com/NVIDIA/cuda-rust.git.
  • The fallback git clone --depth 1 in backend.rs, used only for projects with no cuda-oxide dependency, clones the same address.
  • The backend_source.rs module diagram, its test constant and the matching README diagram follow: the checkout is cuda-rust-<hash>, and the backend crate and the toolchain pin sit under cuda-oxide/ in it.
  • A scaffold test asserts the emitted git = "https://github.com/NVIDIA/cuda-rust.git" lines in both templates and rejects the old address.
Implementation
  • Backend discovery never reads the URL: dependency_source_from_metadata keys on the package name and manifest_path, git_source_rev keeps only the #<sha> fragment, and checkout_root walks up to the first directory holding Cargo.toml plus the codegen crate, bounded by .git or .cargo-ok.
  • codegen_crate_in_checkout prefers cuda-oxide/crates/rustc-codegen-cuda and falls back to the historical flat crates/rustc-codegen-cuda; pinned_channel walks from the codegen crate upward, so the component nightly wins over the stable pin at the git root. The same two functions serve the fallback clone.
  • The backend cache is keyed by commit (source-rev.txt), not by URL, so cached backends and existing projects are unaffected.
  • The historical issue permalink to NVlabs/cuda-oxide/issues/96 in the README stays, per the repository guide.

Verification

Checked at 746d60eb:

Caveats

`cargo oxide new` wrote git = "https://github.com/NVlabs/cuda-oxide.git"
into every new project's manifest. Each Cargo.lock it produced then recorded
the old repository as the dependency source. The backend fallback clone,
used when no cuda-device or cuda-host dependency pins a commit, fetched the
same URL. Both reached the repository only through GitHub's redirect.

Cached backends and existing projects are unaffected. Backend discovery
reads the checkout's manifest path and never its URL, and it already handles
the nested cuda-oxide/crates layout.

Signed-off-by: Alejandro Soto Franco <sotofranco.eng@gmail.com>
@copy-pr-bot

copy-pr-bot Bot commented Oct 11, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@nihalpasham nihalpasham added the cuda-oxide SIMT programming model: rustc backend, cargo oxide, cuda-device, cuda-host, book label Oct 15, 2026
…pository URL

The two backend-discovery diagrams named the new repository on the lockfile line but still showed Cargo's old checkout directory and the flat crate layout. Show the checkout as cuda-rust-<hash>/<sha> with the backend crate and toolchain pin under cuda-oxide/, and use one <sha> placeholder throughout the README block.

Add a scaffold test that both templates name https://github.com/NVIDIA/cuda-rust.git and never the old owner. It fails on the previous template and passes here.

Signed-off-by: nihalpasham <nihalp@nvidia.com>
@nihalpasham

Copy link
Copy Markdown
Collaborator

/ok to test 3280e67

@nihalpasham nihalpasham added bug Something isn't working cargo-oxide The `cargo oxide` subcommand and build automation build-related Build scripts, toolchain discovery, or compilation setup labels Oct 15, 2026
nihalpasham pushed a commit that referenced this pull request Oct 15, 2026
…NVIDIA/cuda-rust (#1490)

## What this adds

The SIMT tree still named the pre-rename repository in its Cargo
metadata, its license inventory and the device-codegen ICE message,
while the four host crates already pointed at `NVIDIA/cuda-rust`
(#1395). This change moves the SIMT tree to the same home: one inherited
`[workspace.package] repository` line for the 26 workspace members,
explicit fields on the two first-party crates outside that workspace, 29
inventory rows and the ICE text. The only compiled change is the string
in that diagnostic.

```text
cargo metadata `repository`, 28 SIMT crates   before: https://github.com/NVlabs/cuda-oxide.git   after: https://github.com/NVIDIA/cuda-rust (one value)
first-party inventory rows at the old URL      before: 29 of 33                                   after: 0 of 33
ICE text                                       before: ...Please file at https://github.com/NVlabs/cuda-oxide/issues
                                               after:  ...Please file at https://github.com/NVIDIA/cuda-rust/issues
```

```rust
// The only compiled change: the diagnostic printed when device codegen panics.
tcx.dcx().fatal(format!(
    "[rustc_codegen_cuda] Internal compiler error in device codegen: {msg}. \
     This is a bug in cuda-oxide. Please file at https://github.com/NVIDIA/cuda-rust/issues"
));
```

## What we fixed

- `cuda-oxide/Cargo.toml` `[workspace.package] repository`, inherited by
every `repository.workspace = true` member (26 crates).
- `rustc-codegen-cuda/Cargo.toml` and
`examples/mathdx_ffi_test/libmathdx-sys/Cargo.toml`, the two first-party
manifests that cannot inherit the workspace field.
- 29 of the 33 first-party rows of `cuda-oxide/dependency-licenses.csv`;
the four git-root host rows already carried the new URL.
- The fatal internal-compiler-error message in `rustc_codegen_cuda` now
names `https://github.com/NVIDIA/cuda-rust/issues`.

<details><summary>Implementation</summary>

- The URL form matches the host crates
(`https://github.com/NVIDIA/cuda-rust`, no `.git` suffix).
- `repository` is not part of `Cargo.lock` and nothing in the tree reads
it, so no lockfile, symbol or PTX changes.
- The inventory guard compares crate names only; the rows are
hand-maintained, so the URL column was edited directly.
- The remaining old-URL sites under `cuda-oxide/` are the cargo-oxide
clone and scaffold constants (#1489), the book and crate README links
(#1491), and issue and pull permalinks that keep their historical form.

</details>

## Verification

Checked at `dad294fd` (merged with `main` at `bc46b1ff`):

- ✅ `git grep NVlabs/cuda-oxide` over the three manifests, the inventory
and `lib.rs`: 1, 1, 1, 1, 29 hits on `main`, 0 after the change.
- ✅ `cargo metadata --locked --offline --no-deps` in the SIMT workspace
(26 members), the backend crate workspace and the `mathdx_ffi_test`
workspace: one `repository` value,
`https://github.com/NVIDIA/cuda-rust`; `git status` clean afterwards.
- ✅ `strings` on the rebuilt `librustc_codegen_cuda.so`: `Please file at
https://github.com/NVIDIA/cuda-rust/issues` once, the old URL zero
times; `main`'s backend still shows the old URL.
- ✅ `cargo oxide run vecadd` and `cargo oxide run mathdx_ffi_test
--emit-nvvm-ir --arch=sm_120` on an RTX 5090 through the rebuilt
backend: `SUCCESS` and `Passed: 9 / Failed: 0`; compute-sanitizer
memcheck 0 errors on both; `vecadd` PTX identical to `main` modulo
symbol hashes.
- ✅ All 18 `scripts/check-*.sh` guards, `sync-example-locks.sh --check`,
`cargo deny check` for cargo-oxide, rustc-codegen-cuda, the device-only
fixture and the root workspace, `cargo oxide fmt --check`, clippy with
`-D warnings`, and the unit, doc and rustdoc suites (5479 tests passed,
0 failed).
- ✅ No file in this PR appears in #1489 or #1491.

## Caveats

- The `oxide-artifacts` inventory row now names the current home; the
published 0.2.1 crate still declares the old URL until the next publish
from `crates/oxide-artifacts`.
- No test reaches the ICE message; the string change is confirmed by
compilation and the dylib strings only.
- Clone and scaffold URLs in cargo-oxide and the book and README links
are left to #1489 and #1491.

Signed-off-by: Alejandro Soto Franco <sotofranco.eng@gmail.com>
nihalpasham added a commit that referenced this pull request Oct 15, 2026
…#1491)

## What this adds

The SIMT book, its `conf.py` and the `cargo-oxide`, `ptx-parse`,
`ptx-schedule` and `pinned_overlap` READMEs still named
`NVlabs/cuda-oxide` in 23 current-repository references and reached the
repository only through GitHub's redirect. This moves every one of them
to `NVIDIA/cuda-rust`: four `cargo install --git` lines, the clone step,
16 tree and blob links to 13 targets, the Discussions link and the
book's GitHub icon. Issue and pull-request permalinks keep their
historical form, as AGENTS.md asks.

```text
Before: git clone https://github.com/NVlabs/cuda-oxide.git   # redirect; creates cuda-oxide/ holding the monorepo
        cd cuda-oxide
After:  git clone https://github.com/NVIDIA/cuda-rust.git
        cd cuda-rust
        cd cuda-oxide                                        # build, doctor and run live here
```

```bash
cargo +nightly-2026-10-11 install --git https://github.com/NVIDIA/cuda-rust.git cargo-oxide
```

## What we fixed

- `conf.py`: the GitHub icon links
`https://github.com/NVIDIA/cuda-rust`.
- Four `cargo install --git` lines (cargo-oxide README, Building from
Source, Writing Your First Kernel, Installation) and the clone step in
Building from Source.
- 16 tree and blob links to 13 targets across seven book pages and the
`ptx-parse`, `ptx-schedule` and `pinned_overlap` READMEs.
- The Discussions link in the ecosystem appendix.
- Building from Source: the build, verify and common-commands sections
run from `cuda-oxide/`, where the nightly pin and the `cargo oxide`
alias apply, and the book and rustdoc sections start from the repository
root. The shared host runtime is described as a path dependency on the
repository-root crates, documented from the root workspace.
- `pinned_overlap` README: the run line names the cuda-oxide root, like
the other example READMEs.

<details><summary>Implementation</summary>

- Documentation sources only: 11 book pages, `conf.py` and four READMEs.
No code, manifest or lockfile changes.
- The tree and blob links already carried monorepo paths with the
`cuda-oxide/` prefix; only the repository name changed.
- Issue and PR permalinks, 18 lines in 15 files under `cuda-oxide/`, are
untouched.
- Code constants, the three `repository` manifest fields, the
dependency-license table and the ICE message's issue URL move in #1489
and #1490.

</details>

## Verification

Checked at `e678f228`:

- ✅ All 13 distinct link targets exist on `origin/main` (`git ls-tree`),
tree links to directories and blob links to files.
- ✅ `NVIDIA/cuda-rust` has Discussions enabled; `NVlabs/cuda-oxide`
still redirects there.
- ✅ `sphinx-build -W --keep-going -b html` (Sphinx 9.1.0, 41 pages)
builds with no warnings; the rendered HTML has no non-permalink
`NVlabs/cuda-oxide` URL left (24 in the book and READMEs on main before,
1 after, owned by #1489).
- ✅ All 18 `scripts/check-*.sh` guards pass, including
`check-source-references.sh`, `check-book-api-names.sh` and
`check-host-api-paths.sh`.
- ✅ `cargo test` for cargo-oxide, ptx-parse and ptx-schedule (243, 35
and 27 tests), clippy with `-D warnings`, rustdoc, `cargo oxide fmt
--check` and `sync-example-locks.sh --check` pass.
- ✅ `cargo oxide run pinned_overlap` on an RTX 5090 (sm_120a) prints its
success marker; compute-sanitizer memcheck reports 0 errors.
- ✅ A dry-run `cargo install --git` against a snapshot of this tree
discovers `cargo-oxide` in the nested workspace.
- ✅ From the monorepo root, `cargo oxide doctor` reports the stable
1.98.0 toolchain and `cargo oxide build vecadd` fails on nightly-only
flags; from `cuda-oxide/` both succeed. The directory anchors were
re-checked with the same book build and guards.

## Caveats

- The 18 kept permalinks rely on GitHub's redirect, by policy.
- No guard checks repository URLs; the link targets were verified by
hand against `origin/main`.
- The remaining `NVlabs/cuda-oxide` references live in cargo-oxide code
constants, the three `repository` manifest fields, the
dependency-license table and the ICE message, owned by #1489 and #1490.

---------

Signed-off-by: Alejandro Soto Franco <sotofranco.eng@gmail.com>
Signed-off-by: nihalpasham <nihalp@nvidia.com>
Co-authored-by: nihalpasham <nihalp@nvidia.com>
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 <sotofranco.eng@gmail.com>
Signed-off-by: nihalpasham <nihalp@nvidia.com>
Co-authored-by: nihalpasham <nihalp@nvidia.com>
@nihalpasham

Copy link
Copy Markdown
Collaborator

Checked at 3280e67c:

  • Discovery never reads the URL, so cached backends and existing projects are unaffected; a fresh scaffold now records NVIDIA/cuda-rust in its manifest and lockfile.
  • I added one commit on top: the two discovery diagrams still drew the old checkout directory and flat crate layout, and a test now asserts both templates name the new repository and never the old owner.
  • 244 cargo-oxide tests, clippy, fmt, rustdoc and the guards pass. CI is green on this head.

@nihalpasham
nihalpasham merged commit ffd82c3 into NVIDIA:main Oct 15, 2026
60 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working build-related Build scripts, toolchain discovery, or compilation setup cargo-oxide The `cargo oxide` subcommand and build automation cuda-oxide SIMT programming model: rustc backend, cargo oxide, cuda-device, cuda-host, book

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants