Skip to content

#219's AccessWidth enum lowers the store ladder to brx jump tables the driver JIT refuses (DriverError 218) #225

Closed

Description

@feitreim

Found by oxide-train's rev-bump agent (oxide-train PR #127). Bumping oxide-train's pin toward ferro main died at the first cuModuleLoadData with DriverError(218) — before any gate output — while offline ptxas --gpu-name=sm_100a -O3 accepts the same PTX with register counts identical to the previous pin.

Bisected: green at 3ae07a8 (#218), red at 41f9e57 (main). A whole-module opcode diff of the consumer's gemm.ptx isolates it to one instruction class: brx is the only opcode present after the bump and absent before — four brx.idx/.branchtargets jump tables in the bf16 tcgen05 GEMM.

Cause: #219 (f4354d0) changed access_width to return a #[repr(usize)] AccessWidth enum. The now-exhaustive four-discriminant matches in store_shared_rows/accumulate_shared_rows lower through LLVM as jump tables where the old compare chain lowered as branches — and the driver's PTX JIT (580.95.05, B200) refuses the module. A typing change that was not supposed to move codegen moved it into a construct the runtime compiler rejects, invisibly to ferro's own CI (whatever ferro's device jobs load evidently doesn't exercise this path the same way — worth confirming why ferro CI stayed green).

Downstream state: oxide-train pinned at 3ae07a8 (#218) — nothing between #218 and main is load-bearing for it (#223 is examples/experiments, #224 is docs), so it loses nothing today, but the pin can't advance past #219 until this is fixed.

Suggested fix directions (pick by measurement):

  • Restore a compare-chain lowering: e.g. rewrite the exhaustive match as an if/else ladder, mark the match arms in a way LLVM won't table-ize (#[cold] on rare arms, or a small match_likely shape), or revert the enum to the raw usize with named consts.
  • Verify with the consumer's failure mode: the reproducer is loading the module through the driver JIT (cuModuleLoadData of the PTX text), not offline ptxas — an offline-ptxas-only check will pass and prove nothing.
  • Consider a CI guard: a device job that JIT-loads every shipped module's PTX (not offline-compiled) so runtime-compiler refusals surface in ferro rather than downstream.

Also worth noting from the same bump: #203's stricter typing caught a real latent bug downstream (an M128 issued over a 64-row Panel — accumulator rows 64..127 read trailing shared memory; harmless-but-invisible until the types refused it). The typing direction is paying for itself; this issue is just the codegen edge it tripped.

Activity

  1. feitreim commented on Aug 7, 2026

    @feitreim
    OwnerAuthor

    Confirmed downstream: #227 fixes it. The module loads.

    oxide-train's pin is bumped 3ae07a8 (#218) → b589b8a (#227) and
    cargo oxide run gemm — the exact run that died at the first
    cuModuleLoadData with DriverError(218), before a line of gate output —
    loads and passes:

    ptxas budgets (registers/thread, spill bytes, .maxntid)
      gemm_tcgen05_bf16_optimized 160 regs,    0 spill bytes, maxntid 192
      gemm_tcgen05_f32_optimized  172 regs,    0 spill bytes, maxntid 192
      gemm_tcgen05_f32_accumulate 146 regs,    0 spill bytes, maxntid 192
    ✓ fp32 and tcgen05 bf16 GEMM store/accumulate parity passed
    

    Same B200 tier, same image, same consumer tree that was red at 41f9e57.
    The register counts are 3ae07a8's to the digit, so the compare-chain
    lowering restored the green build's codegen exactly — not merely something
    the driver tolerates.

    What this settles, and what it does not. #227's reproduction attempt
    failed and its writeup was right to be careful: brx is necessary here and
    not sufficient in general — ferro's own 55 tabled kernels, shared_drain_quad's
    four tables in one entry included, JIT-load fine on 580.95.05. So the honest
    reading is that the trigger is some interaction between the jump tables and
    the rest of gemm_tcgen05_bf16_optimized's module that ferro has no kernel
    large enough to hit, not the construct alone. What is now established is the
    consumer-side half of the bisect in both directions: red exactly when the
    tables are there, green exactly when they are not, across two independent
    changes to how the dispatch lowers. Nothing about the consumer's module moved
    between them.

    Closing the loop on the follow-up #227 named: the bump is oxide-train#130, and
    the remaining gates (flash-attn, ops, model) plus the register/occupancy A/B
    are in that PR.

  2. feitreim commented on Aug 7, 2026

    @feitreim
    OwnerAuthor

    Correction: the tables were #219's. The bisect was right all along.

    This issue currently records "brx is necessary but not sufficient; ferro's own
    55 tabled kernels, shared_drain_quad's four tables in one entry included,
    JIT-load fine on 580.95.05." Half of that is a stale-build artifact. Re-measured
    on three refs, each through #228's _freshen and each with all four crates seen
    to recompile in the container log (#229):

    ref entry functions carrying a brx
    3ae07a8 #218, before the access ladder 0 of 309
    bda3329 after #219, before #227 55 of 318 (9 shipped)
    09beda9 main, after #227 0 of 319

    #219 introduced every jump table in ferro and #227 removed every one of them.
    The consumer's bisect to #219 was correct in ferro's own PTX too, in both
    directions, and #227's claim that 3ae07a8 "already carried 51 of the same set"
    is superseded: AccessWidth does not exist at 3ae07a8. #219 is the commit that
    made the ladder a type; before it both drains dispatched on access_width_bytes
    — three cases, which LLVM branches, which is exactly the lowering #227 restored.
    Zero is the only count that tree can produce. The 51 came from a regcount run
    inside the window where the cargo-cache volume was serving builds it had not
    compiled — the bug #228 found and fixed. So did #227's "identical counts across
    the fix": the real delta is 55 → 0.

    The fix in #227 is unaffected and was right for the reason it gave. What was
    wrong is the measurement it took of itself.

    What that does to "necessary but not sufficient" — it splits.

    So the honest statement is narrower than what is written above: ferro has run
    tabled kernels on this driver and they loaded, so brx alone is still not a
    sufficient condition — but nothing in this repo has ever exercised four tables
    in one entry
    , which is the consumer's actual shape and the thing the failing
    module had. If anyone wants that question answered, it takes a probe that is
    deliberately built with a four-case dispatch; shared_drain_quad is not it.

    Guarding it. #229 arms the census into a gate: regcount now fails when any
    kernel in the shipped set carries a brx. Watched in both directions — green at
    main's 0 of 319, red against bda3329's sources naming the nine shipped kernels
    that carried one. The #219 regression would not reach a consumer again.

    cc oxide-train: the pin at b589b8a is correct and unchanged by any of this;
    what changes is the story, and any note that cites "ferro loads 55 tabled
    kernels fine, including four in one entry" should drop the second clause.

  3. added a commit that references this issue on Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions