interplane.Get Omega
Read in your language

CUDApp

CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit.

Brought by drakestapleton

GitHub aien-dev/CUDApp#234 (code only)

closed derived f95727479fea1027 #234

Imported from GitHub aien-dev/CUDApp#234 (code only)

GitHub's metadata for this pull request is unavailable: its state is DERIVED from the commits (merged: the head is reachable from this project's main; open: GitHub kept a merge ref; else closed).

Base 4bbccf084b7309ae89e126c890324e377478b3be · Head c94933d68cf62da81c314aca4bf782c25cc9c3d3

Fetch it

A git bundle of the pull request's head, 28499 bytes.

curl -fsSL https://interplane.io/drakestapleton/CUDApp/patches/f95727479fea1027.bundle -o f95727479fea1027.bundle
git fetch f95727479fea1027.bundle refs/pull/234/head

Raw bundle · Diff

Provenance

This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record:

github-import 1
aien-dev/CUDApp
234
c94933d68cf62da81c314aca4bf782c25cc9c3d3
{"kind":"github-import","owner":"aien-dev","repo":"CUDApp","number":234,"url":"https://github.com/aien-dev/CUDApp/pull/234","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:38:57Z","metadata":"unavailable","state_derived":true}

Changes

diff --git a/Makefile b/Makefile
index 0a8a8b80..ff0a43dd 100644
--- a/Makefile
+++ b/Makefile
@@ -330,11 +330,64 @@ $(OUT_DIR)/gpu_lmhead_fp8_study: tests/gpu_lmhead_fp8_study.c src/omega_gpu_bf16
 # permutation, budgets) plus the warp simulator (512 threads); the chip gate is tools/run_gpu_fp8gemm_chip.sh under the GB10 lock.
 .PHONY: test-gpu-fp8gemm
 GPU_FP8GEMM_TEST = $(OUT_DIR)/gpu_fp8gemm_test
-$(GPU_FP8GEMM_TEST): tests/gpu_fp8gemm_test.c tests/bw_warp_sim_k.h src/omega_gpu_fp8gemm_api.h src/omega_blackwell_codegen_gemm.h src/omega_gpu_fp8_api.h $(OUT_DIR)/libomega_gpu.a
+$(GPU_FP8GEMM_TEST): tests/gpu_fp8gemm_test.c tests/bw_warp_sim_k.h src/omega_gpu_fp8gemm_api.h src/omega_gpu_fp8gemm_internal.h src/omega_blackwell_codegen_gemm.h src/omega_gpu_fp8_api.h $(OUT_DIR)/libomega_gpu.a
 	$(CC) $(CFLAGS) -ffp-contract=off -DWS_MAX_THREADS=512 -Itests -o $@ tests/gpu_fp8gemm_test.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm
+# P-DRA-4 DRA-67: the decode levers are env-gated and OFF by default; --spec-of checks the spec the stroke path resolves.
+FP8GEMM_STROKE_GU = --spec-of 2048,16,4,1
 test-gpu-fp8gemm: $(GPU_FP8GEMM_TEST)
 	$(GPU_FP8GEMM_TEST) --host-only
 	$(GPU_FP8GEMM_TEST) --sim
+	env -u AIEN_OMEGA_FP8GEMM_X_AHEAD $(GPU_FP8GEMM_TEST) $(FP8GEMM_STROKE_GU) --expect "rowmap=1 mt=4 x_ahead=0"
+	env AIEN_OMEGA_FP8GEMM_X_AHEAD=0 $(GPU_FP8GEMM_TEST) $(FP8GEMM_STROKE_GU) --expect "x_ahead=0"
+	env AIEN_OMEGA_FP8GEMM_X_AHEAD=yes $(GPU_FP8GEMM_TEST) $(FP8GEMM_STROKE_GU) --expect "x_ahead=0"
+	env AIEN_OMEGA_FP8GEMM_X_AHEAD=1 $(GPU_FP8GEMM_TEST) $(FP8GEMM_STROKE_GU) --expect "rowmap=1 mt=4 x_ahead=1"
+	env AIEN_OMEGA_FP8GEMM_X_AHEAD=1 $(GPU_FP8GEMM_TEST) --spec-of 2048,16,8,0 --warps 4 --expect "x_ahead=0"
+	for v in "" 0 yes 2 " 1" "1 " 11; do \
+	  env AIEN_OMEGA_FP8GEMM_X_AHEAD="$$v" $(GPU_FP8GEMM_TEST) $(FP8GEMM_STROKE_GU) --expect "x_ahead=0" || exit 1; done
+	@# DRA-78: AIEN_OMEGA_FP8GEMM_CTA_BUDGET; unset = the incumbent rule exactly (segs >= 64: 2, >= 8: 12, else 96)
+	env -u AIEN_OMEGA_FP8GEMM_CTA_BUDGET $(GPU_FP8GEMM_TEST) --spec-of 512,64,4,1 --expect "ctas=2 x_ahead=0"
+	env -u AIEN_OMEGA_FP8GEMM_CTA_BUDGET $(GPU_FP8GEMM_TEST) --spec-of 2048,64,4,1 --expect "ctas=2"
+	env -u AIEN_OMEGA_FP8GEMM_CTA_BUDGET $(GPU_FP8GEMM_TEST) --spec-of 2048,8,4,1 --expect "ctas=12"
+	env -u AIEN_OMEGA_FP8GEMM_CTA_BUDGET $(GPU_FP8GEMM_TEST) --spec-of 512,7,4,1 --expect "ctas=96"
+	env -u AIEN_OMEGA_FP8GEMM_CTA_BUDGET $(GPU_FP8GEMM_TEST) --spec-of 2048,1,0,0 --expect "ctas=96"
+	env AIEN_OMEGA_FP8GEMM_CTA_BUDGET=4 $(GPU_FP8GEMM_TEST) --spec-of 2048,1,0,0 --expect "ctas=4"
+	env AIEN_OMEGA_FP8GEMM_CTA_BUDGET=512:4 $(GPU_FP8GEMM_TEST) --spec-of 512,64,4,1 --expect "ctas=4"
+	env AIEN_OMEGA_FP8GEMM_CTA_BUDGET=512:4 $(GPU_FP8GEMM_TEST) --spec-of 2048,64,4,1 --expect "ctas=2"
+	env AIEN_OMEGA_FP8GEMM_CTA_BUDGET=512:4 $(GPU_FP8GEMM_TEST) --spec-of 512,7,4,1 --expect "ctas=96"
+	env AIEN_OMEGA_FP8GEMM_CTA_BUDGET=512:4,2048:6 $(GPU_FP8GEMM_TEST) --spec-of 2048,8,4,1 --expect "ctas=6"
+	env AIEN_OMEGA_FP8GEMM_CTA_BUDGET=512:4,2048:6 $(GPU_FP8GEMM_TEST) --spec-of 2048,1,0,0 --expect "ctas=96"
+	env AIEN_OMEGA_FP8GEMM_CTA_BUDGET=2048:6,3 $(GPU_FP8GEMM_TEST) --spec-of 512,64,4,1 --expect "ctas=3"
+	env AIEN_OMEGA_FP8GEMM_CTA_BUDGET=2048:6,3 $(GPU_FP8GEMM_TEST) --spec-of 2048,64,4,1 --expect "ctas=6"
+	env AIEN_OMEGA_FP8GEMM_CTA_BUDGET=1024 $(GPU_FP8GEMM_TEST) --spec-of 512,64,4,1 --expect "ctas=1024"
+	env AIEN_OMEGA_FP8GEMM_CTA_BUDGET=512:4 $(GPU_FP8GEMM_TEST) --spec-of 512,64,4,1 --ctas 7 --expect "ctas=7"
+	@# malformed values are refused whole: the incumbent budget stays (512,64 -> 2)
+	for v in "" 0 1025 -1 abc 4x " 4" "4," ",4" "512:" ":4" "512:0" "512:4,,3" "512:4,512:5" "3,4" "512:4;3" "16385:4" "512:4:4"; do \
+	  env AIEN_OMEGA_FP8GEMM_CTA_BUDGET="$$v" $(GPU_FP8GEMM_TEST) --spec-of 512,64,4,1 --expect "ctas=2" || exit 1; done
+	@# DRA-79: AIEN_OMEGA_FP8GEMM_ROW_AHEAD; only exactly "1" turns it on, and only at one K step per row (k 512 at lane 16, k 256 at lane 8)
+	env -u AIEN_OMEGA_FP8GEMM_ROW_AHEAD $(GPU_FP8GEMM_TEST) --spec-of 512,64,4,1 --expect "row_ahead=0 ctas=2"
+	env -u AIEN_OMEGA_FP8GEMM_ROW_AHEAD $(GPU_FP8GEMM_TEST) --spec-of 512,8,4,1 --expect "row_ahead=0"
+	env AIEN_OMEGA_FP8GEMM_ROW_AHEAD=1 $(GPU_FP8GEMM_TEST) --spec-of 512,64,4,1 --expect "row_ahead=1 rowmap=1 mt=4 ctas=2 x_ahead=0"
+	env AIEN_OMEGA_FP8GEMM_ROW_AHEAD=1 $(GPU_FP8GEMM_TEST) --spec-of 512,8,4,1 --expect "row_ahead=1 ctas=12"
+	env AIEN_OMEGA_FP8GEMM_ROW_AHEAD=1 AIEN_OMEGA_FP8GEMM_X_AHEAD=1 AIEN_OMEGA_FP8GEMM_CTA_BUDGET=512:4 $(GPU_FP8GEMM_TEST) --spec-of 512,64,4,1 --expect "row_ahead=1 x_ahead=1 ctas=4"
+	env AIEN_OMEGA_FP8GEMM_ROW_AHEAD=1 $(GPU_FP8GEMM_TEST) --spec-of 2048,64,4,1 --expect "row_ahead=0"
+	env AIEN_OMEGA_FP8GEMM_ROW_AHEAD=1 $(GPU_FP8GEMM_TEST) --spec-of 2048,1,0,0 --expect "row_ahead=0"
+	for v in "" 0 yes 2 " 1" "1 " 11; do \
+	  env AIEN_OMEGA_FP8GEMM_ROW_AHEAD="$$v" $(GPU_FP8GEMM_TEST) --spec-of 512,64,4,1 --expect "row_ahead=0" || exit 1; done
+	@# DRA-80/81: AIEN_OMEGA_FP8GEMM_X_RESIDENT / _SHARED_ONE_PASS; only exactly "1"; mapped calls only (the dense calls are DRA-89's);
+	@# the decode stroke records segs = 9 N at caller mt 0, so 512,72,0,1 is the down projection at N 8 and 512,36,0,1 at N 4
+	env -u AIEN_OMEGA_FP8GEMM_X_RESIDENT -u AIEN_OMEGA_FP8GEMM_SHARED_ONE_PASS $(GPU_FP8GEMM_TEST) --spec-of 512,72,0,1 --expect "x_resident=0"
+	env -u AIEN_OMEGA_FP8GEMM_X_RESIDENT -u AIEN_OMEGA_FP8GEMM_SHARED_ONE_PASS $(GPU_FP8GEMM_TEST) --spec-of 2048,72,0,1 --expect "x_resident=0"
+	env AIEN_OMEGA_FP8GEMM_X_RESIDENT=1 $(GPU_FP8GEMM_TEST) --spec-of 512,72,0,1 --expect "x_resident=1 mt=4 rowmap=1"
+	env AIEN_OMEGA_FP8GEMM_X_RESIDENT=1 AIEN_OMEGA_FP8GEMM_X_AHEAD=1 AIEN_OMEGA_FP8GEMM_ROW_AHEAD=1 $(GPU_FP8GEMM_TEST) --spec-of 512,72,0,1 --expect "x_resident=1 x_ahead=0 row_ahead=0"
+	env AIEN_OMEGA_FP8GEMM_X_RESIDENT=1 $(GPU_FP8GEMM_TEST) --spec-of 2048,72,0,1 --expect "x_resident=1 mt=4"
+	env AIEN_OMEGA_FP8GEMM_X_RESIDENT=1 $(GPU_FP8GEMM_TEST) --spec-of 2048,1,0,0 --expect "x_resident=0"
+	env AIEN_OMEGA_FP8GEMM_SHARED_ONE_PASS=1 $(GPU_FP8GEMM_TEST) --spec-of 512,72,0,1 --expect "x_resident=1 mt=8"
+	env AIEN_OMEGA_FP8GEMM_SHARED_ONE_PASS=1 $(GPU_FP8GEMM_TEST) --spec-of 512,45,0,1 --expect "x_resident=1 mt=8"
+	env AIEN_OMEGA_FP8GEMM_SHARED_ONE_PASS=1 $(GPU_FP8GEMM_TEST) --spec-of 512,36,0,1 --expect "x_resident=0 mt=4"
+	env AIEN_OMEGA_FP8GEMM_SHARED_ONE_PASS=1 $(GPU_FP8GEMM_TEST) --spec-of 512,72,4,1 --expect "x_resident=0 mt=4"
+	env AIEN_OMEGA_FP8GEMM_SHARED_ONE_PASS=1 AIEN_OMEGA_FP8GEMM_X_RESIDENT=1 $(GPU_FP8GEMM_TEST) --spec-of 2048,72,0,1 --expect "x_resident=1"
+	for v in "" 0 yes 2 " 1" "1 " 11; do \
+	  env AIEN_OMEGA_FP8GEMM_X_RESIDENT="$$v" AIEN_OMEGA_FP8GEMM_SHARED_ONE_PASS="$$v" $(GPU_FP8GEMM_TEST) --spec-of 512,72,0,1 --expect "x_resident=0" || exit 1; done
 
 # OWN-30B (2026-10-13): host-only audit that every launcher declares peak + 2 registers (the chip hung at peak + 1).
 .PHONY: test-gpu-gpr-boundary
diff --git a/src/omega_blackwell_codegen_gemm.c b/src/omega_blackwell_codegen_gemm.c
index 10bf71b4..68362874 100644
--- a/src/omega_blackwell_codegen_gemm.c
+++ b/src/omega_blackwell_codegen_gemm.c
@@ -2,8 +2,10 @@
 /* omega_blackwell_codegen_gemm.c: FP8 e4m3 block-scaled grouped GEMM for prefill (OWN-30B builder F item 26). See the
  * header for the contract. The emitter helpers are copies of omega_blackwell_codegen_moe.c's (same chip-learned
  * scheduling rules) plus one addition: weight and scale prefetch loads use scoreboards 3 (buffer A) and 4 (buffer B)
- * and are waited for only by the step that decodes them, so the next step's weights stream while this step computes. */
+ * and are waited for only by the step that decodes them, so the next step's weights stream while this step computes; the
+ * staging words of x' are loaded one step ahead the same way on scoreboard 5 (L312 lever 3, 2026-10-21). */
 #include "omega_blackwell_codegen_gemm.h"
+#include "omega_blackwell_qmd.h"
 #ifndef OMEGA_GPU_NO_POSIX
 #include <stdlib.h>
 #endif
@@ -72,6 +74,7 @@ static void movi(Em *e, int d, uint32_t imm) { BlackwellIRInsn i = I0(BW_IR_MOV_
 static void movrz(Em *e, int d) { BlackwellIRInsn i = I0(BW_IR_MOV_RZ); i.dst_vreg = d; emit(e, i, K_FIXED); }
 /* d = a * imm + c (c NOREG = RZ); a may be a sub-register of a quad */
 static void imadi(Em *e, int d, int a, unsigned asub, uint32_t imm, int c) { BlackwellIRInsn i = I0(BW_IR_IMAD); i.dst_vreg = d; i.src1_vreg = a; i.src1_subreg = (uint8_t)asub; i.imm = imm; i.src3_vreg = c; emit(e, i, K_FIXED); }
+static void imadi_sub(Em *e, int d, unsigned dsub, int a, unsigned asub, uint32_t imm, int c) { BlackwellIRInsn i = I0(BW_IR_IMAD); i.dst_vreg = d; i.dst_subreg = (uint8_t)dsub; i.src1_vreg = a; i.src1_subreg = (uint8_t)asub; i.imm = imm; i.src3_vreg = c; emit(e, i, K_FIXED); }
 /* d = a * b + c (registers) */
 static void imadr(Em *e, int d, int a, int b, int c) { BlackwellIRInsn i = I0(BW_IR_IMAD); i.dst_vreg = d; i.src1_vreg = a; i.src2_vreg = b; i.src3_vreg = c; emit(e, i, K_FIXED); }
 /* d64 = a * imm + c64 */
@@ -128,22 +131,51 @@ static void ldw_pf(Em *e, BlackwellIROpcode op, int d, int addr64, uint32_t imm,
 }
 static void consume(Em *e, unsigned sb) { e->pending |= e->held & (1u << sb); e->held &= ~(1u << sb); }
 
+/* The staging words of one K step (NJ per thread) into xv[], loaded one step AHEAD on scoreboard 5 (L312 lever 3): the
+ * STS of the step that reads them waits for them (consume(5)), so the x' latency hides behind the previous step's
+ * compute instead of sitting between its barriers. Addresses in rounds of 4 so the temporaries stay few; every load
+ * sets SB_RD and the next waits on it (the address read), as every load batch of this file does. xs (plain) or xso (rowmap)
+ * already point at the step to load. */
+static void x_prefetch(Em *e, uint32_t NJ, uint32_t T, uint32_t ROWW, uint32_t K, int RM, int one, int xs, int xso, const int *xb, const int *xv, int udesc) {
+    for (uint32_t j0 = 0; j0 < NJ; j0 += 4) {
+        const uint32_t nj = NJ - j0 < 4 ? NJ - j0 : 4;
+        int xa[4];
+        for (uint32_t q = 0; q < nj; q++) xa[q] = V64(e);
+        if (e->err) return;
+        for (uint32_t q = 0; q < nj; q++) { const uint32_t pos = (j0 + q) * T; if (RM) imadw(e, xa[q], xso, 1u, xb[j0 + q]); else imadw(e, xa[q], one, ((pos / ROWW) * K + pos % ROWW) * 4u, xs); }
+        for (uint32_t q = 0; q < nj; q++) ldw_pf(e, BW_IR_LDG_E, xv[j0 + q], xa[q], 0, udesc, 5);
+    }
+}
+
 static int log2u(uint32_t v) { int l = 0; while ((1u << l) < v) l++; return (1u << l) == v ? l : -1; }
 
 static int spec_ok(const OmegaFp8GemmSpec *s) {
     if (!s) return 0;
+    if (s->x_resident > 1u) return 0;
+    const int XR = s->x_resident != 0;
     if (s->lane_bytes != 8 && s->lane_bytes != 16) return 0;
-    if (s->mt == 0 || (s->mt & (s->mt - 1)) || s->mt * 128u * s->lane_bytes > OMEGA_GEMM_MAX_SHARED) return 0;
-    if (s->warps < 1 || s->warps > 32 || (s->warps & (s->warps - 1)) || (s->mt * s->lane_bytes) % s->warps) return 0; /* power-of-two warps: the staging words per thread are whole */
+    if (s->mt == 0 || (s->mt & (s->mt - 1))) return 0;
+    if (XR) { if (s->mt > 8u || (uint64_t)s->mt * s->k * 4u > OMEGA_BW_QMD_MAX_SHARED_BYTES) return 0; } /* the x' block of a pass */
+    else if (s->mt * 128u * s->lane_bytes > OMEGA_GEMM_MAX_SHARED) return 0;
+    if (s->warps < 1 || s->warps > 32 || (s->warps & (s->warps - 1))) return 0;
+    if (!XR && (s->mt * s->lane_bytes) % s->warps) return 0; /* power-of-two warps: the staging words per thread are whole */
     if (s->k == 0 || s->k > 16384u || s->k % 128u || s->k % (32u * s->lane_bytes)) return 0;
+    if (XR && s->k % (32u * s->warps)) return 0; /* a staging word's row is (j * threads) / k, one per word index j */
     uint32_t ks = s->k / (32u * s->lane_bytes);
     if (ks % 2u && ks > 3u) return 0; /* odd step counts are fully unrolled: at most 3 */
-    if (s->mutant < 0 || s->mutant > 4) return 0;
-    if (s->rowmap > 1u || (s->rowmap && s->mt > 4u)) return 0; /* the mapped form keeps NJ row bases and MT y rows in registers: mt 8 needs 135 at 16 warps, past the file */
+    if (s->mutant < 0 || s->mutant > 9) return 0;
+    if (s->rowmap > 1u || (s->rowmap && s->mt > 4u && !XR)) return 0; /* the mapped form keeps NJ row bases and MT y rows in registers: mt 8 needs 135 at 16 warps, past the file */
+    if (s->x_ahead > 1u || (s->x_ahead && (XR || s->mt * s->lane_bytes / s->warps > 16u))) return 0; /* lever 3 holds NJ staging words in registers: NJ > 16 (under 8 warps at mt * lane_bytes 128) is not a served shape */
+    if (s->row_ahead > 1u || (s->row_ahead && (XR || ks != 1u))) return 0; /* DRA-79: the next row's weights fill the second register set, which only the one-step K loop leaves free; x_resident has its own cross-row prefetch */
+    if ((s->mutant == 5 || s->mutant == 6) && !s->row_ahead) return 0;
+    if (s->mutant >= 7 && !XR) return 0;
     return 1;
 }
 uint32_t omega_fp8gemm_steps(const OmegaFp8GemmSpec *spec) { return spec_ok(spec) ? spec->k / (32u * spec->lane_bytes) : 0; }
-uint32_t omega_fp8gemm_shared_bytes(const OmegaFp8GemmSpec *spec) { return spec_ok(spec) ? spec->mt * 128u * spec->lane_bytes : 0u; }
+uint32_t omega_fp8gemm_shared_bytes(const OmegaFp8GemmSpec *spec) {
+    if (!spec_ok(spec)) return 0u;
+    return spec->x_resident ? spec->mt * spec->k * 4u : spec->mt * 128u * spec->lane_bytes;
+}
 
 /* e4m3 byte i of word w -> f32 bits (value * 2^-120): ((b & 0x7F) << 20) | ((b & 0x80) << 24) */
 static void decode_byte(Em *e, int f, int wq, unsigned word, unsigned i, int u, int a, int s) {
@@ -156,8 +188,10 @@ static void decode_byte(Em *e, int f, int wq, unsigned word, unsigned i, int u,
     else imadi(e, f, s, 0, 1u, a);
 }
 
+static int prog_resident(const OmegaFp8GemmSpec *spec, BlackwellIRProgram *prog);
 int omega_blackwell_codegen_fp8gemm_prog(const OmegaFp8GemmSpec *spec, BlackwellIRProgram *prog) {
     if (!spec_ok(spec) || !prog) return -1;
+    if (spec->x_resident) return prog_resident(spec, prog); /* x_resident 0: the program below, byte for byte */
     const uint32_t K = spec->k, LB = spec->lane_bytes, MT = spec->mt, W = spec->warps;
     const uint32_t KS = K / (32u * LB), BPS = 32u * LB / 128u, LPB = 128u / LB, KB = K / 128u, WORDS = LB / 4u;
     const uint32_t U = KS % 2u == 0 ? 2u : KS; /* K steps per loop iteration (the A/B register sets alternate) */
@@ -220,7 +254,30 @@ int omega_blackwell_codegen_fp8gemm_prog(const OmegaFp8GemmSpec *spec, Blackwell
     for (int q = 0; q < 4; q++) xq[q] = V128(e);
     for (int b = 0; b < 2; b++) { wq[b] = LB == 16 ? V128(e) : V64(e); sc[b] = V(e); }
     for (int i = 0; i < 4; i++) fr[i] = V(e);
+    /* x_ahead (L312 lever 3): the next K step's staging words, loaded one step ahead (x_prefetch) into NJ registers held
+     * across the step; x_ahead 0 keeps the incumbent program byte for byte (the staging words loaded inside the step) */
+    const int XA = spec->x_ahead != 0;
+    int xv[16];
+    if (XA) for (uint32_t j = 0; j < NJ; j++) xv[j] = V(e);
+    /* row_ahead (DRA-79, KS 1): wq[1]/sc[1] hold the weights of the row the next pass computes, in flight on scoreboard 4. The
+     * row-loop head finds the warp's next row (rg + stride, clamped like rg) as a row delta dr and a scale-block delta dsb; the pass
+     * prologue waits, moves wq[1]/sc[1] into wq[0]/sc[0] and loads the next pass's row: the same row (sel 0) unless this is the
+     * row's last pass (sel 1). row_ahead 0 keeps the incumbent program byte for byte. */
+    const int RA = spec->row_ahead != 0;
+    int dr = NOREG, dsb = NOREG;
+    if (RA) { dr = V(e); dsb = V(e); }
     if (e->err) return -1;
+    if (RA) { /* the first row of the warp (the row-loop head's arithmetic), loaded before the loop */
+        imadi(e, rg, base, 0, 1, warp);
+        imadi(e, t1, rg, 0, 0xffffffffu, nm1); shr(e, over, t1, 0, 31);
+        imadi(e, d, nm1, 0, 0xffffffffu, rg);
+        imadr(e, tmp, over, d, NOREG); imadi(e, rgc, tmp, 0, 0xffffffffu, rg);
+        imadw(e, pw, rgc, K, wbase); imadw(e, pw, wlane, 1, pw);
+        shr(e, tmp, rgc, 0, 7);
+        imadw(e, ps, tmp, KB * 4u, sbase); imadw(e, ps, slane, 1, ps);
+        ldw_pf(e, ldw, wq[1], pw, 0, udesc, 4);
+        ldw_pf(e, BW_IR_LDG_E, sc[1], ps, 0, udesc, 4);
+    }
 
     /* ---- weight-row loop (uniform per CTA) ---- */
     const int L_rg = here(e);
@@ -237,6 +294,15 @@ int omega_blackwell_codegen_fp8gemm_prog(const OmegaFp8GemmSpec *spec, Blackwell
     imadw(e, pyrg, rg, 4, py);
     imadi(e, lo, over, 0, 1, lane);
     imadi(e, rowp, row0, 0, 1, NOREG); imadi(e, rem, cnt, 0, 1, NOREG); imadi(e, pc, passes, 0, 1, NOREG);
+    if (RA) { /* the warp's next row: rg + stride (mutant 5: + 1), clamped to n - 1; deltas from rgc (both >= 0) */
+        imadi(e, t, stride, 0, 1, rg);
+        if (spec->mutant == 5) imadi(e, t, one, 0, 1, t);
+        imadi(e, t1, t, 0, 0xffffffffu, nm1); shr(e, fl, t1, 0, 31);                /* (rg2 > n - 1) */
+        imadi(e, d, nm1, 0, 0xffffffffu, t);
+        imadr(e, tq, fl, d, NOREG); imadi(e, t, tq, 0, 0xffffffffu, t);              /* rg2 clamped */
+        imadi(e, dr, rgc, 0, 0xffffffffu, t);                                         /* dr = rgc2 - rgc */
+        shr(e, t, t, 0, 7); shr(e, tq, rgc, 0, 7); imadi(e, dsb, tq, 0, 0xffffffffu, t); /* dsb = rgc2/128 - rgc/128 */
+    }
 
     /* ---- pass loop: MT rows of x per pass ---- */
     const int L_pass = here(e);
@@ -257,8 +323,23 @@ int omega_blackwell_codegen_fp8gemm_prog(const OmegaFp8GemmSpec *spec, Blackwell
     }
     imadw(e, pwc, one, 0, pw); imadw(e, psc, one, 0, ps);
     for (uint32_t m = 0; m < MT; m++) movrz(e, acc[m]);
-    ldw_pf(e, ldw, wq[0], pwc, 0, udesc, 3);
-    ldw_pf(e, BW_IR_LDG_E, sc[0], psc, 0, udesc, 3);
+    if (RA) {
+        consume(e, 4);
+        for (uint32_t w = 0; w < (LB == 16 ? 4u : 2u); w++) imadi_sub(e, wq[0], w, wq[1], w, 1, NOREG);
+        imadi(e, sc[0], sc[1], 0, 1, NOREG);
+        int pa = V64(e), pb = V64(e), sel = V(e), sd = V(e);
+        if (e->err) return -1;
+        if (spec->mutant == 6) movi(e, sel, 1);
+        else { imadi(e, sel, one, 0, 0xfffffffeu, pc); shr(e, sel, sel, 0, 31); } /* 1 iff pc == 1: this row's last pass */
+        imadr(e, sd, sel, dr, NOREG); imadw(e, pa, sd, K, pw);
+        imadr(e, sd, sel, dsb, NOREG); imadw(e, pb, sd, KB * 4u, ps);
+        ldw_pf(e, ldw, wq[1], pa, 0, udesc, 4);
+        ldw_pf(e, BW_IR_LDG_E, sc[1], pb, 0, udesc, 4);
+    } else {
+        ldw_pf(e, ldw, wq[0], pwc, 0, udesc, 3);
+        ldw_pf(e, BW_IR_LDG_E, sc[0], psc, 0, udesc, 3);
+    }
+    if (XA) x_prefetch(e, NJ, T, ROWW, K, RM, one, xs, xso, xb, xv, udesc); /* step 0's x' words */
     movi(e, cntk, KS / U);
 
     /* ---- K loop: U steps per iteration ---- */
@@ -267,17 +348,18 @@ int omega_blackwell_codegen_fp8gemm_prog(const OmegaFp8GemmSpec *spec, Blackwell
     for (uint32_t us = 0; us < U; us++) {
         const int cur = (int)(us & 1u), nxt = 1 - cur;
         const unsigned sbc = cur ? 4u : 3u, sbn = nxt ? 4u : 3u;
-        /* addresses first (fixed-latency ops would otherwise wait for the loads below), then loads back to back; the
-         * staging words go in rounds of 4 so the temporaries stay few */
+        /* addresses first (fixed-latency ops would otherwise wait for the loads below), then loads back to back */
         const int last = us + 1 == U, prefetch = !last || KS > U;
-        int pwn = -1, psn = -1;
+        int pwn = -1, psn = -1, nf = -1;
         if (prefetch) { pwn = V64(e); psn = V64(e); }
         int sa = V(e);
         if (e->err) return -1;
         if (prefetch && !last) {
             imadw(e, pwn, one, (us + 1) * 32u * LB, pwc); imadw(e, psn, one, spec->mutant == 2 ? 0u : (us + 1) * BPS * 4u, psc);
         } else if (prefetch) { /* the next iteration's step 0; the last iteration re-reads its own step (harmless, drained after the loop) */
-            int nf = V(e), inc = V(e), inc2 = V(e);
+            int inc, inc2;
+            if (XA) { inc = V(e); inc2 = V(e); nf = V(e); }
+            else { nf = V(e); inc = V(e); inc2 = V(e); }
             if (e->err) return -1;
             imadi(e, nf, one, 0, 0xfffffffeu, cntk);     /* cntk - 2 */
             shr(e, nf, nf, 0, 31);                       /* 1 iff cntk == 1 (the last iteration) */
@@ -285,18 +367,34 @@ int omega_blackwell_codegen_fp8gemm_prog(const OmegaFp8GemmSpec *spec, Blackwell
             imadi(e, inc, nf, 0, U * 32u * LB, NOREG); imadi(e, inc2, nf, 0, spec->mutant == 2 ? 0u : U * BPS * 4u, NOREG);
             imadw(e, pwn, inc, 1, pwc); imadw(e, psn, inc2, 1, psc);
         }
-        for (uint32_t j0 = 0; j0 < NJ; j0 += 4) {
-            const uint32_t nj = NJ - j0 < 4 ? NJ - j0 : 4;
-            int xv[4], xa[4];
-            for (uint32_t q = 0; q < nj; q++) { xv[q] = V(e); xa[q] = V64(e); }
-            if (e->err) return -1;
-            for (uint32_t q = 0; q < nj; q++) { const uint32_t pos = (j0 + q) * T; if (RM) imadw(e, xa[q], xso, 1u, xb[j0 + q]); else imadw(e, xa[q], one, ((pos / ROWW) * K + pos % ROWW) * 4u, xs); }
-            for (uint32_t q = 0; q < nj; q++) ldg32(e, xv[q], xa[q], udesc, q == 0);
-            if (prefetch && j0 == 0) {
+        if (XA) {
+            /* stage this step's x' words: they were loaded one step ago (the pass prologue for step 0), scoreboard 5 */
+            consume(e, 5);
+            for (uint32_t j = 0; j < NJ; j++) { imadi(e, sa, one, 0, j * T * 4u, sa0); sts32(e, sa, xv[j]); }
+            if (prefetch) {
                 ldw_pf(e, ldw, wq[nxt], pwn, 0, udesc, sbn);
                 ldw_pf(e, BW_IR_LDG_E, sc[nxt], psn, 0, udesc, sbn);
+                /* the next step's x' words, into the registers the STS above has read (its SB_RD wait orders the two); the
+                 * last step of the last iteration re-reads its own step (nf 0), never past the rows */
+                if (!last) { if (RM) imadi(e, xso, one, 0, ROWW * 4u, xso); else imadw(e, xs, one, ROWW * 4u, xs); }
+                else { if (RM) imadi(e, xso, nf, 0, ROWW * 4u, xso); else imadw(e, xs, nf, ROWW * 4u, xs); }
+                x_prefetch(e, NJ, T, ROWW, K, RM, one, xs, xso, xb, xv, udesc);
+            }
+        } else {
+            /* the incumbent: this step's staging words loaded and stored inside the step, in rounds of 4 */
+            for (uint32_t j0 = 0; j0 < NJ; j0 += 4) {
+                const uint32_t nj = NJ - j0 < 4 ? NJ - j0 : 4;
+                int xw[4], xa[4];
+                for (uint32_t q = 0; q < nj; q++) { xw[q] = V(e); xa[q] = V64(e); }
+                if (e->err) return -1;
+                for (uint32_t q = 0; q < nj; q++) { const uint32_t pos = (j0 + q) * T; if (RM) imadw(e, xa[q], xso, 1u, xb[j0 + q]); else imadw(e, xa[q], one, ((pos / ROWW) * K + pos % ROWW) * 4u, xs); }
+                for (uint32_t q = 0; q < nj; q++) ldg32(e, xw[q], xa[q], udesc, q == 0);
+                if (prefetch && j0 == 0) {
+                    ldw_pf(e, ldw, wq[nxt], pwn, 0, udesc, sbn);
+                    ldw_pf(e, BW_IR_LDG_E, sc[nxt], psn, 0, udesc, sbn);
+                }
+                for (uint32_t q = 0; q < nj; q++) { imadi(e, sa, one, 0, (j0 + q) * T * 4u, sa0); sts32(e, sa, xw[q]); }
             }
-            for (uint32_t q = 0; q < nj; q++) { imadi(e, sa, one, 0, (j0 + q) * T * 4u, sa0); sts32(e, sa, xv[q]); }
         }
         bar_sync(e);
         consume(e, sbc);
@@ -319,7 +417,7 @@ int omega_blackwell_codegen_fp8gemm_prog(const OmegaFp8GemmSpec *spec, Blackwell
             else ffma(e, acc[m], dot[m], sc[cur], 0, acc[m]);
         }
         bar_sync(e);
-        if (RM) imadi(e, xso, one, 0, ROWW * 4u, xso); else imadw(e, xs, one, ROWW * 4u, xs);
+        if (!XA) { if (RM) imadi(e, xso, one, 0, ROWW * 4u, xso); else imadw(e, xs, one, ROWW * 4u, xs); }
     }
     imadw(e, pwc, one, U * 32u * LB, pwc);
     imadw(e, psc, one, spec->mutant == 2 ? 0u : U * BPS * 4u, psc);
@@ -327,7 +425,8 @@ int omega_blackwell_codegen_fp8gemm_prog(const OmegaFp8GemmSpec *spec, Blackwell
     isetp_ge_u32(e, cntk, one);
     bra_if_p0(e, L_k);
     loop_end(e);
-    consume(e, 3); consume(e, 4);
+    consume(e, 3); if (!RA) consume(e, 4); /* row_ahead: scoreboard 4 is the next row, waited for at the next pass prologue */
+    if (XA) consume(e, 5); /* the last step's re-read x' words land before their registers go out of scope */
 
     /* ---- reduce and store, per row of the pass ---- */
     for (uint32_t m = 0; m < MT; m++)
@@ -361,6 +460,238 @@ int omega_blackwell_codegen_fp8gemm_prog(const OmegaFp8GemmSpec *spec, Blackwell
     const int L_end = here(e);
     patch_bra(e, bra_end, L_end);
     if (bra_empty >= 0) patch_bra(e, bra_empty, L_end);
+    if (RA) consume(e, 4); /* the last prefetched row lands before EXIT */
+    tail(e);
+    if (e->err) return -1;
+    return omega_bw_regalloc_solve(prog);
+}
+
+/* x_resident 1 (DRA-80): stage the pass's MT x' rows whole, then stream weight rows with no barrier and a cross-row
+ * weight prefetch (header). Same per-row arithmetic as above (decode, dot per 128-block, acc = fma(dot, S', acc), SHFL tree),
+ * so the result is bit-identical; the loop nest is pass (outer) then weight row (inner). */
+static int prog_resident(const OmegaFp8GemmSpec *spec, BlackwellIRProgram *prog) {
+    const uint32_t K = spec->k, LB = spec->lane_bytes, MT = spec->mt, W = spec->warps;
+    const uint32_t KS = K / (32u * LB), BPS = 32u * LB / 128u, LPB = 128u / LB, KB = K / 128u, WORDS = LB / 4u;
+    const uint32_t U = KS % 2u == 0 ? 2u : KS;
+    const uint32_t ROWW = 32u * LB, T = 32u * W, NR = MT * K / T; /* words per row step, threads, staging words per thread per pass */
+    const uint32_t WINC = U * 32u * LB, SINC = spec->mutant == 2 ? 0u : U * BPS * 4u; /* per K-loop iteration: weight bytes, scale bytes */
+    const int log2lpb = log2u(LPB), log2mt = log2u(MT);
+    const BlackwellIROpcode ldw = LB == 16 ? BW_IR_LDG_E_128 : BW_IR_LDG_E_64;
+    if (log2lpb < 0 || log2mt < 0 || MT > 8u || K % T) return -1;
+    omega_bw_ir_init(prog);
+    Em em; memset(&em, 0, sizeof em); em.p = prog;
+    Em *e = &em;
+    const int RM = spec->rowmap ? 1 : 0;
+
+    /* ---- prologue (as above) ---- */
+    int udesc = UV64(e), pseg = V64(e), px = V64(e), py = V64(e), nreg = V(e), stride = V(e);
+    int tid = V(e), cx = V(e), cy = V(e), warp = V(e), lane = V(e), one = V(e), tent = V64(e);
+    int wbase = V64(e), sbase = V64(e), rc = V64(e), row0 = V(e), cnt = V(e), tpass = V(e), passes = V(e);
+    int wlane = V(e), slane = V(e), xl = V(e), nm1 = V(e), ysn = V(e), sa0 = V(e), b0 = V(e), z = V(e);
+    int pxm = RM ? V64(e) : NOREG, pym = RM ? V64(e) : NOREG;
+    if (e->err) return -1;
+    ldcu64(e, udesc, 0x358);
+    ldc64(e, pseg, OMEGA_GEMM_ARG_SEG); ldc64(e, px, OMEGA_GEMM_ARG_X); ldc64(e, py, OMEGA_GEMM_ARG_Y);
+    ldc32(e, nreg, OMEGA_GEMM_ARG_N); ldc32(e, stride, OMEGA_GEMM_ARG_STRIDE);
+    if (RM) { ldc64(e, pxm, OMEGA_GEMM_ARG_XMAP); ldc64(e, pym, OMEGA_GEMM_ARG_YMAP); }
+    s2r(e, tid, BW_SR_TID_X); s2r(e, cx, BW_SR_CTAID_X); s2r(e, cy, BW_SR_CTAID_Y);
+    movi(e, one, 1);
+    shr(e, warp, tid, 0, 5);
+    andi(e, lane, tid, 0, 31);
+    imadw(e, tent, cy, OMEGA_GEMM_SEG_BYTES, pseg);
+    ldg_wide(e, BW_IR_LDG_E_64, wbase, tent, 0, udesc, 1);
+    ldg_wide(e, BW_IR_LDG_E_64, sbase, tent, 8, udesc, 0);
+    ldg_wide(e, BW_IR_LDG_E_64, rc, tent, 16, udesc, 0);
+    imadi(e, row0, rc, 0, 1, NOREG); imadi(e, cnt, rc, 1, 1, NOREG);
+    imadi(e, tpass, one, 0, MT - 1u, cnt); shr(e, passes, tpass, 0, (uint32_t)log2mt);
+    int bra_empty = -1;
+    if (spec->mutant != 4) {
+        imadi(e, z, one, 0, 0xffffffffu, cnt); shr(e, z, z, 0, 31); /* 1 iff cnt == 0 */
+        isetp_ge_u32(e, z, one);
+        bra_empty = bra_if_p0_fwd(e);
+    }
+    imadi(e, wlane, lane, 0, LB, NOREG);
+    shr(e, slane, lane, 0, (uint32_t)log2lpb); imadi(e, slane, slane, 0, 4, NOREG);
+    imadi(e, xl, lane, 0, 16, NOREG);
+    imadi(e, nm1, one, 0, 0xffffffffu, nreg);
+    imadi(e, ysn, nreg, 0, 4, NOREG);
+    imadi(e, sa0, tid, 0, 4, NOREG);
+    imadi(e, b0, cx, 0, W, NOREG);
+
+    /* loop-wide registers */
+    int base = V(e), nb = V(e), rg = V(e), over = V(e), t1 = V(e), d = V(e), tmp = V(e), rgc = V(e), lo = V(e), rgn = V(e);
+    int woff = V(e), soff = V(e), woffn = V(e), soffn = V(e), rowp = V(e), rem = V(e), pc = V(e), xo = V(e), cntk = V(e);
+    int pyrg = V64(e), pyr = V64(e), pya = V64(e), xs = V64(e), pwn = V64(e), psn = V64(e), t = V(e), tq = V(e), fl = V(e), sv = V(e);
+    int yi[8], ma = NOREG;
+    if (RM) { for (uint32_t m = 0; m < MT; m++) yi[m] = V(e); ma = V64(e); }
+    int acc[8], dot[8], xq[4], wq[2], sc[2], fr[4], u = V(e), a = V(e), sg = V(e), onef = V(e), dum = V(e);
+    for (uint32_t m = 0; m < MT; m++) { acc[m] = V(e); dot[m] = V(e); }
+    for (int q = 0; q < 4; q++) xq[q] = V128(e);
+    for (int b = 0; b < 2; b++) { wq[b] = LB == 16 ? V128(e) : V64(e); sc[b] = V(e); }
+    for (int i = 0; i < 4; i++) fr[i] = V(e);
+    if (e->err) return -1;
+
+    /* rgc = row r (= rbase + warp) clamped to n - 1, over = (r > n - 1); then the row's weight and scale byte offsets */
+#define ROW_OFFSETS(rbase, rr, wo, so)                                                                                  \
+    do {                                                                                                                \
+        imadi(e, rr, rbase, 0, 1, warp);                                                                                \
+        imadi(e, t1, rr, 0, 0xffffffffu, nm1); shr(e, over, t1, 0, 31);                                                \
+        imadi(e, d, nm1, 0, 0xffffffffu, rr);                                                                           \
+        imadr(e, tmp, over, d, NOREG); imadi(e, rgc, tmp, 0, 0xffffffffu, rr);                                         \
+        imadi(e, wo, rgc, 0, K, wlane);                                                                                 \
+        shr(e, tmp, rgc, 0, 7); imadi(e, so, tmp, 0, KB * 4u, slane);                                                  \
+    } while (0)
+
+    /* the first row's step 0, before the first pass stages (held on scoreboard 3 like every row's step 0 below) */
+    ROW_OFFSETS(b0, rgn, woffn, soffn);
+    imadw(e, pwn, woffn, 1, wbase); imadw(e, psn, soffn, 1, sbase);
+    ldw_pf(e, ldw, wq[0], pwn, 0, udesc, 3);
+    ldw_pf(e, BW_IR_LDG_E, sc[0], psn, 0, udesc, 3);
+    imadi(e, rowp, row0, 0, 1, NOREG); imadi(e, rem, cnt, 0, 1, NOREG); imadi(e, pc, passes, 0, 1, NOREG);
+
+    /* ---- pass loop: stage MT whole x' rows, one barrier ---- */
+    const int L_pass = here(e);
+    loop_begin(e);
+    {
+        int xr[8];
+        if (RM) {
+            /* x' row of sorted row rowp + m: XMAP[rowp + m] (mutant 8: XMAP[rowp] for every m), loads back to back */
+            for (uint32_t m = 0; m < MT; m++) xr[m] = V64(e);
+            if (e->err) return -1;
+            for (uint32_t m = 0; m < MT; m++) { imadi(e, tq, one, 0, spec->mutant == 8 ? 0u : m, rowp); imadw(e, ma, tq, 4u, pxm); ldg32(e, xr[m], ma, udesc, m == 0); }
+            for (uint32_t m = 0; m < MT; m++) { imadw(e, xr[m], xr[m], K * 4u, px); imadw(e, xr[m], sa0, 1, xr[m]); }
+        } else { imadw(e, xs, rowp, K * 4u, px); imadw(e, xs, sa0, 1, xs); }
+        /* word j of this thread: shared word j * T + tid = row (j * T) / K, column (j * T) % K + tid; rounds of 4 */
+        for (uint32_t j0 = 0; j0 < NR; j0 += 4) {
+            const uint32_t nj = NR - j0 < 4 ? NR - j0 : 4;
+            int xw[4], xa[4];
+            for (uint32_t q = 0; q < nj; q++) { xw[q] = V(e); xa[q] = V64(e); }
+            if (e->err) return -1;
+            for (uint32_t q = 0; q < nj; q++) {
+                const uint32_t j = j0 + q;
+                if (RM) imadw(e, xa[q], one, ((j * T) % K) * 4u, xr[(j * T) / K]); else imadw(e, xa[q], one, j * T * 4u, xs);
+            }
+            for (uint32_t q = 0; q < nj; q++) ldg32(e, xw[q], xa[q], udesc, q == 0);
+            for (uint32_t q = 0; q < nj; q++) { imadi(e, t, one, 0, (j0 + q) * T * 4u, sa0); sts32(e, t, xw[q]); }
+        }
+    }
+    bar_sync(e);
+    /* y rows of the pass: plain, row rowp + m at pyr + m * n * 4; mapped, YMAP[rowp + m] (uniform loads, once per pass) */
+    if (RM) for (uint32_t m = 0; m < MT; m++) { imadi(e, tq, one, 0, m, rowp); imadw(e, ma, tq, 4u, pym); ldg32(e, yi[m], ma, udesc, m == 0); }
+    else { imadr(e, tq, rowp, ysn, NOREG); imadw(e, pyr, tq, 1, py); }
+    imadi(e, base, b0, 0, 1, NOREG);
+
+    /* ---- weight-row loop (uniform per CTA): no barrier inside ---- */
+    const int L_rg = here(e);
+    loop_begin(e);
+    isetp_ge_u32(e, base, nreg);
+    const int bra_rows_done = bra_if_p0_fwd(e);
+    ROW_OFFSETS(base, rg, woff, soff);
+    imadi(e, lo, over, 0, 1, lane);
+    if (RM) imadw(e, pyrg, rg, 4, py); else imadw(e, pyrg, rg, 4, pyr);
+    /* the next row this warp runs: base + stride, or after this pass's last row the next pass's first row (b0) */
+    imadi(e, nb, stride, 0, 1, base);
+    if (spec->mutant == 9) imadi(e, t, base, 0, 1, NOREG); /* mutant 9: the current row again */
+    else {
+        imadi(e, t1, nb, 0, 0xffffffffu, nm1); shr(e, t1, t1, 0, 31); /* 1 iff nb > n - 1 */
+        imadi(e, d, b0, 0, 0xffffffffu, nb);                          /* nb - b0 */
+        imadr(e, tmp, t1, d, NOREG); imadi(e, t, tmp, 0, 0xffffffffu, nb);
+    }
+    ROW_OFFSETS(t, rgn, woffn, soffn);
+    for (uint32_t m = 0; m < MT; m++) movrz(e, acc[m]);
+    imadi(e, xo, xl, 0, 1, NOREG);
+    movi(e, cntk, KS / U);
+
+    /* ---- K loop: U steps per iteration, no barrier; step 0 of this row is already in flight on scoreboard 3 ---- */
+    const int L_k = here(e);
+    loop_begin(e);
+    for (uint32_t us = 0; us < U; us++) {
+        const int cur = (int)(us & 1u), nxt = 1 - cur;
+        const unsigned sbc = cur ? 4u : 3u, sbn = nxt ? 4u : 3u;
+        const int last = us + 1 == U;
+        int wa = V(e), sa = V(e);
+        if (e->err) return -1;
+        if (!last) { /* step us + 1 of this iteration */
+            imadi(e, wa, one, 0, (us + 1) * 32u * LB, woff); imadi(e, sa, one, 0, spec->mutant == 2 ? 0u : (us + 1) * BPS * 4u, soff);
+            imadw(e, pwn, wa, 1, wbase); imadw(e, psn, sa, 1, sbase);
+            ldw_pf(e, ldw, wq[nxt], pwn, 0, udesc, sbn);
+            ldw_pf(e, BW_IR_LDG_E, sc[nxt], psn, 0, udesc, sbn);
+        } else if (U == 2u) { /* even step count: step 0 of the next iteration, or of the next row after the last iteration */
+            if (KS > U) {
+                int nf = V(e);
+                if (e->err) return -1;
+                imadi(e, nf, one, 0, 0xfffffffeu, cntk); shr(e, nf, nf, 0, 31); imadi(e, nf, nf, 0, 0xffffffffu, one); /* 1 iff another iteration */
+                imadi(e, wa, woffn, 0, 0xffffffffu, woff); imadi(e, wa, one, 0, WINC, wa); imadr(e, wa, nf, wa, woffn);
+                imadi(e, sa, soffn, 0, 0xffffffffu, soff); imadi(e, sa, one, 0, SINC, sa); imadr(e, sa, nf, sa, soffn);
+            } else { imadi(e, wa, woffn, 0, 1, NOREG); imadi(e, sa, soffn, 0, 1, NOREG); }
+            imadw(e, pwn, wa, 1, wbase); imadw(e, psn, sa, 1, sbase);
+            ldw_pf(e, ldw, wq[0], pwn, 0, udesc, 3);
+            ldw_pf(e, BW_IR_LDG_E, sc[0], psn, 0, udesc, 3);
+        }
+        consume(e, sbc);
+        for (uint32_t m = 0; m < MT; m++) movrz(e, dot[m]);
+        for (uint32_t word = 0; word < WORDS; word++) {
+            for (unsigned i = 0; i < 4; i++) decode_byte(e, fr[i], wq[cur], word, i, u, a, sg);
+            for (uint32_t m0 = 0; m0 < MT; m0 += 4) {
+                const uint32_t nq = MT - m0 < 4 ? MT - m0 : 4;
+                for (uint32_t q = 0; q < nq; q++) {
+                    const uint32_t m = m0 + q, mm = spec->mutant == 3 ? (m ^ 1u) % MT : m;
+                    lds128(e, xq[q], xo, mm * (spec->mutant == 7 ? ROWW : K) * 4u + us * ROWW * 4u + word * 512u, q == 0);
+                }
+                for (uint32_t q = 0; q < nq; q++) for (unsigned i = 0; i < 4; i++) ffma(e, dot[m0 + q], fr[i], xq[q], i, dot[m0 + q]);
+            }
+        }
+        if (spec->mutant == 1) { movi(e, onef, 0x3f800000u); ffma(e, dum, sc[cur], onef, 0, onef); }
+        for (uint32_t m = 0; m < MT; m++) {
+            if (spec->mutant == 1) ffma(e, acc[m], dot[m], onef, 0, acc[m]);
+            else ffma(e, acc[m], dot[m], sc[cur], 0, acc[m]);
+        }
+        if (last && U != 2u) { /* odd step count (one iteration): the next row's step 0 into buffer A, now that this step has read it */
+            imadw(e, pwn, woffn, 1, wbase); imadw(e, psn, soffn, 1, sbase);
+            ldw_pf(e, ldw, wq[0], pwn, 0, udesc, 3);
+            ldw_pf(e, BW_IR_LDG_E, sc[0], psn, 0, udesc, 3);
+        }
+    }
+    imadi(e, woff, one, 0, WINC, woff);
+    imadi(e, soff, one, 0, SINC, soff);
+    imadi(e, xo, one, 0, U * ROWW * 4u, xo);
+    imadi(e, cntk, one, 0, 0xffffffffu, cntk);
+    isetp_ge_u32(e, cntk, one);
+    bra_if_p0(e, L_k);
+    loop_end(e);
+    /* scoreboard 3 stays held: the next row's step 0 streams through the reduce, the stores and the back-edges */
+
+    /* ---- reduce and store this row for the pass's MT x' rows ---- */
+    for (uint32_t m = 0; m < MT; m++)
+        for (uint32_t o = 16; o >= 1; o /= 2) { shfl_down(e, t, acc[m], o); fadd(e, acc[m], acc[m], t); }
+    for (uint32_t m = 0; m < MT; m++) {
+        imadi(e, tq, one, 0, (uint32_t)(0u - 1u - m), rem); shr(e, fl, tq, 0, 31); /* 1 iff m >= rem: past this segment's rows */
+        imadi(e, sv, fl, 0, 1, lo);
+        isetp_ge_u32(e, sv, one);
+        const int at_bssy = bssy_fwd(e);
+        const int bra_skip = bra_if_p0_fwd(e);
+        if (RM) { imadr(e, tq, yi[m], ysn, NOREG); imadw(e, pya, tq, 1, pyrg); } else imadw(e, pya, ysn, m, pyrg);
+        stg(e, pya, 0, acc[m], udesc);
+        const int at_bsync = here(e);
+        bsync(e);
+        patch_bra(e, bra_skip, at_bsync);
+        patch_bra(e, at_bssy, at_bsync + 1);
+    }
+    imadi(e, base, nb, 0, 1, NOREG);
+    bra(e, L_rg);
+    loop_end(e);
+    patch_bra(e, bra_rows_done, here(e));
+#undef ROW_OFFSETS
+
+    bar_sync(e); /* every warp has read the pass's x' block before the next pass overwrites it */
+    imadi(e, rowp, one, 0, MT, rowp); imadi(e, rem, one, 0, (uint32_t)(0u - MT), rem);
+    imadi(e, pc, one, 0, 0xffffffffu, pc);
+    isetp_ge_u32(e, pc, one);
+    bra_if_p0(e, L_pass);
+    loop_end(e);
+    consume(e, 3); /* the prefetch past the last row (a valid, clamped row) lands before exit */
+    const int L_end = here(e);
+    if (bra_empty >= 0) patch_bra(e, bra_empty, L_end);
     tail(e);
     if (e->err) return -1;
     return omega_bw_regalloc_solve(prog);
diff --git a/src/omega_blackwell_codegen_gemm.h b/src/omega_blackwell_codegen_gemm.h
index 74abbcfa..659365c6 100644
--- a/src/omega_blackwell_codegen_gemm.h
+++ b/src/omega_blackwell_codegen_gemm.h
@@ -18,7 +18,8 @@
  * stages one K step of MT rows (MT*32*LB*4 <= 16384 bytes: the QMD shared-memory limit of omega_blackwell_qmd.h) in
  * shared memory, so every lane reads its 4 columns of every row with one conflict-free LDS.128. Per step: stage,
  * BAR.SYNC, compute, BAR.SYNC. The weights and scales of step s+1 are loaded before step s computes (two register
- * sets, scoreboards 3 and 4 held until the step that uses them).
+ * sets, scoreboards 3 and 4 held until the step that uses them); with x_ahead 1 (L312 lever 3) so are the staging words
+ * of x' for step s+1 (scoreboard 5, stored at the start of the step that reads them): neither latency sits between the barriers.
  *
  * Segment table (device, 32 bytes per segment, ctaid.y = segment): { w_va u64, s_va u64, row0 u32, cnt u32, pad[8] }.
  * Constant bank 0 argument words (cbank + 0x380):
@@ -35,7 +36,20 @@
  *
  * mutant (tests only): 1 drops the block scale (acc += dot), 2 never advances the scale pointer (wrong when KS >= 2),
  * 3 reads the neighbouring row's x (m ^ 1) for every row, 4 drops the empty-segment guard (a cnt 0 segment then runs 2^32 passes: the
- * warp simulator's step budget catches it). Each must be caught.
+ * warp simulator's step budget catches it), 5 (row_ahead only) prefetches weight row rg + stride + 1 instead of rg + stride,
+ * 6 (row_ahead only) prefetches the next weight row at every pass instead of the last (wrong when a segment runs >= 2 passes).
+ * x_resident only: 7 reads row m at m * 32 * LB words instead of m * k (wrong when
+ * KS >= 2 and mt >= 2), 8 stages every row of a mapped pass from XMAP[rowp] (DRA-81's mapped staging), 9 makes the cross-row
+ * prefetch fetch the current row's step 0 again instead of the next row's. Each must be caught.
+ *
+ * x_resident 1 (P-DRA-4 DRA-80, reused by DRA-81's single-pass shared expert and DRA-89's dense calls): ONE stage-x-once form.
+ * The loop nest turns over: per pass the CTA stages all k columns of its MT x' rows into shared memory (MT * k * 4 bytes
+ * <= OMEGA_BW_QMD_MAX_SHARED_BYTES, one BAR.SYNC), then its warps stream weight rows with no barrier inside a row or
+ * between rows; the last K step of a row prefetches the NEXT row's step 0 (the next pass's first row after the last
+ * row of a pass), so the weight stream crosses row boundaries without a gap. The same x' contract (MT padding rows,
+ * padding XMAP entries) and the same per-row arithmetic as x_resident 0, so the result is bit-identical to it. Needs
+ * k % (32 * warps) == 0, mt <= 8 (rowmap included: no staging-word registers), x_ahead 0, row_ahead 0. Weights are read once per
+ * pass as before; the gain is the barriers and the per-row pipeline restart that x_resident 0 pays per K step.
  */
 #include <stdint.h>
 #include "omega_blackwell_codegen.h"
@@ -59,13 +73,22 @@ extern "C" {
 typedef struct {
     uint32_t k;          /* multiple of 128 and of 32 * lane_bytes; <= 16384 */
     uint32_t lane_bytes; /* 8 or 16 (the GEMV's choice: 16 when k % 512 == 0, else 8) */
-    uint32_t mt;         /* rows per pass: a power of two, mt * 128 * lane_bytes <= 16384 */
+    uint32_t mt;         /* rows per pass: a power of two, mt * 128 * lane_bytes <= 16384 (x_resident: mt <= 8, mt * k * 4 <= the QMD shared limit) */
     uint32_t warps;      /* warps % lane_bytes == 0, (mt * lane_bytes) % warps == 0, 1 .. 32 (host simulator: build with -DWS_MAX_THREADS=512) */
     int mutant;
     uint32_t rowmap;     /* 1: x' rows and y rows are addressed through XMAP / YMAP (the decode stroke: N heads' rows grouped by
                           * expert on the chip; the x' buffer holds one permuted row per head, the outputs land in head order). 0: the
                           * prefill form, x' row i and y row i are sorted row i. mt <= 4 (registers); the dense trunk of a stroke (one
                           * segment, the heads' rows in head order) needs no map and runs at mt 8. */
+    uint32_t x_ahead;    /* 1 (L312 lever 3): the staging words of x' for step s+1 are loaded during step s on scoreboard 5 and
+                          * stored at the start of the step that reads them; NJ = mt * lane_bytes / warps <= 16 (registers). 0: the
+                          * incumbent program, byte for byte (the staging words loaded inside the step that stores them). */
+    uint32_t row_ahead;  /* 1 (P-DRA-4 DRA-79, KS = 1 only: k == 32 * lane_bytes, the decode down projection): the weights and scale
+                          * of the warp's NEXT weight row (rg + stride, clamped) are loaded during the last pass of the current row on
+                          * scoreboard 4 into the second register set, and moved into the first at the next pass prologue, so the
+                          * one-step K loop no longer waits a full load latency per row. Passes before the last re-load the current
+                          * row. 0: the incumbent program, byte for byte. */
+    uint32_t x_resident; /* 1 (DRA-80): the stage-x-once form above; 0: the forms above, byte for byte */
 } OmegaFp8GemmSpec;
 
 int omega_blackwell_codegen_fp8gemm_prog(const OmegaFp8GemmSpec *spec, BlackwellIRProgram *prog);
diff --git a/src/omega_bw_hazard.c b/src/omega_bw_hazard.c
index 026ae76b..7776618e 100644
--- a/src/omega_bw_hazard.c
+++ b/src/omega_bw_hazard.c
@@ -115,7 +115,7 @@ int omega_bw_decode(const uint8_t b[16], OmegaBwInsn *d) {
 }
 
 const char *omega_bw_hazard_kind(uint8_t kind) {
-    return kind == OMEGA_BW_HZ_RAW ? "RAW" : kind == OMEGA_BW_HZ_WAR ? "WAR" : kind == OMEGA_BW_HZ_WAW ? "WAW" : "?";
+    return kind == OMEGA_BW_HZ_RAW ? "RAW" : kind == OMEGA_BW_HZ_WAR ? "WAR" : kind == OMEGA_BW_HZ_WAW ? "WAW" : kind == OMEGA_BW_HZ_EXIT ? "EXIT" : "?";
 }
 
 /* ---- the walk ---------------------------------------------------------------------------------------------------
@@ -175,6 +175,11 @@ static void step(const OmegaBwInsn *d, uint32_t pc, State *s, OmegaBwHazardRepor
             int has_w = d->wbar != OMEGA_BW_NOBAR;
             if (has_w || d->var) { s->w[i] |= 1ull << (has_w ? (1u << d->wbar) : 0u); s->wpc[i] = pc; }
         }
+    /* EXIT (unconditional) with a register write still in flight: the program never waited for a load it issued (P-DRA-4
+     * DRA-79: a prefetch past the last use). Reported once per register, against the producer. */
+    if (d->flow == OMEGA_BW_FLOW_EXIT && d->guard == 7u)
+        for (unsigned i = 0; i < NREG; i++)
+            if (s->w[i]) { if (rep) note(rep, pc, s->wpc[i], OMEGA_BW_HZ_EXIT, i, s->w[i]); s->w[i] = 0; }
     /* late source reads: held until a wait on the read barrier or on the write barrier (completion) */
     if (d->late || d->rbar != OMEGA_BW_NOBAR) {
         unsigned m = (d->rbar != OMEGA_BW_NOBAR ? 1u << d->rbar : 0u) | (d->wbar != OMEGA_BW_NOBAR ? 1u << d->wbar : 0u);
diff --git a/src/omega_bw_hazard.h b/src/omega_bw_hazard.h
index cd80642c..e2e56d4d 100644
--- a/src/omega_bw_hazard.h
+++ b/src/omega_bw_hazard.h
@@ -55,7 +55,8 @@ typedef struct {
  * reported as not checked, never as clean). */
 int omega_bw_decode(const uint8_t b[16], OmegaBwInsn *d);
 
-enum { OMEGA_BW_HZ_RAW = 1, OMEGA_BW_HZ_WAR = 2, OMEGA_BW_HZ_WAW = 3 };
+/* OMEGA_BW_HZ_EXIT: an unconditional EXIT reached with a register write (a load) still pending on some path. */
+enum { OMEGA_BW_HZ_RAW = 1, OMEGA_BW_HZ_WAR = 2, OMEGA_BW_HZ_WAW = 3, OMEGA_BW_HZ_EXIT = 4 };
 
 typedef struct {
     uint32_t pc;       /* instruction index of the offending reader / writer */
diff --git a/src/omega_gpu_fp8gemm_api.c b/src/omega_gpu_fp8gemm_api.c
index 6487abba..26205d19 100644
--- a/src/omega_gpu_fp8gemm_api.c
+++ b/src/omega_gpu_fp8gemm_api.c
@@ -3,12 +3,14 @@
  * See the header. Submission path and buffer policy are the FP8 GEMV API's: every buffer both sides touch is
  * GPU-uncached (nvos.h NVOS32_ATTR2_GPU_CACHEABLE), one launch = omega_gpu_session_launch. */
 #include "omega_gpu_fp8gemm_api.h"
+#include "omega_gpu_fp8gemm_internal.h"
 #include "omega_gpu_session.h"
 #include "omega_gpu_cmdlist.h"
 #include "omega_gpu_fmt.h"
 #include "omega_gpu_native_runtime.h"
 #include "omega_gpu_code_alloc.h"
 #include <string.h>
+#include <stdio.h>
 #include <stdlib.h>
 
 #define CACHE_SLOTS 8
@@ -96,6 +98,22 @@ void omega_gpu_fp8gemm_shape_for(uint32_t k, uint32_t *mt, uint32_t *warps, uint
     if (mt) *mt = g.mt ? g.mt : 4u;
     if (warps) *warps = g.warps ? g.warps : 16u;
 }
+/* L312 lever 3: x' staging words one K step ahead, OFF unless AIEN_OMEGA_FP8GEMM_X_AHEAD=1 (read once; P-DRA-4 DRA-67:
+ * decode changes are env-gated, default off, until the stroke gate passes), and only where the NJ = mt * lane_bytes /
+ * warps staging words fit the registers the program holds for them (NJ <= 16); call after mt is final */
+static void x_ahead_for(OmegaFp8GemmSpec *spec) {
+    static int on = -1;
+    if (on < 0) { const char *e = getenv("AIEN_OMEGA_FP8GEMM_X_AHEAD"); on = (e && e[0] == '1' && e[1] == 0) ? 1 : 0; }
+    spec->x_ahead = on && spec->mt * spec->lane_bytes / spec->warps <= 16u ? 1u : 0u;
+}
+/* DRA-79 (P-DRA-4): the next weight row's weights and scale loaded during the current row (OmegaFp8GemmSpec.row_ahead), OFF
+ * unless AIEN_OMEGA_FP8GEMM_ROW_AHEAD=1 (read once), and only at one K step per row (k == 32 * lane_bytes: the 35B's down
+ * projection, k 512); every call that resolves its spec here (the stroke, prefill) takes it */
+static void row_ahead_for(OmegaFp8GemmSpec *spec) {
+    static int on = -1;
+    if (on < 0) { const char *e = getenv("AIEN_OMEGA_FP8GEMM_ROW_AHEAD"); on = (e && e[0] == '1' && e[1] == 0) ? 1 : 0; }
+    spec->row_ahead = on && spec->k == 32u * spec->lane_bytes ? 1u : 0u;
+}
 /* dense = a few distinct experts with many rows each (qkv, o): 8 rows per pass measured best there */
 static void spec_for(uint32_t k, uint32_t segs, OmegaFp8GemmSpec *spec) {
     memset(spec, 0, sizeof *spec);
@@ -103,6 +121,8 @@ static void spec_for(uint32_t k, uint32_t segs, OmegaFp8GemmSpec *spec) {
     omega_gpu_fp8gemm_shape_for(k, &spec->mt, &spec->warps, &spec->lane_bytes);
     if (!g.mt && segs < 8u) spec->mt = 8u;
     spec->mutant = g.mutant;
+    x_ahead_for(spec);
+    row_ahead_for(spec);
 }
 
 static int g_rec; /* 1 while a record call runs (lock held): kernel_for must not evict */
@@ -205,15 +225,44 @@ int omega_gpu_fp8gemm_prepare(uint32_t k) {
     return rc;
 }
 
+/* P-DRA-4 DRA-80 / DRA-81: the stage-x-once form (spec.x_resident, omega_blackwell_codegen_gemm.h) for the mapped calls,
+ * OFF unless the env says exactly "1" (read once; decode changes are env-gated, default off, until a chip gate passes).
+ *   AIEN_OMEGA_FP8GEMM_X_RESIDENT=1 (DRA-80): every mapped call at its own mt where the x' block fits shared memory.
+ *   AIEN_OMEGA_FP8GEMM_SHARED_ONE_PASS=1 (DRA-81): a decode stroke call (caller mt 0) with segs > 36 runs mt 8 in the
+ *   resident form where it fits. The stroke records segs = 9 N (N heads x (8 routed + the shared expert)), so this is
+ *   N >= 5: the shared expert's segment holds N rows, one pass at mt 8 instead of ceil(N / 4) at mt 4; a routed expert
+ *   picked by fewer than 8 heads pays only padding rows of the staged block. Prefill (caller mt 4) is never touched.
+ * The dense (unmapped) calls are DRA-89's: they reuse the same field, selected by their own gate. */
+#define ONE_PASS_MIN_SEGS 37u
+static int env_exact_1(const char *name) { const char *e = getenv(name); return e && e[0] == '1' && e[1] == 0; }
+static void x_resident_for(OmegaFp8GemmSpec *spec, uint32_t segs, uint32_t caller_mt) {
+    static int on = -1, one_pass = -1;
+    if (on < 0) on = env_exact_1("AIEN_OMEGA_FP8GEMM_X_RESIDENT");
+    if (one_pass < 0) one_pass = env_exact_1("AIEN_OMEGA_FP8GEMM_SHARED_ONE_PASS");
+    if (!spec->rowmap) return;
+    OmegaFp8GemmSpec r = *spec; r.x_ahead = 0; r.row_ahead = 0; r.x_resident = 1; /* the resident form replaces both prefetch levers */
+    if (one_pass && caller_mt == 0 && segs >= ONE_PASS_MIN_SEGS) {
+        r.mt = 8u;
+        if (omega_fp8gemm_steps(&r)) { *spec = r; return; }
+        r.mt = spec->mt;
+    }
+    if (on && omega_fp8gemm_steps(&r)) *spec = r;
+}
+
 /* ---- the stroke's record path (L312 v2): one launch appended to a command list, every buffer the caller's ---- */
 static void spec_for_stroke(uint32_t k, uint32_t segs, uint32_t mt, int rowmap, OmegaFp8GemmSpec *spec) {
     spec_for(k, segs, spec);
     if (mt) spec->mt = mt;
     spec->rowmap = rowmap ? 1u : 0u;
+    x_ahead_for(spec);
+    x_resident_for(spec, segs, mt);
+}
+void omega_gpu_fp8gemm_stroke_spec(uint32_t k, uint32_t segs, uint32_t mt, int rowmap, OmegaFp8GemmSpec *spec) {
+    spec_for_stroke(k, segs, mt, rowmap, spec);
 }
 int omega_gpu_fp8gemm_prepare_shape(uint32_t k, uint32_t segs, uint32_t mt, int rowmap) {
     OmegaFp8GemmSpec spec; spec_for_stroke(k, segs, mt, rowmap, &spec);
-    if (omega_fp8gemm_shared_bytes(&spec) == 0) { omega_gpu_session_set_error("fp8 gemm prepare: shape refused (rowmap needs mt <= 4)"); return OMEGA_GPU_FP8GEMM_BAD_ARGS; }
+    if (omega_fp8gemm_shared_bytes(&spec) == 0) { omega_gpu_session_set_error("fp8 gemm prepare: shape refused (rowmap needs mt <= 4 outside the x_resident form)"); return OMEGA_GPU_FP8GEMM_BAD_ARGS; }
     omega_gpu_session_lock();
     int rc = OMEGA_GPU_FP8GEMM_OK;
     if (!dev_open_locked()) rc = OMEGA_GPU_FP8GEMM_CHIP_FAIL;
@@ -228,7 +277,62 @@ int omega_gpu_fp8gemm_prepare_shape(uint32_t k, uint32_t segs, uint32_t mt, int
     omega_gpu_session_unlock();
     return rc;
 }
-uint32_t omega_gpu_fp8gemm_cta_budget_for(uint32_t segs) { return g.ctas ? g.ctas : (segs >= 64u ? 2u : segs >= 8u ? 12u : 96u); }
+/* DRA-78 (P-DRA-4): AIEN_OMEGA_FP8GEMM_CTA_BUDGET, read once, sets the CTA budget per segment of the calls that take the
+ * API's choice (record cta_budget 0, the stroke; the prefill call) for a chip sweep. Comma-separated items, each "N" (every
+ * call) or "K:N" (the grouped calls of tensor width K with >= 8 segments: the stroke's experts, 512 = down, 2048 = gate_up;
+ * the dense trunk keeps the rule). N 1..1024, K 1..16384, at most one bare N and one item per K. Unset = the incumbent rule
+ * exactly. A malformed value is refused whole (one stderr line; the rule stays) so a sweep never runs a budget it did not
+ * name: slices check the resolved budget first with gpu_fp8gemm_test --spec-of K,SEGS,MT,ROWMAP --expect "ctas=N".
+ * Precedence: the record's cta_budget argument, then omega_gpu_fp8gemm_set_cta_budget, then K:N, then N, then the rule. */
+#define CTA_ENV_ITEMS 8
+static struct { int read; uint32_t all, n, k[CTA_ENV_ITEMS], c[CTA_ENV_ITEMS]; } g_cta_env;
+static int parse_dec(const char **p, uint32_t lo, uint32_t hi, uint32_t *v) {
+    const char *s = *p; uint32_t x = 0;
+    if (*s < '0' || *s > '9') return -1;
+    while (*s >= '0' && *s <= '9') { x = x * 10u + (uint32_t)(*s - '0'); if (x > hi) return -1; s++; }
+    if (x < lo) return -1;
+    *p = s; *v = x; return 0;
+}
+/* 0 on success (out filled), -1 malformed; s non-NULL */
+static int cta_env_parse(const char *s, uint32_t *all, uint32_t *n, uint32_t *ks, uint32_t *cs) {
+    *all = 0; *n = 0;
+    if (!*s) return -1;
+    for (;;) {
+        uint32_t a = 0, b = 0;
+        if (parse_dec(&s, 1, 16384, &a) != 0) return -1;
+        if (*s == ':') {
+            s++;
+            if (parse_dec(&s, 1, 1024, &b) != 0 || *n == CTA_ENV_ITEMS) return -1;
+            for (uint32_t i = 0; i < *n; i++) if (ks[i] == a) return -1;
+            ks[*n] = a; cs[*n] = b; (*n)++;
+        } else {
+            if (a > 1024u || *all) return -1;
+            *all = a;
+        }
+        if (!*s) return 0;
+        if (*s++ != ',') return -1;
+    }
+}
+static void cta_env_read(void) {
+    if (g_cta_env.read) return;
+    g_cta_env.read = 1;
+    const char *e = getenv("AIEN_OMEGA_FP8GEMM_CTA_BUDGET");
+    if (!e) return;
+    uint32_t all = 0, n = 0, ks[CTA_ENV_ITEMS], cs[CTA_ENV_ITEMS];
+    if (cta_env_parse(e, &all, &n, ks, cs) != 0) { fprintf(stderr, "omega_gpu_fp8gemm: AIEN_OMEGA_FP8GEMM_CTA_BUDGET=\"%s\" refused (want N or K:N items, N 1..1024): the incumbent budget stays\n", e); return; }
+    g_cta_env.all = all; g_cta_env.n = n;
+    for (uint32_t i = 0; i < n; i++) { g_cta_env.k[i] = ks[i]; g_cta_env.c[i] = cs[i]; }
+}
+/* the budget a call of width k (0: no width, the public form) with segs segments gets when its caller passes 0 */
+static uint32_t budget_for(uint32_t k, uint32_t segs) {
+    if (g.ctas) return g.ctas;
+    cta_env_read();
+    if (segs >= 8u) for (uint32_t i = 0; i < g_cta_env.n; i++) if (g_cta_env.k[i] == k) return g_cta_env.c[i];
+    if (g_cta_env.all) return g_cta_env.all;
+    return segs >= 64u ? 2u : segs >= 8u ? 12u : 96u;
+}
+uint32_t omega_gpu_fp8gemm_cta_budget_for(uint32_t segs) { return budget_for(0, segs); }
+uint32_t omega_gpu_fp8gemm_stroke_cta_budget(uint32_t k, uint32_t segs) { return budget_for(k, segs); }
 
 int omega_gpu_fp8gemm_record(OmegaGpuCmdList *cl, const OmegaGpuFp8Tensor *t, uint32_t rows, uint32_t segs, uint64_t seg_va, uint64_t xp_va,
                              uint64_t y_va, uint64_t xmap_va, uint64_t ymap_va, uint32_t mt, uint32_t cta_budget, OmegaGpuFp8GemmInfo *info) {
@@ -238,10 +342,10 @@ int omega_gpu_fp8gemm_record(OmegaGpuCmdList *cl, const OmegaGpuFp8Tensor *t, ui
     if (!cl || !t || !experts || !seg_va || !xp_va || !y_va || rows == 0 || segs == 0 || (!xmap_va) != (!ymap_va)) return OMEGA_GPU_FP8GEMM_BAD_ARGS;
     if (rows > OMEGA_GPU_FP8GEMM_MAX_ROWS || segs > OMEGA_GPU_FP8GEMM_MAX_SEGMENTS) return OMEGA_GPU_FP8GEMM_TOO_LARGE;
     OmegaFp8GemmSpec spec; spec_for_stroke(k, segs, mt, xmap_va != 0, &spec);
-    if (omega_fp8gemm_shared_bytes(&spec) == 0) { omega_gpu_session_set_error("fp8 gemm record: shape refused (rowmap needs mt <= 4)"); return OMEGA_GPU_FP8GEMM_BAD_ARGS; }
+    if (omega_fp8gemm_shared_bytes(&spec) == 0) { omega_gpu_session_set_error("fp8 gemm record: shape refused (rowmap needs mt <= 4 outside the x_resident form)"); return OMEGA_GPU_FP8GEMM_BAD_ARGS; }
     const uint32_t W = spec.warps;
     uint32_t grid_x = (n + W - 1) / W;
-    const uint32_t budget = cta_budget ? cta_budget : omega_gpu_fp8gemm_cta_budget_for(segs);
+    const uint32_t budget = cta_budget ? cta_budget : budget_for(k, segs);
     if (grid_x > budget) grid_x = budget;
     if (grid_x == 0) grid_x = 1;
     /* caller holds the session lock */
@@ -337,7 +441,7 @@ static int gemm_core(const OmegaGpuFp8Tensor *t, uint32_t M, const uint32_t *ids
     if (general_ok && omega_fp8gemm_shared_bytes(&spec) == 0) return general_gemm(t, M, ids, trow, x32, x16, y, n, k, segs, info, OMEGA_GPU_FP8GEMM_CODEGEN_FAIL, t0);
     const uint32_t MT = spec.mt, W = spec.warps;
     uint32_t grid_x = (n + W - 1) / W;
-    uint32_t budget = g.ctas ? g.ctas : (segs >= 64u ? 2u : segs >= 8u ? 12u : 96u);
+    uint32_t budget = budget_for(k, segs);
     if (grid_x > budget) grid_x = budget;
     if (grid_x == 0) grid_x = 1;
 
diff --git a/src/omega_gpu_fp8gemm_internal.h b/src/omega_gpu_fp8gemm_internal.h
new file mode 100644
index 00000000..392d7ef7
--- /dev/null
+++ b/src/omega_gpu_fp8gemm_internal.h
@@ -0,0 +1,12 @@
+#ifndef OMEGA_GPU_FP8GEMM_INTERNAL_H
+#define OMEGA_GPU_FP8GEMM_INTERNAL_H
+/* Library-internal view of omega_gpu_fp8gemm_api.c for the host tests. Not part of the public ABI (no manifest entry). */
+#include "omega_blackwell_codegen_gemm.h"
+#include <stdint.h>
+/* The program spec omega_gpu_fp8gemm_prepare_shape / _record would build for (k, segs, mt, rowmap) under the process's
+ * environment and setters (AIEN_OMEGA_FP8GEMM_X_AHEAD, _ROW_AHEAD, _X_RESIDENT, _SHARED_ONE_PASS, omega_gpu_fp8gemm_set_shape, ...). Host only: opens no device. */
+void omega_gpu_fp8gemm_stroke_spec(uint32_t k, uint32_t segs, uint32_t mt, int rowmap, OmegaFp8GemmSpec *spec);
+/* The CTA budget per segment a call of width k with segs segments gets when it passes cta_budget 0 (the stroke), under
+ * the process's environment and setters (AIEN_OMEGA_FP8GEMM_CTA_BUDGET, omega_gpu_fp8gemm_set_cta_budget; DRA-78). */
+uint32_t omega_gpu_fp8gemm_stroke_cta_budget(uint32_t k, uint32_t segs);
+#endif
diff --git a/tests/bw_hazard_test.c b/tests/bw_hazard_test.c
index e052b090..c9f1a553 100644
--- a/tests/bw_hazard_test.c
+++ b/tests/bw_hazard_test.c
@@ -266,7 +266,7 @@ static void test_controls(void) {
     war[1].dst_vreg = 5; war[1].control = FIX; n = enc(war, 3, c);
     CHECK(n && omega_bw_hazard_check(c, n, &g_rep) == 0 && g_rep.count == 0, "control: a register the store does not read passes");
     /* WAR released by the load's completion: waiting on the write barrier also frees the address */
-    BlackwellIRInsn warc[] = { mk(BW_IR_LDG_E, 4, 2, -1, -1, 4, LD), mk(BW_IR_MOV_RZ, 2, -1, -1, -1, -1, CW(6, 7, 7, 0x1)), mk(BW_IR_EXIT, -1, -1, -1, -1, -1, ENDW) };
+    BlackwellIRInsn warc[] = { mk(BW_IR_LDG_E, 4, 2, -1, -1, 4, LD), mk(BW_IR_MOV_RZ, 2, -1, -1, -1, -1, CW(6, 7, 7, 0x1)), mk(BW_IR_EXIT, -1, -1, -1, -1, -1, CW(5, 7, 7, 0x1)) };
     n = enc(warc, 3, c);
     CHECK(n && omega_bw_hazard_check(c, n, &g_rep) == 0 && g_rep.count == 0, "control: address overwrite after the load completed passes");
     warc[1].control = FIX; n = enc(warc, 3, c);
@@ -275,6 +275,12 @@ static void test_controls(void) {
     BlackwellIRInsn waw[] = { mk(BW_IR_LDG_E, 4, 2, -1, -1, 4, LD), mk(BW_IR_MOV_RZ, 4, -1, -1, -1, -1, CW(6, 7, 7, 0x2)), mk(BW_IR_EXIT, -1, -1, -1, -1, -1, ENDW) };
     n = enc(waw, 3, c);
     CHECK(n && omega_bw_hazard_check(c, n, &g_rep) == 0 && g_rep.count == 1 && finding(&g_rep, 1, OMEGA_BW_HZ_WAW, 4), "control WAW caught");
+    /* EXIT with the load still in flight (P-DRA-4 DRA-79 row_ahead L_end wait) / with the wait on the EXIT */
+    BlackwellIRInsn ex[] = { mk(BW_IR_LDG_E, 4, 2, -1, -1, 4, LD), mk(BW_IR_EXIT, -1, -1, -1, -1, -1, ENDW) };
+    n = enc(ex, 2, c);
+    CHECK(n && omega_bw_hazard_check(c, n, &g_rep) == 0 && g_rep.count == 1 && finding(&g_rep, 1, OMEGA_BW_HZ_EXIT, 4), "control EXIT with a pending load caught");
+    ex[1].control = CW(5, 7, 7, 0x1); n = enc(ex, 2, c);
+    CHECK(n && omega_bw_hazard_check(c, n, &g_rep) == 0 && g_rep.count == 0, "control EXIT behind the wait passes");
     /* a variable-latency result with no write barrier at all: nothing can release it */
     BlackwellIRInsn nob[] = { mk(BW_IR_S2R, 4, -1, -1, -1, -1, CW(4, 7, 7, 0)), mk(BW_IR_FADD, 6, 4, 4, -1, -1, CW(6, 7, 7, 0x3f)), mk(BW_IR_EXIT, -1, -1, -1, -1, -1, ENDW) };
     nob[0].imm = BW_SR_TID_X; n = enc(nob, 3, c);
@@ -366,8 +372,15 @@ static void sweep_bytes(const char *family, const char *variant, const uint8_t *
         CHECK(0, "%s %s: not checked (instruction %lld, word 0 %08x, decode %d)", family, variant, pc, w0, pc >= 0 ? omega_bw_decode(code + pc * 16, &d) : -9);
         return;
     }
+    size_t exit_open = 0;
     for (size_t i = 0; i < g_rep.count && i < OMEGA_BW_HAZARD_MAX; i++) {
         const OmegaBwHazard *f = &g_rep.f[i]; int known = 0;
+        /* EXIT-pending gates fp8gemm only (DRA-79). Older families (fp8_gemv2 1059, matmul_frag_block 75, matmul_frag 9 at
+         * 2026-10-31) exit with prefetches in flight; listed as EXITPEND, kept out of the findings total, not gated yet. */
+        if (f->kind == OMEGA_BW_HZ_EXIT && strcmp(family, "fp8gemm")) {
+            printf("EXITPEND %s %s: IR %u R%u (producer IR %u) [not gated]\n", family, variant, f->pc, f->reg, f->src_pc);
+            exit_open++; continue;
+        }
         for (size_t k = 0; g_known[k].family; k++)
             if (!strcmp(g_known[k].family, family) && (g_known[k].pc == ANY_PC || g_known[k].pc == f->pc) && g_known[k].kind == f->kind &&
                 g_known[k].reg == f->reg && g_known[k].uniform == f->uniform) { g_known[k].seen = 1; known = g_known[k].cls; }
@@ -375,7 +388,7 @@ static void sweep_bytes(const char *family, const char *variant, const uint8_t *
                f->uniform ? "U" : "", f->reg, f->release, f->src_pc, known ? "triaged" : "UNTRIAGED", known ? known : '-');
         CHECK(known, "%s %s: untriaged %s at IR %u", family, variant, omega_bw_hazard_kind(f->kind), f->pc);
     }
-    g_findings_total += g_rep.count;
+    g_findings_total += g_rep.count - exit_open;
     if (g_dump_dir && g_rep.count) {
         char path[512]; snprintf(path, sizeof path, "%s/%s-%zu.bin", g_dump_dir, family, g_nseen - 1);
         /* 0644, not fopen's 0666 & ~umask: a dump is never world-writable */
@@ -416,11 +429,14 @@ static void sweep(void) {
           snprintf(v, sizeof v, "k%u rows%u warps%u depth%u", ks[a], rows, w, dp);
           if (BUILD(omega_blackwell_codegen_bf16_gemv_prog(&s, &g_prog))) sweep_prog("bf16_gemv", v, P_NONE);
       } }
-    /* fp8 grouped GEMM */
-    { unsigned ks[] = { 768, 2048, 4096 };
-      for (unsigned a = 0; a < 3; a++) for (unsigned lb = 8; lb <= 16; lb += 8) for (unsigned mt = 1; mt <= 16; mt *= 2) for (unsigned w = 1; w <= 32; w *= 2) {
-          OmegaFp8GemmSpec s = { .k = ks[a], .lane_bytes = lb, .mt = mt, .warps = w };
-          snprintf(v, sizeof v, "k%u lane%u mt%u warps%u", ks[a], lb, mt, w);
+    /* fp8 grouped GEMM: the incumbent, rowmap (the stroke's expert form), x_ahead (L312 lever 3, scoreboard 5), row_ahead
+     * (DRA-79, scoreboard 4 held across the row loop; one K step only: k 256 at lane 8, k 512 at lane 16) and x_resident
+     * (DRA-80/81/89: x' staged once per pass, scoreboard 3 held across rows and passes) */
+    { unsigned ks[] = { 512, 768, 2048, 4096, 256 };
+      for (unsigned a = 0; a < 5; a++) for (unsigned lb = 8; lb <= 16; lb += 8) for (unsigned mt = 1; mt <= 16; mt *= 2) for (unsigned w = 1; w <= 32; w *= 2)
+      for (unsigned rm = 0; rm <= 1; rm++) for (unsigned xa = 0; xa <= 1; xa++) for (unsigned ra = 0; ra <= 1; ra++) for (unsigned xr = 0; xr <= 1; xr++) {
+          OmegaFp8GemmSpec s = { .k = ks[a], .lane_bytes = lb, .mt = mt, .warps = w, .rowmap = rm, .x_ahead = xa, .row_ahead = ra, .x_resident = xr };
+          snprintf(v, sizeof v, "k%u lane%u mt%u warps%u%s%s%s%s", ks[a], lb, mt, w, rm ? " rowmap" : "", xa ? " x_ahead" : "", ra ? " row_ahead" : "", xr ? " x_resident" : "");
           if (BUILD(omega_blackwell_codegen_fp8gemm_prog(&s, &g_prog))) sweep_prog("fp8gemm", v, P_NONE);
       } }
     /* ternary GEMV */
diff --git a/tests/gpu_fp8gemm_test.c b/tests/gpu_fp8gemm_test.c
index 988d8a24..6db01099 100644
--- a/tests/gpu_fp8gemm_test.c
+++ b/tests/gpu_fp8gemm_test.c
@@ -12,6 +12,8 @@
  * Verdict line last: "gpu_fp8gemm_test: N checks, F failed: PASS|FAIL".
  */
 #include "omega_gpu_fp8gemm_api.h"
+#include "omega_gpu_fp8gemm_internal.h"
+#include "omega_blackwell_qmd.h"
 #include "omega_gpu_fp8_api.h"
 #include "omega_gpu_session.h"
 #include "bw_warp_sim_k.h"
@@ -118,24 +120,78 @@ static void host_only(void) {
       CHECK(p[(1 * 32 + 5) * 4 + 2] / 18446744073709551616.0f == x[86], "column 86 sits at lane 5 word 1 element 2"); }
     struct { uint32_t k, lb, mt, w; } shp[] = { { 2048, 16, 8, 16 }, { 4096, 16, 8, 16 }, { 1024, 16, 8, 16 }, { 768, 8, 8, 16 }, { 768, 8, 8, 8 }, { 2048, 8, 8, 16 }, { 2048, 16, 4, 16 }, { 2048, 16, 8, 32 }, { 2048, 16, 8, 8 }, { 2048, 16, 4, 8 }, { 4096, 16, 4, 8 } };
     for (unsigned i = 0; i < sizeof shp / sizeof shp[0]; i++) for (int m = 0; m <= 3; m++) {
-        OmegaFp8GemmSpec s = { shp[i].k, shp[i].lb, shp[i].mt, shp[i].w, m, 0 }; uint32_t n = 0, gp = 0;
+        OmegaFp8GemmSpec s = { shp[i].k, shp[i].lb, shp[i].mt, shp[i].w, m, 0, 0, 0, 0 }; uint32_t n = 0, gp = 0;
         int rc = omega_fp8gemm_prog_stats(&s, &n, &gp);
         uint32_t decl = ((gp + 1 + 7) / 8) * 8;
         CHECK(rc == 0 && n <= 1024, "codegen k %u lb %u mt %u warps %u mutant %d: rc %d insns %u gprs %u", s.k, s.lane_bytes, s.mt, s.warps, m, rc, n, gp);
         if (m == 0 && rc == 0) printf("codegen k %4u lane %2u mt %2u warps %2u: %u instructions, %u registers (declared %u, register file %u of 65536)%s, shared %u B\n", s.k, s.lane_bytes, s.mt, s.warps, n, gp, decl, 32u * s.warps * decl, 32u * s.warps * decl <= 65536u ? "" : " DOES NOT FIT", omega_fp8gemm_shared_bytes(&s));
     }
-    { OmegaFp8GemmSpec s = { 2048, 16, 16, 16, 0, 0 }; CHECK(omega_fp8gemm_prog_stats(&s, NULL, NULL) != 0, "mt 16 at lane 16 refused (32 KB of shared memory)"); }
-    { OmegaFp8GemmSpec s = { 2048, 16, 6, 16, 0, 0 }; CHECK(omega_fp8gemm_prog_stats(&s, NULL, NULL) != 0, "mt 6 refused"); }
-    { OmegaFp8GemmSpec s = { 2048, 16, 8, 16, 5, 0 }; CHECK(omega_fp8gemm_prog_stats(&s, NULL, NULL) != 0, "mutant 5 refused"); }
-    { OmegaFp8GemmSpec s = { 2048, 16, 8, 16, 0, 2 }; CHECK(omega_fp8gemm_prog_stats(&s, NULL, NULL) != 0, "rowmap 2 refused"); }
-    { OmegaFp8GemmSpec s = { 2048, 16, 8, 16, 0, 1 }; CHECK(omega_fp8gemm_prog_stats(&s, NULL, NULL) != 0, "rowmap at mt 8 refused (registers)"); }
+    { OmegaFp8GemmSpec s = { 2048, 16, 16, 16, 0, 0, 0, 0, 0 }; CHECK(omega_fp8gemm_prog_stats(&s, NULL, NULL) != 0, "mt 16 at lane 16 refused (32 KB of shared memory)"); }
+    { OmegaFp8GemmSpec s = { 2048, 16, 6, 16, 0, 0, 0, 0, 0 }; CHECK(omega_fp8gemm_prog_stats(&s, NULL, NULL) != 0, "mt 6 refused"); }
+    { OmegaFp8GemmSpec s = { 2048, 16, 8, 16, 7, 0, 0, 0, 0 }; CHECK(omega_fp8gemm_prog_stats(&s, NULL, NULL) != 0, "mutant 7 refused"); }
+    /* DRA-79 row_ahead: KS 1 only (k == 32 * lane_bytes), 0/1 only; mutants 5 and 6 only with it */
+    { OmegaFp8GemmSpec s = { 2048, 16, 8, 16, 0, 0, 0, 1, 0 }; CHECK(omega_fp8gemm_prog_stats(&s, NULL, NULL) != 0, "row_ahead at KS 4 refused"); }
+    { OmegaFp8GemmSpec s = { 1024, 16, 8, 16, 0, 0, 0, 1, 0 }; CHECK(omega_fp8gemm_prog_stats(&s, NULL, NULL) != 0, "row_ahead at KS 2 refused"); }
+    { OmegaFp8GemmSpec s = { 512, 16, 4, 16, 0, 0, 0, 2, 0 }; CHECK(omega_fp8gemm_prog_stats(&s, NULL, NULL) != 0, "row_ahead 2 refused"); }
+    for (int m = 5; m <= 6; m++) { OmegaFp8GemmSpec s = { 512, 16, 4, 16, m, 0, 0, 0, 0 }; CHECK(omega_fp8gemm_prog_stats(&s, NULL, NULL) != 0, "mutant %d without row_ahead refused", m);
+      s.row_ahead = 1; CHECK(omega_fp8gemm_prog_stats(&s, NULL, NULL) == 0, "mutant %d with row_ahead accepted", m); }
+    { struct { uint32_t k, lb, mt, w, rm, xa; } ra[] = { { 512, 16, 4, 16, 0, 0 }, { 512, 16, 8, 16, 0, 0 }, { 512, 16, 4, 8, 0, 0 }, { 512, 16, 4, 16, 1, 0 },
+                                                       { 512, 16, 4, 16, 1, 1 }, { 512, 16, 8, 16, 0, 1 }, { 256, 8, 4, 8, 0, 0 }, { 256, 8, 4, 8, 1, 1 } };
+      for (unsigned i = 0; i < sizeof ra / sizeof ra[0]; i++) {
+        OmegaFp8GemmSpec s = { ra[i].k, ra[i].lb, ra[i].mt, ra[i].w, 0, ra[i].rm, ra[i].xa, 1, 0 }; uint32_t n = 0, gp = 0;
+        int rc = omega_fp8gemm_prog_stats(&s, &n, &gp);
+        uint32_t decl = ((gp + 1 + 7) / 8) * 8;
+        CHECK(rc == 0 && n <= 1024 && 32u * s.warps * decl <= 65536u, "row_ahead codegen k %u lb %u mt %u warps %u rowmap %u x_ahead %u: rc %d insns %u gprs %u", s.k, s.lane_bytes, s.mt, s.warps, s.rowmap, s.x_ahead, rc, n, gp);
+        printf("row_ahead codegen k %4u lane %2u mt %2u warps %2u%s%s: %u instructions, %u registers (declared %u, register file %u of 65536)\n", s.k, s.lane_bytes, s.mt, s.warps, s.rowmap ? " rowmap" : "", s.x_ahead ? " x_ahead" : "", n, gp, decl, 32u * s.warps * decl);
+      } }
+    { OmegaFp8GemmSpec s = { 2048, 16, 8, 16, 0, 2, 0, 0, 0 }; CHECK(omega_fp8gemm_prog_stats(&s, NULL, NULL) != 0, "rowmap 2 refused"); }
+    { OmegaFp8GemmSpec s = { 2048, 16, 8, 16, 0, 1, 0, 0, 0 }; CHECK(omega_fp8gemm_prog_stats(&s, NULL, NULL) != 0, "rowmap at mt 8 refused (registers)"); }
+    /* L312 lever 3 (x_ahead): every shape above and the rowmap form at mt 4 build with the NJ prefetch registers (fit is
+     * printed as above: warps 32 does not fit either way); NJ > 16 and x_ahead 2 are refused */
+    for (unsigned i = 0; i < sizeof shp / sizeof shp[0]; i++) {
+        OmegaFp8GemmSpec s = { shp[i].k, shp[i].lb, shp[i].mt, shp[i].w, 0, 0, 1, 0, 0 }; uint32_t n = 0, gp = 0;
+        int rc = omega_fp8gemm_prog_stats(&s, &n, &gp);
+        uint32_t decl = ((gp + 1 + 7) / 8) * 8;
+        CHECK(rc == 0 && n <= 1024, "x_ahead codegen k %u lb %u mt %u warps %u: rc %d insns %u gprs %u", s.k, s.lane_bytes, s.mt, s.warps, rc, n, gp);
+        if (rc == 0) printf("x_ahead codegen k %4u lane %2u mt %2u warps %2u: %u instructions, %u registers (declared %u)%s\n", s.k, s.lane_bytes, s.mt, s.warps, n, gp, decl, 32u * s.warps * decl <= 65536u ? "" : " DOES NOT FIT");
+    }
+    { OmegaFp8GemmSpec s = { 2048, 16, 4, 16, 0, 1, 1, 0, 0 }; uint32_t n = 0, gp = 0; int rc = omega_fp8gemm_prog_stats(&s, &n, &gp);
+      uint32_t decl = ((gp + 1 + 7) / 8) * 8;
+      CHECK(rc == 0 && 32u * s.warps * decl <= 65536u, "x_ahead rowmap mt 4: rc %d gprs %u", rc, gp);
+      printf("x_ahead codegen k 2048 lane 16 mt  4 warps 16 rowmap: %u instructions, %u registers (declared %u)\n", n, gp, decl); }
+    { OmegaFp8GemmSpec s = { 2048, 16, 8, 4, 0, 0, 1, 0, 0 }; CHECK(omega_fp8gemm_prog_stats(&s, NULL, NULL) != 0, "x_ahead at NJ 32 refused (registers)");
+      s.x_ahead = 0; CHECK(omega_fp8gemm_prog_stats(&s, NULL, NULL) == 0, "the same shape without x_ahead is accepted"); }
+    { OmegaFp8GemmSpec s = { 2048, 16, 8, 16, 0, 0, 2, 0, 0 }; CHECK(omega_fp8gemm_prog_stats(&s, NULL, NULL) != 0, "x_ahead 2 refused"); }
     { uint32_t ks[] = { 2048, 4096, 512, 768 }; for (unsigned i = 0; i < 4; i++) {
-        OmegaFp8GemmSpec s = { ks[i], ks[i] % 512 ? 8u : 16u, 4, 16, 0, 1 }; uint32_t n = 0, gp = 0;
+        OmegaFp8GemmSpec s = { ks[i], ks[i] % 512 ? 8u : 16u, 4, 16, 0, 1, 0, 0, 0 }; uint32_t n = 0, gp = 0;
         int rc = omega_fp8gemm_prog_stats(&s, &n, &gp);
         uint32_t decl = ((gp + 1 + 7) / 8) * 8;
         CHECK(rc == 0 && n <= 1024 && 32u * s.warps * decl <= 65536u, "codegen k %u mt 4 rowmap: rc %d insns %u gprs %u", ks[i], rc, n, gp);
         printf("codegen k %4u lane %2u mt  4 warps 16 rowmap: %u instructions, %u registers (declared %u, register file %u of 65536)\n", s.k, s.lane_bytes, n, gp, decl, 32u * s.warps * decl);
     } }
+    /* DRA-80 / DRA-81 / DRA-89 (x_resident, the stage-x-once form): the served shapes build and fit the register file */
+    { struct { uint32_t k, lb, mt, w, rm; } xr[] = { { 512, 16, 8, 16, 1 }, { 512, 16, 4, 16, 1 }, { 2048, 16, 4, 16, 1 }, { 2048, 16, 1, 16, 0 },
+          { 2048, 16, 2, 16, 0 }, { 2048, 16, 4, 16, 0 }, { 4096, 16, 1, 16, 0 }, { 4096, 16, 2, 16, 0 }, { 768, 8, 8, 8, 1 }, { 1024, 16, 8, 16, 1 } };
+      for (unsigned i = 0; i < sizeof xr / sizeof xr[0]; i++) for (int m = 0; m <= 9; m++) {
+          if (m >= 5 && m <= 6) continue;
+          OmegaFp8GemmSpec s = { xr[i].k, xr[i].lb, xr[i].mt, xr[i].w, m, xr[i].rm, 0, 0, 1 };
+          uint32_t n = 0, gp = 0; int rc = omega_fp8gemm_prog_stats(&s, &n, &gp);
+          uint32_t decl = ((gp + 1 + 7) / 8) * 8;
+          CHECK(rc == 0 && n <= 1024 && 32u * s.warps * decl <= 65536u, "x_resident codegen k %u mt %u warps %u rowmap %u mutant %d: rc %d insns %u gprs %u", s.k, s.mt, s.warps, s.rowmap, m, rc, n, gp);
+          if (m == 0) printf("x_resident codegen k %4u lane %2u mt %u warps %2u rowmap %u: %u instructions, %u registers (declared %u, register file %u of 65536), shared %u B\n", s.k, s.lane_bytes, s.mt, s.warps, s.rowmap, n, gp, decl, 32u * s.warps * decl, omega_fp8gemm_shared_bytes(&s));
+      } }
+    { OmegaFp8GemmSpec s = { 2048, 16, 8, 16, 0, 1, 0, 0, 1 };
+      const int fits = 8u * 2048u * 4u <= OMEGA_BW_QMD_MAX_SHARED_BYTES;
+      CHECK((omega_fp8gemm_shared_bytes(&s) != 0) == fits, "x_resident gate_up k 2048 mt 8: %s at the %u B QMD limit", fits ? "accepted" : "refused", OMEGA_BW_QMD_MAX_SHARED_BYTES); }
+    { OmegaFp8GemmSpec s = { 512, 16, 8, 16, 0, 1, 0, 0, 1 }; CHECK(omega_fp8gemm_shared_bytes(&s) == 8u * 512u * 4u, "x_resident shared bytes = mt * k * 4"); }
+    { OmegaFp8GemmSpec s = { 512, 16, 8, 16, 0, 1, 0, 0, 2 }; CHECK(omega_fp8gemm_prog_stats(&s, NULL, NULL) != 0, "x_resident 2 refused"); }
+    { OmegaFp8GemmSpec s = { 512, 16, 4, 16, 0, 1, 1, 0, 1 }; CHECK(omega_fp8gemm_prog_stats(&s, NULL, NULL) != 0, "x_resident with x_ahead refused"); }
+    { OmegaFp8GemmSpec s = { 512, 16, 16, 16, 0, 0, 0, 0, 1 }; CHECK(omega_fp8gemm_prog_stats(&s, NULL, NULL) != 0, "x_resident mt 16 refused"); }
+    { OmegaFp8GemmSpec s = { 768, 8, 4, 16, 0, 0, 0, 0, 1 }; CHECK(omega_fp8gemm_prog_stats(&s, NULL, NULL) != 0, "x_resident k 768 at 16 warps refused (k %% 512)"); }
+    { OmegaFp8GemmSpec s = { 512, 16, 4, 16, 0, 1, 0, 1, 1 }; CHECK(omega_fp8gemm_prog_stats(&s, NULL, NULL) != 0, "x_resident with row_ahead refused"); }
+    { OmegaFp8GemmSpec s = { 512, 16, 4, 16, 7, 1, 0, 0, 0 }; CHECK(omega_fp8gemm_prog_stats(&s, NULL, NULL) != 0, "mutant 7 without x_resident refused");
+      s.x_resident = 1; CHECK(omega_fp8gemm_prog_stats(&s, NULL, NULL) == 0, "mutant 7 with x_resident accepted");
+      s.mutant = 10; CHECK(omega_fp8gemm_prog_stats(&s, NULL, NULL) != 0, "mutant 10 refused"); }
     CHECK(OMEGA_GEMM_ARGS_WORDS <= OMEGA_GPU_SESSION_MAX_ARGS, "argument words fit the constant bank window");
     uint32_t ids[3] = { 2, 1, 1 }, tr[3] = { 0, 0, 0 }; float xr[2048] = { 0 }, yo[4];
     CHECK(omega_gpu_fp8gemm_f32(NULL, 3, ids, tr, xr, 1, yo, NULL) == OMEGA_GPU_FP8GEMM_BAD_ARGS, "a NULL tensor is refused");
@@ -143,10 +199,13 @@ static void host_only(void) {
 
 /* ------------------------------------------------------------- simulator */
 static uint64_t g_sim_issues;
+static uint32_t g_xa; /* the battery runs once with x_ahead 0 (the incumbent) and once with x_ahead 1 (L312 lever 3) */
+static uint32_t g_ra; /* 1: the row_ahead battery (DRA-79, KS 1 shapes only) */
+static uint32_t g_xr; /* 1: the x_resident battery (DRA-80 / DRA-81 / DRA-89) */
 typedef struct { uint32_t k, n, lb, mt, w, grid; uint32_t counts[4]; uint32_t nseg; } SimPt;
 static int sim_point(const SimPt *p, int mutant, uint32_t seed, char *msg, size_t msgn, size_t *bad) {
     static BlackwellIRProgram prog;
-    OmegaFp8GemmSpec spec = { p->k, p->lb, p->mt, p->w, mutant, 0 };
+    OmegaFp8GemmSpec spec = { p->k, p->lb, p->mt, p->w, mutant, 0, g_xa, g_ra, g_xr };
     if (omega_blackwell_codegen_fp8gemm_prog(&spec, &prog) != 0) { snprintf(msg, msgn, "codegen refused"); return -1; }
     uint32_t M = 0; for (uint32_t g = 0; g < p->nseg; g++) M += p->counts[g];
     Weights W; weights_make(&W, p->nseg, p->n, p->k, seed);
@@ -198,7 +257,7 @@ static int sim_point(const SimPt *p, int mutant, uint32_t seed, char *msg, size_
  * result must equal the emulation moved through YMAP and differ from the unmoved one. budget: the simulator's step budget. */
 static int sim_point2(const SimPt *p, int mutant, uint32_t seed, int rowmap, int empty_at, uint64_t budget, char *msg, size_t msgn, size_t *bad, int *moved) {
     static BlackwellIRProgram prog;
-    OmegaFp8GemmSpec spec = { p->k, p->lb, p->mt, p->w, mutant, (uint32_t)rowmap };
+    OmegaFp8GemmSpec spec = { p->k, p->lb, p->mt, p->w, mutant, (uint32_t)rowmap, g_xa, g_ra, g_xr };
     if (omega_blackwell_codegen_fp8gemm_prog(&spec, &prog) != 0) { snprintf(msg, msgn, "codegen refused"); return -1; }
     uint32_t M = 0; for (uint32_t g = 0; g < p->nseg; g++) M += p->counts[g];
     Weights W; weights_make(&W, p->nseg, p->n, p->k, seed);
@@ -268,7 +327,8 @@ static int sim_point2(const SimPt *p, int mutant, uint32_t seed, int rowmap, int
     return err;
 }
 
-static void sim_battery(void) {
+static void sim_battery_one(void) {
+    printf("sim battery, x_ahead %u\n", g_xa);
     SimPt pts[] = {
         { 2048, 40, 16, 8, 16, 2, { 1, 5, 9 }, 3 },           /* lane 16, KS 4 (2 iterations), 2 passes in segment 3, row clamping (n 40 < 2 x 32 x 1) */
         { 4096, 20, 16, 8, 16, 1, { 3, 8 }, 2 },              /* KS 8: 4 iterations */
@@ -325,6 +385,108 @@ static void sim_battery(void) {
     }
     printf("sim: %" PRIu64 " warp issues in total\n", g_sim_issues);
 }
+/* DRA-79 row_ahead: KS 1 shapes only (the decode down projection). Many rows per warp (the next-row prefetch crosses the row loop
+ * several times), more than one pass per row (passes before the last re-load the current row), clamped rows past n, more than one
+ * 128-row scale block, an empty segment, the row-mapped form; mutants 1, 3 (the incumbent's), 5 (wrong next row) and 6 (next row
+ * at every pass) must be caught, mutant 4 (guard dropped) must run out of steps */
+static void sim_battery_ra(void) {
+    printf("sim battery, row_ahead 1, x_ahead %u\n", g_xa);
+    const SimPt pts[] = {
+        { 512, 200, 16, 4, 16, 1, { 1, 5, 9 }, 3 },   /* 13 rows per warp, up to 3 passes, rows past n clamped, 2 scale blocks */
+        { 512, 300, 16, 4, 16, 2, { 3, 2 }, 2 },      /* 2 CTAs: stride 32, 3 scale blocks (2 segments, so the mapped form moves rows) */
+        { 512, 40, 16, 8, 16, 2, { 1, 5, 9 }, 3 },    /* mt 8: 2 rows per warp, clamping */
+        { 512, 150, 16, 4, 8, 1, { 2, 7 }, 2 },       /* 8 warps */
+        { 256, 150, 8, 4, 8, 1, { 2, 7 }, 2 },        /* lane 8: k 256 is one step */
+    };
+    char msg[300]; size_t bad = 1; int moved = 0, err;
+    for (size_t i = 0; i < sizeof pts / sizeof pts[0]; i++) {
+        err = sim_point(&pts[i], 0, 131 + (uint32_t)i, msg, sizeof msg, &bad);
+        CHECK(!err && bad == 0, "sim row_ahead k %u n %u lane %u mt %u warps %u grid %u: %s", pts[i].k, pts[i].n, pts[i].lb, pts[i].mt, pts[i].w, pts[i].grid, msg);
+        printf("sim row_ahead k %u n %u lane %u mt %u warps %u grid %u: %s %s\n", pts[i].k, pts[i].n, pts[i].lb, pts[i].mt, pts[i].w, pts[i].grid, err ? "ERROR" : bad ? "MISMATCH" : "ok", msg);
+        bad = 1; SimPt q = pts[i]; if (q.mt > 4u) q.mt = 4u; /* the mapped form runs at mt <= 4 */
+        err = sim_point2(&q, 0, 151 + (uint32_t)i, 1, (int)(i % 3), 0, msg, sizeof msg, &bad, &moved);
+        CHECK(!err && bad == 0 && moved, "sim row_ahead rowmap k %u n %u mt %u + empty segment at %zu: %s", q.k, q.n, q.mt, i % 3, msg);
+        printf("sim row_ahead rowmap k %u n %u mt %u warps %u + empty segment at %zu: %s %s\n", q.k, q.n, q.mt, q.w, i % 3, err ? "ERROR" : bad ? "MISMATCH" : "ok", msg);
+    }
+    const int ms[] = { 1, 3, 5, 6 };
+    for (unsigned j = 0; j < 4; j++) {
+        bad = 0; err = sim_point(&pts[0], ms[j], 77, msg, sizeof msg, &bad);
+        CHECK(!err && bad != 0, "sim row_ahead mutant %d must be caught: %s", ms[j], msg);
+        printf("sim row_ahead mutant %d: %s %s\n", ms[j], err ? "ERROR" : bad ? "caught" : "NOT CAUGHT", msg);
+        bad = 0; err = sim_point2(&pts[0], ms[j], 78, 1, -1, 0, msg, sizeof msg, &bad, NULL);
+        CHECK(!err && bad != 0, "sim row_ahead rowmap mutant %d must be caught: %s", ms[j], msg);
+        printf("sim row_ahead rowmap mutant %d: %s %s\n", ms[j], err ? "ERROR" : bad ? "caught" : "NOT CAUGHT", msg);
+    }
+    err = sim_point2(&pts[0], 4, 99, 0, 1, 2000000ull, msg, sizeof msg, &bad, NULL);
+    CHECK(err != 0 && (strstr(msg, "step budget") || strstr(msg, "outside the declared buffers")), "sim row_ahead mutant 4 (no empty-segment guard) must be caught: %s", msg);
+    printf("sim row_ahead empty segment, mutant 4 (guard dropped): %s %s\n", err ? "caught" : "NOT CAUGHT", msg);
+    printf("sim: %" PRIu64 " warp issues in total\n", g_sim_issues);
+}
+/* x_resident (DRA-80): every point bit-identical to the emulation (the same arithmetic as x_resident 0, whose battery
+ * above proves the same), plain and mapped, mt 1 .. 8, KS 1 / 2 / 3 / 4 / 8, several rows per warp per pass (the cross-row
+ * prefetch and its wrap to the next pass's first row), empty segments; mutants 1-4 and 7-9 caught */
+static void sim_battery_resident(void) {
+    g_xa = 0; g_xr = 1;
+    printf("sim battery, x_resident 1\n");
+    const SimPt pts[] = {
+        { 2048, 40, 16, 4, 16, 2, { 1, 5, 9 }, 3 },   /* KS 4 (2 iterations), 3 passes, 2 rows per warp (the second clamped) */
+        { 4096, 20, 16, 2, 16, 1, { 3, 8 }, 2 },      /* KS 8, mt 2: 4 passes */
+        { 1024, 33, 16, 8, 16, 2, { 2, 1 }, 2 },      /* KS 2: one iteration, mt 8 */
+        { 768, 24, 8, 8, 8, 1, { 1, 8, 2 }, 3 },      /* lane 8, KS 3 (odd, unrolled), 3 rows per warp */
+        { 2048, 16, 16, 4, 16, 1, { 6, 4 }, 2 },
+        { 4096, 70, 16, 1, 16, 2, { 5 }, 1 },         /* DRA-89's O shape (one segment, k 4096) at mt 1: 5 passes, 3 rows per warp */
+        { 2048, 130, 16, 2, 16, 1, { 5 }, 1 },        /* DRA-89's mix shape at mt 2: 9 rows per warp, 3 passes */
+        { 256, 24, 8, 8, 8, 1, { 3, 9 }, 2 },         /* KS 1 at lane 8 */
+    };
+    char msg[300]; size_t bad = 1; int moved = 0, err;
+    for (size_t i = 0; i < sizeof pts / sizeof pts[0]; i++) {
+        bad = 1; err = sim_point(&pts[i], 0, 131 + (uint32_t)i, msg, sizeof msg, &bad);
+        CHECK(!err && bad == 0, "x_resident sim k %u n %u lane %u mt %u warps %u grid %u: %s", pts[i].k, pts[i].n, pts[i].lb, pts[i].mt, pts[i].w, pts[i].grid, msg);
+        printf("x_resident sim k %u n %u lane %u mt %u warps %u grid %u: %s %s\n", pts[i].k, pts[i].n, pts[i].lb, pts[i].mt, pts[i].w, pts[i].grid, err ? "ERROR" : bad ? "MISMATCH" : "ok", msg);
+    }
+    const SimPt rmpts[] = {
+        { 2048, 40, 16, 4, 16, 2, { 1, 5, 9 }, 3 },
+        { 4096, 20, 16, 2, 16, 1, { 3, 8 }, 2 },      /* + an empty segment */
+        { 512, 40, 16, 4, 16, 2, { 1, 5, 9 }, 3 },    /* down at mt 4 (DRA-80) */
+        { 512, 40, 16, 8, 16, 2, { 1, 5, 9 }, 3 },    /* down at mt 8 (DRA-81) */
+        { 512, 40, 16, 8, 16, 2, { 1, 9, 3, 1 }, 4 }, /* a 9-row segment (the shared expert at N 9): 2 passes at mt 8, + an empty segment */
+        { 768, 24, 8, 8, 8, 1, { 1, 8, 2 }, 3 },
+        { 1024, 33, 16, 8, 16, 2, { 2, 1 }, 2 },
+    };
+    for (size_t i = 0; i < sizeof rmpts / sizeof rmpts[0]; i++) {
+        const SimPt *p = &rmpts[i]; const int ea = (i == 1 || i == 4) ? 1 : -1;
+        bad = 1; err = sim_point2(p, 0, 161 + (uint32_t)i, 1, ea, 0, msg, sizeof msg, &bad, &moved);
+        CHECK(!err && bad == 0 && moved, "x_resident sim rowmap k %u mt %u%s: %s", p->k, p->mt, ea >= 0 ? " + empty segment" : "", msg);
+        printf("x_resident sim rowmap k %u n %u mt %u warps %u%s: %s %s\n", p->k, p->n, p->mt, p->w, ea >= 0 ? " + empty segment" : "", err ? "ERROR" : bad ? "MISMATCH" : "ok", msg);
+    }
+    for (int at = 0; at <= 2; at++) {
+        bad = 1; err = sim_point2(&pts[0], 0, 181 + (uint32_t)at, 0, at + (at == 2 ? 1 : 0), 0, msg, sizeof msg, &bad, NULL);
+        CHECK(!err && bad == 0, "x_resident sim empty segment at %d: %s", at, msg);
+        printf("x_resident sim k %u empty segment at index %d: %s %s\n", pts[0].k, at + (at == 2 ? 1 : 0), err ? "ERROR" : bad ? "MISMATCH" : "ok", msg);
+    }
+    err = sim_point2(&pts[4], 4, 99, 0, 1, 2000000ull, msg, sizeof msg, &bad, NULL);
+    CHECK(err != 0 && (strstr(msg, "step budget") || strstr(msg, "outside the declared buffers")), "x_resident sim mutant 4 (no empty-segment guard) must be caught: %s", msg);
+    printf("x_resident sim empty segment, mutant 4 (guard dropped): %s %s\n", err ? "caught" : "NOT CAUGHT", msg);
+    const int muts[] = { 1, 2, 3, 7, 9 };
+    for (unsigned i = 0; i < sizeof muts / sizeof muts[0]; i++) {
+        bad = 0; err = sim_point(&pts[0], muts[i], 77, msg, sizeof msg, &bad);
+        CHECK(!err && bad != 0, "x_resident sim mutant %d must be caught: %s", muts[i], msg);
+        printf("x_resident sim mutant %d: %s %s\n", muts[i], err ? "ERROR" : bad ? "caught" : "NOT CAUGHT", msg);
+    }
+    const int rmuts[] = { 3, 8, 9 };
+    for (unsigned i = 0; i < sizeof rmuts / sizeof rmuts[0]; i++) {
+        bad = 0; err = sim_point2(&rmpts[3], rmuts[i], 77, 1, -1, 0, msg, sizeof msg, &bad, NULL);
+        CHECK(!err && bad != 0, "x_resident sim rowmap mutant %d must be caught: %s", rmuts[i], msg);
+        printf("x_resident sim rowmap mutant %d (down, mt 8): %s %s\n", rmuts[i], err ? "ERROR" : bad ? "caught" : "NOT CAUGHT", msg);
+    }
+    g_xr = 0;
+}
+static void sim_battery(void) {
+    for (g_xa = 0; g_xa <= 1; g_xa++) sim_battery_one();
+    for (g_ra = 1, g_xa = 0; g_xa <= 1; g_xa++) sim_battery_ra();
+    g_ra = 0; g_xa = 0;
+    sim_battery_resident();
+}
 
 /* ------------------------------------------------------------- chip */
 static int g_evict = 1;
@@ -353,8 +515,9 @@ static void run_shape(const Shape *S, uint32_t reps, uint32_t seed) {
     uint32_t *ids = malloc(M * 4), *trow = malloc(M * 4);
     uint32_t *picks = malloc((size_t)M * 4);
     make_table(S->tokens, S->topk, S->experts, seed + 7, ids, trow, picks);
-    uint32_t xrows = S->experts > 1 ? (S->k == 768 ? M : S->tokens) : S->tokens;
-    if (S->experts > 1 && S->k == 768) for (uint32_t i = 0; i < M; i++) trow[i] = i; /* down: one activation row per routed row */
+    const int per_row_x = S->experts > 1 && (S->k == 768 || S->k == 512); /* down: one activation row per routed row (k 768 the 30B's, k 512 the 35B's) */
+    uint32_t xrows = S->experts > 1 ? (per_row_x ? M : S->tokens) : S->tokens;
+    if (per_row_x) for (uint32_t i = 0; i < M; i++) trow[i] = i;
     float *x = make_x(xrows, S->k, seed + 3);
     float *y = malloc((size_t)M * S->n * 4), *yref = malloc((size_t)M * S->n * 4), *y2 = malloc((size_t)M * S->n * 4);
     OmegaGpuFp8GemmInfo info;
@@ -387,13 +550,17 @@ static void run_shape(const Shape *S, uint32_t reps, uint32_t seed) {
         CHECK(rc == 0 && memcmp(y, y2, (size_t)M * S->n * 4) == 0, "%s: second call bit-identical", S->name);
         printf("second call: %s\n", rc == 0 && memcmp(y, y2, (size_t)M * S->n * 4) == 0 ? "bit-identical" : "DIFFERS");
         /* mutants */
-        for (int m = 1; m <= 3; m++) {
+        OmegaFp8GemmSpec rs; omega_gpu_fp8gemm_stroke_spec(S->k, 64, 0, 0, &rs); /* row_ahead (DRA-79) adds mutants 5 and 6 */
+        for (int m = 1; m <= (rs.row_ahead ? 6 : 3); m++) {
+            if (m == 4) continue; /* the empty-segment guard: no empty segment on this path (the simulator catches it) */
             omega_gpu_fp8gemm_test_set_mutant(m);
             rc = omega_gpu_fp8gemm_f32(t, M, ids, trow, x, xrows, y2, NULL);
             size_t b = 0; if (rc == 0) for (size_t i = 0; i < (size_t)M * S->n; i++) if (memcmp(&y[i], &y2[i], 4) != 0) b++;
             if (rc != 0) printf("chip mutant %d: call returned %s: %s\n", m, omega_gpu_fp8gemm_rc_name(rc), omega_gpu_fp8gemm_last_error());
             int caught = rc == 0 && b != 0;
             if (m == 2 && info.k / (32u * info.lane_bytes) < 2) caught = 1; /* single-step k: mutant 2 has no effect by construction */
+            if (m == 3 && info.mt < 2) caught = 1;                           /* one row per pass (--mt 1): mutant 3 has no neighbour row */
+            if (m == 6 && info.passes_max < 2) caught = 1;                   /* one pass per row: every pass is the last */
             CHECK(caught, "%s: chip mutant %d must be caught", S->name, m);
             printf("chip mutant %d: %s (%zu of %zu outputs differ)\n", m, caught ? "caught" : "NOT CAUGHT", b, (size_t)M * S->n);
             if (g_out) fprintf(g_out, "%s{\"point\":\"%s mutant %d\",\"caught\":%d}", g_first ? "" : ",", S->name, m, caught), g_first = 0;
@@ -418,7 +585,7 @@ static void run_shape(const Shape *S, uint32_t reps, uint32_t seed) {
             for (uint32_t tk = 0; tk < S->tokens && ok; tk++) {
                 OmegaGpuFp8Info fi; int r2;
                 if (S->experts == 1) r2 = omega_gpu_fp8_gemv_f32(t, 0, x + (size_t)tk * S->k, yref, &fi);
-                else if (S->k == 768) r2 = omega_gpu_fp8_gemv_grouped_f32(t, S->topk, picks + (size_t)tk * S->topk, x + (size_t)tk * S->topk * S->k, S->topk, yref, &fi);
+                else if (per_row_x) r2 = omega_gpu_fp8_gemv_grouped_f32(t, S->topk, picks + (size_t)tk * S->topk, x + (size_t)tk * S->topk * S->k, S->topk, yref, &fi);
                 else r2 = omega_gpu_fp8_gemv_grouped_f32(t, S->topk, picks + (size_t)tk * S->topk, x + (size_t)tk * S->k, 1, yref, &fi);
                 if (r2) ok = 0; else { sum_e += fi.elapsed_ns; sum_c += fi.call_ns; }
             }
@@ -436,8 +603,29 @@ static void run_shape(const Shape *S, uint32_t reps, uint32_t seed) {
     free(ids); free(trow); free(picks); free(x); free(y); free(yref); free(y2); weights_free(&W);
 }
 
+/* --spec-of K,SEGS,MT,ROWMAP: the spec the stroke path resolves under this process's environment, printed as one line with
+ * ctas = the CTA budget per segment it records with (DRA-78); with --expect "f=v ...", every listed field must hold (the
+ * env-gate checks of the decode levers: default off; the knob checks a chip slice runs before it measures). */
+static int spec_of(const char *arg, const char *expect) {
+    unsigned k = 0, segs = 0, mt = 0, rowmap = 0;
+    if (sscanf(arg, "%u,%u,%u,%u", &k, &segs, &mt, &rowmap) != 4) { printf("spec-of: bad argument %s\n", arg); return 2; }
+    OmegaFp8GemmSpec s; omega_gpu_fp8gemm_stroke_spec(k, segs, mt, (int)rowmap, &s);
+    char line[256];
+    snprintf(line, sizeof line, " k=%u lane_bytes=%u mt=%u warps=%u mutant=%d rowmap=%u x_ahead=%u ctas=%u row_ahead=%u x_resident=%u ", s.k, s.lane_bytes, s.mt, s.warps, s.mutant, s.rowmap, s.x_ahead,
+             omega_gpu_fp8gemm_stroke_cta_budget(k, segs), s.row_ahead, s.x_resident);
+    printf("spec-of %s:%s\n", arg, line);
+    if (!expect) return 0;
+    char want[64]; const char *p = expect; int n = 0, bad = 0;
+    while (sscanf(p, " %62s%n", want + 1, &n) == 1) {
+        want[0] = ' '; size_t w = strlen(want); want[w] = ' '; want[w + 1] = 0;
+        g_checks++; if (!strstr(line, want)) { g_failed++; bad = 1; printf("spec-of %s: FAIL expected%s\n", arg, want); }
+        p += n;
+    }
+    return bad;
+}
+
 int main(int argc, char **argv) {
-    int host = 0, sim = 0; const char *out_path = NULL, *shape = "all"; uint32_t reps = 0, mt = 0, warps = 0, ctas = 0, spin = 2000, tokens = 64;
+    int host = 0, sim = 0; const char *out_path = NULL, *shape = "all", *spec_arg = NULL, *expect = NULL; uint32_t reps = 0, mt = 0, warps = 0, ctas = 0, spin = 2000, tokens = 64;
     for (int i = 1; i < argc; i++) {
         if (strcmp(argv[i], "--host-only") == 0) host = 1;
         else if (strcmp(argv[i], "--sim") == 0) sim = 1;
@@ -450,11 +638,23 @@ int main(int argc, char **argv) {
         else if (strcmp(argv[i], "--tokens") == 0 && i + 1 < argc) tokens = (uint32_t)atoi(argv[++i]);
         else if (strcmp(argv[i], "--spin-us") == 0 && i + 1 < argc) spin = (uint32_t)atoi(argv[++i]);
         else if (strcmp(argv[i], "--no-evict") == 0) g_evict = 0;
+        else if (strcmp(argv[i], "--spec-of") == 0 && i + 1 < argc) spec_arg = argv[++i];
+        else if (strcmp(argv[i], "--expect") == 0 && i + 1 < argc) expect = argv[++i];
         else { printf("unknown argument %s\n", argv[i]); return 2; }
     }
-    Shape shapes[] = { { "gateup", 128, 1536, 2048, tokens, 8 }, { "down", 128, 2048, 768, tokens, 8 }, { "qkv", 1, 5120, 2048, tokens, 1 }, { "o", 1, 2048, 4096, tokens, 1 }, { "d768", 1, 2048, 768, tokens, 1 } };
+    if (spec_arg) {
+        if (mt || warps) omega_gpu_fp8gemm_set_shape(mt, warps);
+        if (ctas) omega_gpu_fp8gemm_set_cta_budget(ctas);
+        int rc = spec_of(spec_arg, expect);
+        if (rc == 2 || !expect) return rc;
+        printf("gpu_fp8gemm_test: %d checks, %d failed: %s\n", g_checks, g_failed, g_failed ? "FAIL" : "PASS");
+        return g_failed ? 1 : 0;
+    }
+    Shape shapes[] = { { "gateup", 128, 1536, 2048, tokens, 8 }, { "down", 128, 2048, 768, tokens, 8 }, { "qkv", 1, 5120, 2048, tokens, 1 }, { "o", 1, 2048, 4096, tokens, 1 }, { "d768", 1, 2048, 768, tokens, 1 }, { "mix", 1, 12288, 2048, tokens, 1 },
+                       { "d512", 128, 2048, 512, tokens, 8 } }; /* d512: the 35B's down projection (k 512: one K step, DRA-79 row_ahead) */
+    const unsigned nshapes = sizeof shapes / sizeof shapes[0];
     unsigned selected = 0;
-    for (unsigned i = 0; i < 5; i++) if ((!strcmp(shape, "all") && i < 4) || !strcmp(shape, shapes[i].name)) selected++;
+    for (unsigned i = 0; i < nshapes; i++) if ((!strcmp(shape, "all") && i < 4) || !strcmp(shape, shapes[i].name)) selected++;
     if (!selected) { fprintf(stderr, "gpu_fp8gemm_test: INVALID shape '%s'\n", shape); return 2; }
     if (host) host_only();
     if (sim) sim_battery();
@@ -463,7 +663,7 @@ int main(int argc, char **argv) {
         if (ctas) omega_gpu_fp8gemm_set_cta_budget(ctas);
         (void)omega_gpu_session_set_spin_us(spin);
         if (out_path) { g_out = test_out_open(out_path); if (g_out) fprintf(g_out, "{\"receipt\":\"OMEGA_GPU_FP8GEMM_V1\",\"reps\":%u,\"evict\":%d,\"tokens\":%u,\"spin_us\":%u,\"points\":[", reps ? reps : 1, g_evict, tokens, omega_gpu_session_spin_us()); }
-        for (unsigned i = 0; i < 5; i++) if ((!strcmp(shape, "all") && i < 4) || !strcmp(shape, shapes[i].name)) run_shape(&shapes[i], reps ? reps : 1, 1000 + i);
+        for (unsigned i = 0; i < nshapes; i++) if ((!strcmp(shape, "all") && i < 4) || !strcmp(shape, shapes[i].name)) run_shape(&shapes[i], reps ? reps : 1, 1000 + i);
         if (g_out) { fprintf(g_out, "],\"checks\":%d,\"failed\":%d,\"verdict\":\"%s\"}\n", g_checks, g_failed, !g_checks ? "NOT_RUN" : g_failed ? "FAIL" : "PASS"); fclose(g_out); }
         omega_gpu_session_close();
     }
diff --git a/tests/gpu_gpr_boundary_test.c b/tests/gpu_gpr_boundary_test.c
index 21046454..c36328ec 100644
--- a/tests/gpu_gpr_boundary_test.c
+++ b/tests/gpu_gpr_boundary_test.c
@@ -56,11 +56,23 @@ int main(void) {
     { unsigned ks[] = { 2048, 4096 }; for (unsigned i = 0; i < 2; i++) { OmegaBf16GemvSpec s; memset(&s, 0, sizeof s); s.k = ks[i]; uint32_t c; omega_gpu_bf16_shape_for(s.k, &s.rows, &s.warps, &s.depth, &c);
         uint32_t peak = 0, decl = 0; CHECK(omega_bf16_gemv_prog_stats(&s, NULL, &peak) == 0, "bf16 k%u builds", ks[i]); (void)omega_gpu_bf16_kernel_fits(&s, &decl);
         CHECK(omega_bw_gpr_declared_ok(decl, peak), "bf16 gemv k%u: peak %u declared %u", ks[i], peak, decl); } }
-    /* fp8 grouped GEMM (all shapes we launch) */
-    { unsigned ks[] = { 2048, 768, 4096 }, mts[] = { 4, 8 }; for (unsigned i = 0; i < 3; i++) for (unsigned j = 0; j < 2; j++) {
-        OmegaFp8GemmSpec s = { ks[i], ks[i] % 512 ? 8u : 16u, mts[j], 16, 0, 0 }; uint32_t peak = 0, decl = 0;
-        CHECK(omega_fp8gemm_prog_stats(&s, NULL, &peak) == 0, "gemm k%u mt%u builds", ks[i], mts[j]); (void)omega_gpu_fp8gemm_kernel_fits(&s, &decl);
-        CHECK(omega_bw_gpr_declared_ok(decl, peak), "gemm k%u mt%u: peak %u declared %u", ks[i], mts[j], peak, decl); } }
+    /* fp8 grouped GEMM (all shapes we launch, with and without the L312 lever 3 x' prefetch) */
+    { unsigned ks[] = { 2048, 768, 4096 }, mts[] = { 4, 8 }; for (unsigned xa = 0; xa < 2; xa++) for (unsigned i = 0; i < 3; i++) for (unsigned j = 0; j < 2; j++) {
+        OmegaFp8GemmSpec s = { ks[i], ks[i] % 512 ? 8u : 16u, mts[j], 16, 0, 0, xa, 0, 0 }; uint32_t peak = 0, decl = 0;
+        CHECK(omega_fp8gemm_prog_stats(&s, NULL, &peak) == 0, "gemm k%u mt%u x_ahead %u builds", ks[i], mts[j], xa); (void)omega_gpu_fp8gemm_kernel_fits(&s, &decl);
+        CHECK(omega_bw_gpr_declared_ok(decl, peak), "gemm k%u mt%u x_ahead %u: peak %u declared %u", ks[i], mts[j], xa, peak, decl); } }
+    /* DRA-79 row_ahead: the decode down projection (k 512, one K step), mapped and plain, with and without x_ahead */
+    { unsigned mts[] = { 4, 8 }; for (unsigned xa = 0; xa < 2; xa++) for (unsigned rm = 0; rm < 2; rm++) for (unsigned j = 0; j < 2; j++) {
+        if (rm && mts[j] > 4) continue;
+        OmegaFp8GemmSpec s = { 512, 16, mts[j], 16, 0, rm, xa, 1, 0 }; uint32_t peak = 0, decl = 0;
+        CHECK(omega_fp8gemm_prog_stats(&s, NULL, &peak) == 0, "gemm k512 mt%u rowmap %u x_ahead %u row_ahead builds", mts[j], rm, xa); (void)omega_gpu_fp8gemm_kernel_fits(&s, &decl);
+        CHECK(omega_bw_gpr_declared_ok(decl, peak), "gemm k512 mt%u rowmap %u x_ahead %u row_ahead: peak %u declared %u", mts[j], rm, xa, peak, decl); } }
+    /* DRA-80/81/89 x_resident: the served shapes (down k 512 mt 4/8 mapped, gate_up k 2048 mt 4 mapped, dense mix/o k 2048/4096 mt 1/2/4) */
+    { struct { unsigned k, mt, rm; } xr[] = { { 512, 4, 1 }, { 512, 8, 1 }, { 2048, 4, 1 }, { 2048, 1, 0 }, { 2048, 2, 0 }, { 2048, 4, 0 }, { 4096, 1, 0 }, { 4096, 2, 0 } };
+      for (unsigned i = 0; i < sizeof xr / sizeof xr[0]; i++) {
+        OmegaFp8GemmSpec s = { xr[i].k, 16, xr[i].mt, 16, 0, xr[i].rm, 0, 0, 1 }; uint32_t peak = 0, decl = 0;
+        CHECK(omega_fp8gemm_prog_stats(&s, NULL, &peak) == 0, "gemm k%u mt%u rowmap %u x_resident builds", xr[i].k, xr[i].mt, xr[i].rm); (void)omega_gpu_fp8gemm_kernel_fits(&s, &decl);
+        CHECK(omega_bw_gpr_declared_ok(decl, peak), "gemm k%u mt%u rowmap %u x_resident: peak %u declared %u", xr[i].k, xr[i].mt, xr[i].rm, peak, decl); } }
     /* router and decode attention: the launcher uses omega_bw_gpr_declared(peak) (static), so check the helper on the real peak */
     { OmegaRouterSpec s = { .warps = OMEGA_GPU_ROUTER_WARPS, .depth = OMEGA_GPU_ROUTER_DEPTH }; uint32_t peak = 0;
       CHECK(omega_router_prog_stats(&s, NULL, &peak) == 0 && omega_bw_gpr_declared_ok(omega_bw_gpr_declared(peak), peak), "router peak %u", peak); printf("router peak %u -> declared %u\n", peak, omega_bw_gpr_declared(peak)); }