Skip to main content

I went looking for what was below SASS. Found control codes. Went deeper. Found microcode. Then found a cross-vendor paper that puts it in context.

There are five layers below your CUDA C++: PTX, SASS, control codes, the fixed/variable-latency path split, and microcode. Most engineers know the first two. Every SASS instruction carries about 21 bits of control information (stall count, yield, read and write barrier indices, a wait mask over six dependency barriers, operand reuse flags), packed into a separate control word on Maxwell and Pascal and embedded in each 128-bit instruction from Volta on. The compiler isn't just translating code, it's encoding a scheduling policy the hardware obeys, and when ptxas's static latency model is off, the hardware follows it anyway. Go one layer down and the SFU runs transcendentals as a microcoded sequence, which matters on Blackwell because the tensor cores doubled and the exp units didn't. And a March 2026 cross-vendor paper shows which execution primitives every GPU vendor shares.

June 25, 2026

Let me tell you what I actually found and what the research says about it, because the two connect in a way that I didn't expect when I started.

SASS is the layer I wrote about last time -- NVIDIA's native GPU assembly, below PTX, undocumented ISA, where CuAsmRL does RL optimization on instruction schedules. I assumed SASS was the floor. It's not. There's structure below it that most GPU engineers have never seen, that the compiler is actively using to guide hardware behavior, and that explains several things about kernel performance that don't make sense if you model SASS as the bottom layer.


The control codes.

SASS code isn't just a flat stream of instructions. Every instruction carries scheduling metadata, and where it lives depends on the generation. On Maxwell and Pascal, instructions are 64 bits and every fourth 64-bit word is a control word holding 21 bits of meta-information for each of the next three instructions: 32-byte groups of one control word plus three instructions. From Volta on (Turing, Ampere, Hopper, Blackwell), instructions are 128 bits and the control bits are embedded in each instruction's high bits.

Those roughly 21 bits per instruction break down as:

  • Stall count (4 bits): how many cycles the scheduler should stall before issuing the next instruction. Encoded statically by the compiler. If the previous instruction has a 4-cycle latency, the compiler sets stall count to 4. The hardware issues the next instruction after waiting that many cycles. No dynamic latency detection needed.
  • Yield bit (1 bit): whether to yield execution to another warp after this instruction. The compiler marks instructions where switching warps is cheap (typically after a memory instruction that won't return for a while).
  • Write barrier (3 bits) and read barrier (3 bits): indices into six hardware dependency barriers (scoreboards) for variable-latency instructions. The write barrier is released when the instruction's result lands in its destination register; the read barrier is released once its source registers have been read, so a later instruction can safely overwrite them.
  • Wait mask (6 bits): a bitmask over those six barriers. The instruction doesn't issue until every barrier in its mask has been released.
  • Reuse flags (4 bits): hints to keep an operand in the register reuse cache, which avoids register bank conflicts.

None of this is in NVIDIA's public documentation. It's in the NVIDIA patent filings, in the reverse-engineering work (maxas for Maxwell, Jia et al.'s Volta microbenchmarking paper for the 128-bit encoding), inferable from cuasm's source code (which had to reverse engineer the encoding to be able to assemble SASS back from disassembled code), and confirmed by the UPC microarchitecture paper (arXiv:2503.20481, March 2025).

The key insight: the compiler is not just translating code to instructions. It's encoding a scheduling policy into the instruction stream. The hardware scheduler reads the control codes and follows them. ptxas makes decisions about stall counts, yield bits, and barrier tokens at compile time based on its static model of instruction latencies. When ptxas's model is wrong -- when the actual hardware latency differs from ptxas's estimate, or when ptxas doesn't model the specific microarchitectural behavior of a new chip -- the stall counts it encodes are wrong. The hardware follows them anyway.

This is also why CuAsmRL has to respect the control codes. It finds better SASS schedules by reordering instructions (moving memory instructions like LDGSTS relative to the math around them), and the stall counts and barriers are constraints on which reorderings are legal. The paper says it ignores control-code tuning for simplicity. The control codes are the part of the scheduling policy CuAsmRL doesn't touch, which leaves it as the obvious next search space.


The fixed-latency / variable-latency split.

The UPC paper reveals that modern NVIDIA GPU cores distinguish between two instruction categories at the hardware level: fixed-latency instructions and variable-latency instructions. The distinction determines which path through the pipeline the instruction takes.

Fixed-latency instructions: arithmetic, logical operations, register-to-register moves. The latency is deterministic and known at compile time. ptxas sets the stall count for the following instruction accordingly. The hardware doesn't need to do any dynamic latency tracking. These instructions go through the "FL path" -- a fast path through the pipeline with an L0 fixed-latency instruction cache that prefetches them efficiently.

Variable-latency instructions: loads from global memory (latency depends on cache hit/miss), shared memory accesses (latency depends on bank conflicts), instructions that stall on synchronization barriers. The latency is not predictable at compile time. These use the barrier mechanism -- the compiler inserts a write barrier when the variable-latency instruction issues, and read barriers on subsequent instructions that depend on its result. The hardware waits for the write barrier to clear before issuing instructions with a matching read barrier.

The interesting consequence: ptxas uses two completely different mechanisms for ordering fixed-latency and variable-latency instructions, and confusing the two is a source of performance bugs that are invisible at the PTX level.

If ptxas incorrectly classifies an instruction as fixed-latency when it's actually variable-latency (or estimates the fixed latency incorrectly for a new architecture generation), it will encode stall counts instead of barrier tokens. The instruction will issue with incorrect timing relative to its dependencies. The output will be wrong or the performance will be degraded depending on whether the incorrectly ordered instruction happens to read from a register before the write completes.

This is architecture-version-specific, and the toolchain treats it that way. An Ampere (sm_80) cubin won't load on Hopper (sm_90) at all; cubins only run within the same major compute capability. If the binary carries PTX, the driver JIT-compiles it with Hopper's ptxas, which encodes Hopper's latencies. SASS binaries are not portable across architecture generations, and the control codes, which encode architecture-specific timing information, are one reason why.


The microcode layer.

Below the control codes, below the instruction pipeline -- there's a layer that handles specific instruction classes that aren't single-cycle operations. The Special Function Units, reached through the MUFU instructions: MUFU.SIN, MUFU.COS, MUFU.EX2 (2^x; exp() is built on it), MUFU.LG2, MUFU.RSQ, MUFU.RCP. These are the transcendental math functions.

An SFU instruction is not a single operation from the hardware's perspective. It's a microcode sequence. The NVIDIA patent for micro-coded transcendental instruction execution (US9471305) describes this explicitly: the pipeline "switches from a first mode to a second mode" to execute SFU instructions. In second mode, the pipeline is "controlled by the instruction pipeline for iterative processing of the micro-code" -- the normal SIMT pipeline hands control over to the microcode sequencer, which executes the SFU's iterative algorithm (Newton-Raphson iterations for reciprocal, polynomial approximations for trig functions, etc.), then switches back to first mode when done.

The SFU design NVIDIA has published (Oberman and Siu's multifunction interpolator) evaluates table-driven piecewise polynomial approximations in fixed point. Whatever ships today is proprietary. The latency is multiple cycles -- higher than a floating-point multiply, much higher than what the stall count mechanism can express in 4 bits (which caps at 15 cycles). SFU instructions use the variable-latency barrier mechanism even though their latency is approximately predictable.

This is the layer FlashAttention-4 works around on Blackwell.

FA4's stated reason is throughput. Per SM per clock, Blackwell's tensor cores do 8,192 ops while MUFU does 16 exponentials. At Hopper hardware ratios the SFU kept up. At Blackwell, where tensor core throughput doubled and MUFU throughput didn't, softmax's exp() became the bottleneck. So FA4 computes part of the exponentials on the FMA units instead: 2^n by shifting the integer part into the float's exponent field, and the fractional part with a cubic polynomial. Some exp() calls go to MUFU.EX2, some to the FMA pipes, and both units stay busy.

The microcode layer is my guess at a second-order effect, not something NVIDIA or the FA4 authors claim. A cubic polynomial on the FP32 pipes stays on the fixed-latency path: small, statically correct stall counts. MUFU.EX2 goes through the variable-latency barrier mechanism and, if the patent describes current hardware, a microcoded sequence. If it does, it only widens the gap at high load.


The cross-vendor view: what's hardware-invariant at this level.

A March 2026 paper I found (arXiv:2603.28793, "Toward a Universal GPU Instruction Set Architecture", by Ojima Abraham and Onyinye Okoli) did something no prior work had done: analyzed GPU ISAs across all four major vendors (NVIDIA, AMD, Intel, Apple) and identified what's hardware-invariant.

Across 16 distinct microarchitectures, drawing on 5,000+ pages of ISA references, whitepapers, patent filings, and community reverse-engineering, they found ten hardware-invariant computational primitives, six parameterizable dialects, and six true architectural divergences. The ten invariants: lockstep thread groups, mask-based divergence, the register-occupancy tradeoff, a managed on-chip scratchpad, zero-cost context switching between warps, a memory hierarchy, atomic read-modify-write, workgroup barriers, identity registers (thread and block IDs), and asynchronous memory with explicit synchronization.

Notice what's not on the list: the control codes. The paper's proposed abstract machine deliberately exposes no pipeline latencies. Scheduling metadata is treated as something each vendor's compiler handles below the portable layer.

That's the part I find interesting, because every vendor does have some version of it. Intel's Xe has SWSB (software scoreboarding), an explicit, documented version of dependency tracking in the instruction stream. AMD's RDNA uses explicit s_waitcnt counters for memory dependencies, and RDNA3 added s_delay_alu to tell the hardware about ALU dependencies. NVIDIA embeds it in control codes. My read, not the paper's claim: compiler-encoded dependency information is the common answer to the same problem, but the encodings differ enough that a portable ISA has to hide it.

The practical consequence for kernel work: FA4's exp() split is tuned to one vendor's ratio of tensor throughput to SFU throughput. On hardware with a different ratio, the same trick may not help. Measure before porting it.


I started this exploration because CuAsmRL's results implied that the scheduler was making decisions based on information encoded below the instruction level. I looked for where that information lived. Found the control code encoding. Looked for what the control codes were implementing. Found the fixed-latency / variable-latency path split. Looked for what used the variable-latency path despite having approximately-predictable latency. Found the microcode sequencer.

The UPC paper (March 2025) confirmed most of what I'd inferred from cuasm's source and the patent filings. The cross-vendor paper (March 2026) told me which parts of this are shared across vendors and which parts a portable ISA has to hide.


there are five layers below your CUDA C++.

PTX. SASS. control codes. fixed/variable latency paths. microcode.

most engineers know the first two. the research community recently published on the next two. the fifth one is in the patents and the compiler source and the performance anomalies you've been calling "weird hardware behavior."

it's not weird. a lot of it is the scheduling policy ptxas wrote into the control codes, and the ratio between units the hardware gives you.

the reason fa4 computes some exp() on the fma pipes on blackwell is throughput: the tensor cores doubled and mufu didn't. whether the sfu's microcoded path costs something extra on top of that is my guess, not something nvidia documents. the control codes are where you'd see it first.


P.S. Intel's SWSB (software scoreboarding) is worth a standalone post. Intel made a version of the NVIDIA control code mechanism fully public and explicit -- SWSB is documented in Intel's Xe ISA reference. Instructions carry a SWSB field that plays the same role as NVIDIA's barrier tokens, but Intel tells you what it does and what the encoding means. NVIDIA's version is inferred from patents and disassembly. Intel's version is in the manual. If you want to understand what's in NVIDIA's control codes, read Intel's SWSB specification. The concepts are close. The documentation is not.

i write these when i have something worth saying. no schedule. no algorithm. if you want to know when the next one goes up -- leave your email.

no spam. no sequence. just the note, when it exists.