diff --git a/crates/cuda-driver/ptx-sm86/MANIFEST.json b/crates/cuda-driver/ptx-sm86/MANIFEST.json index 91bebca3..29bfdf6e 100644 --- a/crates/cuda-driver/ptx-sm86/MANIFEST.json +++ b/crates/cuda-driver/ptx-sm86/MANIFEST.json @@ -2712,6 +2712,20 @@ "problems": [ "not built for sm_86 by design (claude/decode-sm120-switches): the switch is a compute capability 12.0 decode switch; original_verify_window_sm120.rs enables it only on a 12.x card, so an sm_86 build never loads this module" ] + }, + { + "name": "draft_commit.ptx", + "sm120_path": "crates/cuda-driver/src/draft_commit.ptx", + "problems": [ + "not built for sm_86 by design (claude/draft-round): LELEKA_DRAFT_FUSED_COMMIT is opt-in and original_verify_schedule.rs::record_commit fuses only on a compute capability 12 card, so an sm_86 build never loads this module" + ] + }, + { + "name": "draft_commit_qsa.ptx", + "sm120_path": "crates/cuda-driver/src/draft_commit_qsa.ptx", + "problems": [ + "not built for sm_86 by design (claude/draft-round): LELEKA_DRAFT_FUSED_COMMIT is opt-in and original_verify_schedule.rs::record_commit fuses only on a compute capability 12 card, so an sm_86 build never loads this module" + ] } ], "portable_no_companion_needed": [ diff --git a/crates/cuda-driver/src/draft_commit.cu b/crates/cuda-driver/src/draft_commit.cu new file mode 100644 index 00000000..44b091f3 --- /dev/null +++ b/crates/cuda-driver/src/draft_commit.cu @@ -0,0 +1,106 @@ +// draft-round: the verifier's accepted-prefix commit graph, GDN layers fused (docs/experiments/draft-round-5090.md). The QSA layers are draft_commit_qsa.cu (fast-math). +// +// The commit graph of the Original-literal verifier is 182 serial kernel nodes: for each of the 36 GDN layers `verify_gdn_conv_commit_kernel` + +// `verify_gdn_step_norm_multi_kernel` (the replay of the accepted tokens through the layer's recurrence) and for each of the 12 QSA layers one tail restore copy and +// eight `verify_qsa_append_analytic` launches, one per window row (original_verify.cu, original_verify_qsa.cu). The layers are independent of each other, so one launch +// per kind covers all of them. Every output word is computed by the same operations in the same order as by the kernels above: +// +// * GDN: the recurrence state `s` of a (layer, head, column, row group) is updated token by token exactly as in `verify_gdn_step_norm_multi_kernel` +// (same loads, same fmaf chain for kv, same red[] reduction order, same delta and fmaf update). The Original's replay also computes the layer's OUTPUT for every token +// (the o dot products, the RMS norm, the gated y write into a scratch region called `y_dummy` that nothing reads); that part never feeds the state and is not computed here. +// * the conv history update of `verify_gdn_conv_commit_kernel` runs as extra blocks of the same launch (it reads qkv and the old history, writes only the history). +// * the state-independent loads of all accepted tokens (the key vector, the value, the gate and the beta of each token) are issued before the token loop instead of inside it. +// +// The kernel argument is a by-value struct of u64 words; the per-layer addresses of the GDN operands are affine in the layer (canonical state/history, qkv_L, h_L, gate_L, beta_L). +// Compile: nvcc --ptx -O3 -arch=sm_120 --fmad=true --ftz=false (the recipe of original_verify.cu, which is not on the fast-math list). +#include +#include +#include + +constexpr int S = 128, RG = 4, RPG = S / RG; +constexpr int H_K = 16, H_V = 48, C_QKV = 10240; +constexpr int MAX_N = 8; // window rows (max_t) + +struct GdnCommitArgs { + uint64_t state_base; // canonical GDN allocation: layer i state at + i * layer_bytes, history at + i * layer_bytes + hist_off + uint64_t layer_bytes; + uint64_t hist_off; + uint64_t qkv_base; // [36][max_t][10240] f32 + uint64_t h_base; // [36][max_t][10240] f32 + uint64_t gate_base; // [36][max_t][48] f32 + uint64_t beta_base; // [36][max_t][48] f32 + uint64_t commit; // int32 [n_keep, ...] + uint64_t max_t; +}; + +// grid (48 + 20, 36), block (128, 4): blocks x < 48 replay one head of one layer, the other 20 are the conv history commit of the layer (10240 channels / 512 threads) +extern "C" __global__ void __launch_bounds__(S * RG) draft_commit_gdn_layers(GdnCommitArgs a) { + __shared__ float sk[MAX_N][S]; + __shared__ float red[2][RG][S]; + const int layer = blockIdx.y; + int n = *reinterpret_cast(a.commit); + if (n <= 0) return; // both Original kernels do nothing for an empty keep + if (n > MAX_N) n = MAX_N; + const size_t max_t = (size_t) a.max_t; + if (blockIdx.x >= H_V) { // verify_gdn_conv_commit_kernel + const int c = (blockIdx.x - H_V) * (S * RG) + threadIdx.y * S + threadIdx.x; + if (c >= C_QKV) return; + float* hist = reinterpret_cast(a.state_base + (uint64_t) layer * a.layer_bytes + a.hist_off); + const float* qkv = reinterpret_cast(a.qkv_base) + (size_t) layer * max_t * C_QKV; + float seq[3]; +#pragma unroll + for (int j = 0; j < 3; ++j) { + const int src = n + j; // the last three of [hist(3) | x_0..x_{n-1}] + seq[j] = src < 3 ? hist[c * 3 + src] : qkv[(size_t) (src - 3) * C_QKV + c]; + } + hist[c * 3] = seq[0]; + hist[c * 3 + 1] = seq[1]; + hist[c * 3 + 2] = seq[2]; + return; + } + // verify_gdn_step_norm_multi_kernel without the output path + const int head = blockIdx.x; + const int col = threadIdx.x; + const int rg = threadIdx.y; + const int tid = rg * S + col; + const int qh = head % H_K; + const int qk = S * H_K; // q at [0, qk), k at [qk, 2qk), v at [2qk, ...) + const float* hbuf = reinterpret_cast(a.h_base) + (size_t) layer * max_t * C_QKV; + const float* gate = reinterpret_cast(a.gate_base) + (size_t) layer * max_t * H_V; + const float* beta = reinterpret_cast(a.beta_base) + (size_t) layer * max_t * H_V; + float* state = reinterpret_cast(a.state_base + (uint64_t) layer * a.layer_bytes); + float s[RPG]; + float* base = state + ((size_t) (rg * RPG) * H_V + head) * S + col; + const size_t row_stride = (size_t) H_V * S; + // everything that does not depend on the state, for all n tokens, before the recurrence + float v[MAX_N], g[MAX_N], b[MAX_N]; +#pragma unroll + for (int t = 0; t < MAX_N; ++t) { + if (t < n) { + const float* ht = hbuf + (size_t) t * C_QKV; + if (tid < S) sk[t][tid] = ht[qk + qh * S + tid]; + v[t] = ht[2 * qk + head * S + col]; + g[t] = __expf(gate[(size_t) t * H_V + head]); + b[t] = beta[(size_t) t * H_V + head]; + } + } +#pragma unroll + for (int r = 0; r < RPG; ++r) s[r] = base[r * row_stride]; + __syncthreads(); +#pragma unroll + for (int t = 0; t < MAX_N; ++t) { + if (t < n) { + float kv = 0.0f; +#pragma unroll + for (int r = 0; r < RPG; ++r) kv = fmaf(s[r], sk[t][rg * RPG + r], kv); + red[t & 1][rg][col] = kv; + __syncthreads(); // one barrier per token: red is double buffered, the next write goes to the other buffer + const float kv_col = red[t & 1][0][col] + red[t & 1][1][col] + red[t & 1][2][col] + red[t & 1][3][col]; + const float delta = (v[t] - g[t] * kv_col) * b[t]; +#pragma unroll + for (int r = 0; r < RPG; ++r) s[r] = fmaf(g[t], s[r], sk[t][rg * RPG + r] * delta); + } + } +#pragma unroll + for (int r = 0; r < RPG; ++r) base[r * row_stride] = s[r]; +} diff --git a/crates/cuda-driver/src/draft_commit.ptx b/crates/cuda-driver/src/draft_commit.ptx new file mode 100644 index 00000000..b781b4c4 --- /dev/null +++ b/crates/cuda-driver/src/draft_commit.ptx @@ -0,0 +1,1791 @@ +// +// Generated by NVIDIA NVVM Compiler +// +// Compiler Build ID: UNKNOWN +// Cuda compilation tools, release 13.2, V13.2.86 +// Based on NVVM 22.0.0 +// + +.version 9.2 +.target sm_120 +.address_size 64 + + // .globl draft_commit_gdn_layers +// _ZZ23draft_commit_gdn_layersE2sk has been demoted +// _ZZ23draft_commit_gdn_layersE3red has been demoted + +.visible .entry draft_commit_gdn_layers( + .param .align 8 .b8 draft_commit_gdn_layers_param_0[72] +) +.maxntid 512 +{ + .reg .pred %p<28>; + .reg .b32 %r<1325>; + .reg .b64 %rd<66>; + // demoted variable + .shared .align 4 .b8 _ZZ23draft_commit_gdn_layersE2sk[4096]; + // demoted variable + .shared .align 4 .b8 _ZZ23draft_commit_gdn_layersE3red[4096]; + ld.param.b64 %rd1, [draft_commit_gdn_layers_param_0]; + ld.param.b64 %rd2, [draft_commit_gdn_layers_param_0+8]; + ld.param.b64 %rd3, [draft_commit_gdn_layers_param_0+16]; + ld.param.b64 %rd4, [draft_commit_gdn_layers_param_0+24]; + ld.param.b64 %rd5, [draft_commit_gdn_layers_param_0+32]; + ld.param.b64 %rd6, [draft_commit_gdn_layers_param_0+40]; + ld.param.b64 %rd7, [draft_commit_gdn_layers_param_0+48]; + ld.param.b64 %rd8, [draft_commit_gdn_layers_param_0+64]; + ld.param.b64 %rd21, [draft_commit_gdn_layers_param_0+56]; + mov.u32 %r1, %ctaid.y; + cvta.to.global.u64 %rd22, %rd21; + ld.global.b32 %r2, [%rd22]; + setp.lt.s32 %p1, %r2, 1; + @%p1 bra $L__BB0_55; + min.u32 %r3, %r2, 8; + mov.u32 %r4, %ctaid.x; + setp.lt.u32 %p2, %r4, 48; + @%p2 bra $L__BB0_10; + shl.b32 %r1259, %r4, 9; + mov.u32 %r1260, %tid.y; + shl.b32 %r1261, %r1260, 7; + mov.u32 %r1262, %tid.x; + add.s32 %r1263, %r1261, %r1262; + add.s32 %r1264, %r1259, %r1263; + add.s32 %r5, %r1264, -24576; + setp.gt.s32 %p25, %r5, 10239; + @%p25 bra $L__BB0_55; + cvt.u64.u32 %rd41, %r1; + add.s64 %rd42, %rd3, %rd1; + mad.lo.s64 %rd9, %rd2, %rd41, %rd42; + cvta.to.global.u64 %rd43, %rd4; + mul.lo.s64 %rd44, %rd41, %rd8; + mad.lo.s64 %rd10, %rd44, 40960, %rd43; + cvt.s64.s32 %rd11, %r5; + mul.lo.s32 %r6, %r5, 3; + setp.gt.u32 %p26, %r2, 2; + @%p26 bra $L__BB0_5; + add.s32 %r1266, %r3, %r6; + mul.wide.s32 %rd49, %r1266, 4; + add.s64 %rd50, %rd9, %rd49; + ld.b32 %r1270, [%rd50]; + bra.uni $L__BB0_6; +$L__BB0_5: + mad.lo.s32 %r1265, %r3, 10240, -30720; + cvt.u64.u32 %rd45, %r1265; + add.s64 %rd46, %rd45, %rd11; + shl.b64 %rd47, %rd46, 2; + add.s64 %rd48, %rd10, %rd47; + ld.global.b32 %r1270, [%rd48]; +$L__BB0_6: + setp.eq.b32 %p27, %r2, 1; + @%p27 bra $L__BB0_8; + mad.lo.s32 %r1267, %r3, 10240, -20480; + cvt.u64.u32 %rd51, %r1267; + add.s64 %rd52, %rd51, %rd11; + shl.b64 %rd53, %rd52, 2; + add.s64 %rd54, %rd10, %rd53; + ld.global.b32 %r1271, [%rd54]; + bra.uni $L__BB0_9; +$L__BB0_8: + cvt.s64.s32 %rd55, %r6; + cvt.u64.u32 %rd56, %r3; + add.s64 %rd57, %rd56, %rd55; + shl.b64 %rd58, %rd57, 2; + add.s64 %rd59, %rd9, %rd58; + ld.b32 %r1271, [%rd59+4]; +$L__BB0_9: + mad.lo.s32 %r1268, %r3, 10240, -10240; + cvt.u64.u32 %rd60, %r1268; + add.s64 %rd61, %rd60, %rd11; + shl.b64 %rd62, %rd61, 2; + add.s64 %rd63, %rd10, %rd62; + ld.global.b32 %r1269, [%rd63]; + mul.wide.s32 %rd64, %r6, 4; + add.s64 %rd65, %rd9, %rd64; + st.b32 [%rd65], %r1270; + st.b32 [%rd65+4], %r1271; + st.b32 [%rd65+8], %r1269; + bra.uni $L__BB0_55; +$L__BB0_10: + mov.u32 %r12, %tid.x; + mov.u32 %r13, %tid.y; + shl.b32 %r14, %r13, 7; + add.s32 %r7, %r14, %r12; + and.b32 %r15, %r4, 15; + cvta.to.global.u64 %rd23, %rd5; + cvt.u64.u32 %rd24, %r1; + mul.lo.s64 %rd25, %rd8, %rd24; + mad.lo.s64 %rd12, %rd25, 40960, %rd23; + cvta.to.global.u64 %rd26, %rd6; + mul.lo.s64 %rd27, %rd25, 192; + add.s64 %rd13, %rd26, %rd27; + cvta.to.global.u64 %rd28, %rd7; + add.s64 %rd14, %rd28, %rd27; + mad.lo.s64 %rd29, %rd2, %rd24, %rd1; + mad.lo.s32 %r16, %r13, 1536, %r4; + mul.wide.u32 %rd30, %r16, 512; + add.s64 %rd31, %rd29, %rd30; + cvt.u64.u32 %rd15, %r12; + mul.wide.u32 %rd32, %r12, 4; + add.s64 %rd16, %rd31, %rd32; + setp.gt.u32 %p3, %r7, 127; + cvt.u64.u32 %rd33, %r7; + mul.wide.u32 %rd34, %r15, 128; + add.s64 %rd35, %rd34, %rd33; + shl.b32 %r17, %r7, 2; + mov.b32 %r18, _ZZ23draft_commit_gdn_layersE2sk; + add.s32 %r8, %r18, %r17; + shl.b64 %rd36, %rd35, 2; + add.s64 %rd17, %rd12, %rd36; + @%p3 bra $L__BB0_12; + ld.global.b32 %r19, [%rd17+8192]; + st.shared.b32 [%r8], %r19; +$L__BB0_12: + mul.wide.u32 %rd37, %r4, 128; + add.s64 %rd38, %rd15, %rd37; + shl.b64 %rd39, %rd38, 2; + add.s64 %rd18, %rd12, %rd39; + ld.global.b32 %r9, [%rd18+16384]; + mul.wide.u32 %rd40, %r4, 4; + add.s64 %rd19, %rd13, %rd40; + ld.global.b32 %r20, [%rd19]; + mul.f32 %r10, %r20, 0f3FB8AA3B; + add.s64 %rd20, %rd14, %rd40; + ld.global.b32 %r11, [%rd20]; + setp.eq.b32 %p4, %r2, 1; + @%p4 bra $L__BB0_16; + setp.gt.u32 %p5, %r7, 127; + @%p5 bra $L__BB0_15; + ld.global.b32 %r21, [%rd17+49152]; + st.shared.b32 [%r8+512], %r21; +$L__BB0_15: + ld.global.b32 %r1272, [%rd18+57344]; + ld.global.b32 %r22, [%rd19+192]; + mul.f32 %r23, %r22, 0f3FB8AA3B; + ex2.approx.f32 %r1273, %r23; + ld.global.b32 %r1274, [%rd20+192]; +$L__BB0_16: + setp.lt.u32 %p6, %r2, 3; + @%p6 bra $L__BB0_20; + setp.gt.u32 %p7, %r7, 127; + @%p7 bra $L__BB0_19; + ld.global.b32 %r24, [%rd17+90112]; + st.shared.b32 [%r8+1024], %r24; +$L__BB0_19: + ld.global.b32 %r1275, [%rd18+98304]; + ld.global.b32 %r25, [%rd19+384]; + mul.f32 %r26, %r25, 0f3FB8AA3B; + ex2.approx.f32 %r1276, %r26; + ld.global.b32 %r1277, [%rd20+384]; +$L__BB0_20: + setp.lt.u32 %p8, %r2, 4; + @%p8 bra $L__BB0_24; + setp.gt.u32 %p9, %r7, 127; + @%p9 bra $L__BB0_23; + ld.global.b32 %r27, [%rd17+131072]; + st.shared.b32 [%r8+1536], %r27; +$L__BB0_23: + ld.global.b32 %r1278, [%rd18+139264]; + ld.global.b32 %r28, [%rd19+576]; + mul.f32 %r29, %r28, 0f3FB8AA3B; + ex2.approx.f32 %r1279, %r29; + ld.global.b32 %r1280, [%rd20+576]; +$L__BB0_24: + setp.lt.u32 %p10, %r2, 5; + @%p10 bra $L__BB0_28; + setp.gt.u32 %p11, %r7, 127; + @%p11 bra $L__BB0_27; + ld.global.b32 %r30, [%rd17+172032]; + st.shared.b32 [%r8+2048], %r30; +$L__BB0_27: + ld.global.b32 %r1281, [%rd18+180224]; + ld.global.b32 %r31, [%rd19+768]; + mul.f32 %r32, %r31, 0f3FB8AA3B; + ex2.approx.f32 %r1282, %r32; + ld.global.b32 %r1283, [%rd20+768]; +$L__BB0_28: + setp.lt.u32 %p12, %r2, 6; + @%p12 bra $L__BB0_32; + setp.gt.u32 %p13, %r7, 127; + @%p13 bra $L__BB0_31; + ld.global.b32 %r33, [%rd17+212992]; + st.shared.b32 [%r8+2560], %r33; +$L__BB0_31: + ld.global.b32 %r1284, [%rd18+221184]; + ld.global.b32 %r34, [%rd19+960]; + mul.f32 %r35, %r34, 0f3FB8AA3B; + ex2.approx.f32 %r1285, %r35; + ld.global.b32 %r1286, [%rd20+960]; +$L__BB0_32: + setp.lt.u32 %p14, %r2, 7; + @%p14 bra $L__BB0_36; + setp.gt.u32 %p15, %r7, 127; + @%p15 bra $L__BB0_35; + ld.global.b32 %r36, [%rd17+253952]; + st.shared.b32 [%r8+3072], %r36; +$L__BB0_35: + ld.global.b32 %r1287, [%rd18+262144]; + ld.global.b32 %r37, [%rd19+1152]; + mul.f32 %r38, %r37, 0f3FB8AA3B; + ex2.approx.f32 %r1288, %r38; + ld.global.b32 %r1289, [%rd20+1152]; +$L__BB0_36: + setp.lt.u32 %p16, %r2, 8; + @%p16 bra $L__BB0_40; + setp.gt.u32 %p17, %r7, 127; + @%p17 bra $L__BB0_39; + ld.global.b32 %r39, [%rd17+294912]; + st.shared.b32 [%r8+3584], %r39; +$L__BB0_39: + ld.global.b32 %r1290, [%rd18+303104]; + ld.global.b32 %r40, [%rd19+1344]; + mul.f32 %r41, %r40, 0f3FB8AA3B; + ex2.approx.f32 %r1291, %r41; + ld.global.b32 %r1292, [%rd20+1344]; +$L__BB0_40: + ex2.approx.f32 %r42, %r10; + setp.eq.b32 %p18, %r2, 1; + ld.b32 %r43, [%rd16]; + ld.b32 %r44, [%rd16+24576]; + ld.b32 %r45, [%rd16+49152]; + ld.b32 %r46, [%rd16+73728]; + ld.b32 %r47, [%rd16+98304]; + ld.b32 %r48, [%rd16+122880]; + ld.b32 %r49, [%rd16+147456]; + ld.b32 %r50, [%rd16+172032]; + ld.b32 %r51, [%rd16+196608]; + ld.b32 %r52, [%rd16+221184]; + ld.b32 %r53, [%rd16+245760]; + ld.b32 %r54, [%rd16+270336]; + ld.b32 %r55, [%rd16+294912]; + ld.b32 %r56, [%rd16+319488]; + ld.b32 %r57, [%rd16+344064]; + ld.b32 %r58, [%rd16+368640]; + ld.b32 %r59, [%rd16+393216]; + ld.b32 %r60, [%rd16+417792]; + ld.b32 %r61, [%rd16+442368]; + ld.b32 %r62, [%rd16+466944]; + ld.b32 %r63, [%rd16+491520]; + ld.b32 %r64, [%rd16+516096]; + ld.b32 %r65, [%rd16+540672]; + ld.b32 %r66, [%rd16+565248]; + ld.b32 %r67, [%rd16+589824]; + ld.b32 %r68, [%rd16+614400]; + ld.b32 %r69, [%rd16+638976]; + ld.b32 %r70, [%rd16+663552]; + ld.b32 %r71, [%rd16+688128]; + ld.b32 %r72, [%rd16+712704]; + ld.b32 %r73, [%rd16+737280]; + ld.b32 %r74, [%rd16+761856]; + bar.sync 0; + mov.u32 %r75, %tid.y; + shl.b32 %r76, %r75, 7; + mov.b32 %r77, _ZZ23draft_commit_gdn_layersE2sk; + add.s32 %r78, %r77, %r76; + ld.shared.b32 %r79, [%r78]; + fma.rn.f32 %r80, %r43, %r79, 0f00000000; + ld.shared.b32 %r81, [%r78+4]; + fma.rn.f32 %r82, %r44, %r81, %r80; + ld.shared.b32 %r83, [%r78+8]; + fma.rn.f32 %r84, %r45, %r83, %r82; + ld.shared.b32 %r85, [%r78+12]; + fma.rn.f32 %r86, %r46, %r85, %r84; + ld.shared.b32 %r87, [%r78+16]; + fma.rn.f32 %r88, %r47, %r87, %r86; + ld.shared.b32 %r89, [%r78+20]; + fma.rn.f32 %r90, %r48, %r89, %r88; + ld.shared.b32 %r91, [%r78+24]; + fma.rn.f32 %r92, %r49, %r91, %r90; + ld.shared.b32 %r93, [%r78+28]; + fma.rn.f32 %r94, %r50, %r93, %r92; + ld.shared.b32 %r95, [%r78+32]; + fma.rn.f32 %r96, %r51, %r95, %r94; + ld.shared.b32 %r97, [%r78+36]; + fma.rn.f32 %r98, %r52, %r97, %r96; + ld.shared.b32 %r99, [%r78+40]; + fma.rn.f32 %r100, %r53, %r99, %r98; + ld.shared.b32 %r101, [%r78+44]; + fma.rn.f32 %r102, %r54, %r101, %r100; + ld.shared.b32 %r103, [%r78+48]; + fma.rn.f32 %r104, %r55, %r103, %r102; + ld.shared.b32 %r105, [%r78+52]; + fma.rn.f32 %r106, %r56, %r105, %r104; + ld.shared.b32 %r107, [%r78+56]; + fma.rn.f32 %r108, %r57, %r107, %r106; + ld.shared.b32 %r109, [%r78+60]; + fma.rn.f32 %r110, %r58, %r109, %r108; + ld.shared.b32 %r111, [%r78+64]; + fma.rn.f32 %r112, %r59, %r111, %r110; + ld.shared.b32 %r113, [%r78+68]; + fma.rn.f32 %r114, %r60, %r113, %r112; + ld.shared.b32 %r115, [%r78+72]; + fma.rn.f32 %r116, %r61, %r115, %r114; + ld.shared.b32 %r117, [%r78+76]; + fma.rn.f32 %r118, %r62, %r117, %r116; + ld.shared.b32 %r119, [%r78+80]; + fma.rn.f32 %r120, %r63, %r119, %r118; + ld.shared.b32 %r121, [%r78+84]; + fma.rn.f32 %r122, %r64, %r121, %r120; + ld.shared.b32 %r123, [%r78+88]; + fma.rn.f32 %r124, %r65, %r123, %r122; + ld.shared.b32 %r125, [%r78+92]; + fma.rn.f32 %r126, %r66, %r125, %r124; + ld.shared.b32 %r127, [%r78+96]; + fma.rn.f32 %r128, %r67, %r127, %r126; + ld.shared.b32 %r129, [%r78+100]; + fma.rn.f32 %r130, %r68, %r129, %r128; + ld.shared.b32 %r131, [%r78+104]; + fma.rn.f32 %r132, %r69, %r131, %r130; + ld.shared.b32 %r133, [%r78+108]; + fma.rn.f32 %r134, %r70, %r133, %r132; + ld.shared.b32 %r135, [%r78+112]; + fma.rn.f32 %r136, %r71, %r135, %r134; + ld.shared.b32 %r137, [%r78+116]; + fma.rn.f32 %r138, %r72, %r137, %r136; + ld.shared.b32 %r139, [%r78+120]; + fma.rn.f32 %r140, %r73, %r139, %r138; + ld.shared.b32 %r141, [%r78+124]; + fma.rn.f32 %r142, %r74, %r141, %r140; + shl.b32 %r143, %r75, 9; + mov.b32 %r144, _ZZ23draft_commit_gdn_layersE3red; + mov.u32 %r145, %tid.x; + shl.b32 %r146, %r145, 2; + add.s32 %r147, %r144, %r146; + add.s32 %r148, %r147, %r143; + st.shared.b32 [%r148], %r142; + bar.sync 0; + ld.shared.b32 %r149, [%r147]; + ld.shared.b32 %r150, [%r147+512]; + add.f32 %r151, %r149, %r150; + ld.shared.b32 %r152, [%r147+1024]; + add.f32 %r153, %r151, %r152; + ld.shared.b32 %r154, [%r147+1536]; + add.f32 %r155, %r153, %r154; + mul.f32 %r156, %r155, %r42; + sub.f32 %r157, %r9, %r156; + mul.f32 %r158, %r11, %r157; + ld.shared.b32 %r159, [%r78]; + mul.f32 %r160, %r158, %r159; + fma.rn.f32 %r1318, %r42, %r43, %r160; + ld.shared.b32 %r161, [%r78+4]; + mul.f32 %r162, %r158, %r161; + fma.rn.f32 %r1317, %r42, %r44, %r162; + ld.shared.b32 %r163, [%r78+8]; + mul.f32 %r164, %r158, %r163; + fma.rn.f32 %r1316, %r42, %r45, %r164; + ld.shared.b32 %r165, [%r78+12]; + mul.f32 %r166, %r158, %r165; + fma.rn.f32 %r1315, %r42, %r46, %r166; + ld.shared.b32 %r167, [%r78+16]; + mul.f32 %r168, %r158, %r167; + fma.rn.f32 %r1314, %r42, %r47, %r168; + ld.shared.b32 %r169, [%r78+20]; + mul.f32 %r170, %r158, %r169; + fma.rn.f32 %r1313, %r42, %r48, %r170; + ld.shared.b32 %r171, [%r78+24]; + mul.f32 %r172, %r158, %r171; + fma.rn.f32 %r1312, %r42, %r49, %r172; + ld.shared.b32 %r173, [%r78+28]; + mul.f32 %r174, %r158, %r173; + fma.rn.f32 %r1311, %r42, %r50, %r174; + ld.shared.b32 %r175, [%r78+32]; + mul.f32 %r176, %r158, %r175; + fma.rn.f32 %r1310, %r42, %r51, %r176; + ld.shared.b32 %r177, [%r78+36]; + mul.f32 %r178, %r158, %r177; + fma.rn.f32 %r1309, %r42, %r52, %r178; + ld.shared.b32 %r179, [%r78+40]; + mul.f32 %r180, %r158, %r179; + fma.rn.f32 %r1308, %r42, %r53, %r180; + ld.shared.b32 %r181, [%r78+44]; + mul.f32 %r182, %r158, %r181; + fma.rn.f32 %r1307, %r42, %r54, %r182; + ld.shared.b32 %r183, [%r78+48]; + mul.f32 %r184, %r158, %r183; + fma.rn.f32 %r1306, %r42, %r55, %r184; + ld.shared.b32 %r185, [%r78+52]; + mul.f32 %r186, %r158, %r185; + fma.rn.f32 %r1305, %r42, %r56, %r186; + ld.shared.b32 %r187, [%r78+56]; + mul.f32 %r188, %r158, %r187; + fma.rn.f32 %r1304, %r42, %r57, %r188; + ld.shared.b32 %r189, [%r78+60]; + mul.f32 %r190, %r158, %r189; + fma.rn.f32 %r1303, %r42, %r58, %r190; + ld.shared.b32 %r191, [%r78+64]; + mul.f32 %r192, %r158, %r191; + fma.rn.f32 %r1302, %r42, %r59, %r192; + ld.shared.b32 %r193, [%r78+68]; + mul.f32 %r194, %r158, %r193; + fma.rn.f32 %r1301, %r42, %r60, %r194; + ld.shared.b32 %r195, [%r78+72]; + mul.f32 %r196, %r158, %r195; + fma.rn.f32 %r1300, %r42, %r61, %r196; + ld.shared.b32 %r197, [%r78+76]; + mul.f32 %r198, %r158, %r197; + fma.rn.f32 %r1299, %r42, %r62, %r198; + ld.shared.b32 %r199, [%r78+80]; + mul.f32 %r200, %r158, %r199; + fma.rn.f32 %r1298, %r42, %r63, %r200; + ld.shared.b32 %r201, [%r78+84]; + mul.f32 %r202, %r158, %r201; + fma.rn.f32 %r1297, %r42, %r64, %r202; + ld.shared.b32 %r203, [%r78+88]; + mul.f32 %r204, %r158, %r203; + fma.rn.f32 %r1296, %r42, %r65, %r204; + ld.shared.b32 %r205, [%r78+92]; + mul.f32 %r206, %r158, %r205; + fma.rn.f32 %r1295, %r42, %r66, %r206; + ld.shared.b32 %r207, [%r78+96]; + mul.f32 %r208, %r158, %r207; + fma.rn.f32 %r1294, %r42, %r67, %r208; + ld.shared.b32 %r209, [%r78+100]; + mul.f32 %r210, %r158, %r209; + fma.rn.f32 %r1293, %r42, %r68, %r210; + ld.shared.b32 %r211, [%r78+104]; + mul.f32 %r212, %r158, %r211; + fma.rn.f32 %r1319, %r42, %r69, %r212; + ld.shared.b32 %r213, [%r78+108]; + mul.f32 %r214, %r158, %r213; + fma.rn.f32 %r1320, %r42, %r70, %r214; + ld.shared.b32 %r215, [%r78+112]; + mul.f32 %r216, %r158, %r215; + fma.rn.f32 %r1321, %r42, %r71, %r216; + ld.shared.b32 %r217, [%r78+116]; + mul.f32 %r218, %r158, %r217; + fma.rn.f32 %r1322, %r42, %r72, %r218; + ld.shared.b32 %r219, [%r78+120]; + mul.f32 %r220, %r158, %r219; + fma.rn.f32 %r1323, %r42, %r73, %r220; + ld.shared.b32 %r221, [%r78+124]; + mul.f32 %r222, %r158, %r221; + fma.rn.f32 %r1324, %r42, %r74, %r222; + @%p18 bra $L__BB0_42; + mov.u32 %r223, %tid.y; + shl.b32 %r224, %r223, 7; + mov.b32 %r225, _ZZ23draft_commit_gdn_layersE2sk; + add.s32 %r226, %r225, %r224; + ld.shared.b32 %r227, [%r226+512]; + fma.rn.f32 %r228, %r1318, %r227, 0f00000000; + ld.shared.b32 %r229, [%r226+516]; + fma.rn.f32 %r230, %r1317, %r229, %r228; + ld.shared.b32 %r231, [%r226+520]; + fma.rn.f32 %r232, %r1316, %r231, %r230; + ld.shared.b32 %r233, [%r226+524]; + fma.rn.f32 %r234, %r1315, %r233, %r232; + ld.shared.b32 %r235, [%r226+528]; + fma.rn.f32 %r236, %r1314, %r235, %r234; + ld.shared.b32 %r237, [%r226+532]; + fma.rn.f32 %r238, %r1313, %r237, %r236; + ld.shared.b32 %r239, [%r226+536]; + fma.rn.f32 %r240, %r1312, %r239, %r238; + ld.shared.b32 %r241, [%r226+540]; + fma.rn.f32 %r242, %r1311, %r241, %r240; + ld.shared.b32 %r243, [%r226+544]; + fma.rn.f32 %r244, %r1310, %r243, %r242; + ld.shared.b32 %r245, [%r226+548]; + fma.rn.f32 %r246, %r1309, %r245, %r244; + ld.shared.b32 %r247, [%r226+552]; + fma.rn.f32 %r248, %r1308, %r247, %r246; + ld.shared.b32 %r249, [%r226+556]; + fma.rn.f32 %r250, %r1307, %r249, %r248; + ld.shared.b32 %r251, [%r226+560]; + fma.rn.f32 %r252, %r1306, %r251, %r250; + ld.shared.b32 %r253, [%r226+564]; + fma.rn.f32 %r254, %r1305, %r253, %r252; + ld.shared.b32 %r255, [%r226+568]; + fma.rn.f32 %r256, %r1304, %r255, %r254; + ld.shared.b32 %r257, [%r226+572]; + fma.rn.f32 %r258, %r1303, %r257, %r256; + ld.shared.b32 %r259, [%r226+576]; + fma.rn.f32 %r260, %r1302, %r259, %r258; + ld.shared.b32 %r261, [%r226+580]; + fma.rn.f32 %r262, %r1301, %r261, %r260; + ld.shared.b32 %r263, [%r226+584]; + fma.rn.f32 %r264, %r1300, %r263, %r262; + ld.shared.b32 %r265, [%r226+588]; + fma.rn.f32 %r266, %r1299, %r265, %r264; + ld.shared.b32 %r267, [%r226+592]; + fma.rn.f32 %r268, %r1298, %r267, %r266; + ld.shared.b32 %r269, [%r226+596]; + fma.rn.f32 %r270, %r1297, %r269, %r268; + ld.shared.b32 %r271, [%r226+600]; + fma.rn.f32 %r272, %r1296, %r271, %r270; + ld.shared.b32 %r273, [%r226+604]; + fma.rn.f32 %r274, %r1295, %r273, %r272; + ld.shared.b32 %r275, [%r226+608]; + fma.rn.f32 %r276, %r1294, %r275, %r274; + ld.shared.b32 %r277, [%r226+612]; + fma.rn.f32 %r278, %r1293, %r277, %r276; + ld.shared.b32 %r279, [%r226+616]; + fma.rn.f32 %r280, %r1319, %r279, %r278; + ld.shared.b32 %r281, [%r226+620]; + fma.rn.f32 %r282, %r1320, %r281, %r280; + ld.shared.b32 %r283, [%r226+624]; + fma.rn.f32 %r284, %r1321, %r283, %r282; + ld.shared.b32 %r285, [%r226+628]; + fma.rn.f32 %r286, %r1322, %r285, %r284; + ld.shared.b32 %r287, [%r226+632]; + fma.rn.f32 %r288, %r1323, %r287, %r286; + ld.shared.b32 %r289, [%r226+636]; + fma.rn.f32 %r290, %r1324, %r289, %r288; + shl.b32 %r291, %r223, 9; + mov.b32 %r292, _ZZ23draft_commit_gdn_layersE3red; + mov.u32 %r293, %tid.x; + shl.b32 %r294, %r293, 2; + add.s32 %r295, %r292, %r294; + add.s32 %r296, %r295, %r291; + st.shared.b32 [%r296+2048], %r290; + bar.sync 0; + ld.shared.b32 %r297, [%r295+2048]; + ld.shared.b32 %r298, [%r295+2560]; + add.f32 %r299, %r297, %r298; + ld.shared.b32 %r300, [%r295+3072]; + add.f32 %r301, %r299, %r300; + ld.shared.b32 %r302, [%r295+3584]; + add.f32 %r303, %r301, %r302; + mul.f32 %r304, %r303, %r1273; + sub.f32 %r305, %r1272, %r304; + mul.f32 %r306, %r1274, %r305; + ld.shared.b32 %r307, [%r226+512]; + mul.f32 %r308, %r306, %r307; + fma.rn.f32 %r1318, %r1273, %r1318, %r308; + ld.shared.b32 %r309, [%r226+516]; + mul.f32 %r310, %r306, %r309; + fma.rn.f32 %r1317, %r1273, %r1317, %r310; + ld.shared.b32 %r311, [%r226+520]; + mul.f32 %r312, %r306, %r311; + fma.rn.f32 %r1316, %r1273, %r1316, %r312; + ld.shared.b32 %r313, [%r226+524]; + mul.f32 %r314, %r306, %r313; + fma.rn.f32 %r1315, %r1273, %r1315, %r314; + ld.shared.b32 %r315, [%r226+528]; + mul.f32 %r316, %r306, %r315; + fma.rn.f32 %r1314, %r1273, %r1314, %r316; + ld.shared.b32 %r317, [%r226+532]; + mul.f32 %r318, %r306, %r317; + fma.rn.f32 %r1313, %r1273, %r1313, %r318; + ld.shared.b32 %r319, [%r226+536]; + mul.f32 %r320, %r306, %r319; + fma.rn.f32 %r1312, %r1273, %r1312, %r320; + ld.shared.b32 %r321, [%r226+540]; + mul.f32 %r322, %r306, %r321; + fma.rn.f32 %r1311, %r1273, %r1311, %r322; + ld.shared.b32 %r323, [%r226+544]; + mul.f32 %r324, %r306, %r323; + fma.rn.f32 %r1310, %r1273, %r1310, %r324; + ld.shared.b32 %r325, [%r226+548]; + mul.f32 %r326, %r306, %r325; + fma.rn.f32 %r1309, %r1273, %r1309, %r326; + ld.shared.b32 %r327, [%r226+552]; + mul.f32 %r328, %r306, %r327; + fma.rn.f32 %r1308, %r1273, %r1308, %r328; + ld.shared.b32 %r329, [%r226+556]; + mul.f32 %r330, %r306, %r329; + fma.rn.f32 %r1307, %r1273, %r1307, %r330; + ld.shared.b32 %r331, [%r226+560]; + mul.f32 %r332, %r306, %r331; + fma.rn.f32 %r1306, %r1273, %r1306, %r332; + ld.shared.b32 %r333, [%r226+564]; + mul.f32 %r334, %r306, %r333; + fma.rn.f32 %r1305, %r1273, %r1305, %r334; + ld.shared.b32 %r335, [%r226+568]; + mul.f32 %r336, %r306, %r335; + fma.rn.f32 %r1304, %r1273, %r1304, %r336; + ld.shared.b32 %r337, [%r226+572]; + mul.f32 %r338, %r306, %r337; + fma.rn.f32 %r1303, %r1273, %r1303, %r338; + ld.shared.b32 %r339, [%r226+576]; + mul.f32 %r340, %r306, %r339; + fma.rn.f32 %r1302, %r1273, %r1302, %r340; + ld.shared.b32 %r341, [%r226+580]; + mul.f32 %r342, %r306, %r341; + fma.rn.f32 %r1301, %r1273, %r1301, %r342; + ld.shared.b32 %r343, [%r226+584]; + mul.f32 %r344, %r306, %r343; + fma.rn.f32 %r1300, %r1273, %r1300, %r344; + ld.shared.b32 %r345, [%r226+588]; + mul.f32 %r346, %r306, %r345; + fma.rn.f32 %r1299, %r1273, %r1299, %r346; + ld.shared.b32 %r347, [%r226+592]; + mul.f32 %r348, %r306, %r347; + fma.rn.f32 %r1298, %r1273, %r1298, %r348; + ld.shared.b32 %r349, [%r226+596]; + mul.f32 %r350, %r306, %r349; + fma.rn.f32 %r1297, %r1273, %r1297, %r350; + ld.shared.b32 %r351, [%r226+600]; + mul.f32 %r352, %r306, %r351; + fma.rn.f32 %r1296, %r1273, %r1296, %r352; + ld.shared.b32 %r353, [%r226+604]; + mul.f32 %r354, %r306, %r353; + fma.rn.f32 %r1295, %r1273, %r1295, %r354; + ld.shared.b32 %r355, [%r226+608]; + mul.f32 %r356, %r306, %r355; + fma.rn.f32 %r1294, %r1273, %r1294, %r356; + ld.shared.b32 %r357, [%r226+612]; + mul.f32 %r358, %r306, %r357; + fma.rn.f32 %r1293, %r1273, %r1293, %r358; + ld.shared.b32 %r359, [%r226+616]; + mul.f32 %r360, %r306, %r359; + fma.rn.f32 %r1319, %r1273, %r1319, %r360; + ld.shared.b32 %r361, [%r226+620]; + mul.f32 %r362, %r306, %r361; + fma.rn.f32 %r1320, %r1273, %r1320, %r362; + ld.shared.b32 %r363, [%r226+624]; + mul.f32 %r364, %r306, %r363; + fma.rn.f32 %r1321, %r1273, %r1321, %r364; + ld.shared.b32 %r365, [%r226+628]; + mul.f32 %r366, %r306, %r365; + fma.rn.f32 %r1322, %r1273, %r1322, %r366; + ld.shared.b32 %r367, [%r226+632]; + mul.f32 %r368, %r306, %r367; + fma.rn.f32 %r1323, %r1273, %r1323, %r368; + ld.shared.b32 %r369, [%r226+636]; + mul.f32 %r370, %r306, %r369; + fma.rn.f32 %r1324, %r1273, %r1324, %r370; +$L__BB0_42: + setp.lt.u32 %p19, %r2, 3; + @%p19 bra $L__BB0_44; + mov.u32 %r371, %tid.y; + shl.b32 %r372, %r371, 7; + mov.b32 %r373, _ZZ23draft_commit_gdn_layersE2sk; + add.s32 %r374, %r373, %r372; + ld.shared.b32 %r375, [%r374+1024]; + fma.rn.f32 %r376, %r1318, %r375, 0f00000000; + ld.shared.b32 %r377, [%r374+1028]; + fma.rn.f32 %r378, %r1317, %r377, %r376; + ld.shared.b32 %r379, [%r374+1032]; + fma.rn.f32 %r380, %r1316, %r379, %r378; + ld.shared.b32 %r381, [%r374+1036]; + fma.rn.f32 %r382, %r1315, %r381, %r380; + ld.shared.b32 %r383, [%r374+1040]; + fma.rn.f32 %r384, %r1314, %r383, %r382; + ld.shared.b32 %r385, [%r374+1044]; + fma.rn.f32 %r386, %r1313, %r385, %r384; + ld.shared.b32 %r387, [%r374+1048]; + fma.rn.f32 %r388, %r1312, %r387, %r386; + ld.shared.b32 %r389, [%r374+1052]; + fma.rn.f32 %r390, %r1311, %r389, %r388; + ld.shared.b32 %r391, [%r374+1056]; + fma.rn.f32 %r392, %r1310, %r391, %r390; + ld.shared.b32 %r393, [%r374+1060]; + fma.rn.f32 %r394, %r1309, %r393, %r392; + ld.shared.b32 %r395, [%r374+1064]; + fma.rn.f32 %r396, %r1308, %r395, %r394; + ld.shared.b32 %r397, [%r374+1068]; + fma.rn.f32 %r398, %r1307, %r397, %r396; + ld.shared.b32 %r399, [%r374+1072]; + fma.rn.f32 %r400, %r1306, %r399, %r398; + ld.shared.b32 %r401, [%r374+1076]; + fma.rn.f32 %r402, %r1305, %r401, %r400; + ld.shared.b32 %r403, [%r374+1080]; + fma.rn.f32 %r404, %r1304, %r403, %r402; + ld.shared.b32 %r405, [%r374+1084]; + fma.rn.f32 %r406, %r1303, %r405, %r404; + ld.shared.b32 %r407, [%r374+1088]; + fma.rn.f32 %r408, %r1302, %r407, %r406; + ld.shared.b32 %r409, [%r374+1092]; + fma.rn.f32 %r410, %r1301, %r409, %r408; + ld.shared.b32 %r411, [%r374+1096]; + fma.rn.f32 %r412, %r1300, %r411, %r410; + ld.shared.b32 %r413, [%r374+1100]; + fma.rn.f32 %r414, %r1299, %r413, %r412; + ld.shared.b32 %r415, [%r374+1104]; + fma.rn.f32 %r416, %r1298, %r415, %r414; + ld.shared.b32 %r417, [%r374+1108]; + fma.rn.f32 %r418, %r1297, %r417, %r416; + ld.shared.b32 %r419, [%r374+1112]; + fma.rn.f32 %r420, %r1296, %r419, %r418; + ld.shared.b32 %r421, [%r374+1116]; + fma.rn.f32 %r422, %r1295, %r421, %r420; + ld.shared.b32 %r423, [%r374+1120]; + fma.rn.f32 %r424, %r1294, %r423, %r422; + ld.shared.b32 %r425, [%r374+1124]; + fma.rn.f32 %r426, %r1293, %r425, %r424; + ld.shared.b32 %r427, [%r374+1128]; + fma.rn.f32 %r428, %r1319, %r427, %r426; + ld.shared.b32 %r429, [%r374+1132]; + fma.rn.f32 %r430, %r1320, %r429, %r428; + ld.shared.b32 %r431, [%r374+1136]; + fma.rn.f32 %r432, %r1321, %r431, %r430; + ld.shared.b32 %r433, [%r374+1140]; + fma.rn.f32 %r434, %r1322, %r433, %r432; + ld.shared.b32 %r435, [%r374+1144]; + fma.rn.f32 %r436, %r1323, %r435, %r434; + ld.shared.b32 %r437, [%r374+1148]; + fma.rn.f32 %r438, %r1324, %r437, %r436; + shl.b32 %r439, %r371, 9; + mov.b32 %r440, _ZZ23draft_commit_gdn_layersE3red; + mov.u32 %r441, %tid.x; + shl.b32 %r442, %r441, 2; + add.s32 %r443, %r440, %r442; + add.s32 %r444, %r443, %r439; + st.shared.b32 [%r444], %r438; + bar.sync 0; + ld.shared.b32 %r445, [%r443]; + ld.shared.b32 %r446, [%r443+512]; + add.f32 %r447, %r445, %r446; + ld.shared.b32 %r448, [%r443+1024]; + add.f32 %r449, %r447, %r448; + ld.shared.b32 %r450, [%r443+1536]; + add.f32 %r451, %r449, %r450; + mul.f32 %r452, %r451, %r1276; + sub.f32 %r453, %r1275, %r452; + mul.f32 %r454, %r1277, %r453; + ld.shared.b32 %r455, [%r374+1024]; + mul.f32 %r456, %r454, %r455; + fma.rn.f32 %r1318, %r1276, %r1318, %r456; + ld.shared.b32 %r457, [%r374+1028]; + mul.f32 %r458, %r454, %r457; + fma.rn.f32 %r1317, %r1276, %r1317, %r458; + ld.shared.b32 %r459, [%r374+1032]; + mul.f32 %r460, %r454, %r459; + fma.rn.f32 %r1316, %r1276, %r1316, %r460; + ld.shared.b32 %r461, [%r374+1036]; + mul.f32 %r462, %r454, %r461; + fma.rn.f32 %r1315, %r1276, %r1315, %r462; + ld.shared.b32 %r463, [%r374+1040]; + mul.f32 %r464, %r454, %r463; + fma.rn.f32 %r1314, %r1276, %r1314, %r464; + ld.shared.b32 %r465, [%r374+1044]; + mul.f32 %r466, %r454, %r465; + fma.rn.f32 %r1313, %r1276, %r1313, %r466; + ld.shared.b32 %r467, [%r374+1048]; + mul.f32 %r468, %r454, %r467; + fma.rn.f32 %r1312, %r1276, %r1312, %r468; + ld.shared.b32 %r469, [%r374+1052]; + mul.f32 %r470, %r454, %r469; + fma.rn.f32 %r1311, %r1276, %r1311, %r470; + ld.shared.b32 %r471, [%r374+1056]; + mul.f32 %r472, %r454, %r471; + fma.rn.f32 %r1310, %r1276, %r1310, %r472; + ld.shared.b32 %r473, [%r374+1060]; + mul.f32 %r474, %r454, %r473; + fma.rn.f32 %r1309, %r1276, %r1309, %r474; + ld.shared.b32 %r475, [%r374+1064]; + mul.f32 %r476, %r454, %r475; + fma.rn.f32 %r1308, %r1276, %r1308, %r476; + ld.shared.b32 %r477, [%r374+1068]; + mul.f32 %r478, %r454, %r477; + fma.rn.f32 %r1307, %r1276, %r1307, %r478; + ld.shared.b32 %r479, [%r374+1072]; + mul.f32 %r480, %r454, %r479; + fma.rn.f32 %r1306, %r1276, %r1306, %r480; + ld.shared.b32 %r481, [%r374+1076]; + mul.f32 %r482, %r454, %r481; + fma.rn.f32 %r1305, %r1276, %r1305, %r482; + ld.shared.b32 %r483, [%r374+1080]; + mul.f32 %r484, %r454, %r483; + fma.rn.f32 %r1304, %r1276, %r1304, %r484; + ld.shared.b32 %r485, [%r374+1084]; + mul.f32 %r486, %r454, %r485; + fma.rn.f32 %r1303, %r1276, %r1303, %r486; + ld.shared.b32 %r487, [%r374+1088]; + mul.f32 %r488, %r454, %r487; + fma.rn.f32 %r1302, %r1276, %r1302, %r488; + ld.shared.b32 %r489, [%r374+1092]; + mul.f32 %r490, %r454, %r489; + fma.rn.f32 %r1301, %r1276, %r1301, %r490; + ld.shared.b32 %r491, [%r374+1096]; + mul.f32 %r492, %r454, %r491; + fma.rn.f32 %r1300, %r1276, %r1300, %r492; + ld.shared.b32 %r493, [%r374+1100]; + mul.f32 %r494, %r454, %r493; + fma.rn.f32 %r1299, %r1276, %r1299, %r494; + ld.shared.b32 %r495, [%r374+1104]; + mul.f32 %r496, %r454, %r495; + fma.rn.f32 %r1298, %r1276, %r1298, %r496; + ld.shared.b32 %r497, [%r374+1108]; + mul.f32 %r498, %r454, %r497; + fma.rn.f32 %r1297, %r1276, %r1297, %r498; + ld.shared.b32 %r499, [%r374+1112]; + mul.f32 %r500, %r454, %r499; + fma.rn.f32 %r1296, %r1276, %r1296, %r500; + ld.shared.b32 %r501, [%r374+1116]; + mul.f32 %r502, %r454, %r501; + fma.rn.f32 %r1295, %r1276, %r1295, %r502; + ld.shared.b32 %r503, [%r374+1120]; + mul.f32 %r504, %r454, %r503; + fma.rn.f32 %r1294, %r1276, %r1294, %r504; + ld.shared.b32 %r505, [%r374+1124]; + mul.f32 %r506, %r454, %r505; + fma.rn.f32 %r1293, %r1276, %r1293, %r506; + ld.shared.b32 %r507, [%r374+1128]; + mul.f32 %r508, %r454, %r507; + fma.rn.f32 %r1319, %r1276, %r1319, %r508; + ld.shared.b32 %r509, [%r374+1132]; + mul.f32 %r510, %r454, %r509; + fma.rn.f32 %r1320, %r1276, %r1320, %r510; + ld.shared.b32 %r511, [%r374+1136]; + mul.f32 %r512, %r454, %r511; + fma.rn.f32 %r1321, %r1276, %r1321, %r512; + ld.shared.b32 %r513, [%r374+1140]; + mul.f32 %r514, %r454, %r513; + fma.rn.f32 %r1322, %r1276, %r1322, %r514; + ld.shared.b32 %r515, [%r374+1144]; + mul.f32 %r516, %r454, %r515; + fma.rn.f32 %r1323, %r1276, %r1323, %r516; + ld.shared.b32 %r517, [%r374+1148]; + mul.f32 %r518, %r454, %r517; + fma.rn.f32 %r1324, %r1276, %r1324, %r518; +$L__BB0_44: + setp.lt.u32 %p20, %r2, 4; + @%p20 bra $L__BB0_46; + mov.u32 %r519, %tid.y; + shl.b32 %r520, %r519, 7; + mov.b32 %r521, _ZZ23draft_commit_gdn_layersE2sk; + add.s32 %r522, %r521, %r520; + ld.shared.b32 %r523, [%r522+1536]; + fma.rn.f32 %r524, %r1318, %r523, 0f00000000; + ld.shared.b32 %r525, [%r522+1540]; + fma.rn.f32 %r526, %r1317, %r525, %r524; + ld.shared.b32 %r527, [%r522+1544]; + fma.rn.f32 %r528, %r1316, %r527, %r526; + ld.shared.b32 %r529, [%r522+1548]; + fma.rn.f32 %r530, %r1315, %r529, %r528; + ld.shared.b32 %r531, [%r522+1552]; + fma.rn.f32 %r532, %r1314, %r531, %r530; + ld.shared.b32 %r533, [%r522+1556]; + fma.rn.f32 %r534, %r1313, %r533, %r532; + ld.shared.b32 %r535, [%r522+1560]; + fma.rn.f32 %r536, %r1312, %r535, %r534; + ld.shared.b32 %r537, [%r522+1564]; + fma.rn.f32 %r538, %r1311, %r537, %r536; + ld.shared.b32 %r539, [%r522+1568]; + fma.rn.f32 %r540, %r1310, %r539, %r538; + ld.shared.b32 %r541, [%r522+1572]; + fma.rn.f32 %r542, %r1309, %r541, %r540; + ld.shared.b32 %r543, [%r522+1576]; + fma.rn.f32 %r544, %r1308, %r543, %r542; + ld.shared.b32 %r545, [%r522+1580]; + fma.rn.f32 %r546, %r1307, %r545, %r544; + ld.shared.b32 %r547, [%r522+1584]; + fma.rn.f32 %r548, %r1306, %r547, %r546; + ld.shared.b32 %r549, [%r522+1588]; + fma.rn.f32 %r550, %r1305, %r549, %r548; + ld.shared.b32 %r551, [%r522+1592]; + fma.rn.f32 %r552, %r1304, %r551, %r550; + ld.shared.b32 %r553, [%r522+1596]; + fma.rn.f32 %r554, %r1303, %r553, %r552; + ld.shared.b32 %r555, [%r522+1600]; + fma.rn.f32 %r556, %r1302, %r555, %r554; + ld.shared.b32 %r557, [%r522+1604]; + fma.rn.f32 %r558, %r1301, %r557, %r556; + ld.shared.b32 %r559, [%r522+1608]; + fma.rn.f32 %r560, %r1300, %r559, %r558; + ld.shared.b32 %r561, [%r522+1612]; + fma.rn.f32 %r562, %r1299, %r561, %r560; + ld.shared.b32 %r563, [%r522+1616]; + fma.rn.f32 %r564, %r1298, %r563, %r562; + ld.shared.b32 %r565, [%r522+1620]; + fma.rn.f32 %r566, %r1297, %r565, %r564; + ld.shared.b32 %r567, [%r522+1624]; + fma.rn.f32 %r568, %r1296, %r567, %r566; + ld.shared.b32 %r569, [%r522+1628]; + fma.rn.f32 %r570, %r1295, %r569, %r568; + ld.shared.b32 %r571, [%r522+1632]; + fma.rn.f32 %r572, %r1294, %r571, %r570; + ld.shared.b32 %r573, [%r522+1636]; + fma.rn.f32 %r574, %r1293, %r573, %r572; + ld.shared.b32 %r575, [%r522+1640]; + fma.rn.f32 %r576, %r1319, %r575, %r574; + ld.shared.b32 %r577, [%r522+1644]; + fma.rn.f32 %r578, %r1320, %r577, %r576; + ld.shared.b32 %r579, [%r522+1648]; + fma.rn.f32 %r580, %r1321, %r579, %r578; + ld.shared.b32 %r581, [%r522+1652]; + fma.rn.f32 %r582, %r1322, %r581, %r580; + ld.shared.b32 %r583, [%r522+1656]; + fma.rn.f32 %r584, %r1323, %r583, %r582; + ld.shared.b32 %r585, [%r522+1660]; + fma.rn.f32 %r586, %r1324, %r585, %r584; + shl.b32 %r587, %r519, 9; + mov.b32 %r588, _ZZ23draft_commit_gdn_layersE3red; + mov.u32 %r589, %tid.x; + shl.b32 %r590, %r589, 2; + add.s32 %r591, %r588, %r590; + add.s32 %r592, %r591, %r587; + st.shared.b32 [%r592+2048], %r586; + bar.sync 0; + ld.shared.b32 %r593, [%r591+2048]; + ld.shared.b32 %r594, [%r591+2560]; + add.f32 %r595, %r593, %r594; + ld.shared.b32 %r596, [%r591+3072]; + add.f32 %r597, %r595, %r596; + ld.shared.b32 %r598, [%r591+3584]; + add.f32 %r599, %r597, %r598; + mul.f32 %r600, %r599, %r1279; + sub.f32 %r601, %r1278, %r600; + mul.f32 %r602, %r1280, %r601; + ld.shared.b32 %r603, [%r522+1536]; + mul.f32 %r604, %r602, %r603; + fma.rn.f32 %r1318, %r1279, %r1318, %r604; + ld.shared.b32 %r605, [%r522+1540]; + mul.f32 %r606, %r602, %r605; + fma.rn.f32 %r1317, %r1279, %r1317, %r606; + ld.shared.b32 %r607, [%r522+1544]; + mul.f32 %r608, %r602, %r607; + fma.rn.f32 %r1316, %r1279, %r1316, %r608; + ld.shared.b32 %r609, [%r522+1548]; + mul.f32 %r610, %r602, %r609; + fma.rn.f32 %r1315, %r1279, %r1315, %r610; + ld.shared.b32 %r611, [%r522+1552]; + mul.f32 %r612, %r602, %r611; + fma.rn.f32 %r1314, %r1279, %r1314, %r612; + ld.shared.b32 %r613, [%r522+1556]; + mul.f32 %r614, %r602, %r613; + fma.rn.f32 %r1313, %r1279, %r1313, %r614; + ld.shared.b32 %r615, [%r522+1560]; + mul.f32 %r616, %r602, %r615; + fma.rn.f32 %r1312, %r1279, %r1312, %r616; + ld.shared.b32 %r617, [%r522+1564]; + mul.f32 %r618, %r602, %r617; + fma.rn.f32 %r1311, %r1279, %r1311, %r618; + ld.shared.b32 %r619, [%r522+1568]; + mul.f32 %r620, %r602, %r619; + fma.rn.f32 %r1310, %r1279, %r1310, %r620; + ld.shared.b32 %r621, [%r522+1572]; + mul.f32 %r622, %r602, %r621; + fma.rn.f32 %r1309, %r1279, %r1309, %r622; + ld.shared.b32 %r623, [%r522+1576]; + mul.f32 %r624, %r602, %r623; + fma.rn.f32 %r1308, %r1279, %r1308, %r624; + ld.shared.b32 %r625, [%r522+1580]; + mul.f32 %r626, %r602, %r625; + fma.rn.f32 %r1307, %r1279, %r1307, %r626; + ld.shared.b32 %r627, [%r522+1584]; + mul.f32 %r628, %r602, %r627; + fma.rn.f32 %r1306, %r1279, %r1306, %r628; + ld.shared.b32 %r629, [%r522+1588]; + mul.f32 %r630, %r602, %r629; + fma.rn.f32 %r1305, %r1279, %r1305, %r630; + ld.shared.b32 %r631, [%r522+1592]; + mul.f32 %r632, %r602, %r631; + fma.rn.f32 %r1304, %r1279, %r1304, %r632; + ld.shared.b32 %r633, [%r522+1596]; + mul.f32 %r634, %r602, %r633; + fma.rn.f32 %r1303, %r1279, %r1303, %r634; + ld.shared.b32 %r635, [%r522+1600]; + mul.f32 %r636, %r602, %r635; + fma.rn.f32 %r1302, %r1279, %r1302, %r636; + ld.shared.b32 %r637, [%r522+1604]; + mul.f32 %r638, %r602, %r637; + fma.rn.f32 %r1301, %r1279, %r1301, %r638; + ld.shared.b32 %r639, [%r522+1608]; + mul.f32 %r640, %r602, %r639; + fma.rn.f32 %r1300, %r1279, %r1300, %r640; + ld.shared.b32 %r641, [%r522+1612]; + mul.f32 %r642, %r602, %r641; + fma.rn.f32 %r1299, %r1279, %r1299, %r642; + ld.shared.b32 %r643, [%r522+1616]; + mul.f32 %r644, %r602, %r643; + fma.rn.f32 %r1298, %r1279, %r1298, %r644; + ld.shared.b32 %r645, [%r522+1620]; + mul.f32 %r646, %r602, %r645; + fma.rn.f32 %r1297, %r1279, %r1297, %r646; + ld.shared.b32 %r647, [%r522+1624]; + mul.f32 %r648, %r602, %r647; + fma.rn.f32 %r1296, %r1279, %r1296, %r648; + ld.shared.b32 %r649, [%r522+1628]; + mul.f32 %r650, %r602, %r649; + fma.rn.f32 %r1295, %r1279, %r1295, %r650; + ld.shared.b32 %r651, [%r522+1632]; + mul.f32 %r652, %r602, %r651; + fma.rn.f32 %r1294, %r1279, %r1294, %r652; + ld.shared.b32 %r653, [%r522+1636]; + mul.f32 %r654, %r602, %r653; + fma.rn.f32 %r1293, %r1279, %r1293, %r654; + ld.shared.b32 %r655, [%r522+1640]; + mul.f32 %r656, %r602, %r655; + fma.rn.f32 %r1319, %r1279, %r1319, %r656; + ld.shared.b32 %r657, [%r522+1644]; + mul.f32 %r658, %r602, %r657; + fma.rn.f32 %r1320, %r1279, %r1320, %r658; + ld.shared.b32 %r659, [%r522+1648]; + mul.f32 %r660, %r602, %r659; + fma.rn.f32 %r1321, %r1279, %r1321, %r660; + ld.shared.b32 %r661, [%r522+1652]; + mul.f32 %r662, %r602, %r661; + fma.rn.f32 %r1322, %r1279, %r1322, %r662; + ld.shared.b32 %r663, [%r522+1656]; + mul.f32 %r664, %r602, %r663; + fma.rn.f32 %r1323, %r1279, %r1323, %r664; + ld.shared.b32 %r665, [%r522+1660]; + mul.f32 %r666, %r602, %r665; + fma.rn.f32 %r1324, %r1279, %r1324, %r666; +$L__BB0_46: + setp.lt.u32 %p21, %r2, 5; + @%p21 bra $L__BB0_48; + mov.u32 %r667, %tid.y; + shl.b32 %r668, %r667, 7; + mov.b32 %r669, _ZZ23draft_commit_gdn_layersE2sk; + add.s32 %r670, %r669, %r668; + ld.shared.b32 %r671, [%r670+2048]; + fma.rn.f32 %r672, %r1318, %r671, 0f00000000; + ld.shared.b32 %r673, [%r670+2052]; + fma.rn.f32 %r674, %r1317, %r673, %r672; + ld.shared.b32 %r675, [%r670+2056]; + fma.rn.f32 %r676, %r1316, %r675, %r674; + ld.shared.b32 %r677, [%r670+2060]; + fma.rn.f32 %r678, %r1315, %r677, %r676; + ld.shared.b32 %r679, [%r670+2064]; + fma.rn.f32 %r680, %r1314, %r679, %r678; + ld.shared.b32 %r681, [%r670+2068]; + fma.rn.f32 %r682, %r1313, %r681, %r680; + ld.shared.b32 %r683, [%r670+2072]; + fma.rn.f32 %r684, %r1312, %r683, %r682; + ld.shared.b32 %r685, [%r670+2076]; + fma.rn.f32 %r686, %r1311, %r685, %r684; + ld.shared.b32 %r687, [%r670+2080]; + fma.rn.f32 %r688, %r1310, %r687, %r686; + ld.shared.b32 %r689, [%r670+2084]; + fma.rn.f32 %r690, %r1309, %r689, %r688; + ld.shared.b32 %r691, [%r670+2088]; + fma.rn.f32 %r692, %r1308, %r691, %r690; + ld.shared.b32 %r693, [%r670+2092]; + fma.rn.f32 %r694, %r1307, %r693, %r692; + ld.shared.b32 %r695, [%r670+2096]; + fma.rn.f32 %r696, %r1306, %r695, %r694; + ld.shared.b32 %r697, [%r670+2100]; + fma.rn.f32 %r698, %r1305, %r697, %r696; + ld.shared.b32 %r699, [%r670+2104]; + fma.rn.f32 %r700, %r1304, %r699, %r698; + ld.shared.b32 %r701, [%r670+2108]; + fma.rn.f32 %r702, %r1303, %r701, %r700; + ld.shared.b32 %r703, [%r670+2112]; + fma.rn.f32 %r704, %r1302, %r703, %r702; + ld.shared.b32 %r705, [%r670+2116]; + fma.rn.f32 %r706, %r1301, %r705, %r704; + ld.shared.b32 %r707, [%r670+2120]; + fma.rn.f32 %r708, %r1300, %r707, %r706; + ld.shared.b32 %r709, [%r670+2124]; + fma.rn.f32 %r710, %r1299, %r709, %r708; + ld.shared.b32 %r711, [%r670+2128]; + fma.rn.f32 %r712, %r1298, %r711, %r710; + ld.shared.b32 %r713, [%r670+2132]; + fma.rn.f32 %r714, %r1297, %r713, %r712; + ld.shared.b32 %r715, [%r670+2136]; + fma.rn.f32 %r716, %r1296, %r715, %r714; + ld.shared.b32 %r717, [%r670+2140]; + fma.rn.f32 %r718, %r1295, %r717, %r716; + ld.shared.b32 %r719, [%r670+2144]; + fma.rn.f32 %r720, %r1294, %r719, %r718; + ld.shared.b32 %r721, [%r670+2148]; + fma.rn.f32 %r722, %r1293, %r721, %r720; + ld.shared.b32 %r723, [%r670+2152]; + fma.rn.f32 %r724, %r1319, %r723, %r722; + ld.shared.b32 %r725, [%r670+2156]; + fma.rn.f32 %r726, %r1320, %r725, %r724; + ld.shared.b32 %r727, [%r670+2160]; + fma.rn.f32 %r728, %r1321, %r727, %r726; + ld.shared.b32 %r729, [%r670+2164]; + fma.rn.f32 %r730, %r1322, %r729, %r728; + ld.shared.b32 %r731, [%r670+2168]; + fma.rn.f32 %r732, %r1323, %r731, %r730; + ld.shared.b32 %r733, [%r670+2172]; + fma.rn.f32 %r734, %r1324, %r733, %r732; + shl.b32 %r735, %r667, 9; + mov.b32 %r736, _ZZ23draft_commit_gdn_layersE3red; + mov.u32 %r737, %tid.x; + shl.b32 %r738, %r737, 2; + add.s32 %r739, %r736, %r738; + add.s32 %r740, %r739, %r735; + st.shared.b32 [%r740], %r734; + bar.sync 0; + ld.shared.b32 %r741, [%r739]; + ld.shared.b32 %r742, [%r739+512]; + add.f32 %r743, %r741, %r742; + ld.shared.b32 %r744, [%r739+1024]; + add.f32 %r745, %r743, %r744; + ld.shared.b32 %r746, [%r739+1536]; + add.f32 %r747, %r745, %r746; + mul.f32 %r748, %r747, %r1282; + sub.f32 %r749, %r1281, %r748; + mul.f32 %r750, %r1283, %r749; + ld.shared.b32 %r751, [%r670+2048]; + mul.f32 %r752, %r750, %r751; + fma.rn.f32 %r1318, %r1282, %r1318, %r752; + ld.shared.b32 %r753, [%r670+2052]; + mul.f32 %r754, %r750, %r753; + fma.rn.f32 %r1317, %r1282, %r1317, %r754; + ld.shared.b32 %r755, [%r670+2056]; + mul.f32 %r756, %r750, %r755; + fma.rn.f32 %r1316, %r1282, %r1316, %r756; + ld.shared.b32 %r757, [%r670+2060]; + mul.f32 %r758, %r750, %r757; + fma.rn.f32 %r1315, %r1282, %r1315, %r758; + ld.shared.b32 %r759, [%r670+2064]; + mul.f32 %r760, %r750, %r759; + fma.rn.f32 %r1314, %r1282, %r1314, %r760; + ld.shared.b32 %r761, [%r670+2068]; + mul.f32 %r762, %r750, %r761; + fma.rn.f32 %r1313, %r1282, %r1313, %r762; + ld.shared.b32 %r763, [%r670+2072]; + mul.f32 %r764, %r750, %r763; + fma.rn.f32 %r1312, %r1282, %r1312, %r764; + ld.shared.b32 %r765, [%r670+2076]; + mul.f32 %r766, %r750, %r765; + fma.rn.f32 %r1311, %r1282, %r1311, %r766; + ld.shared.b32 %r767, [%r670+2080]; + mul.f32 %r768, %r750, %r767; + fma.rn.f32 %r1310, %r1282, %r1310, %r768; + ld.shared.b32 %r769, [%r670+2084]; + mul.f32 %r770, %r750, %r769; + fma.rn.f32 %r1309, %r1282, %r1309, %r770; + ld.shared.b32 %r771, [%r670+2088]; + mul.f32 %r772, %r750, %r771; + fma.rn.f32 %r1308, %r1282, %r1308, %r772; + ld.shared.b32 %r773, [%r670+2092]; + mul.f32 %r774, %r750, %r773; + fma.rn.f32 %r1307, %r1282, %r1307, %r774; + ld.shared.b32 %r775, [%r670+2096]; + mul.f32 %r776, %r750, %r775; + fma.rn.f32 %r1306, %r1282, %r1306, %r776; + ld.shared.b32 %r777, [%r670+2100]; + mul.f32 %r778, %r750, %r777; + fma.rn.f32 %r1305, %r1282, %r1305, %r778; + ld.shared.b32 %r779, [%r670+2104]; + mul.f32 %r780, %r750, %r779; + fma.rn.f32 %r1304, %r1282, %r1304, %r780; + ld.shared.b32 %r781, [%r670+2108]; + mul.f32 %r782, %r750, %r781; + fma.rn.f32 %r1303, %r1282, %r1303, %r782; + ld.shared.b32 %r783, [%r670+2112]; + mul.f32 %r784, %r750, %r783; + fma.rn.f32 %r1302, %r1282, %r1302, %r784; + ld.shared.b32 %r785, [%r670+2116]; + mul.f32 %r786, %r750, %r785; + fma.rn.f32 %r1301, %r1282, %r1301, %r786; + ld.shared.b32 %r787, [%r670+2120]; + mul.f32 %r788, %r750, %r787; + fma.rn.f32 %r1300, %r1282, %r1300, %r788; + ld.shared.b32 %r789, [%r670+2124]; + mul.f32 %r790, %r750, %r789; + fma.rn.f32 %r1299, %r1282, %r1299, %r790; + ld.shared.b32 %r791, [%r670+2128]; + mul.f32 %r792, %r750, %r791; + fma.rn.f32 %r1298, %r1282, %r1298, %r792; + ld.shared.b32 %r793, [%r670+2132]; + mul.f32 %r794, %r750, %r793; + fma.rn.f32 %r1297, %r1282, %r1297, %r794; + ld.shared.b32 %r795, [%r670+2136]; + mul.f32 %r796, %r750, %r795; + fma.rn.f32 %r1296, %r1282, %r1296, %r796; + ld.shared.b32 %r797, [%r670+2140]; + mul.f32 %r798, %r750, %r797; + fma.rn.f32 %r1295, %r1282, %r1295, %r798; + ld.shared.b32 %r799, [%r670+2144]; + mul.f32 %r800, %r750, %r799; + fma.rn.f32 %r1294, %r1282, %r1294, %r800; + ld.shared.b32 %r801, [%r670+2148]; + mul.f32 %r802, %r750, %r801; + fma.rn.f32 %r1293, %r1282, %r1293, %r802; + ld.shared.b32 %r803, [%r670+2152]; + mul.f32 %r804, %r750, %r803; + fma.rn.f32 %r1319, %r1282, %r1319, %r804; + ld.shared.b32 %r805, [%r670+2156]; + mul.f32 %r806, %r750, %r805; + fma.rn.f32 %r1320, %r1282, %r1320, %r806; + ld.shared.b32 %r807, [%r670+2160]; + mul.f32 %r808, %r750, %r807; + fma.rn.f32 %r1321, %r1282, %r1321, %r808; + ld.shared.b32 %r809, [%r670+2164]; + mul.f32 %r810, %r750, %r809; + fma.rn.f32 %r1322, %r1282, %r1322, %r810; + ld.shared.b32 %r811, [%r670+2168]; + mul.f32 %r812, %r750, %r811; + fma.rn.f32 %r1323, %r1282, %r1323, %r812; + ld.shared.b32 %r813, [%r670+2172]; + mul.f32 %r814, %r750, %r813; + fma.rn.f32 %r1324, %r1282, %r1324, %r814; +$L__BB0_48: + setp.lt.u32 %p22, %r2, 6; + @%p22 bra $L__BB0_50; + mov.u32 %r815, %tid.y; + shl.b32 %r816, %r815, 7; + mov.b32 %r817, _ZZ23draft_commit_gdn_layersE2sk; + add.s32 %r818, %r817, %r816; + ld.shared.b32 %r819, [%r818+2560]; + fma.rn.f32 %r820, %r1318, %r819, 0f00000000; + ld.shared.b32 %r821, [%r818+2564]; + fma.rn.f32 %r822, %r1317, %r821, %r820; + ld.shared.b32 %r823, [%r818+2568]; + fma.rn.f32 %r824, %r1316, %r823, %r822; + ld.shared.b32 %r825, [%r818+2572]; + fma.rn.f32 %r826, %r1315, %r825, %r824; + ld.shared.b32 %r827, [%r818+2576]; + fma.rn.f32 %r828, %r1314, %r827, %r826; + ld.shared.b32 %r829, [%r818+2580]; + fma.rn.f32 %r830, %r1313, %r829, %r828; + ld.shared.b32 %r831, [%r818+2584]; + fma.rn.f32 %r832, %r1312, %r831, %r830; + ld.shared.b32 %r833, [%r818+2588]; + fma.rn.f32 %r834, %r1311, %r833, %r832; + ld.shared.b32 %r835, [%r818+2592]; + fma.rn.f32 %r836, %r1310, %r835, %r834; + ld.shared.b32 %r837, [%r818+2596]; + fma.rn.f32 %r838, %r1309, %r837, %r836; + ld.shared.b32 %r839, [%r818+2600]; + fma.rn.f32 %r840, %r1308, %r839, %r838; + ld.shared.b32 %r841, [%r818+2604]; + fma.rn.f32 %r842, %r1307, %r841, %r840; + ld.shared.b32 %r843, [%r818+2608]; + fma.rn.f32 %r844, %r1306, %r843, %r842; + ld.shared.b32 %r845, [%r818+2612]; + fma.rn.f32 %r846, %r1305, %r845, %r844; + ld.shared.b32 %r847, [%r818+2616]; + fma.rn.f32 %r848, %r1304, %r847, %r846; + ld.shared.b32 %r849, [%r818+2620]; + fma.rn.f32 %r850, %r1303, %r849, %r848; + ld.shared.b32 %r851, [%r818+2624]; + fma.rn.f32 %r852, %r1302, %r851, %r850; + ld.shared.b32 %r853, [%r818+2628]; + fma.rn.f32 %r854, %r1301, %r853, %r852; + ld.shared.b32 %r855, [%r818+2632]; + fma.rn.f32 %r856, %r1300, %r855, %r854; + ld.shared.b32 %r857, [%r818+2636]; + fma.rn.f32 %r858, %r1299, %r857, %r856; + ld.shared.b32 %r859, [%r818+2640]; + fma.rn.f32 %r860, %r1298, %r859, %r858; + ld.shared.b32 %r861, [%r818+2644]; + fma.rn.f32 %r862, %r1297, %r861, %r860; + ld.shared.b32 %r863, [%r818+2648]; + fma.rn.f32 %r864, %r1296, %r863, %r862; + ld.shared.b32 %r865, [%r818+2652]; + fma.rn.f32 %r866, %r1295, %r865, %r864; + ld.shared.b32 %r867, [%r818+2656]; + fma.rn.f32 %r868, %r1294, %r867, %r866; + ld.shared.b32 %r869, [%r818+2660]; + fma.rn.f32 %r870, %r1293, %r869, %r868; + ld.shared.b32 %r871, [%r818+2664]; + fma.rn.f32 %r872, %r1319, %r871, %r870; + ld.shared.b32 %r873, [%r818+2668]; + fma.rn.f32 %r874, %r1320, %r873, %r872; + ld.shared.b32 %r875, [%r818+2672]; + fma.rn.f32 %r876, %r1321, %r875, %r874; + ld.shared.b32 %r877, [%r818+2676]; + fma.rn.f32 %r878, %r1322, %r877, %r876; + ld.shared.b32 %r879, [%r818+2680]; + fma.rn.f32 %r880, %r1323, %r879, %r878; + ld.shared.b32 %r881, [%r818+2684]; + fma.rn.f32 %r882, %r1324, %r881, %r880; + shl.b32 %r883, %r815, 9; + mov.b32 %r884, _ZZ23draft_commit_gdn_layersE3red; + mov.u32 %r885, %tid.x; + shl.b32 %r886, %r885, 2; + add.s32 %r887, %r884, %r886; + add.s32 %r888, %r887, %r883; + st.shared.b32 [%r888+2048], %r882; + bar.sync 0; + ld.shared.b32 %r889, [%r887+2048]; + ld.shared.b32 %r890, [%r887+2560]; + add.f32 %r891, %r889, %r890; + ld.shared.b32 %r892, [%r887+3072]; + add.f32 %r893, %r891, %r892; + ld.shared.b32 %r894, [%r887+3584]; + add.f32 %r895, %r893, %r894; + mul.f32 %r896, %r895, %r1285; + sub.f32 %r897, %r1284, %r896; + mul.f32 %r898, %r1286, %r897; + ld.shared.b32 %r899, [%r818+2560]; + mul.f32 %r900, %r898, %r899; + fma.rn.f32 %r1318, %r1285, %r1318, %r900; + ld.shared.b32 %r901, [%r818+2564]; + mul.f32 %r902, %r898, %r901; + fma.rn.f32 %r1317, %r1285, %r1317, %r902; + ld.shared.b32 %r903, [%r818+2568]; + mul.f32 %r904, %r898, %r903; + fma.rn.f32 %r1316, %r1285, %r1316, %r904; + ld.shared.b32 %r905, [%r818+2572]; + mul.f32 %r906, %r898, %r905; + fma.rn.f32 %r1315, %r1285, %r1315, %r906; + ld.shared.b32 %r907, [%r818+2576]; + mul.f32 %r908, %r898, %r907; + fma.rn.f32 %r1314, %r1285, %r1314, %r908; + ld.shared.b32 %r909, [%r818+2580]; + mul.f32 %r910, %r898, %r909; + fma.rn.f32 %r1313, %r1285, %r1313, %r910; + ld.shared.b32 %r911, [%r818+2584]; + mul.f32 %r912, %r898, %r911; + fma.rn.f32 %r1312, %r1285, %r1312, %r912; + ld.shared.b32 %r913, [%r818+2588]; + mul.f32 %r914, %r898, %r913; + fma.rn.f32 %r1311, %r1285, %r1311, %r914; + ld.shared.b32 %r915, [%r818+2592]; + mul.f32 %r916, %r898, %r915; + fma.rn.f32 %r1310, %r1285, %r1310, %r916; + ld.shared.b32 %r917, [%r818+2596]; + mul.f32 %r918, %r898, %r917; + fma.rn.f32 %r1309, %r1285, %r1309, %r918; + ld.shared.b32 %r919, [%r818+2600]; + mul.f32 %r920, %r898, %r919; + fma.rn.f32 %r1308, %r1285, %r1308, %r920; + ld.shared.b32 %r921, [%r818+2604]; + mul.f32 %r922, %r898, %r921; + fma.rn.f32 %r1307, %r1285, %r1307, %r922; + ld.shared.b32 %r923, [%r818+2608]; + mul.f32 %r924, %r898, %r923; + fma.rn.f32 %r1306, %r1285, %r1306, %r924; + ld.shared.b32 %r925, [%r818+2612]; + mul.f32 %r926, %r898, %r925; + fma.rn.f32 %r1305, %r1285, %r1305, %r926; + ld.shared.b32 %r927, [%r818+2616]; + mul.f32 %r928, %r898, %r927; + fma.rn.f32 %r1304, %r1285, %r1304, %r928; + ld.shared.b32 %r929, [%r818+2620]; + mul.f32 %r930, %r898, %r929; + fma.rn.f32 %r1303, %r1285, %r1303, %r930; + ld.shared.b32 %r931, [%r818+2624]; + mul.f32 %r932, %r898, %r931; + fma.rn.f32 %r1302, %r1285, %r1302, %r932; + ld.shared.b32 %r933, [%r818+2628]; + mul.f32 %r934, %r898, %r933; + fma.rn.f32 %r1301, %r1285, %r1301, %r934; + ld.shared.b32 %r935, [%r818+2632]; + mul.f32 %r936, %r898, %r935; + fma.rn.f32 %r1300, %r1285, %r1300, %r936; + ld.shared.b32 %r937, [%r818+2636]; + mul.f32 %r938, %r898, %r937; + fma.rn.f32 %r1299, %r1285, %r1299, %r938; + ld.shared.b32 %r939, [%r818+2640]; + mul.f32 %r940, %r898, %r939; + fma.rn.f32 %r1298, %r1285, %r1298, %r940; + ld.shared.b32 %r941, [%r818+2644]; + mul.f32 %r942, %r898, %r941; + fma.rn.f32 %r1297, %r1285, %r1297, %r942; + ld.shared.b32 %r943, [%r818+2648]; + mul.f32 %r944, %r898, %r943; + fma.rn.f32 %r1296, %r1285, %r1296, %r944; + ld.shared.b32 %r945, [%r818+2652]; + mul.f32 %r946, %r898, %r945; + fma.rn.f32 %r1295, %r1285, %r1295, %r946; + ld.shared.b32 %r947, [%r818+2656]; + mul.f32 %r948, %r898, %r947; + fma.rn.f32 %r1294, %r1285, %r1294, %r948; + ld.shared.b32 %r949, [%r818+2660]; + mul.f32 %r950, %r898, %r949; + fma.rn.f32 %r1293, %r1285, %r1293, %r950; + ld.shared.b32 %r951, [%r818+2664]; + mul.f32 %r952, %r898, %r951; + fma.rn.f32 %r1319, %r1285, %r1319, %r952; + ld.shared.b32 %r953, [%r818+2668]; + mul.f32 %r954, %r898, %r953; + fma.rn.f32 %r1320, %r1285, %r1320, %r954; + ld.shared.b32 %r955, [%r818+2672]; + mul.f32 %r956, %r898, %r955; + fma.rn.f32 %r1321, %r1285, %r1321, %r956; + ld.shared.b32 %r957, [%r818+2676]; + mul.f32 %r958, %r898, %r957; + fma.rn.f32 %r1322, %r1285, %r1322, %r958; + ld.shared.b32 %r959, [%r818+2680]; + mul.f32 %r960, %r898, %r959; + fma.rn.f32 %r1323, %r1285, %r1323, %r960; + ld.shared.b32 %r961, [%r818+2684]; + mul.f32 %r962, %r898, %r961; + fma.rn.f32 %r1324, %r1285, %r1324, %r962; +$L__BB0_50: + setp.lt.u32 %p23, %r2, 7; + @%p23 bra $L__BB0_52; + mov.u32 %r963, %tid.y; + shl.b32 %r964, %r963, 7; + mov.b32 %r965, _ZZ23draft_commit_gdn_layersE2sk; + add.s32 %r966, %r965, %r964; + ld.shared.b32 %r967, [%r966+3072]; + fma.rn.f32 %r968, %r1318, %r967, 0f00000000; + ld.shared.b32 %r969, [%r966+3076]; + fma.rn.f32 %r970, %r1317, %r969, %r968; + ld.shared.b32 %r971, [%r966+3080]; + fma.rn.f32 %r972, %r1316, %r971, %r970; + ld.shared.b32 %r973, [%r966+3084]; + fma.rn.f32 %r974, %r1315, %r973, %r972; + ld.shared.b32 %r975, [%r966+3088]; + fma.rn.f32 %r976, %r1314, %r975, %r974; + ld.shared.b32 %r977, [%r966+3092]; + fma.rn.f32 %r978, %r1313, %r977, %r976; + ld.shared.b32 %r979, [%r966+3096]; + fma.rn.f32 %r980, %r1312, %r979, %r978; + ld.shared.b32 %r981, [%r966+3100]; + fma.rn.f32 %r982, %r1311, %r981, %r980; + ld.shared.b32 %r983, [%r966+3104]; + fma.rn.f32 %r984, %r1310, %r983, %r982; + ld.shared.b32 %r985, [%r966+3108]; + fma.rn.f32 %r986, %r1309, %r985, %r984; + ld.shared.b32 %r987, [%r966+3112]; + fma.rn.f32 %r988, %r1308, %r987, %r986; + ld.shared.b32 %r989, [%r966+3116]; + fma.rn.f32 %r990, %r1307, %r989, %r988; + ld.shared.b32 %r991, [%r966+3120]; + fma.rn.f32 %r992, %r1306, %r991, %r990; + ld.shared.b32 %r993, [%r966+3124]; + fma.rn.f32 %r994, %r1305, %r993, %r992; + ld.shared.b32 %r995, [%r966+3128]; + fma.rn.f32 %r996, %r1304, %r995, %r994; + ld.shared.b32 %r997, [%r966+3132]; + fma.rn.f32 %r998, %r1303, %r997, %r996; + ld.shared.b32 %r999, [%r966+3136]; + fma.rn.f32 %r1000, %r1302, %r999, %r998; + ld.shared.b32 %r1001, [%r966+3140]; + fma.rn.f32 %r1002, %r1301, %r1001, %r1000; + ld.shared.b32 %r1003, [%r966+3144]; + fma.rn.f32 %r1004, %r1300, %r1003, %r1002; + ld.shared.b32 %r1005, [%r966+3148]; + fma.rn.f32 %r1006, %r1299, %r1005, %r1004; + ld.shared.b32 %r1007, [%r966+3152]; + fma.rn.f32 %r1008, %r1298, %r1007, %r1006; + ld.shared.b32 %r1009, [%r966+3156]; + fma.rn.f32 %r1010, %r1297, %r1009, %r1008; + ld.shared.b32 %r1011, [%r966+3160]; + fma.rn.f32 %r1012, %r1296, %r1011, %r1010; + ld.shared.b32 %r1013, [%r966+3164]; + fma.rn.f32 %r1014, %r1295, %r1013, %r1012; + ld.shared.b32 %r1015, [%r966+3168]; + fma.rn.f32 %r1016, %r1294, %r1015, %r1014; + ld.shared.b32 %r1017, [%r966+3172]; + fma.rn.f32 %r1018, %r1293, %r1017, %r1016; + ld.shared.b32 %r1019, [%r966+3176]; + fma.rn.f32 %r1020, %r1319, %r1019, %r1018; + ld.shared.b32 %r1021, [%r966+3180]; + fma.rn.f32 %r1022, %r1320, %r1021, %r1020; + ld.shared.b32 %r1023, [%r966+3184]; + fma.rn.f32 %r1024, %r1321, %r1023, %r1022; + ld.shared.b32 %r1025, [%r966+3188]; + fma.rn.f32 %r1026, %r1322, %r1025, %r1024; + ld.shared.b32 %r1027, [%r966+3192]; + fma.rn.f32 %r1028, %r1323, %r1027, %r1026; + ld.shared.b32 %r1029, [%r966+3196]; + fma.rn.f32 %r1030, %r1324, %r1029, %r1028; + shl.b32 %r1031, %r963, 9; + mov.b32 %r1032, _ZZ23draft_commit_gdn_layersE3red; + mov.u32 %r1033, %tid.x; + shl.b32 %r1034, %r1033, 2; + add.s32 %r1035, %r1032, %r1034; + add.s32 %r1036, %r1035, %r1031; + st.shared.b32 [%r1036], %r1030; + bar.sync 0; + ld.shared.b32 %r1037, [%r1035]; + ld.shared.b32 %r1038, [%r1035+512]; + add.f32 %r1039, %r1037, %r1038; + ld.shared.b32 %r1040, [%r1035+1024]; + add.f32 %r1041, %r1039, %r1040; + ld.shared.b32 %r1042, [%r1035+1536]; + add.f32 %r1043, %r1041, %r1042; + mul.f32 %r1044, %r1043, %r1288; + sub.f32 %r1045, %r1287, %r1044; + mul.f32 %r1046, %r1289, %r1045; + ld.shared.b32 %r1047, [%r966+3072]; + mul.f32 %r1048, %r1046, %r1047; + fma.rn.f32 %r1318, %r1288, %r1318, %r1048; + ld.shared.b32 %r1049, [%r966+3076]; + mul.f32 %r1050, %r1046, %r1049; + fma.rn.f32 %r1317, %r1288, %r1317, %r1050; + ld.shared.b32 %r1051, [%r966+3080]; + mul.f32 %r1052, %r1046, %r1051; + fma.rn.f32 %r1316, %r1288, %r1316, %r1052; + ld.shared.b32 %r1053, [%r966+3084]; + mul.f32 %r1054, %r1046, %r1053; + fma.rn.f32 %r1315, %r1288, %r1315, %r1054; + ld.shared.b32 %r1055, [%r966+3088]; + mul.f32 %r1056, %r1046, %r1055; + fma.rn.f32 %r1314, %r1288, %r1314, %r1056; + ld.shared.b32 %r1057, [%r966+3092]; + mul.f32 %r1058, %r1046, %r1057; + fma.rn.f32 %r1313, %r1288, %r1313, %r1058; + ld.shared.b32 %r1059, [%r966+3096]; + mul.f32 %r1060, %r1046, %r1059; + fma.rn.f32 %r1312, %r1288, %r1312, %r1060; + ld.shared.b32 %r1061, [%r966+3100]; + mul.f32 %r1062, %r1046, %r1061; + fma.rn.f32 %r1311, %r1288, %r1311, %r1062; + ld.shared.b32 %r1063, [%r966+3104]; + mul.f32 %r1064, %r1046, %r1063; + fma.rn.f32 %r1310, %r1288, %r1310, %r1064; + ld.shared.b32 %r1065, [%r966+3108]; + mul.f32 %r1066, %r1046, %r1065; + fma.rn.f32 %r1309, %r1288, %r1309, %r1066; + ld.shared.b32 %r1067, [%r966+3112]; + mul.f32 %r1068, %r1046, %r1067; + fma.rn.f32 %r1308, %r1288, %r1308, %r1068; + ld.shared.b32 %r1069, [%r966+3116]; + mul.f32 %r1070, %r1046, %r1069; + fma.rn.f32 %r1307, %r1288, %r1307, %r1070; + ld.shared.b32 %r1071, [%r966+3120]; + mul.f32 %r1072, %r1046, %r1071; + fma.rn.f32 %r1306, %r1288, %r1306, %r1072; + ld.shared.b32 %r1073, [%r966+3124]; + mul.f32 %r1074, %r1046, %r1073; + fma.rn.f32 %r1305, %r1288, %r1305, %r1074; + ld.shared.b32 %r1075, [%r966+3128]; + mul.f32 %r1076, %r1046, %r1075; + fma.rn.f32 %r1304, %r1288, %r1304, %r1076; + ld.shared.b32 %r1077, [%r966+3132]; + mul.f32 %r1078, %r1046, %r1077; + fma.rn.f32 %r1303, %r1288, %r1303, %r1078; + ld.shared.b32 %r1079, [%r966+3136]; + mul.f32 %r1080, %r1046, %r1079; + fma.rn.f32 %r1302, %r1288, %r1302, %r1080; + ld.shared.b32 %r1081, [%r966+3140]; + mul.f32 %r1082, %r1046, %r1081; + fma.rn.f32 %r1301, %r1288, %r1301, %r1082; + ld.shared.b32 %r1083, [%r966+3144]; + mul.f32 %r1084, %r1046, %r1083; + fma.rn.f32 %r1300, %r1288, %r1300, %r1084; + ld.shared.b32 %r1085, [%r966+3148]; + mul.f32 %r1086, %r1046, %r1085; + fma.rn.f32 %r1299, %r1288, %r1299, %r1086; + ld.shared.b32 %r1087, [%r966+3152]; + mul.f32 %r1088, %r1046, %r1087; + fma.rn.f32 %r1298, %r1288, %r1298, %r1088; + ld.shared.b32 %r1089, [%r966+3156]; + mul.f32 %r1090, %r1046, %r1089; + fma.rn.f32 %r1297, %r1288, %r1297, %r1090; + ld.shared.b32 %r1091, [%r966+3160]; + mul.f32 %r1092, %r1046, %r1091; + fma.rn.f32 %r1296, %r1288, %r1296, %r1092; + ld.shared.b32 %r1093, [%r966+3164]; + mul.f32 %r1094, %r1046, %r1093; + fma.rn.f32 %r1295, %r1288, %r1295, %r1094; + ld.shared.b32 %r1095, [%r966+3168]; + mul.f32 %r1096, %r1046, %r1095; + fma.rn.f32 %r1294, %r1288, %r1294, %r1096; + ld.shared.b32 %r1097, [%r966+3172]; + mul.f32 %r1098, %r1046, %r1097; + fma.rn.f32 %r1293, %r1288, %r1293, %r1098; + ld.shared.b32 %r1099, [%r966+3176]; + mul.f32 %r1100, %r1046, %r1099; + fma.rn.f32 %r1319, %r1288, %r1319, %r1100; + ld.shared.b32 %r1101, [%r966+3180]; + mul.f32 %r1102, %r1046, %r1101; + fma.rn.f32 %r1320, %r1288, %r1320, %r1102; + ld.shared.b32 %r1103, [%r966+3184]; + mul.f32 %r1104, %r1046, %r1103; + fma.rn.f32 %r1321, %r1288, %r1321, %r1104; + ld.shared.b32 %r1105, [%r966+3188]; + mul.f32 %r1106, %r1046, %r1105; + fma.rn.f32 %r1322, %r1288, %r1322, %r1106; + ld.shared.b32 %r1107, [%r966+3192]; + mul.f32 %r1108, %r1046, %r1107; + fma.rn.f32 %r1323, %r1288, %r1323, %r1108; + ld.shared.b32 %r1109, [%r966+3196]; + mul.f32 %r1110, %r1046, %r1109; + fma.rn.f32 %r1324, %r1288, %r1324, %r1110; +$L__BB0_52: + setp.lt.u32 %p24, %r2, 8; + @%p24 bra $L__BB0_54; + mov.u32 %r1111, %tid.y; + shl.b32 %r1112, %r1111, 7; + mov.b32 %r1113, _ZZ23draft_commit_gdn_layersE2sk; + add.s32 %r1114, %r1113, %r1112; + ld.shared.b32 %r1115, [%r1114+3584]; + fma.rn.f32 %r1116, %r1318, %r1115, 0f00000000; + ld.shared.b32 %r1117, [%r1114+3588]; + fma.rn.f32 %r1118, %r1317, %r1117, %r1116; + ld.shared.b32 %r1119, [%r1114+3592]; + fma.rn.f32 %r1120, %r1316, %r1119, %r1118; + ld.shared.b32 %r1121, [%r1114+3596]; + fma.rn.f32 %r1122, %r1315, %r1121, %r1120; + ld.shared.b32 %r1123, [%r1114+3600]; + fma.rn.f32 %r1124, %r1314, %r1123, %r1122; + ld.shared.b32 %r1125, [%r1114+3604]; + fma.rn.f32 %r1126, %r1313, %r1125, %r1124; + ld.shared.b32 %r1127, [%r1114+3608]; + fma.rn.f32 %r1128, %r1312, %r1127, %r1126; + ld.shared.b32 %r1129, [%r1114+3612]; + fma.rn.f32 %r1130, %r1311, %r1129, %r1128; + ld.shared.b32 %r1131, [%r1114+3616]; + fma.rn.f32 %r1132, %r1310, %r1131, %r1130; + ld.shared.b32 %r1133, [%r1114+3620]; + fma.rn.f32 %r1134, %r1309, %r1133, %r1132; + ld.shared.b32 %r1135, [%r1114+3624]; + fma.rn.f32 %r1136, %r1308, %r1135, %r1134; + ld.shared.b32 %r1137, [%r1114+3628]; + fma.rn.f32 %r1138, %r1307, %r1137, %r1136; + ld.shared.b32 %r1139, [%r1114+3632]; + fma.rn.f32 %r1140, %r1306, %r1139, %r1138; + ld.shared.b32 %r1141, [%r1114+3636]; + fma.rn.f32 %r1142, %r1305, %r1141, %r1140; + ld.shared.b32 %r1143, [%r1114+3640]; + fma.rn.f32 %r1144, %r1304, %r1143, %r1142; + ld.shared.b32 %r1145, [%r1114+3644]; + fma.rn.f32 %r1146, %r1303, %r1145, %r1144; + ld.shared.b32 %r1147, [%r1114+3648]; + fma.rn.f32 %r1148, %r1302, %r1147, %r1146; + ld.shared.b32 %r1149, [%r1114+3652]; + fma.rn.f32 %r1150, %r1301, %r1149, %r1148; + ld.shared.b32 %r1151, [%r1114+3656]; + fma.rn.f32 %r1152, %r1300, %r1151, %r1150; + ld.shared.b32 %r1153, [%r1114+3660]; + fma.rn.f32 %r1154, %r1299, %r1153, %r1152; + ld.shared.b32 %r1155, [%r1114+3664]; + fma.rn.f32 %r1156, %r1298, %r1155, %r1154; + ld.shared.b32 %r1157, [%r1114+3668]; + fma.rn.f32 %r1158, %r1297, %r1157, %r1156; + ld.shared.b32 %r1159, [%r1114+3672]; + fma.rn.f32 %r1160, %r1296, %r1159, %r1158; + ld.shared.b32 %r1161, [%r1114+3676]; + fma.rn.f32 %r1162, %r1295, %r1161, %r1160; + ld.shared.b32 %r1163, [%r1114+3680]; + fma.rn.f32 %r1164, %r1294, %r1163, %r1162; + ld.shared.b32 %r1165, [%r1114+3684]; + fma.rn.f32 %r1166, %r1293, %r1165, %r1164; + ld.shared.b32 %r1167, [%r1114+3688]; + fma.rn.f32 %r1168, %r1319, %r1167, %r1166; + ld.shared.b32 %r1169, [%r1114+3692]; + fma.rn.f32 %r1170, %r1320, %r1169, %r1168; + ld.shared.b32 %r1171, [%r1114+3696]; + fma.rn.f32 %r1172, %r1321, %r1171, %r1170; + ld.shared.b32 %r1173, [%r1114+3700]; + fma.rn.f32 %r1174, %r1322, %r1173, %r1172; + ld.shared.b32 %r1175, [%r1114+3704]; + fma.rn.f32 %r1176, %r1323, %r1175, %r1174; + ld.shared.b32 %r1177, [%r1114+3708]; + fma.rn.f32 %r1178, %r1324, %r1177, %r1176; + shl.b32 %r1179, %r1111, 9; + mov.b32 %r1180, _ZZ23draft_commit_gdn_layersE3red; + mov.u32 %r1181, %tid.x; + shl.b32 %r1182, %r1181, 2; + add.s32 %r1183, %r1180, %r1182; + add.s32 %r1184, %r1183, %r1179; + st.shared.b32 [%r1184+2048], %r1178; + bar.sync 0; + ld.shared.b32 %r1185, [%r1183+2048]; + ld.shared.b32 %r1186, [%r1183+2560]; + add.f32 %r1187, %r1185, %r1186; + ld.shared.b32 %r1188, [%r1183+3072]; + add.f32 %r1189, %r1187, %r1188; + ld.shared.b32 %r1190, [%r1183+3584]; + add.f32 %r1191, %r1189, %r1190; + mul.f32 %r1192, %r1191, %r1291; + sub.f32 %r1193, %r1290, %r1192; + mul.f32 %r1194, %r1292, %r1193; + ld.shared.b32 %r1195, [%r1114+3584]; + mul.f32 %r1196, %r1194, %r1195; + fma.rn.f32 %r1318, %r1291, %r1318, %r1196; + ld.shared.b32 %r1197, [%r1114+3588]; + mul.f32 %r1198, %r1194, %r1197; + fma.rn.f32 %r1317, %r1291, %r1317, %r1198; + ld.shared.b32 %r1199, [%r1114+3592]; + mul.f32 %r1200, %r1194, %r1199; + fma.rn.f32 %r1316, %r1291, %r1316, %r1200; + ld.shared.b32 %r1201, [%r1114+3596]; + mul.f32 %r1202, %r1194, %r1201; + fma.rn.f32 %r1315, %r1291, %r1315, %r1202; + ld.shared.b32 %r1203, [%r1114+3600]; + mul.f32 %r1204, %r1194, %r1203; + fma.rn.f32 %r1314, %r1291, %r1314, %r1204; + ld.shared.b32 %r1205, [%r1114+3604]; + mul.f32 %r1206, %r1194, %r1205; + fma.rn.f32 %r1313, %r1291, %r1313, %r1206; + ld.shared.b32 %r1207, [%r1114+3608]; + mul.f32 %r1208, %r1194, %r1207; + fma.rn.f32 %r1312, %r1291, %r1312, %r1208; + ld.shared.b32 %r1209, [%r1114+3612]; + mul.f32 %r1210, %r1194, %r1209; + fma.rn.f32 %r1311, %r1291, %r1311, %r1210; + ld.shared.b32 %r1211, [%r1114+3616]; + mul.f32 %r1212, %r1194, %r1211; + fma.rn.f32 %r1310, %r1291, %r1310, %r1212; + ld.shared.b32 %r1213, [%r1114+3620]; + mul.f32 %r1214, %r1194, %r1213; + fma.rn.f32 %r1309, %r1291, %r1309, %r1214; + ld.shared.b32 %r1215, [%r1114+3624]; + mul.f32 %r1216, %r1194, %r1215; + fma.rn.f32 %r1308, %r1291, %r1308, %r1216; + ld.shared.b32 %r1217, [%r1114+3628]; + mul.f32 %r1218, %r1194, %r1217; + fma.rn.f32 %r1307, %r1291, %r1307, %r1218; + ld.shared.b32 %r1219, [%r1114+3632]; + mul.f32 %r1220, %r1194, %r1219; + fma.rn.f32 %r1306, %r1291, %r1306, %r1220; + ld.shared.b32 %r1221, [%r1114+3636]; + mul.f32 %r1222, %r1194, %r1221; + fma.rn.f32 %r1305, %r1291, %r1305, %r1222; + ld.shared.b32 %r1223, [%r1114+3640]; + mul.f32 %r1224, %r1194, %r1223; + fma.rn.f32 %r1304, %r1291, %r1304, %r1224; + ld.shared.b32 %r1225, [%r1114+3644]; + mul.f32 %r1226, %r1194, %r1225; + fma.rn.f32 %r1303, %r1291, %r1303, %r1226; + ld.shared.b32 %r1227, [%r1114+3648]; + mul.f32 %r1228, %r1194, %r1227; + fma.rn.f32 %r1302, %r1291, %r1302, %r1228; + ld.shared.b32 %r1229, [%r1114+3652]; + mul.f32 %r1230, %r1194, %r1229; + fma.rn.f32 %r1301, %r1291, %r1301, %r1230; + ld.shared.b32 %r1231, [%r1114+3656]; + mul.f32 %r1232, %r1194, %r1231; + fma.rn.f32 %r1300, %r1291, %r1300, %r1232; + ld.shared.b32 %r1233, [%r1114+3660]; + mul.f32 %r1234, %r1194, %r1233; + fma.rn.f32 %r1299, %r1291, %r1299, %r1234; + ld.shared.b32 %r1235, [%r1114+3664]; + mul.f32 %r1236, %r1194, %r1235; + fma.rn.f32 %r1298, %r1291, %r1298, %r1236; + ld.shared.b32 %r1237, [%r1114+3668]; + mul.f32 %r1238, %r1194, %r1237; + fma.rn.f32 %r1297, %r1291, %r1297, %r1238; + ld.shared.b32 %r1239, [%r1114+3672]; + mul.f32 %r1240, %r1194, %r1239; + fma.rn.f32 %r1296, %r1291, %r1296, %r1240; + ld.shared.b32 %r1241, [%r1114+3676]; + mul.f32 %r1242, %r1194, %r1241; + fma.rn.f32 %r1295, %r1291, %r1295, %r1242; + ld.shared.b32 %r1243, [%r1114+3680]; + mul.f32 %r1244, %r1194, %r1243; + fma.rn.f32 %r1294, %r1291, %r1294, %r1244; + ld.shared.b32 %r1245, [%r1114+3684]; + mul.f32 %r1246, %r1194, %r1245; + fma.rn.f32 %r1293, %r1291, %r1293, %r1246; + ld.shared.b32 %r1247, [%r1114+3688]; + mul.f32 %r1248, %r1194, %r1247; + fma.rn.f32 %r1319, %r1291, %r1319, %r1248; + ld.shared.b32 %r1249, [%r1114+3692]; + mul.f32 %r1250, %r1194, %r1249; + fma.rn.f32 %r1320, %r1291, %r1320, %r1250; + ld.shared.b32 %r1251, [%r1114+3696]; + mul.f32 %r1252, %r1194, %r1251; + fma.rn.f32 %r1321, %r1291, %r1321, %r1252; + ld.shared.b32 %r1253, [%r1114+3700]; + mul.f32 %r1254, %r1194, %r1253; + fma.rn.f32 %r1322, %r1291, %r1322, %r1254; + ld.shared.b32 %r1255, [%r1114+3704]; + mul.f32 %r1256, %r1194, %r1255; + fma.rn.f32 %r1323, %r1291, %r1323, %r1256; + ld.shared.b32 %r1257, [%r1114+3708]; + mul.f32 %r1258, %r1194, %r1257; + fma.rn.f32 %r1324, %r1291, %r1324, %r1258; +$L__BB0_54: + st.b32 [%rd16], %r1318; + st.b32 [%rd16+24576], %r1317; + st.b32 [%rd16+49152], %r1316; + st.b32 [%rd16+73728], %r1315; + st.b32 [%rd16+98304], %r1314; + st.b32 [%rd16+122880], %r1313; + st.b32 [%rd16+147456], %r1312; + st.b32 [%rd16+172032], %r1311; + st.b32 [%rd16+196608], %r1310; + st.b32 [%rd16+221184], %r1309; + st.b32 [%rd16+245760], %r1308; + st.b32 [%rd16+270336], %r1307; + st.b32 [%rd16+294912], %r1306; + st.b32 [%rd16+319488], %r1305; + st.b32 [%rd16+344064], %r1304; + st.b32 [%rd16+368640], %r1303; + st.b32 [%rd16+393216], %r1302; + st.b32 [%rd16+417792], %r1301; + st.b32 [%rd16+442368], %r1300; + st.b32 [%rd16+466944], %r1299; + st.b32 [%rd16+491520], %r1298; + st.b32 [%rd16+516096], %r1297; + st.b32 [%rd16+540672], %r1296; + st.b32 [%rd16+565248], %r1295; + st.b32 [%rd16+589824], %r1294; + st.b32 [%rd16+614400], %r1293; + st.b32 [%rd16+638976], %r1319; + st.b32 [%rd16+663552], %r1320; + st.b32 [%rd16+688128], %r1321; + st.b32 [%rd16+712704], %r1322; + st.b32 [%rd16+737280], %r1323; + st.b32 [%rd16+761856], %r1324; +$L__BB0_55: + ret; + +} diff --git a/crates/cuda-driver/src/draft_commit_qsa.cu b/crates/cuda-driver/src/draft_commit_qsa.cu new file mode 100644 index 00000000..423b3798 --- /dev/null +++ b/crates/cuda-driver/src/draft_commit_qsa.cu @@ -0,0 +1,129 @@ +// draft-round: the verifier's accepted-prefix commit graph, QSA layers fused (docs/experiments/draft-round-5090.md). The GDN layers are draft_commit.cu. +// +// The commit graph's QSA part is, for each of the 12 QSA layers, one tail restore copy (verify_copy_from_mapped_kernel) and eight `verify_qsa_append_analytic` launches, one per +// window row (original_verify_qsa.cu). The layers are independent, so one block per layer runs the restore and the eight row appends in order (row r+1 reads what row r +// wrote, as consecutive launches would); each row is a copy of the body of `verify_qsa_append_analytic` (TAB = false). The kernel argument is a by-value struct of u64 words. +// Compile: nvcc --ptx -O3 -arch=sm_120 --fmad=true --use_fast_math (the RESEALED recipe of original_verify_qsa.cu: the Original builds native_qsa_indexer with --use_fast_math, so +// powf / cosf / sinf are __powf / cos.approx / sin.approx and the keys are not those of a precise build; docs/gpu-bringup.md D6). +#include +#include +#include +#include +#include + +constexpr int QSA_LAYERS = 12; +constexpr int S = 128, RG = 4; +constexpr int D = 128, R = 4, ROT = 64, THREADS = 256, MAX_ROWS = 8; + +struct QsaCommitArgs { + uint64_t tail[QSA_LAYERS]; // float* [3 * D] + uint64_t dead[QSA_LAYERS]; // float* [D] + uint64_t pooled[QSA_LAYERS]; // float* [blocks * D] + uint64_t block_pos[QSA_LAYERS]; // int32* + uint64_t gamma[QSA_LAYERS]; // float* [D] + uint64_t raw_base; // idx_raw_L: [12][max_t][128] f32 + uint64_t snap_base; // tail_snap: [12][1536 bytes] + uint64_t commit; // int32: row r position at [2 + r] + uint64_t mtab; // int32 position table or 0 + uint64_t rows; // window rows to append (max_t) + uint64_t max_cells; + uint64_t pos_base; + float epsilon, theta_scale, freq_scale, corr_low; + float corr_high, ext_factor, mscale, pad; +}; + +__device__ float warp_sum(float x) { +#pragma unroll + for (int offset = 16; offset; offset >>= 1) x += __shfl_xor_sync(0xffffffffu, x, offset); + return x; +} +__device__ __forceinline__ int mrope_pos(const int32_t* tab, int pos, int pair) { + return tab ? __ldg(tab + (size_t) pos * 3 + pair % 3) : pos; +} +__host__ __device__ inline float rope_yarn_ramp(float low, float high, int pair) { + const float y = ((float) pair - low) / (high - low > 0.001f ? high - low : 0.001f); + const float clamped = y < 0.0f ? 0.0f : (y > 1.0f ? 1.0f : y); + return 1.0f - clamped; +} +__host__ __device__ inline void rope_scaled_angle(float theta_extrap, float freq_scale, float corr_low, float corr_high, float ext_factor, float mscale_in, + int pair, float& cos_out, float& sin_out) { + float theta = freq_scale * theta_extrap; + float mscale = mscale_in; + if (ext_factor != 0.0f) { + const float ramp_mix = rope_yarn_ramp(corr_low, corr_high, pair) * ext_factor; + theta = theta * (1.0f - ramp_mix) + theta_extrap * ramp_mix; + mscale *= 1.0f + 0.1f * logf(1.0f / freq_scale); + } + cos_out = cosf(theta) * mscale; + sin_out = sinf(theta) * mscale; +} + +// grid (12), block (128, 4) = 512 threads; threads 0..255 are the Original's 256 +extern "C" __global__ void __launch_bounds__(S * RG) draft_commit_qsa_layers(QsaCommitArgs a) { + __shared__ float values[D]; + __shared__ float partials[32]; + const int layer = blockIdx.x; + const int d = threadIdx.y * S + threadIdx.x; + const bool live = d < THREADS; // the Original's block has 256 threads + float* tail = reinterpret_cast(a.tail[layer]); + float* dead = reinterpret_cast(a.dead[layer]); + float* pooled = reinterpret_cast(a.pooled[layer]); + int32_t* block_pos = reinterpret_cast(a.block_pos[layer]); + const float* gamma = reinterpret_cast(a.gamma[layer]); + // tail restore (verify_copy_from_mapped_kernel, 96 float4) + { + const float4* src = reinterpret_cast(a.snap_base + (uint64_t) layer * 1536); + float4* dst = reinterpret_cast(tail); + if (d < 96) dst[d] = const_cast(src)[d]; + } + __syncthreads(); + const int32_t* mtab = reinterpret_cast(a.mtab); + for (int row = 0; row < (int) a.rows; ++row) { + const float* raw = reinterpret_cast(a.raw_base) + ((size_t) layer * a.rows + row) * D; + const int pos = *(reinterpret_cast(a.commit) + 2 + row); + if (pos < 0 || pos >= (int) a.max_cells) continue; // block-uniform + const int slot = pos % R; + float incoming = 0.0f; + if (d < D) { + incoming = __half2float(__float2half_rn(raw[d])); + if (slot < R - 1) tail[slot * D + d] = incoming; + } + if (pos != 0 && slot != R - 1) { __syncthreads(); continue; } // block-uniform; the barrier closes the row for every thread + float mean = 0.0f; + if (d < D) { + float sum = pos == 0 ? incoming : tail[d]; +#pragma unroll + for (int j = 1; j < R; ++j) sum = __fadd_rn(sum, pos == 0 || j == R - 1 ? incoming : tail[j * D + d]); + mean = __fmaf_rn(0.25f, sum, 0.0f); + } + float square_sum = 0.0f; + if (d < D) square_sum += mean * mean; + square_sum = warp_sum(square_sum); + const int lane = d % 32; + if (live && lane == 0) partials[d / 32] = square_sum; + __syncthreads(); + square_sum = lane < THREADS / 32 ? partials[lane] : 0.0f; + square_sum = warp_sum(square_sum); + const float scale = rsqrtf(square_sum / D + a.epsilon); + if (d < D) values[d] = scale * mean * gamma[d]; + __syncthreads(); + if (d < D) { + const int b = pos / R; + const int rope_pos = pos == 0 ? 0 : (int) a.pos_base + R * b; + float y = values[d]; + if (d < ROT) { + const int pair = d % (ROT / 2); + float c, s; + const float theta_extrap = (pos == 0 ? 0 : mrope_pos(mtab, rope_pos, pair)) * powf(a.theta_scale, float(pair)); + rope_scaled_angle(theta_extrap, a.freq_scale, a.corr_low, a.corr_high, a.ext_factor, a.mscale, pair, c, s); + const float av = values[pair], z = values[pair + ROT / 2]; + y = d < ROT / 2 ? av * c - z * s : av * s + z * c; + } + pooled[std::size_t(b) * D + d] = y; + if (pos == 0) dead[d] = y; + else pooled[std::size_t(b + 1) * D + d] = dead[d]; + if (d == 0 && pos != 0) *block_pos = rope_pos; + } + __syncthreads(); // values / partials are reused by the next row + } +} diff --git a/crates/cuda-driver/src/draft_commit_qsa.ptx b/crates/cuda-driver/src/draft_commit_qsa.ptx new file mode 100644 index 00000000..836738f0 --- /dev/null +++ b/crates/cuda-driver/src/draft_commit_qsa.ptx @@ -0,0 +1,317 @@ +// +// Generated by NVIDIA NVVM Compiler +// +// Compiler Build ID: UNKNOWN +// Cuda compilation tools, release 13.2, V13.2.86 +// Based on NVVM 22.0.0 +// + +.version 9.2 +.target sm_120 +.address_size 64 + + // .globl draft_commit_qsa_layers +// _ZZ23draft_commit_qsa_layersE6values has been demoted +// _ZZ23draft_commit_qsa_layersE8partials has been demoted + +.visible .entry draft_commit_qsa_layers( + .param .align 8 .b8 draft_commit_qsa_layers_param_0[568] +) +.maxntid 512 +{ + .reg .pred %p<42>; + .reg .b16 %rs<7>; + .reg .b32 %r<120>; + .reg .b64 %rd<53>; + // demoted variable + .shared .align 4 .b8 _ZZ23draft_commit_qsa_layersE6values[512]; + // demoted variable + .shared .align 4 .b8 _ZZ23draft_commit_qsa_layersE8partials[128]; + mov.b64 %rd1, draft_commit_qsa_layers_param_0; + mov.u32 %r27, %ctaid.x; + mov.u32 %r1, %tid.y; + shl.b32 %r28, %r1, 7; + mov.u32 %r2, %tid.x; + add.s32 %r3, %r28, %r2; + cvt.u64.u32 %rd2, %r27; + mul.wide.u32 %rd16, %r27, 8; + add.s64 %rd17, %rd1, %rd16; + ld.param.b64 %rd18, [%rd17]; + cvta.to.global.u64 %rd3, %rd18; + ld.param.b64 %rd4, [%rd17+96]; + ld.param.b64 %rd5, [%rd17+192]; + ld.param.b64 %rd6, [%rd17+288]; + setp.gt.u32 %p2, %r3, 95; + @%p2 bra $L__BB0_2; + ld.param.b64 %rd19, [%rd1+488]; + mad.lo.s64 %rd20, %rd2, 1536, %rd19; + mul.wide.u32 %rd21, %r3, 16; + add.s64 %rd22, %rd3, %rd21; + add.s64 %rd23, %rd20, %rd21; + ld.v2.b64 {%rd24, %rd25}, [%rd23]; + st.global.v2.b64 [%rd22], {%rd24, %rd25}; +$L__BB0_2: + bar.sync 0; + ld.param.b64 %rd7, [%rd1+512]; + cvt.u32.u64 %r4, %rd7; + setp.lt.s32 %p3, %r4, 1; + @%p3 bra $L__BB0_41; + setp.lt.u32 %p4, %r3, 256; + ld.param.b64 %rd8, [%rd1+504]; + ld.param.b64 %rd26, [%rd1+480]; + cvta.to.global.u64 %rd27, %rd26; + ld.param.b64 %rd28, [%rd1+496]; + cvta.to.global.u64 %rd29, %rd28; + ld.param.b32 %r5, [%rd1+520]; + cvt.u64.u32 %rd9, %r3; + mul.wide.u32 %rd30, %r3, 4; + add.s64 %rd10, %rd3, %rd30; + and.b32 %r6, %r2, 31; + setp.eq.b32 %p5, %r6, 0; + and.pred %p1, %p5, %p4; + ld.param.v2.b32 {%r7, %r8}, [%rd1+536]; + shl.b64 %rd31, %rd2, 3; + add.s64 %rd32, %rd1, %rd31; + ld.param.b64 %rd33, [%rd32+384]; + cvta.to.global.u64 %rd34, %rd33; + add.s64 %rd11, %rd34, %rd30; + ld.param.b32 %r9, [%rd1+528]; + cvt.u16.u32 %rs2, %r6; + mul.lo.s16 %rs3, %rs2, 86; + shr.u16 %rs4, %rs3, 8; + mul.lo.s16 %rs5, %rs4, 3; + sub.s16 %rs1, %rs2, %rs5; + cvt.rn.f32.u32 %r10, %r6; + ld.param.v2.b32 {%r11, %r29}, [%rd1+544]; + ld.param.v2.b32 {%r30, %r12}, [%rd1+552]; + ld.param.b32 %r13, [%rd1+560]; + sub.ftz.f32 %r14, %r10, %r29; + sub.ftz.f32 %r31, %r30, %r29; + max.ftz.f32 %r15, %r31, 0f3A83126F; + rcp.approx.ftz.f32 %r16, %r11; + cvta.to.global.u64 %rd35, %rd4; + add.s64 %rd12, %rd35, %rd30; + neg.s32 %r110, %r4; + add.s64 %rd52, %rd29, 8; + mul.lo.s64 %rd36, %rd7, %rd2; + shl.b64 %rd37, %rd36, 9; + mul.wide.u32 %rd38, %r1, 512; + add.s64 %rd39, %rd37, %rd38; + mul.wide.u32 %rd40, %r2, 4; + add.s64 %rd41, %rd39, %rd40; + add.s64 %rd51, %rd27, %rd41; + cvta.to.global.u64 %rd13, %rd6; + cvta.to.global.u64 %rd14, %rd5; + not.pred %p21, %p1; + lg2.approx.ftz.f32 %r86, %r8; + mul.ftz.f32 %r87, %r86, %r10; + ex2.approx.ftz.f32 %r88, %r87; + div.approx.ftz.f32 %r89, %r14, %r15; + lg2.approx.ftz.f32 %r97, %r16; + mul.ftz.f32 %r98, %r97, 0f3F317218; + fma.rn.ftz.f32 %r99, %r98, 0f3DCCCCCD, 0f3F800000; + mul.ftz.f32 %r22, %r13, %r99; +$L__BB0_4: + ld.global.b32 %r32, [%rd52]; + setp.lt.s32 %p6, %r32, 0; + setp.ge.s32 %p7, %r32, %r5; + or.pred %p8, %p6, %p7; + @%p8 bra $L__BB0_40; + setp.gt.u32 %p9, %r3, 127; + mov.b32 %r17, 0f00000000; + @%p9 bra $L__BB0_8; + ld.global.b32 %r33, [%rd51]; + // begin inline asm + { cvt.rn.f16.f32 %rs6, %r33;} + + // end inline asm + // begin inline asm + { cvt.f32.f16 %r17, %rs6;} + + // end inline asm + and.b32 %r34, %r32, 3; + setp.eq.b32 %p10, %r34, 3; + @%p10 bra $L__BB0_8; + shl.b32 %r35, %r32, 7; + and.b32 %r36, %r35, 384; + mul.wide.u32 %rd42, %r36, 4; + add.s64 %rd43, %rd10, %rd42; + st.global.b32 [%rd43], %r17; +$L__BB0_8: + setp.eq.b32 %p11, %r32, 0; + and.b32 %r37, %r32, 3; + setp.eq.b32 %p12, %r37, 3; + or.pred %p13, %p11, %p12; + @%p13 bra $L__BB0_10; + bar.sync 0; + bra.uni $L__BB0_40; +$L__BB0_10: + mov.b32 %r113, 0f00000000; + @%p9 bra $L__BB0_17; + mov.b32 %r111, %r17; + @%p11 bra $L__BB0_13; + ld.global.b32 %r111, [%rd10]; +$L__BB0_13: + setp.ne.b32 %p14, %r32, 0; + @%p14 bra $L__BB0_15; + add.rn.ftz.f32 %r42, %r111, %r17; + add.rn.ftz.f32 %r43, %r42, %r17; + add.rn.ftz.f32 %r112, %r43, %r17; + bra.uni $L__BB0_16; +$L__BB0_15: + ld.global.b32 %r38, [%rd10+512]; + add.rn.ftz.f32 %r39, %r111, %r38; + ld.global.b32 %r40, [%rd10+1024]; + add.rn.ftz.f32 %r41, %r39, %r40; + add.rn.ftz.f32 %r112, %r41, %r17; +$L__BB0_16: + fma.rn.ftz.f32 %r113, %r112, 0f3E800000, 0f00000000; +$L__BB0_17: + setp.lt.u32 %p15, %r3, 128; + fma.rn.ftz.f32 %r44, %r113, %r113, 0f00000000; + selp.f32 %r45, %r44, 0f00000000, %p15; + shfl.sync.bfly.b32 %r46|%p16, %r45, 16, 31, -1; + add.ftz.f32 %r47, %r45, %r46; + shfl.sync.bfly.b32 %r48|%p17, %r47, 8, 31, -1; + add.ftz.f32 %r49, %r47, %r48; + shfl.sync.bfly.b32 %r50|%p18, %r49, 4, 31, -1; + add.ftz.f32 %r51, %r49, %r50; + shfl.sync.bfly.b32 %r52|%p19, %r51, 2, 31, -1; + add.ftz.f32 %r53, %r51, %r52; + shfl.sync.bfly.b32 %r54|%p20, %r53, 1, 31, -1; + add.ftz.f32 %r18, %r53, %r54; + @%p21 bra $L__BB0_19; + shr.u32 %r55, %r3, 3; + mov.b32 %r56, _ZZ23draft_commit_qsa_layersE8partials; + add.s32 %r57, %r56, %r55; + st.shared.b32 [%r57], %r18; +$L__BB0_19: + setp.gt.u32 %p22, %r6, 7; + bar.sync 0; + mov.b32 %r114, 0f00000000; + @%p22 bra $L__BB0_21; + shl.b32 %r58, %r6, 2; + mov.b32 %r59, _ZZ23draft_commit_qsa_layersE8partials; + add.s32 %r60, %r59, %r58; + ld.shared.b32 %r114, [%r60]; +$L__BB0_21: + setp.gt.u32 %p23, %r3, 127; + shfl.sync.bfly.b32 %r61|%p24, %r114, 16, 31, -1; + add.ftz.f32 %r62, %r114, %r61; + shfl.sync.bfly.b32 %r63|%p25, %r62, 8, 31, -1; + add.ftz.f32 %r64, %r62, %r63; + shfl.sync.bfly.b32 %r65|%p26, %r64, 4, 31, -1; + add.ftz.f32 %r66, %r64, %r65; + shfl.sync.bfly.b32 %r67|%p27, %r66, 2, 31, -1; + add.ftz.f32 %r68, %r66, %r67; + shfl.sync.bfly.b32 %r69|%p28, %r68, 1, 31, -1; + add.ftz.f32 %r70, %r68, %r69; + mov.b32 %r71, 0f43000000; + div.approx.ftz.f32 %r19, %r70, %r71; + @%p23 bra $L__BB0_23; + add.ftz.f32 %r72, %r19, %r7; + rsqrt.approx.ftz.f32 %r73, %r72; + mul.ftz.f32 %r74, %r113, %r73; + ld.global.b32 %r75, [%rd11]; + mul.ftz.f32 %r76, %r74, %r75; + shl.b32 %r77, %r3, 2; + mov.b32 %r78, _ZZ23draft_commit_qsa_layersE6values; + add.s32 %r79, %r78, %r77; + st.shared.b32 [%r79], %r76; +$L__BB0_23: + setp.gt.u32 %p29, %r3, 127; + bar.sync 0; + @%p29 bra $L__BB0_39; + setp.gt.u32 %p30, %r3, 63; + and.b32 %r80, %r32, 2147483644; + add.s32 %r20, %r80, %r9; + shl.b32 %r81, %r3, 2; + mov.b32 %r82, _ZZ23draft_commit_qsa_layersE6values; + add.s32 %r83, %r82, %r81; + ld.shared.b32 %r119, [%r83]; + @%p30 bra $L__BB0_34; + setp.eq.b32 %p31, %r32, 0; + mov.b32 %r116, 0f00000000; + @%p31 bra $L__BB0_29; + setp.eq.b64 %p32, %rd8, 0; + mov.b32 %r115, %r20; + @%p32 bra $L__BB0_28; + mul.wide.s32 %rd45, %r20, 12; + cvt.u32.u16 %r84, %rs1; + and.b32 %r85, %r84, 255; + mul.wide.u32 %rd46, %r85, 4; + add.s64 %rd47, %rd8, %rd46; + add.s64 %rd44, %rd47, %rd45; + // begin inline asm + ld.global.nc.s32 %r115, [%rd44]; + // end inline asm +$L__BB0_28: + cvt.rn.f32.s32 %r116, %r115; +$L__BB0_29: + setp.eq.ftz.f32 %p33, %r12, 0f00000000; + mul.ftz.f32 %r21, %r116, %r88; + mul.ftz.f32 %r117, %r11, %r21; + mov.b32 %r118, %r13; + @%p33 bra $L__BB0_31; + setp.lt.ftz.f32 %p34, %r89, 0f00000000; + setp.gt.ftz.f32 %p35, %r89, 0f3F800000; + selp.f32 %r90, 0f3F800000, %r89, %p35; + mov.b32 %r91, 0f3F800000; + sub.ftz.f32 %r92, %r91, %r90; + selp.f32 %r93, 0f3F800000, %r92, %p34; + mul.ftz.f32 %r94, %r12, %r93; + sub.ftz.f32 %r95, %r91, %r94; + mul.ftz.f32 %r96, %r117, %r95; + fma.rn.ftz.f32 %r117, %r21, %r94, %r96; + mov.b32 %r118, %r22; +$L__BB0_31: + setp.gt.u32 %p36, %r3, 31; + cos.approx.ftz.f32 %r100, %r117; + mul.ftz.f32 %r23, %r118, %r100; + sin.approx.ftz.f32 %r101, %r117; + mul.ftz.f32 %r24, %r118, %r101; + shl.b32 %r102, %r6, 2; + mov.b32 %r103, _ZZ23draft_commit_qsa_layersE6values; + add.s32 %r104, %r103, %r102; + ld.shared.b32 %r25, [%r104]; + ld.shared.b32 %r26, [%r104+128]; + @%p36 bra $L__BB0_33; + mul.ftz.f32 %r106, %r23, %r25; + mul.ftz.f32 %r107, %r24, %r26; + sub.ftz.f32 %r119, %r106, %r107; + bra.uni $L__BB0_34; +$L__BB0_33: + mul.ftz.f32 %r105, %r23, %r26; + fma.rn.ftz.f32 %r119, %r25, %r24, %r105; +$L__BB0_34: + setp.ne.b32 %p37, %r32, 0; + shr.u32 %r108, %r32, 2; + mul.wide.u32 %rd48, %r108, 128; + add.s64 %rd49, %rd48, %rd9; + shl.b64 %rd50, %rd49, 2; + add.s64 %rd15, %rd14, %rd50; + st.global.b32 [%rd15], %r119; + @%p37 bra $L__BB0_36; + st.global.b32 [%rd12], %r119; + bra.uni $L__BB0_37; +$L__BB0_36: + ld.global.b32 %r109, [%rd12]; + st.global.b32 [%rd15+512], %r109; +$L__BB0_37: + setp.eq.b32 %p38, %r32, 0; + setp.ne.b32 %p39, %r3, 0; + or.pred %p40, %p39, %p38; + @%p40 bra $L__BB0_39; + st.global.b32 [%rd13], %r20; +$L__BB0_39: + bar.sync 0; +$L__BB0_40: + add.s32 %r110, %r110, 1; + setp.ne.b32 %p41, %r110, 0; + add.s64 %rd52, %rd52, 4; + add.s64 %rd51, %rd51, 512; + @%p41 bra $L__BB0_4; +$L__BB0_41: + ret; + +} diff --git a/crates/cuda-driver/src/original_verify.rs b/crates/cuda-driver/src/original_verify.rs index a3999fb5..a7e039bb 100644 --- a/crates/cuda-driver/src/original_verify.rs +++ b/crates/cuda-driver/src/original_verify.rs @@ -16,6 +16,7 @@ #[path="original_verify_window_moe.rs"] pub(crate) mod moe; #[path="original_verify_window_chain.rs"] pub(crate) mod chain; #[path="original_verify_window_sm120.rs"] pub(crate) mod sm120; +#[path="original_verify_window_draft.rs"] pub(crate) mod draft; #[path="original_verify_window_planner.rs"] pub(crate) mod planner; #[cfg(test)] #[path="original_verify_window_gpu.rs"] mod window_gpu; pub use layout::{OriginalVerifyGeometry,OriginalVerifyLayout,OriginalVerifySpan}; @@ -339,6 +340,26 @@ impl<'ctx> OriginalVerifyGdnJournal<'_, 'ctx>{ command("verify_gdn_step_norm_multi_kernel",[48,1,1],[128,4,1],vec![Arg::Address(self.canonical.span(i,false)?),Arg::Address(h),Arg::I32(10240),Arg::Address(gate),Arg::Address(beta),Arg::Address(self.physical.span("z",0,g.max_t*6144*4)?),Arg::Address(admit(self.physical.context,self.weights[i].norm,128*4)?),Arg::F32(EPS),Arg::Address(self.physical.span("y_dummy",0,g.max_t*6144*4)?),Arg::I32(16),Arg::I32(48),Arg::I32(g.max_t as i32),Arg::Address(commit),Arg::I32(0)])? ]) } + /// Load the sealed `draft_commit.ptx` module before the commit graph is captured (module loading is not capturable). + pub(crate) fn load_draft_commit_asset(&self)->Result<()>{self.physical.ensure_window_assets(&[&draft::DRAFT_COMMIT,&draft::DRAFT_COMMIT_QSA])} + /// draft-round (`LELEKA_DRAFT_FUSED_COMMIT=on`): the 36 GDN layers' conv history commit and recurrence replay of `capture_commit_layer` in ONE launch + /// (`draft_commit_gdn_layers`: grid (48 heads + 20 conv blocks, 36 layers)). The per-layer operands are affine in the layer (checked against the per-layer spans below). + pub(crate) fn capture_commit_gdn_fused(&self,capture:&mut OriginalCapture<'_, 'ctx>)->Result<()>{ + self.validate_context(self.physical.context)?;let g=self.physical.layout.geometry;let t=g.max_t; + let commit=self.physical.span("commit",0,(t+2)*4)?; + let state0=self.canonical.span(0,false)?;let hist0=self.canonical.span(0,true)?; + let rows=t*10240*4;let small=t*48*4; + let qkv=self.physical.span("qkv_L",0,rows)?;let h=self.physical.span("h_L",0,rows)?;let gate=self.physical.span("gate_L",0,small)?;let beta=self.physical.span("beta_L",0,small)?; + // affine layout: layer i of every operand is base + i * stride (the per-layer spans `capture_commit_layer` binds) + for i in [1usize,17,35]{ + if self.canonical.span(i,false)?!=state0+(i*LAYER_BYTES)as u64||self.canonical.span(i,true)?!=hist0+(i*LAYER_BYTES)as u64 + ||self.physical.span("qkv_L",i*rows,rows)?!=qkv+(i*rows)as u64||self.physical.span("h_L",i*rows,rows)?!=h+(i*rows)as u64 + ||self.physical.span("gate_L",i*small,small)?!=gate+(i*small)as u64||self.physical.span("beta_L",i*small,small)?!=beta+(i*small)as u64{return Err(Error::InvalidQwenShape)} + } + if hist0+OriginalNativeHeadGraphResources< } pub fn record_commit(&mut self,resources:R,mut record_extra:impl FnMut(&mut OriginalCapture<'_, 'ctx>,&mut R,usize)->Result<()>)->Result<()>{ if self.failed||self.active||self.commit.is_some(){return Err(Error::InvalidQwenShape)}self.record_keys(&resources)?; + // sm_120 only: the fused kernels have no sm_86 companion (ptx-sm86/MANIFEST.json), another card keeps the Original's commit graph + let fused_commit=crate::original_verify::draft::fused_commit()&&resources.verifier_journal().window_device_attribute(crate::original_verify::gr::ATTR_COMPUTE_CAPABILITY_MAJOR)?==12; + if fused_commit{resources.verifier_journal().load_draft_commit_asset()?;} let stream=self.compute.as_mut().ok_or(Error::ContextPoisoned)?; self.commit=Some(stream.capture_owned(OriginalCapturePolicy::VerifierCommit,resources,|capture,r|{ r.verifier_journal().capture_commit_begin(capture)?;let mut gi=0;let mut qi=0; + // draft-round: the layers are independent; one launch per kind (GDN, QSA) instead of 182 nodes. A QSA with retained angle tables keeps its per-layer commit. + if fused_commit{ + r.verifier_journal().capture_commit_gdn_fused(capture)?; + if r.verifier_qsa().capture_commit_fused(r.verifier_journal(),capture)?{ + for layer in (3..48).step_by(4){record_extra(capture,r,layer)?;} + if r.verifier_journal().ple.is_some(){r.verifier_journal().capture_ple_commit(capture)?;}return Ok(()) + } + for layer in 0..48{if layer%4==3{r.verifier_qsa().capture_commit_layer(r.verifier_journal(),capture,qi)?;record_extra(capture,r,layer)?;qi+=1}} + if r.verifier_journal().ple.is_some(){r.verifier_journal().capture_ple_commit(capture)?;}return Ok(()) + } for layer in 0..48{if layer%4==3{r.verifier_qsa().capture_commit_layer(r.verifier_journal(),capture,qi)?;record_extra(capture,r,layer)?;qi+=1}else{r.verifier_journal().capture_commit_layer(capture,gi)?;gi+=1}} if r.verifier_journal().ple.is_some(){r.verifier_journal().capture_ple_commit(capture)?;}Ok(()) })?);if crate::host_profile::enabled(){eprintln!("DBG graph commit nodes={:?}",self.commit.as_ref().and_then(|g|g.nodes()));}Ok(()) diff --git a/crates/cuda-driver/src/original_verify_window_draft.rs b/crates/cuda-driver/src/original_verify_window_draft.rs new file mode 100644 index 00000000..759c1bce --- /dev/null +++ b/crates/cuda-driver/src/original_verify_window_draft.rs @@ -0,0 +1,61 @@ +//! claude/draft-round: the fused verifier commit graph (`draft_commit.cu`, `draft_commit_qsa.cu`). +//! +//! The commit graph of the Original-literal verifier is 182 serial kernel nodes (36 GDN layers x conv commit + recurrence replay, 12 QSA layers x tail restore + 8 row appends, +//! the PLE history copy, the first mapped copy). `LELEKA_DRAFT_FUSED_COMMIT=on` records it as the same first and last node plus one launch for all GDN layers and one for all QSA +//! layers (`draft_commit_gdn_layers`, `draft_commit_qsa_layers`): every state word is computed by the same operations in the same order (proved by the model-free probe +//! `tools/draft-round/commit_probe.cpp` and the replay identity gate, docs/experiments/draft-round-5090.md). Off by default until its paired A/B. +use super::kernels::AssetSpec; + +pub(crate) const E_GDN: &str = "draft_commit_gdn_layers"; +pub(crate) const E_QSA: &str = "draft_commit_qsa_layers"; + +/// `draft_commit.cu` (GDN layers, precise math), sealed by `scripts/gpu-bringup/seal_pins.py` (extra-seal-plan.json, group draft-round). +pub(crate) static DRAFT_COMMIT: AssetSpec = AssetSpec { + name: "draft_commit.ptx", + ptx: concat!(include_str!("draft_commit.ptx"), "\0").as_bytes(), + sha: [42, 84, 134, 220, 68, 111, 65, 245, 130, 212, 5, 3, 242, 10, 36, 211, 62, 194, 218, 187, 182, 163, 8, 18, 113, 83, 194, 204, 47, 192, 99, 150], + entries: &[E_GDN], + unsealed: "Original verifier asset unsealed: draft_commit.ptx (fused verifier commit graph, GDN layers)", +}; + +/// `draft_commit_qsa.cu` (QSA layers, fast math like the Original's `original_verify_qsa.ptx`), sealed the same way. +pub(crate) static DRAFT_COMMIT_QSA: AssetSpec = AssetSpec { + name: "draft_commit_qsa.ptx", + ptx: concat!(include_str!("draft_commit_qsa.ptx"), "\0").as_bytes(), + sha: [223, 201, 194, 216, 75, 207, 191, 33, 97, 151, 192, 218, 191, 162, 203, 165, 182, 75, 182, 169, 170, 199, 204, 83, 70, 33, 188, 104, 184, 119, 48, 157], + entries: &[E_QSA], + unsealed: "Original verifier asset unsealed: draft_commit_qsa.ptx (fused verifier commit graph, QSA layers)", +}; + +/// `LELEKA_DRAFT_FUSED_COMMIT=on|1`: record the commit graph with the fused kernels. Read once per process (it decides which kernels the commit graph records). +pub(crate) fn fused_commit() -> bool { + static ON: std::sync::OnceLock = std::sync::OnceLock::new(); + *ON.get_or_init(|| fused_commit_from(std::env::var("LELEKA_DRAFT_FUSED_COMMIT").ok().as_deref())) +} +pub(crate) fn fused_commit_from(value: Option<&str>) -> bool { + value.is_some_and(|v| matches!(v.trim().to_ascii_lowercase().as_str(), "on" | "1" | "yes" | "true")) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn the_fused_commit_is_opt_in() { + assert!(!fused_commit_from(None)); + assert!(!fused_commit_from(Some(""))); + assert!(!fused_commit_from(Some("off"))); + assert!(!fused_commit_from(Some("0"))); + assert!(fused_commit_from(Some("on"))); + assert!(fused_commit_from(Some("1"))); + assert!(fused_commit_from(Some(" ON "))); + } + + #[test] + fn the_draft_commit_assets_are_sealed_and_export_their_entries() { + DRAFT_COMMIT.assert_sealed_and_fail_closed(); + DRAFT_COMMIT_QSA.assert_sealed_and_fail_closed(); + assert_eq!(DRAFT_COMMIT.entries, &[E_GDN]); + assert_eq!(DRAFT_COMMIT_QSA.entries, &[E_QSA]); + } +} diff --git a/crates/cuda-driver/src/qsa_verification_commit.rs b/crates/cuda-driver/src/qsa_verification_commit.rs index 1a3b8188..8cdb6365 100644 --- a/crates/cuda-driver/src/qsa_verification_commit.rs +++ b/crates/cuda-driver/src/qsa_verification_commit.rs @@ -95,6 +95,32 @@ impl<'a,'ctx> OriginalVerifyQsaJournal<'a,'ctx>{ journal.submit(capture,vec![Command::new("verify_copy_from_mapped_kernel",[1,1,1],[256,1,1],0,vec![Arg::Address(i.h(1,0,1536)?.qwen_address()),Arg::Address(journal.address("tail_snap",layer*1536,1536)?),Arg::I64(96)])?])?; drop(i);self.capture_append(journal,capture,layer,0,t,true) } + /// draft-round (`LELEKA_DRAFT_FUSED_COMMIT=on`): the twelve layers' `capture_commit_layer` (tail restore + all `max_t` row appends) in ONE launch (`draft_commit_qsa_layers`, + /// one block per layer, rows in order). Only the analytic RoPE variant (`verify_qsa_append_analytic`) is fused: with retained angle tables it returns `Ok(false)` and records nothing. + pub(crate) fn capture_commit_fused(&self,journal:&OriginalVerifyGdnJournal<'_, 'ctx>,capture:&mut OriginalCapture<'_, 'ctx>)->Result{ + self.validate_context(journal.context())?;let r=self.rope;if r.angles.is_some(){return Ok(false)} + let t=journal.geometry().max_t;if t==0||t>8{return Err(Error::InvalidQwenShape)} + let mut tail=[0u64;12];let mut dead=[0u64;12];let mut pooled=[0u64;12];let mut block_pos=[0u64;12];let mut gamma=[0u64;12]; + for layer in 0..12{ + let i=self.indices[layer].try_borrow().map_err(|_|Error::InvalidQwenShape)?; + tail[layer]=i.h(1,0,1536)?.qwen_address();dead[layer]=i.h(2,0,512)?.qwen_address(); + pooled[layer]=i.h(0,0,i.image[0].as_ref().ok_or(Error::ContextPoisoned)?.len())?.qwen_address();block_pos[layer]=i.h(3,0,4)?.qwen_address(); + gamma[layer]=whole(self.context,self.gamma[layer],512)?; + } + let raw=journal.address("idx_raw_L",0,512)?;let snap=journal.address("tail_snap",0,1536)?;let commit=journal.address("commit",0,(t+2)*4)?; + // affine layout: the row append of (layer, row) binds idx_raw_L + (layer * t + row) * 512 and the tail snapshot of a layer is at + layer * 1536 (checked at the far end) + if journal.address("idx_raw_L",(11*t+t-1)*512,512)?!=raw+((11*t+t-1)*512)as u64||journal.address("tail_snap",11*1536,1536)?!=snap+(11*1536)as u64 + ||journal.address("commit",(2+t-1)*4,4)?!=commit+((2+t-1)*4)as u64{return Err(Error::InvalidQwenShape)} + let positions=r.positions.map(|b|whole(self.context,b,crate::serving_context::geometry().cells()*12)).transpose()?.unwrap_or(0); + let pack=|a:f32,b:f32|(a.to_bits()as u64)|((b.to_bits()as u64)<<32); + let mut words:Vec=Vec::with_capacity(5*12+7+4); + for v in [&tail,&dead,&pooled,&block_pos,&gamma]{words.extend_from_slice(v)} + words.extend_from_slice(&[raw,snap,commit,positions,t as u64,journal.geometry().max_cells as u64,0]); + words.extend_from_slice(&[pack(1e-6,r.theta_scale),pack(r.freq_scale,r.corr_low),pack(r.corr_high,r.ext_factor),pack(r.magnitude,0.0)]); + journal.submit_launches(capture,vec![crate::original_verify::kernels::Launch::new(&crate::original_verify::draft::DRAFT_COMMIT_QSA,crate::original_verify::draft::E_QSA,[12,1,1],[128,4,1],0, + vec![crate::original_verify::kernels::A::Words(words)])?])?; + Ok(true) + } /// Original provisional index append, row by row on the SAME captured stream. /// Caller records the tail snapshot before the first group's append. pub fn capture_append_rows(&self,journal:&OriginalVerifyGdnJournal<'_, 'ctx>,capture:&mut OriginalCapture<'_, 'ctx>,layer:usize,begin:usize,end:usize)->Result<()>{self.capture_append(journal,capture,layer,begin,end,false)} diff --git a/crates/deploy/src/profile.rs b/crates/deploy/src/profile.rs index 62dbf6f8..9a35578e 100644 --- a/crates/deploy/src/profile.rs +++ b/crates/deploy/src/profile.rs @@ -358,14 +358,15 @@ impl Profile { } self.memory.validate()?; for (key, value) in &self.engine_env { - // LELEKA_CHAIN selects the chain-kernel group (docs/chain-kernels.md); every other switch is a serve-stack one - if !(key.starts_with("LELEKA_ORIGINAL_SERVE_") || key == "LELEKA_CHAIN") + // LELEKA_CHAIN selects the chain-kernel group (docs/chain-kernels.md), LELEKA_SM120_* the compute-capability-12 kernel switches + // (docs/experiments/draft-round-5090.md); every other switch is a serve-stack one + if !(key.starts_with("LELEKA_ORIGINAL_SERVE_") || key.starts_with("LELEKA_SM120_") || key == "LELEKA_CHAIN") || !key .bytes() .all(|b| b.is_ascii_uppercase() || b.is_ascii_digit() || b == b'_') { return Err(format!( - "engine_env key {key} must be an upper-case LELEKA_ORIGINAL_SERVE_* name (or LELEKA_CHAIN)" + "engine_env key {key} must be an upper-case LELEKA_ORIGINAL_SERVE_* or LELEKA_SM120_* name (or LELEKA_CHAIN)" )); } if value.is_empty() || value.len() > 1024 || value.chars().any(char::is_control) { @@ -457,6 +458,22 @@ mod tests { assert!(!laptop.engine_env.contains_key("LELEKA_ORIGINAL_SERVE_SEED")); } + #[test] + fn only_the_server_profile_enables_the_mtp_draft_attention_switch() { + // bitwise draft-attention kernels of the compute capability 12 card (docs/experiments/draft-round-5090.md); the laptop (sm_86) has no companion for them + let server = Profile::builtin("rtx5090-32g").unwrap(); + assert_eq!(server.engine_env.get("LELEKA_SM120_ATTN_DAILY_MTP").map(String::as_str), Some("1")); + let laptop = Profile::builtin("rtx3080-16g").unwrap(); + assert!(!laptop.engine_env.contains_key("LELEKA_SM120_ATTN_DAILY_MTP")); + // the key space of engine_env still refuses everything else + let mut bad = server.clone(); + bad.engine_env.insert("LELEKA_SM86_X".into(), "1".into()); + assert!(bad.validate().is_err()); + let mut ok = server; + ok.engine_env.insert("LELEKA_SM120_ATTN_DAILY_MTP".into(), "1".into()); + ok.validate().unwrap(); + } + #[test] fn auto_selection_picks_the_server_and_the_laptop_profile() { let server = resolve(None, Some(&gpu("NVIDIA GeForce RTX 5090", 120, 32607))).unwrap(); diff --git a/crates/leleka-runtime/src/qwen_forward/original_serve_native.rs b/crates/leleka-runtime/src/qwen_forward/original_serve_native.rs index 5d1cf878..09d4a96a 100644 --- a/crates/leleka-runtime/src/qwen_forward/original_serve_native.rs +++ b/crates/leleka-runtime/src/qwen_forward/original_serve_native.rs @@ -112,6 +112,17 @@ fn trace_logprobs()->Option { static TOPK:std::sync::OnceLock>=std::sync::OnceLock::new(); *TOPK.get_or_init(||std::env::var("LELEKA_TRACE_LOGPROBS").ok().and_then(|v|v.parse::().ok()).filter(|k|*k>0)) } +/// `LELEKA_TRACE_DRAFT=1`: one line per completed draft (position, accepted row, the draft ids and the IEEE bits of their probabilities). The draft's numerics +/// are bit-compared across builds and settings by diffing these lines (draft-round identity gate); nothing reads them in production. +fn trace_draft()->bool { + static ON:std::sync::OnceLock=std::sync::OnceLock::new(); + *ON.get_or_init(||std::env::var("LELEKA_TRACE_DRAFT").is_ok_and(|v|v=="1")) +} +fn trace_draft_line(position:i64,accepted_row:usize,c:&DraftCompletion) { + if !trace_draft() {return;} + let bits:Vec=c.probabilities.iter().map(|p|format!("{:08x}",p.to_bits())).collect(); + eprintln!("DRAFT position={position} accepted_row={accepted_row} cell={} ids={:?} pbits=[{}]",c.first_cell,c.ids,bits.join(",")); +} fn trace_residual()->Option<&'static std::ffi::OsString> { static DIR:std::sync::OnceLock>=std::sync::OnceLock::new(); DIR.get_or_init(||std::env::var_os("LELEKA_TRACE_RESIDUAL")).as_ref() @@ -277,6 +288,7 @@ where R:OriginalVerifyGraphResources<'ctx>+OriginalNativeHeadGraphResources<'ctx self.settle_commit()?; let finished={let _p=profile::span("draft.finish");self.host.finish_draft()}; if finished.is_err() {self.failed=true;} + if let Ok(c)=&finished {trace_draft_line(position,accepted_row,c);} return finished; } // Serialized: the MTP receipt names the PUBLISHED branch, the commit event completes and the session is @@ -286,14 +298,19 @@ where R:OriginalVerifyGraphResources<'ctx>+OriginalNativeHeadGraphResources<'ctx let selection=window.selection.borrow_mut().take().ok_or(Error::IdentityMismatch); let (completed,selection)=match (completed,selection) {(Ok(c),Ok(s))=>(c,s),(Err(e),_)|(_,Err(e))=>return Err(e)}; let draft={let _p=profile::span("draft.mtp");self.host.draft_committed(completed,selection,position,accepted_row,max_drafts,min_p,coupled)}; - if draft.is_err() {self.failed=true;}draft + if draft.is_err() {self.failed=true;} + if let Ok(c)=&draft {trace_draft_line(position,accepted_row,c);} + draft } fn drain_draft(&mut self)->Result<()> { let drained=self.host.drain_draft(); if drained.is_err() {self.failed=true;}drained } fn draft_first(&mut self,seed:&H::Seed,t:usize,cell:i64,token:i32,max_drafts:usize,min_p:f32,coupled:bool)->Result { - self.live()?;self.host.draft_first(seed,t,cell,token,max_drafts,min_p,coupled) + self.live()?; + let c=self.host.draft_first(seed,t,cell,token,max_drafts,min_p,coupled)?; + trace_draft_line(cell,0,&c); + Ok(c) } fn drain_first(&mut self)->Result<()> {self.host.drain_first()} } diff --git a/deploy/rust-runtime/profiles/rtx5090-32g.json b/deploy/rust-runtime/profiles/rtx5090-32g.json index a79a9cce..883e0082 100644 --- a/deploy/rust-runtime/profiles/rtx5090-32g.json +++ b/deploy/rust-runtime/profiles/rtx5090-32g.json @@ -1,6 +1,6 @@ { "name": "rtx5090-32g", - "description": "RTX 5090 class server (sm_120, 32 GB VRAM, >= 100 GiB RAM). The 55 GB level-2 KAR archive is copied once into a sealed memfd and the 50 GB routed-expert bank is a page-locked RAM copy (the bring-up smoke form). Reference-equivalent agent configuration (docs/e2e-run.md 7d; GPU budget 32,819,404,800 B (31,299 MiB) since the dense-slab commits, was 30 GiB: the slab saves physical bytes the Context never counted, so the budget must rise by about that much for the slot gain to appear, docs/experiments/vram-footprint-5090.md; expert tier auto-sized per layer from data/expert-profile.bin, adaptive speculative window with spec-min-p 0, MTP draft vocabulary, prefix cache auto with request-end checkpoints (reply), chain kernels): weighted decode 129-130 tok/s in the reference-equivalent real Codex sessions on the 5090, +5 % from the adaptive window in the CRM replay. Prompt chunk and prefix-cache grid 8192 (paired 256k session on the 5090: TTFT sum 131 s at 2048 against 55-60 s at 8192, docs/upstream-port-plan.md). Prompt-routing seed OFF (engine_env LELEKA_ORIGINAL_SERVE_SEED=off, placement class, owner to confirm; docs/experiments/decode-tail-5090.md: +27 % decode at 45k-247k prompts). Not a formally quality-gated profile.", + "description": "RTX 5090 class server (sm_120, 32 GB VRAM, >= 100 GiB RAM). The 55 GB level-2 KAR archive is copied once into a sealed memfd and the 50 GB routed-expert bank is a page-locked RAM copy (the bring-up smoke form). Reference-equivalent agent configuration (docs/e2e-run.md 7d; GPU budget 32,819,404,800 B (31,299 MiB) since the dense-slab commits, was 30 GiB: the slab saves physical bytes the Context never counted, so the budget must rise by about that much for the slot gain to appear, docs/experiments/vram-footprint-5090.md; expert tier auto-sized per layer from data/expert-profile.bin, adaptive speculative window with spec-min-p 0, MTP draft vocabulary, prefix cache auto with request-end checkpoints (reply), chain kernels): weighted decode 129-130 tok/s in the reference-equivalent real Codex sessions on the 5090, +5 % from the adaptive window in the CRM replay. Prompt chunk and prefix-cache grid 8192 (paired 256k session on the 5090: TTFT sum 131 s at 2048 against 55-60 s at 8192, docs/upstream-port-plan.md). Prompt-routing seed OFF (engine_env LELEKA_ORIGINAL_SERVE_SEED=off, placement class, owner to confirm; docs/experiments/decode-tail-5090.md: +27 % decode at 45k-247k prompts). MTP draft attention = upstream pre75 chunk + merge v2 (engine_env LELEKA_SM120_ATTN_DAILY_MTP=1, bitwise identical on the replay gate, draft round 0.29 ms and whole round 0.37 ms shorter at 245k, docs/experiments/draft-round-5090.md). Not a formally quality-gated profile.", "select": {"sm_min": 120, "sm_max": 130, "vram_mib_min": 30000, "vram_mib_max": 1000000}, "gpu_budget_bytes": 32819404800, "spec_min_p": 0.0, @@ -13,6 +13,6 @@ "min_vram_total_mib": 30000, "min_ram_total_bytes": 107374182400, "min_ram_available_bytes": 113000000000, - "engine_env": {"LELEKA_ORIGINAL_SERVE_EXPERT_PER_LAYER": "yes", "LELEKA_CHAIN": "all", "LELEKA_ORIGINAL_SERVE_SEED": "off"}, + "engine_env": {"LELEKA_ORIGINAL_SERVE_EXPERT_PER_LAYER": "yes", "LELEKA_CHAIN": "all", "LELEKA_ORIGINAL_SERVE_SEED": "off", "LELEKA_SM120_ATTN_DAILY_MTP": "1"}, "memory": {"prefix_cache_mib": "auto", "prefix_cache_tail": "reply", "prefix_cache_block": 8192, "soft_floor_mib": 4096, "hard_floor_mib": 2048, "reserve_mib": 2048, "lock": "try", "heal": true} } diff --git a/docs/experiments/draft-round-5090.md b/docs/experiments/draft-round-5090.md new file mode 100644 index 00000000..b297469f --- /dev/null +++ b/docs/experiments/draft-round-5090.md @@ -0,0 +1,230 @@ +# 5090 decode at 245k: the GPU time of the MTP draft round, where it goes and what was cut without changing a bit (claude/draft-round) + +Date 2026-11-02. RTX 5090 (32 GB), Ryzen 9 9950X3D, driver 595.99, CUDA 13.2 toolchain, server `rnr5090`, one heavy job at a time under `/data/leleka-e2e/gpu.lock`, sealed KAR memfd held by the holder. +Base = `main` 1416973a9 (code of ffd9322c7 outside docs/ and scripts/). Workload of every run: the frozen 245k corpus, 5 turns, `--max-output 300`, final-turn input 246,862-247,022 tokens, +PCIe share pinned 0.45 (product default), seed off, upstream ranked profile, auto slots, `LELEKA_CHAIN=all`, prefix cache auto, spec-min-p 0; vanilla lossy defaults are not involved (this task compares ours with ours). +Labels: M measured in the run named, E estimate. Follows [cpu-service2](cpu-service2-5090.md) section 6 ("draft round (target 3): not changed"). + +## 1. Result + +| item | class | status | effect (paired, same workload at 245k, adaptive window as shipped unless said) | +| --- | --- | --- | --- | +| **MTP draft attention = upstream `attn_chunk_kernel_pre75` + `attn_merge_v2`** (`LELEKA_SM120_ATTN_DAILY_MTP=1`, existed, never run on a GPU) | bitwise (2057/2057 rows, 1036/1036 draft traces) | **enabled in the rtx5090-32g profile by a separate commit (5378b226d)**; engine default stays off | step graph 622 -> 475 us, round graph 806 -> 663 us; `draft_committed` **-0.29 ms**; whole round **-0.37 ms (-2.7 %), 12 of 12 blocks**; tok/s **+0.5 % +- 0.6 %** (n.s., the adaptive window narrows by 2.4 % rows); **+3.0 %, 5 of 5 blocks, with the window held fixed** | +| **fused verifier commit graph** (`LELEKA_DRAFT_FUSED_COMMIT=on`) | bitwise (byte-for-byte probe, same replay gate) | **opt-in, off**: neutral | 182 -> 4 nodes, GPU 516 -> 125 us; round time **-0.024 +- 0.046 ms** (it is not on the critical path); gives the host 0.38 ms of slack against the first draft graph | +| `LELEKA_TRACE_DRAFT=1`, profile/A-B/identity tooling, probe | instrumentation | merged with the branch | | + +Where the 1.46 ms went (profile, section 2): the **commit graph was not the problem** (off the critical path, 4 us of host time); the draft is a GPU-bound chain of one round graph (806 us) and 0.9 step graphs (622 us), a third of which is the draft head and +the sampler scans (not shortenable bitwise) and a third the attention (shortened). The quantities the task listed that this work does not move: deeper drafting is the adaptive window's policy (and it moves *against* a faster draft, section 5), the end-of-window sync +(`drv.sync_compute` 0.46 ms) is the window's GPU time itself, the swap-copy wait (`apply_pending` 0.2 ms) is the tier adaptation's. + + + +## 2. Where the draft round goes (M, `runs/draft-round-prof2`, CUPTI window over turn 5, main binary `bin-main-ffd9322`) + +One CUPTI window (20 s, 156 rounds, `scripts/e2e/decode/draftround-kernels.py`). A round launches three kinds of small graphs after the verify window: the **commit** graph (once), the MTP **round** graph (the first draft +step with the catch-up of the accepted rows, once, 155-173 kernels by row count) and the MTP **step** graphs (the chain, 0.84 per round, 113 kernels each). +GPU spans (CUPTI inflates kernel times by about 10 % against event timing; the shares are what matter): + +| graph (per round) | kernels | GPU span | what dominates it | +| --- | ---: | ---: | --- | +| commit, 1x | 182 | 516 us (kernel sum 417) | `verify_gdn_step_norm_multi_kernel` 36 x 6.7 = 240 us, `verify_qsa_append_analytic` 96 x 0.97 = 94 us, `verify_gdn_conv_commit_kernel` 36 x 1.6 = 58 us, 12 tail restores 18 us | +| MTP round graph, 1x | 155-173 | 806 us | `head_n14_s0` (draft head, 106,299 rows) 142, `chain_qsa_decode_merge_n` 125, `leleka_qsa_decode_chunk` 109, `mtp_original_finite` guards 59 x 1.1 = 64, `mtp_scalar_gr_staged` 3 x 17 = 52, `head_n8_s0` 4 x 10.6 = 42 | +| MTP step graph, 0.84x | 113 | 622 us | `head_n14_s0` 141, `chain_qsa_decode_merge_n` 117, `leleka_qsa_decode_chunk` 102, `head_n8_s0` 4 x 9.5 = 38, guards 41 x 0.74 = 30, `mtp_scalar_gr_staged` 2 x 13 = 27 | + +**What the tracer distorts.** CUPTI instruments every driver call: the launch calls and the gaps between graphs in its timeline (commit launch call starting 62 us after the window, the round graph's first kernel 315 us after it, launch calls of +82-126 us, 124 us between steps) are the tracer's. The same host spans of untraced runs (`runs/draft-round-ab1`, arm a, ms per round): `drv.commit_enqueue` 0.004, window graph launch (`drv.launch`) 0.008, `draft.launch` (staging + launch of the round +graph) 0.027, a chain step 0.594 wall against 0.563 of GPU time (events), i.e. about 30 us of host per step. Kernel durations are close (step 622 us in CUPTI against 563 us with events, +10 %); the shares and the order of the kernels are what the +tables use. Read from the trace and the untraced spans: + +* The **commit graph is not on the draft's critical path**: the draft stream no longer waits for it (decode-tail), and its 516 us end about a millisecond before the draft does (draft end - commit end: 1,066 us in the window). Its host cost is + 4 us per round untraced. So the task's "fused commit kernel" cannot pay through the launch (nothing to save) nor through the critical path; the only way left is the GPU-side contention of its 226 MB of GDN state traffic with the draft. The A/B below isolates it. +* The draft's GPU chain is the critical path: round graph + 0.9 x step graph + about 30 us of host per step is the `draft_committed` span (1.44 ms untraced), of which the host's own work (publish 0.14, adaptive queue 0.08) is hidden in the first graph. +* About a third of every MTP graph is two kernels that nothing in a bitwise-identical port can shorten: the draft head (`head_n14_s0`: 223 MB of Q6_K rows streamed at 1.58 TB/s, 88 % of what the card sustains) and + the 106k-logit argmax and top-probability scans (single-block kernels, 9.5 + 8.1 us). +* The attention is the item that was not at its floor: the Original's chunk kernel and `chain_qsa_decode_merge_n` take 102 + 117 us of a 622 us step. The tree already carries the upstream replacements + (`sm120_attn_daily.cu`: `attn_chunk_kernel_pre75` + `attn_merge_v2`, byte-identical to the Original's by the model-free probe of tools/decode-sm120) as the opt-in `LELEKA_SM120_ATTN_DAILY_MTP=1` + ("not run on the GPU yet"); on the verify window the same kernels measured no end-to-end gain (a741f8e54), on the MTP step they replace 219 us by 70. + +**After the changes** (M, `runs/draft-round-prof4`, final binary `bin-dr2`, both switches on, same window; `runs/draft-round-prof3` has the attention switch alone): + +| graph (per round) | before (prof2) | attention switch alone (prof3) | both switches (prof4) | +| --- | --- | --- | --- | +| commit graph: kernels / GPU span | 182 / 516 us | 182 / 497 us | **4 / 125 us** (`draft_commit_gdn_layers` 113 us, `draft_commit_qsa_layers` 5 us, 2 copies 7 us) | +| (tracer timeline, launch calls inflated) verify end -> commit first kernel | 155 us | 160 us | 72 us | +| (tracer timeline) verify end -> first kernel of the MTP round graph | 315 us | 324 us | 230 us | +| MTP round graph GPU span | 806 us | 663 us | 585 us (run-to-run, the row mix differs: the guard kernels average 0.76 us here, 1.09 us in prof2) | +| MTP step graph GPU span (113 kernels) | 622 us | 475 us | 473 us | +| attention in a step: chunk + merge | 102 + 117 us | 49 + 21 us | 55 + 21 us | +| draft end - commit end | 1,066 us | 843 us | 1,279 us | + +The step graph is now 473 us of which `head_n14_s0` is 141 us (30 %), the attention 76 us, the 41 guards 31 us. + +## 3. Changes (all bitwise; each behind its own switch) + +| item | class | switch | what it does | +| --- | --- | --- | --- | +| **MTP draft attention = upstream `attn_chunk_kernel_pre75` + `attn_merge_v2`** | lossless, bitwise | `LELEKA_SM120_ATTN_DAILY_MTP=1` (existing since d6aee34af, opt-in, "not run on the GPU yet" until now) | step graph 622 -> 475 us, round graph 806 -> 663 us (M, `runs/draft-round-prof3`): chunk 102 -> 49 us, merge 117 -> 21 us; about 0.27 ms of GPU time per round. First GPU runs of this switch: identity below. | +| **fused verifier commit graph** | lossless, bitwise | `LELEKA_DRAFT_FUSED_COMMIT=on` (new, opt-in, sm_120 only: `record_commit` fuses only on cc 12) | 182 nodes -> 4 (`DBG graph commit nodes=Some(4)`): the first mapped copy, one launch for all 36 GDN layers (`draft_commit_gdn_layers`, grid (48 heads + 20 conv blocks, 36 layers)), one for all 12 QSA layers (`draft_commit_qsa_layers`, one block per layer, rows in order) and the PLE history copy. GPU time of the graph: 516 -> 125 us in the profile (probe: GDN part 346 -> 156 us, QSA part 72 -> 4.5 us). It is not on the draft's critical path and its host cost is 4 us per round (section 2), so no end-to-end effect is expected; `ab3` isolates it. | +| `LELEKA_TRACE_DRAFT=1` | instrumentation | env | one `DRAFT position=.. accepted_row=.. cell=.. ids=[..] pbits=[..]` line per completed draft: the ids and the IEEE bits of the probabilities, so the draft's numerics can be diffed across builds and settings | +| tooling | | | `draftround-ab.sh` (paired ours-vs-ours blocks and the CUPTI profile run), `draftround-kernels.py` (per-kernel table of commit / round / step graphs), `draftround-analyze.py`, `draftround-id.sh` + `-idcmp.py` (replay gate with the draft trace), `tools/draft-round/commit_probe.cpp` (model-free probe) | + +How the fused commit stays bitwise (and where it is deliberately not a copy): +* The Original's replay computes, for every accepted token, the layer's **output** as well (the `o` dot products, the RMS norm, the gated `y` write into a scratch region named `y_dummy` that nothing reads). That path never feeds the + recurrence state, so the fused kernel does not compute it; the state words come from the same `fmaf` chain, the same four-way `red[]` sum and the same `delta` expression in the same order. The state-independent loads of all + accepted tokens (key vector, value, gate, beta) are issued before the token loop instead of inside it; one barrier per token (double-buffered reduction) instead of four. +* The conv history update runs as 20 extra blocks per layer of the same launch (it reads the qkv rows and the old history, writes only the history). +* The QSA part is built with `--use_fast_math` like the **resealed** `original_verify_qsa.ptx` (the Original compiles `native_qsa_indexer` fast-math, docs/gpu-bringup.md D6): a first version built with the precise recipe of + `original_verify.cu` differed from the Original in about 1 % of the pooled-key words (`powf/cosf/sinf` against `__powf/cos.approx/sin.approx`) and the probe caught it before any model run; the GDN part stays precise + like `original_verify.cu`, which is not on the fast-math list. +* Per-layer addresses: the GDN operands are affine in the layer (canonical state/history, `qkv_L`, `h_L`, `gate_L`, `beta_L`; the recorder checks layers 1, 17 and 35 against the per-layer spans before it binds the base address), the QSA + ones are a 12 x 5 table of the same spans the per-layer commands bind. A QSA with retained angle tables (not the product) keeps its per-layer commit. +* Assets: `draft_commit.cu/.ptx` and `draft_commit_qsa.cu/.ptx`, sealed with `scripts/gpu-bringup` (extra-seal-plan.json, group `draft-round`, nvcc 13.2.86, SHA-256 pins in `original_verify_window_draft.rs`); `ptx-sm86/MANIFEST.json` + lists both as not built for sm_86 (by design: the switch exists on cc 12 only). `git ls-files --eol` shows `w/lf` for all `.ptx`. + + + +## 4. Identity (M) + +**Model-free probe** (`tools/draft-round/commit_probe.cpp`, on the RTX 5090, `/data/leleka-e2e/draft-round/probe/probe-result.txt`): the sealed Original kernels (`original_verify.ptx`, `original_verify_qsa.ptx`) run next to the fused ones on real-size +random inputs, **every output byte compared**: GDN 36 cases (n_keep 0..8 x 4 seeds, state and history of all 36 layers), QSA 60 cases (n_keep 1..8, holes, positions 0..103 around the 4-cell block edges, three RoPE settings incl. YaRN): +`PROBE OK: every output byte identical`. In a graph: GDN 346 -> 156 us, QSA 72 -> 4.5 us. + +**Replay gate** (`runs/draft-round-id1`, `rt-dr1`; teacher-forced replay of night5-long-256k, 5 requests of 240 forced decode tokens, production shape, `ADAPT_EVERY=4` (the adaptive tier swaps), seed off, one process per setting, two identical arms per process; +compared: the top-16 logprob rows of every window row, and the **draft trace** = ids and IEEE bits of the probabilities of every draft, 518 drafts per arm): + +| process (all against the defaults process `idP1`) | logprob rows | draft trace lines | argmax flips | +| --- | --- | --- | ---: | +| `LELEKA_SM120_ATTN_DAILY_MTP=1` | 2057 / 2057 identical | 1036 / 1036 identical | 0 | +| `LELEKA_DRAFT_FUSED_COMMIT=on` | 2057 / 2057 identical | 1036 / 1036 identical | 0 | +| both | 2057 / 2057 identical | 1036 / 1036 identical | 0 | +| A/A (arm 2 against arm 1 inside each process) | 2057 / 2057 | 518 / 518 | 0 | + +`q_tail_gate` PASS for all four processes (d_top1 max 0.0000). + +**Gate 2, the committed code** (`runs/draft-round-id2`, `rt-dr2` = 28d74a2ef, both switches on, against the defaults reference of gate 1 built from `rt-dr1`: two different binaries): 2057 / 2057 logprob rows and 1036 / 1036 draft-trace lines identical, 0 argmax flips, A/A exact. +Limits: 5 requests of 240 forced tokens (1,207 rows per arm after the prompt rows), production shape; the replay is teacher-forced, so what it proves is the equality of the numerics of the draft (ids and probability bits at every step), of the verifier windows +that follow the fused commit's state, and of the tier-swap path (ADAPT_EVERY=4); it does not run the sampling paths other than greedy. The model-free probe covers the commit state byte for byte, which the logprob rows cover only through their effect. + + + +## 5. Paired A/B at 245k (M, `runs/draft-round-ab1`, 12 blocks, 24 VALID runs, one binary `dt/bin-dr1`) + +a = defaults (= main's behaviour: both switches off), b = `LELEKA_SM120_ATTN_DAILY_MTP=1 LELEKA_DRAFT_FUSED_COMMIT=on`; PCIe share 0.45, seed off, adaptive window, `--spec-min-p 0`, frozen corpus, 5 turns of 300 tokens, order alternated by block +(odd blocks a then b, even b then a), both arms of a block back to back; validity rules of the baseline-pair series (5 turns, final-turn input >= 200k tokens, turn-5 `window.ple` < 5 ms; all 24 runs valid). +tok/s = tokens over seconds of the five decode windows; tok/round = tokens over the request outcome lines' rounds; ms/round = decode seconds over rounds. + +| block | order | a tok/s (T1..T5) | b tok/s (T1..T5) | b - a tok/s | a / b tok/round | a / b ms/round | b - a ms/round | +| ---: | --- | --- | --- | ---: | --- | --- | ---: | +| 1 | a b | 153.5 (159 153 155 152 149) | 152.2 (161 155 164 146 139) | -1.3 | 2.072 / 1.987 | 13.497 / 13.052 | -0.445 | +| 2 | b a | 154.0 (158 152 161 152 148) | 159.7 (161 155 165 154 164) | +5.7 | 2.080 / 2.116 | 13.508 / 13.244 | -0.264 | +| 3 | a b | 157.9 (159 163 174 142 155) | 154.8 (161 155 164 145 150) | -3.1 | 2.161 / 2.038 | 13.688 / 13.164 | -0.524 | +| 4 | b a | 155.5 (160 151 175 149 146) | 154.6 (157 153 155 147 162) | -0.9 | 2.083 / 2.011 | 13.398 / 13.009 | -0.389 | +| 5 | a b | 153.3 (159 154 158 149 147) | 156.9 (158 152 164 158 154) | +3.6 | 2.058 / 2.072 | 13.425 / 13.203 | -0.222 | +| 6 | b a | 153.9 (159 154 158 147 152) | 158.2 (161 155 169 157 151) | +4.3 | 2.078 / 2.098 | 13.500 / 13.259 | -0.241 | +| 7 | a b | 156.3 (159 155 172 151 147) | 153.5 (152 152 168 146 151) | -2.8 | 2.125 / 2.046 | 13.590 / 13.332 | -0.258 | +| 8 | b a | 153.2 (159 154 158 147 148) | 157.9 (160 156 170 155 149) | +4.7 | 2.041 / 2.083 | 13.321 / 13.197 | -0.124 | +| 9 | a b | 154.3 (157 155 148 157 154) | 153.4 (157 153 163 144 151) | -0.9 | 2.101 / 1.982 | 13.616 / 12.913 | -0.703 | +| 10 | b a | 153.3 (160 154 158 148 148) | 154.3 (158 152 163 147 152) | +1.0 | 2.044 / 1.995 | 13.332 / 12.927 | -0.405 | +| 11 | a b | 156.5 (158 150 173 150 154) | 154.9 (161 155 164 150 146) | -1.6 | 2.131 / 2.033 | 13.610 / 13.122 | -0.488 | +| 12 | b a | 155.5 (159 158 154 152 154) | 155.3 (158 153 170 152 146) | -0.2 | 2.095 / 2.041 | 13.470 / 13.138 | -0.332 | + +| over the 12 blocks | a (defaults) | b (both on) | b - a, block-paired (mean, se) | blocks b better | +| --- | --- | --- | --- | --- | +| tok/s | 154.77 (sd 1.56) | 155.49 (sd 2.24) | **+0.71 (+0.47 %), se 0.89** | 5 of 12 | +| ms/round | 13.496 (sd 0.115) | 13.130 (sd 0.132) | **-0.366 (-2.71 %), se 0.046** | **12 of 12** (-0.12 .. -0.70) | +| tok/round | 2.089 (sd 0.036) | 2.042 (sd 0.044) | -0.047 (-2.23 %), se 0.017 | 4 of 12 | +| verified rows per round | 2.713 | 2.648 | -0.065, se 0.017 | 10 of 12 narrower | +| chain steps per round (steps after the round graph) | 0.912 | 0.874 | -0.038, se 0.012 | 10 of 12 fewer | + +Spans (ms per round, the same runs; `LELEKA_SERVE_PROFILE`): `round.draft_committed` 1.439 -> 1.155 (**-0.285**, every block between -0.23 and -0.32), `commit.wait` 0.425 -> 0.085 (-0.340, the fused commit is finished +long before the host asks), `commit.publish` 0.140 -> 0.113, `mtp.chain_step` 0.594 -> 0.438 (GPU 0.563 -> 0.408, -0.155 per step), `mtp.finish_first_step` 0.170 -> 0.411 (the host now waits for the first draft graph instead of for +the commit: the draft's GPU chain is the critical path, the host side is idle in it), `round.run_window` 11.780 -> 11.695, `round.apply_pending` 0.204 -> 0.231. + +**Reading.** +* The draft round is 0.285 ms shorter and the whole round **0.366 ms (2.7 %) shorter in 12 of 12 blocks** (`round.run_window` is 0.085 ms shorter in the same runs, which nothing in the change touches: the earlier start of the next window + and noise at the 0.05 ms level, the span has sd 0.1 ms between runs). +* **tok/s is not resolvably different: +0.5 % with a standard error of 0.6 %** (interval about -0.7 .. +1.6 %). The reason is on the same page: the adaptive window answers the shorter rounds with narrower windows (rows per round -2.4 %, + accepted tokens per round -2.2 %, in 10 of 12 blocks). At equal tokens per round the shorter round would be +2.8 % tok/s. Reading of the code (E, not tested): the policy (`original_spec_adaptive.rs`) raises its draft-confidence floor with the measured token rate, and its + cost constant `draft_step_ms` = 0.45 ms sat below the old step cost of 0.59 ms and sits at the new one of 0.44 ms; so it moves along a flat tokens-against-time curve and gives most of the gain back. Whether a different policy constant + recovers it is a policy question (window shape, not bitwise) and was not tried. The fixed-window series of section 6 shows the gain at equal tokens per round: +3.0 % tok/s, 5 of 5 blocks. +* Run-to-run spread of one arm: tok/s sd 1.6-2.2, ms/round sd 0.12-0.13, tok/round sd 0.04: the round time is the quantity this change moves and the one the A/B resolves; tok/s needs the policy held fixed to resolve it. + + +## 6. The same change with the window policy held fixed, the isolation of the fused commit, and the controls + +**Fixed window (`runs/draft-round-ab2`, 5 blocks, 10 VALID runs, `bin-dr2`)**: `LELEKA_SPEC=4 LELEKA_SPEC_ADAPTIVE=off` (the Original's mode17 window, 4 drafts at most) and a draft floor of 0.5 (`--spec-min-p 0.5`), so that the +window policy cannot react to the shorter rounds; a = defaults, b = both switches on; everything else as section 5. This is not the shipped configuration (the product runs the adaptive window with floor 0); it separates the effect of the change from the policy's answer to it. + +| block | order | a tok/s (T1..T5) | b tok/s (T1..T5) | b - a tok/s | a / b tok/round | a / b ms/round | b - a ms/round | +| ---: | --- | --- | --- | ---: | --- | --- | ---: | +| 1 | a b | 156.9 (156 159 170 149 152) | 160.0 (159 162 174 152 155) | +3.1 | 2.063 / 2.063 | 13.153 / 12.897 | -0.256 | +| 2 | b a | 157.0 (156 159 170 149 152) | 159.7 (159 162 174 151 155) | +2.7 | 2.063 / 2.063 | 13.143 / 12.916 | -0.227 | +| 3 | a b | 156.6 (156 159 170 149 151) | 160.0 (159 162 174 152 155) | +3.4 | 2.063 / 2.063 | 13.172 / 12.897 | -0.275 | +| 4 | b a | 151.7 (156 152 168 144 143) | 159.9 (158 162 173 152 155) | +8.2 | 2.069 / 2.063 | 13.636 / 12.906 | -0.730 | +| 5 | a b | 154.4 (156 154 164 146 153) | 159.9 (159 162 174 152 155) | +5.5 | 2.086 / 2.063 | 13.511 / 12.900 | -0.611 | + +| over the 5 blocks | a | b | b - a, block-paired (mean, se) | blocks b better | +| --- | --- | --- | --- | --- | +| tok/s | 155.33 (sd 2.27) | 159.90 (sd 0.10) | **+4.58 (+2.96 %), se 1.02** | **5 of 5** (+2.7 .. +8.2) | +| ms/round | 13.323 (sd 0.233) | 12.903 (sd 0.008) | **-0.420 (-3.13 %), se 0.104** | **5 of 5** | +| tok/round | 2.069 (sd 0.010) | 2.063 (sd 0.000) | -0.006 (-0.28 %), se 0.004 | (identical text in blocks 1-3) | + +With the window fixed the greedy text is the same run after run (tok/round 2.063 in 8 of the 10 runs), the b arm is repeatable to 0.1 tok/s and the three clean pairs (blocks 1-3, equal tokens per round) give **+3.1, +2.7, +3.4 tok/s = +2.0 %** for +**-0.26 ms per round**. Blocks 4 and 5 have a slow a arm (151.7 and 154.4 tok/s, 13.6 and 13.5 ms/round, 2.069 and 2.086 tokens per round: a run whose adaptive expert tier settled differently); they are valid runs and stay in the means. +So the change does what the profile says (-0.26 .. -0.42 ms per round, 2-3 % of the round) and, with the policy not reacting, it shows as tok/s. + +**What the fused commit adds on top of the attention switch (`runs/draft-round-ab3`, 6 blocks, adaptive window as shipped, `bin-dr2`)**: a = `LELEKA_SM120_ATTN_DAILY_MTP=1`, b = the same plus `LELEKA_DRAFT_FUSED_COMMIT=on`. + +| block | order | a tok/s | b tok/s | b - a tok/s | a / b tok/round | a / b ms/round | b - a ms/round | +| ---: | --- | --- | --- | ---: | --- | --- | ---: | +| 1 | a b | 160.2 | 159.7 | -0.5 | 2.122 / 2.116 | 13.247 / 13.244 | -0.003 | +| 2 | b a | 151.0 | 156.0 | +5.0 | 2.011 / 2.075 | 13.313 / 13.300 | -0.013 | +| 3 | a b | 151.0 | 159.6 | +8.6 | 2.000 / 2.116 | 13.247 / 13.252 | +0.005 | +| 4 | b a | 152.1 | 154.5 | +2.4 | 2.055 / 2.055 | 13.511 / 13.299 | -0.212 | +| 5 | a b | 154.8 | 159.7 | +4.9 | 2.041 / 2.128 | 13.183 / 13.319 | +0.136 | +| 6 | b a | 155.4 | 158.0 | +2.6 | 2.069 / 2.095 | 13.315 / 13.258 | -0.057 | + +| over the 6 blocks | a (attention switch) | b (+ fused commit) | b - a, block-paired (mean, se) | blocks b better | +| --- | --- | --- | --- | --- | +| ms/round | 13.303 (sd 0.114) | 13.279 (sd 0.031) | **-0.024 (-0.17 %), se 0.046** | 4 of 6 | +| `round.draft_committed` | 1.211 | 1.177 | -0.033 | 5 of 6 | +| tok/round | 2.049 | 2.097 | +0.048 (+2.4 %), se 0.020 | (content/policy noise, the other way round from section 5) | +| tok/s | 154.07 (sd 3.52) | 157.94 (sd 2.24) | +3.87 (+2.5 %), se 1.26 | 5 of 6 (carried by tok/round, not by the round time) | + +**The fused commit does not shorten the round: -0.024 ms +- 0.046 ms.** That is what the profile predicts (the commit graph is off the critical path and costs 4 us of host time). What it changes is where the host waits: `commit.wait` 0.466 -> 0.085 ms and +`mtp.finish_first_step` 0.033 -> 0.413 ms. With the attention switch alone the host's side of the round (commit wait 0.47 + publish 0.17 ms = 0.63 ms) ends within 33 us of the first draft graph (0.66 ms): the host path had become +as long as the GPU path, so any further cut of the first graph would have been capped by the commit graph; with the fused commit the host side has 0.38 ms of slack. It is insurance for the next GPU-side cut, not a gain today. The tok/s rows of +this table move with tok/round (content), as they do in section 5, and say nothing about the commit. Class: bitwise (section 4), neutral in speed: **stays opt-in**. + + +**Controls.** (1) `runs/draft-round-ab0` (4 blocks): the main binary `bin-main-ffd9322` (a) against the draft-round binary `bin-dr1` with every new switch off (b), adaptive window: tok/s 153.86 vs 152.69 (-1.17, se 1.08, -0.75 %), ms/round 13.529 vs 13.366 +(**-0.163 ms**, se 0.049, 4 of 4 blocks shorter), `round.draft_committed` -0.031 ms, `round.run_window` -0.104 ms. The two binaries are built from the same sources outside the new, switched-off code (`git diff ffd9322c7 1416973a9` outside docs/ and scripts/ is empty); +the 0.16 ms is not explained by anything in the draft (the draft spans differ by 0.03 ms) and the A/A below says how large such a difference is between two arms of one binary. It does not touch section 5 (one binary, environment switches only). +(2) **A/A** (`runs/draft-round-ab5`, 4 blocks, `bin-dr1` against itself, defaults, adaptive window): b - a ms/round **+1.230, +0.004, -0.313, +0.113** (mean +0.26, se 0.34; the +1.23 block has a run that stalled in turn 2 at 110 tok/s, valid under the rules), tok/s +-4.7, -0.0, +2.1, +4.7 (mean +0.5, se 2.0), tok/round +0.119, 0.000, -0.019, +0.082. So the paired design has a per-block spread of about 0.2-0.3 ms/round and 3-4 tok/s between two identical arms (one outlier included): the control difference of (1) is inside it, +and the 12-block series of section 5 (ms/round differences -0.12 .. -0.70, sd 0.16, all negative) and the span `round.draft_committed` (every block between -0.23 and -0.32; in the A/A -0.145 .. +0.041) sit outside it. The tok/s rows of every series are dominated by +tok/round, which moves by +-0.1 between identical arms. + + + +## 7. Examined and not done (with the numbers that decided it) + +* **Guards.** 41 of the 113 step kernels (59 of about 160 in the round graph) are `mtp_original_finite` / `mtp_original_q8_guard` checks: 0.7-1.1 us of GPU time each with the gap to the next node, about 0.1 ms per round together. A + bitwise- and behaviour-preserving way is to fuse each (finite, quantize, q8_guard) triplet (3 nodes -> 1; 3 in the step, 8 in the round graph, about 30 us per round); dropping or deferring the checks changes how a numerical fault is + reported and is the owner's call. Not done: below what a 6-12 block A/B can resolve. +* **Draft head** `head_n14_s0`: 223 MB of Q6_K rows (106,299 x 2560) per graph at 141 us = 1.58 TB/s, the card's sustained DRAM rate. Reading the matrix in alternating directions in consecutive graphs to reuse the L2 tail + (96 MB) was considered (up to about 25 us per round); the attention reads in between evict part of it. Not done. +* **Argmax + top-probability scans** (`chain_sampler_greedy_kernel` 9.5 us, `chain_row_top_prob_kernel` 8.1 us, single-block kernels over 106k logits): fusing them saves one launch and one L2 pass (about 16 us per round); the probability sum + must keep its order, so only the two-pass fusion is safe. Not done. +* **Draft before commit in the host order** (the draft would start about 48 us earlier): with the fused commit the commit enqueue costs about 10 us, so there is nothing left to win; and the reorder touches the controller's state machine. +* **Pipelined chain** (launch step j+1 before the host read of step j): the adaptive window always runs with a confidence floor, and a speculative step past a failed test writes a ring cell; not safe to do bitwise. +* `LELEKA_SPEC_DRAFT_STEP_MS` (the adaptive window's constant for the cost of one chain step, 0.45 ms) is now closer to the measured step (about 0.42 ms with the attention switch) than before (0.6); it is a policy parameter, not touched. + +## 8. Reproduce + +* Profile: `scripts/e2e/decode/draftround-ab.sh` with `PROFILE=1 ENTRIES="1:1:a"` (stubs `dr-prof*.sh`), then `python3 -I draftround-kernels.py /win-turn5.lct --seq step` and `draftround-timeline.py`. +* Probe: `tools/draft-round/commit_probe.cpp` (`nvcc -O2 -std=c++17 commit_probe.cpp -lcuda`; PTX directory with the four `.ptx`). +* Identity: `draftround-id.sh` (stubs `dr-id1.sh`, `dr-id2.sh`); A/B: `draftround-ab.sh` (stubs `dr-ab0.sh`, `dr-ab1.sh`, `dr-ab1b.sh`); analysis: `draftround-analyze.py `. +* Build: WSL release from an LF worktree (`git ls-files --eol` shows `w/lf` for the `.ptx`), binaries `dt/bin-dr1` (tooling commit + fused commit before the cc gate) and `dt/bin-dr2` (= 28d74a2ef); test binaries `dt/rt-dr1`, `dt/rt-dr2`. +* Two `leleka-runtime` tests fail in a WSL checkout on `/mnt/c` (`model_binding::qwen4exp_input::mtp::backing::tests::{failed_cleanup_or_replaced_inode_never_deletes_unowned_file, frozen_same_fd_hash_owner_and_source_independence}`, ownership checks, already recorded in draft-tail-5090.md); `leleka-cuda-driver` lib: 431 passed, 0 failed. + diff --git a/scripts/e2e/decode/draftround-ab.sh b/scripts/e2e/decode/draftround-ab.sh new file mode 100644 index 00000000..2818f571 --- /dev/null +++ b/scripts/e2e/decode/draftround-ab.sh @@ -0,0 +1,154 @@ +#!/usr/bin/env bash +# draft-round: paired ours-vs-ours A/B (and the CUPTI profile run) on the RTX 5090 at ~245k context. HOLDER JOB (rnr5090). +# Install: scripts/e2e/decode/draftround-install.sh (copies the tools to /data/leleka-e2e/draft-round/tools, read-only, MANIFEST.sha256 of every input); +# stub ~/work/gpu-runs/holder2/jobs/.sh = `#!/usr/bin/env bash` + env lines + `exec bash /data/leleka-e2e/draft-round/tools/draftround-ab.sh`. +# +# Arms "a" and "b" are two configurations of ours: A_BIN/B_BIN (a directory under dt/, may be the same) and A_ENV/B_ENV (extra KEY=VALUE words). +# Everything else is the shipped shape of baseline-pair-ab.sh `ours45`: seed off, upstream ranked profile, auto expert slots, budget 32819404800, spec-min-p 0, +# prefix cache auto, PCIe share pinned (PCIE_FRAC, default 0.45), 5 turns to ~245k, --max-output 300, final-turn input >= 200k tokens, no vanilla lossy switch. +# BLOCKS="1 2 3 4 5": odd block runs a then b, even block b then a (alternating order). A block is the unit of pairing. +# PROFILE=1: every run also loads the CUPTI tracer and writes one 20 s window over turn 5 (dir /win-turn5.lct); the window perturbs the run slightly, profile runs are not A/B data. +set -uo pipefail +DR=/data/leleka-e2e/draft-round +D=/data/leleka-e2e/decode/dt +LOCK=/data/leleka-e2e/gpu.lock +OUTR=${OUTR:?OUTR} +CORPUS=/data/leleka-e2e/decode/corpus/src/crates +UP=/data/leleka-e2e/decode/assets/expert-profile-upstream.bin +BLOCKS=${BLOCKS:-"1 2 3 4 5"} +RUN_TAG=${RUN_TAG:-} +PCIE_FRAC=${PCIE_FRAC:-0.45} +SPEC_MIN_P=${SPEC_MIN_P:-0} # the request's draft confidence floor (the product profile: 0 with the adaptive window) +A_BIN=${A_BIN:?A_BIN}; B_BIN=${B_BIN:-$A_BIN}; A_ENV=${A_ENV:-}; B_ENV=${B_ENV:-} +SESSION_ARGS="--turns 5 --target-tokens 245000 --max-output 300 --min-final-tokens 200000" +WIN_S=${WIN_S:-20} +LIB=$DR/tools/libleleka_cupti_trace.so +mkdir -p "$OUTR" + +( cd / && sha256sum --quiet -c "$DR/MANIFEST.sha256" ) || { echo "draft-round: MANIFEST.sha256 check failed" >&2; exit 3; } +for f in "$UP" "$CORPUS/backend-api/src/lib.rs" "$D/$A_BIN/leleka-inference" "$D/$B_BIN/leleka-inference" "$DR/tools/ts-wrap.sh"; do + [ -r "$f" ] || { echo "missing $f" >&2; exit 3; } +done + +settle() { # $1 run dir + local n=0 t l + while [ $n -lt 30 ]; do + t=$(nvidia-smi --query-gpu=temperature.gpu --format=csv,noheader,nounits | head -1) + [ "${t:-99}" -le 48 ] && break + sleep 5; n=$((n + 1)) + done + echo "gpu_temp_c=$t cooled_after_s=$((n * 5))" >"$1/settle.txt" + n=0 + while [ $n -lt 24 ]; do + l=$(cut -d" " -f1 /proc/loadavg) + awk -v l="$l" 'BEGIN{exit !(l < 0.5)}' && break + sleep 5; n=$((n + 1)) + done + echo "load1=$l quiet_after_s=$((n * 5))" >>"$1/settle.txt" + { date -u +%FT%TZ; uptime; free -m | sed -n 2p; nvidia-smi --query-gpu=clocks.sm,clocks.mem,temperature.gpu,power.draw,pstate --format=csv,noheader; } >>"$1/settle.txt" +} + +watch_and_trigger() { # $1 client log, $2 trigger file, $3 out dir + for _ in $(seq 1 15000); do + if grep -q '"turn": 4' "$1" 2>/dev/null; then + printf '{"seconds": %s, "out": "%s/win-turn5", "label": "turn5"}\n' "$WIN_S" "$3" >"$2.tmp" && mv "$2.tmp" "$2" + echo "$(date +%s.%N) trigger written" >>"$3/trigger.log"; return 0 + fi + sleep 0.2 + done +} + +ours() { # $1 tag, $2 run dir, $3 bin dir, $4 extra env words + local tag=$1 R=$2 bin=$3 xenv=$4 + ( export E2E_BIN=$D/$bin E2E_OUT=$R + export LELEKA_BRINGUP_TRACE=1 LELEKA_PREFIX_TRACE=1 + export LELEKA_ORIGINAL_SERVE_EXPERT_SLOTS=auto E2E_GPU_BUDGET=${GPU_BUDGET:-32819404800} + export E2E_ENGINE_ARGS="--prefix-cache-mib auto --prefix-cache-tail reply --original-prefill-capacity 8192 --prefix-cache-block 8192 --spec-min-p ${SPEC_MIN_P:-0}" + export E2E_SAMPLE_S=10 LELEKA_CHAIN=all + export LELEKA_ORIGINAL_SERVE_EXPERT_PROFILE=$UP + unset LELEKA_FOOTPRINT_LEGACY LELEKA_ORIGINAL_SERVE_SEED_MAX_ROWS LELEKA_SM120_ATTN_DAILY LELEKA_SM120_GU_SWIGLU LELEKA_SM120_SIDE_MIXER LELEKA_SM120_PERF LELEKA_SERVE_DRAFT_AFTER_COMMIT LELEKA_PROMPT_EMBED_ALIAS LELEKA_VRAM_LEDGER LELEKA_DENSE_SLAB LELEKA_ORIGINAL_SERVE_DECODE_RESERVE_MIB LELEKA_ROUTE_TAIL_SKIP + unset LELEKA_HUGEPAGES LELEKA_BANK_THP LELEKA_DRAFT_FUSED_COMMIT LELEKA_DRAFT_ROUND LELEKA_SM120_ATTN_DAILY_MTP + export LELEKA_ORIGINAL_SERVE_SEED=off LELEKA_ORIGINAL_SERVE_PCIE_FRAC=$PCIE_FRAC + for kv in $xenv; do export "$kv"; done + { echo "tag=$tag bin=$bin extra=[$xenv]"; date -u +%FT%TZ; free -g | sed -n 2p; uptime; sha256sum "$UP" "$E2E_BIN"/leleka-inference "$E2E_BIN"/leleka-daemon "$E2E_BIN"/leleka-cli "$E2E_BIN"/strata-next + cat "$E2E_BIN/COMMIT.txt" 2>/dev/null; head -1 /data/leleka-e2e/decode/corpus/MANIFEST.txt + env | grep -E '^(LELEKA_|STRATA_|E2E_)' | sort; } >"$R/env-arm.txt" + export E2E_RUN_CMD="bash $DR/tools/ts-wrap.sh $R/client.ts.log python3 -I $D/tools/long-session.py --src $CORPUS $SESSION_ARGS" + if [ "${PROFILE:-0}" = 1 ]; then + export LELEKA_CUPTI_LIB=$LIB LELEKA_CUPTI_TRIGGER=$R/cupti.trigger LCT_MAX_SECONDS=60 LD_LIBRARY_PATH=$DR/cupti/lib:${LD_LIBRARY_PATH:-} + watch_and_trigger "$R/client.ts.log" "$R/cupti.trigger" "$R" & + W=$! + fi + bash "$D/scripts/e2e/run-e2e.sh" 2>&1 | grep -a -E "^\{|expert cache|request outcome|ready after|rc=|refus|error|Error|long_session|client exit|\[lct\]" | cut -c1-300 + if [ "${PROFILE:-0}" = 1 ]; then for _ in $(seq 1 60); do [ -e "$R/cupti.trigger.done" ] && break; sleep 1; done; kill $W 2>/dev/null; fi + echo "run-e2e done $tag $(date -u +%FT%TZ)" ) +} + +validity() { # $1 run dir + python3 -I - "$1" <<'PY' +import json, os, re, sys +d = sys.argv[1] +f = os.path.join(d, "long-session.json") +verdict = "INVALID: no long-session.json" +if os.path.exists(f): + t = json.load(open(f)) + final = (t[-1].get("input_tokens") or 0) if t else 0 + if any("error" in r for r in t): + verdict = "INVALID: a turn failed" + elif len(t) < 5 or final < 200000: + verdict = "INVALID: %d turns, final-turn input tokens %d < 200000 (short corpus?)" % (len(t), final) + else: + verdict = "VALID: 5 turns, final-turn input tokens %d" % final + wins, last = [], [] + for ln in open(os.path.join(d, "inference.log"), errors="replace"): + if ln.startswith("DBG window "): + last.append(dict((k, float(v)) for k, v in re.findall(r"(\w+)=([-\d.]+)", ln))) + elif "leleka-serve request outcome" in ln: + wins.append(last); last = [] + w = wins[-1] if wins else [] + ple = sum(x.get("ple", 0) for x in w) / max(len(w), 1) + verdict += "; turn-5 window.ple mean %.2f ms over %d windows" % (ple, len(w)) + if not w: + verdict = "INVALID: no turn-5 window lines (trace env missing?)" + elif ple >= 5: + verdict = "INVALID: turn-5 window.ple mean %.2f ms >= 5 ms (PLE scan back?)" % ple +open(os.path.join(d, "VALIDITY.txt"), "w").write(verdict + "\n") +print(os.path.basename(d), verdict) +PY +} + +LIST="" +if [ -n "${ENTRIES:-}" ]; then LIST="$ENTRIES" +else + for b in $BLOCKS; do + if [ $((b % 2)) = 1 ]; then LIST="$LIST $b:1:a $b:2:b"; else LIST="$LIST $b:1:b $b:2:a"; fi + done +fi +for ent in $LIST; do + bn=${ent%%:*}; rest=${ent#*:}; pos=${rest%%:*}; arm=${rest#*:} + tag=$(printf "b%02dp%d-%s%s" "$bn" "$pos" "$arm" "$RUN_TAG"); R=$OUTR/$tag + [ -e "$DR/STOP" ] && { echo "STOP file present, ending before $tag"; exit 0; } + got=0 + for _ in $(seq 1 1080); do + if mkdir "$LOCK" 2>/dev/null; then echo "draft-round $tag $(date -u +%FT%TZ)" >"$LOCK/owner"; got=1; break; fi + sleep 5 + done + [ $got = 1 ] || { echo "GPU lock held by: $(cat $LOCK/owner 2>/dev/null)"; exit 3; } + echo "=== $tag $(date -u +%FT%TZ)" + if [ -n "$(nvidia-smi --query-compute-apps=pid --format=csv,noheader)" ]; then + echo "GPU busy, skipping $tag"; rm -f "$LOCK/owner"; rmdir "$LOCK" 2>/dev/null; continue + fi + mkdir -p "$R"; echo "block=$bn pos=$pos arm=$arm" >"$R/ARM.txt" + settle "$R" + case $arm in + a) ours "$tag" "$R" "$A_BIN" "$A_ENV" ;; + b) ours "$tag" "$R" "$B_BIN" "$B_ENV" ;; + esac + for lg in "$R/inference.log"; do [ -r "$lg" ] && grep -a -E "arena|huge|PCIe probe|pcie_frac|CPU pool|pool workers|expert cache|memory guard|Cpus|pinned|affin" "$lg" | head -60 | cut -c1-300; done >"$R/startup.txt" + validity "$R" + echo "arm done $tag $(date -u +%FT%TZ)" + rm -f "$LOCK/owner"; rmdir "$LOCK" 2>/dev/null + sleep 15 +done +[ -r "$DR/tools/draftround-analyze.py" ] && python3 -I "$DR/tools/draftround-analyze.py" "$OUTR" > "$OUTR/ANALYSIS.$(date -u +%Y%m%dT%H%M%SZ).txt" 2>&1 +echo "draft-round job done $(date -u +%FT%TZ)" diff --git a/scripts/e2e/decode/draftround-analyze.py b/scripts/e2e/decode/draftround-analyze.py new file mode 100644 index 00000000..e84a938b --- /dev/null +++ b/scripts/e2e/decode/draftround-analyze.py @@ -0,0 +1,109 @@ +#!/usr/bin/env python3 +"""Analysis of draftround-ab.sh runs: per run all-turn tok/s (tokens over seconds), tokens/round, ms/round, span means; per arm mean/sd; block-paired b - a. + + python3 -I draftround-analyze.py [ ...] + +A run directory is /bp

-[tag]; VALIDITY.txt must start with VALID or the run is listed and left out. Per run (all five turns): + tok/s = total output tokens / total decode seconds (decode seconds of a turn = tokens / the client's decode_tok_s) + tok/round = tokens / rounds (the 'rounds=' of the request outcome lines) + ms/round = decode seconds / rounds * 1000 +Spans (LELEKA_SERVE_PROFILE, the 'DBG profile request:' line of each request) are summed over the five requests and divided by the total rounds: ms per round. +""" +import glob +import json +import math +import os +import re +import statistics +import sys + +SPANS = ["round.run_window", "round.apply_pending", "round.draft_committed", "draft.launch", "draft.finish", "commit.wait", "commit.publish", + "mtp.finish_first_step", "mtp.chain_step", "mtp.finish_ring", "gpu.mtp_chain_step", "drv.sync_compute", "drv.launch", "round.adapt_deferred"] + + +def run_stats(d): + j = json.load(open(os.path.join(d, "long-session.json"))) + toks = [r["output_tokens"] for r in j] + secs = [r["output_tokens"] / r["decode_tok_s"] for r in j] + rounds, prof = [], [] + cur = None + for ln in open(os.path.join(d, "inference.log"), errors="replace"): + if ln.startswith("DBG profile request:"): + cur = {m[0]: float(m[1]) for m in re.findall(r"(\S+?)=([\d.]+)/\d+", ln)} + elif "leleka-serve request outcome" in ln: + m = re.search(r"rounds=(\d+)", ln) + rounds.append(int(m.group(1))) + prof.append(cur or {}) + cur = None + R = sum(rounds) + out = { + "turns": [r["decode_tok_s"] for r in j], + "tok_s": sum(toks) / sum(secs), + "tok_round": sum(toks) / R if R else float("nan"), + "ms_round": sum(secs) / R * 1000 if R else float("nan"), + "rounds": R, + } + for s in SPANS: + out[s] = sum(p.get(s, 0.0) for p in prof) / R if R else float("nan") + return out + + +def sd(v): + return statistics.stdev(v) if len(v) > 1 else float("nan") + + +def main(): + runs = {} + for root in sys.argv[1:]: + for d in sorted(glob.glob(os.path.join(root, "b*p*-*"))): + if not os.path.isdir(d) or "_poor" in d: + continue + m = re.match(r"b(\d+)p(\d+)-([ab])(.*)", os.path.basename(d)) + if not m: + continue + ver = open(os.path.join(d, "VALIDITY.txt")).read().strip() if os.path.exists(os.path.join(d, "VALIDITY.txt")) else "no VALIDITY" + if not ver.startswith("VALID"): + print("%s %s (left out)" % (os.path.basename(d), ver)) + continue + try: + s = run_stats(d) + except Exception as e: # noqa + print("%s analysis failed: %s" % (os.path.basename(d), e)) + continue + runs[(root, int(m.group(1)), int(m.group(2)), m.group(3))] = s + print("%-24s %-5s %-26s %8s %8s %8s" % ("run", "pos", "turns tok/s", "tok/s", "tok/rnd", "ms/rnd")) + for (root, b, p, arm), s in sorted(runs.items(), key=lambda kv: (kv[0][1], kv[0][2])): + print("%-24s b%02dp%d %-26s %8.1f %8.3f %8.3f" % (os.path.basename(root.rstrip("/")) + "/" + arm, b, p, " ".join("%.0f" % t for t in s["turns"]), s["tok_s"], s["tok_round"], s["ms_round"])) + arms = {} + for (root, b, p, arm), s in runs.items(): + arms.setdefault(arm, []).append(s) + print() + for arm, ss in sorted(arms.items()): + print("arm %s n=%d tok/s %.2f (sd %.2f, %.1f..%.1f) tok/round %.3f (sd %.3f) ms/round %.3f (sd %.3f)" % ( + arm, len(ss), statistics.mean(s["tok_s"] for s in ss), sd([s["tok_s"] for s in ss]), min(s["tok_s"] for s in ss), max(s["tok_s"] for s in ss), + statistics.mean(s["tok_round"] for s in ss), sd([s["tok_round"] for s in ss]), statistics.mean(s["ms_round"] for s in ss), sd([s["ms_round"] for s in ss]))) + print("\nspans, ms per round (mean over the arm's runs):") + print("%-26s" % "span", *["%10s" % a for a in sorted(arms)], "%10s" % "b - a") + for sp in SPANS: + vals = {a: statistics.mean(s[sp] for s in ss) for a, ss in arms.items()} + print("%-26s" % sp, *["%10.3f" % vals[a] for a in sorted(arms)], "%10.3f" % (vals.get("b", float("nan")) - vals.get("a", float("nan")))) + # block pairs + byb = {} + for (root, b, p, arm), s in runs.items(): + byb.setdefault((root, b), {})[arm] = s + pairs = [(k, v["a"], v["b"]) for k, v in sorted(byb.items()) if "a" in v and "b" in v] + if pairs: + print("\nblock-paired (same block, b - a):") + for key, name in (("tok_s", "tok/s"), ("tok_round", "tok/round"), ("ms_round", "ms/round")): + d = [pb[key] - pa[key] for _, pa, pb in pairs] + rel = [100.0 * (pb[key] - pa[key]) / pa[key] for _, pa, pb in pairs] + se = sd(d) / math.sqrt(len(d)) if len(d) > 1 else float("nan") + print(" %-10s per block %s mean %+.3f (sd %.3f, se %.3f) %+.2f %% blocks with b > a: %d of %d" % ( + name, " ".join("%+.3f" % x for x in d), statistics.mean(d), sd(d), se, statistics.mean(rel), sum(1 for x in d if x > 0), len(d))) + for sp in ("round.draft_committed", "draft.finish", "commit.wait", "commit.publish", "mtp.finish_first_step"): + d = [pb[sp] - pa[sp] for _, pa, pb in pairs] + print(" %-22s per block %s mean %+.3f ms/round" % (sp, " ".join("%+.3f" % x for x in d), statistics.mean(d))) + + +if __name__ == "__main__": + main() diff --git a/scripts/e2e/decode/draftround-id.sh b/scripts/e2e/decode/draftround-id.sh new file mode 100644 index 00000000..b3281c82 --- /dev/null +++ b/scripts/e2e/decode/draftround-id.sh @@ -0,0 +1,82 @@ +#!/usr/bin/env bash +# draft-round identity gate (bitwise): teacher-forced replay of the 256k-class capture night5-long-256k (5 requests, recorded replies, decode capped at MAX_NEW forced tokens +# each), production shape, top-16 logprobs of every row and the draft trace (LELEKA_TRACE_DRAFT=1: every draft's ids and IEEE bits of its probabilities), seed OFF, ONE test binary +# (dt/$ID_BIN) for all processes, one process per setting, two arms in each (I1 I2: the A/A floor). HOLDER JOB (copy of footprint3-id.sh). +# ID_BIN test binary directory name under /data/leleka-e2e/decode/dt (required) +# P1_ENV extra env of the reference process (default: nothing) +# P2_ENV extra env of the changed process (required) +# P3_ENV, P4_ENV optional third and fourth process +# ID_OUT output directory (required) MAX_NEW (default 240) ADAPT (default 4: the adaptive tier swaps, as dt-id2) +# SKIP_P1=1 reuse $ID_OUT/idP1.full of an earlier job (same binary, same environment) as the reference instead of running it again +# ~10 GPU-min a process. Verdict: q_pair (top-16 logprob rows, all common rows must be identical) and draftround-idcmp.py (the draft trace lines must be identical). +set -uo pipefail +LOCK=/data/leleka-e2e/gpu.lock +D=/data/leleka-e2e/decode/dt +DR=/data/leleka-e2e/draft-round +O=${ID_OUT:?ID_OUT} +ID_BIN=${ID_BIN:?ID_BIN} +MAX_NEW=${MAX_NEW:-240} +ADAPT=${ADAPT:-4} +mkdir -p "$O" +( cd / && sha256sum --quiet -c "$DR/MANIFEST.sha256" ) || { echo "draft-round: MANIFEST.sha256 check failed" >&2; exit 3; } +export LD_LIBRARY_PATH=$HOME/cuda-toolkits/cublas-12.9.1.4/lib:$HOME/cuda-toolkits/13.2.2/lib64:${LD_LIBRARY_PATH:-} +A=$HOME/leleka-gates/assets +G=$HOME/work/gpu-runs +CAP=/data/leleka-e2e/sm120/capture +export LELEKA_STRA169_KAR_PROVENANCE=$A/qwen-iq3-s-l2-v4.kar.provenance.json +export LELEKA_STRA169_IQ3S_SHARD0=$A/model/Qwen3.8-Flash-Next-GSQ-RCO-IQ3_S-00001-of-00002.gguf +export LELEKA_STRA169_IQ3S_SHARD1=$A/model/Qwen3.8-Flash-Next-GSQ-RCO-IQ3_S-00002-of-00002.gguf +export LELEKA_STRA169_MTP_PACK=$A/data/mtp-rt LELEKA_STRA169_MTP_STAGING=$G/mtp-staging-own LELEKA_ORIGINAL_SERVE_BUDGET_GIB=30 +export LELEKA_ORIGINAL_SERVE_EXPERT_PER_LAYER=yes LELEKA_ORIGINAL_SERVE_PCIE_FRAC=0.45 +export LELEKA_SMOKE_PROMPT_CACHE=0 LELEKA_SERVE_PROFILE=1 LELEKA_GRAPH_EXEC_REUSE=off +export LELEKA_ORIGINAL_SERVE_EXPERT_PROFILE=/data/leleka-e2e/decode/assets/expert-profile-upstream.bin +export LELEKA_ORIGINAL_SERVE_RT_DIR=$A/data/mtp-rt +export LELEKA_ORIGINAL_SERVE_EXPERT_SLOTS=8000 LELEKA_CHAIN=all +export LELEKA_ORIGINAL_SERVE_ADAPT_EVERY=$ADAPT LELEKA_ORIGINAL_SERVE_SEED=off LELEKA_ORIGINAL_SERVE_CPU_WORKERS=1 LELEKA_SPEC=4 LELEKA_SPEC_SUFFIX=0 +unset LELEKA_SERVE_DRAFT_AFTER_COMMIT LELEKA_PROMPT_EMBED_ALIAS LELEKA_VRAM_LEDGER LELEKA_DENSE_SLAB LELEKA_FOOTPRINT_LEGACY LELEKA_SM120_ATTN_DAILY_MTP LELEKA_DRAFT_FUSED_COMMIT LELEKA_DRAFT_ROUND +for f in $D/$ID_BIN $D/tools/q_pair.py $D/tools/q_tail_gate.py $DR/tools/draftround-idcmp.py $CAP/night5-long-256k; do + [ -e "$f" ] || { echo "missing $f" >&2; exit 3; } +done +sha256sum $D/$ID_BIN | tee $O/rt.sha256 +shape="reply@8192/8192!orig!fast!nocluster!store!qpf!gpool!mspan" +run() { # label extra-env + got=0 + for i in $(seq 1 1080); do + if mkdir $LOCK 2>/dev/null; then echo "draft-round identity $1 $(date -u +%FT%TZ)" >$LOCK/owner; got=1; break; fi + sleep 5 + done + [ $got = 1 ] || { echo "GPU lock held by: $(cat $LOCK/owner 2>/dev/null)"; return 3; } + avail=$(awk '/MemAvailable/{print int($2/1048576)}' /proc/meminfo); echo "=== $1 extra=[$2] MemAvailable GiB: $avail" + if [ "$avail" -lt 60 ]; then echo "abort: less than 60 GiB available"; rm -f $LOCK/owner; rmdir $LOCK; return 4; fi + date -u +%FT%TZ + env $2 LELEKA_TRACE_DRAFT=1 LELEKA_ORIGINAL_SERVE_REPLAY=yes LELEKA_BRINGUP_TRACE=1 LELEKA_REPLAY_DIR=$CAP/night5-long-256k LELEKA_PREFIX_TRACE=1 LELEKA_REPLAY_PREFIX_MIB=6000 LELEKA_TRACE_PREFILL_R=1 LELEKA_TRACE_LOGPROBS=16 \ + LELEKA_REPLAY_MAX_NEW=$MAX_NEW LELEKA_REPLAY_FORCE=1 LELEKA_REPLAY_ARMS="I1=$shape,I2=$shape" \ + nice -n 5 $D/$ID_BIN --ignored --exact --test-threads=1 --nocapture backend::original_serve_replay::original_serve_replay_smoke > $O/$1.full 2>&1 + echo "rc=$? label=$1"; date -u +%FT%TZ + grep -a -E "^REPLAY #|test result|panicked|FAILED|expert cache [0-9]+ slots" $O/$1.full | cut -c1-200 | tail -14 + grep -a -c "^DRAFT " $O/$1.full + rm -f $LOCK/owner; rmdir $LOCK 2>/dev/null + sleep 15 +} +if [ "${SKIP_P1:-0}" = 1 ]; then [ -s "$O/idP1.full" ] || { echo "SKIP_P1 set but $O/idP1.full is missing" >&2; exit 3; }; else run idP1 "${P1_ENV:-LELEKA_X=1}"; fi +run idP2 "${P2_ENV:?P2_ENV}" +PROCS="idP1 idP2" +if [ -n "${P3_ENV:-}" ]; then run idP3 "$P3_ENV"; PROCS="idP1 idP2 idP3"; fi +if [ -n "${P4_ENV:-}" ]; then run idP4 "$P4_ENV"; PROCS="$PROCS idP4"; fi +T=$D/tools +for p in $PROCS; do echo "== q_tail_gate $p"; python3 $T/q_tail_gate.py $O/$p.full $CAP/night5-long-256k 2>&1 | tail -8; done +python3 - < 0 + + +def main(): + if len(sys.argv) < 3: + print(__doc__) + sys.exit(2) + a, b = draft_lines(sys.argv[1]), draft_lines(sys.argv[2]) + ok = cmp(a, b, "B against A") + if len(sys.argv) > 3: + cmp(a, draft_lines(sys.argv[3]), "control (A2 against A)") + half = len(a) // 2 + if len(a) % 2 == 0 and half: + # arms I1 and I2 of one process are the same configuration: the A/A inside the process + cmp(a[:half], a[half:], "arm I2 against arm I1 inside A") + print("DRAFT VERDICT:", "IDENTICAL" if ok else "DIFFERENT") + sys.exit(0 if ok else 1) + + +if __name__ == "__main__": + main() diff --git a/scripts/e2e/decode/draftround-install.sh b/scripts/e2e/decode/draftround-install.sh new file mode 100644 index 00000000..3de7dce1 --- /dev/null +++ b/scripts/e2e/decode/draftround-install.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +# Install the draft-round measurement inputs on rnr5090 (run on the server from the directory that holds the scripts): +# bash draftround-install.sh [extra bin dir under dt/ ...] +# Copies the tools to /data/leleka-e2e/draft-round/tools (read-only afterwards) and writes MANIFEST.sha256 with the digest of every input a run depends on: the tools, the CUPTI +# tracer, the ours binaries named on the command line (bin-main-ffd9322 is always included), the harness, the upstream profile and the corpus manifest. Jobs refuse to start on a mismatch. +set -euo pipefail +DR=/data/leleka-e2e/draft-round +D=/data/leleka-e2e/decode/dt +SRC=$(cd "$(dirname "$0")" && pwd) +mkdir -p "$DR/tools" +chmod -R u+w "$DR/tools" 2>/dev/null || true +for f in draftround-ab.sh draftround-id.sh draftround-idcmp.py draftround-kernels.py draftround-timeline.py draftround-width.py draftround-install.sh ts-wrap.sh draftround-analyze.py; do [ -e "$SRC/$f" ] && install -m 0444 "$SRC/$f" "$DR/tools/$f"; done +[ -e "$DR/tools/libleleka_cupti_trace.so" ] || install -m 0444 "$HOME/work/cupti-trace/libleleka_cupti_trace.so" "$DR/tools/libleleka_cupti_trace.so" +chmod a-w "$DR/tools" +BINS="bin-main-ffd9322 $*" +{ + sha256sum "$DR"/tools/* "$DR"/cupti/lib/libcupti.so.2026.1.2 + for b in $BINS; do for x in leleka-inference leleka-daemon leleka-cli strata-next; do echo "$(sha256sum "$D/$b/$x" | cut -d' ' -f1) $D/$b/$x"; done; done + sha256sum "$D/tools/long-session.py" "$D/scripts/e2e/run-e2e.sh" "$D/scripts/e2e/sample_env.sh" \ + /data/leleka-e2e/decode/assets/expert-profile-upstream.bin /data/leleka-e2e/decode/corpus/MANIFEST.txt +} >"$DR/MANIFEST.sha256.new" +mv "$DR/MANIFEST.sha256.new" "$DR/MANIFEST.sha256" +echo "installed; $(wc -l <"$DR/MANIFEST.sha256") inputs in $DR/MANIFEST.sha256" diff --git a/scripts/e2e/decode/draftround-kernels.py b/scripts/e2e/decode/draftround-kernels.py new file mode 100644 index 00000000..25d32616 --- /dev/null +++ b/scripts/e2e/decode/draftround-kernels.py @@ -0,0 +1,89 @@ +#!/usr/bin/env python3 +"""Per-kernel table of the small graphs of a decode round (commit, MTP round graph, MTP chain steps) from a CUPTI window (tools/cupti-trace, lct.py). + + python3 -I draftround-kernels.py [--lct-dir /data/leleka-e2e/decode/tools] [--seq CLASS] [--top N] + +A small graph launch is classified by its kernel-name signature: `commit` (has verify_gdn_conv_commit_kernel), `round` (the first MTP graph of a draft: its kernel count is +160..173 by rows), `step` (113 kernels). For every class: launches, GPU span (first kernel start to last kernel end), kernel sum, in-graph idle (span - kernel union), then one line +per kernel name: calls per graph, mean duration, total per graph, share of the span. --seq CLASS prints the ordered kernel sequence of the median graph with start offsets and gaps. +""" +import argparse +import collections +import os +import statistics +import sys + + +def main(): + ap = argparse.ArgumentParser() + ap.add_argument("dir") + ap.add_argument("--lct-dir", default="/data/leleka-e2e/decode/tools") + ap.add_argument("--seq", default=None) + ap.add_argument("--top", type=int, default=40) + a = ap.parse_args() + sys.path.insert(0, a.lct_dir) + import lct as L + t = L.Trace(a.dir) + gl = {x.corr: x for x in t.apis if "GraphLaunch" in t.names.get(x.name, "")} + byc = collections.defaultdict(list) + for k in t.kernels: + byc[k.corr].append(k) + classes = collections.defaultdict(list) + for corr, x in gl.items(): + ks = sorted(byc.get(corr, []), key=lambda k: k.start) + if not ks or len(ks) >= 1000: + continue + names = [t.names.get(k.name, "?") for k in ks] + if any("conv_commit" in n or "draft_commit" in n for n in names): + cl = "commit" + elif len(ks) == 113: + cl = "step" + elif 140 <= len(ks) <= 180 and len(ks) != 182: + cl = "round" + else: + cl = "other%d" % len(ks) + classes[cl].append((ks, names)) + for cl, gs in sorted(classes.items()): + spans = [(ks[-1].end - ks[0].start) / 1e3 for ks, _ in gs] + ksum = [sum(k.end - k.start for k in ks) / 1e3 for ks, _ in gs] + # union of kernel intervals (concurrent branches in a graph overlap) + un = [] + for ks, _ in gs: + tot, cur_s, cur_e = 0, None, None + for k in ks: + if cur_e is None or k.start > cur_e: + if cur_e is not None: + tot += cur_e - cur_s + cur_s, cur_e = k.start, k.end + else: + cur_e = max(cur_e, k.end) + tot += cur_e - cur_s + un.append(tot / 1e3) + print("== %s: %d launches, kernels/graph %s, span mean %.1f us (p10 %.1f p90 %.1f), kernel sum %.1f us, union busy %.1f us, in-graph idle %.1f us" + % (cl, len(gs), sorted(set(len(g[0]) for g in gs)), statistics.mean(spans), sorted(spans)[len(spans) // 10], sorted(spans)[len(spans) * 9 // 10], + statistics.mean(ksum), statistics.mean(un), statistics.mean(spans) - statistics.mean(un))) + agg = collections.defaultdict(lambda: [0, 0.0, 0.0]) + for ks, names in gs: + for k, n in zip(ks, names): + r = agg[n] + r[0] += 1 + r[1] += (k.end - k.start) / 1e3 + r[2] += k.regs if False else 0 + rows = sorted(agg.items(), key=lambda kv: -kv[1][1]) + sp = statistics.mean(spans) + print(" %-64s %8s %9s %10s %7s" % ("kernel", "calls/g", "mean us", "total us/g", "%span")) + for n, (c, tot, _) in rows[: a.top]: + print(" %-64s %8.2f %9.2f %10.2f %6.1f%%" % (n[:64], c / len(gs), tot / c, tot / len(gs), 100.0 * tot / len(gs) / sp)) + if a.seq == cl: + ks, names = sorted(gs, key=lambda g: g[0][-1].end - g[0][0].start)[len(gs) // 2] + t0 = ks[0].start + prev_end = t0 + print(" -- median graph, ordered kernels: idx start_us dur_us gap_us grid block name") + for i, (k, n) in enumerate(zip(ks, names)): + print(" %3d %8.1f %7.2f %6.2f %s x %s %s" % (i, (k.start - t0) / 1e3, (k.end - k.start) / 1e3, (k.start - prev_end) / 1e3, + (k.gx, k.gy, k.gz), (k.bx, k.by, k.bz), n[:70])) + prev_end = max(prev_end, k.end) + + +if __name__ == "__main__": + main() diff --git a/scripts/e2e/decode/draftround-timeline.py b/scripts/e2e/decode/draftround-timeline.py new file mode 100644 index 00000000..1c382a28 --- /dev/null +++ b/scripts/e2e/decode/draftround-timeline.py @@ -0,0 +1,61 @@ +#!/usr/bin/env python3 +"""Timeline of a decode round from a CUPTI window: for each verify window graph followed by one commit graph, one MTP round graph and 0..n step graphs, the mean gaps +(verify end -> commit launch call / first kernel, -> round graph first kernel, launch call lengths, step gaps, draft end vs commit end, last draft kernel -> next verify). + + python3 -I draftround-timeline.py + +Classes by kernel count and names: V >= 1000 kernels (verify window), C has verify_gdn_conv_commit_kernel or draft_commit_* (the fused commit graph), S exactly 113 kernels (MTP step), R 140-200 kernels (MTP round graph). +""" +import sys, collections, statistics +sys.path.insert(0,"/data/leleka-e2e/decode/tools") +import lct as L +t = L.Trace(sys.argv[1]) +gl = {x.corr: x for x in t.apis if "GraphLaunch" in t.names.get(x.name, "")} +byc = collections.defaultdict(list) +for k in t.kernels: byc[k.corr].append(k) +G=[] +for corr,x in gl.items(): + ks=sorted(byc.get(corr,[]),key=lambda k:k.start) + if not ks: continue + names=[t.names.get(k.name,"?") for k in ks] + if len(ks)>=1000: cl="V" + elif any("conv_commit" in n or "draft_commit" in n for n in names): cl="C" + elif len(ks)==113: cl="S" + elif 140<=len(ks)<=200: cl="R" + else: cl="?" + G.append((ks[0].start, ks[-1].end, cl, x.start, x.end)) +G.sort() +# rounds: V then C, R, S* +rows=[] +i=0 +while i < len(G): + if G[i][2]=="V": + j=i+1; seq=[] + while j C launch call start"].append(c[3]-v[1]) + acc["V end -> C first kernel"].append(c[0]-v[1]) + acc["C gpu span"].append(c[1]-c[0]) + acc["V end -> R first kernel"].append(r[0]-v[1]) + acc["R launch call (start->end)"].append(r[4]-r[3]) + acc["R gpu span"].append(r[1]-r[0]) + last=r + for k,s in enumerate(S): + acc["gap before step (prev end -> launch call start)"].append(s[3]-last[1]) + acc["gap before step (prev end -> first kernel)"].append(s[0]-last[1]) + acc["step gpu span"].append(s[1]-s[0]) + last=s + acc["last draft kernel end -> next V first kernel"].append(nv[0]-last[1]) + acc["C end vs draft end (draft end - C end)"].append(last[1]-c[1]) + acc["V end -> next V start (round)"].append(nv[0]-v[1]) + acc["nsteps"].append(len(S)*1e3) +for k,v in acc.items(): print("%-55s n=%4d mean %8.1f us p10 %8.1f p90 %8.1f"%(k,len(v),f(v),sorted(v)[len(v)//10]/1e3,sorted(v)[len(v)*9//10]/1e3)) diff --git a/scripts/e2e/decode/draftround-width.py b/scripts/e2e/decode/draftround-width.py new file mode 100644 index 00000000..af0be5d6 --- /dev/null +++ b/scripts/e2e/decode/draftround-width.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python3 +"""Window width and acceptance per arm of a draftround-ab.sh series: mean verified rows per round (round.T), mean accepted drafts per round (round.acc), drafts per +round (mtp.chain_step calls + 1 round graph = steps) from the 'DBG profile request:' lines; block-paired b - a. + + python3 -I draftround-width.py +""" +import glob, os, re, statistics, sys + +def stats(d): + rounds = T = acc = steps = 0 + cur = None + for ln in open(os.path.join(d, "inference.log"), errors="replace"): + if ln.startswith("DBG profile request:"): + cur = {m[0]: (float(m[1]), int(m[2])) for m in re.findall(r"(\S+?)=([\d.]+)/(\d+)", ln)} + elif "leleka-serve request outcome" in ln and cur: + r = int(re.search(r"rounds=(\d+)", ln).group(1)) + rounds += r + T += cur.get("round.T", (0, 0))[0] + acc += cur.get("round.acc", (0, 0))[0] + steps += cur.get("mtp.chain_step", (0, 0))[1] + cur = None + return rounds, T / rounds, acc / rounds, steps / rounds + +root = sys.argv[1] +by = {} +for d in sorted(glob.glob(os.path.join(root, "b*p*-*"))): + m = re.match(r"b(\d+)p(\d+)-([ab])", os.path.basename(d)) + if not m or not os.path.exists(os.path.join(d, "VALIDITY.txt")) or not open(os.path.join(d, "VALIDITY.txt")).read().startswith("VALID"): + continue + by.setdefault(int(m.group(1)), {})[m.group(3)] = stats(d) +print("block arm rounds rows/round accepted/round chain steps/round") +for b, v in sorted(by.items()): + for arm in "ab": + if arm in v: + print("%5d %s %6d %10.3f %14.3f %17.3f" % (b, arm, *v[arm])) +pairs = [(v["a"], v["b"]) for v in by.values() if "a" in v and "b" in v] +for i, name in ((1, "rows/round"), (2, "accepted/round"), (3, "chain steps/round")): + d = [pb[i] - pa[i] for pa, pb in pairs] + print("b - a %-18s per block %s mean %+.3f (se %.3f)" % (name, " ".join("%+.3f" % x for x in d), statistics.mean(d), statistics.stdev(d) / len(d) ** 0.5)) diff --git a/scripts/gpu-bringup/extra-seal-plan.json b/scripts/gpu-bringup/extra-seal-plan.json index 2fc54670..9b922e00 100644 --- a/scripts/gpu-bringup/extra-seal-plan.json +++ b/scripts/gpu-bringup/extra-seal-plan.json @@ -874,6 +874,56 @@ }, "group": "sm120-decode", "optional": false + }, + { + "cu": "crates/cuda-driver/src/draft_commit.cu", + "ptx": "crates/cuda-driver/src/draft_commit.ptx", + "flags": [ + "-ptx", + "-O3", + "-arch=sm_120", + "-std=c++17", + "--fmad=true", + "--ftz=false" + ], + "include_profile": "standard", + "policy": "precise (--fmad=true --ftz=false: the recipe of original_verify.cu, which the Original does not build fast-math; draft-round fused GDN commit, bitwise the 72 kernels it replaces)", + "entries": [ + "draft_commit_gdn_layers" + ], + "encoding": "concat_include_str", + "rust_fields_to_fill": { + "original_verify_window_draft.rs": [ + "DRAFT_COMMIT.sha" + ] + }, + "group": "draft-round", + "optional": false + }, + { + "cu": "crates/cuda-driver/src/draft_commit_qsa.cu", + "ptx": "crates/cuda-driver/src/draft_commit_qsa.ptx", + "flags": [ + "--ptx", + "-std=c++17", + "-O3", + "-arch=sm_120", + "--fmad=true", + "--use_fast_math" + ], + "include_profile": "standard", + "policy": "fast-math, the RESEALED recipe of original_verify_qsa.cu (the Original compiles native_qsa_indexer with --use_fast_math: __powf/cos.approx/sin.approx); draft-round fused QSA commit, bitwise the 108 kernels it replaces", + "entries": [ + "draft_commit_qsa_layers" + ], + "encoding": "concat_include_str", + "rust_fields_to_fill": { + "original_verify_window_draft.rs": [ + "DRAFT_COMMIT_QSA.sha" + ] + }, + "group": "draft-round", + "optional": false } ] } diff --git a/tools/draft-round/commit_probe.cpp b/tools/draft-round/commit_probe.cpp new file mode 100644 index 00000000..e3d38d60 --- /dev/null +++ b/tools/draft-round/commit_probe.cpp @@ -0,0 +1,244 @@ +// draft-round: model-free probe of the fused verifier commit kernels (crates/cuda-driver/src/draft_commit.ptx). Each fused kernel is run next to the sequence of kernels of +// the commit graph it replaces (original_verify.ptx / original_verify_qsa.ptx) on real-size random inputs and EVERY output byte is compared; the two are also timed inside a +// CUDA graph. Prints "RESULT name key=value" lines; exits 1 if any comparison differs. Never touches the model. +// commit_probe PTXDIR PTXDIR holds original_verify.ptx, original_verify_qsa.ptx, draft_commit.ptx and draft_commit_qsa.ptx (copies of crates/cuda-driver/src/) +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define CU(x) do { CUresult r_ = (x); if (r_ != CUDA_SUCCESS) { const char* s_ = nullptr; cuGetErrorString(r_, &s_); fprintf(stderr, "CUDA error %s at %s:%d: %s\n", #x, __FILE__, __LINE__, s_ ? s_ : "?"); exit(2); } } while (0) + +static int g_fail = 0; +static uint64_t g_rng = 0x9e3779b97f4a7c15ull; +static uint32_t rnd() { g_rng ^= g_rng << 13; g_rng ^= g_rng >> 7; g_rng ^= g_rng << 17; return (uint32_t)(g_rng >> 16); } +static float rndf() { return (float)(rnd() & 0xffffff) / 16777216.0f * 2.0f - 1.0f; } // [-1, 1) + +static std::string read_file(const std::string& p) { + FILE* f = fopen(p.c_str(), "rb"); + if (!f) { fprintf(stderr, "cannot open %s\n", p.c_str()); exit(2); } + std::string s; char buf[1 << 16]; size_t n; + while ((n = fread(buf, 1, sizeof buf, f)) > 0) s.append(buf, n); + fclose(f); + return s; +} +static CUmodule load_module(const std::string& p) { + std::string s = read_file(p); + s.push_back('\0'); + CUmodule m; char log[8192] = {}; + CUjit_option opt[] = {CU_JIT_ERROR_LOG_BUFFER, CU_JIT_ERROR_LOG_BUFFER_SIZE_BYTES}; + void* val[] = {log, (void*)(uintptr_t)sizeof log}; + CUresult r = cuModuleLoadDataEx(&m, s.data(), 2, opt, val); + if (r != CUDA_SUCCESS) { fprintf(stderr, "load %s failed: %d %s\n", p.c_str(), (int)r, log); exit(2); } + return m; +} +static CUfunction get_fn(CUmodule m, const char* name) { + CUfunction f; CUresult r = cuModuleGetFunction(&f, m, name); + if (r != CUDA_SUCCESS) { fprintf(stderr, "no entry %s\n", name); exit(2); } + return f; +} +struct Dev { + CUdeviceptr p = 0; size_t n = 0; + void alloc(size_t bytes) { n = bytes; CU(cuMemAlloc(&p, bytes ? bytes : 1)); CU(cuMemsetD8(p, 0, bytes ? bytes : 1)); CU(cuCtxSynchronize()); } + void put(const void* h, size_t bytes) { CU(cuMemcpyHtoD(p, h, bytes)); CU(cuCtxSynchronize()); } + std::vector get() const { std::vector v(n); CU(cuMemcpyDtoH(v.data(), p, n)); return v; } +}; +static bool same(const char* what, const std::vector& a, const std::vector& b) { + if (a.size() != b.size()) { printf("MISMATCH %s: size %zu vs %zu\n", what, a.size(), b.size()); g_fail++; return false; } + size_t bad = 0, first = (size_t)-1; + for (size_t i = 0; i < a.size(); ++i) if (a[i] != b[i]) { if (first == (size_t)-1) first = i; ++bad; } + if (bad) { printf("MISMATCH %s: %zu of %zu bytes differ (first at %zu)\n", what, bad, a.size(), first); g_fail++; return false; } + return true; +} +static CUstream g_s; +static double time_graph(const std::function& body, int iters = 20) { + CUgraph g; CUgraphExec ge; + CU(cuStreamBeginCapture(g_s, CU_STREAM_CAPTURE_MODE_GLOBAL)); + body(); + CU(cuStreamEndCapture(g_s, &g)); + CU(cuGraphInstantiateWithFlags(&ge, g, 0)); + for (int i = 0; i < 3; ++i) CU(cuGraphLaunch(ge, g_s)); + CU(cuStreamSynchronize(g_s)); + CUevent a, b; CU(cuEventCreate(&a, 0)); CU(cuEventCreate(&b, 0)); + std::vector v; + for (int i = 0; i < iters; ++i) { + CU(cuEventRecord(a, g_s)); CU(cuGraphLaunch(ge, g_s)); CU(cuEventRecord(b, g_s)); CU(cuEventSynchronize(b)); + float ms; CU(cuEventElapsedTime(&ms, a, b)); v.push_back(ms * 1000.0); + } + std::sort(v.begin(), v.end()); + return v[v.size() / 2]; +} +static void launch(CUfunction f, unsigned gx, unsigned gy, unsigned bx, unsigned by, void** args) { + CU(cuLaunchKernel(f, gx, gy, 1, bx, by, 1, 0, g_s, args, nullptr)); +} + +constexpr int H = 48, C = 10240, T = 8; +constexpr size_t STATE_WORDS = (size_t)128 * 48 * 128, HIST_WORDS = (size_t)10240 * 3; +constexpr size_t LAYER_BYTES = (STATE_WORDS + HIST_WORDS) * 4; + +struct GdnOperands { + Dev A, B, dqkv, dh, dg, db, dz, dgam, ydummy, commit; +}; +// the Original's commit graph for the GDN layers: per layer conv commit + recurrence replay +static void gdn_original(GdnOperands& o, CUfunction conv, CUfunction step) { + const float eps = 1e-6f; + for (int i = 0; i < 36; ++i) { + CUdeviceptr hist = o.A.p + (size_t)i * LAYER_BYTES + STATE_WORDS * 4, state = o.A.p + (size_t)i * LAYER_BYTES; + CUdeviceptr q = o.dqkv.p + (size_t)i * T * C * 4, hh = o.dh.p + (size_t)i * T * C * 4, g = o.dg.p + (size_t)i * T * H * 4, b = o.db.p + (size_t)i * T * H * 4, gm = o.dgam.p + (size_t)i * 128 * 4; + int c = C; CUdeviceptr nk = o.commit.p; + void* a1[] = {&hist, &q, &c, &nk}; + launch(conv, (C + 255) / 256, 1, 256, 1, a1); + CUdeviceptr zz = o.dz.p, yd = o.ydummy.p; int ci = C, hk = 16, hv = 48, tt = T, tob = 0; float e = eps; + void* a2[] = {&state, &hh, &ci, &g, &b, &zz, &gm, &e, &yd, &hk, &hv, &tt, &nk, &tob}; + launch(step, 48, 1, 128, 4, a2); + } +} +static void gdn_fused(GdnOperands& o, CUfunction fused) { + uint64_t w[9] = {o.B.p, (uint64_t)LAYER_BYTES, (uint64_t)(STATE_WORDS * 4), o.dqkv.p, o.dh.p, o.dg.p, o.db.p, o.commit.p, (uint64_t)T}; + void* af[] = {w}; + launch(fused, 48 + 20, 36, 128, 4, af); +} + +static void test_gdn(CUmodule mo, CUmodule md) { + CUfunction conv = get_fn(mo, "verify_gdn_conv_commit_kernel"), step = get_fn(mo, "verify_gdn_step_norm_multi_kernel"), fused = get_fn(md, "draft_commit_gdn_layers"); + const size_t canon = 36 * LAYER_BYTES; + std::vector st(canon / 4), qkv((size_t)36 * T * C), h((size_t)36 * T * C), gate((size_t)36 * T * H), beta((size_t)36 * T * H), z((size_t)T * 6144), gamma(36 * 128); + for (auto& x : qkv) x = rndf(); + for (auto& x : h) x = rndf() * 0.3f; + for (auto& x : gate) x = -(rndf() * 0.5f + 0.5f) * 2.0f; + for (auto& x : beta) x = rndf() * 0.5f + 0.5f; + for (auto& x : z) x = rndf(); + for (auto& x : gamma) x = rndf() * 0.5f + 1.0f; + GdnOperands o; + o.A.alloc(canon); o.B.alloc(canon); o.dqkv.alloc(qkv.size() * 4); o.dh.alloc(h.size() * 4); o.dg.alloc(gate.size() * 4); o.db.alloc(beta.size() * 4); o.dz.alloc(z.size() * 4); o.dgam.alloc(gamma.size() * 4); + o.ydummy.alloc((size_t)T * 6144 * 4); o.commit.alloc((T + 2) * 4); + o.dqkv.put(qkv.data(), qkv.size() * 4); o.dh.put(h.data(), h.size() * 4); o.dg.put(gate.data(), gate.size() * 4); o.db.put(beta.data(), beta.size() * 4); o.dz.put(z.data(), z.size() * 4); o.dgam.put(gamma.data(), gamma.size() * 4); + int cases = 0; + for (int seed = 0; seed < 4; ++seed) { + for (int n = 0; n <= T; ++n) { + for (auto& x : st) x = rndf() * (seed ? 0.5f : 2.0f); + o.A.put(st.data(), canon); o.B.put(st.data(), canon); + int32_t cm[T + 2] = {n, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + o.commit.put(cm, sizeof cm); + gdn_original(o, conv, step); + gdn_fused(o, fused); + CU(cuStreamSynchronize(g_s)); + char what[96]; snprintf(what, sizeof what, "gdn seed %d n_keep %d (state+history of 36 layers)", seed, n); + same(what, o.A.get(), o.B.get()); + ++cases; + } + } + printf("RESULT gdn cases=%d\n", cases); + int32_t cm[T + 2] = {3, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + o.commit.put(cm, sizeof cm); + double t_orig = time_graph([&] { gdn_original(o, conv, step); }); + double t_fused = time_graph([&] { gdn_fused(o, fused); }); + printf("RESULT gdn_time n_keep=3 original_us=%.1f fused_us=%.1f\n", t_orig, t_fused); +} + +constexpr int D = 128; +struct QsaArgs { + uint64_t tail[12], dead[12], pooled[12], block_pos[12], gamma[12]; + uint64_t raw_base, snap_base, commit, mtab, rows, max_cells, pos_base; + float epsilon, theta_scale, freq_scale, corr_low, corr_high, ext_factor, mscale, pad; +}; +struct Rope { float theta_scale, freq_scale, corr_low, corr_high, ext_factor, mscale; }; +struct QsaOperands { + Dev tail[2][12], dead[2][12], pooled[2][12], bpos[2][12], gam[12], raw, snap, commit; +}; +static const int kMaxCells = 64 * 4; +static void qsa_original(QsaOperands& q, CUfunction app, CUfunction cpy, const Rope& r) { + for (int l = 0; l < 12; ++l) { + CUdeviceptr dst = q.tail[0][l].p, src = q.snap.p + (size_t)l * 1536; int64_t n4 = 96; + void* ac[] = {&dst, &src, &n4}; + launch(cpy, 1, 1, 256, 1, ac); + for (int row = 0; row < T; ++row) { + CUdeviceptr rw = q.raw.p + ((size_t)l * T + row) * 512, pd = q.commit.p + (2 + row) * 4, gm = q.gam[l].p, tl = q.tail[0][l].p, dd = q.dead[0][l].p, po = q.pooled[0][l].p, bpp = q.bpos[0][l].p, mt = 0, rc = 0, rs = 0; + int pb = 0, mc = kMaxCells, rm = 0; float e = 1e-6f, th = r.theta_scale, fs = r.freq_scale, cl = r.corr_low, ch = r.corr_high, ex = r.ext_factor, ms = r.mscale; + void* aa[] = {&rw, &pd, &pb, &gm, &e, &tl, &dd, &po, &bpp, &mc, &th, &fs, &cl, &ch, &ex, &ms, &mt, &rc, &rs, &rm}; + launch(app, 1, 1, 256, 1, aa); + } + } +} +static void qsa_fused(QsaOperands& q, CUfunction fused, const Rope& r) { + QsaArgs qa; + memset(&qa, 0, sizeof qa); + for (int l = 0; l < 12; ++l) { qa.tail[l] = q.tail[1][l].p; qa.dead[l] = q.dead[1][l].p; qa.pooled[l] = q.pooled[1][l].p; qa.block_pos[l] = q.bpos[1][l].p; qa.gamma[l] = q.gam[l].p; } + qa.raw_base = q.raw.p; qa.snap_base = q.snap.p; qa.commit = q.commit.p; qa.mtab = 0; qa.rows = T; qa.max_cells = kMaxCells; qa.pos_base = 0; + qa.epsilon = 1e-6f; qa.theta_scale = r.theta_scale; qa.freq_scale = r.freq_scale; qa.corr_low = r.corr_low; qa.corr_high = r.corr_high; qa.ext_factor = r.ext_factor; qa.mscale = r.mscale; + void* af[] = {&qa}; + launch(fused, 12, 1, 128, 4, af); +} + +static void test_qsa(CUmodule mq, CUmodule mo, CUmodule md) { + CUfunction app = get_fn(mq, "verify_qsa_append_analytic"), cpy = get_fn(mo, "verify_copy_from_mapped_kernel"), fused = get_fn(md, "draft_commit_qsa_layers"); + const int blocks = 40; // positions below 160: block index <= 40 + const size_t pooled_bytes = (size_t)(blocks + 2) * D * 4; + const Rope ropes[] = {{0.7f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f}, {0.8409f, 0.25f, 1.0f, 20.0f, 1.0f, 1.1f}, {0.9f, 0.5f, 2.0f, 30.0f, 0.5f, 1.3f}}; + QsaOperands q; + for (int v = 0; v < 2; ++v) for (int l = 0; l < 12; ++l) { q.tail[v][l].alloc(1536); q.dead[v][l].alloc(512); q.pooled[v][l].alloc(pooled_bytes); q.bpos[v][l].alloc(16); } + for (int l = 0; l < 12; ++l) q.gam[l].alloc(512); + q.raw.alloc((size_t)12 * T * 512); q.snap.alloc(12 * 1536); q.commit.alloc((T + 2) * 4); + int cases = 0; + for (int seed = 0; seed < 60; ++seed) { + const Rope r = ropes[seed % 3]; + std::vector hraw((size_t)12 * T * D), hsnap(12 * 384), hg(128); + for (auto& x : hraw) x = rndf() * 2.0f; + for (auto& x : hsnap) x = rndf(); + q.raw.put(hraw.data(), hraw.size() * 4); q.snap.put(hsnap.data(), hsnap.size() * 4); + for (int l = 0; l < 12; ++l) { for (auto& x : hg) x = rndf() + 1.2f; q.gam[l].put(hg.data(), 512); } + // accepted positions: a run of consecutive cells from p0 (sometimes 0 or around a block edge), the rest -1 + int32_t cm[T + 2] = {0, 0}; + const int p0choices[] = {0, 1, 2, 3, 4, 5, 7, 8, 37, 100, 101, 102, 103}; + const int p0 = p0choices[seed % 13]; + const int keep = 1 + (int)(rnd() % T); + cm[0] = keep; + for (int row = 0; row < T; ++row) cm[2 + row] = row < keep ? p0 + row : -1; + if (seed % 7 == 6) cm[2 + 2] = -1; // a hole + q.commit.put(cm, sizeof cm); + std::vector ts(12 * 384), ds(12 * 128), ps(12 * (pooled_bytes / 4)); + for (auto& x : ts) x = rndf(); + for (auto& x : ds) x = rndf(); + for (auto& x : ps) x = rndf(); + int32_t bp0[4] = {-1, 0, 0, 0}; + for (int v = 0; v < 2; ++v) for (int l = 0; l < 12; ++l) { + q.tail[v][l].put(&ts[l * 384], 1536); q.dead[v][l].put(&ds[l * 128], 512); q.pooled[v][l].put(&ps[(size_t)l * (pooled_bytes / 4)], pooled_bytes); q.bpos[v][l].put(bp0, 16); + } + qsa_original(q, app, cpy, r); + qsa_fused(q, fused, r); + CU(cuStreamSynchronize(g_s)); + for (int l = 0; l < 12; ++l) { + char what[96]; + snprintf(what, sizeof what, "qsa seed %d layer %d tail", seed, l); same(what, q.tail[0][l].get(), q.tail[1][l].get()); + snprintf(what, sizeof what, "qsa seed %d layer %d dead", seed, l); same(what, q.dead[0][l].get(), q.dead[1][l].get()); + snprintf(what, sizeof what, "qsa seed %d layer %d pooled", seed, l); same(what, q.pooled[0][l].get(), q.pooled[1][l].get()); + snprintf(what, sizeof what, "qsa seed %d layer %d block_pos", seed, l); same(what, q.bpos[0][l].get(), q.bpos[1][l].get()); + } + ++cases; + } + printf("RESULT qsa cases=%d\n", cases); + const Rope r = ropes[0]; + double t_orig = time_graph([&] { qsa_original(q, app, cpy, r); }); + double t_fused = time_graph([&] { qsa_fused(q, fused, r); }); + printf("RESULT qsa_time original_us=%.1f fused_us=%.1f\n", t_orig, t_fused); +} + +int main(int argc, char** argv) { + if (argc < 2) { fprintf(stderr, "usage: commit_probe PTXDIR\n"); return 2; } + std::string dir = argv[1]; + CU(cuInit(0)); + CUdevice dev; CU(cuDeviceGet(&dev, 0)); + CUcontext ctx; CU(cuCtxCreate(&ctx, nullptr, 0, dev)); + CU(cuStreamCreate(&g_s, CU_STREAM_NON_BLOCKING)); + CUmodule mo = load_module(dir + "/original_verify.ptx"), mq = load_module(dir + "/original_verify_qsa.ptx"), md = load_module(dir + "/draft_commit.ptx"), mdq = load_module(dir + "/draft_commit_qsa.ptx"); + test_gdn(mo, md); + test_qsa(mq, mo, mdq); + printf(g_fail ? "PROBE FAILED: %d mismatches\n" : "PROBE OK: every output byte identical\n", g_fail); + return g_fail ? 1 : 0; +}