Skip to content

The inverted clc doc was fixed upstream before our pin, and we cited a stale checkout - #106

Merged
feitreim merged 1 commit into
mainfrom
clc-polarity-correction
Jul 28, 2026
Merged

feitreim merged 1 commit into
mainfrom
clc-polarity-correction

Conversation

@feitreim

Copy link
Copy Markdown
Owner

PR #97 reported that cuda_device::clc's module-level usage example has is_canceled inverted against its own function doc, and recommended it as an upstream report. It was already fixed, and we were reading a stale file.

What is actually true

  • The defect was real at v0.2.1. if canceled == 0 really did mean the opposite of the function doc beside it.
  • Upstream fixed it in 61f4a563 on 2026-06-29, a month before the b099f64c this repo pins. That commit also fixed four sites Ask the hardware for the schedule, and find out the ragged wave was never the cost (#88) #97 never mentioned in the same file — the ASCII flow diagram's two arms, and all three clc_query_get_first_ctaid_{x,y,z} docs, which said "only valid when is_canceled returned 0".
  • 6a9a6373 (#406, 2026-07-18) then replaced the hand-written module doc with a generated one. Our pinned clc.rs is thirteen lines with no usage example, so there is nothing left to be wrong.

Where the claim came from

A stale sibling checkout. Cargo keeps every revision it has ever fetched under ~/.cargo/git/checkouts/cuda-oxide-…/, and of the six sitting there exactly one still carries the bug:

checkout lines canceled == 0
b099f64 — what we compile against 13 0
2409204 13 0
29396b7, 2b71354, aa0f77b 226 0
4514af2 — v0.2.1, 2026-06-10 226 1

The file cited as settling the question, crates/mir-lower/src/convert/intrinsics/clc.rs, exists at no upstream revision. That inline-PTX string lives in crates/cuda-oxide-codegen/src/target.rs today.

What changes, and what does not

No code. != 0 was and is correct. It is worth being clear about why we know that, because it is the reassuring part: the polarity was established by the clc work stealing probe counting 2224 + 1872 = 4096 clusters on a B200, not by reading a doc. The wrong doc could not have misled the implementation, because the implementation was checked against the hardware.

This corrects the two places that assert the upstream defect in the present tense — examples/README.md §7 and gemm.rs's dropped-tile comment — and states what happened rather than deleting the trail.

The mechanism, which is the part worth keeping

This is #65's failure mode with a new surface. A ~/.cargo checkout is not a citation. Revisions accumulate there, cargo never removes the old ones, and nothing about the path says which one the build uses. Reading one proves nothing without git log -1 on that specific directory.

An upstream claim in this repo should name the revision it was read at. That is now written down in §7 beside the correction.

Also verified

A full polarity sweep of current upstream main found 33 sites across 22 files with zero inverted uses — nine runtime branches, four prose statements, the book's three mentions. A search of upstream issues and PRs for is_canceled, canceled, clc and cluster launch control, open and closed, returned nothing. So there is no upstream report to file and no duplicate we would have been filing.

For the record, since it will come up if anything is worth sending later: cuda-oxide takes DCO sign-off, not a CLA (git commit -s), wants an issue opened first, uses Conventional Commits with a trailing PR number, and routes contributions through NVIDIA's IP review.

…a stale checkout

PR #97 reported cuda_device::clc's module usage example as having is_canceled
inverted against its own function doc. The defect was real at v0.2.1 and
upstream fixed it in 61f4a563 on 2026-06-29, a month before the b099f64c this
repo pins -- which now ships a 13-line clc.rs with no usage example at all.

The claim came from a stale sibling checkout under ~/.cargo/git/checkouts:
of six revisions cargo has left there, only 4514af2 (v0.2.1, 2026-06-10) still
carries it. The file cited as settling the question, crates/mir-lower/.../clc.rs,
exists at no upstream revision.

No code changes -- != 0 was and is correct, established by the probe rather
than by the doc. This corrects the two places that assert the upstream defect
in the present tense, and names the mechanism: a ~/.cargo checkout is not a
citation without git log -1 on that directory.
@feitreim
feitreim merged commit 701c1b8 into main Jul 28, 2026
3 checks passed
@feitreim
feitreim deleted the clc-polarity-correction branch July 28, 2026 23:36
feitreim added a commit that referenced this pull request Jul 30, 2026
cuda-oxide goes from b099f64 to 20a5616 across all four manifests, all four
locks and `CUDA_OXIDE_REF` in `modal_app.py` — nine build files that move
together, since the codegen backend and the device/host/core crates have to come
from one revision. The lockfile diffs are the rev string and nothing else: zero
non-rev changed lines across the four, and `cargo metadata --locked` passes on
each.

#142's 41-case validation predates the #144–#148 stack, so it no longer covers
the tree and is not leaned on. What is leaned on is re-verification: every claim
this commit repoints was read out of a checkout whose `git rev-parse HEAD` was
confirmed to be `20a56163f258e09f2c51e4c27ae4e4ff17582443` first, which is
#106's rule. Six of the seven checkouts in that cargo directory are not the pin,
`/Users/finn/projects/cuda-oxide` (at `29396b7`) among them.

**Two claims did not just need a new hash.**

`src/lib.rs` said libdevice math is legal beside tcgen05 in one pure-PTX
artifact "at cuda-oxide b099f64". Moving that hash would have asserted it at a
revision nothing checks, because **nothing in this tree makes a libdevice
call** — `Abs` clears the sign bit rather than calling `fabsf`, `fmax`/`fmin`
are comparison-selects, `Sqrt`/`rsqrt` lower to native `sqrt.rn.f32`, and
`exp2`/`log2` are FMA polynomials or the `ex2` SFU. So no gate re-establishes
it, a green `build` says nothing either way, and the citation stays at
`b099f64` with the reason written down.

`GAPS.md` said `cp.reduce.async.bulk.tensor` was absent from cuda-oxide "in
every form — not in the generated crate and not in `intrinsics/imported.json`
either", and argued from that that reduction stores were a lowering to
contribute. The records are there, and were there at `b099f64` too: 64 of them
at both revisions, spelled `int_nvvm_cp_async_bulk_tensor_reduce_*` — which is
why a grep for `cp_reduce_*` finds nothing and how the claim lasted. They are
simply not admitted to the generated crate, where the count is zero. That makes
#42 the same shape as prefetch one row below it, a generation-list change rather
than a lowering, and a smaller ask than the file claimed.

**Provenance kept where it is the historical fact.** The `gemm_sol_upstream`
copy was taken at `b099f64` and the port measured there; `gemm_sol_final/` is
byte-identical at `20a5616` and upstream's `kernels.rs` and the vendored copy
all hash to `6746e517…`, so those citations keep `b099f64` and say why. The
`stmatrix` defect is annotated rather than rewritten: #145 proved it survives
the bump, so `ldst.rs`'s `ptx_asm!` workaround stays and `upstream_ptx`'s
docstring now records that the bump drops neither workaround.

**One retracted argument removed rather than repointed.** `gemm.rs`'s
`.pack::16b` doc still carried "the register count does not fall, so nothing is
packed" — the sixth instance of the register-count error (#47, #63, #67, #76,
#81) that #147 refuted and corrected in `experiments/README.md`. Repointing the
hash beside it would have asserted the retracted reasoning at the new pin, so
the doc now carries #147's two answers instead: `cvt.rn.bf16x2` censuses at 0
and the arm faults with `Xid 13`.
feitreim added a commit that referenced this pull request Jul 30, 2026
cuda-oxide goes from b099f64 to 20a5616 across all four manifests, all four
locks and `CUDA_OXIDE_REF` in `modal_app.py` — nine build files that move
together, since the codegen backend and the device/host/core crates have to come
from one revision. The lockfile diffs are the rev string and nothing else: zero
non-rev changed lines across the four, and `cargo metadata --locked` passes on
each.

#142's 41-case validation predates the #144–#148 stack, so it no longer covers
the tree and is not leaned on. What is leaned on is re-verification: every claim
this commit repoints was read out of a checkout whose `git rev-parse HEAD` was
confirmed to be `20a56163f258e09f2c51e4c27ae4e4ff17582443` first, which is
#106's rule. Six of the seven checkouts in that cargo directory are not the pin,
`/Users/finn/projects/cuda-oxide` (at `29396b7`) among them.

**Two claims did not just need a new hash.**

`src/lib.rs` said libdevice math is legal beside tcgen05 in one pure-PTX
artifact "at cuda-oxide b099f64". Moving that hash would have asserted it at a
revision nothing checks, because **nothing in this tree makes a libdevice
call** — `Abs` clears the sign bit rather than calling `fabsf`, `fmax`/`fmin`
are comparison-selects, `Sqrt`/`rsqrt` lower to native `sqrt.rn.f32`, and
`exp2`/`log2` are FMA polynomials or the `ex2` SFU. So no gate re-establishes
it, a green `build` says nothing either way, and the citation stays at
`b099f64` with the reason written down.

`GAPS.md` said `cp.reduce.async.bulk.tensor` was absent from cuda-oxide "in
every form — not in the generated crate and not in `intrinsics/imported.json`
either", and argued from that that reduction stores were a lowering to
contribute. The records are there, and were there at `b099f64` too: 64 of them
at both revisions, spelled `int_nvvm_cp_async_bulk_tensor_reduce_*` — which is
why a grep for `cp_reduce_*` finds nothing and how the claim lasted. They are
simply not admitted to the generated crate, where the count is zero. That makes
#42 the same shape as prefetch one row below it, a generation-list change rather
than a lowering, and a smaller ask than the file claimed.

**Provenance kept where it is the historical fact.** The `gemm_sol_upstream`
copy was taken at `b099f64` and the port measured there; `gemm_sol_final/` is
byte-identical at `20a5616` and upstream's `kernels.rs` and the vendored copy
all hash to `6746e517…`, so those citations keep `b099f64` and say why. The
`stmatrix` defect is annotated rather than rewritten: #145 proved it survives
the bump, so `ldst.rs`'s `ptx_asm!` workaround stays and `upstream_ptx`'s
docstring now records that the bump drops neither workaround.

**One retracted argument removed rather than repointed.** `gemm.rs`'s
`.pack::16b` doc still carried "the register count does not fall, so nothing is
packed" — the sixth instance of the register-count error (#47, #63, #67, #76,
#81) that #147 refuted and corrected in `experiments/README.md`. Repointing the
hash beside it would have asserted the retracted reasoning at the new pin, so
the doc now carries #147's two answers instead: `cvt.rn.bf16x2` censuses at 0
and the arm faults with `Xid 13`.
feitreim added a commit that referenced this pull request Jul 30, 2026
…nd the one shipped spill is outside the hot loop (#152)

cuda-oxide `b099f64` → `20a5616` across all four manifests, all four lockfiles and
`CUDA_OXIDE_REF`. Every Rust change is a doc comment; `git diff main -- '*.rs'` has
zero non-comment changed lines.

**Two doc claims needed more than a hash.** `src/lib.rs`'s libdevice claim is not
re-establishable at the new pin — nothing in the tree makes a libdevice call
(`Abs` clears the sign bit, `fmax` is a comparison-select, `Sqrt`/`rsqrt` are
native), so no gate exercises it and repointing the hash would have been #106's
exact failure mode; the citation stays with the reason written down. And GAPS.md's
`cp.reduce` claim was wrong *before* the bump: 64 records are in `imported.json` at
**both** revisions as `int_nvvm_cp_async_bulk_tensor_reduce_*`, which is why a
`cp_reduce_*` grep finds nothing — reclassifying #42 as a generation-list change.

Read only from the checkout at `20a5616` with `git rev-parse HEAD` confirmed first,
per #106; six of the seven checkouts on the machine are not the pin. Repointed after
re-verification: the 13-line `clc.rs`, the `[u32; 32]` `pack16` result, the `.x8`
hazard, `generated/stmatrix.rs`, and all thirteen rows of GAPS.md's support table.
Kept at `b099f64` as provenance: the `gemm_sol_upstream` copy point and the
`stmatrix` observation, with `kernels.rs` hashing to `6746e517…` at both revisions
and in the vendored copy. The retracted register-count sentence still living in
`gemm.rs`'s `.pack::16b` doc is removed — #147 fixed it in the README and missed it
there, and repointing the hash beside it would have asserted retracted reasoning at
the new pin.

**The census had to be taken twice and the answer changed.** Against `336e3d7` it
was 44 of 270 rows with `gemm_sol_m512_mma` among the newly-spilling four; #154
landed in between and moves registers on its own, and against `aaadcc2` that kernel
is 80 → 79 with no spill at all. The newly-spilling set is not stable under the
choice of baseline, so a dependency diff has to be taken against the commit it will
land on. Final: 46 of 272 rows moved, identical kernel sets, `regcount
--determinism` passing on the new pin. Not an LLVM bump — `rust-toolchain.toml` is
byte-identical and both revisions validate against `rust-llvm-22.1.2-1cb4e383`.

Four rows started spilling and **every one falls in register count while doing
so** — `ptxas` taking a lower target and paying in local memory, which is this
repo's oldest error arriving from the toolchain rather than from a diff. The
columns are **bytes**: `4,8` is one 32-bit register stored once and reloaded twice.

**The one shipped spill is outside the hot loop, and a CPU container settled what a
GPU one could not.** `bench sol-small` cannot answer it — the N128/N256 ratio moves
±6.4% with inconsistent sign and `M256xN256`, whose registers did not move, reads
0.5-4.8% slower too, so that table's 4-87% spread is the container. The
disassembly can: `nvdisasm -c` through `_print_sass_loops` finds the pin adds
**exactly three** local-memory instructions to `m256_n128` and none to the two
unspilled controls — one `STL` and two `LDL` at `[R1+0x100]`, the 4 and 8 bytes
arrived at independently. All three sit in 510-727 instruction regions; the
innermost 216-instruction loop, where this kernel's 64 pre-existing frame accesses
live on *both* pins, contains none of them. Cost bounded at ≤0.6% of issue in one
outer loop and zero in the inner one. Below the noise floor, with the noise floor
stated.

**The decomposition survives, laddered on both pins.** Every arm agrees across the
pin to 0.2 points or better inside its own two-pass spread; `mma only` reads
99.5/99.6% old and 99.7/99.6% new, `[512, 256]` 99.3-99.7%. So `mma only` is still
at peak and no published row needs amending. One number does not reproduce and it
is not the pin's: `mma only` is published at 100.6% and reads 99.5-99.6% on the
*old* pin at `aaadcc2`, so #154 or the session moved it.

Also noted: `cuda-core` removed the public `ClusteredCooperativeValidationUnsupported`
variant, which the repo never names; and `.reqntid` is now emitted from a declared
exact block and driver-enforced per axis where `.maxntid` only bounded the product,
closed empirically by green `build`, `regcount` and 42/42 device cases.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant