Skip to content

future_apis self-gates at sm_80 but its PTX needs sm_90: FAILs instead of skipping #676

Closed as not planned

Description

@vyncint

Description

future_apis self-gates on compute capability, but one generation too low. It
skips when major < 8, on the basis that the mbarrier APIs need sm_80 — true of
the APIs, but not of the PTX cuda-oxide emits for them. ManagedBarrier::init
also emits fence.proxy.async.shared::cta, whose .async modifier ptxas
rejects below sm_90. So on sm_80..sm_89 the gate lets the example through and it
fails in the driver with DriverError(218, "a PTX JIT compilation failed")
before any kernel starts.

It was the only failure in an otherwise-green 185-example run on an A10G (sm_86).

Root cause

ManagedBarrier::init_by emits the fence unconditionally
(crates/cuda-device/src/barrier.rs:417):

pub unsafe fn init_by(self, count: u32, init_thread: u32) -> ManagedBarrier<Ready, Kind, ID> {
    if crate::thread::threadIdx_x() == init_thread {
        unsafe {
            mbarrier_init(self.ptr as *mut Barrier, count);
            fence_proxy_async_shared_cta();     // <-- requires sm_90

In the generated PTX every init is paired with it:

mbarrier.init.shared.b64 	[__shared_mem_0], %r2;
// begin inline asm
fence.proxy.async.shared::cta;
// end inline asm

That is also why the module is compiled .target sm_100:
contains_tma_features treats a bare fence.proxy.async as a TMA feature
(crates/cuda-oxide-codegen/src/target.rs:420), and with no usable device hint
select_target maps plain Tma to sm_100 (target.rs:1183). Hopper itself is
fine, since arch_satisfies_feature maps Tma to major >= 9 (target.rs:1590)
so an sm_90 hint is compatible and wins — I have no Hopper to confirm that and
am going on the code.

Minimal reproducer

The floor needs no GPU:

cargo oxide build future_apis
cd crates/rustc-codegen-cuda/examples/future_apis
for arch in sm_86 sm_90; do
  sed "s/^\.target .*/.target $arch/" future_apis.ptx > /tmp/fa_$arch.ptx
  printf '%-8s : ' "$arch"; ptxas -arch=$arch /tmp/fa_$arch.ptx -o /dev/null 2>&1 | head -1; echo
done
sm_86    : ptxas fatal   : Modifier '.async' requires .target sm_90 or higher
sm_90    :

The module contains no actual TMA — cp.async.bulk., expect_tx,
.sync_restrict, tcgen05 and clusterlaunchcontrol. are all absent; the
proxy fence is the only trigger.

Expected behavior

The gate matches the floor of the emitted PTX, so the example reports
PASS (skipped) on sm_80..sm_89 via verdict_standard's skipping: path,
as cluster already does for pre-Hopper.

Actual behavior

=== Future APIs Test (Unified) ===

Error: DriverError(218, "a PTX JIT compilation failed")

Failed with exit code: Some(1)

and in a full run: [85/185] future_apis ... FAIL (exit=1) [2s].

Environment

Additional context

I confirmed this is not a regression from anything in flight by rebuilding the
same tree with my only outstanding change reverted and seeing the identical
failure.

Correcting the gate to major < 9 is the minimal fix and I am happy to send it.
But there may be a better one, which is really a question about the memory model:
the fence is emitted for every ManagedBarrier::init regardless of Kind, and
the proxy fence exists to make generic-proxy writes visible to the async
proxy. A ManagedBarrier<_, GeneralBarrier> that never feeds an async copy
arguably does not need it, and the typestate already distinguishes
GeneralBarrier from TmaBarrier. If the fence can be predicated on Kind,
plain barriers would keep working on Ampere as the sm_80 comment intends,
instead of the whole API being Hopper+. I did not want to guess at the ordering
requirement, so I have not attempted that. Which would you prefer?

Activity

  1. changed the title [-]future_apis is not compute-capability gated: FAILs instead of SKIPs below sm_90[/-] [+]future_apis self-gates at sm_80 but its PTX needs sm_90: FAILs instead of skipping[/+] on Aug 6, 2026
  2. vyncint commented on Aug 6, 2026

    @vyncint
    ContributorAuthor

    Correcting my own report: the original text said the example had no compute-capability gate and proposed a floor=90 entry in smoketest.sh's required_cc. Both were wrong.

    required_cc only raises the compile arch; it does not gate execution. And future_apis does already self-gate — at major < 8. The real defect is narrower and more interesting: the gate matches the mbarrier API floor (sm_80) while the emitted PTX floor is sm_90, because ManagedBarrier::init unconditionally appends fence.proxy.async.shared::cta.

    Body updated with the root cause, the ptxas evidence, and the Kind-predication question.

  3. added
    bug
    examples
    cuda-feature
    on Aug 6, 2026
  4. vyncint commented on Aug 6, 2026

    @vyncint
    ContributorAuthor

    Closing this as a duplicate — I filed it without checking that the instance was already handled.

    The one thing here that I do not think is covered anywhere: ManagedBarrier::init_by emits fence.proxy.async for every barrier kind, and that fence is what forces the sm_90 floor. Its purpose is to make generic-proxy writes visible to the async proxy, so a ManagedBarrier<_, GeneralBarrier> that never feeds an async copy plausibly does not need it — and if it can be predicated on Kind, plain barriers would keep working on Ampere, which is what the original sm_80 comment intended. I have not attempted it because I do not want to guess at the ordering requirement. I will raise that as a question on #666 where the context lives rather than keep a duplicate issue open for it.

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

    bugcuda-featureexamples

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions