ptxas generates SASS from your PTX. ptxas is a heuristic compiler. The SASS it generates is not optimal. CuAsmRL attacks that gap with RL.
ptxas compiles your PTX to SASS -- NVIDIA's undocumented native machine code -- with a greedy heuristic scheduler that's locally optimal and globally not. Almost every kernel-optimization paper works above ptxas and accepts whatever it emits. CuAsmRL (arXiv:2501.08071, CGO 2025) automates what SASS experts used to do by hand: infer register dependencies from the bytecode, search valid instruction schedules with RL, and let measured GPU execution time, not an ISA spec, be the reward.
June 19, 2026I want to be precise about what layer this is, because the kernel optimization conversation has been happening at the wrong level of the stack.
The CUDA compilation pipeline has four levels. You write CUDA C++ or Triton. That compiles to PTX -- NVIDIA's virtual instruction set, hardware-agnostic, the documented layer. PTX compiles to SASS -- Streaming ASSembler, NVIDIA's actual native GPU machine code, hardware-specific, undocumented. SASS compiles to cubin, the executable binary. The GPU runs cubin.
Every kernel optimization paper in the last two years has targeted CUDA C++, PTX, or Triton. KernelBench. CUDA-L1. CUDA Agent. Kernel-Smith. All of them work at level one, two, or two-and-a-half. They generate or modify code that gets compiled through ptxas. Whatever ptxas does, they accept.
CuAsmRL (arXiv:2501.08071, January 2025, published at CGO 2025) targets SASS directly.
Not PTX. The actual machine code. The layer that runs on silicon. The layer NVIDIA doesn't document.
Why SASS optimization is different from everything above it.
ptxas is a compiler. It has a scheduler. The scheduler reorders PTX instructions to improve latency hiding -- it tries to issue memory loads early so that by the time the compute instruction that needs the result executes, the load has already completed. The scheduler uses heuristics. Heuristics are not optimal.
The specific failure mode: ptxas makes locally optimal scheduling decisions that can be globally suboptimal. At each scheduling step, it picks the instruction that looks best given the current state. It doesn't search ahead. It doesn't try alternative orderings and measure them. It applies rules.
SASS gives you the result of those rules. If the rules were suboptimal, the SASS is suboptimal. And because SASS is undocumented -- NVIDIA doesn't publish the ISA specification -- there's no obvious way to improve it. You can't write "better SASS" the way you can write better CUDA C++. You'd have to understand an instruction set that NVIDIA has deliberately kept opaque, which is what the hand-tuning tradition (KeplerAs, MaxAs, TuringAs) did, one kernel at a time.
CuAsmRL's approach: you don't need to understand the ISA to reorder instructions. You need to understand dependencies.
Instruction B cannot be reordered before instruction A if B reads a register that A writes. That's a read-after-write dependency. Instruction C cannot be reordered before A if A reads a register that C writes. That's a write-after-read dependency. These constraints are inferable from the SASS bytecode structure -- register operands are specified in the encoding even if the semantics are opaque.
Given dependency constraints, there is a space of valid SASS schedules -- all orderings of instructions that respect every dependency. ptxas picks one ordering from this space. CuAsmRL searches the space using RL, measuring actual GPU execution time for each candidate schedule, and learning which orderings produce better performance.
The specific example from Ampere that makes this concrete.
In CUDA C++ or Triton, a load from global memory to shared memory becomes a cp.async in PTX. When ptxas compiles it to Ampere SASS, cp.async becomes LDGSTS, the native Ampere async copy, surrounded by integer address math like IMAD.WIDE. The tensor core math becomes HMMA.
CuAsmRL's action is simple: pick an instruction and swap it with its neighbor, if the dependencies allow it. The paper's illustration of a single action is exactly that: an IMAD.WIDE and an LDGSTS trading places.
The most significant move the RL agent found, in a fused GEMM with LeakyReLU, was scheduling an HMMA before an LDGSTS. That one reordering gave 7% kernel throughput. The authors suspect the .reuse flag on an operand register, a hint that keeps the operand in the register reuse cache and avoids a register bank read, and they tested it. Removing the flag from ptxas's original schedule changed nothing. Removing it from the optimized schedule erased the gain. The reordering is what lets the reuse hint pay off.
This is not visible from PTX. PTX has no .reuse flags and no choice of where an HMMA sits relative to an LDGSTS; those exist only in SASS. The information lives below PTX, in the specific sequence of machine code that touches the hardware scheduler. You can only find it by measuring execution time across multiple SASS orderings and learning which direction the gradient points.
Why ptxas can't fix this itself.
The obvious question: if HMMA-before-LDGSTS is better here, why doesn't ptxas generate it?
ptxas's scheduler is greedy. At each step, it looks at the ready instructions (no unsatisfied dependencies) and picks the one with the highest estimated priority. The priority estimate is based on heuristics -- instruction type, latency characteristics, register pressure. It doesn't simulate "if I move this HMMA above this load, does the operand stay in the reuse cache?" It doesn't have that model. How a particular ordering interacts with operand reuse, register banks, and the memory pipeline on this exact chip is not fully in ptxas's cost model.
Capturing those interactions in a compiler cost model is extremely hard. It requires a detailed model of the hardware microarchitecture that NVIDIA's internal compiler team has and their users don't. Even NVIDIA's compiler team uses heuristics -- the microarchitecture is too complex to model exactly.
CuAsmRL sidesteps the cost model problem entirely. Instead of modeling the hardware, it measures the hardware. Candidate SASS schedules are compiled to cubin and executed. The measured latency is the reward signal. No microarchitecture model required. The hardware tells you what's better.
The gap between ptxas and optimal is non-trivial.
CuAsmRL evaluates on six common LLM kernels written in Triton, on an A100, including attention, fused feed-forward, RMSNorm, batched matmul, and GEMM with LeakyReLU. These are the kernels that matter -- the ones that dominate inference and training wall-clock time for transformer models.
Across them, CuAsmRL improves throughput over what Triton and ptxas emit by 9% on average and up to 26%. Not 1-2%. Enough to matter for kernels that make up a significant fraction of total inference compute.
I want to be careful here because the paper presents results that I don't want to overstate. The gains are real and measured. They're also workload-specific and architecture-specific. A SASS schedule optimized for Ampere won't transfer to Hopper. The CuAsmRL optimization loop has to run separately for each target architecture. SASS is not portable.
The portability limitation is also the precision advantage. Because SASS is architecture-specific, an optimal SASS schedule can exploit microarchitectural details that no higher-level abstraction can. The gap between "best Triton kernel" and "best possible SASS kernel for this specific operation on this specific GPU" is not zero. CuAsmRL explores that gap automatically, instead of one expert and one kernel at a time.
Why this connects to everything else in the stack.
I've spent months writing about the kernel optimization space. Triton reaching performance parity with hand-tuned CUDA C++. NVIDIA's CUDA Tile IR backend making Blackwell's peak performance accessible from Triton. Kernel-Smith's evolutionary RL optimizer generating production kernels for arbitrary hardware backends. CuAsmRL is the layer below all of that.
Triton compiles to PTX. PTX compiles to SASS via ptxas. ptxas is a heuristic. CuAsmRL improves what ptxas generates.
The interaction is important: a Triton kernel goes through the same PTX-to-SASS compilation as a hand-written CUDA C++ kernel. Whatever suboptimality ptxas introduces, both suffer equally. CuAsmRL's SASS optimization applies downstream of Triton -- you can take the SASS that Triton generates, run CuAsmRL on it, and get better schedules without changing the Triton source.
This means the kernel optimization stack now has optimizable layers at: Triton source (Kernel-Smith, CUDA-L1) → PTX (ptxas optimization flags) → SASS (CuAsmRL). The composition of these three layers -- better Triton code, compiled through ptxas, then SASS-level scheduled by RL -- approaches the theoretical hardware ceiling from three independent angles simultaneously.
The undocumented ISA problem.
SASS is undocumented by design. NVIDIA deliberately keeps the SASS ISA specification private. Their reasoning: it lets them change the microarchitecture without breaking user code. If users wrote directly in SASS, any hardware change that modified instruction semantics would break their code. By keeping users at PTX, NVIDIA can evolve the hardware freely.
This creates a specific asymmetry: NVIDIA knows the SASS semantics perfectly and can optimize ptxas with full knowledge. Users see the PTX layer and accept whatever ptxas generates. The performance gap between "what NVIDIA's engineers could write in SASS if they optimized every kernel manually" and "what ptxas generates" is the gap CuAsmRL is exploring.
The dependency constraint approach -- you don't need to understand instruction semantics to reorder them, only to identify dependencies -- is the specific technique that makes SASS optimization tractable without the ISA documentation. You can infer register dependencies from the SASS encoding without knowing what any instruction does. You can measure execution time without knowing why one schedule is faster than another. The measurement substitutes for the missing documentation.
SASS is below PTX. ptxas is a heuristic. The SASS it generates is not optimal.
CuAsmRL attacks this layer with RL and measured execution time as the reward signal, instead of an expert's trial and error.
no ISA documentation required. dependency constraints are inferable from bytecode. execution time is measurable. the hardware tells you which schedule is better.
the three-layer optimization stack is now complete: triton source → ptxas → sass. kernel-smith attacks layer one. cuda-l1 attacks layer one differently. cuasmrl attacks layer three. the composition approaches the hardware ceiling from both ends simultaneously. the middle layer -- ptxas itself -- is the one nobody is attacking. that's the next paper.
P.S. The SASS architecture-specificity creates an interesting product question. A CuAsmRL-optimized FlashAttention for Ampere is different SASS from a CuAsmRL-optimized FlashAttention for Hopper, which is different from Blackwell. You can't ship one binary. You ship an optimization loop that runs on the target architecture before deployment, generates the optimal SASS for that specific GPU, and compiles to cubin locally. This is the "JIT kernel optimization" model -- not ahead-of-time optimized kernels, but kernels that optimize themselves for the specific hardware they land on. karpathy's autoresearch project (visible in the AutoKernel reference list) is exploring this direction: RL agents that run kernel research on single-GPU nanochat training at deployment time. The trajectory is toward kernels that are never shipped pre-optimized -- they optimize on first run, cache the result, and start from that cache on subsequent runs. Kernel optimization as a runtime property, not a compile-time one.
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.