diff --git a/architecture-baseline.json b/architecture-baseline.json index 6c6ed8c5..ac71e524 100644 --- a/architecture-baseline.json +++ b/architecture-baseline.json @@ -8,7 +8,7 @@ "source": { "dyn-trait:leleka-backend-api": 1, "dyn-trait:leleka-cpu-worker": 4, - "dyn-trait:leleka-cuda-driver": 46, + "dyn-trait:leleka-cuda-driver": 45, "dyn-trait:leleka-cuda-model": 3, "dyn-trait:leleka-deploy": 17, "dyn-trait:leleka-engine-core": 18, diff --git a/crates/cuda-driver/ptx-sm86/MANIFEST.json b/crates/cuda-driver/ptx-sm86/MANIFEST.json index fc06ecd4..9f91b3af 100644 --- a/crates/cuda-driver/ptx-sm86/MANIFEST.json +++ b/crates/cuda-driver/ptx-sm86/MANIFEST.json @@ -2727,6 +2727,13 @@ "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": "gdn_prefill_tc.ptx", + "sm120_path": "crates/cuda-driver/src/gdn_prefill_tc.ptx", + "problems": [ + "not built for sm_86 by design (claude/prefill-gdn-tensor-core): LELEKA_PREFILL_GDN_TC is opt-in and experimental and gdn_prefill_tc.rs::plan refuses every device below compute capability 12, so an sm_86 build never loads this module (the kernels use only sm_80 features and would retarget; the 3080 plan needs its own parity and quality run first)" + ] + }, { "name": "original_verify_window_qsa_kv_rows.ptx", "sm120_path": "crates/cuda-driver/src/original_verify_window_qsa_kv_rows.ptx", diff --git a/crates/cuda-driver/src/api/async_api.rs b/crates/cuda-driver/src/api/async_api.rs index 6279320a..14ac75c9 100644 --- a/crates/cuda-driver/src/api/async_api.rs +++ b/crates/cuda-driver/src/api/async_api.rs @@ -54,6 +54,15 @@ impl AsyncApi { let _ = stream.0; Err(Error::UnsupportedPlatform) } + pub(crate) fn can_batch(&self) -> bool { + false + } + pub(crate) fn copy_batch(&self, _: &mut crate::refill_batch_copy::BatchCall, _: Stream) -> Result<()> { + Err(Error::UnsupportedPlatform) + } + pub(crate) fn wait_event(&self, _: Stream, _: Event) -> Result<()> { + Err(Error::UnsupportedPlatform) + } } #[cfg(not(all( feature = "cuda-driver", diff --git a/crates/cuda-driver/src/api/enabled.rs b/crates/cuda-driver/src/api/enabled.rs index 0edbeba4..f8e85d7d 100644 --- a/crates/cuda-driver/src/api/enabled.rs +++ b/crates/cuda-driver/src/api/enabled.rs @@ -33,7 +33,10 @@ pub(crate) struct AsyncApi { unregister: Unregister, stream_wait: Query, zero: Zero, + /// `cuMemcpyBatchAsync_v2` and `cuStreamWaitEvent`, resolved optionally (`None`: the per-copy path only). + batch: Option, } +mod batch_copy; fn check(operation: &'static str, code: c_int) -> Result<()> { if code == 0 { Ok(()) } else { Err(Error::Driver { operation, code }) } } @@ -70,6 +73,7 @@ impl AsyncApi { unregister: symbol!(library, c"cuMemHostUnregister", Unregister), stream_wait: symbol!(library, c"cuStreamSynchronize", Query), zero: symbol!(library, c"cuMemsetD8_v2", Zero), + batch: batch_copy::BatchCopyApi::resolve(&library), _library: library, }) } diff --git a/crates/cuda-driver/src/api/enabled/batch_copy.rs b/crates/cuda-driver/src/api/enabled/batch_copy.rs new file mode 100644 index 00000000..63a08832 --- /dev/null +++ b/crates/cuda-driver/src/api/enabled/batch_copy.rs @@ -0,0 +1,100 @@ +//! The optional batch-copy entry of `AsyncApi` (the lent-slot refill's `LELEKA_REFILL_BATCH`): resolved only when the +//! driver exports both symbols; a missing one leaves the per-copy path. +use super::*; +use crate::refill_batch_copy::BatchCall; + +/// `cuMemcpyBatchAsync_v2` (CUDA 12.8+/13, the form without `failIdx`): dsts, srcs, sizes, count, attrs, attrsIdxs, +/// numAttrs, stream. The same prototype as `original_gpu_schedule_ffi::platform::CopyBatch`. +type CopyBatch = unsafe extern "C" fn( + *mut u64, + *mut u64, + *mut usize, + usize, + *mut BatchAttributes, + *mut usize, + usize, + *mut c_void, +) -> c_int; +/// `cuStreamWaitEvent`: stream, event, flags. +type WaitEvent = unsafe extern "C" fn(*mut c_void, *mut c_void, c_uint) -> c_int; + +/// `CUmemcpyAttributes`: srcAccessOrder, srcLocHint {type, id}, dstLocHint {type, id}, flags (24 bytes). +#[repr(C)] +#[derive(Clone, Copy)] +struct BatchAttributes { + src_access_order: u32, + src_loc: [i32; 2], + dst_loc: [i32; 2], + flags: u32, +} +const _: () = assert!(std::mem::size_of::() == 24); +/// `CU_MEMCPY_SRC_ACCESS_ORDER_STREAM`: the source is read in stream order (the bank stays retained to the fence). +const SRC_ACCESS_ORDER_STREAM: u32 = 1; + +pub(crate) struct BatchCopyApi { + copy: CopyBatch, + wait_event: WaitEvent, +} + +impl BatchCopyApi { + pub(super) fn resolve(library: &Library) -> Option { + // SAFETY: fixed C names and a live dlopen owner; a null address maps to `None`. + let copy = unsafe { libc::dlsym(library.0, c"cuMemcpyBatchAsync_v2".as_ptr()) }; + // SAFETY: as above. + let wait = unsafe { libc::dlsym(library.0, c"cuStreamWaitEvent".as_ptr()) }; + if copy.is_null() || wait.is_null() { + return None; + } + // SAFETY: non-null addresses of the named symbols; `CopyBatch` and `WaitEvent` are their exact C signatures. + Some(unsafe { + Self { + copy: std::mem::transmute::<*mut c_void, CopyBatch>(copy), + wait_event: std::mem::transmute::<*mut c_void, WaitEvent>(wait), + } + }) + } +} + +impl AsyncApi { + /// Whether the driver exports the batch-copy entry (and `cuStreamWaitEvent`). + pub(crate) fn can_batch(&self) -> bool { + self.batch.is_some() + } + /// One `cuMemcpyBatchAsync_v2` of `call` on `stream` (never the legacy default stream: the caller passes a + /// created stream). The descriptor arrays are consumed during the call; the sources and destinations must stay + /// alive until the stream's fence. + pub(crate) fn copy_batch(&self, call: &mut BatchCall, stream: Stream) -> Result<()> { + let batch = self.batch.as_ref().ok_or(Error::MissingSymbol("cuMemcpyBatchAsync_v2"))?; + let count = call.sizes.len(); + if count == 0 { + return Ok(()); + } + if call.destinations.len() != count || call.sources.len() != count || stream.0 == 0 { + return Err(Error::InvalidSize); + } + let mut attributes = + BatchAttributes { src_access_order: SRC_ACCESS_ORDER_STREAM, src_loc: [0, 0], dst_loc: [0, 0], flags: 0 }; + let mut index = 0usize; + // SAFETY: the three arrays hold `count` entries each (checked above) and, with `attributes`/`index`, live + // across the call; the driver copies the descriptors during it. Every source is a slice of a bank the caller + // retains until the stream's fence (srcAccessOrder STREAM); every destination is a validated slot subspan. + check("cuMemcpyBatchAsync_v2", unsafe { + (batch.copy)( + call.destinations.as_mut_ptr(), + call.sources.as_mut_ptr(), + call.sizes.as_mut_ptr(), + count, + &mut attributes, + &mut index, + 1, + stream.0 as *mut c_void, + ) + }) + } + /// `cuStreamWaitEvent(stream, event, 0)`: later work of `stream` waits for the event's recorded work. + pub(crate) fn wait_event(&self, stream: Stream, event: Event) -> Result<()> { + let batch = self.batch.as_ref().ok_or(Error::MissingSymbol("cuStreamWaitEvent"))?; + // SAFETY: live owned handles in their actual current Context; no host memory is passed. + check("cuStreamWaitEvent", unsafe { (batch.wait_event)(stream.0 as *mut c_void, event.0 as *mut c_void, 0) }) + } +} diff --git a/crates/cuda-driver/src/device_buffer.rs b/crates/cuda-driver/src/device_buffer.rs index 4efaab13..1cb80981 100644 --- a/crates/cuda-driver/src/device_buffer.rs +++ b/crates/cuda-driver/src/device_buffer.rs @@ -79,24 +79,33 @@ impl DeviceBuffer<'_> { /// synchronization with the same poisoning/leak rule as whole-buffer reads; /// a failed synchronization never returns its bytes. pub fn copy_to_range(&self, offset: usize, output: &mut [u8]) -> Result<()> { + let staging = self.copy_range_staged(offset, output.len())?; + output.copy_from_slice(&staging); + Ok(()) + } + /// `copy_to_range` that hands the completed staging over instead of copying it into a second buffer: the same + /// transfer, synchronization and poisoning/leak rule, the same bytes, one allocation and one copy fewer. + pub fn copy_to_range_owned(&self, offset: usize, bytes: usize) -> Result> { + self.copy_range_staged(offset, bytes) + } + fn copy_range_staged(&self, offset: usize, bytes: usize) -> Result> { if self.context.poisoned.get() { return Err(Error::ContextPoisoned); } - let handle = self.handle.ok_or(Error::ContextPoisoned)?.checked_subspan(self.bytes, offset, output.len())?; + let handle = self.handle.ok_or(Error::ContextPoisoned)?.checked_subspan(self.bytes, offset, bytes)?; let mut staging = Vec::new(); - staging.try_reserve_exact(output.len()).map_err(|_| Error::HostAllocation)?; - staging.resize(output.len(), 0); + staging.try_reserve_exact(bytes).map_err(|_| Error::HostAllocation)?; + staging.resize(bytes, 0); let guard = self.context.enter()?; let copy = self.context.driver.api.copy_to(handle, &mut staging); let sync = self.context.driver.api.synchronize(); if sync.is_err() { self.context.poisoned.set(true); std::mem::forget(staging); - return combine(combine(copy, sync), guard.finish()); + return combine(combine(copy, sync), guard.finish()).map(|()| Vec::new()); } combine(copy, guard.finish())?; - output.copy_from_slice(&staging); - Ok(()) + Ok(staging) } pub fn copy_to(&self, output: &mut [u8]) -> Result<()> { let staging = self.staging(output.len())?; diff --git a/crates/cuda-driver/src/exact_fill.rs b/crates/cuda-driver/src/exact_fill.rs new file mode 100644 index 00000000..a9623a19 --- /dev/null +++ b/crates/cuda-driver/src/exact_fill.rs @@ -0,0 +1,93 @@ +//! A byte vector of a size known up front, filled by a copy without first being filled with zeros. +//! +//! The prefix-cache export (`OriginalQsaMappedJournal::export_pages_fast`) writes every byte of a fresh buffer. The +//! usual `resize(n, 0)` then touches the whole buffer once for nothing (a memset and the page faults of a fresh +//! allocation) before the copy touches it again. +use crate::{Error, Result}; +use std::mem::MaybeUninit; + +/// `out` becomes exactly `total` bytes written by `fill` into its spare capacity, with no zero fill first. +/// +/// `fill` gets `total` writable bytes and returns how many leading bytes it initialised. Anything but `total`, or an +/// error, leaves `out` empty: a half-written buffer is never exposed. A reused `out` keeps its capacity. +pub(crate) fn fill_exact( + out: &mut Vec, + total: usize, + fill: impl FnOnce(&mut [MaybeUninit]) -> Result, +) -> Result<()> { + out.clear(); + out.try_reserve_exact(total).map_err(|_| Error::HostAllocation)?; + let written = fill(&mut out.spare_capacity_mut()[..total])?; + if written != total { + return Err(Error::InvalidSize); + } + // SAFETY: `fill` reported that it initialised the first `total` bytes of the spare capacity, `total` bytes were + // reserved above, and `u8` has no invalid bit pattern. + unsafe { out.set_len(total) }; + Ok(()) +} + +#[cfg(test)] +mod tests { + use super::*; + + /// A source split in pieces like the K/V page image: the pieces of the pattern in order. + fn pattern(len: usize) -> Vec { + (0..len).map(|i| (i.wrapping_mul(31) ^ (i >> 7)) as u8).collect() + } + + /// Copies `pieces` consecutive runs of `source` into `dst` the way the export copies its four runs. + fn copy_runs(source: &[u8], runs: &[usize], dst: &mut [MaybeUninit]) -> Result { + let (mut at, mut rest) = (0, dst); + for &n in runs { + let (piece, tail) = rest.split_at_mut(n); + for (d, s) in piece.iter_mut().zip(&source[at..at + n]) { + d.write(*s); + } + (at, rest) = (at + n, tail); + } + Ok(at) + } + + #[test] + fn the_unzeroed_fill_gives_the_bytes_of_the_zero_filled_copy() { + let source = pattern(4 * 1056 * 3); + let runs = [3 * 2048, 3 * 2048, 3 * 64, 3 * 64]; + let mut zeroed = vec![0u8; source.len()]; + zeroed.copy_from_slice(&source); + let mut fast = Vec::new(); + fill_exact(&mut fast, source.len(), |dst| copy_runs(&source, &runs, dst)).unwrap(); + assert_eq!(fast, zeroed); + assert_eq!(fast.len(), 4 * 1056 * 3); + } + + #[test] + fn a_reused_buffer_is_replaced_whatever_it_held_and_keeps_its_capacity() { + let source = pattern(512); + let mut out = vec![0xAAu8; 4096]; + let capacity = out.capacity(); + fill_exact(&mut out, 512, |dst| copy_runs(&source, &[256, 256], dst)).unwrap(); + assert_eq!(out, source); + assert_eq!(out.capacity(), capacity, "no new allocation for a smaller export"); + } + + #[test] + fn a_short_or_failed_fill_leaves_the_buffer_empty() { + let source = pattern(64); + let mut out = vec![1u8; 8]; + let short = fill_exact(&mut out, 64, |dst| copy_runs(&source, &[32], dst)); + assert!(matches!(short, Err(Error::InvalidSize))); + assert!(out.is_empty()); + let failed = fill_exact(&mut out, 64, |_| Err(Error::ContextPoisoned)); + assert!(matches!(failed, Err(Error::ContextPoisoned))); + assert!(out.is_empty()); + } + + #[test] + fn a_size_that_cannot_be_reserved_is_a_host_allocation_error() { + let mut out = Vec::new(); + let refused = fill_exact(&mut out, usize::MAX, |_| Ok(0)); + assert!(matches!(refused, Err(Error::HostAllocation))); + assert!(out.is_empty()); + } +} diff --git a/crates/cuda-driver/src/gdn_native_batch.rs b/crates/cuda-driver/src/gdn_native_batch.rs index 9d4ecbec..d5683faf 100644 --- a/crates/cuda-driver/src/gdn_native_batch.rs +++ b/crates/cuda-driver/src/gdn_native_batch.rs @@ -342,7 +342,7 @@ mod gpu; // Original physical prompt arena producer: old whole-owner API remains exact. #[path = "gdn_prompt_device.rs"] mod prompt_device; -pub use prompt_device::{OriginalGdnPromptDevice, OriginalGdnPromptState, OriginalGdnPromptWeights}; +pub use prompt_device::{GdnPromptOptions, OriginalGdnPromptDevice, OriginalGdnPromptState, OriginalGdnPromptWeights}; #[path = "gdn_native_batch/pinned.rs"] mod pinned; diff --git a/crates/cuda-driver/src/gdn_prefill_tc.cu b/crates/cuda-driver/src/gdn_prefill_tc.cu new file mode 100644 index 00000000..270ecccb --- /dev/null +++ b/crates/cuda-driver/src/gdn_prefill_tc.cu @@ -0,0 +1,549 @@ +// Offline compilation source; not a runtime/toolkit dependency. +// EXPERIMENTAL, LOSSY (LELEKA_PREFILL_GDN_TC, off by default): the prompt GDN recurrence as a chunked scan on the tensor cores. +// +// Port of Strata upstream `src/prefill/gdn_tc.cuh` (strata-upstream/main 504b1433, history 8c2a84694 -> 06f212aef (the 99-KB +// split plan for sm_86 / sm_89 / sm_120) -> ee0511484 -> 51567de1a (two value tiles a head on cards with >= 96 SMs)), restricted +// to the plan the RTX 5090 (sm_120, 99 KB of shared memory a block, 170 SMs) runs: SPLIT shared-memory plan, three f16 passes a +// product (NP = 3), output norm NOT fused (our separate leleka_prefill_gdn_out_norm* kernel runs after the recurrence as before), +// one value tile (leleka_gdn_tc_scan_t1, 48 blocks) or two (leleka_gdn_tc_scan_t2, 96 blocks of 128 threads). The fused norm, the +// one-pass and 124-KB plans, and the NP experiments are not ported. +// +// What it replaces: leleka_prefill_gdn_rec / leleka_prefill_gdn_rec_kh (prefill_stage.cu), the token-serial recurrence of the +// Original. Same interface and layout: state_in -> state_out ([128 rows][48 heads][128 cols] f32), h = the convolved and L2-normalised +// qkv rows ([T][10240]: q | k | v), gate (log decay) and beta ([T][48]), the readout `oc_out` ([T][48][128], already x rsqrt(128)) +// and the state witness (bit 0 of *witness raised when the FINAL state holds a non-finite value, as leleka_prefill_gdn_rec_kh). +// +// NOT BITWISE EQUAL to those kernels, by design: the recurrence is re-associated into the chunked WY form of +// gdn_chunk_scan_kernel and every product runs on f16 mma.sync with f16x3 splits (x = hi + lo, hi.hi + hi.lo + lo.hi, lo.lo dropped, +// operands scaled by powers of two so that lo stays normal): within 3 x 2^-22 |a||b| of each exact product, 1e-4 of the sequential +// kernel in the upstream harness. Upstream's end-to-end first-token KL against the sequential path: mean 0.0019, max 0.0125. The gate +// that decides is docs/quality-gate.md (first-token KL / q_tail_gate / logprob envelope), not an identity probe. +// +// Three kernels, a prompt chunk of T tokens runs in super-blocks of nch chunks (32 tokens each) held in a scratch the host provides: +// leleka_gdn_tc_prep grid nch * 16 (block b: chunk b / 16, key head b % 16), 256 threads, 43,264 B dynamic shared memory: +// A, T = (I + A)^-1 and P of the chunk, the k / q f16 hi / lo images, the token scalars, into the scratch +// leleka_gdn_tc_scan_t1 grid 48 (a block per value head), 256 threads, 97,808 B +// leleka_gdn_tc_scan_t2 grid 96 (value head x 2 column tiles), 128 threads, 97,808 B +// The scan launches of one prompt run in order and the second one on reads the state the first wrote (state_in == state_out is +// supported: a block reads and writes only its own columns). +// +// Scratch (bytes, a chunk of the super-block): T images 196,608 + T scales 192 + token scalars 24,576 + k / q images 524,288 + P images +// 196,608 = 942,272 B; 64 chunks (2048 tokens, upstream's GSB) are 60,305,408 B. Every sub-buffer starts on a 16-B boundary (cp.async). +// +// Intended offline compile (the recipe of the other precise assets): pinned NVCC 13.2.86, -std=c++17 -O3 -ptx -arch=sm_120 +// --ftz=false --prec-div=true --prec-sqrt=true --fmad=true. +#include +#include + +namespace { +constexpr int S = 128, HK = 16, HV = 48, C = 10240; // head size, key heads, value heads, qkv row width +constexpr int VPK = HV / HK; // value heads a key head +constexpr int GCH = 32; // tokens a chunk (the prep's solve is a lane per token) +constexpr int GTP = GCH + 1; // padded T / P rows of the prep +static_assert(GCH == 32, "a lane per token of the chunk"); +static_assert(C == 2 * HK * S + HV * S, "qkv row: q | k | v"); + +__device__ __forceinline__ void gdn_cp4(float* smem, const float* gmem) { + asm volatile("cp.async.ca.shared.global [%0], [%1], 4;\n" ::"r"((unsigned) __cvta_generic_to_shared(smem)), "l"(gmem)); +} +__device__ __forceinline__ void gdn_cp16(float* smem, const float* gmem) { + asm volatile("cp.async.cg.shared.global [%0], [%1], 16;\n" ::"r"((unsigned) __cvta_generic_to_shared(smem)), "l"(gmem)); +} +__device__ __forceinline__ void gdn_cp_commit() { asm volatile("cp.async.commit_group;\n" ::); } +__device__ __forceinline__ void gdn_cp_wait_all() { asm volatile("cp.async.wait_all;\n" ::); } + +constexpr int GTC_KP = S + 8; // f16 k / q rows: a 272-B stride puts the 8 rows of a ldmatrix 8x8 on 8 distinct 16-B lanes +constexpr int GTC_VP = S + 4; // f32 v rows: lane (gid, tig) reads word 264 tig + gid, 32 distinct banks +constexpr int GTC_PP = GCH + 8; // f16 T / P rows: an 80-B stride, 8 rows on distinct 16-B lanes +constexpr int GTC_CW = S / 16; // consumer warps a block: 16 value columns each +// The SPLIT shared-memory plan (the 99-KB cards): only k / q hi / lo and the token scalars stay double-buffered; v, T and P (one +// buffer) are staged for the next chunk after this chunk's last read of them, so that load overlaps the state update. +constexpr size_t kTcScanSmemSplit = 2 * (4 * GCH * GTC_KP * 2 + GCH * 16) + GCH * GTC_VP * 4 + 4 * GCH * GTC_PP * 2 + 16; +static_assert(kTcScanSmemSplit == 97808, "the split shared-memory plan"); +constexpr size_t kTcPrepSmem = (size_t) 4 * GCH * GTC_KP * 2 + 2 * GCH * GTP * 4; // the images, then k_t.k_i and q_t.k_i +static_assert(kTcPrepSmem == 43264, "the prep shared-memory plan"); +static_assert(VPK * GCH * GTP * 4 <= 4 * GCH * GTC_KP * 2, "gdn_tc_prep: A fits where the images were"); + +// the warp's largest of non-negative floats: their bits order as unsigned integers, so one redux.sync. Under the full mask (the +// first call of the scan follows a lane-divergent branch, so __activemask() would not do). +__device__ __forceinline__ float gtc_warp_max(float v) { + return __uint_as_float(__reduce_max_sync(0xffffffffu, __float_as_uint(v))); +} +__device__ __forceinline__ float gtc_pow2(int e) { return __int_as_float((e + 127) << 23); } // 2^e, |e| < 127 +// the power of two that puts m = max |x| >= 0 in [2^14, 2^15): f16 hi never overflows (65504) and the low part of every entry within +// 2^-17 of the max stays normal; clamped so that the compensating powers stay far from f32's range +__device__ __forceinline__ int gtc_scale_exp(float m) { + if (m == 0.0f) return 0; + const int e = 14 - ((__float_as_int(m) >> 23) - 127); + return e < -40 ? -40 : (e > 40 ? 40 : e); +} + +// ---- the tensor-core wrappers (PTX ISA "Matrix Fragments": lane = 4 gid + tig) +// m16n8k16 f16: A a0 = (row gid, cols 2tig, 2tig+1) a1 = (gid+8, ..) a2 = (gid, 2tig+8..) a3 = (gid+8, 2tig+8..); +// B b0 = (k 2tig, 2tig+1; n gid) b1 = (k 2tig+8..; n gid); C/D c0 = (gid, 2tig) c1 = (gid, 2tig+1) +// c2 = (gid+8, 2tig) c3 = (gid+8, 2tig+1) - so two adjacent C tiles ARE the next product's A fragment +// ldmatrix m8n8.x4.b16: lanes 8m..8m+7 give the row addresses of matrix m; a lane gets (row gid, cols 2tig, 2tig+1) +// of each matrix (the lower column in the low half), or with .trans (rows 2tig, 2tig+1; col gid) +__device__ __forceinline__ void gtc_ldsm_x4(uint32_t (&r)[4], const void* smem) { + asm volatile("ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%0,%1,%2,%3}, [%4];" + : "=r"(r[0]), "=r"(r[1]), "=r"(r[2]), "=r"(r[3]) + : "r"((unsigned) __cvta_generic_to_shared(smem))); +} +__device__ __forceinline__ void gtc_ldsm_x4_trans(uint32_t (&r)[4], const void* smem) { + asm volatile("ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%0,%1,%2,%3}, [%4];" + : "=r"(r[0]), "=r"(r[1]), "=r"(r[2]), "=r"(r[3]) + : "r"((unsigned) __cvta_generic_to_shared(smem))); +} +__device__ __forceinline__ void gtc_mma_f16(float (&c)[4], const uint32_t (&a)[4], uint32_t b0, uint32_t b1) { + asm("mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%0,%1,%2,%3}, {%4,%5,%6,%7}, {%8,%9}, {%0,%1,%2,%3};" + : "+f"(c[0]), "+f"(c[1]), "+f"(c[2]), "+f"(c[3]) + : "r"(a[0]), "r"(a[1]), "r"(a[2]), "r"(a[3]), "r"(b0), "r"(b1)); +} +// the three passes of a split product, small terms first: lo.hi, hi.lo, hi.hi +__device__ __forceinline__ void gtc_mma3_f16(float (&c)[4], const uint32_t (&ah)[4], const uint32_t (&al)[4], uint32_t bh0, + uint32_t bh1, uint32_t bl0, uint32_t bl1) { + gtc_mma_f16(c, al, bh0, bh1); + gtc_mma_f16(c, ah, bl0, bl1); + gtc_mma_f16(c, ah, bh0, bh1); +} +// x0, x1 -> packed f16 hi (x0 in the low half) and lo = f16(x - hi): x - hi is exact in f32 (hi carries x's exponent) +__device__ __forceinline__ void gtc_split_f16x2(float x0, float x1, uint32_t& hi, uint32_t& lo) { + union { __half2 h; uint32_t u; } cv; + cv.h = __floats2half2_rn(x0, x1); + hi = cv.u; + const float2 r = __half22float2(cv.h); + cv.h = __floats2half2_rn(x0 - r.x, x1 - r.y); + lo = cv.u; +} +// four consecutive elements of an f16 hi / lo row from a float4 x scale (an 8-byte store each) +__device__ __forceinline__ void gtc_split_store4(uint16_t* hi, uint16_t* lo, float4 v, float scale) { + uint32_t h0, l0, h1, l1; + gtc_split_f16x2(v.x * scale, v.y * scale, h0, l0); + gtc_split_f16x2(v.z * scale, v.w * scale, h1, l1); + *reinterpret_cast(hi) = make_uint2(h0, h1); + *reinterpret_cast(lo) = make_uint2(l0, l1); +} +// a float4 from shared memory the compiler does not keep: the per-token scalars are read in three phases of a chunk, a component +// each, and kept across them they cost 24 registers a thread +__device__ __forceinline__ float4 gtc_lds128(const float4* p) { + float4 v; + asm volatile("ld.shared.v4.f32 {%0,%1,%2,%3}, [%4];" + : "=f"(v.x), "=f"(v.y), "=f"(v.z), "=f"(v.w) + : "r"((unsigned) __cvta_generic_to_shared(p))); + return v; +} + +// ---- the products of a chunk, a warp each +// X^T = S^T K^T and QS^T = S^T Q^T: A = the state fragments x sA (= 2^es) split in f16 hi / lo just in time per k16-step (tiles 2kk and +// 2kk + 1 of S^T are that step's A fragment), B = the f16 hi / lo images of k and q ([GCH][GTC_KP] in shared memory, rows = tokens) by +// ldmatrix: matrices (n-tile 2hf + (lane >> 4), k-half (lane >> 3) & 1), a lane's row is token 8 n-tile + (lane & 7). The accumulators +// come out as 2^(8 + es) times the products. 2 x 96 mma. +__device__ __forceinline__ void gtc_prod_state(const float (&s)[16][4], float sA, const uint16_t* kh, const uint16_t* kl, + const uint16_t* qh, const uint16_t* ql, float (&xt)[4][4], float (&qs)[4][4]) { + const int lane = threadIdx.x & 31; + const int off = (8 * (lane >> 4) + (lane & 7)) * GTC_KP + 8 * ((lane >> 3) & 1); +#pragma unroll + for (int kk = 0; kk < S / 16; ++kk) { + uint32_t ah[4], al[4]; + gtc_split_f16x2(s[2 * kk][0] * sA, s[2 * kk][1] * sA, ah[0], al[0]); + gtc_split_f16x2(s[2 * kk][2] * sA, s[2 * kk][3] * sA, ah[1], al[1]); + gtc_split_f16x2(s[2 * kk + 1][0] * sA, s[2 * kk + 1][1] * sA, ah[2], al[2]); + gtc_split_f16x2(s[2 * kk + 1][2] * sA, s[2 * kk + 1][3] * sA, ah[3], al[3]); +#pragma unroll + for (int hf = 0; hf < 2; ++hf) { + const int o = off + 16 * hf * GTC_KP + 16 * kk; + uint32_t bh[4], bl[4]; + gtc_ldsm_x4(bh, kh + o); + gtc_ldsm_x4(bl, kl + o); + gtc_mma3_f16(xt[2 * hf], ah, al, bh[0], bh[1], bl[0], bl[1]); + gtc_mma3_f16(xt[2 * hf + 1], ah, al, bh[2], bh[3], bl[2], bl[3]); + gtc_ldsm_x4(bh, qh + o); + gtc_ldsm_x4(bl, ql + o); + gtc_mma3_f16(qs[2 * hf], ah, al, bh[0], bh[1], bl[0], bl[1]); + gtc_mma3_f16(qs[2 * hf + 1], ah, al, bh[2], bh[3], bl[2], bl[3]); + } + } +} +// o^T += (sD D^T) (2^8 P^T) on f16x3: A = the D^T tiles x sD (= 2^ed) split per k16-step, B = the f16 hi / lo images of P x 2^8 +// ([GCH][GTC_PP], rows = tokens t) by ldmatrix as in gtc_prod_state. The tiles above P's diagonal are left out: tokens t < 16 (n-tiles +// 0, 1) see no i >= 16 (k-step 1). 18 mma. D^T += (sY Y^T) (2^et T^T) is the same product on the T images (T is zero above its +// diagonal too), the accumulator x 2^(ey + et). +__device__ __forceinline__ void gtc_prod_dt(const float (&dt)[4][4], float sD, const uint16_t* ph, const uint16_t* pl, + float (&ot)[4][4]) { + const int lane = threadIdx.x & 31; + const int off = (8 * (lane >> 4) + (lane & 7)) * GTC_PP + 8 * ((lane >> 3) & 1); +#pragma unroll + for (int ks = 0; ks < GCH / 16; ++ks) { + uint32_t ah[4], al[4]; + gtc_split_f16x2(dt[2 * ks][0] * sD, dt[2 * ks][1] * sD, ah[0], al[0]); + gtc_split_f16x2(dt[2 * ks][2] * sD, dt[2 * ks][3] * sD, ah[1], al[1]); + gtc_split_f16x2(dt[2 * ks + 1][0] * sD, dt[2 * ks + 1][1] * sD, ah[2], al[2]); + gtc_split_f16x2(dt[2 * ks + 1][2] * sD, dt[2 * ks + 1][3] * sD, ah[3], al[3]); +#pragma unroll + for (int hf = 0; hf < 2; ++hf) { + if (ks == 1 && hf == 0) continue; + const int o = off + 16 * hf * GTC_PP + 16 * ks; + uint32_t bh[4], bl[4]; + gtc_ldsm_x4(bh, ph + o); + gtc_ldsm_x4(bl, pl + o); + gtc_mma3_f16(ot[2 * hf], ah, al, bh[0], bh[1], bl[0], bl[1]); + gtc_mma3_f16(ot[2 * hf + 1], ah, al, bh[2], bh[3], bl[2], bl[3]); + } + } +} +// S^T += Dd^T (2^8 K) on f16x3: A = the (already scaled) Dd^T tiles split per k16-step, B = the same k images read the other way by +// ldmatrix.trans: matrices (n-tile 2hf + (lane >> 4), k-half (lane >> 3) & 1), a lane's row is token 16 ks + 8 k-half + (lane & 7), its +// 16-B piece state rows 8 n-tile.. 96 mma. +__device__ __forceinline__ void gtc_update_state(float (&s)[16][4], const float (&dd)[4][4], const uint16_t* kh, + const uint16_t* kl) { + const int lane = threadIdx.x & 31; + const int off = (8 * ((lane >> 3) & 1) + (lane & 7)) * GTC_KP + 8 * (lane >> 4); +#pragma unroll + for (int ks = 0; ks < GCH / 16; ++ks) { + uint32_t ah[4], al[4]; + gtc_split_f16x2(dd[2 * ks][0], dd[2 * ks][1], ah[0], al[0]); + gtc_split_f16x2(dd[2 * ks][2], dd[2 * ks][3], ah[1], al[1]); + gtc_split_f16x2(dd[2 * ks + 1][0], dd[2 * ks + 1][1], ah[2], al[2]); + gtc_split_f16x2(dd[2 * ks + 1][2], dd[2 * ks + 1][3], ah[3], al[3]); +#pragma unroll + for (int hf = 0; hf < S / 16; ++hf) { + const int o = off + 16 * ks * GTC_KP + 16 * hf; + uint32_t bh[4], bl[4]; + gtc_ldsm_x4_trans(bh, kh + o); + gtc_ldsm_x4_trans(bl, kl + o); + gtc_mma3_f16(s[2 * hf], ah, al, bh[0], bh[1], bl[0], bl[1]); + gtc_mma3_f16(s[2 * hf + 1], ah, al, bh[2], bh[3], bl[2], bl[3]); + } + } +} + +// ---- the scan of one super-block: a block per value head (or per head and column tile), warps of 16 value columns each walking +// every chunk with their state slice in registers, the prep's scratch staged by cp.async. NTL value tiles a head (a launch of HV x NTL +// blocks of GTC_CW / NTL warps): block (vh, tile) owns the state columns [tile S / NTL, (tile + 1) S / NTL). The k / q / T / P images +// are staged by every tile of the head, v only for its columns. +extern __shared__ __align__(16) unsigned char gtc_sm[]; // the scan's dynamic shared memory (97,808 B) + +template +__device__ __forceinline__ void gtc_scan_body(const float* state_in, float* state_out, const float* __restrict__ h, + const uint16_t* __restrict__ tig_, const float* __restrict__ teg, + const float4* __restrict__ scg, const uint16_t* __restrict__ kqg, + const uint16_t* __restrict__ pig, float* __restrict__ oc_out, int64_t t0, + int nch, int64_t T, unsigned* witness) { + static_assert(GTC_CW % NTL == 0, "tiles of whole warps"); + constexpr int NT = (GTC_CW / NTL) * 32; + uint16_t* kh = reinterpret_cast(gtc_sm); // [2][GCH][GTC_KP] f16 of k x 2^8 (hi) + uint16_t* kl = kh + 2 * GCH * GTC_KP; // [2][GCH][GTC_KP] what hi left out (lo) + uint16_t* qh = kl + 2 * GCH * GTC_KP; // q likewise + uint16_t* ql = qh + 2 * GCH * GTC_KP; + float* sv = reinterpret_cast(ql + 2 * GCH * GTC_KP); // [GCH][GTC_VP] v (one buffer) + uint16_t* th = reinterpret_cast(sv + GCH * GTC_VP); // [GCH][GTC_PP] T x 2^et hi / lo + uint16_t* tl = th + GCH * GTC_PP; + uint16_t* ph = tl + GCH * GTC_PP; // [GCH][GTC_PP] P x 2^8 hi / lo + uint16_t* pl = ph + GCH * GTC_PP; + float4* sc = reinterpret_cast(pl + GCH * GTC_PP); // [2][GCH] (beta, exp(gamma), exp(gL - gamma), gamma) + float* ste = reinterpret_cast(sc + 2 * GCH); // [2] 2^-et + const int vh = blockIdx.x / NTL, qhd = vh % HK, cb = (blockIdx.x % NTL) * (S / NTL); // the tile's first column + const int tid = threadIdx.x, warp = tid >> 5, lane = tid & 31, gid = lane >> 2, tig = lane & 3; + const size_t rs = (size_t) HV * S; + // chunk ch into buffer b, this thread's 16-B pieces (one cp.async group): the four k / q images (4 x GCH rows of 16 pieces: 8 a + // thread), v (4 a thread), the two T images (1), the two P images (1), the scalars (threads < GCH), T's scale (thread 0, 4 B) + // parts: bit 0 = the k / q images, the scalars and T's scale (buffer b); bit 1 = v, T and P (the one buffer) + auto stage = [&](int ch, int b, int parts) { + const int64_t c_t0 = t0 + (int64_t) ch * GCH; + const int n = (int) min((int64_t) GCH, T - c_t0); + if (parts & 1) { + const uint16_t* img = kqg + ((size_t) ch * HK + qhd) * 4 * GCH * S; +#pragma unroll + for (int m = 0; m < 4 * GCH * S / 8 / NT; ++m) { + const int pc = tid + NT * m, im = pc / (GCH * S / 8), t = (pc % (GCH * S / 8)) / (S / 8), r = (pc % (S / 8)) * 8; + uint16_t* dst = (im == 0 ? kh : im == 1 ? kl : im == 2 ? qh : ql) + (b * GCH + t) * GTC_KP + r; + gdn_cp16(reinterpret_cast(dst), reinterpret_cast(img + (im * GCH + t) * S + r)); + } + if (tid < GCH) gdn_cp16(reinterpret_cast(sc + b * GCH + tid), reinterpret_cast(scg + ((int64_t) ch * HV + vh) * GCH + tid)); + if (tid == 0) gdn_cp4(ste + b, teg + (int64_t) ch * HV + vh); + } + if (parts & 2) { +#pragma unroll + for (int m = 0; m < GCH * (S / NTL) / 4 / NT; ++m) { + const int p = tid + NT * m, t = p / (S / NTL / 4), r = (p % (S / NTL / 4)) * 4; + float* dst = sv + t * GTC_VP + r; + if (t < n) gdn_cp16(dst, h + (c_t0 + t) * C + 2 * HK * S + vh * S + cb + r); + else *reinterpret_cast(dst) = make_float4(0.0f, 0.0f, 0.0f, 0.0f); + } +#pragma unroll + for (int m = 0; m < 2 * GCH * GCH / 8 / NT; ++m) { + const int pc = tid + NT * m, im = pc / (GCH * GCH / 8), t = (pc % (GCH * GCH / 8)) / (GCH / 8), i = (pc % (GCH / 8)) * 8; + const int64_t src = ((((int64_t) ch * HV + vh) * 2 + im) * GCH + t) * GCH + i; + const int dst = t * GTC_PP + i; + gdn_cp16(reinterpret_cast((im ? tl : th) + dst), reinterpret_cast(tig_ + src)); + gdn_cp16(reinterpret_cast((im ? pl : ph) + dst), reinterpret_cast(pig + src)); + } + } + gdn_cp_commit(); + }; + const int c0 = 16 * warp; // the warp's value columns c0 + gid and c0 + gid + 8 of the tile (v in shared memory) + const int ca = cb + c0; // the same in the head (state, output) + // the state slice as S^T fragments: tile j = rows 8j..8j+7; s[j][0] = S[8j + 2tig][c0 + gid], [1] the row after, [2] column + 8, [3] + // both (64 scalar loads a lane, 32-B runs, once a launch) + float s[16][4]; +#pragma unroll + for (int j = 0; j < 16; ++j) { + const float* p = state_in + (size_t) (8 * j + 2 * tig) * rs + (size_t) vh * S + ca + gid; + s[j][0] = p[0]; s[j][1] = p[rs]; s[j][2] = p[8]; s[j][3] = p[rs + 8]; + } + stage(0, 0, 3); + const float out_scale = rsqrtf((float) S); + for (int ch = 0; ch < nch; ++ch) { + const int b = ch & 1; + const int64_t c_t0 = t0 + (int64_t) ch * GCH; + const int n = (int) min((int64_t) GCH, T - c_t0); + gdn_cp_wait_all(); // this thread's pieces of chunk ch + __syncthreads(); // every thread's: chunk ch's buffer complete; every read of the other one done + if (ch + 1 < nch) stage(ch + 1, b ^ 1, 1); + const uint16_t* bkh = kh + b * GCH * GTC_KP; + const uint16_t* bkl = kl + b * GCH * GTC_KP; + const uint16_t* bqh = qh + b * GCH * GTC_KP; + const uint16_t* bql = ql + b * GCH * GTC_KP; + const float4* bsc = sc + b * GCH; + // (a) X^T = S0^T K^T and QS^T = S0^T Q^T, the state x 2^es (its largest entry in [2^14, 2^15)). The lane's maximum over eight + // chains (nvcc keeps the order written: one chain was 64 dependent FMNMX before the first mma) + float m8[8] = {}; +#pragma unroll + for (int j = 0; j < 16; ++j) +#pragma unroll + for (int q = 0; q < 4; ++q) m8[(2 * j + (q >> 1)) & 7] = fmaxf(m8[(2 * j + (q >> 1)) & 7], fabsf(s[j][q])); + const float m = fmaxf(fmaxf(fmaxf(m8[0], m8[1]), fmaxf(m8[2], m8[3])), fmaxf(fmaxf(m8[4], m8[5]), fmaxf(m8[6], m8[7]))); + const int es = gtc_scale_exp(gtc_warp_max(m)); + float xt[4][4] = {}, qs[4][4] = {}; + gtc_prod_state(s, gtc_pow2(es), bkh, bkl, bqh, bql, xt, qs); + // (b) Y^T = beta_i (V^T - e'_i X^T), e'_i = exp(gamma_i) 2^-(8 + es): lane (gid, tig) holds tokens 8nt + 2tig and + 1, columns + // c0 + gid and + 8 + const float eS = gtc_pow2(-(8 + es)); + float yt[4][4]; +#pragma unroll + for (int nt = 0; nt < 4; ++nt) { + const float4 s0 = gtc_lds128(bsc + 8 * nt + 2 * tig), s1 = gtc_lds128(bsc + 8 * nt + 2 * tig + 1); + const float* v = sv + (8 * nt + 2 * tig) * GTC_VP + c0 + gid; + const float e0 = s0.y * eS, e1 = s1.y * eS; + yt[nt][0] = s0.x * fmaf(-e0, xt[nt][0], v[0]); + yt[nt][1] = s1.x * fmaf(-e1, xt[nt][1], v[GTC_VP]); + yt[nt][2] = s0.x * fmaf(-e0, xt[nt][2], v[8]); + yt[nt][3] = s1.x * fmaf(-e1, xt[nt][3], v[GTC_VP + 8]); + } + // (c) D^T = Y^T T^T on f16x3: Y^T x 2^ey (its largest entry in [2^14, 2^15)), T's images x 2^et from the prep; the accumulator + // comes out x 2^(ey + et) (T above its diagonal skipped) + float my4[4] = {}; +#pragma unroll + for (int nt = 0; nt < 4; ++nt) +#pragma unroll + for (int q = 0; q < 4; ++q) my4[q] = fmaxf(my4[q], fabsf(yt[nt][q])); + const int ey = gtc_scale_exp(gtc_warp_max(fmaxf(fmaxf(my4[0], my4[1]), fmaxf(my4[2], my4[3])))); + float dt[4][4] = {}; + gtc_prod_dt(yt, gtc_pow2(ey), th, tl, dt); + const float sYT = gtc_pow2(-ey) * ste[b]; +#pragma unroll + for (int nt = 0; nt < 4; ++nt) +#pragma unroll + for (int q = 0; q < 4; ++q) dt[nt][q] *= sYT; + // (d) o^T = e_t QS^T + D^T P^T: the accumulator starts as 2^(ed + 8) e_t QS^T (QS^T came out x 2^(8 + es)), D^T goes in x 2^ed, P + // x 2^8; the output is the accumulator x 2^-(ed + 8), then rsqrt(S) + float md4[4] = {}; +#pragma unroll + for (int nt = 0; nt < 4; ++nt) +#pragma unroll + for (int q = 0; q < 4; ++q) md4[q] = fmaxf(md4[q], fabsf(dt[nt][q])); + const int ed = gtc_scale_exp(gtc_warp_max(fmaxf(fmaxf(md4[0], md4[1]), fmaxf(md4[2], md4[3])))); + const float sD = gtc_pow2(ed), sO = gtc_pow2(ed + 8), sOi = gtc_pow2(-(ed + 8)), eO = gtc_pow2(ed - es); + float ot[4][4]; +#pragma unroll + for (int nt = 0; nt < 4; ++nt) { + const float e0 = gtc_lds128(bsc + 8 * nt + 2 * tig).y * eO, e1 = gtc_lds128(bsc + 8 * nt + 2 * tig + 1).y * eO; + ot[nt][0] = qs[nt][0] * e0; ot[nt][1] = qs[nt][1] * e1; ot[nt][2] = qs[nt][2] * e0; ot[nt][3] = qs[nt][3] * e1; + } + gtc_prod_dt(dt, sD, ph, pl, ot); +#pragma unroll + for (int nt = 0; nt < 4; ++nt) +#pragma unroll + for (int q = 0; q < 4; ++q) { + const int t = 8 * nt + 2 * tig + (q & 1); + if (t < n) oc_out[(c_t0 + t) * rs + (size_t) vh * S + ca + gid + 8 * (q >> 1)] = (ot[nt][q] * sOi) * out_scale; + } + // v, T and P of this chunk are dead: every warp is past (d); the next chunk's land during (e) + __syncthreads(); + if (ch + 1 < nch) stage(ch + 1, 0, 2); + // (e) S^T = eL S0^T + Dd^T K, Dd^T = f_i D^T: the accumulator x (eL 2^(ed + 8)) before (one rounding), Dd^T in x 2^ed, K x 2^8, + // the accumulator x 2^-(ed + 8) after + const float sPre = gtc_lds128(bsc + GCH - 1).y * sO; // exp(gL) +#pragma unroll + for (int j = 0; j < 16; ++j) +#pragma unroll + for (int q = 0; q < 4; ++q) s[j][q] *= sPre; + float dd[4][4]; +#pragma unroll + for (int nt = 0; nt < 4; ++nt) { + const float f0 = gtc_lds128(bsc + 8 * nt + 2 * tig).z * sD, f1 = gtc_lds128(bsc + 8 * nt + 2 * tig + 1).z * sD; + dd[nt][0] = dt[nt][0] * f0; dd[nt][1] = dt[nt][1] * f1; dd[nt][2] = dt[nt][2] * f0; dd[nt][3] = dt[nt][3] * f1; + } + gtc_update_state(s, dd, bkh, bkl); +#pragma unroll + for (int j = 0; j < 16; ++j) +#pragma unroll + for (int q = 0; q < 4; ++q) s[j][q] *= sOi; + } + // the final state and its witness (a non-finite state value never becomes finite again, so the final state is enough) + unsigned bad = 0; +#pragma unroll + for (int j = 0; j < 16; ++j) { + float* p = state_out + (size_t) (8 * j + 2 * tig) * rs + (size_t) vh * S + ca + gid; + p[0] = s[j][0]; p[rs] = s[j][1]; p[8] = s[j][2]; p[rs + 8] = s[j][3]; +#pragma unroll + for (int q = 0; q < 4; ++q) bad |= (__float_as_uint(s[j][q]) & 0x7f800000u) == 0x7f800000u; + } + if (bad) atomicOr(witness, 1u); +} +} // namespace + +// ---- the prep, a block per (chunk, key head): the same A, solve, T and P as the chunk algebra, but the Gram products k_t.k_i and +// q_t.k_i on the tensor cores (f16x3 from the k and q hi / lo images x 2^8, which the block builds first in shared memory straight from +// the float4 registers the rows arrive in, rows past the chunk's end zero), and it writes what the scan stages by cp.async with no +// conversion of its own: the same k / q images, P as f16 hi / lo images x 2^8 and the token scalars (beta, exp(gamma), exp(gL - gamma), +// gamma) as a float4 a token, T as f16 hi / lo images x 2^et, et from the warp's largest |T| (2^-et beside them in te). The Gram +// entries are within 3 x 2^-22 of exact, so T and P differ from the sequential algebra's by that. +// Grid: nch * HK blocks, block b = chunk b / HK of the super-block, key head b % HK (a 1-D grid: KernelModule's contract). +extern "C" __global__ void __launch_bounds__(256) leleka_gdn_tc_prep( + const float* __restrict__ h, const float* __restrict__ gate, const float* __restrict__ beta, uint16_t* __restrict__ ti, + float* __restrict__ te, float4* __restrict__ sc, uint16_t* __restrict__ kq, uint16_t* __restrict__ pi, int64_t t0, + int64_t T) { + extern __shared__ __align__(16) float gsm[]; + uint16_t* im = reinterpret_cast(gsm); // [4][GCH][GTC_KP] k hi, k lo, q hi, q lo (x 2^8) + float* skk = gsm + 4 * GCH * GTC_KP / 2; // [GCH][GTP] k_t.k_i + float* sqk = skk + GCH * GTP; // [GCH][GTP] q_t.k_i + float* sa = gsm; // [VPK][GCH][GTP] A, then T below the diagonal (over the images: read by then) + const int qh = blockIdx.x % HK, ch = blockIdx.x / HK, tid = threadIdx.x, lane = tid & 31, warp = tid >> 5; + const int64_t tb = t0 + (int64_t) ch * GCH; + const int n = (int) min((int64_t) GCH, T - tb); + // after the Gram: warps j and VPK + j take value head j (lane i: token i), the first A, the solve and T, the second P and the token + // scalars; their beta and gate (past the end: gate 0, beta 0, no effect on S) are loaded now so that they are in by then + const int j = warp % VPK, vh = qh + j * HK, i = lane; + const bool pv = warp < 2 * VPK && i < n; + const float b = pv ? beta[(tb + i) * HV + vh] : 0.0f; + float gam = pv ? gate[(tb + i) * HV + vh] : 0.0f; + { // k and q as float4, every load issued before the first store; the images to shared and to global + constexpr int NP = GCH * S / 4 / 256; // float4 a thread, each of k and q + float4 kv[NP], qv[NP]; +#pragma unroll + for (int m = 0; m < NP; ++m) { + const int p = tid + 256 * m, t = p / (S / 4), r = (p % (S / 4)) * 4; + kv[m] = t < n ? *reinterpret_cast(h + (tb + t) * C + HK * S + qh * S + r) : make_float4(0.f, 0.f, 0.f, 0.f); + qv[m] = t < n ? *reinterpret_cast(h + (tb + t) * C + qh * S + r) : make_float4(0.f, 0.f, 0.f, 0.f); + } + uint16_t* img = kq + ((size_t) ch * HK + qh) * 4 * GCH * S; +#pragma unroll + for (int m = 0; m < NP; ++m) { + const int p = tid + 256 * m, t = p / (S / 4), r = (p % (S / 4)) * 4; + const int o = t * GTC_KP + r; + gtc_split_store4(im + o, im + GCH * GTC_KP + o, kv[m], 256.0f); + gtc_split_store4(im + 2 * GCH * GTC_KP + o, im + 3 * GCH * GTC_KP + o, qv[m], 256.0f); + gtc_split_store4(img + t * S + r, img + GCH * S + t * S + r, kv[m], 256.0f); + gtc_split_store4(img + 2 * GCH * S + t * S + r, img + 3 * GCH * S + t * S + r, qv[m], 256.0f); + } + } + __syncthreads(); + { // the Gram products: warp w takes product w >> 2 (k_t.k_i, q_t.k_i), rows 16 ((w >> 1) & 1).. (the A tile, by ldmatrix as a + // row-major [t][r] 16 x 16), columns 16 (w & 1).. (two n-tiles: B = k^T, stored [n][k] = the k rows, by ldmatrix as the scan's + // gtc_prod_state); the accumulators come out x 2^16 + const int pr = warp >> 2, mt = (warp >> 1) & 1, np = warp & 1; + const uint16_t* ah_ = im + 2 * pr * GCH * GTC_KP + (16 * mt + (lane & 7) + 8 * ((lane >> 3) & 1)) * GTC_KP + 8 * (lane >> 4); + const uint16_t* bh_ = im + (16 * np + 8 * (lane >> 4) + (lane & 7)) * GTC_KP + 8 * ((lane >> 3) & 1); + float c[2][4] = {}; +#pragma unroll + for (int kk = 0; kk < S / 16; ++kk) { + uint32_t ah[4], al[4], bh[4], bl[4]; + gtc_ldsm_x4(ah, ah_ + 16 * kk); + gtc_ldsm_x4(al, ah_ + GCH * GTC_KP + 16 * kk); + gtc_ldsm_x4(bh, bh_ + 16 * kk); + gtc_ldsm_x4(bl, bh_ + GCH * GTC_KP + 16 * kk); + gtc_mma3_f16(c[0], ah, al, bh[0], bh[1], bl[0], bl[1]); + gtc_mma3_f16(c[1], ah, al, bh[2], bh[3], bl[2], bl[3]); + } + float* g = pr ? sqk : skk; + const int gid = lane >> 2, tig = lane & 3; +#pragma unroll + for (int jj = 0; jj < 2; ++jj) +#pragma unroll + for (int q = 0; q < 4; ++q) { + const int t = 16 * mt + gid + 8 * (q >> 1), ii = 16 * np + 8 * jj + 2 * tig + (q & 1); + g[t * GTP + ii] = ii <= t ? c[jj][q] * gtc_pow2(-16) : 0.0f; + } + } + __syncthreads(); + if (warp >= 2 * VPK) return; +#pragma unroll + for (int o = 1; o < 32; o <<= 1) { + const float u = __shfl_up_sync(0xffffffffu, gam, o); + if (lane >= o) gam += u; + } + if (warp >= VPK) { // P = exp(gamma_t - gamma_i) q_t.k_i (i <= t) x 2^8 as f16 hi / lo; the scalars + uint16_t* Ph = pi + ((int64_t) ch * HV + vh) * 2 * GCH * GCH; + uint16_t* Pl = Ph + GCH * GCH; +#pragma unroll + for (int t = 0; t < GCH; ++t) { + const float gt = __shfl_sync(0xffffffffu, gam, t); + const float p = (i <= t ? expf(gt - gam) * sqk[t * GTP + i] : 0.0f) * 256.0f; + const __half hi = __float2half_rn(p); + Ph[t * GCH + i] = __half_as_ushort(hi); + Pl[t * GCH + i] = __half_as_ushort(__float2half_rn(p - __half2float(hi))); + } + const float gL = __shfl_sync(0xffffffffu, gam, GCH - 1); + sc[((int64_t) ch * HV + vh) * GCH + i] = make_float4(b, expf(gam), expf(gL - gam), gam); + return; + } + float* a = sa + j * GCH * GTP; +#pragma unroll + for (int t = 0; t < GCH; ++t) { + const float gt = __shfl_sync(0xffffffffu, gam, t), bt = __shfl_sync(0xffffffffu, b, t); + a[t * GTP + i] = i < t ? bt * expf(gt - gam) * skk[t * GTP + i] : (i == t ? 1.0f : 0.0f); + } + __syncwarp(); + // T = (I + A)^-1 by forward substitution, row by row: T[t][i] = -sum_{k < t} A[t][k] T[k][i] over the finished rows (diagonal 1, + // zeros above it: the terms k < i add an exact 0, so the same bits as summing from k = i). Lane i keeps its column T[.][i] in + // registers, so a row needs only A's row t (a broadcast load a term) and A is never written: no store and no __syncwarp a row + float tv[GCH]; + tv[0] = i == 0 ? 1.0f : 0.0f; +#pragma unroll + for (int t = 1; t < GCH; ++t) { + float v = 0.0f; +#pragma unroll + for (int k = 0; k < t; ++k) v = fmaf(-a[t * GTP + k], tv[k], v); + tv[t] = i < t ? v : (i == t ? 1.0f : 0.0f); + } + // T's images x 2^et (its largest entry in [2^14, 2^15), as the scan scales its own operands) + float mt4[4] = {}; +#pragma unroll + for (int t = 0; t < GCH; ++t) mt4[t & 3] = fmaxf(mt4[t & 3], fabsf(tv[t])); + const int et = gtc_scale_exp(gtc_warp_max(fmaxf(fmaxf(mt4[0], mt4[1]), fmaxf(mt4[2], mt4[3])))); + const float sT = gtc_pow2(et); + uint16_t* Th = ti + ((int64_t) ch * HV + vh) * 2 * GCH * GCH; + uint16_t* Tl = Th + GCH * GCH; +#pragma unroll + for (int t = 0; t < GCH; ++t) { + const float x = tv[t] * sT; + const __half hi = __float2half_rn(x); + Th[t * GCH + i] = __half_as_ushort(hi); + Tl[t * GCH + i] = __half_as_ushort(__float2half_rn(x - __half2float(hi))); + } + if (i == 0) te[(int64_t) ch * HV + vh] = gtc_pow2(-et); +} + +// ---- the two scan entries. Arguments: state_in, state_out, h, ti, te, sc, kq, pi, oc_out, t0 (first token of the super-block), nch (its +// chunks), T (tokens of the whole prompt chunk), witness. +extern "C" __global__ void __launch_bounds__(GTC_CW * 32, 1) leleka_gdn_tc_scan_t1( + const float* state_in, float* state_out, const float* h, const uint16_t* ti, const float* te, const float4* sc, + const uint16_t* kq, const uint16_t* pi, float* oc_out, int64_t t0, int nch, int64_t T, unsigned* witness) { + gtc_scan_body<1>(state_in, state_out, h, ti, te, sc, kq, pi, oc_out, t0, nch, T, witness); +} +extern "C" __global__ void __launch_bounds__(GTC_CW * 32, 1) leleka_gdn_tc_scan_t2( + const float* state_in, float* state_out, const float* h, const uint16_t* ti, const float* te, const float4* sc, + const uint16_t* kq, const uint16_t* pi, float* oc_out, int64_t t0, int nch, int64_t T, unsigned* witness) { + gtc_scan_body<2>(state_in, state_out, h, ti, te, sc, kq, pi, oc_out, t0, nch, T, witness); +} diff --git a/crates/cuda-driver/src/gdn_prefill_tc.ptx b/crates/cuda-driver/src/gdn_prefill_tc.ptx new file mode 100644 index 00000000..e9c00679 --- /dev/null +++ b/crates/cuda-driver/src/gdn_prefill_tc.ptx @@ -0,0 +1,14291 @@ +// +// 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 leleka_gdn_tc_prep +.extern .shared .align 16 .b8 gsm[]; +.extern .shared .align 16 .b8 _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE[]; + +.visible .entry leleka_gdn_tc_prep( + .param .u64 .ptr .align 1 leleka_gdn_tc_prep_param_0, + .param .u64 .ptr .align 1 leleka_gdn_tc_prep_param_1, + .param .u64 .ptr .align 1 leleka_gdn_tc_prep_param_2, + .param .u64 .ptr .align 1 leleka_gdn_tc_prep_param_3, + .param .u64 .ptr .align 1 leleka_gdn_tc_prep_param_4, + .param .u64 .ptr .align 1 leleka_gdn_tc_prep_param_5, + .param .u64 .ptr .align 1 leleka_gdn_tc_prep_param_6, + .param .u64 .ptr .align 1 leleka_gdn_tc_prep_param_7, + .param .u64 leleka_gdn_tc_prep_param_8, + .param .u64 leleka_gdn_tc_prep_param_9 +) +.maxntid 256 +{ + .reg .pred %p<281>; + .reg .b16 %rs<135>; + .reg .b32 %r<3371>; + .reg .b64 %rd<95>; + + ld.param.b64 %rd10, [leleka_gdn_tc_prep_param_1]; + ld.param.b64 %rd11, [leleka_gdn_tc_prep_param_2]; + ld.param.b64 %rd12, [leleka_gdn_tc_prep_param_8]; + ld.param.b64 %rd13, [leleka_gdn_tc_prep_param_9]; + mov.u32 %r1, %ctaid.x; + and.b32 %r2, %r1, 15; + shr.u32 %r3, %r1, 4; + mov.u32 %r145, %tid.x; + and.b32 %r4, %r145, 31; + shr.u32 %r5, %r145, 5; + mul.wide.u32 %rd14, %r3, 32; + add.s64 %rd1, %rd12, %rd14; + sub.s64 %rd15, %rd13, %rd1; + min.s64 %rd16, %rd15, 32; + cvt.u32.u64 %r6, %rd16; + cvt.u16.u32 %rs1, %r5; + mul.lo.s16 %rs2, %rs1, 171; + shr.u16 %rs3, %rs2, 9; + mul.lo.s16 %rs4, %rs3, 3; + sub.s16 %rs5, %rs1, %rs4; + cvt.u32.u16 %r146, %rs5; + and.b32 %r7, %r146, 255; + and.b16 %rs6, %rs5, 255; + mul.wide.u16 %r147, %rs6, 16; + or.b32 %r8, %r147, %r2; + setp.gt.u32 %p1, %r145, 191; + setp.ge.s32 %p2, %r4, %r6; + mov.b32 %r3275, 0f00000000; + mov.b32 %r3274, 0; + or.pred %p3, %p1, %p2; + @%p3 bra $L__BB0_2; + cvta.to.global.u64 %rd17, %rd10; + cvta.to.global.u64 %rd18, %rd11; + cvt.u64.u32 %rd19, %r4; + add.s64 %rd20, %rd1, %rd19; + cvt.u64.u32 %rd21, %r8; + mad.lo.s64 %rd22, %rd20, 48, %rd21; + shl.b64 %rd23, %rd22, 2; + add.s64 %rd24, %rd18, %rd23; + ld.global.nc.b32 %r3274, [%rd24]; + add.s64 %rd25, %rd17, %rd23; + ld.global.nc.b32 %r3275, [%rd25]; +$L__BB0_2: + ld.param.b64 %rd88, [leleka_gdn_tc_prep_param_0]; + shl.b32 %r148, %r145, 2; + and.b32 %r149, %r148, 124; + shl.b32 %r150, %r2, 7; + or.b32 %r151, %r150, %r149; + cvta.to.global.u64 %rd26, %rd88; + mul.wide.u32 %rd27, %r151, 4; + add.s64 %rd2, %rd26, %rd27; + setp.ge.s32 %p4, %r5, %r6; + mov.b32 %r3276, 0f00000000; + mov.b32 %r3277, %r3276; + mov.b32 %r3278, %r3276; + mov.b32 %r3279, %r3276; + mov.b32 %r3280, %r3276; + mov.b32 %r3281, %r3276; + mov.b32 %r3282, %r3276; + mov.b32 %r3283, %r3276; + @%p4 bra $L__BB0_4; + cvt.u64.u32 %rd28, %r5; + add.s64 %rd29, %rd1, %rd28; + mad.lo.s64 %rd30, %rd29, 40960, %rd2; + ld.global.nc.v4.b32 {%r152, %r153, %r154, %r155}, [%rd30+8192]; + ld.global.nc.v4.b32 {%r156, %r157, %r158, %r159}, [%rd30]; + mul.f32 %r3276, %r152, 0f43800000; + mul.f32 %r3277, %r153, 0f43800000; + mul.f32 %r3278, %r154, 0f43800000; + mul.f32 %r3279, %r155, 0f43800000; + mul.f32 %r3280, %r156, 0f43800000; + mul.f32 %r3281, %r157, 0f43800000; + mul.f32 %r3282, %r158, 0f43800000; + mul.f32 %r3283, %r159, 0f43800000; +$L__BB0_4: + add.s32 %r160, %r145, 256; + shr.u32 %r9, %r160, 5; + setp.ge.s32 %p5, %r9, %r6; + cvt.u64.u32 %rd31, %r9; + add.s64 %rd32, %rd1, %rd31; + mad.lo.s64 %rd3, %rd32, 40960, %rd2; + mov.b32 %r3284, 0f00000000; + mov.b32 %r3285, %r3284; + mov.b32 %r3286, %r3284; + mov.b32 %r3287, %r3284; + @%p5 bra $L__BB0_6; + ld.global.nc.v4.b32 {%r161, %r162, %r163, %r164}, [%rd3+8192]; + mul.f32 %r3284, %r161, 0f43800000; + mul.f32 %r3285, %r162, 0f43800000; + mul.f32 %r3286, %r163, 0f43800000; + mul.f32 %r3287, %r164, 0f43800000; +$L__BB0_6: + setp.ge.s32 %p6, %r9, %r6; + mov.b32 %r3288, 0f00000000; + mov.b32 %r3289, %r3288; + mov.b32 %r3290, %r3288; + mov.b32 %r3291, %r3288; + @%p6 bra $L__BB0_8; + ld.global.nc.v4.b32 {%r165, %r166, %r167, %r168}, [%rd3]; + mul.f32 %r3288, %r165, 0f43800000; + mul.f32 %r3289, %r166, 0f43800000; + mul.f32 %r3290, %r167, 0f43800000; + mul.f32 %r3291, %r168, 0f43800000; +$L__BB0_8: + add.s32 %r169, %r145, 512; + shr.u32 %r10, %r169, 5; + setp.ge.s32 %p7, %r10, %r6; + cvt.u64.u32 %rd33, %r10; + add.s64 %rd34, %rd1, %rd33; + mad.lo.s64 %rd4, %rd34, 40960, %rd2; + mov.b32 %r3292, 0f00000000; + mov.b32 %r3293, %r3292; + mov.b32 %r3294, %r3292; + mov.b32 %r3295, %r3292; + @%p7 bra $L__BB0_10; + ld.global.nc.v4.b32 {%r170, %r171, %r172, %r173}, [%rd4+8192]; + mul.f32 %r3292, %r170, 0f43800000; + mul.f32 %r3293, %r171, 0f43800000; + mul.f32 %r3294, %r172, 0f43800000; + mul.f32 %r3295, %r173, 0f43800000; +$L__BB0_10: + mov.b32 %r3296, 0f00000000; + mov.b32 %r3297, %r3296; + mov.b32 %r3298, %r3296; + mov.b32 %r3299, %r3296; + @%p7 bra $L__BB0_12; + ld.global.nc.v4.b32 {%r174, %r175, %r176, %r177}, [%rd4]; + mul.f32 %r3296, %r174, 0f43800000; + mul.f32 %r3297, %r175, 0f43800000; + mul.f32 %r3298, %r176, 0f43800000; + mul.f32 %r3299, %r177, 0f43800000; +$L__BB0_12: + ld.param.b64 %rd89, [leleka_gdn_tc_prep_param_0]; + add.s32 %r178, %r145, 768; + shr.u32 %r11, %r178, 5; + setp.ge.s32 %p8, %r11, %r6; + cvt.u64.u32 %rd35, %r11; + add.s64 %rd36, %rd1, %rd35; + cvta.to.global.u64 %rd37, %rd89; + shl.b32 %r179, %r1, 7; + and.b32 %r180, %r179, 1920; + shl.b32 %r181, %r145, 2; + and.b32 %r182, %r181, 124; + or.b32 %r183, %r180, %r182; + mul.wide.u32 %rd38, %r183, 4; + add.s64 %rd39, %rd37, %rd38; + mad.lo.s64 %rd5, %rd36, 40960, %rd39; + mov.b32 %r3300, 0f00000000; + mov.b32 %r3301, %r3300; + mov.b32 %r3302, %r3300; + mov.b32 %r3303, %r3300; + @%p8 bra $L__BB0_14; + ld.global.nc.v4.b32 {%r184, %r185, %r186, %r187}, [%rd5+8192]; + mul.f32 %r3300, %r184, 0f43800000; + mul.f32 %r3301, %r185, 0f43800000; + mul.f32 %r3302, %r186, 0f43800000; + mul.f32 %r3303, %r187, 0f43800000; +$L__BB0_14: + mov.b32 %r3304, 0f00000000; + mov.b32 %r3305, %r3304; + mov.b32 %r3306, %r3304; + mov.b32 %r3307, %r3304; + @%p8 bra $L__BB0_16; + ld.global.nc.v4.b32 {%r188, %r189, %r190, %r191}, [%rd5]; + mul.f32 %r3304, %r188, 0f43800000; + mul.f32 %r3305, %r189, 0f43800000; + mul.f32 %r3306, %r190, 0f43800000; + mul.f32 %r3307, %r191, 0f43800000; +$L__BB0_16: + ld.param.b64 %rd93, [leleka_gdn_tc_prep_param_6]; + mul.wide.u32 %rd40, %r1, 32768; + cvta.to.global.u64 %rd41, %rd93; + add.s64 %rd42, %rd41, %rd40; + shr.u32 %r456, %r145, 5; + shl.b32 %r457, %r145, 2; + and.b32 %r458, %r457, 124; + mad.lo.s32 %r459, %r456, 136, %r458; + shl.b32 %r460, %r459, 1; + mov.b32 %r461, gsm; + add.s32 %r462, %r461, %r460; + // begin inline asm + { cvt.rn.f16x2.f32 %r193, %r3277, %r3276; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r193; + cvt.f32.f16 %r192, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r193; + cvt.f32.f16 %r194, high;} + + // end inline asm + sub.f32 %r196, %r3276, %r192; + sub.f32 %r197, %r3277, %r194; + // begin inline asm + { cvt.rn.f16x2.f32 %r195, %r197, %r196; } + + // end inline asm + // begin inline asm + { cvt.rn.f16x2.f32 %r199, %r3279, %r3278; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r199; + cvt.f32.f16 %r198, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r199; + cvt.f32.f16 %r200, high;} + + // end inline asm + sub.f32 %r202, %r3278, %r198; + sub.f32 %r203, %r3279, %r200; + // begin inline asm + { cvt.rn.f16x2.f32 %r201, %r203, %r202; } + + // end inline asm + mov.b64 %rd43, {%r193, %r199}; + st.shared.b64 [%r462], %rd43; + mov.b64 %rd44, {%r195, %r201}; + st.shared.b64 [%r462+8704], %rd44; + // begin inline asm + { cvt.rn.f16x2.f32 %r205, %r3281, %r3280; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r205; + cvt.f32.f16 %r204, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r205; + cvt.f32.f16 %r206, high;} + + // end inline asm + sub.f32 %r208, %r3280, %r204; + sub.f32 %r209, %r3281, %r206; + // begin inline asm + { cvt.rn.f16x2.f32 %r207, %r209, %r208; } + + // end inline asm + // begin inline asm + { cvt.rn.f16x2.f32 %r211, %r3283, %r3282; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r211; + cvt.f32.f16 %r210, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r211; + cvt.f32.f16 %r212, high;} + + // end inline asm + sub.f32 %r214, %r3282, %r210; + sub.f32 %r215, %r3283, %r212; + // begin inline asm + { cvt.rn.f16x2.f32 %r213, %r215, %r214; } + + // end inline asm + mov.b64 %rd45, {%r205, %r211}; + st.shared.b64 [%r462+17408], %rd45; + mov.b64 %rd46, {%r207, %r213}; + st.shared.b64 [%r462+26112], %rd46; + shl.b32 %r463, %r456, 3; + sub.s32 %r464, %r459, %r463; + mul.wide.u32 %rd47, %r464, 2; + add.s64 %rd48, %rd42, %rd47; + st.global.b64 [%rd48], %rd43; + st.global.b64 [%rd48+8192], %rd44; + st.global.b64 [%rd48+16384], %rd45; + st.global.b64 [%rd48+24576], %rd46; + add.s32 %r465, %r145, 256; + shr.u32 %r466, %r465, 5; + mad.lo.s32 %r467, %r466, 136, %r458; + shl.b32 %r468, %r467, 1; + add.s32 %r469, %r461, %r468; + // begin inline asm + { cvt.rn.f16x2.f32 %r217, %r3285, %r3284; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r217; + cvt.f32.f16 %r216, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r217; + cvt.f32.f16 %r218, high;} + + // end inline asm + sub.f32 %r220, %r3284, %r216; + sub.f32 %r221, %r3285, %r218; + // begin inline asm + { cvt.rn.f16x2.f32 %r219, %r221, %r220; } + + // end inline asm + // begin inline asm + { cvt.rn.f16x2.f32 %r223, %r3287, %r3286; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r223; + cvt.f32.f16 %r222, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r223; + cvt.f32.f16 %r224, high;} + + // end inline asm + sub.f32 %r226, %r3286, %r222; + sub.f32 %r227, %r3287, %r224; + // begin inline asm + { cvt.rn.f16x2.f32 %r225, %r227, %r226; } + + // end inline asm + mov.b64 %rd49, {%r217, %r223}; + st.shared.b64 [%r469], %rd49; + mov.b64 %rd50, {%r219, %r225}; + st.shared.b64 [%r469+8704], %rd50; + // begin inline asm + { cvt.rn.f16x2.f32 %r229, %r3289, %r3288; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r229; + cvt.f32.f16 %r228, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r229; + cvt.f32.f16 %r230, high;} + + // end inline asm + sub.f32 %r232, %r3288, %r228; + sub.f32 %r233, %r3289, %r230; + // begin inline asm + { cvt.rn.f16x2.f32 %r231, %r233, %r232; } + + // end inline asm + // begin inline asm + { cvt.rn.f16x2.f32 %r235, %r3291, %r3290; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r235; + cvt.f32.f16 %r234, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r235; + cvt.f32.f16 %r236, high;} + + // end inline asm + sub.f32 %r238, %r3290, %r234; + sub.f32 %r239, %r3291, %r236; + // begin inline asm + { cvt.rn.f16x2.f32 %r237, %r239, %r238; } + + // end inline asm + mov.b64 %rd51, {%r229, %r235}; + st.shared.b64 [%r469+17408], %rd51; + mov.b64 %rd52, {%r231, %r237}; + st.shared.b64 [%r469+26112], %rd52; + shl.b32 %r470, %r466, 3; + sub.s32 %r471, %r467, %r470; + mul.wide.u32 %rd53, %r471, 2; + add.s64 %rd54, %rd42, %rd53; + st.global.b64 [%rd54], %rd49; + st.global.b64 [%rd54+8192], %rd50; + st.global.b64 [%rd54+16384], %rd51; + st.global.b64 [%rd54+24576], %rd52; + mad.lo.s32 %r472, %r10, 136, %r458; + shl.b32 %r473, %r472, 1; + add.s32 %r474, %r461, %r473; + // begin inline asm + { cvt.rn.f16x2.f32 %r241, %r3293, %r3292; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r241; + cvt.f32.f16 %r240, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r241; + cvt.f32.f16 %r242, high;} + + // end inline asm + sub.f32 %r244, %r3292, %r240; + sub.f32 %r245, %r3293, %r242; + // begin inline asm + { cvt.rn.f16x2.f32 %r243, %r245, %r244; } + + // end inline asm + // begin inline asm + { cvt.rn.f16x2.f32 %r247, %r3295, %r3294; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r247; + cvt.f32.f16 %r246, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r247; + cvt.f32.f16 %r248, high;} + + // end inline asm + sub.f32 %r250, %r3294, %r246; + sub.f32 %r251, %r3295, %r248; + // begin inline asm + { cvt.rn.f16x2.f32 %r249, %r251, %r250; } + + // end inline asm + mov.b64 %rd55, {%r241, %r247}; + st.shared.b64 [%r474], %rd55; + mov.b64 %rd56, {%r243, %r249}; + st.shared.b64 [%r474+8704], %rd56; + // begin inline asm + { cvt.rn.f16x2.f32 %r253, %r3297, %r3296; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r253; + cvt.f32.f16 %r252, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r253; + cvt.f32.f16 %r254, high;} + + // end inline asm + sub.f32 %r256, %r3296, %r252; + sub.f32 %r257, %r3297, %r254; + // begin inline asm + { cvt.rn.f16x2.f32 %r255, %r257, %r256; } + + // end inline asm + // begin inline asm + { cvt.rn.f16x2.f32 %r259, %r3299, %r3298; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r259; + cvt.f32.f16 %r258, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r259; + cvt.f32.f16 %r260, high;} + + // end inline asm + sub.f32 %r262, %r3298, %r258; + sub.f32 %r263, %r3299, %r260; + // begin inline asm + { cvt.rn.f16x2.f32 %r261, %r263, %r262; } + + // end inline asm + mov.b64 %rd57, {%r253, %r259}; + st.shared.b64 [%r474+17408], %rd57; + mov.b64 %rd58, {%r255, %r261}; + st.shared.b64 [%r474+26112], %rd58; + shl.b32 %r475, %r10, 3; + sub.s32 %r476, %r472, %r475; + mul.wide.u32 %rd59, %r476, 2; + add.s64 %rd60, %rd42, %rd59; + st.global.b64 [%rd60], %rd55; + st.global.b64 [%rd60+8192], %rd56; + st.global.b64 [%rd60+16384], %rd57; + st.global.b64 [%rd60+24576], %rd58; + mad.lo.s32 %r477, %r11, 136, %r458; + shl.b32 %r478, %r477, 1; + add.s32 %r479, %r461, %r478; + // begin inline asm + { cvt.rn.f16x2.f32 %r265, %r3301, %r3300; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r265; + cvt.f32.f16 %r264, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r265; + cvt.f32.f16 %r266, high;} + + // end inline asm + sub.f32 %r268, %r3300, %r264; + sub.f32 %r269, %r3301, %r266; + // begin inline asm + { cvt.rn.f16x2.f32 %r267, %r269, %r268; } + + // end inline asm + // begin inline asm + { cvt.rn.f16x2.f32 %r271, %r3303, %r3302; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r271; + cvt.f32.f16 %r270, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r271; + cvt.f32.f16 %r272, high;} + + // end inline asm + sub.f32 %r274, %r3302, %r270; + sub.f32 %r275, %r3303, %r272; + // begin inline asm + { cvt.rn.f16x2.f32 %r273, %r275, %r274; } + + // end inline asm + mov.b64 %rd61, {%r265, %r271}; + st.shared.b64 [%r479], %rd61; + mov.b64 %rd62, {%r267, %r273}; + st.shared.b64 [%r479+8704], %rd62; + // begin inline asm + { cvt.rn.f16x2.f32 %r277, %r3305, %r3304; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r277; + cvt.f32.f16 %r276, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r277; + cvt.f32.f16 %r278, high;} + + // end inline asm + sub.f32 %r280, %r3304, %r276; + sub.f32 %r281, %r3305, %r278; + // begin inline asm + { cvt.rn.f16x2.f32 %r279, %r281, %r280; } + + // end inline asm + // begin inline asm + { cvt.rn.f16x2.f32 %r283, %r3307, %r3306; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r283; + cvt.f32.f16 %r282, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r283; + cvt.f32.f16 %r284, high;} + + // end inline asm + sub.f32 %r286, %r3306, %r282; + sub.f32 %r287, %r3307, %r284; + // begin inline asm + { cvt.rn.f16x2.f32 %r285, %r287, %r286; } + + // end inline asm + mov.b64 %rd63, {%r277, %r283}; + st.shared.b64 [%r479+17408], %rd63; + mov.b64 %rd64, {%r279, %r285}; + st.shared.b64 [%r479+26112], %rd64; + shl.b32 %r480, %r11, 3; + sub.s32 %r481, %r477, %r480; + mul.wide.u32 %rd65, %r481, 2; + add.s64 %rd66, %rd42, %rd65; + st.global.b64 [%rd66], %rd61; + st.global.b64 [%rd66+8192], %rd62; + st.global.b64 [%rd66+16384], %rd63; + st.global.b64 [%rd66+24576], %rd64; + bar.sync 0; + shr.u32 %r482, %r145, 7; + mul.lo.s32 %r483, %r482, 8704; + shr.u32 %r484, %r145, 2; + and.b32 %r485, %r484, 16; + and.b32 %r486, %r145, 7; + and.b32 %r487, %r145, 8; + or.b32 %r488, %r487, %r486; + or.b32 %r489, %r488, %r485; + shr.u32 %r490, %r145, 1; + and.b32 %r491, %r490, 8; + or.b32 %r492, %r491, %r483; + mad.lo.s32 %r493, %r489, 136, %r492; + and.b32 %r494, %r490, 16; + or.b32 %r495, %r491, %r486; + or.b32 %r496, %r495, %r494; + mad.lo.s32 %r497, %r496, 136, %r487; + shl.b32 %r498, %r497, 1; + add.s32 %r290, %r461, %r498; + add.s32 %r291, %r290, 8704; + shl.b32 %r499, %r493, 1; + add.s32 %r288, %r461, %r499; + add.s32 %r289, %r288, 8704; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r302,%r303,%r304,%r305}, [%r288]; + // end inline asm + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r292,%r293,%r294,%r295}, [%r289]; + // end inline asm + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r296,%r297,%r308,%r309}, [%r290]; + // end inline asm + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r306,%r307,%r314,%r315}, [%r291]; + // end inline asm + mov.b32 %r310, 0; + mov.b32 %r298, %r310; + mov.b32 %r299, %r310; + mov.b32 %r300, %r310; + mov.b32 %r301, %r310; + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r298,%r299,%r300,%r301}, {%r292,%r293,%r294,%r295}, {%r296,%r297}, {%r298,%r299,%r300,%r301}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r298,%r299,%r300,%r301}, {%r302,%r303,%r304,%r305}, {%r306,%r307}, {%r298,%r299,%r300,%r301}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r298,%r299,%r300,%r301}, {%r302,%r303,%r304,%r305}, {%r296,%r297}, {%r298,%r299,%r300,%r301}; + // end inline asm + mov.b32 %r311, %r310; + mov.b32 %r312, %r310; + mov.b32 %r313, %r310; + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r310,%r311,%r312,%r313}, {%r292,%r293,%r294,%r295}, {%r308,%r309}, {%r310,%r311,%r312,%r313}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r310,%r311,%r312,%r313}, {%r302,%r303,%r304,%r305}, {%r314,%r315}, {%r310,%r311,%r312,%r313}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r310,%r311,%r312,%r313}, {%r302,%r303,%r304,%r305}, {%r308,%r309}, {%r310,%r311,%r312,%r313}; + // end inline asm + add.s32 %r316, %r288, 32; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r326,%r327,%r328,%r329}, [%r316]; + // end inline asm + add.s32 %r317, %r288, 8736; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r320,%r321,%r322,%r323}, [%r317]; + // end inline asm + add.s32 %r318, %r290, 32; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r324,%r325,%r332,%r333}, [%r318]; + // end inline asm + add.s32 %r319, %r290, 8736; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r330,%r331,%r334,%r335}, [%r319]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r298,%r299,%r300,%r301}, {%r320,%r321,%r322,%r323}, {%r324,%r325}, {%r298,%r299,%r300,%r301}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r298,%r299,%r300,%r301}, {%r326,%r327,%r328,%r329}, {%r330,%r331}, {%r298,%r299,%r300,%r301}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r298,%r299,%r300,%r301}, {%r326,%r327,%r328,%r329}, {%r324,%r325}, {%r298,%r299,%r300,%r301}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r310,%r311,%r312,%r313}, {%r320,%r321,%r322,%r323}, {%r332,%r333}, {%r310,%r311,%r312,%r313}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r310,%r311,%r312,%r313}, {%r326,%r327,%r328,%r329}, {%r334,%r335}, {%r310,%r311,%r312,%r313}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r310,%r311,%r312,%r313}, {%r326,%r327,%r328,%r329}, {%r332,%r333}, {%r310,%r311,%r312,%r313}; + // end inline asm + add.s32 %r336, %r288, 64; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r346,%r347,%r348,%r349}, [%r336]; + // end inline asm + add.s32 %r337, %r288, 8768; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r340,%r341,%r342,%r343}, [%r337]; + // end inline asm + add.s32 %r338, %r290, 64; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r344,%r345,%r352,%r353}, [%r338]; + // end inline asm + add.s32 %r339, %r290, 8768; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r350,%r351,%r354,%r355}, [%r339]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r298,%r299,%r300,%r301}, {%r340,%r341,%r342,%r343}, {%r344,%r345}, {%r298,%r299,%r300,%r301}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r298,%r299,%r300,%r301}, {%r346,%r347,%r348,%r349}, {%r350,%r351}, {%r298,%r299,%r300,%r301}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r298,%r299,%r300,%r301}, {%r346,%r347,%r348,%r349}, {%r344,%r345}, {%r298,%r299,%r300,%r301}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r310,%r311,%r312,%r313}, {%r340,%r341,%r342,%r343}, {%r352,%r353}, {%r310,%r311,%r312,%r313}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r310,%r311,%r312,%r313}, {%r346,%r347,%r348,%r349}, {%r354,%r355}, {%r310,%r311,%r312,%r313}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r310,%r311,%r312,%r313}, {%r346,%r347,%r348,%r349}, {%r352,%r353}, {%r310,%r311,%r312,%r313}; + // end inline asm + add.s32 %r356, %r288, 96; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r366,%r367,%r368,%r369}, [%r356]; + // end inline asm + add.s32 %r357, %r288, 8800; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r360,%r361,%r362,%r363}, [%r357]; + // end inline asm + add.s32 %r358, %r290, 96; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r364,%r365,%r372,%r373}, [%r358]; + // end inline asm + add.s32 %r359, %r290, 8800; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r370,%r371,%r374,%r375}, [%r359]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r298,%r299,%r300,%r301}, {%r360,%r361,%r362,%r363}, {%r364,%r365}, {%r298,%r299,%r300,%r301}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r298,%r299,%r300,%r301}, {%r366,%r367,%r368,%r369}, {%r370,%r371}, {%r298,%r299,%r300,%r301}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r298,%r299,%r300,%r301}, {%r366,%r367,%r368,%r369}, {%r364,%r365}, {%r298,%r299,%r300,%r301}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r310,%r311,%r312,%r313}, {%r360,%r361,%r362,%r363}, {%r372,%r373}, {%r310,%r311,%r312,%r313}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r310,%r311,%r312,%r313}, {%r366,%r367,%r368,%r369}, {%r374,%r375}, {%r310,%r311,%r312,%r313}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r310,%r311,%r312,%r313}, {%r366,%r367,%r368,%r369}, {%r372,%r373}, {%r310,%r311,%r312,%r313}; + // end inline asm + add.s32 %r376, %r288, 128; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r386,%r387,%r388,%r389}, [%r376]; + // end inline asm + add.s32 %r377, %r288, 8832; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r380,%r381,%r382,%r383}, [%r377]; + // end inline asm + add.s32 %r378, %r290, 128; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r384,%r385,%r392,%r393}, [%r378]; + // end inline asm + add.s32 %r379, %r290, 8832; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r390,%r391,%r394,%r395}, [%r379]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r298,%r299,%r300,%r301}, {%r380,%r381,%r382,%r383}, {%r384,%r385}, {%r298,%r299,%r300,%r301}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r298,%r299,%r300,%r301}, {%r386,%r387,%r388,%r389}, {%r390,%r391}, {%r298,%r299,%r300,%r301}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r298,%r299,%r300,%r301}, {%r386,%r387,%r388,%r389}, {%r384,%r385}, {%r298,%r299,%r300,%r301}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r310,%r311,%r312,%r313}, {%r380,%r381,%r382,%r383}, {%r392,%r393}, {%r310,%r311,%r312,%r313}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r310,%r311,%r312,%r313}, {%r386,%r387,%r388,%r389}, {%r394,%r395}, {%r310,%r311,%r312,%r313}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r310,%r311,%r312,%r313}, {%r386,%r387,%r388,%r389}, {%r392,%r393}, {%r310,%r311,%r312,%r313}; + // end inline asm + add.s32 %r396, %r288, 160; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r406,%r407,%r408,%r409}, [%r396]; + // end inline asm + add.s32 %r397, %r288, 8864; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r400,%r401,%r402,%r403}, [%r397]; + // end inline asm + add.s32 %r398, %r290, 160; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r404,%r405,%r412,%r413}, [%r398]; + // end inline asm + add.s32 %r399, %r290, 8864; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r410,%r411,%r414,%r415}, [%r399]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r298,%r299,%r300,%r301}, {%r400,%r401,%r402,%r403}, {%r404,%r405}, {%r298,%r299,%r300,%r301}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r298,%r299,%r300,%r301}, {%r406,%r407,%r408,%r409}, {%r410,%r411}, {%r298,%r299,%r300,%r301}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r298,%r299,%r300,%r301}, {%r406,%r407,%r408,%r409}, {%r404,%r405}, {%r298,%r299,%r300,%r301}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r310,%r311,%r312,%r313}, {%r400,%r401,%r402,%r403}, {%r412,%r413}, {%r310,%r311,%r312,%r313}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r310,%r311,%r312,%r313}, {%r406,%r407,%r408,%r409}, {%r414,%r415}, {%r310,%r311,%r312,%r313}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r310,%r311,%r312,%r313}, {%r406,%r407,%r408,%r409}, {%r412,%r413}, {%r310,%r311,%r312,%r313}; + // end inline asm + add.s32 %r416, %r288, 192; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r426,%r427,%r428,%r429}, [%r416]; + // end inline asm + add.s32 %r417, %r288, 8896; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r420,%r421,%r422,%r423}, [%r417]; + // end inline asm + add.s32 %r418, %r290, 192; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r424,%r425,%r432,%r433}, [%r418]; + // end inline asm + add.s32 %r419, %r290, 8896; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r430,%r431,%r434,%r435}, [%r419]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r298,%r299,%r300,%r301}, {%r420,%r421,%r422,%r423}, {%r424,%r425}, {%r298,%r299,%r300,%r301}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r298,%r299,%r300,%r301}, {%r426,%r427,%r428,%r429}, {%r430,%r431}, {%r298,%r299,%r300,%r301}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r298,%r299,%r300,%r301}, {%r426,%r427,%r428,%r429}, {%r424,%r425}, {%r298,%r299,%r300,%r301}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r310,%r311,%r312,%r313}, {%r420,%r421,%r422,%r423}, {%r432,%r433}, {%r310,%r311,%r312,%r313}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r310,%r311,%r312,%r313}, {%r426,%r427,%r428,%r429}, {%r434,%r435}, {%r310,%r311,%r312,%r313}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r310,%r311,%r312,%r313}, {%r426,%r427,%r428,%r429}, {%r432,%r433}, {%r310,%r311,%r312,%r313}; + // end inline asm + add.s32 %r436, %r288, 224; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r446,%r447,%r448,%r449}, [%r436]; + // end inline asm + add.s32 %r437, %r288, 8928; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r440,%r441,%r442,%r443}, [%r437]; + // end inline asm + add.s32 %r438, %r290, 224; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r444,%r445,%r452,%r453}, [%r438]; + // end inline asm + add.s32 %r439, %r290, 8928; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r450,%r451,%r454,%r455}, [%r439]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r298,%r299,%r300,%r301}, {%r440,%r441,%r442,%r443}, {%r444,%r445}, {%r298,%r299,%r300,%r301}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r298,%r299,%r300,%r301}, {%r446,%r447,%r448,%r449}, {%r450,%r451}, {%r298,%r299,%r300,%r301}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r298,%r299,%r300,%r301}, {%r446,%r447,%r448,%r449}, {%r444,%r445}, {%r298,%r299,%r300,%r301}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r310,%r311,%r312,%r313}, {%r440,%r441,%r442,%r443}, {%r452,%r453}, {%r310,%r311,%r312,%r313}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r310,%r311,%r312,%r313}, {%r446,%r447,%r448,%r449}, {%r454,%r455}, {%r310,%r311,%r312,%r313}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r310,%r311,%r312,%r313}, {%r446,%r447,%r448,%r449}, {%r452,%r453}, {%r310,%r311,%r312,%r313}; + // end inline asm + setp.lt.u32 %p9, %r145, 128; + selp.b32 %r500, 34816, 39040, %p9; + add.s32 %r501, %r461, %r500; + shr.u32 %r502, %r4, 2; + or.b32 %r503, %r485, %r502; + shl.b32 %r504, %r145, 1; + and.b32 %r505, %r504, 6; + or.b32 %r506, %r494, %r505; + setp.gt.u32 %p10, %r506, %r503; + mul.f32 %r507, %r298, 0f37800000; + selp.f32 %r508, 0f00000000, %r507, %p10; + mad.lo.s32 %r509, %r503, 33, %r506; + shl.b32 %r510, %r509, 2; + add.s32 %r511, %r501, %r510; + st.shared.b32 [%r511], %r508; + setp.lt.u32 %p11, %r506, %r503; + mul.f32 %r512, %r299, 0f37800000; + selp.f32 %r513, %r512, 0f00000000, %p11; + st.shared.b32 [%r511+4], %r513; + or.b32 %r514, %r503, 8; + setp.gt.u32 %p12, %r506, %r514; + mul.f32 %r515, %r300, 0f37800000; + selp.f32 %r516, 0f00000000, %r515, %p12; + st.shared.b32 [%r511+1056], %r516; + setp.lt.u32 %p13, %r506, %r514; + mul.f32 %r517, %r301, 0f37800000; + selp.f32 %r518, %r517, 0f00000000, %p13; + st.shared.b32 [%r511+1060], %r518; + or.b32 %r519, %r506, 8; + setp.gt.u32 %p14, %r519, %r503; + mul.f32 %r520, %r310, 0f37800000; + selp.f32 %r521, 0f00000000, %r520, %p14; + st.shared.b32 [%r511+32], %r521; + or.b32 %r522, %r506, 9; + setp.gt.u32 %p15, %r522, %r503; + mul.f32 %r523, %r311, 0f37800000; + selp.f32 %r524, 0f00000000, %r523, %p15; + st.shared.b32 [%r511+36], %r524; + mul.f32 %r525, %r312, 0f37800000; + selp.f32 %r526, 0f00000000, %r525, %p10; + st.shared.b32 [%r511+1088], %r526; + setp.gt.u32 %p16, %r522, %r514; + mul.f32 %r527, %r313, 0f37800000; + selp.f32 %r528, 0f00000000, %r527, %p16; + st.shared.b32 [%r511+1092], %r528; + bar.sync 0; + setp.gt.u32 %p17, %r145, 191; + @%p17 bra $L__BB0_177; + shl.b32 %r529, %r7, 4; + mov.u32 %r530, %ctaid.x; + and.b32 %r531, %r530, 15; + or.b32 %r12, %r529, %r531; + shfl.sync.up.b32 %r532|%p18, %r3275, 1, 0, -1; + setp.eq.b32 %p19, %r4, 0; + add.f32 %r533, %r3275, %r532; + selp.f32 %r534, %r3275, %r533, %p19; + shfl.sync.up.b32 %r535|%p20, %r534, 2, 0, -1; + setp.lt.u32 %p21, %r4, 2; + add.f32 %r536, %r534, %r535; + selp.f32 %r537, %r534, %r536, %p21; + shfl.sync.up.b32 %r538|%p22, %r537, 4, 0, -1; + setp.lt.u32 %p23, %r4, 4; + add.f32 %r539, %r537, %r538; + selp.f32 %r540, %r537, %r539, %p23; + shfl.sync.up.b32 %r541|%p24, %r540, 8, 0, -1; + setp.lt.u32 %p25, %r4, 8; + add.f32 %r542, %r540, %r541; + selp.f32 %r13, %r540, %r542, %p25; + shfl.sync.up.b32 %r543|%p26, %r13, 16, 0, -1; + setp.lt.u32 %p27, %r4, 16; + add.f32 %r544, %r13, %r543; + selp.f32 %r14, %r13, %r544, %p27; + setp.lt.u32 %p28, %r145, 96; + @%p28 bra $L__BB0_81; + setp.ne.b32 %p217, %r4, 0; + mul.wide.u32 %rd77, %r3, 48; + cvt.u64.u32 %rd78, %r12; + add.s64 %rd6, %rd77, %rd78; + shfl.sync.idx.b32 %r15|%p218, %r14, 0, 31, -1; + mov.b32 %r3308, 0f00000000; + @%p217 bra $L__BB0_20; + sub.f32 %r2704, %r15, %r13; + fma.rn.f32 %r2705, %r2704, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r2706, %r2705; + mov.b32 %r2707, 0f4B400001; + mov.b32 %r2708, 0f437C0000; + fma.rm.f32 %r2709, %r2706, %r2708, %r2707; + add.f32 %r2710, %r2709, 0fCB40007F; + neg.f32 %r2711, %r2710; + fma.rn.f32 %r2712, %r2704, 0f3FB8AA3B, %r2711; + fma.rn.f32 %r2713, %r2704, 0f32A57060, %r2712; + shl.b32 %r2714, %r2709, 23; + ex2.approx.ftz.f32 %r2715, %r2713; + mul.f32 %r2716, %r2715, %r2714; + ld.shared.b32 %r2717, [gsm+39040]; + mul.f32 %r2718, %r2716, %r2717; + mul.f32 %r3308, %r2718, 0f43800000; +$L__BB0_20: + ld.param.b64 %rd94, [leleka_gdn_tc_prep_param_7]; + // begin inline asm + { cvt.rn.f16.f32 %rs71, %r3308;} + + // end inline asm + cvt.u64.u32 %rd7, %r4; + cvta.to.global.u64 %rd79, %rd94; + shl.b64 %rd80, %rd6, 12; + add.s64 %rd81, %rd79, %rd80; + mul.wide.u32 %rd82, %r4, 2; + add.s64 %rd8, %rd81, %rd82; + st.global.b16 [%rd8], %rs71; + // begin inline asm + { cvt.f32.f16 %r2719, %rs71;} + + // end inline asm + sub.f32 %r2720, %r3308, %r2719; + // begin inline asm + { cvt.rn.f16.f32 %rs72, %r2720;} + + // end inline asm + st.global.b16 [%rd8+2048], %rs72; + shfl.sync.idx.b32 %r16|%p219, %r14, 1, 31, -1; + setp.gt.u32 %p220, %r4, 1; + shl.b32 %r2721, %r4, 2; + mov.b32 %r2722, gsm; + add.s32 %r17, %r2722, %r2721; + mov.b32 %r3309, 0f00000000; + @%p220 bra $L__BB0_22; + sub.f32 %r2723, %r16, %r13; + fma.rn.f32 %r2724, %r2723, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r2725, %r2724; + mov.b32 %r2726, 0f4B400001; + mov.b32 %r2727, 0f437C0000; + fma.rm.f32 %r2728, %r2725, %r2727, %r2726; + add.f32 %r2729, %r2728, 0fCB40007F; + neg.f32 %r2730, %r2729; + fma.rn.f32 %r2731, %r2723, 0f3FB8AA3B, %r2730; + fma.rn.f32 %r2732, %r2723, 0f32A57060, %r2731; + shl.b32 %r2733, %r2728, 23; + ex2.approx.ftz.f32 %r2734, %r2732; + mul.f32 %r2735, %r2734, %r2733; + ld.shared.b32 %r2736, [%r17+39172]; + mul.f32 %r2737, %r2735, %r2736; + mul.f32 %r3309, %r2737, 0f43800000; +$L__BB0_22: + // begin inline asm + { cvt.rn.f16.f32 %rs73, %r3309;} + + // end inline asm + st.global.b16 [%rd8+64], %rs73; + // begin inline asm + { cvt.f32.f16 %r2738, %rs73;} + + // end inline asm + sub.f32 %r2739, %r3309, %r2738; + // begin inline asm + { cvt.rn.f16.f32 %rs74, %r2739;} + + // end inline asm + st.global.b16 [%rd8+2112], %rs74; + shfl.sync.idx.b32 %r18|%p221, %r14, 2, 31, -1; + setp.gt.u32 %p222, %r4, 2; + mov.b32 %r3310, 0f00000000; + @%p222 bra $L__BB0_24; + sub.f32 %r2740, %r18, %r13; + fma.rn.f32 %r2741, %r2740, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r2742, %r2741; + mov.b32 %r2743, 0f4B400001; + mov.b32 %r2744, 0f437C0000; + fma.rm.f32 %r2745, %r2742, %r2744, %r2743; + add.f32 %r2746, %r2745, 0fCB40007F; + neg.f32 %r2747, %r2746; + fma.rn.f32 %r2748, %r2740, 0f3FB8AA3B, %r2747; + fma.rn.f32 %r2749, %r2740, 0f32A57060, %r2748; + shl.b32 %r2750, %r2745, 23; + ex2.approx.ftz.f32 %r2751, %r2749; + mul.f32 %r2752, %r2751, %r2750; + ld.shared.b32 %r2753, [%r17+39304]; + mul.f32 %r2754, %r2752, %r2753; + mul.f32 %r3310, %r2754, 0f43800000; +$L__BB0_24: + // begin inline asm + { cvt.rn.f16.f32 %rs75, %r3310;} + + // end inline asm + st.global.b16 [%rd8+128], %rs75; + // begin inline asm + { cvt.f32.f16 %r2755, %rs75;} + + // end inline asm + sub.f32 %r2756, %r3310, %r2755; + // begin inline asm + { cvt.rn.f16.f32 %rs76, %r2756;} + + // end inline asm + st.global.b16 [%rd8+2176], %rs76; + shfl.sync.idx.b32 %r19|%p223, %r14, 3, 31, -1; + setp.gt.u32 %p224, %r4, 3; + mov.b32 %r3311, 0f00000000; + @%p224 bra $L__BB0_26; + sub.f32 %r2757, %r19, %r13; + fma.rn.f32 %r2758, %r2757, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r2759, %r2758; + mov.b32 %r2760, 0f4B400001; + mov.b32 %r2761, 0f437C0000; + fma.rm.f32 %r2762, %r2759, %r2761, %r2760; + add.f32 %r2763, %r2762, 0fCB40007F; + neg.f32 %r2764, %r2763; + fma.rn.f32 %r2765, %r2757, 0f3FB8AA3B, %r2764; + fma.rn.f32 %r2766, %r2757, 0f32A57060, %r2765; + shl.b32 %r2767, %r2762, 23; + ex2.approx.ftz.f32 %r2768, %r2766; + mul.f32 %r2769, %r2768, %r2767; + ld.shared.b32 %r2770, [%r17+39436]; + mul.f32 %r2771, %r2769, %r2770; + mul.f32 %r3311, %r2771, 0f43800000; +$L__BB0_26: + // begin inline asm + { cvt.rn.f16.f32 %rs77, %r3311;} + + // end inline asm + st.global.b16 [%rd8+192], %rs77; + // begin inline asm + { cvt.f32.f16 %r2772, %rs77;} + + // end inline asm + sub.f32 %r2773, %r3311, %r2772; + // begin inline asm + { cvt.rn.f16.f32 %rs78, %r2773;} + + // end inline asm + st.global.b16 [%rd8+2240], %rs78; + shfl.sync.idx.b32 %r20|%p225, %r14, 4, 31, -1; + setp.gt.u32 %p226, %r4, 4; + mov.b32 %r3312, 0f00000000; + @%p226 bra $L__BB0_28; + sub.f32 %r2774, %r20, %r13; + fma.rn.f32 %r2775, %r2774, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r2776, %r2775; + mov.b32 %r2777, 0f4B400001; + mov.b32 %r2778, 0f437C0000; + fma.rm.f32 %r2779, %r2776, %r2778, %r2777; + add.f32 %r2780, %r2779, 0fCB40007F; + neg.f32 %r2781, %r2780; + fma.rn.f32 %r2782, %r2774, 0f3FB8AA3B, %r2781; + fma.rn.f32 %r2783, %r2774, 0f32A57060, %r2782; + shl.b32 %r2784, %r2779, 23; + ex2.approx.ftz.f32 %r2785, %r2783; + mul.f32 %r2786, %r2785, %r2784; + ld.shared.b32 %r2787, [%r17+39568]; + mul.f32 %r2788, %r2786, %r2787; + mul.f32 %r3312, %r2788, 0f43800000; +$L__BB0_28: + // begin inline asm + { cvt.rn.f16.f32 %rs79, %r3312;} + + // end inline asm + st.global.b16 [%rd8+256], %rs79; + // begin inline asm + { cvt.f32.f16 %r2789, %rs79;} + + // end inline asm + sub.f32 %r2790, %r3312, %r2789; + // begin inline asm + { cvt.rn.f16.f32 %rs80, %r2790;} + + // end inline asm + st.global.b16 [%rd8+2304], %rs80; + shfl.sync.idx.b32 %r21|%p227, %r14, 5, 31, -1; + setp.gt.u32 %p228, %r4, 5; + mov.b32 %r3313, 0f00000000; + @%p228 bra $L__BB0_30; + sub.f32 %r2791, %r21, %r13; + fma.rn.f32 %r2792, %r2791, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r2793, %r2792; + mov.b32 %r2794, 0f4B400001; + mov.b32 %r2795, 0f437C0000; + fma.rm.f32 %r2796, %r2793, %r2795, %r2794; + add.f32 %r2797, %r2796, 0fCB40007F; + neg.f32 %r2798, %r2797; + fma.rn.f32 %r2799, %r2791, 0f3FB8AA3B, %r2798; + fma.rn.f32 %r2800, %r2791, 0f32A57060, %r2799; + shl.b32 %r2801, %r2796, 23; + ex2.approx.ftz.f32 %r2802, %r2800; + mul.f32 %r2803, %r2802, %r2801; + ld.shared.b32 %r2804, [%r17+39700]; + mul.f32 %r2805, %r2803, %r2804; + mul.f32 %r3313, %r2805, 0f43800000; +$L__BB0_30: + // begin inline asm + { cvt.rn.f16.f32 %rs81, %r3313;} + + // end inline asm + st.global.b16 [%rd8+320], %rs81; + // begin inline asm + { cvt.f32.f16 %r2806, %rs81;} + + // end inline asm + sub.f32 %r2807, %r3313, %r2806; + // begin inline asm + { cvt.rn.f16.f32 %rs82, %r2807;} + + // end inline asm + st.global.b16 [%rd8+2368], %rs82; + shfl.sync.idx.b32 %r22|%p229, %r14, 6, 31, -1; + setp.gt.u32 %p230, %r4, 6; + mov.b32 %r3314, 0f00000000; + @%p230 bra $L__BB0_32; + sub.f32 %r2808, %r22, %r13; + fma.rn.f32 %r2809, %r2808, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r2810, %r2809; + mov.b32 %r2811, 0f4B400001; + mov.b32 %r2812, 0f437C0000; + fma.rm.f32 %r2813, %r2810, %r2812, %r2811; + add.f32 %r2814, %r2813, 0fCB40007F; + neg.f32 %r2815, %r2814; + fma.rn.f32 %r2816, %r2808, 0f3FB8AA3B, %r2815; + fma.rn.f32 %r2817, %r2808, 0f32A57060, %r2816; + shl.b32 %r2818, %r2813, 23; + ex2.approx.ftz.f32 %r2819, %r2817; + mul.f32 %r2820, %r2819, %r2818; + ld.shared.b32 %r2821, [%r17+39832]; + mul.f32 %r2822, %r2820, %r2821; + mul.f32 %r3314, %r2822, 0f43800000; +$L__BB0_32: + // begin inline asm + { cvt.rn.f16.f32 %rs83, %r3314;} + + // end inline asm + st.global.b16 [%rd8+384], %rs83; + // begin inline asm + { cvt.f32.f16 %r2823, %rs83;} + + // end inline asm + sub.f32 %r2824, %r3314, %r2823; + // begin inline asm + { cvt.rn.f16.f32 %rs84, %r2824;} + + // end inline asm + st.global.b16 [%rd8+2432], %rs84; + shfl.sync.idx.b32 %r23|%p231, %r14, 7, 31, -1; + setp.gt.u32 %p232, %r4, 7; + mov.b32 %r3315, 0f00000000; + @%p232 bra $L__BB0_34; + sub.f32 %r2825, %r23, %r13; + fma.rn.f32 %r2826, %r2825, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r2827, %r2826; + mov.b32 %r2828, 0f4B400001; + mov.b32 %r2829, 0f437C0000; + fma.rm.f32 %r2830, %r2827, %r2829, %r2828; + add.f32 %r2831, %r2830, 0fCB40007F; + neg.f32 %r2832, %r2831; + fma.rn.f32 %r2833, %r2825, 0f3FB8AA3B, %r2832; + fma.rn.f32 %r2834, %r2825, 0f32A57060, %r2833; + shl.b32 %r2835, %r2830, 23; + ex2.approx.ftz.f32 %r2836, %r2834; + mul.f32 %r2837, %r2836, %r2835; + ld.shared.b32 %r2838, [%r17+39964]; + mul.f32 %r2839, %r2837, %r2838; + mul.f32 %r3315, %r2839, 0f43800000; +$L__BB0_34: + // begin inline asm + { cvt.rn.f16.f32 %rs85, %r3315;} + + // end inline asm + st.global.b16 [%rd8+448], %rs85; + // begin inline asm + { cvt.f32.f16 %r2840, %rs85;} + + // end inline asm + sub.f32 %r2841, %r3315, %r2840; + // begin inline asm + { cvt.rn.f16.f32 %rs86, %r2841;} + + // end inline asm + st.global.b16 [%rd8+2496], %rs86; + shfl.sync.idx.b32 %r24|%p233, %r14, 8, 31, -1; + setp.gt.u32 %p234, %r4, 8; + mov.b32 %r3316, 0f00000000; + @%p234 bra $L__BB0_36; + sub.f32 %r2842, %r24, %r13; + fma.rn.f32 %r2843, %r2842, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r2844, %r2843; + mov.b32 %r2845, 0f4B400001; + mov.b32 %r2846, 0f437C0000; + fma.rm.f32 %r2847, %r2844, %r2846, %r2845; + add.f32 %r2848, %r2847, 0fCB40007F; + neg.f32 %r2849, %r2848; + fma.rn.f32 %r2850, %r2842, 0f3FB8AA3B, %r2849; + fma.rn.f32 %r2851, %r2842, 0f32A57060, %r2850; + shl.b32 %r2852, %r2847, 23; + ex2.approx.ftz.f32 %r2853, %r2851; + mul.f32 %r2854, %r2853, %r2852; + ld.shared.b32 %r2855, [%r17+40096]; + mul.f32 %r2856, %r2854, %r2855; + mul.f32 %r3316, %r2856, 0f43800000; +$L__BB0_36: + // begin inline asm + { cvt.rn.f16.f32 %rs87, %r3316;} + + // end inline asm + st.global.b16 [%rd8+512], %rs87; + // begin inline asm + { cvt.f32.f16 %r2857, %rs87;} + + // end inline asm + sub.f32 %r2858, %r3316, %r2857; + // begin inline asm + { cvt.rn.f16.f32 %rs88, %r2858;} + + // end inline asm + st.global.b16 [%rd8+2560], %rs88; + shfl.sync.idx.b32 %r25|%p235, %r14, 9, 31, -1; + setp.gt.u32 %p236, %r4, 9; + mov.b32 %r3317, 0f00000000; + @%p236 bra $L__BB0_38; + sub.f32 %r2859, %r25, %r13; + fma.rn.f32 %r2860, %r2859, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r2861, %r2860; + mov.b32 %r2862, 0f4B400001; + mov.b32 %r2863, 0f437C0000; + fma.rm.f32 %r2864, %r2861, %r2863, %r2862; + add.f32 %r2865, %r2864, 0fCB40007F; + neg.f32 %r2866, %r2865; + fma.rn.f32 %r2867, %r2859, 0f3FB8AA3B, %r2866; + fma.rn.f32 %r2868, %r2859, 0f32A57060, %r2867; + shl.b32 %r2869, %r2864, 23; + ex2.approx.ftz.f32 %r2870, %r2868; + mul.f32 %r2871, %r2870, %r2869; + ld.shared.b32 %r2872, [%r17+40228]; + mul.f32 %r2873, %r2871, %r2872; + mul.f32 %r3317, %r2873, 0f43800000; +$L__BB0_38: + // begin inline asm + { cvt.rn.f16.f32 %rs89, %r3317;} + + // end inline asm + st.global.b16 [%rd8+576], %rs89; + // begin inline asm + { cvt.f32.f16 %r2874, %rs89;} + + // end inline asm + sub.f32 %r2875, %r3317, %r2874; + // begin inline asm + { cvt.rn.f16.f32 %rs90, %r2875;} + + // end inline asm + st.global.b16 [%rd8+2624], %rs90; + shfl.sync.idx.b32 %r26|%p237, %r14, 10, 31, -1; + setp.gt.u32 %p238, %r4, 10; + mov.b32 %r3318, 0f00000000; + @%p238 bra $L__BB0_40; + sub.f32 %r2876, %r26, %r13; + fma.rn.f32 %r2877, %r2876, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r2878, %r2877; + mov.b32 %r2879, 0f4B400001; + mov.b32 %r2880, 0f437C0000; + fma.rm.f32 %r2881, %r2878, %r2880, %r2879; + add.f32 %r2882, %r2881, 0fCB40007F; + neg.f32 %r2883, %r2882; + fma.rn.f32 %r2884, %r2876, 0f3FB8AA3B, %r2883; + fma.rn.f32 %r2885, %r2876, 0f32A57060, %r2884; + shl.b32 %r2886, %r2881, 23; + ex2.approx.ftz.f32 %r2887, %r2885; + mul.f32 %r2888, %r2887, %r2886; + ld.shared.b32 %r2889, [%r17+40360]; + mul.f32 %r2890, %r2888, %r2889; + mul.f32 %r3318, %r2890, 0f43800000; +$L__BB0_40: + // begin inline asm + { cvt.rn.f16.f32 %rs91, %r3318;} + + // end inline asm + st.global.b16 [%rd8+640], %rs91; + // begin inline asm + { cvt.f32.f16 %r2891, %rs91;} + + // end inline asm + sub.f32 %r2892, %r3318, %r2891; + // begin inline asm + { cvt.rn.f16.f32 %rs92, %r2892;} + + // end inline asm + st.global.b16 [%rd8+2688], %rs92; + shfl.sync.idx.b32 %r27|%p239, %r14, 11, 31, -1; + setp.gt.u32 %p240, %r4, 11; + mov.b32 %r3319, 0f00000000; + @%p240 bra $L__BB0_42; + sub.f32 %r2893, %r27, %r13; + fma.rn.f32 %r2894, %r2893, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r2895, %r2894; + mov.b32 %r2896, 0f4B400001; + mov.b32 %r2897, 0f437C0000; + fma.rm.f32 %r2898, %r2895, %r2897, %r2896; + add.f32 %r2899, %r2898, 0fCB40007F; + neg.f32 %r2900, %r2899; + fma.rn.f32 %r2901, %r2893, 0f3FB8AA3B, %r2900; + fma.rn.f32 %r2902, %r2893, 0f32A57060, %r2901; + shl.b32 %r2903, %r2898, 23; + ex2.approx.ftz.f32 %r2904, %r2902; + mul.f32 %r2905, %r2904, %r2903; + ld.shared.b32 %r2906, [%r17+40492]; + mul.f32 %r2907, %r2905, %r2906; + mul.f32 %r3319, %r2907, 0f43800000; +$L__BB0_42: + // begin inline asm + { cvt.rn.f16.f32 %rs93, %r3319;} + + // end inline asm + st.global.b16 [%rd8+704], %rs93; + // begin inline asm + { cvt.f32.f16 %r2908, %rs93;} + + // end inline asm + sub.f32 %r2909, %r3319, %r2908; + // begin inline asm + { cvt.rn.f16.f32 %rs94, %r2909;} + + // end inline asm + st.global.b16 [%rd8+2752], %rs94; + shfl.sync.idx.b32 %r28|%p241, %r14, 12, 31, -1; + setp.gt.u32 %p242, %r4, 12; + mov.b32 %r3320, 0f00000000; + @%p242 bra $L__BB0_44; + sub.f32 %r2910, %r28, %r13; + fma.rn.f32 %r2911, %r2910, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r2912, %r2911; + mov.b32 %r2913, 0f4B400001; + mov.b32 %r2914, 0f437C0000; + fma.rm.f32 %r2915, %r2912, %r2914, %r2913; + add.f32 %r2916, %r2915, 0fCB40007F; + neg.f32 %r2917, %r2916; + fma.rn.f32 %r2918, %r2910, 0f3FB8AA3B, %r2917; + fma.rn.f32 %r2919, %r2910, 0f32A57060, %r2918; + shl.b32 %r2920, %r2915, 23; + ex2.approx.ftz.f32 %r2921, %r2919; + mul.f32 %r2922, %r2921, %r2920; + ld.shared.b32 %r2923, [%r17+40624]; + mul.f32 %r2924, %r2922, %r2923; + mul.f32 %r3320, %r2924, 0f43800000; +$L__BB0_44: + // begin inline asm + { cvt.rn.f16.f32 %rs95, %r3320;} + + // end inline asm + st.global.b16 [%rd8+768], %rs95; + // begin inline asm + { cvt.f32.f16 %r2925, %rs95;} + + // end inline asm + sub.f32 %r2926, %r3320, %r2925; + // begin inline asm + { cvt.rn.f16.f32 %rs96, %r2926;} + + // end inline asm + st.global.b16 [%rd8+2816], %rs96; + shfl.sync.idx.b32 %r29|%p243, %r14, 13, 31, -1; + setp.gt.u32 %p244, %r4, 13; + mov.b32 %r3321, 0f00000000; + @%p244 bra $L__BB0_46; + sub.f32 %r2927, %r29, %r13; + fma.rn.f32 %r2928, %r2927, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r2929, %r2928; + mov.b32 %r2930, 0f4B400001; + mov.b32 %r2931, 0f437C0000; + fma.rm.f32 %r2932, %r2929, %r2931, %r2930; + add.f32 %r2933, %r2932, 0fCB40007F; + neg.f32 %r2934, %r2933; + fma.rn.f32 %r2935, %r2927, 0f3FB8AA3B, %r2934; + fma.rn.f32 %r2936, %r2927, 0f32A57060, %r2935; + shl.b32 %r2937, %r2932, 23; + ex2.approx.ftz.f32 %r2938, %r2936; + mul.f32 %r2939, %r2938, %r2937; + ld.shared.b32 %r2940, [%r17+40756]; + mul.f32 %r2941, %r2939, %r2940; + mul.f32 %r3321, %r2941, 0f43800000; +$L__BB0_46: + // begin inline asm + { cvt.rn.f16.f32 %rs97, %r3321;} + + // end inline asm + st.global.b16 [%rd8+832], %rs97; + // begin inline asm + { cvt.f32.f16 %r2942, %rs97;} + + // end inline asm + sub.f32 %r2943, %r3321, %r2942; + // begin inline asm + { cvt.rn.f16.f32 %rs98, %r2943;} + + // end inline asm + st.global.b16 [%rd8+2880], %rs98; + shfl.sync.idx.b32 %r30|%p245, %r14, 14, 31, -1; + setp.gt.u32 %p246, %r4, 14; + mov.b32 %r3322, 0f00000000; + @%p246 bra $L__BB0_48; + sub.f32 %r2944, %r30, %r13; + fma.rn.f32 %r2945, %r2944, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r2946, %r2945; + mov.b32 %r2947, 0f4B400001; + mov.b32 %r2948, 0f437C0000; + fma.rm.f32 %r2949, %r2946, %r2948, %r2947; + add.f32 %r2950, %r2949, 0fCB40007F; + neg.f32 %r2951, %r2950; + fma.rn.f32 %r2952, %r2944, 0f3FB8AA3B, %r2951; + fma.rn.f32 %r2953, %r2944, 0f32A57060, %r2952; + shl.b32 %r2954, %r2949, 23; + ex2.approx.ftz.f32 %r2955, %r2953; + mul.f32 %r2956, %r2955, %r2954; + ld.shared.b32 %r2957, [%r17+40888]; + mul.f32 %r2958, %r2956, %r2957; + mul.f32 %r3322, %r2958, 0f43800000; +$L__BB0_48: + // begin inline asm + { cvt.rn.f16.f32 %rs99, %r3322;} + + // end inline asm + st.global.b16 [%rd8+896], %rs99; + // begin inline asm + { cvt.f32.f16 %r2959, %rs99;} + + // end inline asm + sub.f32 %r2960, %r3322, %r2959; + // begin inline asm + { cvt.rn.f16.f32 %rs100, %r2960;} + + // end inline asm + st.global.b16 [%rd8+2944], %rs100; + shfl.sync.idx.b32 %r31|%p247, %r14, 15, 31, -1; + setp.gt.u32 %p248, %r4, 15; + mov.b32 %r3323, 0f00000000; + @%p248 bra $L__BB0_50; + sub.f32 %r2961, %r31, %r13; + fma.rn.f32 %r2962, %r2961, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r2963, %r2962; + mov.b32 %r2964, 0f4B400001; + mov.b32 %r2965, 0f437C0000; + fma.rm.f32 %r2966, %r2963, %r2965, %r2964; + add.f32 %r2967, %r2966, 0fCB40007F; + neg.f32 %r2968, %r2967; + fma.rn.f32 %r2969, %r2961, 0f3FB8AA3B, %r2968; + fma.rn.f32 %r2970, %r2961, 0f32A57060, %r2969; + shl.b32 %r2971, %r2966, 23; + ex2.approx.ftz.f32 %r2972, %r2970; + mul.f32 %r2973, %r2972, %r2971; + ld.shared.b32 %r2974, [%r17+41020]; + mul.f32 %r2975, %r2973, %r2974; + mul.f32 %r3323, %r2975, 0f43800000; +$L__BB0_50: + // begin inline asm + { cvt.rn.f16.f32 %rs101, %r3323;} + + // end inline asm + st.global.b16 [%rd8+960], %rs101; + // begin inline asm + { cvt.f32.f16 %r2976, %rs101;} + + // end inline asm + sub.f32 %r2977, %r3323, %r2976; + // begin inline asm + { cvt.rn.f16.f32 %rs102, %r2977;} + + // end inline asm + st.global.b16 [%rd8+3008], %rs102; + shfl.sync.idx.b32 %r32|%p249, %r14, 16, 31, -1; + setp.gt.u32 %p250, %r4, 16; + mov.b32 %r3324, 0f00000000; + @%p250 bra $L__BB0_52; + sub.f32 %r2978, %r32, %r14; + fma.rn.f32 %r2979, %r2978, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r2980, %r2979; + mov.b32 %r2981, 0f4B400001; + mov.b32 %r2982, 0f437C0000; + fma.rm.f32 %r2983, %r2980, %r2982, %r2981; + add.f32 %r2984, %r2983, 0fCB40007F; + neg.f32 %r2985, %r2984; + fma.rn.f32 %r2986, %r2978, 0f3FB8AA3B, %r2985; + fma.rn.f32 %r2987, %r2978, 0f32A57060, %r2986; + shl.b32 %r2988, %r2983, 23; + ex2.approx.ftz.f32 %r2989, %r2987; + mul.f32 %r2990, %r2989, %r2988; + ld.shared.b32 %r2991, [%r17+41152]; + mul.f32 %r2992, %r2990, %r2991; + mul.f32 %r3324, %r2992, 0f43800000; +$L__BB0_52: + // begin inline asm + { cvt.rn.f16.f32 %rs103, %r3324;} + + // end inline asm + st.global.b16 [%rd8+1024], %rs103; + // begin inline asm + { cvt.f32.f16 %r2993, %rs103;} + + // end inline asm + sub.f32 %r2994, %r3324, %r2993; + // begin inline asm + { cvt.rn.f16.f32 %rs104, %r2994;} + + // end inline asm + st.global.b16 [%rd8+3072], %rs104; + shfl.sync.idx.b32 %r33|%p251, %r14, 17, 31, -1; + setp.gt.u32 %p252, %r4, 17; + mov.b32 %r3325, 0f00000000; + @%p252 bra $L__BB0_54; + sub.f32 %r2995, %r33, %r14; + fma.rn.f32 %r2996, %r2995, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r2997, %r2996; + mov.b32 %r2998, 0f4B400001; + mov.b32 %r2999, 0f437C0000; + fma.rm.f32 %r3000, %r2997, %r2999, %r2998; + add.f32 %r3001, %r3000, 0fCB40007F; + neg.f32 %r3002, %r3001; + fma.rn.f32 %r3003, %r2995, 0f3FB8AA3B, %r3002; + fma.rn.f32 %r3004, %r2995, 0f32A57060, %r3003; + shl.b32 %r3005, %r3000, 23; + ex2.approx.ftz.f32 %r3006, %r3004; + mul.f32 %r3007, %r3006, %r3005; + ld.shared.b32 %r3008, [%r17+41284]; + mul.f32 %r3009, %r3007, %r3008; + mul.f32 %r3325, %r3009, 0f43800000; +$L__BB0_54: + // begin inline asm + { cvt.rn.f16.f32 %rs105, %r3325;} + + // end inline asm + st.global.b16 [%rd8+1088], %rs105; + // begin inline asm + { cvt.f32.f16 %r3010, %rs105;} + + // end inline asm + sub.f32 %r3011, %r3325, %r3010; + // begin inline asm + { cvt.rn.f16.f32 %rs106, %r3011;} + + // end inline asm + st.global.b16 [%rd8+3136], %rs106; + shfl.sync.idx.b32 %r34|%p253, %r14, 18, 31, -1; + setp.gt.u32 %p254, %r4, 18; + mov.b32 %r3326, 0f00000000; + @%p254 bra $L__BB0_56; + sub.f32 %r3012, %r34, %r14; + fma.rn.f32 %r3013, %r3012, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r3014, %r3013; + mov.b32 %r3015, 0f4B400001; + mov.b32 %r3016, 0f437C0000; + fma.rm.f32 %r3017, %r3014, %r3016, %r3015; + add.f32 %r3018, %r3017, 0fCB40007F; + neg.f32 %r3019, %r3018; + fma.rn.f32 %r3020, %r3012, 0f3FB8AA3B, %r3019; + fma.rn.f32 %r3021, %r3012, 0f32A57060, %r3020; + shl.b32 %r3022, %r3017, 23; + ex2.approx.ftz.f32 %r3023, %r3021; + mul.f32 %r3024, %r3023, %r3022; + ld.shared.b32 %r3025, [%r17+41416]; + mul.f32 %r3026, %r3024, %r3025; + mul.f32 %r3326, %r3026, 0f43800000; +$L__BB0_56: + // begin inline asm + { cvt.rn.f16.f32 %rs107, %r3326;} + + // end inline asm + st.global.b16 [%rd8+1152], %rs107; + // begin inline asm + { cvt.f32.f16 %r3027, %rs107;} + + // end inline asm + sub.f32 %r3028, %r3326, %r3027; + // begin inline asm + { cvt.rn.f16.f32 %rs108, %r3028;} + + // end inline asm + st.global.b16 [%rd8+3200], %rs108; + shfl.sync.idx.b32 %r35|%p255, %r14, 19, 31, -1; + setp.gt.u32 %p256, %r4, 19; + mov.b32 %r3327, 0f00000000; + @%p256 bra $L__BB0_58; + sub.f32 %r3029, %r35, %r14; + fma.rn.f32 %r3030, %r3029, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r3031, %r3030; + mov.b32 %r3032, 0f4B400001; + mov.b32 %r3033, 0f437C0000; + fma.rm.f32 %r3034, %r3031, %r3033, %r3032; + add.f32 %r3035, %r3034, 0fCB40007F; + neg.f32 %r3036, %r3035; + fma.rn.f32 %r3037, %r3029, 0f3FB8AA3B, %r3036; + fma.rn.f32 %r3038, %r3029, 0f32A57060, %r3037; + shl.b32 %r3039, %r3034, 23; + ex2.approx.ftz.f32 %r3040, %r3038; + mul.f32 %r3041, %r3040, %r3039; + ld.shared.b32 %r3042, [%r17+41548]; + mul.f32 %r3043, %r3041, %r3042; + mul.f32 %r3327, %r3043, 0f43800000; +$L__BB0_58: + // begin inline asm + { cvt.rn.f16.f32 %rs109, %r3327;} + + // end inline asm + st.global.b16 [%rd8+1216], %rs109; + // begin inline asm + { cvt.f32.f16 %r3044, %rs109;} + + // end inline asm + sub.f32 %r3045, %r3327, %r3044; + // begin inline asm + { cvt.rn.f16.f32 %rs110, %r3045;} + + // end inline asm + st.global.b16 [%rd8+3264], %rs110; + shfl.sync.idx.b32 %r36|%p257, %r14, 20, 31, -1; + setp.gt.u32 %p258, %r4, 20; + mov.b32 %r3328, 0f00000000; + @%p258 bra $L__BB0_60; + sub.f32 %r3046, %r36, %r14; + fma.rn.f32 %r3047, %r3046, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r3048, %r3047; + mov.b32 %r3049, 0f4B400001; + mov.b32 %r3050, 0f437C0000; + fma.rm.f32 %r3051, %r3048, %r3050, %r3049; + add.f32 %r3052, %r3051, 0fCB40007F; + neg.f32 %r3053, %r3052; + fma.rn.f32 %r3054, %r3046, 0f3FB8AA3B, %r3053; + fma.rn.f32 %r3055, %r3046, 0f32A57060, %r3054; + shl.b32 %r3056, %r3051, 23; + ex2.approx.ftz.f32 %r3057, %r3055; + mul.f32 %r3058, %r3057, %r3056; + ld.shared.b32 %r3059, [%r17+41680]; + mul.f32 %r3060, %r3058, %r3059; + mul.f32 %r3328, %r3060, 0f43800000; +$L__BB0_60: + // begin inline asm + { cvt.rn.f16.f32 %rs111, %r3328;} + + // end inline asm + st.global.b16 [%rd8+1280], %rs111; + // begin inline asm + { cvt.f32.f16 %r3061, %rs111;} + + // end inline asm + sub.f32 %r3062, %r3328, %r3061; + // begin inline asm + { cvt.rn.f16.f32 %rs112, %r3062;} + + // end inline asm + st.global.b16 [%rd8+3328], %rs112; + shfl.sync.idx.b32 %r37|%p259, %r14, 21, 31, -1; + setp.gt.u32 %p260, %r4, 21; + mov.b32 %r3329, 0f00000000; + @%p260 bra $L__BB0_62; + sub.f32 %r3063, %r37, %r14; + fma.rn.f32 %r3064, %r3063, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r3065, %r3064; + mov.b32 %r3066, 0f4B400001; + mov.b32 %r3067, 0f437C0000; + fma.rm.f32 %r3068, %r3065, %r3067, %r3066; + add.f32 %r3069, %r3068, 0fCB40007F; + neg.f32 %r3070, %r3069; + fma.rn.f32 %r3071, %r3063, 0f3FB8AA3B, %r3070; + fma.rn.f32 %r3072, %r3063, 0f32A57060, %r3071; + shl.b32 %r3073, %r3068, 23; + ex2.approx.ftz.f32 %r3074, %r3072; + mul.f32 %r3075, %r3074, %r3073; + ld.shared.b32 %r3076, [%r17+41812]; + mul.f32 %r3077, %r3075, %r3076; + mul.f32 %r3329, %r3077, 0f43800000; +$L__BB0_62: + // begin inline asm + { cvt.rn.f16.f32 %rs113, %r3329;} + + // end inline asm + st.global.b16 [%rd8+1344], %rs113; + // begin inline asm + { cvt.f32.f16 %r3078, %rs113;} + + // end inline asm + sub.f32 %r3079, %r3329, %r3078; + // begin inline asm + { cvt.rn.f16.f32 %rs114, %r3079;} + + // end inline asm + st.global.b16 [%rd8+3392], %rs114; + shfl.sync.idx.b32 %r38|%p261, %r14, 22, 31, -1; + setp.gt.u32 %p262, %r4, 22; + mov.b32 %r3330, 0f00000000; + @%p262 bra $L__BB0_64; + sub.f32 %r3080, %r38, %r14; + fma.rn.f32 %r3081, %r3080, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r3082, %r3081; + mov.b32 %r3083, 0f4B400001; + mov.b32 %r3084, 0f437C0000; + fma.rm.f32 %r3085, %r3082, %r3084, %r3083; + add.f32 %r3086, %r3085, 0fCB40007F; + neg.f32 %r3087, %r3086; + fma.rn.f32 %r3088, %r3080, 0f3FB8AA3B, %r3087; + fma.rn.f32 %r3089, %r3080, 0f32A57060, %r3088; + shl.b32 %r3090, %r3085, 23; + ex2.approx.ftz.f32 %r3091, %r3089; + mul.f32 %r3092, %r3091, %r3090; + ld.shared.b32 %r3093, [%r17+41944]; + mul.f32 %r3094, %r3092, %r3093; + mul.f32 %r3330, %r3094, 0f43800000; +$L__BB0_64: + // begin inline asm + { cvt.rn.f16.f32 %rs115, %r3330;} + + // end inline asm + st.global.b16 [%rd8+1408], %rs115; + // begin inline asm + { cvt.f32.f16 %r3095, %rs115;} + + // end inline asm + sub.f32 %r3096, %r3330, %r3095; + // begin inline asm + { cvt.rn.f16.f32 %rs116, %r3096;} + + // end inline asm + st.global.b16 [%rd8+3456], %rs116; + shfl.sync.idx.b32 %r39|%p263, %r14, 23, 31, -1; + setp.gt.u32 %p264, %r4, 23; + mov.b32 %r3331, 0f00000000; + @%p264 bra $L__BB0_66; + sub.f32 %r3097, %r39, %r14; + fma.rn.f32 %r3098, %r3097, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r3099, %r3098; + mov.b32 %r3100, 0f4B400001; + mov.b32 %r3101, 0f437C0000; + fma.rm.f32 %r3102, %r3099, %r3101, %r3100; + add.f32 %r3103, %r3102, 0fCB40007F; + neg.f32 %r3104, %r3103; + fma.rn.f32 %r3105, %r3097, 0f3FB8AA3B, %r3104; + fma.rn.f32 %r3106, %r3097, 0f32A57060, %r3105; + shl.b32 %r3107, %r3102, 23; + ex2.approx.ftz.f32 %r3108, %r3106; + mul.f32 %r3109, %r3108, %r3107; + ld.shared.b32 %r3110, [%r17+42076]; + mul.f32 %r3111, %r3109, %r3110; + mul.f32 %r3331, %r3111, 0f43800000; +$L__BB0_66: + // begin inline asm + { cvt.rn.f16.f32 %rs117, %r3331;} + + // end inline asm + st.global.b16 [%rd8+1472], %rs117; + // begin inline asm + { cvt.f32.f16 %r3112, %rs117;} + + // end inline asm + sub.f32 %r3113, %r3331, %r3112; + // begin inline asm + { cvt.rn.f16.f32 %rs118, %r3113;} + + // end inline asm + st.global.b16 [%rd8+3520], %rs118; + shfl.sync.idx.b32 %r40|%p265, %r14, 24, 31, -1; + setp.gt.u32 %p266, %r4, 24; + mov.b32 %r3332, 0f00000000; + @%p266 bra $L__BB0_68; + sub.f32 %r3114, %r40, %r14; + fma.rn.f32 %r3115, %r3114, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r3116, %r3115; + mov.b32 %r3117, 0f4B400001; + mov.b32 %r3118, 0f437C0000; + fma.rm.f32 %r3119, %r3116, %r3118, %r3117; + add.f32 %r3120, %r3119, 0fCB40007F; + neg.f32 %r3121, %r3120; + fma.rn.f32 %r3122, %r3114, 0f3FB8AA3B, %r3121; + fma.rn.f32 %r3123, %r3114, 0f32A57060, %r3122; + shl.b32 %r3124, %r3119, 23; + ex2.approx.ftz.f32 %r3125, %r3123; + mul.f32 %r3126, %r3125, %r3124; + ld.shared.b32 %r3127, [%r17+42208]; + mul.f32 %r3128, %r3126, %r3127; + mul.f32 %r3332, %r3128, 0f43800000; +$L__BB0_68: + // begin inline asm + { cvt.rn.f16.f32 %rs119, %r3332;} + + // end inline asm + st.global.b16 [%rd8+1536], %rs119; + // begin inline asm + { cvt.f32.f16 %r3129, %rs119;} + + // end inline asm + sub.f32 %r3130, %r3332, %r3129; + // begin inline asm + { cvt.rn.f16.f32 %rs120, %r3130;} + + // end inline asm + st.global.b16 [%rd8+3584], %rs120; + shfl.sync.idx.b32 %r41|%p267, %r14, 25, 31, -1; + setp.gt.u32 %p268, %r4, 25; + mov.b32 %r3333, 0f00000000; + @%p268 bra $L__BB0_70; + sub.f32 %r3131, %r41, %r14; + fma.rn.f32 %r3132, %r3131, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r3133, %r3132; + mov.b32 %r3134, 0f4B400001; + mov.b32 %r3135, 0f437C0000; + fma.rm.f32 %r3136, %r3133, %r3135, %r3134; + add.f32 %r3137, %r3136, 0fCB40007F; + neg.f32 %r3138, %r3137; + fma.rn.f32 %r3139, %r3131, 0f3FB8AA3B, %r3138; + fma.rn.f32 %r3140, %r3131, 0f32A57060, %r3139; + shl.b32 %r3141, %r3136, 23; + ex2.approx.ftz.f32 %r3142, %r3140; + mul.f32 %r3143, %r3142, %r3141; + ld.shared.b32 %r3144, [%r17+42340]; + mul.f32 %r3145, %r3143, %r3144; + mul.f32 %r3333, %r3145, 0f43800000; +$L__BB0_70: + // begin inline asm + { cvt.rn.f16.f32 %rs121, %r3333;} + + // end inline asm + st.global.b16 [%rd8+1600], %rs121; + // begin inline asm + { cvt.f32.f16 %r3146, %rs121;} + + // end inline asm + sub.f32 %r3147, %r3333, %r3146; + // begin inline asm + { cvt.rn.f16.f32 %rs122, %r3147;} + + // end inline asm + st.global.b16 [%rd8+3648], %rs122; + shfl.sync.idx.b32 %r42|%p269, %r14, 26, 31, -1; + setp.gt.u32 %p270, %r4, 26; + mov.b32 %r3334, 0f00000000; + @%p270 bra $L__BB0_72; + sub.f32 %r3148, %r42, %r14; + fma.rn.f32 %r3149, %r3148, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r3150, %r3149; + mov.b32 %r3151, 0f4B400001; + mov.b32 %r3152, 0f437C0000; + fma.rm.f32 %r3153, %r3150, %r3152, %r3151; + add.f32 %r3154, %r3153, 0fCB40007F; + neg.f32 %r3155, %r3154; + fma.rn.f32 %r3156, %r3148, 0f3FB8AA3B, %r3155; + fma.rn.f32 %r3157, %r3148, 0f32A57060, %r3156; + shl.b32 %r3158, %r3153, 23; + ex2.approx.ftz.f32 %r3159, %r3157; + mul.f32 %r3160, %r3159, %r3158; + ld.shared.b32 %r3161, [%r17+42472]; + mul.f32 %r3162, %r3160, %r3161; + mul.f32 %r3334, %r3162, 0f43800000; +$L__BB0_72: + // begin inline asm + { cvt.rn.f16.f32 %rs123, %r3334;} + + // end inline asm + st.global.b16 [%rd8+1664], %rs123; + // begin inline asm + { cvt.f32.f16 %r3163, %rs123;} + + // end inline asm + sub.f32 %r3164, %r3334, %r3163; + // begin inline asm + { cvt.rn.f16.f32 %rs124, %r3164;} + + // end inline asm + st.global.b16 [%rd8+3712], %rs124; + shfl.sync.idx.b32 %r43|%p271, %r14, 27, 31, -1; + setp.gt.u32 %p272, %r4, 27; + mov.b32 %r3335, 0f00000000; + @%p272 bra $L__BB0_74; + sub.f32 %r3165, %r43, %r14; + fma.rn.f32 %r3166, %r3165, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r3167, %r3166; + mov.b32 %r3168, 0f4B400001; + mov.b32 %r3169, 0f437C0000; + fma.rm.f32 %r3170, %r3167, %r3169, %r3168; + add.f32 %r3171, %r3170, 0fCB40007F; + neg.f32 %r3172, %r3171; + fma.rn.f32 %r3173, %r3165, 0f3FB8AA3B, %r3172; + fma.rn.f32 %r3174, %r3165, 0f32A57060, %r3173; + shl.b32 %r3175, %r3170, 23; + ex2.approx.ftz.f32 %r3176, %r3174; + mul.f32 %r3177, %r3176, %r3175; + ld.shared.b32 %r3178, [%r17+42604]; + mul.f32 %r3179, %r3177, %r3178; + mul.f32 %r3335, %r3179, 0f43800000; +$L__BB0_74: + // begin inline asm + { cvt.rn.f16.f32 %rs125, %r3335;} + + // end inline asm + st.global.b16 [%rd8+1728], %rs125; + // begin inline asm + { cvt.f32.f16 %r3180, %rs125;} + + // end inline asm + sub.f32 %r3181, %r3335, %r3180; + // begin inline asm + { cvt.rn.f16.f32 %rs126, %r3181;} + + // end inline asm + st.global.b16 [%rd8+3776], %rs126; + shfl.sync.idx.b32 %r44|%p273, %r14, 28, 31, -1; + setp.gt.u32 %p274, %r4, 28; + mov.b32 %r3336, 0f00000000; + @%p274 bra $L__BB0_76; + sub.f32 %r3182, %r44, %r14; + fma.rn.f32 %r3183, %r3182, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r3184, %r3183; + mov.b32 %r3185, 0f4B400001; + mov.b32 %r3186, 0f437C0000; + fma.rm.f32 %r3187, %r3184, %r3186, %r3185; + add.f32 %r3188, %r3187, 0fCB40007F; + neg.f32 %r3189, %r3188; + fma.rn.f32 %r3190, %r3182, 0f3FB8AA3B, %r3189; + fma.rn.f32 %r3191, %r3182, 0f32A57060, %r3190; + shl.b32 %r3192, %r3187, 23; + ex2.approx.ftz.f32 %r3193, %r3191; + mul.f32 %r3194, %r3193, %r3192; + ld.shared.b32 %r3195, [%r17+42736]; + mul.f32 %r3196, %r3194, %r3195; + mul.f32 %r3336, %r3196, 0f43800000; +$L__BB0_76: + // begin inline asm + { cvt.rn.f16.f32 %rs127, %r3336;} + + // end inline asm + st.global.b16 [%rd8+1792], %rs127; + // begin inline asm + { cvt.f32.f16 %r3197, %rs127;} + + // end inline asm + sub.f32 %r3198, %r3336, %r3197; + // begin inline asm + { cvt.rn.f16.f32 %rs128, %r3198;} + + // end inline asm + st.global.b16 [%rd8+3840], %rs128; + shfl.sync.idx.b32 %r45|%p275, %r14, 29, 31, -1; + setp.gt.u32 %p276, %r4, 29; + mov.b32 %r3337, 0f00000000; + @%p276 bra $L__BB0_78; + sub.f32 %r3199, %r45, %r14; + fma.rn.f32 %r3200, %r3199, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r3201, %r3200; + mov.b32 %r3202, 0f4B400001; + mov.b32 %r3203, 0f437C0000; + fma.rm.f32 %r3204, %r3201, %r3203, %r3202; + add.f32 %r3205, %r3204, 0fCB40007F; + neg.f32 %r3206, %r3205; + fma.rn.f32 %r3207, %r3199, 0f3FB8AA3B, %r3206; + fma.rn.f32 %r3208, %r3199, 0f32A57060, %r3207; + shl.b32 %r3209, %r3204, 23; + ex2.approx.ftz.f32 %r3210, %r3208; + mul.f32 %r3211, %r3210, %r3209; + ld.shared.b32 %r3212, [%r17+42868]; + mul.f32 %r3213, %r3211, %r3212; + mul.f32 %r3337, %r3213, 0f43800000; +$L__BB0_78: + // begin inline asm + { cvt.rn.f16.f32 %rs129, %r3337;} + + // end inline asm + st.global.b16 [%rd8+1856], %rs129; + // begin inline asm + { cvt.f32.f16 %r3214, %rs129;} + + // end inline asm + sub.f32 %r3215, %r3337, %r3214; + // begin inline asm + { cvt.rn.f16.f32 %rs130, %r3215;} + + // end inline asm + st.global.b16 [%rd8+3904], %rs130; + shfl.sync.idx.b32 %r46|%p277, %r14, 30, 31, -1; + setp.eq.b32 %p278, %r4, 31; + mov.b32 %r3338, 0f00000000; + @%p278 bra $L__BB0_80; + sub.f32 %r3216, %r46, %r14; + fma.rn.f32 %r3217, %r3216, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r3218, %r3217; + mov.b32 %r3219, 0f4B400001; + mov.b32 %r3220, 0f437C0000; + fma.rm.f32 %r3221, %r3218, %r3220, %r3219; + add.f32 %r3222, %r3221, 0fCB40007F; + neg.f32 %r3223, %r3222; + fma.rn.f32 %r3224, %r3216, 0f3FB8AA3B, %r3223; + fma.rn.f32 %r3225, %r3216, 0f32A57060, %r3224; + shl.b32 %r3226, %r3221, 23; + ex2.approx.ftz.f32 %r3227, %r3225; + mul.f32 %r3228, %r3227, %r3226; + ld.shared.b32 %r3229, [%r17+43000]; + mul.f32 %r3230, %r3228, %r3229; + mul.f32 %r3338, %r3230, 0f43800000; +$L__BB0_80: + ld.param.b64 %rd92, [leleka_gdn_tc_prep_param_5]; + // begin inline asm + { cvt.rn.f16.f32 %rs131, %r3338;} + + // end inline asm + st.global.b16 [%rd8+1920], %rs131; + // begin inline asm + { cvt.f32.f16 %r3231, %rs131;} + + // end inline asm + sub.f32 %r3232, %r3338, %r3231; + // begin inline asm + { cvt.rn.f16.f32 %rs132, %r3232;} + + // end inline asm + st.global.b16 [%rd8+3968], %rs132; + shfl.sync.idx.b32 %r3236|%p279, %r14, 31, 31, -1; + sub.f32 %r3237, %r3236, %r14; + fma.rn.f32 %r3238, %r3237, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r3239, %r3238; + mov.b32 %r3240, 0f4B400001; + mov.b32 %r3241, 0f437C0000; + fma.rm.f32 %r3242, %r3239, %r3241, %r3240; + add.f32 %r3243, %r3242, 0fCB40007F; + neg.f32 %r3244, %r3243; + fma.rn.f32 %r3245, %r3237, 0f3FB8AA3B, %r3244; + fma.rn.f32 %r3246, %r3237, 0f32A57060, %r3245; + shl.b32 %r3247, %r3242, 23; + ex2.approx.ftz.f32 %r3248, %r3246; + mul.f32 %r3249, %r3248, %r3247; + ld.shared.b32 %r3250, [%r17+43132]; + mul.f32 %r3251, %r3249, %r3250; + mul.f32 %r3233, %r3251, 0f43800000; + // begin inline asm + { cvt.rn.f16.f32 %rs133, %r3233;} + + // end inline asm + st.global.b16 [%rd8+1984], %rs133; + // begin inline asm + { cvt.f32.f16 %r3234, %rs133;} + + // end inline asm + sub.f32 %r3235, %r3233, %r3234; + // begin inline asm + { cvt.rn.f16.f32 %rs134, %r3235;} + + // end inline asm + st.global.b16 [%rd8+4032], %rs134; + shfl.sync.idx.b32 %r3252|%p280, %r14, 31, 31, -1; + fma.rn.f32 %r3253, %r14, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r3254, %r3253; + fma.rm.f32 %r3255, %r3254, %r3241, %r3240; + add.f32 %r3256, %r3255, 0fCB40007F; + neg.f32 %r3257, %r3256; + fma.rn.f32 %r3258, %r14, 0f3FB8AA3B, %r3257; + fma.rn.f32 %r3259, %r14, 0f32A57060, %r3258; + shl.b32 %r3260, %r3255, 23; + ex2.approx.ftz.f32 %r3261, %r3259; + mul.f32 %r3262, %r3261, %r3260; + sub.f32 %r3263, %r3252, %r14; + fma.rn.f32 %r3264, %r3263, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r3265, %r3264; + fma.rm.f32 %r3266, %r3265, %r3241, %r3240; + add.f32 %r3267, %r3266, 0fCB40007F; + neg.f32 %r3268, %r3267; + fma.rn.f32 %r3269, %r3263, 0f3FB8AA3B, %r3268; + fma.rn.f32 %r3270, %r3263, 0f32A57060, %r3269; + shl.b32 %r3271, %r3266, 23; + ex2.approx.ftz.f32 %r3272, %r3270; + mul.f32 %r3273, %r3272, %r3271; + cvta.to.global.u64 %rd83, %rd92; + shl.b64 %rd84, %rd7, 4; + shl.b64 %rd85, %rd6, 9; + or.b64 %rd86, %rd85, %rd84; + add.s64 %rd87, %rd83, %rd86; + st.global.v4.b32 [%rd87], {%r3274, %r3262, %r3273, %r14}; + bra.uni $L__BB0_177; +$L__BB0_81: + setp.eq.b32 %p29, %r4, 0; + mov.b32 %r545, gsm; + mad.lo.s32 %r47, %r7, 4224, %r545; + shfl.sync.idx.b32 %r546|%p30, %r14, 0, 31, -1; + shfl.sync.idx.b32 %r547|%p31, %r3274, 0, 31, -1; + selp.f32 %r48, 0f3F800000, 0f00000000, %p29; + shl.b32 %r548, %r4, 2; + add.s32 %r49, %r47, %r548; + st.shared.b32 [%r49], %r48; + shfl.sync.idx.b32 %r50|%p32, %r14, 1, 31, -1; + shfl.sync.idx.b32 %r51|%p33, %r3274, 1, 31, -1; + @%p29 bra $L__BB0_83; + setp.eq.b32 %p34, %r4, 1; + selp.f32 %r3339, 0f3F800000, 0f00000000, %p34; + bra.uni $L__BB0_84; +$L__BB0_83: + sub.f32 %r549, %r50, %r13; + fma.rn.f32 %r550, %r549, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r551, %r550; + mov.b32 %r552, 0f4B400001; + mov.b32 %r553, 0f437C0000; + fma.rm.f32 %r554, %r551, %r553, %r552; + add.f32 %r555, %r554, 0fCB40007F; + neg.f32 %r556, %r555; + fma.rn.f32 %r557, %r549, 0f3FB8AA3B, %r556; + fma.rn.f32 %r558, %r549, 0f32A57060, %r557; + shl.b32 %r559, %r554, 23; + ex2.approx.ftz.f32 %r560, %r558; + mul.f32 %r561, %r560, %r559; + mul.f32 %r562, %r561, %r51; + ld.shared.b32 %r563, [gsm+34948]; + mul.f32 %r3339, %r563, %r562; +$L__BB0_84: + setp.lt.u32 %p35, %r4, 2; + st.shared.b32 [%r49+132], %r3339; + shfl.sync.idx.b32 %r52|%p36, %r14, 2, 31, -1; + shfl.sync.idx.b32 %r53|%p37, %r3274, 2, 31, -1; + mov.b32 %r564, gsm; + add.s32 %r54, %r564, %r548; + @%p35 bra $L__BB0_86; + setp.eq.b32 %p38, %r4, 2; + selp.f32 %r3340, 0f3F800000, 0f00000000, %p38; + bra.uni $L__BB0_87; +$L__BB0_86: + sub.f32 %r565, %r52, %r13; + fma.rn.f32 %r566, %r565, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r567, %r566; + mov.b32 %r568, 0f4B400001; + mov.b32 %r569, 0f437C0000; + fma.rm.f32 %r570, %r567, %r569, %r568; + add.f32 %r571, %r570, 0fCB40007F; + neg.f32 %r572, %r571; + fma.rn.f32 %r573, %r565, 0f3FB8AA3B, %r572; + fma.rn.f32 %r574, %r565, 0f32A57060, %r573; + shl.b32 %r575, %r570, 23; + ex2.approx.ftz.f32 %r576, %r574; + mul.f32 %r577, %r576, %r575; + mul.f32 %r578, %r577, %r53; + ld.shared.b32 %r579, [%r54+35080]; + mul.f32 %r3340, %r579, %r578; +$L__BB0_87: + st.shared.b32 [%r49+264], %r3340; + shfl.sync.idx.b32 %r55|%p39, %r14, 3, 31, -1; + shfl.sync.idx.b32 %r56|%p40, %r3274, 3, 31, -1; + setp.lt.u32 %p41, %r4, 3; + @%p41 bra $L__BB0_89; + setp.eq.b32 %p42, %r4, 3; + selp.f32 %r3341, 0f3F800000, 0f00000000, %p42; + bra.uni $L__BB0_90; +$L__BB0_89: + sub.f32 %r580, %r55, %r13; + fma.rn.f32 %r581, %r580, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r582, %r581; + mov.b32 %r583, 0f4B400001; + mov.b32 %r584, 0f437C0000; + fma.rm.f32 %r585, %r582, %r584, %r583; + add.f32 %r586, %r585, 0fCB40007F; + neg.f32 %r587, %r586; + fma.rn.f32 %r588, %r580, 0f3FB8AA3B, %r587; + fma.rn.f32 %r589, %r580, 0f32A57060, %r588; + shl.b32 %r590, %r585, 23; + ex2.approx.ftz.f32 %r591, %r589; + mul.f32 %r592, %r591, %r590; + mul.f32 %r593, %r592, %r56; + ld.shared.b32 %r594, [%r54+35212]; + mul.f32 %r3341, %r594, %r593; +$L__BB0_90: + setp.lt.u32 %p43, %r4, 4; + st.shared.b32 [%r49+396], %r3341; + shfl.sync.idx.b32 %r57|%p44, %r14, 4, 31, -1; + shfl.sync.idx.b32 %r58|%p45, %r3274, 4, 31, -1; + @%p43 bra $L__BB0_92; + setp.eq.b32 %p46, %r4, 4; + selp.f32 %r3342, 0f3F800000, 0f00000000, %p46; + bra.uni $L__BB0_93; +$L__BB0_92: + sub.f32 %r595, %r57, %r13; + fma.rn.f32 %r596, %r595, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r597, %r596; + mov.b32 %r598, 0f4B400001; + mov.b32 %r599, 0f437C0000; + fma.rm.f32 %r600, %r597, %r599, %r598; + add.f32 %r601, %r600, 0fCB40007F; + neg.f32 %r602, %r601; + fma.rn.f32 %r603, %r595, 0f3FB8AA3B, %r602; + fma.rn.f32 %r604, %r595, 0f32A57060, %r603; + shl.b32 %r605, %r600, 23; + ex2.approx.ftz.f32 %r606, %r604; + mul.f32 %r607, %r606, %r605; + mul.f32 %r608, %r607, %r58; + ld.shared.b32 %r609, [%r54+35344]; + mul.f32 %r3342, %r609, %r608; +$L__BB0_93: + st.shared.b32 [%r49+528], %r3342; + shfl.sync.idx.b32 %r59|%p47, %r14, 5, 31, -1; + shfl.sync.idx.b32 %r60|%p48, %r3274, 5, 31, -1; + setp.lt.u32 %p49, %r4, 5; + @%p49 bra $L__BB0_95; + setp.eq.b32 %p50, %r4, 5; + selp.f32 %r3343, 0f3F800000, 0f00000000, %p50; + bra.uni $L__BB0_96; +$L__BB0_95: + sub.f32 %r610, %r59, %r13; + fma.rn.f32 %r611, %r610, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r612, %r611; + mov.b32 %r613, 0f4B400001; + mov.b32 %r614, 0f437C0000; + fma.rm.f32 %r615, %r612, %r614, %r613; + add.f32 %r616, %r615, 0fCB40007F; + neg.f32 %r617, %r616; + fma.rn.f32 %r618, %r610, 0f3FB8AA3B, %r617; + fma.rn.f32 %r619, %r610, 0f32A57060, %r618; + shl.b32 %r620, %r615, 23; + ex2.approx.ftz.f32 %r621, %r619; + mul.f32 %r622, %r621, %r620; + mul.f32 %r623, %r622, %r60; + ld.shared.b32 %r624, [%r54+35476]; + mul.f32 %r3343, %r624, %r623; +$L__BB0_96: + st.shared.b32 [%r49+660], %r3343; + shfl.sync.idx.b32 %r61|%p51, %r14, 6, 31, -1; + shfl.sync.idx.b32 %r62|%p52, %r3274, 6, 31, -1; + setp.lt.u32 %p53, %r4, 6; + @%p53 bra $L__BB0_98; + setp.eq.b32 %p54, %r4, 6; + selp.f32 %r3344, 0f3F800000, 0f00000000, %p54; + bra.uni $L__BB0_99; +$L__BB0_98: + sub.f32 %r625, %r61, %r13; + fma.rn.f32 %r626, %r625, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r627, %r626; + mov.b32 %r628, 0f4B400001; + mov.b32 %r629, 0f437C0000; + fma.rm.f32 %r630, %r627, %r629, %r628; + add.f32 %r631, %r630, 0fCB40007F; + neg.f32 %r632, %r631; + fma.rn.f32 %r633, %r625, 0f3FB8AA3B, %r632; + fma.rn.f32 %r634, %r625, 0f32A57060, %r633; + shl.b32 %r635, %r630, 23; + ex2.approx.ftz.f32 %r636, %r634; + mul.f32 %r637, %r636, %r635; + mul.f32 %r638, %r637, %r62; + ld.shared.b32 %r639, [%r54+35608]; + mul.f32 %r3344, %r639, %r638; +$L__BB0_99: + st.shared.b32 [%r49+792], %r3344; + shfl.sync.idx.b32 %r63|%p55, %r14, 7, 31, -1; + shfl.sync.idx.b32 %r64|%p56, %r3274, 7, 31, -1; + setp.lt.u32 %p57, %r4, 7; + @%p57 bra $L__BB0_101; + setp.eq.b32 %p58, %r4, 7; + selp.f32 %r3345, 0f3F800000, 0f00000000, %p58; + bra.uni $L__BB0_102; +$L__BB0_101: + sub.f32 %r640, %r63, %r13; + fma.rn.f32 %r641, %r640, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r642, %r641; + mov.b32 %r643, 0f4B400001; + mov.b32 %r644, 0f437C0000; + fma.rm.f32 %r645, %r642, %r644, %r643; + add.f32 %r646, %r645, 0fCB40007F; + neg.f32 %r647, %r646; + fma.rn.f32 %r648, %r640, 0f3FB8AA3B, %r647; + fma.rn.f32 %r649, %r640, 0f32A57060, %r648; + shl.b32 %r650, %r645, 23; + ex2.approx.ftz.f32 %r651, %r649; + mul.f32 %r652, %r651, %r650; + mul.f32 %r653, %r652, %r64; + ld.shared.b32 %r654, [%r54+35740]; + mul.f32 %r3345, %r654, %r653; +$L__BB0_102: + setp.lt.u32 %p59, %r4, 8; + st.shared.b32 [%r49+924], %r3345; + shfl.sync.idx.b32 %r65|%p60, %r14, 8, 31, -1; + shfl.sync.idx.b32 %r66|%p61, %r3274, 8, 31, -1; + @%p59 bra $L__BB0_104; + setp.eq.b32 %p62, %r4, 8; + selp.f32 %r3346, 0f3F800000, 0f00000000, %p62; + bra.uni $L__BB0_105; +$L__BB0_104: + sub.f32 %r655, %r65, %r13; + fma.rn.f32 %r656, %r655, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r657, %r656; + mov.b32 %r658, 0f4B400001; + mov.b32 %r659, 0f437C0000; + fma.rm.f32 %r660, %r657, %r659, %r658; + add.f32 %r661, %r660, 0fCB40007F; + neg.f32 %r662, %r661; + fma.rn.f32 %r663, %r655, 0f3FB8AA3B, %r662; + fma.rn.f32 %r664, %r655, 0f32A57060, %r663; + shl.b32 %r665, %r660, 23; + ex2.approx.ftz.f32 %r666, %r664; + mul.f32 %r667, %r666, %r665; + mul.f32 %r668, %r667, %r66; + ld.shared.b32 %r669, [%r54+35872]; + mul.f32 %r3346, %r669, %r668; +$L__BB0_105: + st.shared.b32 [%r49+1056], %r3346; + shfl.sync.idx.b32 %r67|%p63, %r14, 9, 31, -1; + shfl.sync.idx.b32 %r68|%p64, %r3274, 9, 31, -1; + setp.lt.u32 %p65, %r4, 9; + @%p65 bra $L__BB0_107; + setp.eq.b32 %p66, %r4, 9; + selp.f32 %r3347, 0f3F800000, 0f00000000, %p66; + bra.uni $L__BB0_108; +$L__BB0_107: + sub.f32 %r670, %r67, %r13; + fma.rn.f32 %r671, %r670, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r672, %r671; + mov.b32 %r673, 0f4B400001; + mov.b32 %r674, 0f437C0000; + fma.rm.f32 %r675, %r672, %r674, %r673; + add.f32 %r676, %r675, 0fCB40007F; + neg.f32 %r677, %r676; + fma.rn.f32 %r678, %r670, 0f3FB8AA3B, %r677; + fma.rn.f32 %r679, %r670, 0f32A57060, %r678; + shl.b32 %r680, %r675, 23; + ex2.approx.ftz.f32 %r681, %r679; + mul.f32 %r682, %r681, %r680; + mul.f32 %r683, %r682, %r68; + ld.shared.b32 %r684, [%r54+36004]; + mul.f32 %r3347, %r684, %r683; +$L__BB0_108: + st.shared.b32 [%r49+1188], %r3347; + shfl.sync.idx.b32 %r69|%p67, %r14, 10, 31, -1; + shfl.sync.idx.b32 %r70|%p68, %r3274, 10, 31, -1; + setp.lt.u32 %p69, %r4, 10; + @%p69 bra $L__BB0_110; + setp.eq.b32 %p70, %r4, 10; + selp.f32 %r3348, 0f3F800000, 0f00000000, %p70; + bra.uni $L__BB0_111; +$L__BB0_110: + sub.f32 %r685, %r69, %r13; + fma.rn.f32 %r686, %r685, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r687, %r686; + mov.b32 %r688, 0f4B400001; + mov.b32 %r689, 0f437C0000; + fma.rm.f32 %r690, %r687, %r689, %r688; + add.f32 %r691, %r690, 0fCB40007F; + neg.f32 %r692, %r691; + fma.rn.f32 %r693, %r685, 0f3FB8AA3B, %r692; + fma.rn.f32 %r694, %r685, 0f32A57060, %r693; + shl.b32 %r695, %r690, 23; + ex2.approx.ftz.f32 %r696, %r694; + mul.f32 %r697, %r696, %r695; + mul.f32 %r698, %r697, %r70; + ld.shared.b32 %r699, [%r54+36136]; + mul.f32 %r3348, %r699, %r698; +$L__BB0_111: + st.shared.b32 [%r49+1320], %r3348; + shfl.sync.idx.b32 %r71|%p71, %r14, 11, 31, -1; + shfl.sync.idx.b32 %r72|%p72, %r3274, 11, 31, -1; + setp.lt.u32 %p73, %r4, 11; + @%p73 bra $L__BB0_113; + setp.eq.b32 %p74, %r4, 11; + selp.f32 %r3349, 0f3F800000, 0f00000000, %p74; + bra.uni $L__BB0_114; +$L__BB0_113: + sub.f32 %r700, %r71, %r13; + fma.rn.f32 %r701, %r700, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r702, %r701; + mov.b32 %r703, 0f4B400001; + mov.b32 %r704, 0f437C0000; + fma.rm.f32 %r705, %r702, %r704, %r703; + add.f32 %r706, %r705, 0fCB40007F; + neg.f32 %r707, %r706; + fma.rn.f32 %r708, %r700, 0f3FB8AA3B, %r707; + fma.rn.f32 %r709, %r700, 0f32A57060, %r708; + shl.b32 %r710, %r705, 23; + ex2.approx.ftz.f32 %r711, %r709; + mul.f32 %r712, %r711, %r710; + mul.f32 %r713, %r712, %r72; + ld.shared.b32 %r714, [%r54+36268]; + mul.f32 %r3349, %r714, %r713; +$L__BB0_114: + st.shared.b32 [%r49+1452], %r3349; + shfl.sync.idx.b32 %r73|%p75, %r14, 12, 31, -1; + shfl.sync.idx.b32 %r74|%p76, %r3274, 12, 31, -1; + setp.lt.u32 %p77, %r4, 12; + @%p77 bra $L__BB0_116; + setp.eq.b32 %p78, %r4, 12; + selp.f32 %r3350, 0f3F800000, 0f00000000, %p78; + bra.uni $L__BB0_117; +$L__BB0_116: + sub.f32 %r715, %r73, %r13; + fma.rn.f32 %r716, %r715, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r717, %r716; + mov.b32 %r718, 0f4B400001; + mov.b32 %r719, 0f437C0000; + fma.rm.f32 %r720, %r717, %r719, %r718; + add.f32 %r721, %r720, 0fCB40007F; + neg.f32 %r722, %r721; + fma.rn.f32 %r723, %r715, 0f3FB8AA3B, %r722; + fma.rn.f32 %r724, %r715, 0f32A57060, %r723; + shl.b32 %r725, %r720, 23; + ex2.approx.ftz.f32 %r726, %r724; + mul.f32 %r727, %r726, %r725; + mul.f32 %r728, %r727, %r74; + ld.shared.b32 %r729, [%r54+36400]; + mul.f32 %r3350, %r729, %r728; +$L__BB0_117: + st.shared.b32 [%r49+1584], %r3350; + shfl.sync.idx.b32 %r75|%p79, %r14, 13, 31, -1; + shfl.sync.idx.b32 %r76|%p80, %r3274, 13, 31, -1; + setp.lt.u32 %p81, %r4, 13; + @%p81 bra $L__BB0_119; + setp.eq.b32 %p82, %r4, 13; + selp.f32 %r3351, 0f3F800000, 0f00000000, %p82; + bra.uni $L__BB0_120; +$L__BB0_119: + sub.f32 %r730, %r75, %r13; + fma.rn.f32 %r731, %r730, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r732, %r731; + mov.b32 %r733, 0f4B400001; + mov.b32 %r734, 0f437C0000; + fma.rm.f32 %r735, %r732, %r734, %r733; + add.f32 %r736, %r735, 0fCB40007F; + neg.f32 %r737, %r736; + fma.rn.f32 %r738, %r730, 0f3FB8AA3B, %r737; + fma.rn.f32 %r739, %r730, 0f32A57060, %r738; + shl.b32 %r740, %r735, 23; + ex2.approx.ftz.f32 %r741, %r739; + mul.f32 %r742, %r741, %r740; + mul.f32 %r743, %r742, %r76; + ld.shared.b32 %r744, [%r54+36532]; + mul.f32 %r3351, %r744, %r743; +$L__BB0_120: + st.shared.b32 [%r49+1716], %r3351; + shfl.sync.idx.b32 %r77|%p83, %r14, 14, 31, -1; + shfl.sync.idx.b32 %r78|%p84, %r3274, 14, 31, -1; + setp.lt.u32 %p85, %r4, 14; + @%p85 bra $L__BB0_122; + setp.eq.b32 %p86, %r4, 14; + selp.f32 %r3352, 0f3F800000, 0f00000000, %p86; + bra.uni $L__BB0_123; +$L__BB0_122: + sub.f32 %r745, %r77, %r13; + fma.rn.f32 %r746, %r745, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r747, %r746; + mov.b32 %r748, 0f4B400001; + mov.b32 %r749, 0f437C0000; + fma.rm.f32 %r750, %r747, %r749, %r748; + add.f32 %r751, %r750, 0fCB40007F; + neg.f32 %r752, %r751; + fma.rn.f32 %r753, %r745, 0f3FB8AA3B, %r752; + fma.rn.f32 %r754, %r745, 0f32A57060, %r753; + shl.b32 %r755, %r750, 23; + ex2.approx.ftz.f32 %r756, %r754; + mul.f32 %r757, %r756, %r755; + mul.f32 %r758, %r757, %r78; + ld.shared.b32 %r759, [%r54+36664]; + mul.f32 %r3352, %r759, %r758; +$L__BB0_123: + st.shared.b32 [%r49+1848], %r3352; + shfl.sync.idx.b32 %r79|%p87, %r14, 15, 31, -1; + shfl.sync.idx.b32 %r80|%p88, %r3274, 15, 31, -1; + setp.lt.u32 %p89, %r4, 15; + @%p89 bra $L__BB0_125; + setp.eq.b32 %p90, %r4, 15; + selp.f32 %r3353, 0f3F800000, 0f00000000, %p90; + bra.uni $L__BB0_126; +$L__BB0_125: + sub.f32 %r760, %r79, %r13; + fma.rn.f32 %r761, %r760, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r762, %r761; + mov.b32 %r763, 0f4B400001; + mov.b32 %r764, 0f437C0000; + fma.rm.f32 %r765, %r762, %r764, %r763; + add.f32 %r766, %r765, 0fCB40007F; + neg.f32 %r767, %r766; + fma.rn.f32 %r768, %r760, 0f3FB8AA3B, %r767; + fma.rn.f32 %r769, %r760, 0f32A57060, %r768; + shl.b32 %r770, %r765, 23; + ex2.approx.ftz.f32 %r771, %r769; + mul.f32 %r772, %r771, %r770; + mul.f32 %r773, %r772, %r80; + ld.shared.b32 %r774, [%r54+36796]; + mul.f32 %r3353, %r774, %r773; +$L__BB0_126: + setp.lt.u32 %p91, %r4, 16; + st.shared.b32 [%r49+1980], %r3353; + shfl.sync.idx.b32 %r81|%p92, %r14, 16, 31, -1; + shfl.sync.idx.b32 %r82|%p93, %r3274, 16, 31, -1; + @%p91 bra $L__BB0_128; + setp.eq.b32 %p94, %r4, 16; + selp.f32 %r3354, 0f3F800000, 0f00000000, %p94; + bra.uni $L__BB0_129; +$L__BB0_128: + sub.f32 %r775, %r81, %r13; + fma.rn.f32 %r776, %r775, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r777, %r776; + mov.b32 %r778, 0f4B400001; + mov.b32 %r779, 0f437C0000; + fma.rm.f32 %r780, %r777, %r779, %r778; + add.f32 %r781, %r780, 0fCB40007F; + neg.f32 %r782, %r781; + fma.rn.f32 %r783, %r775, 0f3FB8AA3B, %r782; + fma.rn.f32 %r784, %r775, 0f32A57060, %r783; + shl.b32 %r785, %r780, 23; + ex2.approx.ftz.f32 %r786, %r784; + mul.f32 %r787, %r786, %r785; + mul.f32 %r788, %r787, %r82; + ld.shared.b32 %r789, [%r54+36928]; + mul.f32 %r3354, %r789, %r788; +$L__BB0_129: + st.shared.b32 [%r49+2112], %r3354; + shfl.sync.idx.b32 %r83|%p95, %r14, 17, 31, -1; + shfl.sync.idx.b32 %r84|%p96, %r3274, 17, 31, -1; + setp.lt.u32 %p97, %r4, 17; + @%p97 bra $L__BB0_131; + setp.eq.b32 %p98, %r4, 17; + selp.f32 %r3355, 0f3F800000, 0f00000000, %p98; + bra.uni $L__BB0_132; +$L__BB0_131: + sub.f32 %r790, %r83, %r14; + fma.rn.f32 %r791, %r790, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r792, %r791; + mov.b32 %r793, 0f4B400001; + mov.b32 %r794, 0f437C0000; + fma.rm.f32 %r795, %r792, %r794, %r793; + add.f32 %r796, %r795, 0fCB40007F; + neg.f32 %r797, %r796; + fma.rn.f32 %r798, %r790, 0f3FB8AA3B, %r797; + fma.rn.f32 %r799, %r790, 0f32A57060, %r798; + shl.b32 %r800, %r795, 23; + ex2.approx.ftz.f32 %r801, %r799; + mul.f32 %r802, %r801, %r800; + mul.f32 %r803, %r802, %r84; + ld.shared.b32 %r804, [%r54+37060]; + mul.f32 %r3355, %r804, %r803; +$L__BB0_132: + st.shared.b32 [%r49+2244], %r3355; + shfl.sync.idx.b32 %r85|%p99, %r14, 18, 31, -1; + shfl.sync.idx.b32 %r86|%p100, %r3274, 18, 31, -1; + setp.lt.u32 %p101, %r4, 18; + @%p101 bra $L__BB0_134; + setp.eq.b32 %p102, %r4, 18; + selp.f32 %r3356, 0f3F800000, 0f00000000, %p102; + bra.uni $L__BB0_135; +$L__BB0_134: + sub.f32 %r805, %r85, %r14; + fma.rn.f32 %r806, %r805, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r807, %r806; + mov.b32 %r808, 0f4B400001; + mov.b32 %r809, 0f437C0000; + fma.rm.f32 %r810, %r807, %r809, %r808; + add.f32 %r811, %r810, 0fCB40007F; + neg.f32 %r812, %r811; + fma.rn.f32 %r813, %r805, 0f3FB8AA3B, %r812; + fma.rn.f32 %r814, %r805, 0f32A57060, %r813; + shl.b32 %r815, %r810, 23; + ex2.approx.ftz.f32 %r816, %r814; + mul.f32 %r817, %r816, %r815; + mul.f32 %r818, %r817, %r86; + ld.shared.b32 %r819, [%r54+37192]; + mul.f32 %r3356, %r819, %r818; +$L__BB0_135: + st.shared.b32 [%r49+2376], %r3356; + shfl.sync.idx.b32 %r87|%p103, %r14, 19, 31, -1; + shfl.sync.idx.b32 %r88|%p104, %r3274, 19, 31, -1; + setp.lt.u32 %p105, %r4, 19; + @%p105 bra $L__BB0_137; + setp.eq.b32 %p106, %r4, 19; + selp.f32 %r3357, 0f3F800000, 0f00000000, %p106; + bra.uni $L__BB0_138; +$L__BB0_137: + sub.f32 %r820, %r87, %r14; + fma.rn.f32 %r821, %r820, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r822, %r821; + mov.b32 %r823, 0f4B400001; + mov.b32 %r824, 0f437C0000; + fma.rm.f32 %r825, %r822, %r824, %r823; + add.f32 %r826, %r825, 0fCB40007F; + neg.f32 %r827, %r826; + fma.rn.f32 %r828, %r820, 0f3FB8AA3B, %r827; + fma.rn.f32 %r829, %r820, 0f32A57060, %r828; + shl.b32 %r830, %r825, 23; + ex2.approx.ftz.f32 %r831, %r829; + mul.f32 %r832, %r831, %r830; + mul.f32 %r833, %r832, %r88; + ld.shared.b32 %r834, [%r54+37324]; + mul.f32 %r3357, %r834, %r833; +$L__BB0_138: + st.shared.b32 [%r49+2508], %r3357; + shfl.sync.idx.b32 %r89|%p107, %r14, 20, 31, -1; + shfl.sync.idx.b32 %r90|%p108, %r3274, 20, 31, -1; + setp.lt.u32 %p109, %r4, 20; + @%p109 bra $L__BB0_140; + setp.eq.b32 %p110, %r4, 20; + selp.f32 %r3358, 0f3F800000, 0f00000000, %p110; + bra.uni $L__BB0_141; +$L__BB0_140: + sub.f32 %r835, %r89, %r14; + fma.rn.f32 %r836, %r835, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r837, %r836; + mov.b32 %r838, 0f4B400001; + mov.b32 %r839, 0f437C0000; + fma.rm.f32 %r840, %r837, %r839, %r838; + add.f32 %r841, %r840, 0fCB40007F; + neg.f32 %r842, %r841; + fma.rn.f32 %r843, %r835, 0f3FB8AA3B, %r842; + fma.rn.f32 %r844, %r835, 0f32A57060, %r843; + shl.b32 %r845, %r840, 23; + ex2.approx.ftz.f32 %r846, %r844; + mul.f32 %r847, %r846, %r845; + mul.f32 %r848, %r847, %r90; + ld.shared.b32 %r849, [%r54+37456]; + mul.f32 %r3358, %r849, %r848; +$L__BB0_141: + st.shared.b32 [%r49+2640], %r3358; + shfl.sync.idx.b32 %r91|%p111, %r14, 21, 31, -1; + shfl.sync.idx.b32 %r92|%p112, %r3274, 21, 31, -1; + setp.lt.u32 %p113, %r4, 21; + @%p113 bra $L__BB0_143; + setp.eq.b32 %p114, %r4, 21; + selp.f32 %r3359, 0f3F800000, 0f00000000, %p114; + bra.uni $L__BB0_144; +$L__BB0_143: + sub.f32 %r850, %r91, %r14; + fma.rn.f32 %r851, %r850, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r852, %r851; + mov.b32 %r853, 0f4B400001; + mov.b32 %r854, 0f437C0000; + fma.rm.f32 %r855, %r852, %r854, %r853; + add.f32 %r856, %r855, 0fCB40007F; + neg.f32 %r857, %r856; + fma.rn.f32 %r858, %r850, 0f3FB8AA3B, %r857; + fma.rn.f32 %r859, %r850, 0f32A57060, %r858; + shl.b32 %r860, %r855, 23; + ex2.approx.ftz.f32 %r861, %r859; + mul.f32 %r862, %r861, %r860; + mul.f32 %r863, %r862, %r92; + ld.shared.b32 %r864, [%r54+37588]; + mul.f32 %r3359, %r864, %r863; +$L__BB0_144: + st.shared.b32 [%r49+2772], %r3359; + shfl.sync.idx.b32 %r93|%p115, %r14, 22, 31, -1; + shfl.sync.idx.b32 %r94|%p116, %r3274, 22, 31, -1; + setp.lt.u32 %p117, %r4, 22; + @%p117 bra $L__BB0_146; + setp.eq.b32 %p118, %r4, 22; + selp.f32 %r3360, 0f3F800000, 0f00000000, %p118; + bra.uni $L__BB0_147; +$L__BB0_146: + sub.f32 %r865, %r93, %r14; + fma.rn.f32 %r866, %r865, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r867, %r866; + mov.b32 %r868, 0f4B400001; + mov.b32 %r869, 0f437C0000; + fma.rm.f32 %r870, %r867, %r869, %r868; + add.f32 %r871, %r870, 0fCB40007F; + neg.f32 %r872, %r871; + fma.rn.f32 %r873, %r865, 0f3FB8AA3B, %r872; + fma.rn.f32 %r874, %r865, 0f32A57060, %r873; + shl.b32 %r875, %r870, 23; + ex2.approx.ftz.f32 %r876, %r874; + mul.f32 %r877, %r876, %r875; + mul.f32 %r878, %r877, %r94; + ld.shared.b32 %r879, [%r54+37720]; + mul.f32 %r3360, %r879, %r878; +$L__BB0_147: + st.shared.b32 [%r49+2904], %r3360; + shfl.sync.idx.b32 %r95|%p119, %r14, 23, 31, -1; + shfl.sync.idx.b32 %r96|%p120, %r3274, 23, 31, -1; + setp.lt.u32 %p121, %r4, 23; + @%p121 bra $L__BB0_149; + setp.eq.b32 %p122, %r4, 23; + selp.f32 %r3361, 0f3F800000, 0f00000000, %p122; + bra.uni $L__BB0_150; +$L__BB0_149: + sub.f32 %r880, %r95, %r14; + fma.rn.f32 %r881, %r880, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r882, %r881; + mov.b32 %r883, 0f4B400001; + mov.b32 %r884, 0f437C0000; + fma.rm.f32 %r885, %r882, %r884, %r883; + add.f32 %r886, %r885, 0fCB40007F; + neg.f32 %r887, %r886; + fma.rn.f32 %r888, %r880, 0f3FB8AA3B, %r887; + fma.rn.f32 %r889, %r880, 0f32A57060, %r888; + shl.b32 %r890, %r885, 23; + ex2.approx.ftz.f32 %r891, %r889; + mul.f32 %r892, %r891, %r890; + mul.f32 %r893, %r892, %r96; + ld.shared.b32 %r894, [%r54+37852]; + mul.f32 %r3361, %r894, %r893; +$L__BB0_150: + st.shared.b32 [%r49+3036], %r3361; + shfl.sync.idx.b32 %r97|%p123, %r14, 24, 31, -1; + shfl.sync.idx.b32 %r98|%p124, %r3274, 24, 31, -1; + setp.lt.u32 %p125, %r4, 24; + @%p125 bra $L__BB0_152; + setp.eq.b32 %p126, %r4, 24; + selp.f32 %r3362, 0f3F800000, 0f00000000, %p126; + bra.uni $L__BB0_153; +$L__BB0_152: + sub.f32 %r895, %r97, %r14; + fma.rn.f32 %r896, %r895, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r897, %r896; + mov.b32 %r898, 0f4B400001; + mov.b32 %r899, 0f437C0000; + fma.rm.f32 %r900, %r897, %r899, %r898; + add.f32 %r901, %r900, 0fCB40007F; + neg.f32 %r902, %r901; + fma.rn.f32 %r903, %r895, 0f3FB8AA3B, %r902; + fma.rn.f32 %r904, %r895, 0f32A57060, %r903; + shl.b32 %r905, %r900, 23; + ex2.approx.ftz.f32 %r906, %r904; + mul.f32 %r907, %r906, %r905; + mul.f32 %r908, %r907, %r98; + ld.shared.b32 %r909, [%r54+37984]; + mul.f32 %r3362, %r909, %r908; +$L__BB0_153: + st.shared.b32 [%r49+3168], %r3362; + shfl.sync.idx.b32 %r99|%p127, %r14, 25, 31, -1; + shfl.sync.idx.b32 %r100|%p128, %r3274, 25, 31, -1; + setp.lt.u32 %p129, %r4, 25; + @%p129 bra $L__BB0_155; + setp.eq.b32 %p130, %r4, 25; + selp.f32 %r3363, 0f3F800000, 0f00000000, %p130; + bra.uni $L__BB0_156; +$L__BB0_155: + sub.f32 %r910, %r99, %r14; + fma.rn.f32 %r911, %r910, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r912, %r911; + mov.b32 %r913, 0f4B400001; + mov.b32 %r914, 0f437C0000; + fma.rm.f32 %r915, %r912, %r914, %r913; + add.f32 %r916, %r915, 0fCB40007F; + neg.f32 %r917, %r916; + fma.rn.f32 %r918, %r910, 0f3FB8AA3B, %r917; + fma.rn.f32 %r919, %r910, 0f32A57060, %r918; + shl.b32 %r920, %r915, 23; + ex2.approx.ftz.f32 %r921, %r919; + mul.f32 %r922, %r921, %r920; + mul.f32 %r923, %r922, %r100; + ld.shared.b32 %r924, [%r54+38116]; + mul.f32 %r3363, %r924, %r923; +$L__BB0_156: + st.shared.b32 [%r49+3300], %r3363; + shfl.sync.idx.b32 %r101|%p131, %r14, 26, 31, -1; + shfl.sync.idx.b32 %r102|%p132, %r3274, 26, 31, -1; + setp.lt.u32 %p133, %r4, 26; + @%p133 bra $L__BB0_158; + setp.eq.b32 %p134, %r4, 26; + selp.f32 %r3364, 0f3F800000, 0f00000000, %p134; + bra.uni $L__BB0_159; +$L__BB0_158: + sub.f32 %r925, %r101, %r14; + fma.rn.f32 %r926, %r925, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r927, %r926; + mov.b32 %r928, 0f4B400001; + mov.b32 %r929, 0f437C0000; + fma.rm.f32 %r930, %r927, %r929, %r928; + add.f32 %r931, %r930, 0fCB40007F; + neg.f32 %r932, %r931; + fma.rn.f32 %r933, %r925, 0f3FB8AA3B, %r932; + fma.rn.f32 %r934, %r925, 0f32A57060, %r933; + shl.b32 %r935, %r930, 23; + ex2.approx.ftz.f32 %r936, %r934; + mul.f32 %r937, %r936, %r935; + mul.f32 %r938, %r937, %r102; + ld.shared.b32 %r939, [%r54+38248]; + mul.f32 %r3364, %r939, %r938; +$L__BB0_159: + st.shared.b32 [%r49+3432], %r3364; + shfl.sync.idx.b32 %r103|%p135, %r14, 27, 31, -1; + shfl.sync.idx.b32 %r104|%p136, %r3274, 27, 31, -1; + setp.lt.u32 %p137, %r4, 27; + @%p137 bra $L__BB0_161; + setp.eq.b32 %p138, %r4, 27; + selp.f32 %r3365, 0f3F800000, 0f00000000, %p138; + bra.uni $L__BB0_162; +$L__BB0_161: + sub.f32 %r940, %r103, %r14; + fma.rn.f32 %r941, %r940, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r942, %r941; + mov.b32 %r943, 0f4B400001; + mov.b32 %r944, 0f437C0000; + fma.rm.f32 %r945, %r942, %r944, %r943; + add.f32 %r946, %r945, 0fCB40007F; + neg.f32 %r947, %r946; + fma.rn.f32 %r948, %r940, 0f3FB8AA3B, %r947; + fma.rn.f32 %r949, %r940, 0f32A57060, %r948; + shl.b32 %r950, %r945, 23; + ex2.approx.ftz.f32 %r951, %r949; + mul.f32 %r952, %r951, %r950; + mul.f32 %r953, %r952, %r104; + ld.shared.b32 %r954, [%r54+38380]; + mul.f32 %r3365, %r954, %r953; +$L__BB0_162: + st.shared.b32 [%r49+3564], %r3365; + shfl.sync.idx.b32 %r105|%p139, %r14, 28, 31, -1; + shfl.sync.idx.b32 %r106|%p140, %r3274, 28, 31, -1; + setp.lt.u32 %p141, %r4, 28; + @%p141 bra $L__BB0_164; + setp.eq.b32 %p142, %r4, 28; + selp.f32 %r3366, 0f3F800000, 0f00000000, %p142; + bra.uni $L__BB0_165; +$L__BB0_164: + sub.f32 %r955, %r105, %r14; + fma.rn.f32 %r956, %r955, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r957, %r956; + mov.b32 %r958, 0f4B400001; + mov.b32 %r959, 0f437C0000; + fma.rm.f32 %r960, %r957, %r959, %r958; + add.f32 %r961, %r960, 0fCB40007F; + neg.f32 %r962, %r961; + fma.rn.f32 %r963, %r955, 0f3FB8AA3B, %r962; + fma.rn.f32 %r964, %r955, 0f32A57060, %r963; + shl.b32 %r965, %r960, 23; + ex2.approx.ftz.f32 %r966, %r964; + mul.f32 %r967, %r966, %r965; + mul.f32 %r968, %r967, %r106; + ld.shared.b32 %r969, [%r54+38512]; + mul.f32 %r3366, %r969, %r968; +$L__BB0_165: + st.shared.b32 [%r49+3696], %r3366; + shfl.sync.idx.b32 %r107|%p143, %r14, 29, 31, -1; + shfl.sync.idx.b32 %r108|%p144, %r3274, 29, 31, -1; + setp.lt.u32 %p145, %r4, 29; + @%p145 bra $L__BB0_167; + setp.eq.b32 %p146, %r4, 29; + selp.f32 %r3367, 0f3F800000, 0f00000000, %p146; + bra.uni $L__BB0_168; +$L__BB0_167: + sub.f32 %r970, %r107, %r14; + fma.rn.f32 %r971, %r970, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r972, %r971; + mov.b32 %r973, 0f4B400001; + mov.b32 %r974, 0f437C0000; + fma.rm.f32 %r975, %r972, %r974, %r973; + add.f32 %r976, %r975, 0fCB40007F; + neg.f32 %r977, %r976; + fma.rn.f32 %r978, %r970, 0f3FB8AA3B, %r977; + fma.rn.f32 %r979, %r970, 0f32A57060, %r978; + shl.b32 %r980, %r975, 23; + ex2.approx.ftz.f32 %r981, %r979; + mul.f32 %r982, %r981, %r980; + mul.f32 %r983, %r982, %r108; + ld.shared.b32 %r984, [%r54+38644]; + mul.f32 %r3367, %r984, %r983; +$L__BB0_168: + st.shared.b32 [%r49+3828], %r3367; + shfl.sync.idx.b32 %r109|%p147, %r14, 30, 31, -1; + shfl.sync.idx.b32 %r110|%p148, %r3274, 30, 31, -1; + setp.lt.u32 %p149, %r4, 30; + @%p149 bra $L__BB0_170; + setp.eq.b32 %p150, %r4, 30; + selp.f32 %r3368, 0f3F800000, 0f00000000, %p150; + bra.uni $L__BB0_171; +$L__BB0_170: + sub.f32 %r985, %r109, %r14; + fma.rn.f32 %r986, %r985, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r987, %r986; + mov.b32 %r988, 0f4B400001; + mov.b32 %r989, 0f437C0000; + fma.rm.f32 %r990, %r987, %r989, %r988; + add.f32 %r991, %r990, 0fCB40007F; + neg.f32 %r992, %r991; + fma.rn.f32 %r993, %r985, 0f3FB8AA3B, %r992; + fma.rn.f32 %r994, %r985, 0f32A57060, %r993; + shl.b32 %r995, %r990, 23; + ex2.approx.ftz.f32 %r996, %r994; + mul.f32 %r997, %r996, %r995; + mul.f32 %r998, %r997, %r110; + ld.shared.b32 %r999, [%r54+38776]; + mul.f32 %r3368, %r999, %r998; +$L__BB0_171: + st.shared.b32 [%r49+3960], %r3368; + shfl.sync.idx.b32 %r111|%p151, %r14, 31, 31, -1; + shfl.sync.idx.b32 %r112|%p152, %r3274, 31, 31, -1; + setp.eq.b32 %p153, %r4, 31; + mov.b32 %r3369, 0f3F800000; + @%p153 bra $L__BB0_173; + sub.f32 %r1000, %r111, %r14; + fma.rn.f32 %r1001, %r1000, 0f3BBB989D, 0f3F000000; + cvt.sat.f32.f32 %r1002, %r1001; + mov.b32 %r1003, 0f4B400001; + mov.b32 %r1004, 0f437C0000; + fma.rm.f32 %r1005, %r1002, %r1004, %r1003; + add.f32 %r1006, %r1005, 0fCB40007F; + neg.f32 %r1007, %r1006; + fma.rn.f32 %r1008, %r1000, 0f3FB8AA3B, %r1007; + fma.rn.f32 %r1009, %r1000, 0f32A57060, %r1008; + shl.b32 %r1010, %r1005, 23; + ex2.approx.ftz.f32 %r1011, %r1009; + mul.f32 %r1012, %r1011, %r1010; + mul.f32 %r1013, %r1012, %r112; + ld.shared.b32 %r1014, [%r54+38908]; + mul.f32 %r3369, %r1014, %r1013; +$L__BB0_173: + setp.eq.b32 %p154, %r4, 31; + setp.lt.u32 %p155, %r4, 30; + setp.lt.u32 %p156, %r4, 29; + setp.lt.u32 %p157, %r4, 28; + setp.lt.u32 %p158, %r4, 27; + setp.lt.u32 %p159, %r4, 26; + setp.lt.u32 %p160, %r4, 25; + setp.lt.u32 %p161, %r4, 24; + setp.lt.u32 %p162, %r4, 23; + setp.lt.u32 %p163, %r4, 22; + setp.lt.u32 %p164, %r4, 21; + setp.lt.u32 %p165, %r4, 20; + setp.lt.u32 %p166, %r4, 19; + setp.lt.u32 %p167, %r4, 18; + setp.lt.u32 %p168, %r4, 17; + setp.lt.u32 %p169, %r4, 15; + setp.lt.u32 %p170, %r4, 14; + setp.lt.u32 %p171, %r4, 13; + setp.lt.u32 %p172, %r4, 12; + setp.lt.u32 %p173, %r4, 11; + setp.lt.u32 %p174, %r4, 10; + setp.lt.u32 %p175, %r4, 9; + setp.lt.u32 %p176, %r4, 7; + setp.lt.u32 %p177, %r4, 6; + setp.lt.u32 %p178, %r4, 5; + setp.lt.u32 %p179, %r4, 3; + setp.lt.u32 %p180, %r4, 16; + setp.lt.u32 %p181, %r4, 8; + setp.lt.u32 %p182, %r4, 4; + setp.lt.u32 %p183, %r4, 2; + setp.eq.b32 %p184, %r4, 0; + st.shared.b32 [%r49+4092], %r3369; + bar.warp.sync -1; + ld.shared.b32 %r1015, [%r47+132]; + neg.f32 %r1016, %r1015; + fma.rn.f32 %r1017, %r1016, %r48, 0f00000000; + setp.eq.b32 %p185, %r4, 1; + selp.f32 %r1018, 0f3F800000, 0f00000000, %p185; + selp.f32 %r113, %r1017, %r1018, %p184; + ld.shared.v2.b32 {%r1019, %r1020}, [%r47+264]; + neg.f32 %r1021, %r1019; + fma.rn.f32 %r1022, %r1021, %r48, 0f00000000; + neg.f32 %r1023, %r1020; + fma.rn.f32 %r1024, %r1023, %r113, %r1022; + setp.eq.b32 %p186, %r4, 2; + selp.f32 %r1025, 0f3F800000, 0f00000000, %p186; + selp.f32 %r114, %r1024, %r1025, %p183; + ld.shared.b32 %r1026, [%r47+396]; + neg.f32 %r1027, %r1026; + fma.rn.f32 %r1028, %r1027, %r48, 0f00000000; + ld.shared.v2.b32 {%r1029, %r1030}, [%r47+400]; + neg.f32 %r1031, %r1029; + fma.rn.f32 %r1032, %r1031, %r113, %r1028; + neg.f32 %r1033, %r1030; + fma.rn.f32 %r1034, %r1033, %r114, %r1032; + setp.eq.b32 %p187, %r4, 3; + selp.f32 %r1035, 0f3F800000, 0f00000000, %p187; + selp.f32 %r115, %r1034, %r1035, %p179; + ld.shared.v4.b32 {%r1036, %r1037, %r1038, %r1039}, [%r47+528]; + neg.f32 %r1040, %r1036; + fma.rn.f32 %r1041, %r1040, %r48, 0f00000000; + neg.f32 %r1042, %r1037; + fma.rn.f32 %r1043, %r1042, %r113, %r1041; + neg.f32 %r1044, %r1038; + fma.rn.f32 %r1045, %r1044, %r114, %r1043; + neg.f32 %r1046, %r1039; + fma.rn.f32 %r1047, %r1046, %r115, %r1045; + setp.eq.b32 %p188, %r4, 4; + selp.f32 %r1048, 0f3F800000, 0f00000000, %p188; + selp.f32 %r116, %r1047, %r1048, %p182; + ld.shared.b32 %r1049, [%r47+660]; + neg.f32 %r1050, %r1049; + fma.rn.f32 %r1051, %r1050, %r48, 0f00000000; + ld.shared.v2.b32 {%r1052, %r1053}, [%r47+664]; + neg.f32 %r1054, %r1052; + fma.rn.f32 %r1055, %r1054, %r113, %r1051; + neg.f32 %r1056, %r1053; + fma.rn.f32 %r1057, %r1056, %r114, %r1055; + ld.shared.v2.b32 {%r1058, %r1059}, [%r47+672]; + neg.f32 %r1060, %r1058; + fma.rn.f32 %r1061, %r1060, %r115, %r1057; + neg.f32 %r1062, %r1059; + fma.rn.f32 %r1063, %r1062, %r116, %r1061; + setp.eq.b32 %p189, %r4, 5; + selp.f32 %r1064, 0f3F800000, 0f00000000, %p189; + selp.f32 %r117, %r1063, %r1064, %p178; + ld.shared.v2.b32 {%r1065, %r1066}, [%r47+792]; + neg.f32 %r1067, %r1065; + fma.rn.f32 %r1068, %r1067, %r48, 0f00000000; + neg.f32 %r1069, %r1066; + fma.rn.f32 %r1070, %r1069, %r113, %r1068; + ld.shared.v4.b32 {%r1071, %r1072, %r1073, %r1074}, [%r47+800]; + neg.f32 %r1075, %r1071; + fma.rn.f32 %r1076, %r1075, %r114, %r1070; + neg.f32 %r1077, %r1072; + fma.rn.f32 %r1078, %r1077, %r115, %r1076; + neg.f32 %r1079, %r1073; + fma.rn.f32 %r1080, %r1079, %r116, %r1078; + neg.f32 %r1081, %r1074; + fma.rn.f32 %r1082, %r1081, %r117, %r1080; + setp.eq.b32 %p190, %r4, 6; + selp.f32 %r1083, 0f3F800000, 0f00000000, %p190; + selp.f32 %r118, %r1082, %r1083, %p177; + ld.shared.b32 %r1084, [%r47+924]; + neg.f32 %r1085, %r1084; + fma.rn.f32 %r1086, %r1085, %r48, 0f00000000; + ld.shared.v4.b32 {%r1087, %r1088, %r1089, %r1090}, [%r47+928]; + neg.f32 %r1091, %r1087; + fma.rn.f32 %r1092, %r1091, %r113, %r1086; + neg.f32 %r1093, %r1088; + fma.rn.f32 %r1094, %r1093, %r114, %r1092; + neg.f32 %r1095, %r1089; + fma.rn.f32 %r1096, %r1095, %r115, %r1094; + neg.f32 %r1097, %r1090; + fma.rn.f32 %r1098, %r1097, %r116, %r1096; + ld.shared.v2.b32 {%r1099, %r1100}, [%r47+944]; + neg.f32 %r1101, %r1099; + fma.rn.f32 %r1102, %r1101, %r117, %r1098; + neg.f32 %r1103, %r1100; + fma.rn.f32 %r1104, %r1103, %r118, %r1102; + setp.eq.b32 %p191, %r4, 7; + selp.f32 %r1105, 0f3F800000, 0f00000000, %p191; + selp.f32 %r119, %r1104, %r1105, %p176; + ld.shared.v4.b32 {%r1106, %r1107, %r1108, %r1109}, [%r47+1056]; + neg.f32 %r1110, %r1106; + fma.rn.f32 %r1111, %r1110, %r48, 0f00000000; + neg.f32 %r1112, %r1107; + fma.rn.f32 %r1113, %r1112, %r113, %r1111; + neg.f32 %r1114, %r1108; + fma.rn.f32 %r1115, %r1114, %r114, %r1113; + neg.f32 %r1116, %r1109; + fma.rn.f32 %r1117, %r1116, %r115, %r1115; + ld.shared.v4.b32 {%r1118, %r1119, %r1120, %r1121}, [%r47+1072]; + neg.f32 %r1122, %r1118; + fma.rn.f32 %r1123, %r1122, %r116, %r1117; + neg.f32 %r1124, %r1119; + fma.rn.f32 %r1125, %r1124, %r117, %r1123; + neg.f32 %r1126, %r1120; + fma.rn.f32 %r1127, %r1126, %r118, %r1125; + neg.f32 %r1128, %r1121; + fma.rn.f32 %r1129, %r1128, %r119, %r1127; + setp.eq.b32 %p192, %r4, 8; + selp.f32 %r1130, 0f3F800000, 0f00000000, %p192; + selp.f32 %r120, %r1129, %r1130, %p181; + ld.shared.b32 %r1131, [%r47+1188]; + neg.f32 %r1132, %r1131; + fma.rn.f32 %r1133, %r1132, %r48, 0f00000000; + ld.shared.v2.b32 {%r1134, %r1135}, [%r47+1192]; + neg.f32 %r1136, %r1134; + fma.rn.f32 %r1137, %r1136, %r113, %r1133; + neg.f32 %r1138, %r1135; + fma.rn.f32 %r1139, %r1138, %r114, %r1137; + ld.shared.v4.b32 {%r1140, %r1141, %r1142, %r1143}, [%r47+1200]; + neg.f32 %r1144, %r1140; + fma.rn.f32 %r1145, %r1144, %r115, %r1139; + neg.f32 %r1146, %r1141; + fma.rn.f32 %r1147, %r1146, %r116, %r1145; + neg.f32 %r1148, %r1142; + fma.rn.f32 %r1149, %r1148, %r117, %r1147; + neg.f32 %r1150, %r1143; + fma.rn.f32 %r1151, %r1150, %r118, %r1149; + ld.shared.v2.b32 {%r1152, %r1153}, [%r47+1216]; + neg.f32 %r1154, %r1152; + fma.rn.f32 %r1155, %r1154, %r119, %r1151; + neg.f32 %r1156, %r1153; + fma.rn.f32 %r1157, %r1156, %r120, %r1155; + setp.eq.b32 %p193, %r4, 9; + selp.f32 %r1158, 0f3F800000, 0f00000000, %p193; + selp.f32 %r121, %r1157, %r1158, %p175; + ld.shared.v2.b32 {%r1159, %r1160}, [%r47+1320]; + neg.f32 %r1161, %r1159; + fma.rn.f32 %r1162, %r1161, %r48, 0f00000000; + neg.f32 %r1163, %r1160; + fma.rn.f32 %r1164, %r1163, %r113, %r1162; + ld.shared.v4.b32 {%r1165, %r1166, %r1167, %r1168}, [%r47+1328]; + neg.f32 %r1169, %r1165; + fma.rn.f32 %r1170, %r1169, %r114, %r1164; + neg.f32 %r1171, %r1166; + fma.rn.f32 %r1172, %r1171, %r115, %r1170; + neg.f32 %r1173, %r1167; + fma.rn.f32 %r1174, %r1173, %r116, %r1172; + neg.f32 %r1175, %r1168; + fma.rn.f32 %r1176, %r1175, %r117, %r1174; + ld.shared.v4.b32 {%r1177, %r1178, %r1179, %r1180}, [%r47+1344]; + neg.f32 %r1181, %r1177; + fma.rn.f32 %r1182, %r1181, %r118, %r1176; + neg.f32 %r1183, %r1178; + fma.rn.f32 %r1184, %r1183, %r119, %r1182; + neg.f32 %r1185, %r1179; + fma.rn.f32 %r1186, %r1185, %r120, %r1184; + neg.f32 %r1187, %r1180; + fma.rn.f32 %r1188, %r1187, %r121, %r1186; + setp.eq.b32 %p194, %r4, 10; + selp.f32 %r1189, 0f3F800000, 0f00000000, %p194; + selp.f32 %r122, %r1188, %r1189, %p174; + ld.shared.b32 %r1190, [%r47+1452]; + neg.f32 %r1191, %r1190; + fma.rn.f32 %r1192, %r1191, %r48, 0f00000000; + ld.shared.v4.b32 {%r1193, %r1194, %r1195, %r1196}, [%r47+1456]; + neg.f32 %r1197, %r1193; + fma.rn.f32 %r1198, %r1197, %r113, %r1192; + neg.f32 %r1199, %r1194; + fma.rn.f32 %r1200, %r1199, %r114, %r1198; + neg.f32 %r1201, %r1195; + fma.rn.f32 %r1202, %r1201, %r115, %r1200; + neg.f32 %r1203, %r1196; + fma.rn.f32 %r1204, %r1203, %r116, %r1202; + ld.shared.v4.b32 {%r1205, %r1206, %r1207, %r1208}, [%r47+1472]; + neg.f32 %r1209, %r1205; + fma.rn.f32 %r1210, %r1209, %r117, %r1204; + neg.f32 %r1211, %r1206; + fma.rn.f32 %r1212, %r1211, %r118, %r1210; + neg.f32 %r1213, %r1207; + fma.rn.f32 %r1214, %r1213, %r119, %r1212; + neg.f32 %r1215, %r1208; + fma.rn.f32 %r1216, %r1215, %r120, %r1214; + ld.shared.v2.b32 {%r1217, %r1218}, [%r47+1488]; + neg.f32 %r1219, %r1217; + fma.rn.f32 %r1220, %r1219, %r121, %r1216; + neg.f32 %r1221, %r1218; + fma.rn.f32 %r1222, %r1221, %r122, %r1220; + setp.eq.b32 %p195, %r4, 11; + selp.f32 %r1223, 0f3F800000, 0f00000000, %p195; + selp.f32 %r123, %r1222, %r1223, %p173; + ld.shared.v4.b32 {%r1224, %r1225, %r1226, %r1227}, [%r47+1584]; + neg.f32 %r1228, %r1224; + fma.rn.f32 %r1229, %r1228, %r48, 0f00000000; + neg.f32 %r1230, %r1225; + fma.rn.f32 %r1231, %r1230, %r113, %r1229; + neg.f32 %r1232, %r1226; + fma.rn.f32 %r1233, %r1232, %r114, %r1231; + neg.f32 %r1234, %r1227; + fma.rn.f32 %r1235, %r1234, %r115, %r1233; + ld.shared.v4.b32 {%r1236, %r1237, %r1238, %r1239}, [%r47+1600]; + neg.f32 %r1240, %r1236; + fma.rn.f32 %r1241, %r1240, %r116, %r1235; + neg.f32 %r1242, %r1237; + fma.rn.f32 %r1243, %r1242, %r117, %r1241; + neg.f32 %r1244, %r1238; + fma.rn.f32 %r1245, %r1244, %r118, %r1243; + neg.f32 %r1246, %r1239; + fma.rn.f32 %r1247, %r1246, %r119, %r1245; + ld.shared.v4.b32 {%r1248, %r1249, %r1250, %r1251}, [%r47+1616]; + neg.f32 %r1252, %r1248; + fma.rn.f32 %r1253, %r1252, %r120, %r1247; + neg.f32 %r1254, %r1249; + fma.rn.f32 %r1255, %r1254, %r121, %r1253; + neg.f32 %r1256, %r1250; + fma.rn.f32 %r1257, %r1256, %r122, %r1255; + neg.f32 %r1258, %r1251; + fma.rn.f32 %r1259, %r1258, %r123, %r1257; + setp.eq.b32 %p196, %r4, 12; + selp.f32 %r1260, 0f3F800000, 0f00000000, %p196; + selp.f32 %r124, %r1259, %r1260, %p172; + ld.shared.b32 %r1261, [%r47+1716]; + neg.f32 %r1262, %r1261; + fma.rn.f32 %r1263, %r1262, %r48, 0f00000000; + ld.shared.v2.b32 {%r1264, %r1265}, [%r47+1720]; + neg.f32 %r1266, %r1264; + fma.rn.f32 %r1267, %r1266, %r113, %r1263; + neg.f32 %r1268, %r1265; + fma.rn.f32 %r1269, %r1268, %r114, %r1267; + ld.shared.v4.b32 {%r1270, %r1271, %r1272, %r1273}, [%r47+1728]; + neg.f32 %r1274, %r1270; + fma.rn.f32 %r1275, %r1274, %r115, %r1269; + neg.f32 %r1276, %r1271; + fma.rn.f32 %r1277, %r1276, %r116, %r1275; + neg.f32 %r1278, %r1272; + fma.rn.f32 %r1279, %r1278, %r117, %r1277; + neg.f32 %r1280, %r1273; + fma.rn.f32 %r1281, %r1280, %r118, %r1279; + ld.shared.v4.b32 {%r1282, %r1283, %r1284, %r1285}, [%r47+1744]; + neg.f32 %r1286, %r1282; + fma.rn.f32 %r1287, %r1286, %r119, %r1281; + neg.f32 %r1288, %r1283; + fma.rn.f32 %r1289, %r1288, %r120, %r1287; + neg.f32 %r1290, %r1284; + fma.rn.f32 %r1291, %r1290, %r121, %r1289; + neg.f32 %r1292, %r1285; + fma.rn.f32 %r1293, %r1292, %r122, %r1291; + ld.shared.v2.b32 {%r1294, %r1295}, [%r47+1760]; + neg.f32 %r1296, %r1294; + fma.rn.f32 %r1297, %r1296, %r123, %r1293; + neg.f32 %r1298, %r1295; + fma.rn.f32 %r1299, %r1298, %r124, %r1297; + setp.eq.b32 %p197, %r4, 13; + selp.f32 %r1300, 0f3F800000, 0f00000000, %p197; + selp.f32 %r125, %r1299, %r1300, %p171; + ld.shared.v2.b32 {%r1301, %r1302}, [%r47+1848]; + neg.f32 %r1303, %r1301; + fma.rn.f32 %r1304, %r1303, %r48, 0f00000000; + neg.f32 %r1305, %r1302; + fma.rn.f32 %r1306, %r1305, %r113, %r1304; + ld.shared.v4.b32 {%r1307, %r1308, %r1309, %r1310}, [%r47+1856]; + neg.f32 %r1311, %r1307; + fma.rn.f32 %r1312, %r1311, %r114, %r1306; + neg.f32 %r1313, %r1308; + fma.rn.f32 %r1314, %r1313, %r115, %r1312; + neg.f32 %r1315, %r1309; + fma.rn.f32 %r1316, %r1315, %r116, %r1314; + neg.f32 %r1317, %r1310; + fma.rn.f32 %r1318, %r1317, %r117, %r1316; + ld.shared.v4.b32 {%r1319, %r1320, %r1321, %r1322}, [%r47+1872]; + neg.f32 %r1323, %r1319; + fma.rn.f32 %r1324, %r1323, %r118, %r1318; + neg.f32 %r1325, %r1320; + fma.rn.f32 %r1326, %r1325, %r119, %r1324; + neg.f32 %r1327, %r1321; + fma.rn.f32 %r1328, %r1327, %r120, %r1326; + neg.f32 %r1329, %r1322; + fma.rn.f32 %r1330, %r1329, %r121, %r1328; + ld.shared.v4.b32 {%r1331, %r1332, %r1333, %r1334}, [%r47+1888]; + neg.f32 %r1335, %r1331; + fma.rn.f32 %r1336, %r1335, %r122, %r1330; + neg.f32 %r1337, %r1332; + fma.rn.f32 %r1338, %r1337, %r123, %r1336; + neg.f32 %r1339, %r1333; + fma.rn.f32 %r1340, %r1339, %r124, %r1338; + neg.f32 %r1341, %r1334; + fma.rn.f32 %r1342, %r1341, %r125, %r1340; + setp.eq.b32 %p198, %r4, 14; + selp.f32 %r1343, 0f3F800000, 0f00000000, %p198; + selp.f32 %r126, %r1342, %r1343, %p170; + ld.shared.b32 %r1344, [%r47+1980]; + neg.f32 %r1345, %r1344; + fma.rn.f32 %r1346, %r1345, %r48, 0f00000000; + ld.shared.v4.b32 {%r1347, %r1348, %r1349, %r1350}, [%r47+1984]; + neg.f32 %r1351, %r1347; + fma.rn.f32 %r1352, %r1351, %r113, %r1346; + neg.f32 %r1353, %r1348; + fma.rn.f32 %r1354, %r1353, %r114, %r1352; + neg.f32 %r1355, %r1349; + fma.rn.f32 %r1356, %r1355, %r115, %r1354; + neg.f32 %r1357, %r1350; + fma.rn.f32 %r1358, %r1357, %r116, %r1356; + ld.shared.v4.b32 {%r1359, %r1360, %r1361, %r1362}, [%r47+2000]; + neg.f32 %r1363, %r1359; + fma.rn.f32 %r1364, %r1363, %r117, %r1358; + neg.f32 %r1365, %r1360; + fma.rn.f32 %r1366, %r1365, %r118, %r1364; + neg.f32 %r1367, %r1361; + fma.rn.f32 %r1368, %r1367, %r119, %r1366; + neg.f32 %r1369, %r1362; + fma.rn.f32 %r1370, %r1369, %r120, %r1368; + ld.shared.v4.b32 {%r1371, %r1372, %r1373, %r1374}, [%r47+2016]; + neg.f32 %r1375, %r1371; + fma.rn.f32 %r1376, %r1375, %r121, %r1370; + neg.f32 %r1377, %r1372; + fma.rn.f32 %r1378, %r1377, %r122, %r1376; + neg.f32 %r1379, %r1373; + fma.rn.f32 %r1380, %r1379, %r123, %r1378; + neg.f32 %r1381, %r1374; + fma.rn.f32 %r1382, %r1381, %r124, %r1380; + ld.shared.v2.b32 {%r1383, %r1384}, [%r47+2032]; + neg.f32 %r1385, %r1383; + fma.rn.f32 %r1386, %r1385, %r125, %r1382; + neg.f32 %r1387, %r1384; + fma.rn.f32 %r1388, %r1387, %r126, %r1386; + setp.eq.b32 %p199, %r4, 15; + selp.f32 %r1389, 0f3F800000, 0f00000000, %p199; + selp.f32 %r127, %r1388, %r1389, %p169; + ld.shared.v4.b32 {%r1390, %r1391, %r1392, %r1393}, [%r47+2112]; + neg.f32 %r1394, %r1390; + fma.rn.f32 %r1395, %r1394, %r48, 0f00000000; + neg.f32 %r1396, %r1391; + fma.rn.f32 %r1397, %r1396, %r113, %r1395; + neg.f32 %r1398, %r1392; + fma.rn.f32 %r1399, %r1398, %r114, %r1397; + neg.f32 %r1400, %r1393; + fma.rn.f32 %r1401, %r1400, %r115, %r1399; + ld.shared.v4.b32 {%r1402, %r1403, %r1404, %r1405}, [%r47+2128]; + neg.f32 %r1406, %r1402; + fma.rn.f32 %r1407, %r1406, %r116, %r1401; + neg.f32 %r1408, %r1403; + fma.rn.f32 %r1409, %r1408, %r117, %r1407; + neg.f32 %r1410, %r1404; + fma.rn.f32 %r1411, %r1410, %r118, %r1409; + neg.f32 %r1412, %r1405; + fma.rn.f32 %r1413, %r1412, %r119, %r1411; + ld.shared.v4.b32 {%r1414, %r1415, %r1416, %r1417}, [%r47+2144]; + neg.f32 %r1418, %r1414; + fma.rn.f32 %r1419, %r1418, %r120, %r1413; + neg.f32 %r1420, %r1415; + fma.rn.f32 %r1421, %r1420, %r121, %r1419; + neg.f32 %r1422, %r1416; + fma.rn.f32 %r1423, %r1422, %r122, %r1421; + neg.f32 %r1424, %r1417; + fma.rn.f32 %r1425, %r1424, %r123, %r1423; + ld.shared.v4.b32 {%r1426, %r1427, %r1428, %r1429}, [%r47+2160]; + neg.f32 %r1430, %r1426; + fma.rn.f32 %r1431, %r1430, %r124, %r1425; + neg.f32 %r1432, %r1427; + fma.rn.f32 %r1433, %r1432, %r125, %r1431; + neg.f32 %r1434, %r1428; + fma.rn.f32 %r1435, %r1434, %r126, %r1433; + neg.f32 %r1436, %r1429; + fma.rn.f32 %r1437, %r1436, %r127, %r1435; + setp.eq.b32 %p200, %r4, 16; + selp.f32 %r1438, 0f3F800000, 0f00000000, %p200; + selp.f32 %r128, %r1437, %r1438, %p180; + ld.shared.b32 %r1439, [%r47+2244]; + neg.f32 %r1440, %r1439; + fma.rn.f32 %r1441, %r1440, %r48, 0f00000000; + ld.shared.v2.b32 {%r1442, %r1443}, [%r47+2248]; + neg.f32 %r1444, %r1442; + fma.rn.f32 %r1445, %r1444, %r113, %r1441; + neg.f32 %r1446, %r1443; + fma.rn.f32 %r1447, %r1446, %r114, %r1445; + ld.shared.v4.b32 {%r1448, %r1449, %r1450, %r1451}, [%r47+2256]; + neg.f32 %r1452, %r1448; + fma.rn.f32 %r1453, %r1452, %r115, %r1447; + neg.f32 %r1454, %r1449; + fma.rn.f32 %r1455, %r1454, %r116, %r1453; + neg.f32 %r1456, %r1450; + fma.rn.f32 %r1457, %r1456, %r117, %r1455; + neg.f32 %r1458, %r1451; + fma.rn.f32 %r1459, %r1458, %r118, %r1457; + ld.shared.v4.b32 {%r1460, %r1461, %r1462, %r1463}, [%r47+2272]; + neg.f32 %r1464, %r1460; + fma.rn.f32 %r1465, %r1464, %r119, %r1459; + neg.f32 %r1466, %r1461; + fma.rn.f32 %r1467, %r1466, %r120, %r1465; + neg.f32 %r1468, %r1462; + fma.rn.f32 %r1469, %r1468, %r121, %r1467; + neg.f32 %r1470, %r1463; + fma.rn.f32 %r1471, %r1470, %r122, %r1469; + ld.shared.v4.b32 {%r1472, %r1473, %r1474, %r1475}, [%r47+2288]; + neg.f32 %r1476, %r1472; + fma.rn.f32 %r1477, %r1476, %r123, %r1471; + neg.f32 %r1478, %r1473; + fma.rn.f32 %r1479, %r1478, %r124, %r1477; + neg.f32 %r1480, %r1474; + fma.rn.f32 %r1481, %r1480, %r125, %r1479; + neg.f32 %r1482, %r1475; + fma.rn.f32 %r1483, %r1482, %r126, %r1481; + ld.shared.v2.b32 {%r1484, %r1485}, [%r47+2304]; + neg.f32 %r1486, %r1484; + fma.rn.f32 %r1487, %r1486, %r127, %r1483; + neg.f32 %r1488, %r1485; + fma.rn.f32 %r1489, %r1488, %r128, %r1487; + setp.eq.b32 %p201, %r4, 17; + selp.f32 %r1490, 0f3F800000, 0f00000000, %p201; + selp.f32 %r129, %r1489, %r1490, %p168; + ld.shared.v2.b32 {%r1491, %r1492}, [%r47+2376]; + neg.f32 %r1493, %r1491; + fma.rn.f32 %r1494, %r1493, %r48, 0f00000000; + neg.f32 %r1495, %r1492; + fma.rn.f32 %r1496, %r1495, %r113, %r1494; + ld.shared.v4.b32 {%r1497, %r1498, %r1499, %r1500}, [%r47+2384]; + neg.f32 %r1501, %r1497; + fma.rn.f32 %r1502, %r1501, %r114, %r1496; + neg.f32 %r1503, %r1498; + fma.rn.f32 %r1504, %r1503, %r115, %r1502; + neg.f32 %r1505, %r1499; + fma.rn.f32 %r1506, %r1505, %r116, %r1504; + neg.f32 %r1507, %r1500; + fma.rn.f32 %r1508, %r1507, %r117, %r1506; + ld.shared.v4.b32 {%r1509, %r1510, %r1511, %r1512}, [%r47+2400]; + neg.f32 %r1513, %r1509; + fma.rn.f32 %r1514, %r1513, %r118, %r1508; + neg.f32 %r1515, %r1510; + fma.rn.f32 %r1516, %r1515, %r119, %r1514; + neg.f32 %r1517, %r1511; + fma.rn.f32 %r1518, %r1517, %r120, %r1516; + neg.f32 %r1519, %r1512; + fma.rn.f32 %r1520, %r1519, %r121, %r1518; + ld.shared.v4.b32 {%r1521, %r1522, %r1523, %r1524}, [%r47+2416]; + neg.f32 %r1525, %r1521; + fma.rn.f32 %r1526, %r1525, %r122, %r1520; + neg.f32 %r1527, %r1522; + fma.rn.f32 %r1528, %r1527, %r123, %r1526; + neg.f32 %r1529, %r1523; + fma.rn.f32 %r1530, %r1529, %r124, %r1528; + neg.f32 %r1531, %r1524; + fma.rn.f32 %r1532, %r1531, %r125, %r1530; + ld.shared.v4.b32 {%r1533, %r1534, %r1535, %r1536}, [%r47+2432]; + neg.f32 %r1537, %r1533; + fma.rn.f32 %r1538, %r1537, %r126, %r1532; + neg.f32 %r1539, %r1534; + fma.rn.f32 %r1540, %r1539, %r127, %r1538; + neg.f32 %r1541, %r1535; + fma.rn.f32 %r1542, %r1541, %r128, %r1540; + neg.f32 %r1543, %r1536; + fma.rn.f32 %r1544, %r1543, %r129, %r1542; + setp.eq.b32 %p202, %r4, 18; + selp.f32 %r1545, 0f3F800000, 0f00000000, %p202; + selp.f32 %r130, %r1544, %r1545, %p167; + ld.shared.b32 %r1546, [%r47+2508]; + neg.f32 %r1547, %r1546; + fma.rn.f32 %r1548, %r1547, %r48, 0f00000000; + ld.shared.v4.b32 {%r1549, %r1550, %r1551, %r1552}, [%r47+2512]; + neg.f32 %r1553, %r1549; + fma.rn.f32 %r1554, %r1553, %r113, %r1548; + neg.f32 %r1555, %r1550; + fma.rn.f32 %r1556, %r1555, %r114, %r1554; + neg.f32 %r1557, %r1551; + fma.rn.f32 %r1558, %r1557, %r115, %r1556; + neg.f32 %r1559, %r1552; + fma.rn.f32 %r1560, %r1559, %r116, %r1558; + ld.shared.v4.b32 {%r1561, %r1562, %r1563, %r1564}, [%r47+2528]; + neg.f32 %r1565, %r1561; + fma.rn.f32 %r1566, %r1565, %r117, %r1560; + neg.f32 %r1567, %r1562; + fma.rn.f32 %r1568, %r1567, %r118, %r1566; + neg.f32 %r1569, %r1563; + fma.rn.f32 %r1570, %r1569, %r119, %r1568; + neg.f32 %r1571, %r1564; + fma.rn.f32 %r1572, %r1571, %r120, %r1570; + ld.shared.v4.b32 {%r1573, %r1574, %r1575, %r1576}, [%r47+2544]; + neg.f32 %r1577, %r1573; + fma.rn.f32 %r1578, %r1577, %r121, %r1572; + neg.f32 %r1579, %r1574; + fma.rn.f32 %r1580, %r1579, %r122, %r1578; + neg.f32 %r1581, %r1575; + fma.rn.f32 %r1582, %r1581, %r123, %r1580; + neg.f32 %r1583, %r1576; + fma.rn.f32 %r1584, %r1583, %r124, %r1582; + ld.shared.v4.b32 {%r1585, %r1586, %r1587, %r1588}, [%r47+2560]; + neg.f32 %r1589, %r1585; + fma.rn.f32 %r1590, %r1589, %r125, %r1584; + neg.f32 %r1591, %r1586; + fma.rn.f32 %r1592, %r1591, %r126, %r1590; + neg.f32 %r1593, %r1587; + fma.rn.f32 %r1594, %r1593, %r127, %r1592; + neg.f32 %r1595, %r1588; + fma.rn.f32 %r1596, %r1595, %r128, %r1594; + ld.shared.v2.b32 {%r1597, %r1598}, [%r47+2576]; + neg.f32 %r1599, %r1597; + fma.rn.f32 %r1600, %r1599, %r129, %r1596; + neg.f32 %r1601, %r1598; + fma.rn.f32 %r1602, %r1601, %r130, %r1600; + setp.eq.b32 %p203, %r4, 19; + selp.f32 %r1603, 0f3F800000, 0f00000000, %p203; + selp.f32 %r131, %r1602, %r1603, %p166; + ld.shared.v4.b32 {%r1604, %r1605, %r1606, %r1607}, [%r47+2640]; + neg.f32 %r1608, %r1604; + fma.rn.f32 %r1609, %r1608, %r48, 0f00000000; + neg.f32 %r1610, %r1605; + fma.rn.f32 %r1611, %r1610, %r113, %r1609; + neg.f32 %r1612, %r1606; + fma.rn.f32 %r1613, %r1612, %r114, %r1611; + neg.f32 %r1614, %r1607; + fma.rn.f32 %r1615, %r1614, %r115, %r1613; + ld.shared.v4.b32 {%r1616, %r1617, %r1618, %r1619}, [%r47+2656]; + neg.f32 %r1620, %r1616; + fma.rn.f32 %r1621, %r1620, %r116, %r1615; + neg.f32 %r1622, %r1617; + fma.rn.f32 %r1623, %r1622, %r117, %r1621; + neg.f32 %r1624, %r1618; + fma.rn.f32 %r1625, %r1624, %r118, %r1623; + neg.f32 %r1626, %r1619; + fma.rn.f32 %r1627, %r1626, %r119, %r1625; + ld.shared.v4.b32 {%r1628, %r1629, %r1630, %r1631}, [%r47+2672]; + neg.f32 %r1632, %r1628; + fma.rn.f32 %r1633, %r1632, %r120, %r1627; + neg.f32 %r1634, %r1629; + fma.rn.f32 %r1635, %r1634, %r121, %r1633; + neg.f32 %r1636, %r1630; + fma.rn.f32 %r1637, %r1636, %r122, %r1635; + neg.f32 %r1638, %r1631; + fma.rn.f32 %r1639, %r1638, %r123, %r1637; + ld.shared.v4.b32 {%r1640, %r1641, %r1642, %r1643}, [%r47+2688]; + neg.f32 %r1644, %r1640; + fma.rn.f32 %r1645, %r1644, %r124, %r1639; + neg.f32 %r1646, %r1641; + fma.rn.f32 %r1647, %r1646, %r125, %r1645; + neg.f32 %r1648, %r1642; + fma.rn.f32 %r1649, %r1648, %r126, %r1647; + neg.f32 %r1650, %r1643; + fma.rn.f32 %r1651, %r1650, %r127, %r1649; + ld.shared.v4.b32 {%r1652, %r1653, %r1654, %r1655}, [%r47+2704]; + neg.f32 %r1656, %r1652; + fma.rn.f32 %r1657, %r1656, %r128, %r1651; + neg.f32 %r1658, %r1653; + fma.rn.f32 %r1659, %r1658, %r129, %r1657; + neg.f32 %r1660, %r1654; + fma.rn.f32 %r1661, %r1660, %r130, %r1659; + neg.f32 %r1662, %r1655; + fma.rn.f32 %r1663, %r1662, %r131, %r1661; + setp.eq.b32 %p204, %r4, 20; + selp.f32 %r1664, 0f3F800000, 0f00000000, %p204; + selp.f32 %r132, %r1663, %r1664, %p165; + ld.shared.b32 %r1665, [%r47+2772]; + neg.f32 %r1666, %r1665; + fma.rn.f32 %r1667, %r1666, %r48, 0f00000000; + ld.shared.v2.b32 {%r1668, %r1669}, [%r47+2776]; + neg.f32 %r1670, %r1668; + fma.rn.f32 %r1671, %r1670, %r113, %r1667; + neg.f32 %r1672, %r1669; + fma.rn.f32 %r1673, %r1672, %r114, %r1671; + ld.shared.v4.b32 {%r1674, %r1675, %r1676, %r1677}, [%r47+2784]; + neg.f32 %r1678, %r1674; + fma.rn.f32 %r1679, %r1678, %r115, %r1673; + neg.f32 %r1680, %r1675; + fma.rn.f32 %r1681, %r1680, %r116, %r1679; + neg.f32 %r1682, %r1676; + fma.rn.f32 %r1683, %r1682, %r117, %r1681; + neg.f32 %r1684, %r1677; + fma.rn.f32 %r1685, %r1684, %r118, %r1683; + ld.shared.v4.b32 {%r1686, %r1687, %r1688, %r1689}, [%r47+2800]; + neg.f32 %r1690, %r1686; + fma.rn.f32 %r1691, %r1690, %r119, %r1685; + neg.f32 %r1692, %r1687; + fma.rn.f32 %r1693, %r1692, %r120, %r1691; + neg.f32 %r1694, %r1688; + fma.rn.f32 %r1695, %r1694, %r121, %r1693; + neg.f32 %r1696, %r1689; + fma.rn.f32 %r1697, %r1696, %r122, %r1695; + ld.shared.v4.b32 {%r1698, %r1699, %r1700, %r1701}, [%r47+2816]; + neg.f32 %r1702, %r1698; + fma.rn.f32 %r1703, %r1702, %r123, %r1697; + neg.f32 %r1704, %r1699; + fma.rn.f32 %r1705, %r1704, %r124, %r1703; + neg.f32 %r1706, %r1700; + fma.rn.f32 %r1707, %r1706, %r125, %r1705; + neg.f32 %r1708, %r1701; + fma.rn.f32 %r1709, %r1708, %r126, %r1707; + ld.shared.v4.b32 {%r1710, %r1711, %r1712, %r1713}, [%r47+2832]; + neg.f32 %r1714, %r1710; + fma.rn.f32 %r1715, %r1714, %r127, %r1709; + neg.f32 %r1716, %r1711; + fma.rn.f32 %r1717, %r1716, %r128, %r1715; + neg.f32 %r1718, %r1712; + fma.rn.f32 %r1719, %r1718, %r129, %r1717; + neg.f32 %r1720, %r1713; + fma.rn.f32 %r1721, %r1720, %r130, %r1719; + ld.shared.v2.b32 {%r1722, %r1723}, [%r47+2848]; + neg.f32 %r1724, %r1722; + fma.rn.f32 %r1725, %r1724, %r131, %r1721; + neg.f32 %r1726, %r1723; + fma.rn.f32 %r1727, %r1726, %r132, %r1725; + setp.eq.b32 %p205, %r4, 21; + selp.f32 %r1728, 0f3F800000, 0f00000000, %p205; + selp.f32 %r133, %r1727, %r1728, %p164; + ld.shared.v2.b32 {%r1729, %r1730}, [%r47+2904]; + neg.f32 %r1731, %r1729; + fma.rn.f32 %r1732, %r1731, %r48, 0f00000000; + neg.f32 %r1733, %r1730; + fma.rn.f32 %r1734, %r1733, %r113, %r1732; + ld.shared.v4.b32 {%r1735, %r1736, %r1737, %r1738}, [%r47+2912]; + neg.f32 %r1739, %r1735; + fma.rn.f32 %r1740, %r1739, %r114, %r1734; + neg.f32 %r1741, %r1736; + fma.rn.f32 %r1742, %r1741, %r115, %r1740; + neg.f32 %r1743, %r1737; + fma.rn.f32 %r1744, %r1743, %r116, %r1742; + neg.f32 %r1745, %r1738; + fma.rn.f32 %r1746, %r1745, %r117, %r1744; + ld.shared.v4.b32 {%r1747, %r1748, %r1749, %r1750}, [%r47+2928]; + neg.f32 %r1751, %r1747; + fma.rn.f32 %r1752, %r1751, %r118, %r1746; + neg.f32 %r1753, %r1748; + fma.rn.f32 %r1754, %r1753, %r119, %r1752; + neg.f32 %r1755, %r1749; + fma.rn.f32 %r1756, %r1755, %r120, %r1754; + neg.f32 %r1757, %r1750; + fma.rn.f32 %r1758, %r1757, %r121, %r1756; + ld.shared.v4.b32 {%r1759, %r1760, %r1761, %r1762}, [%r47+2944]; + neg.f32 %r1763, %r1759; + fma.rn.f32 %r1764, %r1763, %r122, %r1758; + neg.f32 %r1765, %r1760; + fma.rn.f32 %r1766, %r1765, %r123, %r1764; + neg.f32 %r1767, %r1761; + fma.rn.f32 %r1768, %r1767, %r124, %r1766; + neg.f32 %r1769, %r1762; + fma.rn.f32 %r1770, %r1769, %r125, %r1768; + ld.shared.v4.b32 {%r1771, %r1772, %r1773, %r1774}, [%r47+2960]; + neg.f32 %r1775, %r1771; + fma.rn.f32 %r1776, %r1775, %r126, %r1770; + neg.f32 %r1777, %r1772; + fma.rn.f32 %r1778, %r1777, %r127, %r1776; + neg.f32 %r1779, %r1773; + fma.rn.f32 %r1780, %r1779, %r128, %r1778; + neg.f32 %r1781, %r1774; + fma.rn.f32 %r1782, %r1781, %r129, %r1780; + ld.shared.v4.b32 {%r1783, %r1784, %r1785, %r1786}, [%r47+2976]; + neg.f32 %r1787, %r1783; + fma.rn.f32 %r1788, %r1787, %r130, %r1782; + neg.f32 %r1789, %r1784; + fma.rn.f32 %r1790, %r1789, %r131, %r1788; + neg.f32 %r1791, %r1785; + fma.rn.f32 %r1792, %r1791, %r132, %r1790; + neg.f32 %r1793, %r1786; + fma.rn.f32 %r1794, %r1793, %r133, %r1792; + setp.eq.b32 %p206, %r4, 22; + selp.f32 %r1795, 0f3F800000, 0f00000000, %p206; + selp.f32 %r134, %r1794, %r1795, %p163; + ld.shared.b32 %r1796, [%r47+3036]; + neg.f32 %r1797, %r1796; + fma.rn.f32 %r1798, %r1797, %r48, 0f00000000; + ld.shared.v4.b32 {%r1799, %r1800, %r1801, %r1802}, [%r47+3040]; + neg.f32 %r1803, %r1799; + fma.rn.f32 %r1804, %r1803, %r113, %r1798; + neg.f32 %r1805, %r1800; + fma.rn.f32 %r1806, %r1805, %r114, %r1804; + neg.f32 %r1807, %r1801; + fma.rn.f32 %r1808, %r1807, %r115, %r1806; + neg.f32 %r1809, %r1802; + fma.rn.f32 %r1810, %r1809, %r116, %r1808; + ld.shared.v4.b32 {%r1811, %r1812, %r1813, %r1814}, [%r47+3056]; + neg.f32 %r1815, %r1811; + fma.rn.f32 %r1816, %r1815, %r117, %r1810; + neg.f32 %r1817, %r1812; + fma.rn.f32 %r1818, %r1817, %r118, %r1816; + neg.f32 %r1819, %r1813; + fma.rn.f32 %r1820, %r1819, %r119, %r1818; + neg.f32 %r1821, %r1814; + fma.rn.f32 %r1822, %r1821, %r120, %r1820; + ld.shared.v4.b32 {%r1823, %r1824, %r1825, %r1826}, [%r47+3072]; + neg.f32 %r1827, %r1823; + fma.rn.f32 %r1828, %r1827, %r121, %r1822; + neg.f32 %r1829, %r1824; + fma.rn.f32 %r1830, %r1829, %r122, %r1828; + neg.f32 %r1831, %r1825; + fma.rn.f32 %r1832, %r1831, %r123, %r1830; + neg.f32 %r1833, %r1826; + fma.rn.f32 %r1834, %r1833, %r124, %r1832; + ld.shared.v4.b32 {%r1835, %r1836, %r1837, %r1838}, [%r47+3088]; + neg.f32 %r1839, %r1835; + fma.rn.f32 %r1840, %r1839, %r125, %r1834; + neg.f32 %r1841, %r1836; + fma.rn.f32 %r1842, %r1841, %r126, %r1840; + neg.f32 %r1843, %r1837; + fma.rn.f32 %r1844, %r1843, %r127, %r1842; + neg.f32 %r1845, %r1838; + fma.rn.f32 %r1846, %r1845, %r128, %r1844; + ld.shared.v4.b32 {%r1847, %r1848, %r1849, %r1850}, [%r47+3104]; + neg.f32 %r1851, %r1847; + fma.rn.f32 %r1852, %r1851, %r129, %r1846; + neg.f32 %r1853, %r1848; + fma.rn.f32 %r1854, %r1853, %r130, %r1852; + neg.f32 %r1855, %r1849; + fma.rn.f32 %r1856, %r1855, %r131, %r1854; + neg.f32 %r1857, %r1850; + fma.rn.f32 %r1858, %r1857, %r132, %r1856; + ld.shared.v2.b32 {%r1859, %r1860}, [%r47+3120]; + neg.f32 %r1861, %r1859; + fma.rn.f32 %r1862, %r1861, %r133, %r1858; + neg.f32 %r1863, %r1860; + fma.rn.f32 %r1864, %r1863, %r134, %r1862; + setp.eq.b32 %p207, %r4, 23; + selp.f32 %r1865, 0f3F800000, 0f00000000, %p207; + selp.f32 %r135, %r1864, %r1865, %p162; + ld.shared.v4.b32 {%r1866, %r1867, %r1868, %r1869}, [%r47+3168]; + neg.f32 %r1870, %r1866; + fma.rn.f32 %r1871, %r1870, %r48, 0f00000000; + neg.f32 %r1872, %r1867; + fma.rn.f32 %r1873, %r1872, %r113, %r1871; + neg.f32 %r1874, %r1868; + fma.rn.f32 %r1875, %r1874, %r114, %r1873; + neg.f32 %r1876, %r1869; + fma.rn.f32 %r1877, %r1876, %r115, %r1875; + ld.shared.v4.b32 {%r1878, %r1879, %r1880, %r1881}, [%r47+3184]; + neg.f32 %r1882, %r1878; + fma.rn.f32 %r1883, %r1882, %r116, %r1877; + neg.f32 %r1884, %r1879; + fma.rn.f32 %r1885, %r1884, %r117, %r1883; + neg.f32 %r1886, %r1880; + fma.rn.f32 %r1887, %r1886, %r118, %r1885; + neg.f32 %r1888, %r1881; + fma.rn.f32 %r1889, %r1888, %r119, %r1887; + ld.shared.v4.b32 {%r1890, %r1891, %r1892, %r1893}, [%r47+3200]; + neg.f32 %r1894, %r1890; + fma.rn.f32 %r1895, %r1894, %r120, %r1889; + neg.f32 %r1896, %r1891; + fma.rn.f32 %r1897, %r1896, %r121, %r1895; + neg.f32 %r1898, %r1892; + fma.rn.f32 %r1899, %r1898, %r122, %r1897; + neg.f32 %r1900, %r1893; + fma.rn.f32 %r1901, %r1900, %r123, %r1899; + ld.shared.v4.b32 {%r1902, %r1903, %r1904, %r1905}, [%r47+3216]; + neg.f32 %r1906, %r1902; + fma.rn.f32 %r1907, %r1906, %r124, %r1901; + neg.f32 %r1908, %r1903; + fma.rn.f32 %r1909, %r1908, %r125, %r1907; + neg.f32 %r1910, %r1904; + fma.rn.f32 %r1911, %r1910, %r126, %r1909; + neg.f32 %r1912, %r1905; + fma.rn.f32 %r1913, %r1912, %r127, %r1911; + ld.shared.v4.b32 {%r1914, %r1915, %r1916, %r1917}, [%r47+3232]; + neg.f32 %r1918, %r1914; + fma.rn.f32 %r1919, %r1918, %r128, %r1913; + neg.f32 %r1920, %r1915; + fma.rn.f32 %r1921, %r1920, %r129, %r1919; + neg.f32 %r1922, %r1916; + fma.rn.f32 %r1923, %r1922, %r130, %r1921; + neg.f32 %r1924, %r1917; + fma.rn.f32 %r1925, %r1924, %r131, %r1923; + ld.shared.v4.b32 {%r1926, %r1927, %r1928, %r1929}, [%r47+3248]; + neg.f32 %r1930, %r1926; + fma.rn.f32 %r1931, %r1930, %r132, %r1925; + neg.f32 %r1932, %r1927; + fma.rn.f32 %r1933, %r1932, %r133, %r1931; + neg.f32 %r1934, %r1928; + fma.rn.f32 %r1935, %r1934, %r134, %r1933; + neg.f32 %r1936, %r1929; + fma.rn.f32 %r1937, %r1936, %r135, %r1935; + setp.eq.b32 %p208, %r4, 24; + selp.f32 %r1938, 0f3F800000, 0f00000000, %p208; + selp.f32 %r136, %r1937, %r1938, %p161; + ld.shared.b32 %r1939, [%r47+3300]; + neg.f32 %r1940, %r1939; + fma.rn.f32 %r1941, %r1940, %r48, 0f00000000; + ld.shared.v2.b32 {%r1942, %r1943}, [%r47+3304]; + neg.f32 %r1944, %r1942; + fma.rn.f32 %r1945, %r1944, %r113, %r1941; + neg.f32 %r1946, %r1943; + fma.rn.f32 %r1947, %r1946, %r114, %r1945; + ld.shared.v4.b32 {%r1948, %r1949, %r1950, %r1951}, [%r47+3312]; + neg.f32 %r1952, %r1948; + fma.rn.f32 %r1953, %r1952, %r115, %r1947; + neg.f32 %r1954, %r1949; + fma.rn.f32 %r1955, %r1954, %r116, %r1953; + neg.f32 %r1956, %r1950; + fma.rn.f32 %r1957, %r1956, %r117, %r1955; + neg.f32 %r1958, %r1951; + fma.rn.f32 %r1959, %r1958, %r118, %r1957; + ld.shared.v4.b32 {%r1960, %r1961, %r1962, %r1963}, [%r47+3328]; + neg.f32 %r1964, %r1960; + fma.rn.f32 %r1965, %r1964, %r119, %r1959; + neg.f32 %r1966, %r1961; + fma.rn.f32 %r1967, %r1966, %r120, %r1965; + neg.f32 %r1968, %r1962; + fma.rn.f32 %r1969, %r1968, %r121, %r1967; + neg.f32 %r1970, %r1963; + fma.rn.f32 %r1971, %r1970, %r122, %r1969; + ld.shared.v4.b32 {%r1972, %r1973, %r1974, %r1975}, [%r47+3344]; + neg.f32 %r1976, %r1972; + fma.rn.f32 %r1977, %r1976, %r123, %r1971; + neg.f32 %r1978, %r1973; + fma.rn.f32 %r1979, %r1978, %r124, %r1977; + neg.f32 %r1980, %r1974; + fma.rn.f32 %r1981, %r1980, %r125, %r1979; + neg.f32 %r1982, %r1975; + fma.rn.f32 %r1983, %r1982, %r126, %r1981; + ld.shared.v4.b32 {%r1984, %r1985, %r1986, %r1987}, [%r47+3360]; + neg.f32 %r1988, %r1984; + fma.rn.f32 %r1989, %r1988, %r127, %r1983; + neg.f32 %r1990, %r1985; + fma.rn.f32 %r1991, %r1990, %r128, %r1989; + neg.f32 %r1992, %r1986; + fma.rn.f32 %r1993, %r1992, %r129, %r1991; + neg.f32 %r1994, %r1987; + fma.rn.f32 %r1995, %r1994, %r130, %r1993; + ld.shared.v4.b32 {%r1996, %r1997, %r1998, %r1999}, [%r47+3376]; + neg.f32 %r2000, %r1996; + fma.rn.f32 %r2001, %r2000, %r131, %r1995; + neg.f32 %r2002, %r1997; + fma.rn.f32 %r2003, %r2002, %r132, %r2001; + neg.f32 %r2004, %r1998; + fma.rn.f32 %r2005, %r2004, %r133, %r2003; + neg.f32 %r2006, %r1999; + fma.rn.f32 %r2007, %r2006, %r134, %r2005; + ld.shared.v2.b32 {%r2008, %r2009}, [%r47+3392]; + neg.f32 %r2010, %r2008; + fma.rn.f32 %r2011, %r2010, %r135, %r2007; + neg.f32 %r2012, %r2009; + fma.rn.f32 %r2013, %r2012, %r136, %r2011; + setp.eq.b32 %p209, %r4, 25; + selp.f32 %r2014, 0f3F800000, 0f00000000, %p209; + selp.f32 %r137, %r2013, %r2014, %p160; + ld.shared.v2.b32 {%r2015, %r2016}, [%r47+3432]; + neg.f32 %r2017, %r2015; + fma.rn.f32 %r2018, %r2017, %r48, 0f00000000; + neg.f32 %r2019, %r2016; + fma.rn.f32 %r2020, %r2019, %r113, %r2018; + ld.shared.v4.b32 {%r2021, %r2022, %r2023, %r2024}, [%r47+3440]; + neg.f32 %r2025, %r2021; + fma.rn.f32 %r2026, %r2025, %r114, %r2020; + neg.f32 %r2027, %r2022; + fma.rn.f32 %r2028, %r2027, %r115, %r2026; + neg.f32 %r2029, %r2023; + fma.rn.f32 %r2030, %r2029, %r116, %r2028; + neg.f32 %r2031, %r2024; + fma.rn.f32 %r2032, %r2031, %r117, %r2030; + ld.shared.v4.b32 {%r2033, %r2034, %r2035, %r2036}, [%r47+3456]; + neg.f32 %r2037, %r2033; + fma.rn.f32 %r2038, %r2037, %r118, %r2032; + neg.f32 %r2039, %r2034; + fma.rn.f32 %r2040, %r2039, %r119, %r2038; + neg.f32 %r2041, %r2035; + fma.rn.f32 %r2042, %r2041, %r120, %r2040; + neg.f32 %r2043, %r2036; + fma.rn.f32 %r2044, %r2043, %r121, %r2042; + ld.shared.v4.b32 {%r2045, %r2046, %r2047, %r2048}, [%r47+3472]; + neg.f32 %r2049, %r2045; + fma.rn.f32 %r2050, %r2049, %r122, %r2044; + neg.f32 %r2051, %r2046; + fma.rn.f32 %r2052, %r2051, %r123, %r2050; + neg.f32 %r2053, %r2047; + fma.rn.f32 %r2054, %r2053, %r124, %r2052; + neg.f32 %r2055, %r2048; + fma.rn.f32 %r2056, %r2055, %r125, %r2054; + ld.shared.v4.b32 {%r2057, %r2058, %r2059, %r2060}, [%r47+3488]; + neg.f32 %r2061, %r2057; + fma.rn.f32 %r2062, %r2061, %r126, %r2056; + neg.f32 %r2063, %r2058; + fma.rn.f32 %r2064, %r2063, %r127, %r2062; + neg.f32 %r2065, %r2059; + fma.rn.f32 %r2066, %r2065, %r128, %r2064; + neg.f32 %r2067, %r2060; + fma.rn.f32 %r2068, %r2067, %r129, %r2066; + ld.shared.v4.b32 {%r2069, %r2070, %r2071, %r2072}, [%r47+3504]; + neg.f32 %r2073, %r2069; + fma.rn.f32 %r2074, %r2073, %r130, %r2068; + neg.f32 %r2075, %r2070; + fma.rn.f32 %r2076, %r2075, %r131, %r2074; + neg.f32 %r2077, %r2071; + fma.rn.f32 %r2078, %r2077, %r132, %r2076; + neg.f32 %r2079, %r2072; + fma.rn.f32 %r2080, %r2079, %r133, %r2078; + ld.shared.v4.b32 {%r2081, %r2082, %r2083, %r2084}, [%r47+3520]; + neg.f32 %r2085, %r2081; + fma.rn.f32 %r2086, %r2085, %r134, %r2080; + neg.f32 %r2087, %r2082; + fma.rn.f32 %r2088, %r2087, %r135, %r2086; + neg.f32 %r2089, %r2083; + fma.rn.f32 %r2090, %r2089, %r136, %r2088; + neg.f32 %r2091, %r2084; + fma.rn.f32 %r2092, %r2091, %r137, %r2090; + setp.eq.b32 %p210, %r4, 26; + selp.f32 %r2093, 0f3F800000, 0f00000000, %p210; + selp.f32 %r138, %r2092, %r2093, %p159; + ld.shared.b32 %r2094, [%r47+3564]; + neg.f32 %r2095, %r2094; + fma.rn.f32 %r2096, %r2095, %r48, 0f00000000; + ld.shared.v4.b32 {%r2097, %r2098, %r2099, %r2100}, [%r47+3568]; + neg.f32 %r2101, %r2097; + fma.rn.f32 %r2102, %r2101, %r113, %r2096; + neg.f32 %r2103, %r2098; + fma.rn.f32 %r2104, %r2103, %r114, %r2102; + neg.f32 %r2105, %r2099; + fma.rn.f32 %r2106, %r2105, %r115, %r2104; + neg.f32 %r2107, %r2100; + fma.rn.f32 %r2108, %r2107, %r116, %r2106; + ld.shared.v4.b32 {%r2109, %r2110, %r2111, %r2112}, [%r47+3584]; + neg.f32 %r2113, %r2109; + fma.rn.f32 %r2114, %r2113, %r117, %r2108; + neg.f32 %r2115, %r2110; + fma.rn.f32 %r2116, %r2115, %r118, %r2114; + neg.f32 %r2117, %r2111; + fma.rn.f32 %r2118, %r2117, %r119, %r2116; + neg.f32 %r2119, %r2112; + fma.rn.f32 %r2120, %r2119, %r120, %r2118; + ld.shared.v4.b32 {%r2121, %r2122, %r2123, %r2124}, [%r47+3600]; + neg.f32 %r2125, %r2121; + fma.rn.f32 %r2126, %r2125, %r121, %r2120; + neg.f32 %r2127, %r2122; + fma.rn.f32 %r2128, %r2127, %r122, %r2126; + neg.f32 %r2129, %r2123; + fma.rn.f32 %r2130, %r2129, %r123, %r2128; + neg.f32 %r2131, %r2124; + fma.rn.f32 %r2132, %r2131, %r124, %r2130; + ld.shared.v4.b32 {%r2133, %r2134, %r2135, %r2136}, [%r47+3616]; + neg.f32 %r2137, %r2133; + fma.rn.f32 %r2138, %r2137, %r125, %r2132; + neg.f32 %r2139, %r2134; + fma.rn.f32 %r2140, %r2139, %r126, %r2138; + neg.f32 %r2141, %r2135; + fma.rn.f32 %r2142, %r2141, %r127, %r2140; + neg.f32 %r2143, %r2136; + fma.rn.f32 %r2144, %r2143, %r128, %r2142; + ld.shared.v4.b32 {%r2145, %r2146, %r2147, %r2148}, [%r47+3632]; + neg.f32 %r2149, %r2145; + fma.rn.f32 %r2150, %r2149, %r129, %r2144; + neg.f32 %r2151, %r2146; + fma.rn.f32 %r2152, %r2151, %r130, %r2150; + neg.f32 %r2153, %r2147; + fma.rn.f32 %r2154, %r2153, %r131, %r2152; + neg.f32 %r2155, %r2148; + fma.rn.f32 %r2156, %r2155, %r132, %r2154; + ld.shared.v4.b32 {%r2157, %r2158, %r2159, %r2160}, [%r47+3648]; + neg.f32 %r2161, %r2157; + fma.rn.f32 %r2162, %r2161, %r133, %r2156; + neg.f32 %r2163, %r2158; + fma.rn.f32 %r2164, %r2163, %r134, %r2162; + neg.f32 %r2165, %r2159; + fma.rn.f32 %r2166, %r2165, %r135, %r2164; + neg.f32 %r2167, %r2160; + fma.rn.f32 %r2168, %r2167, %r136, %r2166; + ld.shared.v2.b32 {%r2169, %r2170}, [%r47+3664]; + neg.f32 %r2171, %r2169; + fma.rn.f32 %r2172, %r2171, %r137, %r2168; + neg.f32 %r2173, %r2170; + fma.rn.f32 %r2174, %r2173, %r138, %r2172; + setp.eq.b32 %p211, %r4, 27; + selp.f32 %r2175, 0f3F800000, 0f00000000, %p211; + selp.f32 %r139, %r2174, %r2175, %p158; + ld.shared.v4.b32 {%r2176, %r2177, %r2178, %r2179}, [%r47+3696]; + neg.f32 %r2180, %r2176; + fma.rn.f32 %r2181, %r2180, %r48, 0f00000000; + neg.f32 %r2182, %r2177; + fma.rn.f32 %r2183, %r2182, %r113, %r2181; + neg.f32 %r2184, %r2178; + fma.rn.f32 %r2185, %r2184, %r114, %r2183; + neg.f32 %r2186, %r2179; + fma.rn.f32 %r2187, %r2186, %r115, %r2185; + ld.shared.v4.b32 {%r2188, %r2189, %r2190, %r2191}, [%r47+3712]; + neg.f32 %r2192, %r2188; + fma.rn.f32 %r2193, %r2192, %r116, %r2187; + neg.f32 %r2194, %r2189; + fma.rn.f32 %r2195, %r2194, %r117, %r2193; + neg.f32 %r2196, %r2190; + fma.rn.f32 %r2197, %r2196, %r118, %r2195; + neg.f32 %r2198, %r2191; + fma.rn.f32 %r2199, %r2198, %r119, %r2197; + ld.shared.v4.b32 {%r2200, %r2201, %r2202, %r2203}, [%r47+3728]; + neg.f32 %r2204, %r2200; + fma.rn.f32 %r2205, %r2204, %r120, %r2199; + neg.f32 %r2206, %r2201; + fma.rn.f32 %r2207, %r2206, %r121, %r2205; + neg.f32 %r2208, %r2202; + fma.rn.f32 %r2209, %r2208, %r122, %r2207; + neg.f32 %r2210, %r2203; + fma.rn.f32 %r2211, %r2210, %r123, %r2209; + ld.shared.v4.b32 {%r2212, %r2213, %r2214, %r2215}, [%r47+3744]; + neg.f32 %r2216, %r2212; + fma.rn.f32 %r2217, %r2216, %r124, %r2211; + neg.f32 %r2218, %r2213; + fma.rn.f32 %r2219, %r2218, %r125, %r2217; + neg.f32 %r2220, %r2214; + fma.rn.f32 %r2221, %r2220, %r126, %r2219; + neg.f32 %r2222, %r2215; + fma.rn.f32 %r2223, %r2222, %r127, %r2221; + ld.shared.v4.b32 {%r2224, %r2225, %r2226, %r2227}, [%r47+3760]; + neg.f32 %r2228, %r2224; + fma.rn.f32 %r2229, %r2228, %r128, %r2223; + neg.f32 %r2230, %r2225; + fma.rn.f32 %r2231, %r2230, %r129, %r2229; + neg.f32 %r2232, %r2226; + fma.rn.f32 %r2233, %r2232, %r130, %r2231; + neg.f32 %r2234, %r2227; + fma.rn.f32 %r2235, %r2234, %r131, %r2233; + ld.shared.v4.b32 {%r2236, %r2237, %r2238, %r2239}, [%r47+3776]; + neg.f32 %r2240, %r2236; + fma.rn.f32 %r2241, %r2240, %r132, %r2235; + neg.f32 %r2242, %r2237; + fma.rn.f32 %r2243, %r2242, %r133, %r2241; + neg.f32 %r2244, %r2238; + fma.rn.f32 %r2245, %r2244, %r134, %r2243; + neg.f32 %r2246, %r2239; + fma.rn.f32 %r2247, %r2246, %r135, %r2245; + ld.shared.v4.b32 {%r2248, %r2249, %r2250, %r2251}, [%r47+3792]; + neg.f32 %r2252, %r2248; + fma.rn.f32 %r2253, %r2252, %r136, %r2247; + neg.f32 %r2254, %r2249; + fma.rn.f32 %r2255, %r2254, %r137, %r2253; + neg.f32 %r2256, %r2250; + fma.rn.f32 %r2257, %r2256, %r138, %r2255; + neg.f32 %r2258, %r2251; + fma.rn.f32 %r2259, %r2258, %r139, %r2257; + setp.eq.b32 %p212, %r4, 28; + selp.f32 %r2260, 0f3F800000, 0f00000000, %p212; + selp.f32 %r140, %r2259, %r2260, %p157; + ld.shared.b32 %r2261, [%r47+3828]; + neg.f32 %r2262, %r2261; + fma.rn.f32 %r2263, %r2262, %r48, 0f00000000; + ld.shared.v2.b32 {%r2264, %r2265}, [%r47+3832]; + neg.f32 %r2266, %r2264; + fma.rn.f32 %r2267, %r2266, %r113, %r2263; + neg.f32 %r2268, %r2265; + fma.rn.f32 %r2269, %r2268, %r114, %r2267; + ld.shared.v4.b32 {%r2270, %r2271, %r2272, %r2273}, [%r47+3840]; + neg.f32 %r2274, %r2270; + fma.rn.f32 %r2275, %r2274, %r115, %r2269; + neg.f32 %r2276, %r2271; + fma.rn.f32 %r2277, %r2276, %r116, %r2275; + neg.f32 %r2278, %r2272; + fma.rn.f32 %r2279, %r2278, %r117, %r2277; + neg.f32 %r2280, %r2273; + fma.rn.f32 %r2281, %r2280, %r118, %r2279; + ld.shared.v4.b32 {%r2282, %r2283, %r2284, %r2285}, [%r47+3856]; + neg.f32 %r2286, %r2282; + fma.rn.f32 %r2287, %r2286, %r119, %r2281; + neg.f32 %r2288, %r2283; + fma.rn.f32 %r2289, %r2288, %r120, %r2287; + neg.f32 %r2290, %r2284; + fma.rn.f32 %r2291, %r2290, %r121, %r2289; + neg.f32 %r2292, %r2285; + fma.rn.f32 %r2293, %r2292, %r122, %r2291; + ld.shared.v4.b32 {%r2294, %r2295, %r2296, %r2297}, [%r47+3872]; + neg.f32 %r2298, %r2294; + fma.rn.f32 %r2299, %r2298, %r123, %r2293; + neg.f32 %r2300, %r2295; + fma.rn.f32 %r2301, %r2300, %r124, %r2299; + neg.f32 %r2302, %r2296; + fma.rn.f32 %r2303, %r2302, %r125, %r2301; + neg.f32 %r2304, %r2297; + fma.rn.f32 %r2305, %r2304, %r126, %r2303; + ld.shared.v4.b32 {%r2306, %r2307, %r2308, %r2309}, [%r47+3888]; + neg.f32 %r2310, %r2306; + fma.rn.f32 %r2311, %r2310, %r127, %r2305; + neg.f32 %r2312, %r2307; + fma.rn.f32 %r2313, %r2312, %r128, %r2311; + neg.f32 %r2314, %r2308; + fma.rn.f32 %r2315, %r2314, %r129, %r2313; + neg.f32 %r2316, %r2309; + fma.rn.f32 %r2317, %r2316, %r130, %r2315; + ld.shared.v4.b32 {%r2318, %r2319, %r2320, %r2321}, [%r47+3904]; + neg.f32 %r2322, %r2318; + fma.rn.f32 %r2323, %r2322, %r131, %r2317; + neg.f32 %r2324, %r2319; + fma.rn.f32 %r2325, %r2324, %r132, %r2323; + neg.f32 %r2326, %r2320; + fma.rn.f32 %r2327, %r2326, %r133, %r2325; + neg.f32 %r2328, %r2321; + fma.rn.f32 %r2329, %r2328, %r134, %r2327; + ld.shared.v4.b32 {%r2330, %r2331, %r2332, %r2333}, [%r47+3920]; + neg.f32 %r2334, %r2330; + fma.rn.f32 %r2335, %r2334, %r135, %r2329; + neg.f32 %r2336, %r2331; + fma.rn.f32 %r2337, %r2336, %r136, %r2335; + neg.f32 %r2338, %r2332; + fma.rn.f32 %r2339, %r2338, %r137, %r2337; + neg.f32 %r2340, %r2333; + fma.rn.f32 %r2341, %r2340, %r138, %r2339; + ld.shared.v2.b32 {%r2342, %r2343}, [%r47+3936]; + neg.f32 %r2344, %r2342; + fma.rn.f32 %r2345, %r2344, %r139, %r2341; + neg.f32 %r2346, %r2343; + fma.rn.f32 %r2347, %r2346, %r140, %r2345; + setp.eq.b32 %p213, %r4, 29; + selp.f32 %r2348, 0f3F800000, 0f00000000, %p213; + selp.f32 %r141, %r2347, %r2348, %p156; + ld.shared.v2.b32 {%r2349, %r2350}, [%r47+3960]; + neg.f32 %r2351, %r2349; + fma.rn.f32 %r2352, %r2351, %r48, 0f00000000; + neg.f32 %r2353, %r2350; + fma.rn.f32 %r2354, %r2353, %r113, %r2352; + ld.shared.v4.b32 {%r2355, %r2356, %r2357, %r2358}, [%r47+3968]; + neg.f32 %r2359, %r2355; + fma.rn.f32 %r2360, %r2359, %r114, %r2354; + neg.f32 %r2361, %r2356; + fma.rn.f32 %r2362, %r2361, %r115, %r2360; + neg.f32 %r2363, %r2357; + fma.rn.f32 %r2364, %r2363, %r116, %r2362; + neg.f32 %r2365, %r2358; + fma.rn.f32 %r2366, %r2365, %r117, %r2364; + ld.shared.v4.b32 {%r2367, %r2368, %r2369, %r2370}, [%r47+3984]; + neg.f32 %r2371, %r2367; + fma.rn.f32 %r2372, %r2371, %r118, %r2366; + neg.f32 %r2373, %r2368; + fma.rn.f32 %r2374, %r2373, %r119, %r2372; + neg.f32 %r2375, %r2369; + fma.rn.f32 %r2376, %r2375, %r120, %r2374; + neg.f32 %r2377, %r2370; + fma.rn.f32 %r2378, %r2377, %r121, %r2376; + ld.shared.v4.b32 {%r2379, %r2380, %r2381, %r2382}, [%r47+4000]; + neg.f32 %r2383, %r2379; + fma.rn.f32 %r2384, %r2383, %r122, %r2378; + neg.f32 %r2385, %r2380; + fma.rn.f32 %r2386, %r2385, %r123, %r2384; + neg.f32 %r2387, %r2381; + fma.rn.f32 %r2388, %r2387, %r124, %r2386; + neg.f32 %r2389, %r2382; + fma.rn.f32 %r2390, %r2389, %r125, %r2388; + ld.shared.v4.b32 {%r2391, %r2392, %r2393, %r2394}, [%r47+4016]; + neg.f32 %r2395, %r2391; + fma.rn.f32 %r2396, %r2395, %r126, %r2390; + neg.f32 %r2397, %r2392; + fma.rn.f32 %r2398, %r2397, %r127, %r2396; + neg.f32 %r2399, %r2393; + fma.rn.f32 %r2400, %r2399, %r128, %r2398; + neg.f32 %r2401, %r2394; + fma.rn.f32 %r2402, %r2401, %r129, %r2400; + ld.shared.v4.b32 {%r2403, %r2404, %r2405, %r2406}, [%r47+4032]; + neg.f32 %r2407, %r2403; + fma.rn.f32 %r2408, %r2407, %r130, %r2402; + neg.f32 %r2409, %r2404; + fma.rn.f32 %r2410, %r2409, %r131, %r2408; + neg.f32 %r2411, %r2405; + fma.rn.f32 %r2412, %r2411, %r132, %r2410; + neg.f32 %r2413, %r2406; + fma.rn.f32 %r2414, %r2413, %r133, %r2412; + ld.shared.v4.b32 {%r2415, %r2416, %r2417, %r2418}, [%r47+4048]; + neg.f32 %r2419, %r2415; + fma.rn.f32 %r2420, %r2419, %r134, %r2414; + neg.f32 %r2421, %r2416; + fma.rn.f32 %r2422, %r2421, %r135, %r2420; + neg.f32 %r2423, %r2417; + fma.rn.f32 %r2424, %r2423, %r136, %r2422; + neg.f32 %r2425, %r2418; + fma.rn.f32 %r2426, %r2425, %r137, %r2424; + ld.shared.v4.b32 {%r2427, %r2428, %r2429, %r2430}, [%r47+4064]; + neg.f32 %r2431, %r2427; + fma.rn.f32 %r2432, %r2431, %r138, %r2426; + neg.f32 %r2433, %r2428; + fma.rn.f32 %r2434, %r2433, %r139, %r2432; + neg.f32 %r2435, %r2429; + fma.rn.f32 %r2436, %r2435, %r140, %r2434; + neg.f32 %r2437, %r2430; + fma.rn.f32 %r2438, %r2437, %r141, %r2436; + setp.eq.b32 %p214, %r4, 30; + selp.f32 %r2439, 0f3F800000, 0f00000000, %p214; + selp.f32 %r142, %r2438, %r2439, %p155; + ld.shared.b32 %r2440, [%r47+4092]; + neg.f32 %r2441, %r2440; + fma.rn.f32 %r2442, %r2441, %r48, 0f00000000; + ld.shared.v4.b32 {%r2443, %r2444, %r2445, %r2446}, [%r47+4096]; + neg.f32 %r2447, %r2443; + fma.rn.f32 %r2448, %r2447, %r113, %r2442; + neg.f32 %r2449, %r2444; + fma.rn.f32 %r2450, %r2449, %r114, %r2448; + neg.f32 %r2451, %r2445; + fma.rn.f32 %r2452, %r2451, %r115, %r2450; + neg.f32 %r2453, %r2446; + fma.rn.f32 %r2454, %r2453, %r116, %r2452; + ld.shared.v4.b32 {%r2455, %r2456, %r2457, %r2458}, [%r47+4112]; + neg.f32 %r2459, %r2455; + fma.rn.f32 %r2460, %r2459, %r117, %r2454; + neg.f32 %r2461, %r2456; + fma.rn.f32 %r2462, %r2461, %r118, %r2460; + neg.f32 %r2463, %r2457; + fma.rn.f32 %r2464, %r2463, %r119, %r2462; + neg.f32 %r2465, %r2458; + fma.rn.f32 %r2466, %r2465, %r120, %r2464; + ld.shared.v4.b32 {%r2467, %r2468, %r2469, %r2470}, [%r47+4128]; + neg.f32 %r2471, %r2467; + fma.rn.f32 %r2472, %r2471, %r121, %r2466; + neg.f32 %r2473, %r2468; + fma.rn.f32 %r2474, %r2473, %r122, %r2472; + neg.f32 %r2475, %r2469; + fma.rn.f32 %r2476, %r2475, %r123, %r2474; + neg.f32 %r2477, %r2470; + fma.rn.f32 %r2478, %r2477, %r124, %r2476; + ld.shared.v4.b32 {%r2479, %r2480, %r2481, %r2482}, [%r47+4144]; + neg.f32 %r2483, %r2479; + fma.rn.f32 %r2484, %r2483, %r125, %r2478; + neg.f32 %r2485, %r2480; + fma.rn.f32 %r2486, %r2485, %r126, %r2484; + neg.f32 %r2487, %r2481; + fma.rn.f32 %r2488, %r2487, %r127, %r2486; + neg.f32 %r2489, %r2482; + fma.rn.f32 %r2490, %r2489, %r128, %r2488; + ld.shared.v4.b32 {%r2491, %r2492, %r2493, %r2494}, [%r47+4160]; + neg.f32 %r2495, %r2491; + fma.rn.f32 %r2496, %r2495, %r129, %r2490; + neg.f32 %r2497, %r2492; + fma.rn.f32 %r2498, %r2497, %r130, %r2496; + neg.f32 %r2499, %r2493; + fma.rn.f32 %r2500, %r2499, %r131, %r2498; + neg.f32 %r2501, %r2494; + fma.rn.f32 %r2502, %r2501, %r132, %r2500; + ld.shared.v4.b32 {%r2503, %r2504, %r2505, %r2506}, [%r47+4176]; + neg.f32 %r2507, %r2503; + fma.rn.f32 %r2508, %r2507, %r133, %r2502; + neg.f32 %r2509, %r2504; + fma.rn.f32 %r2510, %r2509, %r134, %r2508; + neg.f32 %r2511, %r2505; + fma.rn.f32 %r2512, %r2511, %r135, %r2510; + neg.f32 %r2513, %r2506; + fma.rn.f32 %r2514, %r2513, %r136, %r2512; + ld.shared.v4.b32 {%r2515, %r2516, %r2517, %r2518}, [%r47+4192]; + neg.f32 %r2519, %r2515; + fma.rn.f32 %r2520, %r2519, %r137, %r2514; + neg.f32 %r2521, %r2516; + fma.rn.f32 %r2522, %r2521, %r138, %r2520; + neg.f32 %r2523, %r2517; + fma.rn.f32 %r2524, %r2523, %r139, %r2522; + neg.f32 %r2525, %r2518; + fma.rn.f32 %r2526, %r2525, %r140, %r2524; + ld.shared.v2.b32 {%r2527, %r2528}, [%r47+4208]; + neg.f32 %r2529, %r2527; + fma.rn.f32 %r2530, %r2529, %r141, %r2526; + neg.f32 %r2531, %r2528; + fma.rn.f32 %r2532, %r2531, %r142, %r2530; + selp.f32 %r143, 0f3F800000, %r2532, %p154; + abs.f32 %r2533, %r48; + max.f32 %r2534, %r2533, 0f00000000; + abs.f32 %r2535, %r113; + max.f32 %r2536, %r2535, 0f00000000; + abs.f32 %r2537, %r114; + max.f32 %r2538, %r2537, 0f00000000; + abs.f32 %r2539, %r115; + max.f32 %r2540, %r2539, 0f00000000; + abs.f32 %r2541, %r116; + max.f32 %r2542, %r2534, %r2541; + abs.f32 %r2543, %r117; + max.f32 %r2544, %r2536, %r2543; + abs.f32 %r2545, %r118; + max.f32 %r2546, %r2538, %r2545; + abs.f32 %r2547, %r119; + max.f32 %r2548, %r2540, %r2547; + abs.f32 %r2549, %r120; + max.f32 %r2550, %r2542, %r2549; + abs.f32 %r2551, %r121; + max.f32 %r2552, %r2544, %r2551; + abs.f32 %r2553, %r122; + max.f32 %r2554, %r2546, %r2553; + abs.f32 %r2555, %r123; + max.f32 %r2556, %r2548, %r2555; + abs.f32 %r2557, %r124; + max.f32 %r2558, %r2550, %r2557; + abs.f32 %r2559, %r125; + max.f32 %r2560, %r2552, %r2559; + abs.f32 %r2561, %r126; + max.f32 %r2562, %r2554, %r2561; + abs.f32 %r2563, %r127; + max.f32 %r2564, %r2556, %r2563; + abs.f32 %r2565, %r128; + max.f32 %r2566, %r2558, %r2565; + abs.f32 %r2567, %r129; + max.f32 %r2568, %r2560, %r2567; + abs.f32 %r2569, %r130; + max.f32 %r2570, %r2562, %r2569; + abs.f32 %r2571, %r131; + max.f32 %r2572, %r2564, %r2571; + abs.f32 %r2573, %r132; + max.f32 %r2574, %r2566, %r2573; + abs.f32 %r2575, %r133; + max.f32 %r2576, %r2568, %r2575; + abs.f32 %r2577, %r134; + max.f32 %r2578, %r2570, %r2577; + abs.f32 %r2579, %r135; + max.f32 %r2580, %r2572, %r2579; + abs.f32 %r2581, %r136; + max.f32 %r2582, %r2574, %r2581; + abs.f32 %r2583, %r137; + max.f32 %r2584, %r2576, %r2583; + abs.f32 %r2585, %r138; + max.f32 %r2586, %r2578, %r2585; + abs.f32 %r2587, %r139; + max.f32 %r2588, %r2580, %r2587; + abs.f32 %r2589, %r140; + max.f32 %r2590, %r2582, %r2589; + abs.f32 %r2591, %r141; + max.f32 %r2592, %r2584, %r2591; + abs.f32 %r2593, %r142; + max.f32 %r2594, %r2586, %r2593; + abs.f32 %r2595, %r143; + max.f32 %r2596, %r2588, %r2595; + max.f32 %r2597, %r2590, %r2592; + max.f32 %r2598, %r2594, %r2596; + max.f32 %r2599, %r2597, %r2598; + mov.b32 %r2600, -1; + redux.sync.max.u32 %r144, %r2599, %r2600; + and.b32 %r2601, %r144, 2147483647; + setp.eq.b32 %p215, %r2601, 0; + mov.b32 %r3370, 0; + @%p215 bra $L__BB0_175; + shr.s32 %r2602, %r144, 23; + sub.s32 %r2603, 141, %r2602; + max.s32 %r2604, %r2603, -40; + min.s32 %r2605, %r2604, 40; + shl.b32 %r3370, %r2605, 23; +$L__BB0_175: + ld.param.b64 %rd90, [leleka_gdn_tc_prep_param_3]; + setp.ne.b32 %p216, %r4, 0; + mul.wide.u32 %rd67, %r3, 48; + cvt.u64.u32 %rd68, %r12; + add.s64 %rd9, %rd67, %rd68; + shl.b64 %rd69, %rd9, 12; + cvta.to.global.u64 %rd70, %rd90; + add.s64 %rd71, %rd70, %rd69; + add.s32 %r2702, %r3370, 1065353216; + mul.f32 %r2606, %r48, %r2702; + // begin inline asm + { cvt.rn.f16.f32 %rs7, %r2606;} + + // end inline asm + mul.wide.u32 %rd72, %r4, 2; + add.s64 %rd73, %rd71, %rd72; + st.global.b16 [%rd73], %rs7; + // begin inline asm + { cvt.f32.f16 %r2607, %rs7;} + + // end inline asm + sub.f32 %r2608, %r2606, %r2607; + // begin inline asm + { cvt.rn.f16.f32 %rs8, %r2608;} + + // end inline asm + st.global.b16 [%rd73+2048], %rs8; + mul.f32 %r2609, %r113, %r2702; + // begin inline asm + { cvt.rn.f16.f32 %rs9, %r2609;} + + // end inline asm + st.global.b16 [%rd73+64], %rs9; + // begin inline asm + { cvt.f32.f16 %r2610, %rs9;} + + // end inline asm + sub.f32 %r2611, %r2609, %r2610; + // begin inline asm + { cvt.rn.f16.f32 %rs10, %r2611;} + + // end inline asm + st.global.b16 [%rd73+2112], %rs10; + mul.f32 %r2612, %r114, %r2702; + // begin inline asm + { cvt.rn.f16.f32 %rs11, %r2612;} + + // end inline asm + st.global.b16 [%rd73+128], %rs11; + // begin inline asm + { cvt.f32.f16 %r2613, %rs11;} + + // end inline asm + sub.f32 %r2614, %r2612, %r2613; + // begin inline asm + { cvt.rn.f16.f32 %rs12, %r2614;} + + // end inline asm + st.global.b16 [%rd73+2176], %rs12; + mul.f32 %r2615, %r115, %r2702; + // begin inline asm + { cvt.rn.f16.f32 %rs13, %r2615;} + + // end inline asm + st.global.b16 [%rd73+192], %rs13; + // begin inline asm + { cvt.f32.f16 %r2616, %rs13;} + + // end inline asm + sub.f32 %r2617, %r2615, %r2616; + // begin inline asm + { cvt.rn.f16.f32 %rs14, %r2617;} + + // end inline asm + st.global.b16 [%rd73+2240], %rs14; + mul.f32 %r2618, %r116, %r2702; + // begin inline asm + { cvt.rn.f16.f32 %rs15, %r2618;} + + // end inline asm + st.global.b16 [%rd73+256], %rs15; + // begin inline asm + { cvt.f32.f16 %r2619, %rs15;} + + // end inline asm + sub.f32 %r2620, %r2618, %r2619; + // begin inline asm + { cvt.rn.f16.f32 %rs16, %r2620;} + + // end inline asm + st.global.b16 [%rd73+2304], %rs16; + mul.f32 %r2621, %r117, %r2702; + // begin inline asm + { cvt.rn.f16.f32 %rs17, %r2621;} + + // end inline asm + st.global.b16 [%rd73+320], %rs17; + // begin inline asm + { cvt.f32.f16 %r2622, %rs17;} + + // end inline asm + sub.f32 %r2623, %r2621, %r2622; + // begin inline asm + { cvt.rn.f16.f32 %rs18, %r2623;} + + // end inline asm + st.global.b16 [%rd73+2368], %rs18; + mul.f32 %r2624, %r118, %r2702; + // begin inline asm + { cvt.rn.f16.f32 %rs19, %r2624;} + + // end inline asm + st.global.b16 [%rd73+384], %rs19; + // begin inline asm + { cvt.f32.f16 %r2625, %rs19;} + + // end inline asm + sub.f32 %r2626, %r2624, %r2625; + // begin inline asm + { cvt.rn.f16.f32 %rs20, %r2626;} + + // end inline asm + st.global.b16 [%rd73+2432], %rs20; + mul.f32 %r2627, %r119, %r2702; + // begin inline asm + { cvt.rn.f16.f32 %rs21, %r2627;} + + // end inline asm + st.global.b16 [%rd73+448], %rs21; + // begin inline asm + { cvt.f32.f16 %r2628, %rs21;} + + // end inline asm + sub.f32 %r2629, %r2627, %r2628; + // begin inline asm + { cvt.rn.f16.f32 %rs22, %r2629;} + + // end inline asm + st.global.b16 [%rd73+2496], %rs22; + mul.f32 %r2630, %r120, %r2702; + // begin inline asm + { cvt.rn.f16.f32 %rs23, %r2630;} + + // end inline asm + st.global.b16 [%rd73+512], %rs23; + // begin inline asm + { cvt.f32.f16 %r2631, %rs23;} + + // end inline asm + sub.f32 %r2632, %r2630, %r2631; + // begin inline asm + { cvt.rn.f16.f32 %rs24, %r2632;} + + // end inline asm + st.global.b16 [%rd73+2560], %rs24; + mul.f32 %r2633, %r121, %r2702; + // begin inline asm + { cvt.rn.f16.f32 %rs25, %r2633;} + + // end inline asm + st.global.b16 [%rd73+576], %rs25; + // begin inline asm + { cvt.f32.f16 %r2634, %rs25;} + + // end inline asm + sub.f32 %r2635, %r2633, %r2634; + // begin inline asm + { cvt.rn.f16.f32 %rs26, %r2635;} + + // end inline asm + st.global.b16 [%rd73+2624], %rs26; + mul.f32 %r2636, %r122, %r2702; + // begin inline asm + { cvt.rn.f16.f32 %rs27, %r2636;} + + // end inline asm + st.global.b16 [%rd73+640], %rs27; + // begin inline asm + { cvt.f32.f16 %r2637, %rs27;} + + // end inline asm + sub.f32 %r2638, %r2636, %r2637; + // begin inline asm + { cvt.rn.f16.f32 %rs28, %r2638;} + + // end inline asm + st.global.b16 [%rd73+2688], %rs28; + mul.f32 %r2639, %r123, %r2702; + // begin inline asm + { cvt.rn.f16.f32 %rs29, %r2639;} + + // end inline asm + st.global.b16 [%rd73+704], %rs29; + // begin inline asm + { cvt.f32.f16 %r2640, %rs29;} + + // end inline asm + sub.f32 %r2641, %r2639, %r2640; + // begin inline asm + { cvt.rn.f16.f32 %rs30, %r2641;} + + // end inline asm + st.global.b16 [%rd73+2752], %rs30; + mul.f32 %r2642, %r124, %r2702; + // begin inline asm + { cvt.rn.f16.f32 %rs31, %r2642;} + + // end inline asm + st.global.b16 [%rd73+768], %rs31; + // begin inline asm + { cvt.f32.f16 %r2643, %rs31;} + + // end inline asm + sub.f32 %r2644, %r2642, %r2643; + // begin inline asm + { cvt.rn.f16.f32 %rs32, %r2644;} + + // end inline asm + st.global.b16 [%rd73+2816], %rs32; + mul.f32 %r2645, %r125, %r2702; + // begin inline asm + { cvt.rn.f16.f32 %rs33, %r2645;} + + // end inline asm + st.global.b16 [%rd73+832], %rs33; + // begin inline asm + { cvt.f32.f16 %r2646, %rs33;} + + // end inline asm + sub.f32 %r2647, %r2645, %r2646; + // begin inline asm + { cvt.rn.f16.f32 %rs34, %r2647;} + + // end inline asm + st.global.b16 [%rd73+2880], %rs34; + mul.f32 %r2648, %r126, %r2702; + // begin inline asm + { cvt.rn.f16.f32 %rs35, %r2648;} + + // end inline asm + st.global.b16 [%rd73+896], %rs35; + // begin inline asm + { cvt.f32.f16 %r2649, %rs35;} + + // end inline asm + sub.f32 %r2650, %r2648, %r2649; + // begin inline asm + { cvt.rn.f16.f32 %rs36, %r2650;} + + // end inline asm + st.global.b16 [%rd73+2944], %rs36; + mul.f32 %r2651, %r127, %r2702; + // begin inline asm + { cvt.rn.f16.f32 %rs37, %r2651;} + + // end inline asm + st.global.b16 [%rd73+960], %rs37; + // begin inline asm + { cvt.f32.f16 %r2652, %rs37;} + + // end inline asm + sub.f32 %r2653, %r2651, %r2652; + // begin inline asm + { cvt.rn.f16.f32 %rs38, %r2653;} + + // end inline asm + st.global.b16 [%rd73+3008], %rs38; + mul.f32 %r2654, %r128, %r2702; + // begin inline asm + { cvt.rn.f16.f32 %rs39, %r2654;} + + // end inline asm + st.global.b16 [%rd73+1024], %rs39; + // begin inline asm + { cvt.f32.f16 %r2655, %rs39;} + + // end inline asm + sub.f32 %r2656, %r2654, %r2655; + // begin inline asm + { cvt.rn.f16.f32 %rs40, %r2656;} + + // end inline asm + st.global.b16 [%rd73+3072], %rs40; + mul.f32 %r2657, %r129, %r2702; + // begin inline asm + { cvt.rn.f16.f32 %rs41, %r2657;} + + // end inline asm + st.global.b16 [%rd73+1088], %rs41; + // begin inline asm + { cvt.f32.f16 %r2658, %rs41;} + + // end inline asm + sub.f32 %r2659, %r2657, %r2658; + // begin inline asm + { cvt.rn.f16.f32 %rs42, %r2659;} + + // end inline asm + st.global.b16 [%rd73+3136], %rs42; + mul.f32 %r2660, %r130, %r2702; + // begin inline asm + { cvt.rn.f16.f32 %rs43, %r2660;} + + // end inline asm + st.global.b16 [%rd73+1152], %rs43; + // begin inline asm + { cvt.f32.f16 %r2661, %rs43;} + + // end inline asm + sub.f32 %r2662, %r2660, %r2661; + // begin inline asm + { cvt.rn.f16.f32 %rs44, %r2662;} + + // end inline asm + st.global.b16 [%rd73+3200], %rs44; + mul.f32 %r2663, %r131, %r2702; + // begin inline asm + { cvt.rn.f16.f32 %rs45, %r2663;} + + // end inline asm + st.global.b16 [%rd73+1216], %rs45; + // begin inline asm + { cvt.f32.f16 %r2664, %rs45;} + + // end inline asm + sub.f32 %r2665, %r2663, %r2664; + // begin inline asm + { cvt.rn.f16.f32 %rs46, %r2665;} + + // end inline asm + st.global.b16 [%rd73+3264], %rs46; + mul.f32 %r2666, %r132, %r2702; + // begin inline asm + { cvt.rn.f16.f32 %rs47, %r2666;} + + // end inline asm + st.global.b16 [%rd73+1280], %rs47; + // begin inline asm + { cvt.f32.f16 %r2667, %rs47;} + + // end inline asm + sub.f32 %r2668, %r2666, %r2667; + // begin inline asm + { cvt.rn.f16.f32 %rs48, %r2668;} + + // end inline asm + st.global.b16 [%rd73+3328], %rs48; + mul.f32 %r2669, %r133, %r2702; + // begin inline asm + { cvt.rn.f16.f32 %rs49, %r2669;} + + // end inline asm + st.global.b16 [%rd73+1344], %rs49; + // begin inline asm + { cvt.f32.f16 %r2670, %rs49;} + + // end inline asm + sub.f32 %r2671, %r2669, %r2670; + // begin inline asm + { cvt.rn.f16.f32 %rs50, %r2671;} + + // end inline asm + st.global.b16 [%rd73+3392], %rs50; + mul.f32 %r2672, %r134, %r2702; + // begin inline asm + { cvt.rn.f16.f32 %rs51, %r2672;} + + // end inline asm + st.global.b16 [%rd73+1408], %rs51; + // begin inline asm + { cvt.f32.f16 %r2673, %rs51;} + + // end inline asm + sub.f32 %r2674, %r2672, %r2673; + // begin inline asm + { cvt.rn.f16.f32 %rs52, %r2674;} + + // end inline asm + st.global.b16 [%rd73+3456], %rs52; + mul.f32 %r2675, %r135, %r2702; + // begin inline asm + { cvt.rn.f16.f32 %rs53, %r2675;} + + // end inline asm + st.global.b16 [%rd73+1472], %rs53; + // begin inline asm + { cvt.f32.f16 %r2676, %rs53;} + + // end inline asm + sub.f32 %r2677, %r2675, %r2676; + // begin inline asm + { cvt.rn.f16.f32 %rs54, %r2677;} + + // end inline asm + st.global.b16 [%rd73+3520], %rs54; + mul.f32 %r2678, %r136, %r2702; + // begin inline asm + { cvt.rn.f16.f32 %rs55, %r2678;} + + // end inline asm + st.global.b16 [%rd73+1536], %rs55; + // begin inline asm + { cvt.f32.f16 %r2679, %rs55;} + + // end inline asm + sub.f32 %r2680, %r2678, %r2679; + // begin inline asm + { cvt.rn.f16.f32 %rs56, %r2680;} + + // end inline asm + st.global.b16 [%rd73+3584], %rs56; + mul.f32 %r2681, %r137, %r2702; + // begin inline asm + { cvt.rn.f16.f32 %rs57, %r2681;} + + // end inline asm + st.global.b16 [%rd73+1600], %rs57; + // begin inline asm + { cvt.f32.f16 %r2682, %rs57;} + + // end inline asm + sub.f32 %r2683, %r2681, %r2682; + // begin inline asm + { cvt.rn.f16.f32 %rs58, %r2683;} + + // end inline asm + st.global.b16 [%rd73+3648], %rs58; + mul.f32 %r2684, %r138, %r2702; + // begin inline asm + { cvt.rn.f16.f32 %rs59, %r2684;} + + // end inline asm + st.global.b16 [%rd73+1664], %rs59; + // begin inline asm + { cvt.f32.f16 %r2685, %rs59;} + + // end inline asm + sub.f32 %r2686, %r2684, %r2685; + // begin inline asm + { cvt.rn.f16.f32 %rs60, %r2686;} + + // end inline asm + st.global.b16 [%rd73+3712], %rs60; + mul.f32 %r2687, %r139, %r2702; + // begin inline asm + { cvt.rn.f16.f32 %rs61, %r2687;} + + // end inline asm + st.global.b16 [%rd73+1728], %rs61; + // begin inline asm + { cvt.f32.f16 %r2688, %rs61;} + + // end inline asm + sub.f32 %r2689, %r2687, %r2688; + // begin inline asm + { cvt.rn.f16.f32 %rs62, %r2689;} + + // end inline asm + st.global.b16 [%rd73+3776], %rs62; + mul.f32 %r2690, %r140, %r2702; + // begin inline asm + { cvt.rn.f16.f32 %rs63, %r2690;} + + // end inline asm + st.global.b16 [%rd73+1792], %rs63; + // begin inline asm + { cvt.f32.f16 %r2691, %rs63;} + + // end inline asm + sub.f32 %r2692, %r2690, %r2691; + // begin inline asm + { cvt.rn.f16.f32 %rs64, %r2692;} + + // end inline asm + st.global.b16 [%rd73+3840], %rs64; + mul.f32 %r2693, %r141, %r2702; + // begin inline asm + { cvt.rn.f16.f32 %rs65, %r2693;} + + // end inline asm + st.global.b16 [%rd73+1856], %rs65; + // begin inline asm + { cvt.f32.f16 %r2694, %rs65;} + + // end inline asm + sub.f32 %r2695, %r2693, %r2694; + // begin inline asm + { cvt.rn.f16.f32 %rs66, %r2695;} + + // end inline asm + st.global.b16 [%rd73+3904], %rs66; + mul.f32 %r2696, %r142, %r2702; + // begin inline asm + { cvt.rn.f16.f32 %rs67, %r2696;} + + // end inline asm + st.global.b16 [%rd73+1920], %rs67; + // begin inline asm + { cvt.f32.f16 %r2697, %rs67;} + + // end inline asm + sub.f32 %r2698, %r2696, %r2697; + // begin inline asm + { cvt.rn.f16.f32 %rs68, %r2698;} + + // end inline asm + st.global.b16 [%rd73+3968], %rs68; + mul.f32 %r2699, %r143, %r2702; + // begin inline asm + { cvt.rn.f16.f32 %rs69, %r2699;} + + // end inline asm + st.global.b16 [%rd73+1984], %rs69; + // begin inline asm + { cvt.f32.f16 %r2700, %rs69;} + + // end inline asm + sub.f32 %r2701, %r2699, %r2700; + // begin inline asm + { cvt.rn.f16.f32 %rs70, %r2701;} + + // end inline asm + st.global.b16 [%rd73+4032], %rs70; + @%p216 bra $L__BB0_177; + ld.param.b64 %rd91, [leleka_gdn_tc_prep_param_4]; + sub.s32 %r2703, 1065353216, %r3370; + cvta.to.global.u64 %rd74, %rd91; + shl.b64 %rd75, %rd9, 2; + add.s64 %rd76, %rd74, %rd75; + st.global.b32 [%rd76], %r2703; +$L__BB0_177: + ret; + +} + // .globl leleka_gdn_tc_scan_t1 +.visible .entry leleka_gdn_tc_scan_t1( + .param .u64 .ptr .align 1 leleka_gdn_tc_scan_t1_param_0, + .param .u64 .ptr .align 1 leleka_gdn_tc_scan_t1_param_1, + .param .u64 .ptr .align 1 leleka_gdn_tc_scan_t1_param_2, + .param .u64 .ptr .align 1 leleka_gdn_tc_scan_t1_param_3, + .param .u64 .ptr .align 1 leleka_gdn_tc_scan_t1_param_4, + .param .u64 .ptr .align 1 leleka_gdn_tc_scan_t1_param_5, + .param .u64 .ptr .align 1 leleka_gdn_tc_scan_t1_param_6, + .param .u64 .ptr .align 1 leleka_gdn_tc_scan_t1_param_7, + .param .u64 .ptr .align 1 leleka_gdn_tc_scan_t1_param_8, + .param .u64 leleka_gdn_tc_scan_t1_param_9, + .param .u32 leleka_gdn_tc_scan_t1_param_10, + .param .u64 leleka_gdn_tc_scan_t1_param_11, + .param .u64 .ptr .align 1 leleka_gdn_tc_scan_t1_param_12 +) +.maxntid 256 +.minnctapersm 1 +{ + .reg .pred %p<168>; + .reg .b32 %r<1989>; + .reg .b64 %rd<168>; + + ld.param.b64 %rd38, [leleka_gdn_tc_scan_t1_param_0]; + ld.param.b64 %rd26, [leleka_gdn_tc_scan_t1_param_1]; + ld.param.b64 %rd27, [leleka_gdn_tc_scan_t1_param_2]; + ld.param.b64 %rd28, [leleka_gdn_tc_scan_t1_param_3]; + ld.param.b64 %rd29, [leleka_gdn_tc_scan_t1_param_4]; + ld.param.b64 %rd30, [leleka_gdn_tc_scan_t1_param_5]; + ld.param.b64 %rd31, [leleka_gdn_tc_scan_t1_param_6]; + ld.param.b64 %rd32, [leleka_gdn_tc_scan_t1_param_7]; + ld.param.b64 %rd33, [leleka_gdn_tc_scan_t1_param_8]; + ld.param.b64 %rd34, [leleka_gdn_tc_scan_t1_param_9]; + ld.param.b32 %r113, [leleka_gdn_tc_scan_t1_param_10]; + ld.param.b64 %rd35, [leleka_gdn_tc_scan_t1_param_11]; + ld.param.b64 %rd36, [leleka_gdn_tc_scan_t1_param_12]; + cvta.to.global.u64 %rd39, %rd38; + mov.u32 %r115, %ctaid.x; + mov.u32 %r1, %tid.x; + shr.u32 %r2, %r1, 2; + and.b32 %r3, %r2, 7; + and.b32 %r4, %r1, 3; + shr.u32 %r5, %r1, 1; + and.b32 %r6, %r5, 496; + cvt.u64.u32 %rd1, %r115; + mul.wide.u32 %rd2, %r115, 512; + add.s64 %rd40, %rd39, %rd2; + or.b32 %r116, %r6, %r3; + mul.lo.s32 %r117, %r4, 12288; + or.b32 %r7, %r116, %r117; + mul.wide.u32 %rd41, %r7, 4; + add.s64 %rd42, %rd40, %rd41; + ld.global.b32 %r1921, [%rd42]; + ld.global.b32 %r1922, [%rd42+24576]; + ld.global.b32 %r1923, [%rd42+32]; + ld.global.b32 %r1924, [%rd42+24608]; + ld.global.b32 %r1925, [%rd42+196608]; + ld.global.b32 %r1926, [%rd42+221184]; + ld.global.b32 %r1927, [%rd42+196640]; + ld.global.b32 %r1928, [%rd42+221216]; + ld.global.b32 %r1929, [%rd42+393216]; + ld.global.b32 %r1930, [%rd42+417792]; + ld.global.b32 %r1931, [%rd42+393248]; + ld.global.b32 %r1932, [%rd42+417824]; + ld.global.b32 %r1933, [%rd42+589824]; + ld.global.b32 %r1934, [%rd42+614400]; + ld.global.b32 %r1935, [%rd42+589856]; + ld.global.b32 %r1936, [%rd42+614432]; + ld.global.b32 %r1937, [%rd42+786432]; + ld.global.b32 %r1938, [%rd42+811008]; + ld.global.b32 %r1939, [%rd42+786464]; + ld.global.b32 %r1940, [%rd42+811040]; + ld.global.b32 %r1941, [%rd42+983040]; + ld.global.b32 %r1942, [%rd42+1007616]; + ld.global.b32 %r1943, [%rd42+983072]; + ld.global.b32 %r1944, [%rd42+1007648]; + ld.global.b32 %r1945, [%rd42+1179648]; + ld.global.b32 %r1946, [%rd42+1204224]; + ld.global.b32 %r1947, [%rd42+1179680]; + ld.global.b32 %r1948, [%rd42+1204256]; + ld.global.b32 %r1949, [%rd42+1376256]; + ld.global.b32 %r1950, [%rd42+1400832]; + ld.global.b32 %r1951, [%rd42+1376288]; + ld.global.b32 %r1952, [%rd42+1400864]; + ld.global.b32 %r1953, [%rd42+1572864]; + ld.global.b32 %r1954, [%rd42+1597440]; + ld.global.b32 %r1955, [%rd42+1572896]; + ld.global.b32 %r1956, [%rd42+1597472]; + ld.global.b32 %r1957, [%rd42+1769472]; + ld.global.b32 %r1958, [%rd42+1794048]; + ld.global.b32 %r1959, [%rd42+1769504]; + ld.global.b32 %r1960, [%rd42+1794080]; + ld.global.b32 %r1961, [%rd42+1966080]; + ld.global.b32 %r1962, [%rd42+1990656]; + ld.global.b32 %r1963, [%rd42+1966112]; + ld.global.b32 %r1964, [%rd42+1990688]; + ld.global.b32 %r1965, [%rd42+2162688]; + ld.global.b32 %r1966, [%rd42+2187264]; + ld.global.b32 %r1967, [%rd42+2162720]; + ld.global.b32 %r1968, [%rd42+2187296]; + ld.global.b32 %r1969, [%rd42+2359296]; + ld.global.b32 %r1970, [%rd42+2383872]; + ld.global.b32 %r1971, [%rd42+2359328]; + ld.global.b32 %r1972, [%rd42+2383904]; + ld.global.b32 %r1973, [%rd42+2555904]; + ld.global.b32 %r1974, [%rd42+2580480]; + ld.global.b32 %r1975, [%rd42+2555936]; + ld.global.b32 %r1976, [%rd42+2580512]; + ld.global.b32 %r1977, [%rd42+2752512]; + ld.global.b32 %r1978, [%rd42+2777088]; + ld.global.b32 %r1979, [%rd42+2752544]; + ld.global.b32 %r1980, [%rd42+2777120]; + ld.global.b32 %r1981, [%rd42+2949120]; + ld.global.b32 %r1982, [%rd42+2973696]; + ld.global.b32 %r1983, [%rd42+2949152]; + ld.global.b32 %r1984, [%rd42+2973728]; + sub.s64 %rd43, %rd35, %rd34; + min.s64 %rd44, %rd43, 32; + cvt.u32.u64 %r8, %rd44; + shl.b32 %r118, %r115, 14; + shl.b32 %r9, %r1, 3; + or.b32 %r119, %r9, %r118; + and.b32 %r10, %r9, 120; + and.b32 %r11, %r119, 245880; + shr.u32 %r120, %r1, 9; + shr.u32 %r12, %r1, 4; + and.b32 %r13, %r12, 31; + setp.eq.b32 %p1, %r120, 0; + mov.b32 %r1919, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r121, %r1919, 17408; + selp.b32 %r14, %r1919, %r121, %p1; + mad.lo.s32 %r15, %r13, 136, %r10; + shl.b32 %r16, %r120, 12; + and.b32 %r17, %r9, 3968; + or.b32 %r122, %r11, %r16; + or.b32 %r123, %r122, %r17; + mul.wide.u32 %rd45, %r123, 2; + add.s64 %rd37, %rd31, %rd45; + shl.b32 %r124, %r15, 1; + add.s32 %r114, %r14, %r124; + // begin inline asm + cp.async.cg.shared.global [%r114], [%rd37], 16; + + // end inline asm + add.s32 %r18, %r1, 256; + shr.u32 %r19, %r18, 9; + shr.u32 %r125, %r18, 4; + and.b32 %r20, %r125, 31; + setp.eq.b32 %p2, %r19, 0; + @%p2 bra $L__BB1_4; + setp.eq.b32 %p3, %r19, 1; + @%p3 bra $L__BB1_3; + mov.b32 %r126, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r1919, %r126, 34816; + bra.uni $L__BB1_4; +$L__BB1_3: + mov.b32 %r127, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r1919, %r127, 17408; +$L__BB1_4: + mad.lo.s32 %r130, %r20, 136, %r10; + shl.b32 %r21, %r19, 12; + shl.b32 %r22, %r20, 7; + add.s32 %r131, %r11, %r21; + add.s32 %r132, %r131, %r22; + mul.wide.u32 %rd48, %r132, 2; + add.s64 %rd46, %rd31, %rd48; + shl.b32 %r133, %r130, 1; + add.s32 %r128, %r1919, %r133; + // begin inline asm + cp.async.cg.shared.global [%r128], [%rd46], 16; + + // end inline asm + add.s32 %r23, %r1, 512; + shr.u32 %r134, %r23, 9; + setp.eq.b32 %p4, %r134, 2; + mov.b32 %r135, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r136, %r135, 17408; + add.s32 %r1920, %r135, 34816; + selp.b32 %r24, %r1920, %r136, %p4; + shl.b32 %r25, %r134, 12; + add.s32 %r137, %r11, %r25; + add.s32 %r138, %r137, %r17; + mul.wide.u32 %rd49, %r138, 2; + add.s64 %rd47, %rd31, %rd49; + add.s32 %r129, %r24, %r124; + // begin inline asm + cp.async.cg.shared.global [%r129], [%rd47], 16; + + // end inline asm + add.s32 %r26, %r1, 768; + shr.u32 %r27, %r26, 9; + shr.u32 %r139, %r26, 4; + and.b32 %r28, %r139, 31; + setp.eq.b32 %p5, %r27, 3; + @%p5 bra $L__BB1_7; + setp.eq.b32 %p6, %r27, 2; + @%p6 bra $L__BB1_8; + mov.b32 %r140, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r1920, %r140, 17408; + bra.uni $L__BB1_8; +$L__BB1_7: + mov.b32 %r141, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r1920, %r141, 52224; +$L__BB1_8: + mad.lo.s32 %r147, %r28, 136, %r10; + shl.b32 %r29, %r27, 12; + shl.b32 %r30, %r28, 7; + add.s32 %r148, %r11, %r29; + add.s32 %r149, %r148, %r30; + mul.wide.u32 %rd55, %r149, 2; + add.s64 %rd50, %rd31, %rd55; + shl.b32 %r150, %r147, 1; + add.s32 %r142, %r1920, %r150; + // begin inline asm + cp.async.cg.shared.global [%r142], [%rd50], 16; + + // end inline asm + or.b32 %r151, %r1, 1024; + shr.u32 %r152, %r151, 9; + setp.eq.b32 %p7, %r152, 2; + mov.b32 %r153, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r154, %r153, 52224; + add.s32 %r155, %r153, 34816; + selp.b32 %r31, %r155, %r154, %p7; + shl.b32 %r32, %r152, 12; + add.s32 %r156, %r11, %r32; + add.s32 %r157, %r156, %r17; + mul.wide.u32 %rd56, %r157, 2; + add.s64 %rd51, %rd31, %rd56; + add.s32 %r143, %r31, %r124; + // begin inline asm + cp.async.cg.shared.global [%r143], [%rd51], 16; + + // end inline asm + add.s32 %r158, %r1, 1280; + shr.u32 %r159, %r158, 9; + shr.u32 %r160, %r158, 4; + and.b32 %r33, %r160, 31; + setp.eq.b32 %p8, %r159, 2; + selp.b32 %r34, %r155, %r154, %p8; + mad.lo.s32 %r161, %r33, 136, %r10; + shl.b32 %r35, %r159, 12; + shl.b32 %r162, %r158, 3; + and.b32 %r36, %r162, 3968; + add.s32 %r163, %r11, %r35; + add.s32 %r164, %r163, %r36; + mul.wide.u32 %rd57, %r164, 2; + add.s64 %rd52, %rd31, %rd57; + shl.b32 %r165, %r161, 1; + add.s32 %r144, %r34, %r165; + // begin inline asm + cp.async.cg.shared.global [%r144], [%rd52], 16; + + // end inline asm + add.s32 %r166, %r9, 12288; + and.b32 %r37, %r166, 28672; + add.s32 %r167, %r11, %r37; + add.s32 %r168, %r167, %r17; + mul.wide.u32 %rd58, %r168, 2; + add.s64 %rd53, %rd31, %rd58; + add.s32 %r145, %r154, %r124; + // begin inline asm + cp.async.cg.shared.global [%r145], [%rd53], 16; + + // end inline asm + add.s32 %r169, %r1, 1792; + shr.u32 %r170, %r169, 4; + and.b32 %r38, %r170, 31; + mad.lo.s32 %r171, %r38, 136, %r10; + shl.b32 %r172, %r169, 3; + and.b32 %r39, %r172, 28672; + and.b32 %r40, %r172, 3968; + add.s32 %r173, %r11, %r39; + add.s32 %r174, %r173, %r40; + mul.wide.u32 %rd59, %r174, 2; + add.s64 %rd54, %rd31, %rd59; + shl.b32 %r175, %r171, 1; + add.s32 %r146, %r154, %r175; + // begin inline asm + cp.async.cg.shared.global [%r146], [%rd54], 16; + + // end inline asm + setp.gt.u32 %p9, %r1, 31; + @%p9 bra $L__BB1_10; + add.s64 %rd61, %rd30, %rd2; + mul.wide.u32 %rd62, %r1, 16; + add.s64 %rd60, %rd61, %rd62; + shl.b32 %r177, %r1, 4; + mov.b32 %r178, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r179, %r178, %r177; + add.s32 %r176, %r179, 96768; + // begin inline asm + cp.async.cg.shared.global [%r176], [%rd60], 16; + + // end inline asm +$L__BB1_10: + setp.ne.b32 %p10, %r1, 0; + shl.b64 %rd63, %rd1, 2; + add.s64 %rd3, %rd29, %rd63; + @%p10 bra $L__BB1_12; + mov.b32 %r181, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r180, %r181, 97792; + // begin inline asm + cp.async.ca.shared.global [%r180], [%rd3], 4; + + // end inline asm +$L__BB1_12: + cvt.u32.u64 %r182, %rd1; + shl.b32 %r183, %r1, 2; + and.b32 %r41, %r183, 124; + shl.b32 %r184, %r182, 7; + or.b32 %r185, %r184, %r41; + mul.wide.u32 %rd64, %r185, 4; + add.s64 %rd4, %rd27, %rd64; + shr.u32 %r42, %r1, 5; + mad.lo.s32 %r186, %r42, 132, %r41; + setp.ge.s32 %p11, %r42, %r8; + shl.b32 %r187, %r186, 2; + mov.b32 %r188, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r43, %r188, %r187; + @%p11 bra $L__BB1_14; + cvt.u64.u32 %rd67, %r42; + add.s64 %rd68, %rd34, %rd67; + mad.lo.s64 %rd69, %rd68, 40960, %rd4; + add.s64 %rd66, %rd69, 16384; + add.s32 %r190, %r43, 69632; + // begin inline asm + cp.async.cg.shared.global [%r190], [%rd66], 16; + + // end inline asm + bra.uni $L__BB1_15; +$L__BB1_14: + mov.b32 %r189, 0f00000000; + mov.b64 %rd65, {%r189, %r189}; + st.shared.v2.b64 [%r43+69632], {%rd65, %rd65}; +$L__BB1_15: + shr.u32 %r44, %r18, 5; + mad.lo.s32 %r191, %r44, 132, %r41; + setp.lt.s32 %p12, %r44, %r8; + shl.b32 %r192, %r191, 2; + mov.b32 %r193, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r45, %r193, %r192; + @%p12 bra $L__BB1_17; + mov.b32 %r194, 0f00000000; + mov.b64 %rd70, {%r194, %r194}; + st.shared.v2.b64 [%r45+69632], {%rd70, %rd70}; + bra.uni $L__BB1_18; +$L__BB1_17: + cvt.u64.u32 %rd72, %r44; + add.s64 %rd73, %rd34, %rd72; + mad.lo.s64 %rd74, %rd73, 40960, %rd4; + add.s64 %rd71, %rd74, 16384; + add.s32 %r195, %r45, 69632; + // begin inline asm + cp.async.cg.shared.global [%r195], [%rd71], 16; + + // end inline asm +$L__BB1_18: + shr.u32 %r46, %r23, 5; + mad.lo.s32 %r196, %r46, 132, %r41; + setp.lt.s32 %p13, %r46, %r8; + shl.b32 %r197, %r196, 2; + mov.b32 %r198, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r47, %r198, %r197; + @%p13 bra $L__BB1_20; + mov.b32 %r199, 0f00000000; + mov.b64 %rd75, {%r199, %r199}; + st.shared.v2.b64 [%r47+69632], {%rd75, %rd75}; + bra.uni $L__BB1_21; +$L__BB1_20: + cvt.u64.u32 %rd77, %r46; + add.s64 %rd78, %rd34, %rd77; + mad.lo.s64 %rd79, %rd78, 40960, %rd4; + add.s64 %rd76, %rd79, 16384; + add.s32 %r200, %r47, 69632; + // begin inline asm + cp.async.cg.shared.global [%r200], [%rd76], 16; + + // end inline asm +$L__BB1_21: + shr.u32 %r48, %r26, 5; + mad.lo.s32 %r201, %r48, 132, %r41; + setp.lt.s32 %p14, %r48, %r8; + shl.b32 %r202, %r201, 2; + mov.b32 %r203, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r49, %r203, %r202; + @%p14 bra $L__BB1_23; + mov.b32 %r204, 0f00000000; + mov.b64 %rd80, {%r204, %r204}; + st.shared.v2.b64 [%r49+69632], {%rd80, %rd80}; + bra.uni $L__BB1_24; +$L__BB1_23: + cvt.u64.u32 %rd82, %r48; + add.s64 %rd83, %rd34, %rd82; + mad.lo.s64 %rd84, %rd83, 40960, %rd4; + add.s64 %rd81, %rd84, 16384; + add.s32 %r205, %r49, 69632; + // begin inline asm + cp.async.cg.shared.global [%r205], [%rd81], 16; + + // end inline asm +$L__BB1_24: + and.b32 %r50, %r2, 31; + and.b32 %r51, %r9, 24; + shl.b64 %rd87, %rd1, 6; + and.b32 %r52, %r2, 224; + cvt.u64.u32 %rd88, %r52; + add.s64 %rd89, %rd87, %rd88; + cvt.u64.u32 %rd90, %r50; + or.b64 %rd91, %rd89, %rd90; + mad.lo.s32 %r206, %r50, 40, %r51; + setp.lt.u32 %p15, %r1, 128; + shl.b64 %rd92, %rd91, 6; + shl.b32 %r207, %r9, 1; + cvt.u64.u32 %rd93, %r207; + and.b64 %rd94, %rd93, 48; + or.b64 %rd95, %rd92, %rd94; + add.s64 %rd85, %rd28, %rd95; + mov.b32 %r208, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r209, %r208, 89088; + add.s32 %r210, %r208, 86528; + selp.b32 %r211, %r210, %r209, %p15; + shl.b32 %r212, %r206, 1; + add.s32 %r1505, %r211, %r212; + // begin inline asm + cp.async.cg.shared.global [%r1505], [%rd85], 16; + + // end inline asm + add.s64 %rd86, %rd32, %rd95; + add.s32 %r213, %r208, 94208; + add.s32 %r214, %r208, 91648; + selp.b32 %r215, %r214, %r213, %p15; + add.s32 %r1506, %r215, %r212; + // begin inline asm + cp.async.cg.shared.global [%r1506], [%rd86], 16; + + // end inline asm + // begin inline asm + cp.async.commit_group; + + // end inline asm + mov.b32 %r216, 0f43000000; + rsqrt.approx.f32 %r53, %r216; + setp.lt.s32 %p16, %r113, 1; + @%p16 bra $L__BB1_89; + cvt.u64.u32 %rd5, %r11; + mul.wide.u32 %rd96, %r1, 16; + add.s64 %rd6, %rd30, %rd96; + and.b32 %r217, %r5, 8; + and.b32 %r218, %r1, 7; + or.b32 %r219, %r217, %r218; + and.b32 %r220, %r1, 8; + mad.lo.s32 %r54, %r219, 136, %r220; + shl.b32 %r221, %r4, 1; + mad.lo.s32 %r222, %r219, -96, %r54; + shl.b64 %rd97, %rd1, 7; + cvt.u64.u32 %rd98, %r6; + cvt.u64.u32 %rd99, %r3; + add.s64 %rd100, %rd97, %rd98; + add.s64 %rd7, %rd100, %rd99; + add.s32 %r223, %r50, %r52; + shl.b32 %r224, %r223, 5; + or.b32 %r225, %r224, %r51; + cvt.u64.u32 %rd8, %r225; + or.b32 %r226, %r220, %r218; + shl.b32 %r227, %r12, 3; + and.b32 %r228, %r227, 8; + mad.lo.s32 %r55, %r226, 136, %r228; + add.s32 %r229, %r16, %r17; + cvt.u64.u32 %rd9, %r229; + add.s32 %r230, %r21, %r22; + cvt.u64.u32 %rd10, %r230; + add.s32 %r231, %r25, %r17; + cvt.u64.u32 %rd11, %r231; + add.s32 %r232, %r29, %r30; + cvt.u64.u32 %rd12, %r232; + add.s32 %r233, %r32, %r17; + cvt.u64.u32 %rd13, %r233; + add.s32 %r234, %r35, %r36; + cvt.u64.u32 %rd14, %r234; + add.s32 %r235, %r37, %r17; + cvt.u64.u32 %rd15, %r235; + add.s32 %r236, %r39, %r40; + cvt.u64.u32 %rd16, %r236; + mad.lo.s32 %r237, %r4, -12024, %r7; + shl.b32 %r238, %r237, 2; + mov.b32 %r239, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r56, %r239, %r238; + or.b32 %r57, %r221, 8; + or.b32 %r58, %r221, 16; + or.b32 %r59, %r221, 24; + shl.b32 %r240, %r222, 1; + add.s32 %r241, %r239, %r240; + add.s32 %r1183, %r241, 86528; + add.s32 %r1184, %r241, 89088; + add.s32 %r1205, %r241, 87808; + add.s32 %r1206, %r241, 90368; + add.s32 %r1251, %r241, 87840; + add.s32 %r1252, %r241, 90400; + add.s32 %r1325, %r241, 91648; + add.s32 %r1326, %r241, 94208; + add.s32 %r1347, %r241, 92928; + add.s32 %r1348, %r241, 95488; + add.s32 %r1393, %r241, 92960; + add.s32 %r1394, %r241, 95520; + cvt.u64.u32 %rd17, %r221; + or.b32 %r60, %r221, 1; + or.b32 %r61, %r221, 9; + or.b32 %r62, %r221, 17; + or.b32 %r63, %r221, 25; + add.s32 %r64, %r43, 69632; + add.s32 %r65, %r45, 69632; + cvt.u64.u32 %rd18, %r44; + add.s32 %r66, %r47, 69632; + cvt.u64.u32 %rd19, %r46; + add.s32 %r67, %r49, 69632; + cvt.u64.u32 %rd20, %r48; + cvta.to.global.u64 %rd21, %rd33; + mov.b32 %r1985, 0; +$L__BB1_26: + and.b32 %r68, %r1985, 1; + mul.wide.u32 %rd101, %r1985, 32; + add.s64 %rd22, %rd101, %rd34; + sub.s64 %rd102, %rd35, %rd22; + min.s64 %rd103, %rd102, 32; + cvt.u32.u64 %r69, %rd103; + // begin inline asm + cp.async.wait_all; + + // end inline asm + bar.sync 0; + add.s32 %r1985, %r1985, 1; + setp.ge.s32 %p17, %r1985, %r113; + @%p17 bra $L__BB1_40; + xor.b32 %r70, %r68, 1; + mul.wide.u32 %rd105, %r1985, 262144; + shl.b32 %r243, %r68, 5; + xor.b32 %r71, %r243, 32; + or.b64 %rd23, %rd105, %rd5; + or.b32 %r244, %r71, %r13; + mad.lo.s32 %r72, %r244, 136, %r10; + add.s64 %rd106, %rd23, %rd9; + shl.b64 %rd107, %rd106, 1; + add.s64 %rd104, %rd31, %rd107; + shl.b32 %r245, %r72, 1; + add.s32 %r242, %r14, %r245; + // begin inline asm + cp.async.cg.shared.global [%r242], [%rd104], 16; + + // end inline asm + mov.b32 %r1986, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + setp.eq.b32 %p18, %r19, 0; + @%p18 bra $L__BB1_31; + setp.eq.b32 %p19, %r19, 1; + @%p19 bra $L__BB1_30; + mov.b32 %r246, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r1986, %r246, 34816; + bra.uni $L__BB1_31; +$L__BB1_30: + mov.b32 %r247, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r1986, %r247, 17408; +$L__BB1_31: + add.s32 %r250, %r71, %r20; + mad.lo.s32 %r251, %r250, 136, %r10; + add.s64 %rd110, %rd23, %rd10; + shl.b64 %rd111, %rd110, 1; + add.s64 %rd108, %rd31, %rd111; + shl.b32 %r252, %r251, 1; + add.s32 %r248, %r1986, %r252; + // begin inline asm + cp.async.cg.shared.global [%r248], [%rd108], 16; + + // end inline asm + add.s64 %rd112, %rd23, %rd11; + shl.b64 %rd113, %rd112, 1; + add.s64 %rd109, %rd31, %rd113; + add.s32 %r249, %r24, %r245; + // begin inline asm + cp.async.cg.shared.global [%r249], [%rd109], 16; + + // end inline asm + mov.b32 %r253, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r1987, %r253, 34816; + setp.eq.b32 %p20, %r27, 3; + @%p20 bra $L__BB1_34; + setp.eq.b32 %p21, %r27, 2; + @%p21 bra $L__BB1_35; + mov.b32 %r254, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r1987, %r254, 17408; + bra.uni $L__BB1_35; +$L__BB1_34: + mov.b32 %r255, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r1987, %r255, 52224; +$L__BB1_35: + setp.gt.u32 %p22, %r1, 31; + add.s32 %r261, %r71, %r28; + mad.lo.s32 %r262, %r261, 136, %r10; + add.s64 %rd119, %rd23, %rd12; + shl.b64 %rd120, %rd119, 1; + add.s64 %rd114, %rd31, %rd120; + shl.b32 %r263, %r262, 1; + add.s32 %r256, %r1987, %r263; + // begin inline asm + cp.async.cg.shared.global [%r256], [%rd114], 16; + + // end inline asm + add.s64 %rd121, %rd23, %rd13; + shl.b64 %rd122, %rd121, 1; + add.s64 %rd115, %rd31, %rd122; + add.s32 %r257, %r31, %r245; + // begin inline asm + cp.async.cg.shared.global [%r257], [%rd115], 16; + + // end inline asm + add.s32 %r264, %r71, %r33; + mad.lo.s32 %r265, %r264, 136, %r10; + add.s64 %rd123, %rd23, %rd14; + shl.b64 %rd124, %rd123, 1; + add.s64 %rd116, %rd31, %rd124; + shl.b32 %r266, %r265, 1; + add.s32 %r258, %r34, %r266; + // begin inline asm + cp.async.cg.shared.global [%r258], [%rd116], 16; + + // end inline asm + add.s64 %rd125, %rd23, %rd15; + shl.b64 %rd126, %rd125, 1; + add.s64 %rd117, %rd31, %rd126; + mov.b32 %r267, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r268, %r267, %r245; + add.s32 %r259, %r268, 52224; + // begin inline asm + cp.async.cg.shared.global [%r259], [%rd117], 16; + + // end inline asm + add.s32 %r269, %r71, %r38; + mad.lo.s32 %r270, %r269, 136, %r10; + add.s64 %rd127, %rd23, %rd16; + shl.b64 %rd128, %rd127, 1; + add.s64 %rd118, %rd31, %rd128; + shl.b32 %r271, %r270, 1; + add.s32 %r272, %r267, %r271; + add.s32 %r260, %r272, 52224; + // begin inline asm + cp.async.cg.shared.global [%r260], [%rd118], 16; + + // end inline asm + @%p22 bra $L__BB1_37; + add.s32 %r274, %r71, %r1; + mul.wide.u32 %rd130, %r1985, 48; + add.s64 %rd131, %rd130, %rd1; + shl.b64 %rd132, %rd131, 9; + add.s64 %rd129, %rd6, %rd132; + shl.b32 %r275, %r274, 4; + mov.b32 %r276, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r277, %r276, %r275; + add.s32 %r273, %r277, 96768; + // begin inline asm + cp.async.cg.shared.global [%r273], [%rd129], 16; + + // end inline asm +$L__BB1_37: + setp.ne.b32 %p23, %r1, 0; + @%p23 bra $L__BB1_39; + mul.wide.u32 %rd134, %r1985, 192; + add.s64 %rd133, %rd3, %rd134; + shl.b32 %r279, %r70, 2; + mov.b32 %r280, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r281, %r280, %r279; + add.s32 %r278, %r281, 97792; + // begin inline asm + cp.async.ca.shared.global [%r278], [%rd133], 4; + + // end inline asm +$L__BB1_39: + // begin inline asm + cp.async.commit_group; + + // end inline asm +$L__BB1_40: + cvt.u32.u64 %r922, %rd17; + mul.lo.s32 %r73, %r68, 4352; + shl.b32 %r74, %r68, 5; + abs.f32 %r923, %r1921; + max.f32 %r924, %r923, 0f00000000; + abs.f32 %r925, %r1922; + max.f32 %r926, %r924, %r925; + abs.f32 %r927, %r1923; + max.f32 %r928, %r927, 0f00000000; + abs.f32 %r929, %r1924; + max.f32 %r930, %r928, %r929; + abs.f32 %r931, %r1925; + max.f32 %r932, %r931, 0f00000000; + abs.f32 %r933, %r1926; + max.f32 %r934, %r932, %r933; + abs.f32 %r935, %r1927; + max.f32 %r936, %r935, 0f00000000; + abs.f32 %r937, %r1928; + max.f32 %r938, %r936, %r937; + abs.f32 %r939, %r1929; + max.f32 %r940, %r939, 0f00000000; + abs.f32 %r941, %r1930; + max.f32 %r942, %r940, %r941; + abs.f32 %r943, %r1931; + max.f32 %r944, %r943, 0f00000000; + abs.f32 %r945, %r1932; + max.f32 %r946, %r944, %r945; + abs.f32 %r947, %r1933; + max.f32 %r948, %r947, 0f00000000; + abs.f32 %r949, %r1934; + max.f32 %r950, %r948, %r949; + abs.f32 %r951, %r1935; + max.f32 %r952, %r951, 0f00000000; + abs.f32 %r953, %r1936; + max.f32 %r954, %r952, %r953; + abs.f32 %r955, %r1937; + max.f32 %r956, %r926, %r955; + abs.f32 %r957, %r1938; + max.f32 %r958, %r956, %r957; + abs.f32 %r959, %r1939; + max.f32 %r960, %r930, %r959; + abs.f32 %r961, %r1940; + max.f32 %r962, %r960, %r961; + abs.f32 %r963, %r1941; + max.f32 %r964, %r934, %r963; + abs.f32 %r965, %r1942; + max.f32 %r966, %r964, %r965; + abs.f32 %r967, %r1943; + max.f32 %r968, %r938, %r967; + abs.f32 %r969, %r1944; + max.f32 %r970, %r968, %r969; + abs.f32 %r971, %r1945; + max.f32 %r972, %r942, %r971; + abs.f32 %r973, %r1946; + max.f32 %r974, %r972, %r973; + abs.f32 %r975, %r1947; + max.f32 %r976, %r946, %r975; + abs.f32 %r977, %r1948; + max.f32 %r978, %r976, %r977; + abs.f32 %r979, %r1949; + max.f32 %r980, %r950, %r979; + abs.f32 %r981, %r1950; + max.f32 %r982, %r980, %r981; + abs.f32 %r983, %r1951; + max.f32 %r984, %r954, %r983; + abs.f32 %r985, %r1952; + max.f32 %r986, %r984, %r985; + abs.f32 %r987, %r1953; + max.f32 %r988, %r958, %r987; + abs.f32 %r989, %r1954; + max.f32 %r990, %r988, %r989; + abs.f32 %r991, %r1955; + max.f32 %r992, %r962, %r991; + abs.f32 %r993, %r1956; + max.f32 %r994, %r992, %r993; + abs.f32 %r995, %r1957; + max.f32 %r996, %r966, %r995; + abs.f32 %r997, %r1958; + max.f32 %r998, %r996, %r997; + abs.f32 %r999, %r1959; + max.f32 %r1000, %r970, %r999; + abs.f32 %r1001, %r1960; + max.f32 %r1002, %r1000, %r1001; + abs.f32 %r1003, %r1961; + max.f32 %r1004, %r974, %r1003; + abs.f32 %r1005, %r1962; + max.f32 %r1006, %r1004, %r1005; + abs.f32 %r1007, %r1963; + max.f32 %r1008, %r978, %r1007; + abs.f32 %r1009, %r1964; + max.f32 %r1010, %r1008, %r1009; + abs.f32 %r1011, %r1965; + max.f32 %r1012, %r982, %r1011; + abs.f32 %r1013, %r1966; + max.f32 %r1014, %r1012, %r1013; + abs.f32 %r1015, %r1967; + max.f32 %r1016, %r986, %r1015; + abs.f32 %r1017, %r1968; + max.f32 %r1018, %r1016, %r1017; + abs.f32 %r1019, %r1969; + max.f32 %r1020, %r990, %r1019; + abs.f32 %r1021, %r1970; + max.f32 %r1022, %r1020, %r1021; + abs.f32 %r1023, %r1971; + max.f32 %r1024, %r994, %r1023; + abs.f32 %r1025, %r1972; + max.f32 %r1026, %r1024, %r1025; + abs.f32 %r1027, %r1973; + max.f32 %r1028, %r998, %r1027; + abs.f32 %r1029, %r1974; + max.f32 %r1030, %r1028, %r1029; + abs.f32 %r1031, %r1975; + max.f32 %r1032, %r1002, %r1031; + abs.f32 %r1033, %r1976; + max.f32 %r1034, %r1032, %r1033; + abs.f32 %r1035, %r1977; + max.f32 %r1036, %r1006, %r1035; + abs.f32 %r1037, %r1978; + max.f32 %r1038, %r1036, %r1037; + abs.f32 %r1039, %r1979; + max.f32 %r1040, %r1010, %r1039; + abs.f32 %r1041, %r1980; + max.f32 %r1042, %r1040, %r1041; + abs.f32 %r1043, %r1981; + max.f32 %r1044, %r1014, %r1043; + abs.f32 %r1045, %r1982; + max.f32 %r1046, %r1044, %r1045; + abs.f32 %r1047, %r1983; + max.f32 %r1048, %r1018, %r1047; + abs.f32 %r1049, %r1984; + max.f32 %r1050, %r1048, %r1049; + max.f32 %r1051, %r1022, %r1026; + max.f32 %r1052, %r1030, %r1034; + max.f32 %r1053, %r1051, %r1052; + max.f32 %r1054, %r1038, %r1042; + max.f32 %r1055, %r1046, %r1050; + max.f32 %r1056, %r1054, %r1055; + max.f32 %r1057, %r1053, %r1056; + mov.b32 %r1058, -1; + redux.sync.max.u32 %r1059, %r1057, %r1058; + and.b32 %r1060, %r1059, 2147483647; + setp.eq.b32 %p24, %r1060, 0; + shr.s32 %r1061, %r1059, 23; + sub.s32 %r1062, 141, %r1061; + max.s32 %r1063, %r1062, -40; + min.s32 %r1064, %r1063, 40; + selp.b32 %r75, 0, %r1064, %p24; + shl.b32 %r1065, %r75, 23; + add.s32 %r1066, %r1065, 1065353216; + mul.f32 %r282, %r1921, %r1066; + mul.f32 %r283, %r1922, %r1066; + // begin inline asm + { cvt.rn.f16x2.f32 %r285, %r283, %r282; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r285; + cvt.f32.f16 %r284, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r285; + cvt.f32.f16 %r286, high;} + + // end inline asm + sub.f32 %r287, %r282, %r284; + sub.f32 %r288, %r283, %r286; + // begin inline asm + { cvt.rn.f16x2.f32 %r312, %r288, %r287; } + + // end inline asm + mul.f32 %r289, %r1923, %r1066; + mul.f32 %r290, %r1924, %r1066; + // begin inline asm + { cvt.rn.f16x2.f32 %r292, %r290, %r289; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r292; + cvt.f32.f16 %r291, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r292; + cvt.f32.f16 %r293, high;} + + // end inline asm + sub.f32 %r294, %r289, %r291; + sub.f32 %r295, %r290, %r293; + // begin inline asm + { cvt.rn.f16x2.f32 %r313, %r295, %r294; } + + // end inline asm + mul.f32 %r296, %r1925, %r1066; + mul.f32 %r297, %r1926, %r1066; + // begin inline asm + { cvt.rn.f16x2.f32 %r299, %r297, %r296; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r299; + cvt.f32.f16 %r298, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r299; + cvt.f32.f16 %r300, high;} + + // end inline asm + sub.f32 %r301, %r296, %r298; + sub.f32 %r302, %r297, %r300; + // begin inline asm + { cvt.rn.f16x2.f32 %r314, %r302, %r301; } + + // end inline asm + mul.f32 %r303, %r1927, %r1066; + mul.f32 %r304, %r1928, %r1066; + // begin inline asm + { cvt.rn.f16x2.f32 %r306, %r304, %r303; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r306; + cvt.f32.f16 %r305, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r306; + cvt.f32.f16 %r307, high;} + + // end inline asm + sub.f32 %r308, %r303, %r305; + sub.f32 %r309, %r304, %r307; + // begin inline asm + { cvt.rn.f16x2.f32 %r315, %r309, %r308; } + + // end inline asm + add.s32 %r1067, %r54, %r73; + shl.b32 %r1068, %r1067, 1; + mov.b32 %r1069, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r310, %r1069, %r1068; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r316,%r317,%r324,%r325}, [%r310]; + // end inline asm + add.s32 %r311, %r310, 17408; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r322,%r323,%r330,%r331}, [%r311]; + // end inline asm + mov.b32 %r1988, 0; + mov.b32 %r318, %r1988; + mov.b32 %r319, %r1988; + mov.b32 %r320, %r1988; + mov.b32 %r321, %r1988; + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r318,%r319,%r320,%r321}, {%r312,%r313,%r314,%r315}, {%r316,%r317}, {%r318,%r319,%r320,%r321}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r318,%r319,%r320,%r321}, {%r285,%r292,%r299,%r306}, {%r322,%r323}, {%r318,%r319,%r320,%r321}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r318,%r319,%r320,%r321}, {%r285,%r292,%r299,%r306}, {%r316,%r317}, {%r318,%r319,%r320,%r321}; + // end inline asm + mov.b32 %r326, %r1988; + mov.b32 %r327, %r1988; + mov.b32 %r328, %r1988; + mov.b32 %r329, %r1988; + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r326,%r327,%r328,%r329}, {%r312,%r313,%r314,%r315}, {%r324,%r325}, {%r326,%r327,%r328,%r329}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r326,%r327,%r328,%r329}, {%r285,%r292,%r299,%r306}, {%r330,%r331}, {%r326,%r327,%r328,%r329}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r326,%r327,%r328,%r329}, {%r285,%r292,%r299,%r306}, {%r324,%r325}, {%r326,%r327,%r328,%r329}; + // end inline asm + add.s32 %r332, %r310, 34816; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r334,%r335,%r342,%r343}, [%r332]; + // end inline asm + add.s32 %r333, %r310, 52224; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r340,%r341,%r348,%r349}, [%r333]; + // end inline asm + mov.b32 %r336, %r1988; + mov.b32 %r337, %r1988; + mov.b32 %r338, %r1988; + mov.b32 %r339, %r1988; + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r336,%r337,%r338,%r339}, {%r312,%r313,%r314,%r315}, {%r334,%r335}, {%r336,%r337,%r338,%r339}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r336,%r337,%r338,%r339}, {%r285,%r292,%r299,%r306}, {%r340,%r341}, {%r336,%r337,%r338,%r339}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r336,%r337,%r338,%r339}, {%r285,%r292,%r299,%r306}, {%r334,%r335}, {%r336,%r337,%r338,%r339}; + // end inline asm + mov.b32 %r344, %r1988; + mov.b32 %r345, %r1988; + mov.b32 %r346, %r1988; + mov.b32 %r347, %r1988; + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r344,%r345,%r346,%r347}, {%r312,%r313,%r314,%r315}, {%r342,%r343}, {%r344,%r345,%r346,%r347}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r344,%r345,%r346,%r347}, {%r285,%r292,%r299,%r306}, {%r348,%r349}, {%r344,%r345,%r346,%r347}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r344,%r345,%r346,%r347}, {%r285,%r292,%r299,%r306}, {%r342,%r343}, {%r344,%r345,%r346,%r347}; + // end inline asm + add.s32 %r350, %r310, 4352; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r352,%r353,%r360,%r361}, [%r350]; + // end inline asm + add.s32 %r351, %r310, 21760; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r358,%r359,%r366,%r367}, [%r351]; + // end inline asm + mov.b32 %r354, %r1988; + mov.b32 %r355, %r1988; + mov.b32 %r356, %r1988; + mov.b32 %r357, %r1988; + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r354,%r355,%r356,%r357}, {%r312,%r313,%r314,%r315}, {%r352,%r353}, {%r354,%r355,%r356,%r357}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r354,%r355,%r356,%r357}, {%r285,%r292,%r299,%r306}, {%r358,%r359}, {%r354,%r355,%r356,%r357}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r354,%r355,%r356,%r357}, {%r285,%r292,%r299,%r306}, {%r352,%r353}, {%r354,%r355,%r356,%r357}; + // end inline asm + mov.b32 %r362, %r1988; + mov.b32 %r363, %r1988; + mov.b32 %r364, %r1988; + mov.b32 %r365, %r1988; + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r362,%r363,%r364,%r365}, {%r312,%r313,%r314,%r315}, {%r360,%r361}, {%r362,%r363,%r364,%r365}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r362,%r363,%r364,%r365}, {%r285,%r292,%r299,%r306}, {%r366,%r367}, {%r362,%r363,%r364,%r365}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r362,%r363,%r364,%r365}, {%r285,%r292,%r299,%r306}, {%r360,%r361}, {%r362,%r363,%r364,%r365}; + // end inline asm + add.s32 %r368, %r310, 39168; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r370,%r371,%r378,%r379}, [%r368]; + // end inline asm + add.s32 %r369, %r310, 56576; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r376,%r377,%r384,%r385}, [%r369]; + // end inline asm + mov.b32 %r372, %r1988; + mov.b32 %r373, %r1988; + mov.b32 %r374, %r1988; + mov.b32 %r375, %r1988; + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r372,%r373,%r374,%r375}, {%r312,%r313,%r314,%r315}, {%r370,%r371}, {%r372,%r373,%r374,%r375}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r372,%r373,%r374,%r375}, {%r285,%r292,%r299,%r306}, {%r376,%r377}, {%r372,%r373,%r374,%r375}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r372,%r373,%r374,%r375}, {%r285,%r292,%r299,%r306}, {%r370,%r371}, {%r372,%r373,%r374,%r375}; + // end inline asm + mov.b32 %r380, %r1988; + mov.b32 %r381, %r1988; + mov.b32 %r382, %r1988; + mov.b32 %r383, %r1988; + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r380,%r381,%r382,%r383}, {%r312,%r313,%r314,%r315}, {%r378,%r379}, {%r380,%r381,%r382,%r383}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r380,%r381,%r382,%r383}, {%r285,%r292,%r299,%r306}, {%r384,%r385}, {%r380,%r381,%r382,%r383}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r380,%r381,%r382,%r383}, {%r285,%r292,%r299,%r306}, {%r378,%r379}, {%r380,%r381,%r382,%r383}; + // end inline asm + mul.f32 %r386, %r1929, %r1066; + mul.f32 %r387, %r1930, %r1066; + // begin inline asm + { cvt.rn.f16x2.f32 %r389, %r387, %r386; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r389; + cvt.f32.f16 %r388, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r389; + cvt.f32.f16 %r390, high;} + + // end inline asm + sub.f32 %r391, %r386, %r388; + sub.f32 %r392, %r387, %r390; + // begin inline asm + { cvt.rn.f16x2.f32 %r416, %r392, %r391; } + + // end inline asm + mul.f32 %r393, %r1931, %r1066; + mul.f32 %r394, %r1932, %r1066; + // begin inline asm + { cvt.rn.f16x2.f32 %r396, %r394, %r393; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r396; + cvt.f32.f16 %r395, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r396; + cvt.f32.f16 %r397, high;} + + // end inline asm + sub.f32 %r398, %r393, %r395; + sub.f32 %r399, %r394, %r397; + // begin inline asm + { cvt.rn.f16x2.f32 %r417, %r399, %r398; } + + // end inline asm + mul.f32 %r400, %r1933, %r1066; + mul.f32 %r401, %r1934, %r1066; + // begin inline asm + { cvt.rn.f16x2.f32 %r403, %r401, %r400; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r403; + cvt.f32.f16 %r402, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r403; + cvt.f32.f16 %r404, high;} + + // end inline asm + sub.f32 %r405, %r400, %r402; + sub.f32 %r406, %r401, %r404; + // begin inline asm + { cvt.rn.f16x2.f32 %r418, %r406, %r405; } + + // end inline asm + mul.f32 %r407, %r1935, %r1066; + mul.f32 %r408, %r1936, %r1066; + // begin inline asm + { cvt.rn.f16x2.f32 %r410, %r408, %r407; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r410; + cvt.f32.f16 %r409, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r410; + cvt.f32.f16 %r411, high;} + + // end inline asm + sub.f32 %r412, %r407, %r409; + sub.f32 %r413, %r408, %r411; + // begin inline asm + { cvt.rn.f16x2.f32 %r419, %r413, %r412; } + + // end inline asm + add.s32 %r414, %r310, 32; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r420,%r421,%r424,%r425}, [%r414]; + // end inline asm + add.s32 %r415, %r310, 17440; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r422,%r423,%r426,%r427}, [%r415]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r318,%r319,%r320,%r321}, {%r416,%r417,%r418,%r419}, {%r420,%r421}, {%r318,%r319,%r320,%r321}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r318,%r319,%r320,%r321}, {%r389,%r396,%r403,%r410}, {%r422,%r423}, {%r318,%r319,%r320,%r321}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r318,%r319,%r320,%r321}, {%r389,%r396,%r403,%r410}, {%r420,%r421}, {%r318,%r319,%r320,%r321}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r326,%r327,%r328,%r329}, {%r416,%r417,%r418,%r419}, {%r424,%r425}, {%r326,%r327,%r328,%r329}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r326,%r327,%r328,%r329}, {%r389,%r396,%r403,%r410}, {%r426,%r427}, {%r326,%r327,%r328,%r329}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r326,%r327,%r328,%r329}, {%r389,%r396,%r403,%r410}, {%r424,%r425}, {%r326,%r327,%r328,%r329}; + // end inline asm + add.s32 %r428, %r310, 34848; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r430,%r431,%r434,%r435}, [%r428]; + // end inline asm + add.s32 %r429, %r310, 52256; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r432,%r433,%r436,%r437}, [%r429]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r336,%r337,%r338,%r339}, {%r416,%r417,%r418,%r419}, {%r430,%r431}, {%r336,%r337,%r338,%r339}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r336,%r337,%r338,%r339}, {%r389,%r396,%r403,%r410}, {%r432,%r433}, {%r336,%r337,%r338,%r339}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r336,%r337,%r338,%r339}, {%r389,%r396,%r403,%r410}, {%r430,%r431}, {%r336,%r337,%r338,%r339}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r344,%r345,%r346,%r347}, {%r416,%r417,%r418,%r419}, {%r434,%r435}, {%r344,%r345,%r346,%r347}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r344,%r345,%r346,%r347}, {%r389,%r396,%r403,%r410}, {%r436,%r437}, {%r344,%r345,%r346,%r347}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r344,%r345,%r346,%r347}, {%r389,%r396,%r403,%r410}, {%r434,%r435}, {%r344,%r345,%r346,%r347}; + // end inline asm + add.s32 %r438, %r310, 4384; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r440,%r441,%r444,%r445}, [%r438]; + // end inline asm + add.s32 %r439, %r310, 21792; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r442,%r443,%r446,%r447}, [%r439]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r354,%r355,%r356,%r357}, {%r416,%r417,%r418,%r419}, {%r440,%r441}, {%r354,%r355,%r356,%r357}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r354,%r355,%r356,%r357}, {%r389,%r396,%r403,%r410}, {%r442,%r443}, {%r354,%r355,%r356,%r357}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r354,%r355,%r356,%r357}, {%r389,%r396,%r403,%r410}, {%r440,%r441}, {%r354,%r355,%r356,%r357}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r362,%r363,%r364,%r365}, {%r416,%r417,%r418,%r419}, {%r444,%r445}, {%r362,%r363,%r364,%r365}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r362,%r363,%r364,%r365}, {%r389,%r396,%r403,%r410}, {%r446,%r447}, {%r362,%r363,%r364,%r365}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r362,%r363,%r364,%r365}, {%r389,%r396,%r403,%r410}, {%r444,%r445}, {%r362,%r363,%r364,%r365}; + // end inline asm + add.s32 %r448, %r310, 39200; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r450,%r451,%r454,%r455}, [%r448]; + // end inline asm + add.s32 %r449, %r310, 56608; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r452,%r453,%r456,%r457}, [%r449]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r372,%r373,%r374,%r375}, {%r416,%r417,%r418,%r419}, {%r450,%r451}, {%r372,%r373,%r374,%r375}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r372,%r373,%r374,%r375}, {%r389,%r396,%r403,%r410}, {%r452,%r453}, {%r372,%r373,%r374,%r375}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r372,%r373,%r374,%r375}, {%r389,%r396,%r403,%r410}, {%r450,%r451}, {%r372,%r373,%r374,%r375}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r380,%r381,%r382,%r383}, {%r416,%r417,%r418,%r419}, {%r454,%r455}, {%r380,%r381,%r382,%r383}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r380,%r381,%r382,%r383}, {%r389,%r396,%r403,%r410}, {%r456,%r457}, {%r380,%r381,%r382,%r383}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r380,%r381,%r382,%r383}, {%r389,%r396,%r403,%r410}, {%r454,%r455}, {%r380,%r381,%r382,%r383}; + // end inline asm + mul.f32 %r458, %r1937, %r1066; + mul.f32 %r459, %r1938, %r1066; + // begin inline asm + { cvt.rn.f16x2.f32 %r461, %r459, %r458; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r461; + cvt.f32.f16 %r460, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r461; + cvt.f32.f16 %r462, high;} + + // end inline asm + sub.f32 %r463, %r458, %r460; + sub.f32 %r464, %r459, %r462; + // begin inline asm + { cvt.rn.f16x2.f32 %r488, %r464, %r463; } + + // end inline asm + mul.f32 %r465, %r1939, %r1066; + mul.f32 %r466, %r1940, %r1066; + // begin inline asm + { cvt.rn.f16x2.f32 %r468, %r466, %r465; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r468; + cvt.f32.f16 %r467, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r468; + cvt.f32.f16 %r469, high;} + + // end inline asm + sub.f32 %r470, %r465, %r467; + sub.f32 %r471, %r466, %r469; + // begin inline asm + { cvt.rn.f16x2.f32 %r489, %r471, %r470; } + + // end inline asm + mul.f32 %r472, %r1941, %r1066; + mul.f32 %r473, %r1942, %r1066; + // begin inline asm + { cvt.rn.f16x2.f32 %r475, %r473, %r472; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r475; + cvt.f32.f16 %r474, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r475; + cvt.f32.f16 %r476, high;} + + // end inline asm + sub.f32 %r477, %r472, %r474; + sub.f32 %r478, %r473, %r476; + // begin inline asm + { cvt.rn.f16x2.f32 %r490, %r478, %r477; } + + // end inline asm + mul.f32 %r479, %r1943, %r1066; + mul.f32 %r480, %r1944, %r1066; + // begin inline asm + { cvt.rn.f16x2.f32 %r482, %r480, %r479; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r482; + cvt.f32.f16 %r481, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r482; + cvt.f32.f16 %r483, high;} + + // end inline asm + sub.f32 %r484, %r479, %r481; + sub.f32 %r485, %r480, %r483; + // begin inline asm + { cvt.rn.f16x2.f32 %r491, %r485, %r484; } + + // end inline asm + add.s32 %r486, %r310, 64; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r492,%r493,%r496,%r497}, [%r486]; + // end inline asm + add.s32 %r487, %r310, 17472; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r494,%r495,%r498,%r499}, [%r487]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r318,%r319,%r320,%r321}, {%r488,%r489,%r490,%r491}, {%r492,%r493}, {%r318,%r319,%r320,%r321}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r318,%r319,%r320,%r321}, {%r461,%r468,%r475,%r482}, {%r494,%r495}, {%r318,%r319,%r320,%r321}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r318,%r319,%r320,%r321}, {%r461,%r468,%r475,%r482}, {%r492,%r493}, {%r318,%r319,%r320,%r321}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r326,%r327,%r328,%r329}, {%r488,%r489,%r490,%r491}, {%r496,%r497}, {%r326,%r327,%r328,%r329}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r326,%r327,%r328,%r329}, {%r461,%r468,%r475,%r482}, {%r498,%r499}, {%r326,%r327,%r328,%r329}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r326,%r327,%r328,%r329}, {%r461,%r468,%r475,%r482}, {%r496,%r497}, {%r326,%r327,%r328,%r329}; + // end inline asm + add.s32 %r500, %r310, 34880; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r502,%r503,%r506,%r507}, [%r500]; + // end inline asm + add.s32 %r501, %r310, 52288; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r504,%r505,%r508,%r509}, [%r501]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r336,%r337,%r338,%r339}, {%r488,%r489,%r490,%r491}, {%r502,%r503}, {%r336,%r337,%r338,%r339}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r336,%r337,%r338,%r339}, {%r461,%r468,%r475,%r482}, {%r504,%r505}, {%r336,%r337,%r338,%r339}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r336,%r337,%r338,%r339}, {%r461,%r468,%r475,%r482}, {%r502,%r503}, {%r336,%r337,%r338,%r339}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r344,%r345,%r346,%r347}, {%r488,%r489,%r490,%r491}, {%r506,%r507}, {%r344,%r345,%r346,%r347}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r344,%r345,%r346,%r347}, {%r461,%r468,%r475,%r482}, {%r508,%r509}, {%r344,%r345,%r346,%r347}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r344,%r345,%r346,%r347}, {%r461,%r468,%r475,%r482}, {%r506,%r507}, {%r344,%r345,%r346,%r347}; + // end inline asm + add.s32 %r510, %r310, 4416; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r512,%r513,%r516,%r517}, [%r510]; + // end inline asm + add.s32 %r511, %r310, 21824; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r514,%r515,%r518,%r519}, [%r511]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r354,%r355,%r356,%r357}, {%r488,%r489,%r490,%r491}, {%r512,%r513}, {%r354,%r355,%r356,%r357}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r354,%r355,%r356,%r357}, {%r461,%r468,%r475,%r482}, {%r514,%r515}, {%r354,%r355,%r356,%r357}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r354,%r355,%r356,%r357}, {%r461,%r468,%r475,%r482}, {%r512,%r513}, {%r354,%r355,%r356,%r357}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r362,%r363,%r364,%r365}, {%r488,%r489,%r490,%r491}, {%r516,%r517}, {%r362,%r363,%r364,%r365}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r362,%r363,%r364,%r365}, {%r461,%r468,%r475,%r482}, {%r518,%r519}, {%r362,%r363,%r364,%r365}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r362,%r363,%r364,%r365}, {%r461,%r468,%r475,%r482}, {%r516,%r517}, {%r362,%r363,%r364,%r365}; + // end inline asm + add.s32 %r520, %r310, 39232; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r522,%r523,%r526,%r527}, [%r520]; + // end inline asm + add.s32 %r521, %r310, 56640; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r524,%r525,%r528,%r529}, [%r521]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r372,%r373,%r374,%r375}, {%r488,%r489,%r490,%r491}, {%r522,%r523}, {%r372,%r373,%r374,%r375}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r372,%r373,%r374,%r375}, {%r461,%r468,%r475,%r482}, {%r524,%r525}, {%r372,%r373,%r374,%r375}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r372,%r373,%r374,%r375}, {%r461,%r468,%r475,%r482}, {%r522,%r523}, {%r372,%r373,%r374,%r375}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r380,%r381,%r382,%r383}, {%r488,%r489,%r490,%r491}, {%r526,%r527}, {%r380,%r381,%r382,%r383}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r380,%r381,%r382,%r383}, {%r461,%r468,%r475,%r482}, {%r528,%r529}, {%r380,%r381,%r382,%r383}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r380,%r381,%r382,%r383}, {%r461,%r468,%r475,%r482}, {%r526,%r527}, {%r380,%r381,%r382,%r383}; + // end inline asm + mul.f32 %r530, %r1945, %r1066; + mul.f32 %r531, %r1946, %r1066; + // begin inline asm + { cvt.rn.f16x2.f32 %r533, %r531, %r530; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r533; + cvt.f32.f16 %r532, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r533; + cvt.f32.f16 %r534, high;} + + // end inline asm + sub.f32 %r535, %r530, %r532; + sub.f32 %r536, %r531, %r534; + // begin inline asm + { cvt.rn.f16x2.f32 %r560, %r536, %r535; } + + // end inline asm + mul.f32 %r537, %r1947, %r1066; + mul.f32 %r538, %r1948, %r1066; + // begin inline asm + { cvt.rn.f16x2.f32 %r540, %r538, %r537; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r540; + cvt.f32.f16 %r539, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r540; + cvt.f32.f16 %r541, high;} + + // end inline asm + sub.f32 %r542, %r537, %r539; + sub.f32 %r543, %r538, %r541; + // begin inline asm + { cvt.rn.f16x2.f32 %r561, %r543, %r542; } + + // end inline asm + mul.f32 %r544, %r1949, %r1066; + mul.f32 %r545, %r1950, %r1066; + // begin inline asm + { cvt.rn.f16x2.f32 %r547, %r545, %r544; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r547; + cvt.f32.f16 %r546, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r547; + cvt.f32.f16 %r548, high;} + + // end inline asm + sub.f32 %r549, %r544, %r546; + sub.f32 %r550, %r545, %r548; + // begin inline asm + { cvt.rn.f16x2.f32 %r562, %r550, %r549; } + + // end inline asm + mul.f32 %r551, %r1951, %r1066; + mul.f32 %r552, %r1952, %r1066; + // begin inline asm + { cvt.rn.f16x2.f32 %r554, %r552, %r551; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r554; + cvt.f32.f16 %r553, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r554; + cvt.f32.f16 %r555, high;} + + // end inline asm + sub.f32 %r556, %r551, %r553; + sub.f32 %r557, %r552, %r555; + // begin inline asm + { cvt.rn.f16x2.f32 %r563, %r557, %r556; } + + // end inline asm + add.s32 %r558, %r310, 96; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r564,%r565,%r568,%r569}, [%r558]; + // end inline asm + add.s32 %r559, %r310, 17504; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r566,%r567,%r570,%r571}, [%r559]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r318,%r319,%r320,%r321}, {%r560,%r561,%r562,%r563}, {%r564,%r565}, {%r318,%r319,%r320,%r321}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r318,%r319,%r320,%r321}, {%r533,%r540,%r547,%r554}, {%r566,%r567}, {%r318,%r319,%r320,%r321}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r318,%r319,%r320,%r321}, {%r533,%r540,%r547,%r554}, {%r564,%r565}, {%r318,%r319,%r320,%r321}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r326,%r327,%r328,%r329}, {%r560,%r561,%r562,%r563}, {%r568,%r569}, {%r326,%r327,%r328,%r329}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r326,%r327,%r328,%r329}, {%r533,%r540,%r547,%r554}, {%r570,%r571}, {%r326,%r327,%r328,%r329}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r326,%r327,%r328,%r329}, {%r533,%r540,%r547,%r554}, {%r568,%r569}, {%r326,%r327,%r328,%r329}; + // end inline asm + add.s32 %r572, %r310, 34912; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r574,%r575,%r578,%r579}, [%r572]; + // end inline asm + add.s32 %r573, %r310, 52320; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r576,%r577,%r580,%r581}, [%r573]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r336,%r337,%r338,%r339}, {%r560,%r561,%r562,%r563}, {%r574,%r575}, {%r336,%r337,%r338,%r339}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r336,%r337,%r338,%r339}, {%r533,%r540,%r547,%r554}, {%r576,%r577}, {%r336,%r337,%r338,%r339}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r336,%r337,%r338,%r339}, {%r533,%r540,%r547,%r554}, {%r574,%r575}, {%r336,%r337,%r338,%r339}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r344,%r345,%r346,%r347}, {%r560,%r561,%r562,%r563}, {%r578,%r579}, {%r344,%r345,%r346,%r347}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r344,%r345,%r346,%r347}, {%r533,%r540,%r547,%r554}, {%r580,%r581}, {%r344,%r345,%r346,%r347}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r344,%r345,%r346,%r347}, {%r533,%r540,%r547,%r554}, {%r578,%r579}, {%r344,%r345,%r346,%r347}; + // end inline asm + add.s32 %r582, %r310, 4448; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r584,%r585,%r588,%r589}, [%r582]; + // end inline asm + add.s32 %r583, %r310, 21856; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r586,%r587,%r590,%r591}, [%r583]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r354,%r355,%r356,%r357}, {%r560,%r561,%r562,%r563}, {%r584,%r585}, {%r354,%r355,%r356,%r357}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r354,%r355,%r356,%r357}, {%r533,%r540,%r547,%r554}, {%r586,%r587}, {%r354,%r355,%r356,%r357}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r354,%r355,%r356,%r357}, {%r533,%r540,%r547,%r554}, {%r584,%r585}, {%r354,%r355,%r356,%r357}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r362,%r363,%r364,%r365}, {%r560,%r561,%r562,%r563}, {%r588,%r589}, {%r362,%r363,%r364,%r365}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r362,%r363,%r364,%r365}, {%r533,%r540,%r547,%r554}, {%r590,%r591}, {%r362,%r363,%r364,%r365}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r362,%r363,%r364,%r365}, {%r533,%r540,%r547,%r554}, {%r588,%r589}, {%r362,%r363,%r364,%r365}; + // end inline asm + add.s32 %r592, %r310, 39264; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r594,%r595,%r598,%r599}, [%r592]; + // end inline asm + add.s32 %r593, %r310, 56672; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r596,%r597,%r600,%r601}, [%r593]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r372,%r373,%r374,%r375}, {%r560,%r561,%r562,%r563}, {%r594,%r595}, {%r372,%r373,%r374,%r375}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r372,%r373,%r374,%r375}, {%r533,%r540,%r547,%r554}, {%r596,%r597}, {%r372,%r373,%r374,%r375}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r372,%r373,%r374,%r375}, {%r533,%r540,%r547,%r554}, {%r594,%r595}, {%r372,%r373,%r374,%r375}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r380,%r381,%r382,%r383}, {%r560,%r561,%r562,%r563}, {%r598,%r599}, {%r380,%r381,%r382,%r383}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r380,%r381,%r382,%r383}, {%r533,%r540,%r547,%r554}, {%r600,%r601}, {%r380,%r381,%r382,%r383}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r380,%r381,%r382,%r383}, {%r533,%r540,%r547,%r554}, {%r598,%r599}, {%r380,%r381,%r382,%r383}; + // end inline asm + mul.f32 %r602, %r1953, %r1066; + mul.f32 %r603, %r1954, %r1066; + // begin inline asm + { cvt.rn.f16x2.f32 %r605, %r603, %r602; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r605; + cvt.f32.f16 %r604, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r605; + cvt.f32.f16 %r606, high;} + + // end inline asm + sub.f32 %r607, %r602, %r604; + sub.f32 %r608, %r603, %r606; + // begin inline asm + { cvt.rn.f16x2.f32 %r632, %r608, %r607; } + + // end inline asm + mul.f32 %r609, %r1955, %r1066; + mul.f32 %r610, %r1956, %r1066; + // begin inline asm + { cvt.rn.f16x2.f32 %r612, %r610, %r609; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r612; + cvt.f32.f16 %r611, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r612; + cvt.f32.f16 %r613, high;} + + // end inline asm + sub.f32 %r614, %r609, %r611; + sub.f32 %r615, %r610, %r613; + // begin inline asm + { cvt.rn.f16x2.f32 %r633, %r615, %r614; } + + // end inline asm + mul.f32 %r616, %r1957, %r1066; + mul.f32 %r617, %r1958, %r1066; + // begin inline asm + { cvt.rn.f16x2.f32 %r619, %r617, %r616; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r619; + cvt.f32.f16 %r618, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r619; + cvt.f32.f16 %r620, high;} + + // end inline asm + sub.f32 %r621, %r616, %r618; + sub.f32 %r622, %r617, %r620; + // begin inline asm + { cvt.rn.f16x2.f32 %r634, %r622, %r621; } + + // end inline asm + mul.f32 %r623, %r1959, %r1066; + mul.f32 %r624, %r1960, %r1066; + // begin inline asm + { cvt.rn.f16x2.f32 %r626, %r624, %r623; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r626; + cvt.f32.f16 %r625, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r626; + cvt.f32.f16 %r627, high;} + + // end inline asm + sub.f32 %r628, %r623, %r625; + sub.f32 %r629, %r624, %r627; + // begin inline asm + { cvt.rn.f16x2.f32 %r635, %r629, %r628; } + + // end inline asm + add.s32 %r630, %r310, 128; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r636,%r637,%r640,%r641}, [%r630]; + // end inline asm + add.s32 %r631, %r310, 17536; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r638,%r639,%r642,%r643}, [%r631]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r318,%r319,%r320,%r321}, {%r632,%r633,%r634,%r635}, {%r636,%r637}, {%r318,%r319,%r320,%r321}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r318,%r319,%r320,%r321}, {%r605,%r612,%r619,%r626}, {%r638,%r639}, {%r318,%r319,%r320,%r321}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r318,%r319,%r320,%r321}, {%r605,%r612,%r619,%r626}, {%r636,%r637}, {%r318,%r319,%r320,%r321}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r326,%r327,%r328,%r329}, {%r632,%r633,%r634,%r635}, {%r640,%r641}, {%r326,%r327,%r328,%r329}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r326,%r327,%r328,%r329}, {%r605,%r612,%r619,%r626}, {%r642,%r643}, {%r326,%r327,%r328,%r329}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r326,%r327,%r328,%r329}, {%r605,%r612,%r619,%r626}, {%r640,%r641}, {%r326,%r327,%r328,%r329}; + // end inline asm + add.s32 %r644, %r310, 34944; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r646,%r647,%r650,%r651}, [%r644]; + // end inline asm + add.s32 %r645, %r310, 52352; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r648,%r649,%r652,%r653}, [%r645]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r336,%r337,%r338,%r339}, {%r632,%r633,%r634,%r635}, {%r646,%r647}, {%r336,%r337,%r338,%r339}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r336,%r337,%r338,%r339}, {%r605,%r612,%r619,%r626}, {%r648,%r649}, {%r336,%r337,%r338,%r339}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r336,%r337,%r338,%r339}, {%r605,%r612,%r619,%r626}, {%r646,%r647}, {%r336,%r337,%r338,%r339}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r344,%r345,%r346,%r347}, {%r632,%r633,%r634,%r635}, {%r650,%r651}, {%r344,%r345,%r346,%r347}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r344,%r345,%r346,%r347}, {%r605,%r612,%r619,%r626}, {%r652,%r653}, {%r344,%r345,%r346,%r347}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r344,%r345,%r346,%r347}, {%r605,%r612,%r619,%r626}, {%r650,%r651}, {%r344,%r345,%r346,%r347}; + // end inline asm + add.s32 %r654, %r310, 4480; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r656,%r657,%r660,%r661}, [%r654]; + // end inline asm + add.s32 %r655, %r310, 21888; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r658,%r659,%r662,%r663}, [%r655]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r354,%r355,%r356,%r357}, {%r632,%r633,%r634,%r635}, {%r656,%r657}, {%r354,%r355,%r356,%r357}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r354,%r355,%r356,%r357}, {%r605,%r612,%r619,%r626}, {%r658,%r659}, {%r354,%r355,%r356,%r357}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r354,%r355,%r356,%r357}, {%r605,%r612,%r619,%r626}, {%r656,%r657}, {%r354,%r355,%r356,%r357}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r362,%r363,%r364,%r365}, {%r632,%r633,%r634,%r635}, {%r660,%r661}, {%r362,%r363,%r364,%r365}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r362,%r363,%r364,%r365}, {%r605,%r612,%r619,%r626}, {%r662,%r663}, {%r362,%r363,%r364,%r365}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r362,%r363,%r364,%r365}, {%r605,%r612,%r619,%r626}, {%r660,%r661}, {%r362,%r363,%r364,%r365}; + // end inline asm + add.s32 %r664, %r310, 39296; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r666,%r667,%r670,%r671}, [%r664]; + // end inline asm + add.s32 %r665, %r310, 56704; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r668,%r669,%r672,%r673}, [%r665]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r372,%r373,%r374,%r375}, {%r632,%r633,%r634,%r635}, {%r666,%r667}, {%r372,%r373,%r374,%r375}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r372,%r373,%r374,%r375}, {%r605,%r612,%r619,%r626}, {%r668,%r669}, {%r372,%r373,%r374,%r375}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r372,%r373,%r374,%r375}, {%r605,%r612,%r619,%r626}, {%r666,%r667}, {%r372,%r373,%r374,%r375}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r380,%r381,%r382,%r383}, {%r632,%r633,%r634,%r635}, {%r670,%r671}, {%r380,%r381,%r382,%r383}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r380,%r381,%r382,%r383}, {%r605,%r612,%r619,%r626}, {%r672,%r673}, {%r380,%r381,%r382,%r383}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r380,%r381,%r382,%r383}, {%r605,%r612,%r619,%r626}, {%r670,%r671}, {%r380,%r381,%r382,%r383}; + // end inline asm + mul.f32 %r674, %r1961, %r1066; + mul.f32 %r675, %r1962, %r1066; + // begin inline asm + { cvt.rn.f16x2.f32 %r677, %r675, %r674; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r677; + cvt.f32.f16 %r676, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r677; + cvt.f32.f16 %r678, high;} + + // end inline asm + sub.f32 %r679, %r674, %r676; + sub.f32 %r680, %r675, %r678; + // begin inline asm + { cvt.rn.f16x2.f32 %r704, %r680, %r679; } + + // end inline asm + mul.f32 %r681, %r1963, %r1066; + mul.f32 %r682, %r1964, %r1066; + // begin inline asm + { cvt.rn.f16x2.f32 %r684, %r682, %r681; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r684; + cvt.f32.f16 %r683, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r684; + cvt.f32.f16 %r685, high;} + + // end inline asm + sub.f32 %r686, %r681, %r683; + sub.f32 %r687, %r682, %r685; + // begin inline asm + { cvt.rn.f16x2.f32 %r705, %r687, %r686; } + + // end inline asm + mul.f32 %r688, %r1965, %r1066; + mul.f32 %r689, %r1966, %r1066; + // begin inline asm + { cvt.rn.f16x2.f32 %r691, %r689, %r688; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r691; + cvt.f32.f16 %r690, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r691; + cvt.f32.f16 %r692, high;} + + // end inline asm + sub.f32 %r693, %r688, %r690; + sub.f32 %r694, %r689, %r692; + // begin inline asm + { cvt.rn.f16x2.f32 %r706, %r694, %r693; } + + // end inline asm + mul.f32 %r695, %r1967, %r1066; + mul.f32 %r696, %r1968, %r1066; + // begin inline asm + { cvt.rn.f16x2.f32 %r698, %r696, %r695; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r698; + cvt.f32.f16 %r697, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r698; + cvt.f32.f16 %r699, high;} + + // end inline asm + sub.f32 %r700, %r695, %r697; + sub.f32 %r701, %r696, %r699; + // begin inline asm + { cvt.rn.f16x2.f32 %r707, %r701, %r700; } + + // end inline asm + add.s32 %r702, %r310, 160; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r708,%r709,%r712,%r713}, [%r702]; + // end inline asm + add.s32 %r703, %r310, 17568; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r710,%r711,%r714,%r715}, [%r703]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r318,%r319,%r320,%r321}, {%r704,%r705,%r706,%r707}, {%r708,%r709}, {%r318,%r319,%r320,%r321}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r318,%r319,%r320,%r321}, {%r677,%r684,%r691,%r698}, {%r710,%r711}, {%r318,%r319,%r320,%r321}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r318,%r319,%r320,%r321}, {%r677,%r684,%r691,%r698}, {%r708,%r709}, {%r318,%r319,%r320,%r321}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r326,%r327,%r328,%r329}, {%r704,%r705,%r706,%r707}, {%r712,%r713}, {%r326,%r327,%r328,%r329}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r326,%r327,%r328,%r329}, {%r677,%r684,%r691,%r698}, {%r714,%r715}, {%r326,%r327,%r328,%r329}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r326,%r327,%r328,%r329}, {%r677,%r684,%r691,%r698}, {%r712,%r713}, {%r326,%r327,%r328,%r329}; + // end inline asm + add.s32 %r716, %r310, 34976; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r718,%r719,%r722,%r723}, [%r716]; + // end inline asm + add.s32 %r717, %r310, 52384; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r720,%r721,%r724,%r725}, [%r717]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r336,%r337,%r338,%r339}, {%r704,%r705,%r706,%r707}, {%r718,%r719}, {%r336,%r337,%r338,%r339}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r336,%r337,%r338,%r339}, {%r677,%r684,%r691,%r698}, {%r720,%r721}, {%r336,%r337,%r338,%r339}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r336,%r337,%r338,%r339}, {%r677,%r684,%r691,%r698}, {%r718,%r719}, {%r336,%r337,%r338,%r339}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r344,%r345,%r346,%r347}, {%r704,%r705,%r706,%r707}, {%r722,%r723}, {%r344,%r345,%r346,%r347}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r344,%r345,%r346,%r347}, {%r677,%r684,%r691,%r698}, {%r724,%r725}, {%r344,%r345,%r346,%r347}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r344,%r345,%r346,%r347}, {%r677,%r684,%r691,%r698}, {%r722,%r723}, {%r344,%r345,%r346,%r347}; + // end inline asm + add.s32 %r726, %r310, 4512; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r728,%r729,%r732,%r733}, [%r726]; + // end inline asm + add.s32 %r727, %r310, 21920; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r730,%r731,%r734,%r735}, [%r727]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r354,%r355,%r356,%r357}, {%r704,%r705,%r706,%r707}, {%r728,%r729}, {%r354,%r355,%r356,%r357}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r354,%r355,%r356,%r357}, {%r677,%r684,%r691,%r698}, {%r730,%r731}, {%r354,%r355,%r356,%r357}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r354,%r355,%r356,%r357}, {%r677,%r684,%r691,%r698}, {%r728,%r729}, {%r354,%r355,%r356,%r357}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r362,%r363,%r364,%r365}, {%r704,%r705,%r706,%r707}, {%r732,%r733}, {%r362,%r363,%r364,%r365}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r362,%r363,%r364,%r365}, {%r677,%r684,%r691,%r698}, {%r734,%r735}, {%r362,%r363,%r364,%r365}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r362,%r363,%r364,%r365}, {%r677,%r684,%r691,%r698}, {%r732,%r733}, {%r362,%r363,%r364,%r365}; + // end inline asm + add.s32 %r736, %r310, 39328; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r738,%r739,%r742,%r743}, [%r736]; + // end inline asm + add.s32 %r737, %r310, 56736; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r740,%r741,%r744,%r745}, [%r737]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r372,%r373,%r374,%r375}, {%r704,%r705,%r706,%r707}, {%r738,%r739}, {%r372,%r373,%r374,%r375}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r372,%r373,%r374,%r375}, {%r677,%r684,%r691,%r698}, {%r740,%r741}, {%r372,%r373,%r374,%r375}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r372,%r373,%r374,%r375}, {%r677,%r684,%r691,%r698}, {%r738,%r739}, {%r372,%r373,%r374,%r375}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r380,%r381,%r382,%r383}, {%r704,%r705,%r706,%r707}, {%r742,%r743}, {%r380,%r381,%r382,%r383}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r380,%r381,%r382,%r383}, {%r677,%r684,%r691,%r698}, {%r744,%r745}, {%r380,%r381,%r382,%r383}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r380,%r381,%r382,%r383}, {%r677,%r684,%r691,%r698}, {%r742,%r743}, {%r380,%r381,%r382,%r383}; + // end inline asm + mul.f32 %r746, %r1969, %r1066; + mul.f32 %r747, %r1970, %r1066; + // begin inline asm + { cvt.rn.f16x2.f32 %r749, %r747, %r746; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r749; + cvt.f32.f16 %r748, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r749; + cvt.f32.f16 %r750, high;} + + // end inline asm + sub.f32 %r751, %r746, %r748; + sub.f32 %r752, %r747, %r750; + // begin inline asm + { cvt.rn.f16x2.f32 %r776, %r752, %r751; } + + // end inline asm + mul.f32 %r753, %r1971, %r1066; + mul.f32 %r754, %r1972, %r1066; + // begin inline asm + { cvt.rn.f16x2.f32 %r756, %r754, %r753; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r756; + cvt.f32.f16 %r755, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r756; + cvt.f32.f16 %r757, high;} + + // end inline asm + sub.f32 %r758, %r753, %r755; + sub.f32 %r759, %r754, %r757; + // begin inline asm + { cvt.rn.f16x2.f32 %r777, %r759, %r758; } + + // end inline asm + mul.f32 %r760, %r1973, %r1066; + mul.f32 %r761, %r1974, %r1066; + // begin inline asm + { cvt.rn.f16x2.f32 %r763, %r761, %r760; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r763; + cvt.f32.f16 %r762, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r763; + cvt.f32.f16 %r764, high;} + + // end inline asm + sub.f32 %r765, %r760, %r762; + sub.f32 %r766, %r761, %r764; + // begin inline asm + { cvt.rn.f16x2.f32 %r778, %r766, %r765; } + + // end inline asm + mul.f32 %r767, %r1975, %r1066; + mul.f32 %r768, %r1976, %r1066; + // begin inline asm + { cvt.rn.f16x2.f32 %r770, %r768, %r767; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r770; + cvt.f32.f16 %r769, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r770; + cvt.f32.f16 %r771, high;} + + // end inline asm + sub.f32 %r772, %r767, %r769; + sub.f32 %r773, %r768, %r771; + // begin inline asm + { cvt.rn.f16x2.f32 %r779, %r773, %r772; } + + // end inline asm + add.s32 %r774, %r310, 192; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r780,%r781,%r784,%r785}, [%r774]; + // end inline asm + add.s32 %r775, %r310, 17600; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r782,%r783,%r786,%r787}, [%r775]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r318,%r319,%r320,%r321}, {%r776,%r777,%r778,%r779}, {%r780,%r781}, {%r318,%r319,%r320,%r321}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r318,%r319,%r320,%r321}, {%r749,%r756,%r763,%r770}, {%r782,%r783}, {%r318,%r319,%r320,%r321}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r318,%r319,%r320,%r321}, {%r749,%r756,%r763,%r770}, {%r780,%r781}, {%r318,%r319,%r320,%r321}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r326,%r327,%r328,%r329}, {%r776,%r777,%r778,%r779}, {%r784,%r785}, {%r326,%r327,%r328,%r329}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r326,%r327,%r328,%r329}, {%r749,%r756,%r763,%r770}, {%r786,%r787}, {%r326,%r327,%r328,%r329}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r326,%r327,%r328,%r329}, {%r749,%r756,%r763,%r770}, {%r784,%r785}, {%r326,%r327,%r328,%r329}; + // end inline asm + add.s32 %r788, %r310, 35008; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r790,%r791,%r794,%r795}, [%r788]; + // end inline asm + add.s32 %r789, %r310, 52416; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r792,%r793,%r796,%r797}, [%r789]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r336,%r337,%r338,%r339}, {%r776,%r777,%r778,%r779}, {%r790,%r791}, {%r336,%r337,%r338,%r339}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r336,%r337,%r338,%r339}, {%r749,%r756,%r763,%r770}, {%r792,%r793}, {%r336,%r337,%r338,%r339}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r336,%r337,%r338,%r339}, {%r749,%r756,%r763,%r770}, {%r790,%r791}, {%r336,%r337,%r338,%r339}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r344,%r345,%r346,%r347}, {%r776,%r777,%r778,%r779}, {%r794,%r795}, {%r344,%r345,%r346,%r347}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r344,%r345,%r346,%r347}, {%r749,%r756,%r763,%r770}, {%r796,%r797}, {%r344,%r345,%r346,%r347}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r344,%r345,%r346,%r347}, {%r749,%r756,%r763,%r770}, {%r794,%r795}, {%r344,%r345,%r346,%r347}; + // end inline asm + add.s32 %r798, %r310, 4544; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r800,%r801,%r804,%r805}, [%r798]; + // end inline asm + add.s32 %r799, %r310, 21952; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r802,%r803,%r806,%r807}, [%r799]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r354,%r355,%r356,%r357}, {%r776,%r777,%r778,%r779}, {%r800,%r801}, {%r354,%r355,%r356,%r357}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r354,%r355,%r356,%r357}, {%r749,%r756,%r763,%r770}, {%r802,%r803}, {%r354,%r355,%r356,%r357}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r354,%r355,%r356,%r357}, {%r749,%r756,%r763,%r770}, {%r800,%r801}, {%r354,%r355,%r356,%r357}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r362,%r363,%r364,%r365}, {%r776,%r777,%r778,%r779}, {%r804,%r805}, {%r362,%r363,%r364,%r365}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r362,%r363,%r364,%r365}, {%r749,%r756,%r763,%r770}, {%r806,%r807}, {%r362,%r363,%r364,%r365}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r362,%r363,%r364,%r365}, {%r749,%r756,%r763,%r770}, {%r804,%r805}, {%r362,%r363,%r364,%r365}; + // end inline asm + add.s32 %r808, %r310, 39360; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r810,%r811,%r814,%r815}, [%r808]; + // end inline asm + add.s32 %r809, %r310, 56768; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r812,%r813,%r816,%r817}, [%r809]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r372,%r373,%r374,%r375}, {%r776,%r777,%r778,%r779}, {%r810,%r811}, {%r372,%r373,%r374,%r375}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r372,%r373,%r374,%r375}, {%r749,%r756,%r763,%r770}, {%r812,%r813}, {%r372,%r373,%r374,%r375}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r372,%r373,%r374,%r375}, {%r749,%r756,%r763,%r770}, {%r810,%r811}, {%r372,%r373,%r374,%r375}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r380,%r381,%r382,%r383}, {%r776,%r777,%r778,%r779}, {%r814,%r815}, {%r380,%r381,%r382,%r383}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r380,%r381,%r382,%r383}, {%r749,%r756,%r763,%r770}, {%r816,%r817}, {%r380,%r381,%r382,%r383}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r380,%r381,%r382,%r383}, {%r749,%r756,%r763,%r770}, {%r814,%r815}, {%r380,%r381,%r382,%r383}; + // end inline asm + mul.f32 %r818, %r1977, %r1066; + mul.f32 %r819, %r1978, %r1066; + // begin inline asm + { cvt.rn.f16x2.f32 %r821, %r819, %r818; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r821; + cvt.f32.f16 %r820, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r821; + cvt.f32.f16 %r822, high;} + + // end inline asm + sub.f32 %r823, %r818, %r820; + sub.f32 %r824, %r819, %r822; + // begin inline asm + { cvt.rn.f16x2.f32 %r848, %r824, %r823; } + + // end inline asm + mul.f32 %r825, %r1979, %r1066; + mul.f32 %r826, %r1980, %r1066; + // begin inline asm + { cvt.rn.f16x2.f32 %r828, %r826, %r825; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r828; + cvt.f32.f16 %r827, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r828; + cvt.f32.f16 %r829, high;} + + // end inline asm + sub.f32 %r830, %r825, %r827; + sub.f32 %r831, %r826, %r829; + // begin inline asm + { cvt.rn.f16x2.f32 %r849, %r831, %r830; } + + // end inline asm + mul.f32 %r832, %r1981, %r1066; + mul.f32 %r833, %r1982, %r1066; + // begin inline asm + { cvt.rn.f16x2.f32 %r835, %r833, %r832; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r835; + cvt.f32.f16 %r834, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r835; + cvt.f32.f16 %r836, high;} + + // end inline asm + sub.f32 %r837, %r832, %r834; + sub.f32 %r838, %r833, %r836; + // begin inline asm + { cvt.rn.f16x2.f32 %r850, %r838, %r837; } + + // end inline asm + mul.f32 %r839, %r1983, %r1066; + mul.f32 %r840, %r1984, %r1066; + // begin inline asm + { cvt.rn.f16x2.f32 %r842, %r840, %r839; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r842; + cvt.f32.f16 %r841, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r842; + cvt.f32.f16 %r843, high;} + + // end inline asm + sub.f32 %r844, %r839, %r841; + sub.f32 %r845, %r840, %r843; + // begin inline asm + { cvt.rn.f16x2.f32 %r851, %r845, %r844; } + + // end inline asm + add.s32 %r846, %r310, 224; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r852,%r853,%r856,%r857}, [%r846]; + // end inline asm + add.s32 %r847, %r310, 17632; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r854,%r855,%r858,%r859}, [%r847]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r318,%r319,%r320,%r321}, {%r848,%r849,%r850,%r851}, {%r852,%r853}, {%r318,%r319,%r320,%r321}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r318,%r319,%r320,%r321}, {%r821,%r828,%r835,%r842}, {%r854,%r855}, {%r318,%r319,%r320,%r321}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r318,%r319,%r320,%r321}, {%r821,%r828,%r835,%r842}, {%r852,%r853}, {%r318,%r319,%r320,%r321}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r326,%r327,%r328,%r329}, {%r848,%r849,%r850,%r851}, {%r856,%r857}, {%r326,%r327,%r328,%r329}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r326,%r327,%r328,%r329}, {%r821,%r828,%r835,%r842}, {%r858,%r859}, {%r326,%r327,%r328,%r329}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r326,%r327,%r328,%r329}, {%r821,%r828,%r835,%r842}, {%r856,%r857}, {%r326,%r327,%r328,%r329}; + // end inline asm + add.s32 %r860, %r310, 35040; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r862,%r863,%r866,%r867}, [%r860]; + // end inline asm + add.s32 %r861, %r310, 52448; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r864,%r865,%r868,%r869}, [%r861]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r336,%r337,%r338,%r339}, {%r848,%r849,%r850,%r851}, {%r862,%r863}, {%r336,%r337,%r338,%r339}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r336,%r337,%r338,%r339}, {%r821,%r828,%r835,%r842}, {%r864,%r865}, {%r336,%r337,%r338,%r339}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r336,%r337,%r338,%r339}, {%r821,%r828,%r835,%r842}, {%r862,%r863}, {%r336,%r337,%r338,%r339}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r344,%r345,%r346,%r347}, {%r848,%r849,%r850,%r851}, {%r866,%r867}, {%r344,%r345,%r346,%r347}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r344,%r345,%r346,%r347}, {%r821,%r828,%r835,%r842}, {%r868,%r869}, {%r344,%r345,%r346,%r347}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r344,%r345,%r346,%r347}, {%r821,%r828,%r835,%r842}, {%r866,%r867}, {%r344,%r345,%r346,%r347}; + // end inline asm + add.s32 %r870, %r310, 4576; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r872,%r873,%r876,%r877}, [%r870]; + // end inline asm + add.s32 %r871, %r310, 21984; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r874,%r875,%r878,%r879}, [%r871]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r354,%r355,%r356,%r357}, {%r848,%r849,%r850,%r851}, {%r872,%r873}, {%r354,%r355,%r356,%r357}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r354,%r355,%r356,%r357}, {%r821,%r828,%r835,%r842}, {%r874,%r875}, {%r354,%r355,%r356,%r357}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r354,%r355,%r356,%r357}, {%r821,%r828,%r835,%r842}, {%r872,%r873}, {%r354,%r355,%r356,%r357}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r362,%r363,%r364,%r365}, {%r848,%r849,%r850,%r851}, {%r876,%r877}, {%r362,%r363,%r364,%r365}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r362,%r363,%r364,%r365}, {%r821,%r828,%r835,%r842}, {%r878,%r879}, {%r362,%r363,%r364,%r365}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r362,%r363,%r364,%r365}, {%r821,%r828,%r835,%r842}, {%r876,%r877}, {%r362,%r363,%r364,%r365}; + // end inline asm + add.s32 %r880, %r310, 39392; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r882,%r883,%r886,%r887}, [%r880]; + // end inline asm + add.s32 %r881, %r310, 56800; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r884,%r885,%r888,%r889}, [%r881]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r372,%r373,%r374,%r375}, {%r848,%r849,%r850,%r851}, {%r882,%r883}, {%r372,%r373,%r374,%r375}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r372,%r373,%r374,%r375}, {%r821,%r828,%r835,%r842}, {%r884,%r885}, {%r372,%r373,%r374,%r375}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r372,%r373,%r374,%r375}, {%r821,%r828,%r835,%r842}, {%r882,%r883}, {%r372,%r373,%r374,%r375}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r380,%r381,%r382,%r383}, {%r848,%r849,%r850,%r851}, {%r886,%r887}, {%r380,%r381,%r382,%r383}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r380,%r381,%r382,%r383}, {%r821,%r828,%r835,%r842}, {%r888,%r889}, {%r380,%r381,%r382,%r383}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r380,%r381,%r382,%r383}, {%r821,%r828,%r835,%r842}, {%r886,%r887}, {%r380,%r381,%r382,%r383}; + // end inline asm + sub.s32 %r1070, 998244352, %r1065; + neg.f32 %r1071, %r1070; + or.b32 %r1072, %r922, %r74; + shl.b32 %r1073, %r1072, 4; + add.s32 %r1074, %r1069, %r1073; + add.s32 %r1516, %r1074, 96768; + // begin inline asm + ld.shared.v4.f32 {%r890,%r891,%r892,%r893}, [%r1516]; + // end inline asm + add.s32 %r1521, %r1074, 96784; + // begin inline asm + ld.shared.v4.f32 {%r894,%r895,%r896,%r897}, [%r1521]; + // end inline asm + mul.f32 %r1075, %r891, %r1071; + ld.shared.b32 %r1076, [%r56+69632]; + fma.rn.f32 %r1077, %r1075, %r318, %r1076; + mul.f32 %r76, %r890, %r1077; + mul.f32 %r1078, %r895, %r1071; + ld.shared.b32 %r1079, [%r56+70160]; + fma.rn.f32 %r1080, %r1078, %r319, %r1079; + mul.f32 %r77, %r894, %r1080; + ld.shared.b32 %r1081, [%r56+69664]; + fma.rn.f32 %r1082, %r1075, %r320, %r1081; + mul.f32 %r78, %r890, %r1082; + ld.shared.b32 %r1083, [%r56+70192]; + fma.rn.f32 %r1084, %r1078, %r321, %r1083; + mul.f32 %r79, %r894, %r1084; + add.s32 %r1526, %r1074, 96896; + // begin inline asm + ld.shared.v4.f32 {%r898,%r899,%r900,%r901}, [%r1526]; + // end inline asm + add.s32 %r1531, %r1074, 96912; + // begin inline asm + ld.shared.v4.f32 {%r902,%r903,%r904,%r905}, [%r1531]; + // end inline asm + mul.f32 %r1085, %r899, %r1071; + ld.shared.b32 %r1086, [%r56+73856]; + fma.rn.f32 %r1087, %r1085, %r326, %r1086; + mul.f32 %r80, %r898, %r1087; + mul.f32 %r1088, %r903, %r1071; + ld.shared.b32 %r1089, [%r56+74384]; + fma.rn.f32 %r1090, %r1088, %r327, %r1089; + mul.f32 %r81, %r902, %r1090; + ld.shared.b32 %r1091, [%r56+73888]; + fma.rn.f32 %r1092, %r1085, %r328, %r1091; + mul.f32 %r82, %r898, %r1092; + ld.shared.b32 %r1093, [%r56+74416]; + fma.rn.f32 %r1094, %r1088, %r329, %r1093; + mul.f32 %r83, %r902, %r1094; + add.s32 %r1536, %r1074, 97024; + // begin inline asm + ld.shared.v4.f32 {%r906,%r907,%r908,%r909}, [%r1536]; + // end inline asm + add.s32 %r1541, %r1074, 97040; + // begin inline asm + ld.shared.v4.f32 {%r910,%r911,%r912,%r913}, [%r1541]; + // end inline asm + mul.f32 %r1095, %r907, %r1071; + ld.shared.b32 %r1096, [%r56+78080]; + fma.rn.f32 %r1097, %r1095, %r354, %r1096; + mul.f32 %r84, %r906, %r1097; + mul.f32 %r1098, %r911, %r1071; + ld.shared.b32 %r1099, [%r56+78608]; + fma.rn.f32 %r1100, %r1098, %r355, %r1099; + mul.f32 %r85, %r910, %r1100; + ld.shared.b32 %r1101, [%r56+78112]; + fma.rn.f32 %r1102, %r1095, %r356, %r1101; + mul.f32 %r86, %r906, %r1102; + ld.shared.b32 %r1103, [%r56+78640]; + fma.rn.f32 %r1104, %r1098, %r357, %r1103; + mul.f32 %r87, %r910, %r1104; + add.s32 %r1546, %r1074, 97152; + // begin inline asm + ld.shared.v4.f32 {%r914,%r915,%r916,%r917}, [%r1546]; + // end inline asm + add.s32 %r1551, %r1074, 97168; + // begin inline asm + ld.shared.v4.f32 {%r918,%r919,%r920,%r921}, [%r1551]; + // end inline asm + mul.f32 %r1105, %r915, %r1071; + ld.shared.b32 %r1106, [%r56+82304]; + fma.rn.f32 %r1107, %r1105, %r362, %r1106; + mul.f32 %r88, %r914, %r1107; + mul.f32 %r1108, %r919, %r1071; + ld.shared.b32 %r1109, [%r56+82832]; + fma.rn.f32 %r1110, %r1108, %r363, %r1109; + mul.f32 %r89, %r918, %r1110; + ld.shared.b32 %r1111, [%r56+82336]; + fma.rn.f32 %r1112, %r1105, %r364, %r1111; + mul.f32 %r90, %r914, %r1112; + ld.shared.b32 %r1113, [%r56+82864]; + fma.rn.f32 %r1114, %r1108, %r365, %r1113; + mul.f32 %r91, %r918, %r1114; + abs.f32 %r1115, %r76; + max.f32 %r1116, %r1115, 0f00000000; + abs.f32 %r1117, %r77; + max.f32 %r1118, %r1117, 0f00000000; + abs.f32 %r1119, %r78; + max.f32 %r1120, %r1119, 0f00000000; + abs.f32 %r1121, %r79; + max.f32 %r1122, %r1121, 0f00000000; + abs.f32 %r1123, %r80; + max.f32 %r1124, %r1116, %r1123; + abs.f32 %r1125, %r81; + max.f32 %r1126, %r1118, %r1125; + abs.f32 %r1127, %r82; + max.f32 %r1128, %r1120, %r1127; + abs.f32 %r1129, %r83; + max.f32 %r1130, %r1122, %r1129; + abs.f32 %r1131, %r84; + max.f32 %r1132, %r1124, %r1131; + abs.f32 %r1133, %r85; + max.f32 %r1134, %r1126, %r1133; + abs.f32 %r1135, %r86; + max.f32 %r1136, %r1128, %r1135; + abs.f32 %r1137, %r87; + max.f32 %r1138, %r1130, %r1137; + abs.f32 %r1139, %r88; + max.f32 %r1140, %r1132, %r1139; + abs.f32 %r1141, %r89; + max.f32 %r1142, %r1134, %r1141; + abs.f32 %r1143, %r90; + max.f32 %r1144, %r1136, %r1143; + abs.f32 %r1145, %r91; + max.f32 %r1146, %r1138, %r1145; + max.f32 %r1147, %r1140, %r1142; + max.f32 %r1148, %r1144, %r1146; + max.f32 %r1149, %r1147, %r1148; + redux.sync.max.u32 %r92, %r1149, %r1058; + and.b32 %r1150, %r92, 2147483647; + setp.eq.b32 %p25, %r1150, 0; + @%p25 bra $L__BB1_42; + shr.s32 %r1151, %r92, 23; + sub.s32 %r1152, 141, %r1151; + max.s32 %r1153, %r1152, -40; + min.s32 %r1154, %r1153, 40; + shl.b32 %r1988, %r1154, 23; +$L__BB1_42: + add.s32 %r1407, %r1988, 1065353216; + mul.f32 %r1155, %r76, %r1407; + mul.f32 %r1156, %r77, %r1407; + // begin inline asm + { cvt.rn.f16x2.f32 %r1158, %r1156, %r1155; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1158; + cvt.f32.f16 %r1157, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1158; + cvt.f32.f16 %r1159, high;} + + // end inline asm + sub.f32 %r1160, %r1155, %r1157; + sub.f32 %r1161, %r1156, %r1159; + // begin inline asm + { cvt.rn.f16x2.f32 %r1185, %r1161, %r1160; } + + // end inline asm + mul.f32 %r1162, %r78, %r1407; + mul.f32 %r1163, %r79, %r1407; + // begin inline asm + { cvt.rn.f16x2.f32 %r1165, %r1163, %r1162; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1165; + cvt.f32.f16 %r1164, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1165; + cvt.f32.f16 %r1166, high;} + + // end inline asm + sub.f32 %r1167, %r1162, %r1164; + sub.f32 %r1168, %r1163, %r1166; + // begin inline asm + { cvt.rn.f16x2.f32 %r1186, %r1168, %r1167; } + + // end inline asm + mul.f32 %r1169, %r80, %r1407; + mul.f32 %r1170, %r81, %r1407; + // begin inline asm + { cvt.rn.f16x2.f32 %r1172, %r1170, %r1169; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1172; + cvt.f32.f16 %r1171, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1172; + cvt.f32.f16 %r1173, high;} + + // end inline asm + sub.f32 %r1174, %r1169, %r1171; + sub.f32 %r1175, %r1170, %r1173; + // begin inline asm + { cvt.rn.f16x2.f32 %r1187, %r1175, %r1174; } + + // end inline asm + mul.f32 %r1176, %r82, %r1407; + mul.f32 %r1177, %r83, %r1407; + // begin inline asm + { cvt.rn.f16x2.f32 %r1179, %r1177, %r1176; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1179; + cvt.f32.f16 %r1178, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1179; + cvt.f32.f16 %r1180, high;} + + // end inline asm + sub.f32 %r1181, %r1176, %r1178; + sub.f32 %r1182, %r1177, %r1180; + // begin inline asm + { cvt.rn.f16x2.f32 %r1188, %r1182, %r1181; } + + // end inline asm + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r1189,%r1190,%r1197,%r1198}, [%r1183]; + // end inline asm + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r1195,%r1196,%r1203,%r1204}, [%r1184]; + // end inline asm + mov.b32 %r1217, 0; + mov.b32 %r1191, %r1217; + mov.b32 %r1192, %r1217; + mov.b32 %r1193, %r1217; + mov.b32 %r1194, %r1217; + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1191,%r1192,%r1193,%r1194}, {%r1185,%r1186,%r1187,%r1188}, {%r1189,%r1190}, {%r1191,%r1192,%r1193,%r1194}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1191,%r1192,%r1193,%r1194}, {%r1158,%r1165,%r1172,%r1179}, {%r1195,%r1196}, {%r1191,%r1192,%r1193,%r1194}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1191,%r1192,%r1193,%r1194}, {%r1158,%r1165,%r1172,%r1179}, {%r1189,%r1190}, {%r1191,%r1192,%r1193,%r1194}; + // end inline asm + mov.b32 %r1199, %r1217; + mov.b32 %r1200, %r1217; + mov.b32 %r1201, %r1217; + mov.b32 %r1202, %r1217; + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1199,%r1200,%r1201,%r1202}, {%r1185,%r1186,%r1187,%r1188}, {%r1197,%r1198}, {%r1199,%r1200,%r1201,%r1202}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1199,%r1200,%r1201,%r1202}, {%r1158,%r1165,%r1172,%r1179}, {%r1203,%r1204}, {%r1199,%r1200,%r1201,%r1202}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1199,%r1200,%r1201,%r1202}, {%r1158,%r1165,%r1172,%r1179}, {%r1197,%r1198}, {%r1199,%r1200,%r1201,%r1202}; + // end inline asm + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r1207,%r1208,%r1215,%r1216}, [%r1205]; + // end inline asm + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r1213,%r1214,%r1221,%r1222}, [%r1206]; + // end inline asm + mov.b32 %r1209, %r1217; + mov.b32 %r1210, %r1217; + mov.b32 %r1211, %r1217; + mov.b32 %r1212, %r1217; + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1209,%r1210,%r1211,%r1212}, {%r1185,%r1186,%r1187,%r1188}, {%r1207,%r1208}, {%r1209,%r1210,%r1211,%r1212}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1209,%r1210,%r1211,%r1212}, {%r1158,%r1165,%r1172,%r1179}, {%r1213,%r1214}, {%r1209,%r1210,%r1211,%r1212}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1209,%r1210,%r1211,%r1212}, {%r1158,%r1165,%r1172,%r1179}, {%r1207,%r1208}, {%r1209,%r1210,%r1211,%r1212}; + // end inline asm + mov.b32 %r1218, %r1217; + mov.b32 %r1219, %r1217; + mov.b32 %r1220, %r1217; + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1217,%r1218,%r1219,%r1220}, {%r1185,%r1186,%r1187,%r1188}, {%r1215,%r1216}, {%r1217,%r1218,%r1219,%r1220}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1217,%r1218,%r1219,%r1220}, {%r1158,%r1165,%r1172,%r1179}, {%r1221,%r1222}, {%r1217,%r1218,%r1219,%r1220}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1217,%r1218,%r1219,%r1220}, {%r1158,%r1165,%r1172,%r1179}, {%r1215,%r1216}, {%r1217,%r1218,%r1219,%r1220}; + // end inline asm + mul.f32 %r1223, %r84, %r1407; + mul.f32 %r1224, %r85, %r1407; + // begin inline asm + { cvt.rn.f16x2.f32 %r1226, %r1224, %r1223; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1226; + cvt.f32.f16 %r1225, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1226; + cvt.f32.f16 %r1227, high;} + + // end inline asm + sub.f32 %r1228, %r1223, %r1225; + sub.f32 %r1229, %r1224, %r1227; + // begin inline asm + { cvt.rn.f16x2.f32 %r1253, %r1229, %r1228; } + + // end inline asm + mul.f32 %r1230, %r86, %r1407; + mul.f32 %r1231, %r87, %r1407; + // begin inline asm + { cvt.rn.f16x2.f32 %r1233, %r1231, %r1230; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1233; + cvt.f32.f16 %r1232, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1233; + cvt.f32.f16 %r1234, high;} + + // end inline asm + sub.f32 %r1235, %r1230, %r1232; + sub.f32 %r1236, %r1231, %r1234; + // begin inline asm + { cvt.rn.f16x2.f32 %r1254, %r1236, %r1235; } + + // end inline asm + mul.f32 %r1237, %r88, %r1407; + mul.f32 %r1238, %r89, %r1407; + // begin inline asm + { cvt.rn.f16x2.f32 %r1240, %r1238, %r1237; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1240; + cvt.f32.f16 %r1239, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1240; + cvt.f32.f16 %r1241, high;} + + // end inline asm + sub.f32 %r1242, %r1237, %r1239; + sub.f32 %r1243, %r1238, %r1241; + // begin inline asm + { cvt.rn.f16x2.f32 %r1255, %r1243, %r1242; } + + // end inline asm + mul.f32 %r1244, %r90, %r1407; + mul.f32 %r1245, %r91, %r1407; + // begin inline asm + { cvt.rn.f16x2.f32 %r1247, %r1245, %r1244; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1247; + cvt.f32.f16 %r1246, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1247; + cvt.f32.f16 %r1248, high;} + + // end inline asm + sub.f32 %r1249, %r1244, %r1246; + sub.f32 %r1250, %r1245, %r1248; + // begin inline asm + { cvt.rn.f16x2.f32 %r1256, %r1250, %r1249; } + + // end inline asm + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r1257,%r1258,%r1261,%r1262}, [%r1251]; + // end inline asm + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r1259,%r1260,%r1263,%r1264}, [%r1252]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1209,%r1210,%r1211,%r1212}, {%r1253,%r1254,%r1255,%r1256}, {%r1257,%r1258}, {%r1209,%r1210,%r1211,%r1212}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1209,%r1210,%r1211,%r1212}, {%r1226,%r1233,%r1240,%r1247}, {%r1259,%r1260}, {%r1209,%r1210,%r1211,%r1212}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1209,%r1210,%r1211,%r1212}, {%r1226,%r1233,%r1240,%r1247}, {%r1257,%r1258}, {%r1209,%r1210,%r1211,%r1212}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1217,%r1218,%r1219,%r1220}, {%r1253,%r1254,%r1255,%r1256}, {%r1261,%r1262}, {%r1217,%r1218,%r1219,%r1220}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1217,%r1218,%r1219,%r1220}, {%r1226,%r1233,%r1240,%r1247}, {%r1263,%r1264}, {%r1217,%r1218,%r1219,%r1220}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1217,%r1218,%r1219,%r1220}, {%r1226,%r1233,%r1240,%r1247}, {%r1261,%r1262}, {%r1217,%r1218,%r1219,%r1220}; + // end inline asm + sub.s32 %r1408, 1065353216, %r1988; + shl.b32 %r1409, %r68, 2; + mov.b32 %r1410, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r1411, %r1410, %r1409; + ld.shared.b32 %r1412, [%r1411+97792]; + mul.f32 %r1413, %r1412, %r1408; + mul.f32 %r93, %r1413, %r1191; + mul.f32 %r94, %r1413, %r1192; + mul.f32 %r95, %r1413, %r1193; + mul.f32 %r96, %r1413, %r1194; + mul.f32 %r97, %r1413, %r1199; + mul.f32 %r98, %r1413, %r1200; + mul.f32 %r99, %r1413, %r1201; + mul.f32 %r100, %r1413, %r1202; + mul.f32 %r101, %r1413, %r1209; + mul.f32 %r102, %r1413, %r1210; + mul.f32 %r103, %r1413, %r1211; + mul.f32 %r104, %r1413, %r1212; + mul.f32 %r105, %r1413, %r1217; + mul.f32 %r106, %r1413, %r1218; + mul.f32 %r107, %r1413, %r1219; + mul.f32 %r108, %r1413, %r1220; + abs.f32 %r1414, %r93; + max.f32 %r1415, %r1414, 0f00000000; + abs.f32 %r1416, %r94; + max.f32 %r1417, %r1416, 0f00000000; + abs.f32 %r1418, %r95; + max.f32 %r1419, %r1418, 0f00000000; + abs.f32 %r1420, %r96; + max.f32 %r1421, %r1420, 0f00000000; + abs.f32 %r1422, %r97; + max.f32 %r1423, %r1415, %r1422; + abs.f32 %r1424, %r98; + max.f32 %r1425, %r1417, %r1424; + abs.f32 %r1426, %r99; + max.f32 %r1427, %r1419, %r1426; + abs.f32 %r1428, %r100; + max.f32 %r1429, %r1421, %r1428; + abs.f32 %r1430, %r101; + max.f32 %r1431, %r1423, %r1430; + abs.f32 %r1432, %r102; + max.f32 %r1433, %r1425, %r1432; + abs.f32 %r1434, %r103; + max.f32 %r1435, %r1427, %r1434; + abs.f32 %r1436, %r104; + max.f32 %r1437, %r1429, %r1436; + abs.f32 %r1438, %r105; + max.f32 %r1439, %r1431, %r1438; + abs.f32 %r1440, %r106; + max.f32 %r1441, %r1433, %r1440; + abs.f32 %r1442, %r107; + max.f32 %r1443, %r1435, %r1442; + abs.f32 %r1444, %r108; + max.f32 %r1445, %r1437, %r1444; + max.f32 %r1446, %r1439, %r1441; + max.f32 %r1447, %r1443, %r1445; + max.f32 %r1448, %r1446, %r1447; + mov.b32 %r1449, -1; + redux.sync.max.u32 %r1450, %r1448, %r1449; + and.b32 %r1451, %r1450, 2147483647; + setp.eq.b32 %p26, %r1451, 0; + shr.s32 %r1452, %r1450, 23; + sub.s32 %r1453, 141, %r1452; + max.s32 %r1454, %r1453, -40; + min.s32 %r1455, %r1454, 40; + selp.b32 %r1456, 0, %r1455, %p26; + shl.b32 %r1457, %r1456, 23; + add.s32 %r109, %r1457, 1065353216; + add.s32 %r110, %r1457, 1132462080; + sub.s32 %r111, 998244352, %r1457; + sub.s32 %r1458, %r1456, %r75; + shl.b32 %r1459, %r1458, 23; + add.s32 %r1460, %r1459, 1065353216; + // begin inline asm + ld.shared.v4.f32 {%r1265,%r1266,%r1267,%r1268}, [%r1516]; + // end inline asm + mul.f32 %r1461, %r1266, %r1460; + // begin inline asm + ld.shared.v4.f32 {%r1269,%r1270,%r1271,%r1272}, [%r1521]; + // end inline asm + mul.f32 %r1462, %r1270, %r1460; + mul.f32 %r1333, %r336, %r1461; + mul.f32 %r1334, %r1462, %r337; + mul.f32 %r1335, %r1461, %r338; + mul.f32 %r1336, %r1462, %r339; + // begin inline asm + ld.shared.v4.f32 {%r1273,%r1274,%r1275,%r1276}, [%r1526]; + // end inline asm + mul.f32 %r1463, %r1274, %r1460; + // begin inline asm + ld.shared.v4.f32 {%r1277,%r1278,%r1279,%r1280}, [%r1531]; + // end inline asm + mul.f32 %r1464, %r1278, %r1460; + mul.f32 %r1341, %r344, %r1463; + mul.f32 %r1342, %r1464, %r345; + mul.f32 %r1343, %r1463, %r346; + mul.f32 %r1344, %r1464, %r347; + // begin inline asm + ld.shared.v4.f32 {%r1281,%r1282,%r1283,%r1284}, [%r1536]; + // end inline asm + mul.f32 %r1465, %r1282, %r1460; + // begin inline asm + ld.shared.v4.f32 {%r1285,%r1286,%r1287,%r1288}, [%r1541]; + // end inline asm + mul.f32 %r1466, %r1286, %r1460; + mul.f32 %r1351, %r372, %r1465; + mul.f32 %r1352, %r1466, %r373; + mul.f32 %r1353, %r1465, %r374; + mul.f32 %r1354, %r1466, %r375; + // begin inline asm + ld.shared.v4.f32 {%r1289,%r1290,%r1291,%r1292}, [%r1546]; + // end inline asm + mul.f32 %r1467, %r1290, %r1460; + // begin inline asm + ld.shared.v4.f32 {%r1293,%r1294,%r1295,%r1296}, [%r1551]; + // end inline asm + mul.f32 %r1468, %r1294, %r1460; + mul.f32 %r1359, %r380, %r1467; + mul.f32 %r1360, %r1468, %r381; + mul.f32 %r1361, %r1467, %r382; + mul.f32 %r1362, %r1468, %r383; + mul.f32 %r1297, %r93, %r109; + mul.f32 %r1298, %r94, %r109; + // begin inline asm + { cvt.rn.f16x2.f32 %r1300, %r1298, %r1297; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1300; + cvt.f32.f16 %r1299, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1300; + cvt.f32.f16 %r1301, high;} + + // end inline asm + sub.f32 %r1302, %r1297, %r1299; + sub.f32 %r1303, %r1298, %r1301; + // begin inline asm + { cvt.rn.f16x2.f32 %r1327, %r1303, %r1302; } + + // end inline asm + mul.f32 %r1304, %r95, %r109; + mul.f32 %r1305, %r96, %r109; + // begin inline asm + { cvt.rn.f16x2.f32 %r1307, %r1305, %r1304; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1307; + cvt.f32.f16 %r1306, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1307; + cvt.f32.f16 %r1308, high;} + + // end inline asm + sub.f32 %r1309, %r1304, %r1306; + sub.f32 %r1310, %r1305, %r1308; + // begin inline asm + { cvt.rn.f16x2.f32 %r1328, %r1310, %r1309; } + + // end inline asm + mul.f32 %r1311, %r97, %r109; + mul.f32 %r1312, %r98, %r109; + // begin inline asm + { cvt.rn.f16x2.f32 %r1314, %r1312, %r1311; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1314; + cvt.f32.f16 %r1313, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1314; + cvt.f32.f16 %r1315, high;} + + // end inline asm + sub.f32 %r1316, %r1311, %r1313; + sub.f32 %r1317, %r1312, %r1315; + // begin inline asm + { cvt.rn.f16x2.f32 %r1329, %r1317, %r1316; } + + // end inline asm + mul.f32 %r1318, %r99, %r109; + mul.f32 %r1319, %r100, %r109; + // begin inline asm + { cvt.rn.f16x2.f32 %r1321, %r1319, %r1318; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1321; + cvt.f32.f16 %r1320, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1321; + cvt.f32.f16 %r1322, high;} + + // end inline asm + sub.f32 %r1323, %r1318, %r1320; + sub.f32 %r1324, %r1319, %r1322; + // begin inline asm + { cvt.rn.f16x2.f32 %r1330, %r1324, %r1323; } + + // end inline asm + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r1331,%r1332,%r1339,%r1340}, [%r1325]; + // end inline asm + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r1337,%r1338,%r1345,%r1346}, [%r1326]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1333,%r1334,%r1335,%r1336}, {%r1327,%r1328,%r1329,%r1330}, {%r1331,%r1332}, {%r1333,%r1334,%r1335,%r1336}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1333,%r1334,%r1335,%r1336}, {%r1300,%r1307,%r1314,%r1321}, {%r1337,%r1338}, {%r1333,%r1334,%r1335,%r1336}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1333,%r1334,%r1335,%r1336}, {%r1300,%r1307,%r1314,%r1321}, {%r1331,%r1332}, {%r1333,%r1334,%r1335,%r1336}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1341,%r1342,%r1343,%r1344}, {%r1327,%r1328,%r1329,%r1330}, {%r1339,%r1340}, {%r1341,%r1342,%r1343,%r1344}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1341,%r1342,%r1343,%r1344}, {%r1300,%r1307,%r1314,%r1321}, {%r1345,%r1346}, {%r1341,%r1342,%r1343,%r1344}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1341,%r1342,%r1343,%r1344}, {%r1300,%r1307,%r1314,%r1321}, {%r1339,%r1340}, {%r1341,%r1342,%r1343,%r1344}; + // end inline asm + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r1349,%r1350,%r1357,%r1358}, [%r1347]; + // end inline asm + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r1355,%r1356,%r1363,%r1364}, [%r1348]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1351,%r1352,%r1353,%r1354}, {%r1327,%r1328,%r1329,%r1330}, {%r1349,%r1350}, {%r1351,%r1352,%r1353,%r1354}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1351,%r1352,%r1353,%r1354}, {%r1300,%r1307,%r1314,%r1321}, {%r1355,%r1356}, {%r1351,%r1352,%r1353,%r1354}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1351,%r1352,%r1353,%r1354}, {%r1300,%r1307,%r1314,%r1321}, {%r1349,%r1350}, {%r1351,%r1352,%r1353,%r1354}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1359,%r1360,%r1361,%r1362}, {%r1327,%r1328,%r1329,%r1330}, {%r1357,%r1358}, {%r1359,%r1360,%r1361,%r1362}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1359,%r1360,%r1361,%r1362}, {%r1300,%r1307,%r1314,%r1321}, {%r1363,%r1364}, {%r1359,%r1360,%r1361,%r1362}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1359,%r1360,%r1361,%r1362}, {%r1300,%r1307,%r1314,%r1321}, {%r1357,%r1358}, {%r1359,%r1360,%r1361,%r1362}; + // end inline asm + mul.f32 %r1365, %r101, %r109; + mul.f32 %r1366, %r102, %r109; + // begin inline asm + { cvt.rn.f16x2.f32 %r1368, %r1366, %r1365; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1368; + cvt.f32.f16 %r1367, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1368; + cvt.f32.f16 %r1369, high;} + + // end inline asm + sub.f32 %r1370, %r1365, %r1367; + sub.f32 %r1371, %r1366, %r1369; + // begin inline asm + { cvt.rn.f16x2.f32 %r1395, %r1371, %r1370; } + + // end inline asm + mul.f32 %r1372, %r103, %r109; + mul.f32 %r1373, %r104, %r109; + // begin inline asm + { cvt.rn.f16x2.f32 %r1375, %r1373, %r1372; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1375; + cvt.f32.f16 %r1374, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1375; + cvt.f32.f16 %r1376, high;} + + // end inline asm + sub.f32 %r1377, %r1372, %r1374; + sub.f32 %r1378, %r1373, %r1376; + // begin inline asm + { cvt.rn.f16x2.f32 %r1396, %r1378, %r1377; } + + // end inline asm + mul.f32 %r1379, %r105, %r109; + mul.f32 %r1380, %r106, %r109; + // begin inline asm + { cvt.rn.f16x2.f32 %r1382, %r1380, %r1379; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1382; + cvt.f32.f16 %r1381, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1382; + cvt.f32.f16 %r1383, high;} + + // end inline asm + sub.f32 %r1384, %r1379, %r1381; + sub.f32 %r1385, %r1380, %r1383; + // begin inline asm + { cvt.rn.f16x2.f32 %r1397, %r1385, %r1384; } + + // end inline asm + mul.f32 %r1386, %r107, %r109; + mul.f32 %r1387, %r108, %r109; + // begin inline asm + { cvt.rn.f16x2.f32 %r1389, %r1387, %r1386; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1389; + cvt.f32.f16 %r1388, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1389; + cvt.f32.f16 %r1390, high;} + + // end inline asm + sub.f32 %r1391, %r1386, %r1388; + sub.f32 %r1392, %r1387, %r1390; + // begin inline asm + { cvt.rn.f16x2.f32 %r1398, %r1392, %r1391; } + + // end inline asm + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r1399,%r1400,%r1403,%r1404}, [%r1393]; + // end inline asm + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r1401,%r1402,%r1405,%r1406}, [%r1394]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1351,%r1352,%r1353,%r1354}, {%r1395,%r1396,%r1397,%r1398}, {%r1399,%r1400}, {%r1351,%r1352,%r1353,%r1354}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1351,%r1352,%r1353,%r1354}, {%r1368,%r1375,%r1382,%r1389}, {%r1401,%r1402}, {%r1351,%r1352,%r1353,%r1354}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1351,%r1352,%r1353,%r1354}, {%r1368,%r1375,%r1382,%r1389}, {%r1399,%r1400}, {%r1351,%r1352,%r1353,%r1354}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1359,%r1360,%r1361,%r1362}, {%r1395,%r1396,%r1397,%r1398}, {%r1403,%r1404}, {%r1359,%r1360,%r1361,%r1362}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1359,%r1360,%r1361,%r1362}, {%r1368,%r1375,%r1382,%r1389}, {%r1405,%r1406}, {%r1359,%r1360,%r1361,%r1362}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1359,%r1360,%r1361,%r1362}, {%r1368,%r1375,%r1382,%r1389}, {%r1403,%r1404}, {%r1359,%r1360,%r1361,%r1362}; + // end inline asm + setp.ge.s32 %p27, %r922, %r69; + add.s64 %rd135, %rd22, %rd17; + mad.lo.s64 %rd136, %rd135, 6144, %rd7; + shl.b64 %rd137, %rd136, 2; + add.s64 %rd24, %rd21, %rd137; + @%p27 bra $L__BB1_44; + mul.f32 %r1469, %r1333, %r111; + mul.f32 %r1470, %r53, %r1469; + st.global.b32 [%rd24], %r1470; +$L__BB1_44: + setp.ge.s32 %p28, %r60, %r69; + @%p28 bra $L__BB1_46; + mul.f32 %r1471, %r1334, %r111; + mul.f32 %r1472, %r53, %r1471; + st.global.b32 [%rd24+24576], %r1472; +$L__BB1_46: + @%p27 bra $L__BB1_48; + mul.f32 %r1473, %r1335, %r111; + mul.f32 %r1474, %r53, %r1473; + st.global.b32 [%rd24+32], %r1474; +$L__BB1_48: + @%p28 bra $L__BB1_50; + mul.f32 %r1475, %r1336, %r111; + mul.f32 %r1476, %r53, %r1475; + st.global.b32 [%rd24+24608], %r1476; +$L__BB1_50: + setp.ge.s32 %p29, %r57, %r69; + @%p29 bra $L__BB1_52; + mul.f32 %r1477, %r1341, %r111; + mul.f32 %r1478, %r53, %r1477; + st.global.b32 [%rd24+196608], %r1478; +$L__BB1_52: + setp.ge.s32 %p30, %r61, %r69; + @%p30 bra $L__BB1_54; + mul.f32 %r1479, %r1342, %r111; + mul.f32 %r1480, %r53, %r1479; + st.global.b32 [%rd24+221184], %r1480; +$L__BB1_54: + @%p29 bra $L__BB1_56; + mul.f32 %r1481, %r1343, %r111; + mul.f32 %r1482, %r53, %r1481; + st.global.b32 [%rd24+196640], %r1482; +$L__BB1_56: + @%p30 bra $L__BB1_58; + mul.f32 %r1483, %r1344, %r111; + mul.f32 %r1484, %r53, %r1483; + st.global.b32 [%rd24+221216], %r1484; +$L__BB1_58: + setp.ge.s32 %p31, %r58, %r69; + @%p31 bra $L__BB1_60; + mul.f32 %r1485, %r1351, %r111; + mul.f32 %r1486, %r53, %r1485; + st.global.b32 [%rd24+393216], %r1486; +$L__BB1_60: + setp.ge.s32 %p32, %r62, %r69; + @%p32 bra $L__BB1_62; + mul.f32 %r1487, %r1352, %r111; + mul.f32 %r1488, %r53, %r1487; + st.global.b32 [%rd24+417792], %r1488; +$L__BB1_62: + @%p31 bra $L__BB1_64; + mul.f32 %r1489, %r1353, %r111; + mul.f32 %r1490, %r53, %r1489; + st.global.b32 [%rd24+393248], %r1490; +$L__BB1_64: + @%p32 bra $L__BB1_66; + mul.f32 %r1491, %r1354, %r111; + mul.f32 %r1492, %r53, %r1491; + st.global.b32 [%rd24+417824], %r1492; +$L__BB1_66: + setp.ge.s32 %p33, %r59, %r69; + @%p33 bra $L__BB1_68; + mul.f32 %r1493, %r1359, %r111; + mul.f32 %r1494, %r53, %r1493; + st.global.b32 [%rd24+589824], %r1494; +$L__BB1_68: + setp.ge.s32 %p34, %r63, %r69; + @%p34 bra $L__BB1_70; + mul.f32 %r1495, %r1360, %r111; + mul.f32 %r1496, %r53, %r1495; + st.global.b32 [%rd24+614400], %r1496; +$L__BB1_70: + @%p33 bra $L__BB1_72; + mul.f32 %r1497, %r1361, %r111; + mul.f32 %r1498, %r53, %r1497; + st.global.b32 [%rd24+589856], %r1498; +$L__BB1_72: + @%p34 bra $L__BB1_74; + mul.f32 %r1499, %r1362, %r111; + mul.f32 %r1500, %r53, %r1499; + st.global.b32 [%rd24+614432], %r1500; +$L__BB1_74: + setp.ge.s32 %p35, %r1985, %r113; + bar.sync 0; + @%p35 bra $L__BB1_88; + add.s64 %rd25, %rd22, 32; + sub.s64 %rd138, %rd35, %rd25; + min.s64 %rd139, %rd138, 32; + cvt.u32.u64 %r112, %rd139; + setp.ge.s32 %p36, %r42, %r112; + @%p36 bra $L__BB1_77; + cvt.u64.u32 %rd142, %r42; + add.s64 %rd143, %rd25, %rd142; + mad.lo.s64 %rd144, %rd143, 40960, %rd4; + add.s64 %rd141, %rd144, 16384; + // begin inline asm + cp.async.cg.shared.global [%r64], [%rd141], 16; + + // end inline asm + bra.uni $L__BB1_78; +$L__BB1_77: + mov.b32 %r1501, 0f00000000; + mov.b64 %rd140, {%r1501, %r1501}; + st.shared.v2.b64 [%r64], {%rd140, %rd140}; +$L__BB1_78: + setp.lt.s32 %p37, %r44, %r112; + @%p37 bra $L__BB1_80; + mov.b32 %r1502, 0f00000000; + mov.b64 %rd145, {%r1502, %r1502}; + st.shared.v2.b64 [%r65], {%rd145, %rd145}; + bra.uni $L__BB1_81; +$L__BB1_80: + add.s64 %rd147, %rd25, %rd18; + mad.lo.s64 %rd148, %rd147, 40960, %rd4; + add.s64 %rd146, %rd148, 16384; + // begin inline asm + cp.async.cg.shared.global [%r65], [%rd146], 16; + + // end inline asm +$L__BB1_81: + setp.lt.s32 %p38, %r46, %r112; + @%p38 bra $L__BB1_83; + mov.b32 %r1503, 0f00000000; + mov.b64 %rd149, {%r1503, %r1503}; + st.shared.v2.b64 [%r66], {%rd149, %rd149}; + bra.uni $L__BB1_84; +$L__BB1_83: + add.s64 %rd151, %rd25, %rd19; + mad.lo.s64 %rd152, %rd151, 40960, %rd4; + add.s64 %rd150, %rd152, 16384; + // begin inline asm + cp.async.cg.shared.global [%r66], [%rd150], 16; + + // end inline asm +$L__BB1_84: + setp.lt.s32 %p39, %r48, %r112; + @%p39 bra $L__BB1_86; + mov.b32 %r1504, 0f00000000; + mov.b64 %rd153, {%r1504, %r1504}; + st.shared.v2.b64 [%r67], {%rd153, %rd153}; + bra.uni $L__BB1_87; +$L__BB1_86: + add.s64 %rd155, %rd25, %rd20; + mad.lo.s64 %rd156, %rd155, 40960, %rd4; + add.s64 %rd154, %rd156, 16384; + // begin inline asm + cp.async.cg.shared.global [%r67], [%rd154], 16; + + // end inline asm +$L__BB1_87: + mul.wide.u32 %rd159, %r1985, 48; + add.s64 %rd160, %rd159, %rd1; + shl.b64 %rd161, %rd160, 11; + add.s64 %rd162, %rd161, %rd8; + shl.b64 %rd163, %rd162, 1; + add.s64 %rd157, %rd28, %rd163; + // begin inline asm + cp.async.cg.shared.global [%r1505], [%rd157], 16; + + // end inline asm + add.s64 %rd158, %rd32, %rd163; + // begin inline asm + cp.async.cg.shared.global [%r1506], [%rd158], 16; + + // end inline asm + // begin inline asm + cp.async.commit_group; + + // end inline asm +$L__BB1_88: + shl.b32 %r1840, %r74, 4; + mov.b32 %r1841, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r1842, %r1841, %r1840; + add.s32 %r1511, %r1842, 97264; + // begin inline asm + ld.shared.v4.f32 {%r1507,%r1508,%r1509,%r1510}, [%r1511]; + // end inline asm + mul.f32 %r1843, %r1508, %r110; + mul.f32 %r1588, %r1843, %r1921; + mul.f32 %r1589, %r1843, %r1922; + mul.f32 %r1590, %r1843, %r1923; + mul.f32 %r1591, %r1843, %r1924; + mul.f32 %r1596, %r1843, %r1925; + mul.f32 %r1597, %r1843, %r1926; + mul.f32 %r1598, %r1843, %r1927; + mul.f32 %r1599, %r1843, %r1928; + mul.f32 %r1606, %r1843, %r1929; + mul.f32 %r1607, %r1843, %r1930; + mul.f32 %r1608, %r1843, %r1931; + mul.f32 %r1609, %r1843, %r1932; + mul.f32 %r1614, %r1843, %r1933; + mul.f32 %r1615, %r1843, %r1934; + mul.f32 %r1616, %r1843, %r1935; + mul.f32 %r1617, %r1843, %r1936; + mul.f32 %r1624, %r1843, %r1937; + mul.f32 %r1625, %r1843, %r1938; + mul.f32 %r1626, %r1843, %r1939; + mul.f32 %r1627, %r1843, %r1940; + mul.f32 %r1632, %r1843, %r1941; + mul.f32 %r1633, %r1843, %r1942; + mul.f32 %r1634, %r1843, %r1943; + mul.f32 %r1635, %r1843, %r1944; + mul.f32 %r1642, %r1843, %r1945; + mul.f32 %r1643, %r1843, %r1946; + mul.f32 %r1644, %r1843, %r1947; + mul.f32 %r1645, %r1843, %r1948; + mul.f32 %r1650, %r1843, %r1949; + mul.f32 %r1651, %r1843, %r1950; + mul.f32 %r1652, %r1843, %r1951; + mul.f32 %r1653, %r1843, %r1952; + mul.f32 %r1660, %r1843, %r1953; + mul.f32 %r1661, %r1843, %r1954; + mul.f32 %r1662, %r1843, %r1955; + mul.f32 %r1663, %r1843, %r1956; + mul.f32 %r1668, %r1843, %r1957; + mul.f32 %r1669, %r1843, %r1958; + mul.f32 %r1670, %r1843, %r1959; + mul.f32 %r1671, %r1843, %r1960; + mul.f32 %r1678, %r1843, %r1961; + mul.f32 %r1679, %r1843, %r1962; + mul.f32 %r1680, %r1843, %r1963; + mul.f32 %r1681, %r1843, %r1964; + mul.f32 %r1686, %r1843, %r1965; + mul.f32 %r1687, %r1843, %r1966; + mul.f32 %r1688, %r1843, %r1967; + mul.f32 %r1689, %r1843, %r1968; + mul.f32 %r1696, %r1843, %r1969; + mul.f32 %r1697, %r1843, %r1970; + mul.f32 %r1698, %r1843, %r1971; + mul.f32 %r1699, %r1843, %r1972; + mul.f32 %r1704, %r1843, %r1973; + mul.f32 %r1705, %r1843, %r1974; + mul.f32 %r1706, %r1843, %r1975; + mul.f32 %r1707, %r1843, %r1976; + mul.f32 %r1714, %r1843, %r1977; + mul.f32 %r1715, %r1843, %r1978; + mul.f32 %r1716, %r1843, %r1979; + mul.f32 %r1717, %r1843, %r1980; + mul.f32 %r1722, %r1843, %r1981; + mul.f32 %r1723, %r1843, %r1982; + mul.f32 %r1724, %r1843, %r1983; + mul.f32 %r1725, %r1843, %r1984; + // begin inline asm + ld.shared.v4.f32 {%r1512,%r1513,%r1514,%r1515}, [%r1516]; + // end inline asm + mul.f32 %r1844, %r1514, %r109; + // begin inline asm + ld.shared.v4.f32 {%r1517,%r1518,%r1519,%r1520}, [%r1521]; + // end inline asm + mul.f32 %r1845, %r1519, %r109; + mul.f32 %r1552, %r93, %r1844; + mul.f32 %r1553, %r1845, %r94; + mul.f32 %r1559, %r1844, %r95; + mul.f32 %r1560, %r1845, %r96; + // begin inline asm + ld.shared.v4.f32 {%r1522,%r1523,%r1524,%r1525}, [%r1526]; + // end inline asm + mul.f32 %r1846, %r1524, %r109; + // begin inline asm + ld.shared.v4.f32 {%r1527,%r1528,%r1529,%r1530}, [%r1531]; + // end inline asm + mul.f32 %r1847, %r1529, %r109; + mul.f32 %r1566, %r97, %r1846; + mul.f32 %r1567, %r1847, %r98; + mul.f32 %r1573, %r1846, %r99; + mul.f32 %r1574, %r1847, %r100; + // begin inline asm + ld.shared.v4.f32 {%r1532,%r1533,%r1534,%r1535}, [%r1536]; + // end inline asm + mul.f32 %r1848, %r1534, %r109; + // begin inline asm + ld.shared.v4.f32 {%r1537,%r1538,%r1539,%r1540}, [%r1541]; + // end inline asm + mul.f32 %r1849, %r1539, %r109; + mul.f32 %r1728, %r101, %r1848; + mul.f32 %r1729, %r1849, %r102; + mul.f32 %r1735, %r1848, %r103; + mul.f32 %r1736, %r1849, %r104; + // begin inline asm + ld.shared.v4.f32 {%r1542,%r1543,%r1544,%r1545}, [%r1546]; + // end inline asm + mul.f32 %r1850, %r1544, %r109; + // begin inline asm + ld.shared.v4.f32 {%r1547,%r1548,%r1549,%r1550}, [%r1551]; + // end inline asm + mul.f32 %r1851, %r1549, %r109; + mul.f32 %r1742, %r105, %r1850; + mul.f32 %r1743, %r1851, %r106; + mul.f32 %r1749, %r1850, %r107; + mul.f32 %r1750, %r1851, %r108; + // begin inline asm + { cvt.rn.f16x2.f32 %r1555, %r1553, %r1552; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1555; + cvt.f32.f16 %r1554, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1555; + cvt.f32.f16 %r1556, high;} + + // end inline asm + sub.f32 %r1557, %r1552, %r1554; + sub.f32 %r1558, %r1553, %r1556; + // begin inline asm + { cvt.rn.f16x2.f32 %r1582, %r1558, %r1557; } + + // end inline asm + // begin inline asm + { cvt.rn.f16x2.f32 %r1562, %r1560, %r1559; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1562; + cvt.f32.f16 %r1561, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1562; + cvt.f32.f16 %r1563, high;} + + // end inline asm + sub.f32 %r1564, %r1559, %r1561; + sub.f32 %r1565, %r1560, %r1563; + // begin inline asm + { cvt.rn.f16x2.f32 %r1583, %r1565, %r1564; } + + // end inline asm + // begin inline asm + { cvt.rn.f16x2.f32 %r1569, %r1567, %r1566; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1569; + cvt.f32.f16 %r1568, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1569; + cvt.f32.f16 %r1570, high;} + + // end inline asm + sub.f32 %r1571, %r1566, %r1568; + sub.f32 %r1572, %r1567, %r1570; + // begin inline asm + { cvt.rn.f16x2.f32 %r1584, %r1572, %r1571; } + + // end inline asm + // begin inline asm + { cvt.rn.f16x2.f32 %r1576, %r1574, %r1573; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1576; + cvt.f32.f16 %r1575, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1576; + cvt.f32.f16 %r1577, high;} + + // end inline asm + sub.f32 %r1578, %r1573, %r1575; + sub.f32 %r1579, %r1574, %r1577; + // begin inline asm + { cvt.rn.f16x2.f32 %r1585, %r1579, %r1578; } + + // end inline asm + add.s32 %r1852, %r55, %r73; + shl.b32 %r1853, %r1852, 1; + add.s32 %r1580, %r1841, %r1853; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1586,%r1587,%r1594,%r1595}, [%r1580]; + // end inline asm + add.s32 %r1581, %r1580, 17408; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1592,%r1593,%r1600,%r1601}, [%r1581]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1588,%r1589,%r1590,%r1591}, {%r1582,%r1583,%r1584,%r1585}, {%r1586,%r1587}, {%r1588,%r1589,%r1590,%r1591}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1588,%r1589,%r1590,%r1591}, {%r1555,%r1562,%r1569,%r1576}, {%r1592,%r1593}, {%r1588,%r1589,%r1590,%r1591}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1588,%r1589,%r1590,%r1591}, {%r1555,%r1562,%r1569,%r1576}, {%r1586,%r1587}, {%r1588,%r1589,%r1590,%r1591}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1596,%r1597,%r1598,%r1599}, {%r1582,%r1583,%r1584,%r1585}, {%r1594,%r1595}, {%r1596,%r1597,%r1598,%r1599}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1596,%r1597,%r1598,%r1599}, {%r1555,%r1562,%r1569,%r1576}, {%r1600,%r1601}, {%r1596,%r1597,%r1598,%r1599}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1596,%r1597,%r1598,%r1599}, {%r1555,%r1562,%r1569,%r1576}, {%r1594,%r1595}, {%r1596,%r1597,%r1598,%r1599}; + // end inline asm + add.s32 %r1602, %r1580, 32; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1604,%r1605,%r1612,%r1613}, [%r1602]; + // end inline asm + add.s32 %r1603, %r1580, 17440; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1610,%r1611,%r1618,%r1619}, [%r1603]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1606,%r1607,%r1608,%r1609}, {%r1582,%r1583,%r1584,%r1585}, {%r1604,%r1605}, {%r1606,%r1607,%r1608,%r1609}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1606,%r1607,%r1608,%r1609}, {%r1555,%r1562,%r1569,%r1576}, {%r1610,%r1611}, {%r1606,%r1607,%r1608,%r1609}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1606,%r1607,%r1608,%r1609}, {%r1555,%r1562,%r1569,%r1576}, {%r1604,%r1605}, {%r1606,%r1607,%r1608,%r1609}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1614,%r1615,%r1616,%r1617}, {%r1582,%r1583,%r1584,%r1585}, {%r1612,%r1613}, {%r1614,%r1615,%r1616,%r1617}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1614,%r1615,%r1616,%r1617}, {%r1555,%r1562,%r1569,%r1576}, {%r1618,%r1619}, {%r1614,%r1615,%r1616,%r1617}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1614,%r1615,%r1616,%r1617}, {%r1555,%r1562,%r1569,%r1576}, {%r1612,%r1613}, {%r1614,%r1615,%r1616,%r1617}; + // end inline asm + add.s32 %r1620, %r1580, 64; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1622,%r1623,%r1630,%r1631}, [%r1620]; + // end inline asm + add.s32 %r1621, %r1580, 17472; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1628,%r1629,%r1636,%r1637}, [%r1621]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1624,%r1625,%r1626,%r1627}, {%r1582,%r1583,%r1584,%r1585}, {%r1622,%r1623}, {%r1624,%r1625,%r1626,%r1627}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1624,%r1625,%r1626,%r1627}, {%r1555,%r1562,%r1569,%r1576}, {%r1628,%r1629}, {%r1624,%r1625,%r1626,%r1627}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1624,%r1625,%r1626,%r1627}, {%r1555,%r1562,%r1569,%r1576}, {%r1622,%r1623}, {%r1624,%r1625,%r1626,%r1627}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1632,%r1633,%r1634,%r1635}, {%r1582,%r1583,%r1584,%r1585}, {%r1630,%r1631}, {%r1632,%r1633,%r1634,%r1635}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1632,%r1633,%r1634,%r1635}, {%r1555,%r1562,%r1569,%r1576}, {%r1636,%r1637}, {%r1632,%r1633,%r1634,%r1635}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1632,%r1633,%r1634,%r1635}, {%r1555,%r1562,%r1569,%r1576}, {%r1630,%r1631}, {%r1632,%r1633,%r1634,%r1635}; + // end inline asm + add.s32 %r1638, %r1580, 96; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1640,%r1641,%r1648,%r1649}, [%r1638]; + // end inline asm + add.s32 %r1639, %r1580, 17504; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1646,%r1647,%r1654,%r1655}, [%r1639]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1642,%r1643,%r1644,%r1645}, {%r1582,%r1583,%r1584,%r1585}, {%r1640,%r1641}, {%r1642,%r1643,%r1644,%r1645}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1642,%r1643,%r1644,%r1645}, {%r1555,%r1562,%r1569,%r1576}, {%r1646,%r1647}, {%r1642,%r1643,%r1644,%r1645}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1642,%r1643,%r1644,%r1645}, {%r1555,%r1562,%r1569,%r1576}, {%r1640,%r1641}, {%r1642,%r1643,%r1644,%r1645}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1650,%r1651,%r1652,%r1653}, {%r1582,%r1583,%r1584,%r1585}, {%r1648,%r1649}, {%r1650,%r1651,%r1652,%r1653}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1650,%r1651,%r1652,%r1653}, {%r1555,%r1562,%r1569,%r1576}, {%r1654,%r1655}, {%r1650,%r1651,%r1652,%r1653}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1650,%r1651,%r1652,%r1653}, {%r1555,%r1562,%r1569,%r1576}, {%r1648,%r1649}, {%r1650,%r1651,%r1652,%r1653}; + // end inline asm + add.s32 %r1656, %r1580, 128; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1658,%r1659,%r1666,%r1667}, [%r1656]; + // end inline asm + add.s32 %r1657, %r1580, 17536; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1664,%r1665,%r1672,%r1673}, [%r1657]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1660,%r1661,%r1662,%r1663}, {%r1582,%r1583,%r1584,%r1585}, {%r1658,%r1659}, {%r1660,%r1661,%r1662,%r1663}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1660,%r1661,%r1662,%r1663}, {%r1555,%r1562,%r1569,%r1576}, {%r1664,%r1665}, {%r1660,%r1661,%r1662,%r1663}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1660,%r1661,%r1662,%r1663}, {%r1555,%r1562,%r1569,%r1576}, {%r1658,%r1659}, {%r1660,%r1661,%r1662,%r1663}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1668,%r1669,%r1670,%r1671}, {%r1582,%r1583,%r1584,%r1585}, {%r1666,%r1667}, {%r1668,%r1669,%r1670,%r1671}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1668,%r1669,%r1670,%r1671}, {%r1555,%r1562,%r1569,%r1576}, {%r1672,%r1673}, {%r1668,%r1669,%r1670,%r1671}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1668,%r1669,%r1670,%r1671}, {%r1555,%r1562,%r1569,%r1576}, {%r1666,%r1667}, {%r1668,%r1669,%r1670,%r1671}; + // end inline asm + add.s32 %r1674, %r1580, 160; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1676,%r1677,%r1684,%r1685}, [%r1674]; + // end inline asm + add.s32 %r1675, %r1580, 17568; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1682,%r1683,%r1690,%r1691}, [%r1675]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1678,%r1679,%r1680,%r1681}, {%r1582,%r1583,%r1584,%r1585}, {%r1676,%r1677}, {%r1678,%r1679,%r1680,%r1681}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1678,%r1679,%r1680,%r1681}, {%r1555,%r1562,%r1569,%r1576}, {%r1682,%r1683}, {%r1678,%r1679,%r1680,%r1681}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1678,%r1679,%r1680,%r1681}, {%r1555,%r1562,%r1569,%r1576}, {%r1676,%r1677}, {%r1678,%r1679,%r1680,%r1681}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1686,%r1687,%r1688,%r1689}, {%r1582,%r1583,%r1584,%r1585}, {%r1684,%r1685}, {%r1686,%r1687,%r1688,%r1689}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1686,%r1687,%r1688,%r1689}, {%r1555,%r1562,%r1569,%r1576}, {%r1690,%r1691}, {%r1686,%r1687,%r1688,%r1689}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1686,%r1687,%r1688,%r1689}, {%r1555,%r1562,%r1569,%r1576}, {%r1684,%r1685}, {%r1686,%r1687,%r1688,%r1689}; + // end inline asm + add.s32 %r1692, %r1580, 192; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1694,%r1695,%r1702,%r1703}, [%r1692]; + // end inline asm + add.s32 %r1693, %r1580, 17600; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1700,%r1701,%r1708,%r1709}, [%r1693]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1696,%r1697,%r1698,%r1699}, {%r1582,%r1583,%r1584,%r1585}, {%r1694,%r1695}, {%r1696,%r1697,%r1698,%r1699}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1696,%r1697,%r1698,%r1699}, {%r1555,%r1562,%r1569,%r1576}, {%r1700,%r1701}, {%r1696,%r1697,%r1698,%r1699}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1696,%r1697,%r1698,%r1699}, {%r1555,%r1562,%r1569,%r1576}, {%r1694,%r1695}, {%r1696,%r1697,%r1698,%r1699}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1704,%r1705,%r1706,%r1707}, {%r1582,%r1583,%r1584,%r1585}, {%r1702,%r1703}, {%r1704,%r1705,%r1706,%r1707}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1704,%r1705,%r1706,%r1707}, {%r1555,%r1562,%r1569,%r1576}, {%r1708,%r1709}, {%r1704,%r1705,%r1706,%r1707}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1704,%r1705,%r1706,%r1707}, {%r1555,%r1562,%r1569,%r1576}, {%r1702,%r1703}, {%r1704,%r1705,%r1706,%r1707}; + // end inline asm + add.s32 %r1710, %r1580, 224; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1712,%r1713,%r1720,%r1721}, [%r1710]; + // end inline asm + add.s32 %r1711, %r1580, 17632; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1718,%r1719,%r1726,%r1727}, [%r1711]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1714,%r1715,%r1716,%r1717}, {%r1582,%r1583,%r1584,%r1585}, {%r1712,%r1713}, {%r1714,%r1715,%r1716,%r1717}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1714,%r1715,%r1716,%r1717}, {%r1555,%r1562,%r1569,%r1576}, {%r1718,%r1719}, {%r1714,%r1715,%r1716,%r1717}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1714,%r1715,%r1716,%r1717}, {%r1555,%r1562,%r1569,%r1576}, {%r1712,%r1713}, {%r1714,%r1715,%r1716,%r1717}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1722,%r1723,%r1724,%r1725}, {%r1582,%r1583,%r1584,%r1585}, {%r1720,%r1721}, {%r1722,%r1723,%r1724,%r1725}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1722,%r1723,%r1724,%r1725}, {%r1555,%r1562,%r1569,%r1576}, {%r1726,%r1727}, {%r1722,%r1723,%r1724,%r1725}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1722,%r1723,%r1724,%r1725}, {%r1555,%r1562,%r1569,%r1576}, {%r1720,%r1721}, {%r1722,%r1723,%r1724,%r1725}; + // end inline asm + // begin inline asm + { cvt.rn.f16x2.f32 %r1731, %r1729, %r1728; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1731; + cvt.f32.f16 %r1730, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1731; + cvt.f32.f16 %r1732, high;} + + // end inline asm + sub.f32 %r1733, %r1728, %r1730; + sub.f32 %r1734, %r1729, %r1732; + // begin inline asm + { cvt.rn.f16x2.f32 %r1758, %r1734, %r1733; } + + // end inline asm + // begin inline asm + { cvt.rn.f16x2.f32 %r1738, %r1736, %r1735; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1738; + cvt.f32.f16 %r1737, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1738; + cvt.f32.f16 %r1739, high;} + + // end inline asm + sub.f32 %r1740, %r1735, %r1737; + sub.f32 %r1741, %r1736, %r1739; + // begin inline asm + { cvt.rn.f16x2.f32 %r1759, %r1741, %r1740; } + + // end inline asm + // begin inline asm + { cvt.rn.f16x2.f32 %r1745, %r1743, %r1742; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1745; + cvt.f32.f16 %r1744, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1745; + cvt.f32.f16 %r1746, high;} + + // end inline asm + sub.f32 %r1747, %r1742, %r1744; + sub.f32 %r1748, %r1743, %r1746; + // begin inline asm + { cvt.rn.f16x2.f32 %r1760, %r1748, %r1747; } + + // end inline asm + // begin inline asm + { cvt.rn.f16x2.f32 %r1752, %r1750, %r1749; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1752; + cvt.f32.f16 %r1751, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1752; + cvt.f32.f16 %r1753, high;} + + // end inline asm + sub.f32 %r1754, %r1749, %r1751; + sub.f32 %r1755, %r1750, %r1753; + // begin inline asm + { cvt.rn.f16x2.f32 %r1761, %r1755, %r1754; } + + // end inline asm + add.s32 %r1756, %r1580, 4352; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1762,%r1763,%r1766,%r1767}, [%r1756]; + // end inline asm + add.s32 %r1757, %r1580, 21760; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1764,%r1765,%r1768,%r1769}, [%r1757]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1588,%r1589,%r1590,%r1591}, {%r1758,%r1759,%r1760,%r1761}, {%r1762,%r1763}, {%r1588,%r1589,%r1590,%r1591}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1588,%r1589,%r1590,%r1591}, {%r1731,%r1738,%r1745,%r1752}, {%r1764,%r1765}, {%r1588,%r1589,%r1590,%r1591}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1588,%r1589,%r1590,%r1591}, {%r1731,%r1738,%r1745,%r1752}, {%r1762,%r1763}, {%r1588,%r1589,%r1590,%r1591}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1596,%r1597,%r1598,%r1599}, {%r1758,%r1759,%r1760,%r1761}, {%r1766,%r1767}, {%r1596,%r1597,%r1598,%r1599}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1596,%r1597,%r1598,%r1599}, {%r1731,%r1738,%r1745,%r1752}, {%r1768,%r1769}, {%r1596,%r1597,%r1598,%r1599}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1596,%r1597,%r1598,%r1599}, {%r1731,%r1738,%r1745,%r1752}, {%r1766,%r1767}, {%r1596,%r1597,%r1598,%r1599}; + // end inline asm + add.s32 %r1770, %r1580, 4384; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1772,%r1773,%r1776,%r1777}, [%r1770]; + // end inline asm + add.s32 %r1771, %r1580, 21792; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1774,%r1775,%r1778,%r1779}, [%r1771]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1606,%r1607,%r1608,%r1609}, {%r1758,%r1759,%r1760,%r1761}, {%r1772,%r1773}, {%r1606,%r1607,%r1608,%r1609}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1606,%r1607,%r1608,%r1609}, {%r1731,%r1738,%r1745,%r1752}, {%r1774,%r1775}, {%r1606,%r1607,%r1608,%r1609}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1606,%r1607,%r1608,%r1609}, {%r1731,%r1738,%r1745,%r1752}, {%r1772,%r1773}, {%r1606,%r1607,%r1608,%r1609}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1614,%r1615,%r1616,%r1617}, {%r1758,%r1759,%r1760,%r1761}, {%r1776,%r1777}, {%r1614,%r1615,%r1616,%r1617}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1614,%r1615,%r1616,%r1617}, {%r1731,%r1738,%r1745,%r1752}, {%r1778,%r1779}, {%r1614,%r1615,%r1616,%r1617}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1614,%r1615,%r1616,%r1617}, {%r1731,%r1738,%r1745,%r1752}, {%r1776,%r1777}, {%r1614,%r1615,%r1616,%r1617}; + // end inline asm + add.s32 %r1780, %r1580, 4416; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1782,%r1783,%r1786,%r1787}, [%r1780]; + // end inline asm + add.s32 %r1781, %r1580, 21824; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1784,%r1785,%r1788,%r1789}, [%r1781]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1624,%r1625,%r1626,%r1627}, {%r1758,%r1759,%r1760,%r1761}, {%r1782,%r1783}, {%r1624,%r1625,%r1626,%r1627}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1624,%r1625,%r1626,%r1627}, {%r1731,%r1738,%r1745,%r1752}, {%r1784,%r1785}, {%r1624,%r1625,%r1626,%r1627}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1624,%r1625,%r1626,%r1627}, {%r1731,%r1738,%r1745,%r1752}, {%r1782,%r1783}, {%r1624,%r1625,%r1626,%r1627}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1632,%r1633,%r1634,%r1635}, {%r1758,%r1759,%r1760,%r1761}, {%r1786,%r1787}, {%r1632,%r1633,%r1634,%r1635}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1632,%r1633,%r1634,%r1635}, {%r1731,%r1738,%r1745,%r1752}, {%r1788,%r1789}, {%r1632,%r1633,%r1634,%r1635}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1632,%r1633,%r1634,%r1635}, {%r1731,%r1738,%r1745,%r1752}, {%r1786,%r1787}, {%r1632,%r1633,%r1634,%r1635}; + // end inline asm + add.s32 %r1790, %r1580, 4448; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1792,%r1793,%r1796,%r1797}, [%r1790]; + // end inline asm + add.s32 %r1791, %r1580, 21856; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1794,%r1795,%r1798,%r1799}, [%r1791]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1642,%r1643,%r1644,%r1645}, {%r1758,%r1759,%r1760,%r1761}, {%r1792,%r1793}, {%r1642,%r1643,%r1644,%r1645}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1642,%r1643,%r1644,%r1645}, {%r1731,%r1738,%r1745,%r1752}, {%r1794,%r1795}, {%r1642,%r1643,%r1644,%r1645}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1642,%r1643,%r1644,%r1645}, {%r1731,%r1738,%r1745,%r1752}, {%r1792,%r1793}, {%r1642,%r1643,%r1644,%r1645}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1650,%r1651,%r1652,%r1653}, {%r1758,%r1759,%r1760,%r1761}, {%r1796,%r1797}, {%r1650,%r1651,%r1652,%r1653}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1650,%r1651,%r1652,%r1653}, {%r1731,%r1738,%r1745,%r1752}, {%r1798,%r1799}, {%r1650,%r1651,%r1652,%r1653}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1650,%r1651,%r1652,%r1653}, {%r1731,%r1738,%r1745,%r1752}, {%r1796,%r1797}, {%r1650,%r1651,%r1652,%r1653}; + // end inline asm + add.s32 %r1800, %r1580, 4480; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1802,%r1803,%r1806,%r1807}, [%r1800]; + // end inline asm + add.s32 %r1801, %r1580, 21888; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1804,%r1805,%r1808,%r1809}, [%r1801]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1660,%r1661,%r1662,%r1663}, {%r1758,%r1759,%r1760,%r1761}, {%r1802,%r1803}, {%r1660,%r1661,%r1662,%r1663}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1660,%r1661,%r1662,%r1663}, {%r1731,%r1738,%r1745,%r1752}, {%r1804,%r1805}, {%r1660,%r1661,%r1662,%r1663}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1660,%r1661,%r1662,%r1663}, {%r1731,%r1738,%r1745,%r1752}, {%r1802,%r1803}, {%r1660,%r1661,%r1662,%r1663}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1668,%r1669,%r1670,%r1671}, {%r1758,%r1759,%r1760,%r1761}, {%r1806,%r1807}, {%r1668,%r1669,%r1670,%r1671}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1668,%r1669,%r1670,%r1671}, {%r1731,%r1738,%r1745,%r1752}, {%r1808,%r1809}, {%r1668,%r1669,%r1670,%r1671}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1668,%r1669,%r1670,%r1671}, {%r1731,%r1738,%r1745,%r1752}, {%r1806,%r1807}, {%r1668,%r1669,%r1670,%r1671}; + // end inline asm + add.s32 %r1810, %r1580, 4512; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1812,%r1813,%r1816,%r1817}, [%r1810]; + // end inline asm + add.s32 %r1811, %r1580, 21920; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1814,%r1815,%r1818,%r1819}, [%r1811]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1678,%r1679,%r1680,%r1681}, {%r1758,%r1759,%r1760,%r1761}, {%r1812,%r1813}, {%r1678,%r1679,%r1680,%r1681}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1678,%r1679,%r1680,%r1681}, {%r1731,%r1738,%r1745,%r1752}, {%r1814,%r1815}, {%r1678,%r1679,%r1680,%r1681}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1678,%r1679,%r1680,%r1681}, {%r1731,%r1738,%r1745,%r1752}, {%r1812,%r1813}, {%r1678,%r1679,%r1680,%r1681}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1686,%r1687,%r1688,%r1689}, {%r1758,%r1759,%r1760,%r1761}, {%r1816,%r1817}, {%r1686,%r1687,%r1688,%r1689}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1686,%r1687,%r1688,%r1689}, {%r1731,%r1738,%r1745,%r1752}, {%r1818,%r1819}, {%r1686,%r1687,%r1688,%r1689}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1686,%r1687,%r1688,%r1689}, {%r1731,%r1738,%r1745,%r1752}, {%r1816,%r1817}, {%r1686,%r1687,%r1688,%r1689}; + // end inline asm + add.s32 %r1820, %r1580, 4544; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1822,%r1823,%r1826,%r1827}, [%r1820]; + // end inline asm + add.s32 %r1821, %r1580, 21952; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1824,%r1825,%r1828,%r1829}, [%r1821]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1696,%r1697,%r1698,%r1699}, {%r1758,%r1759,%r1760,%r1761}, {%r1822,%r1823}, {%r1696,%r1697,%r1698,%r1699}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1696,%r1697,%r1698,%r1699}, {%r1731,%r1738,%r1745,%r1752}, {%r1824,%r1825}, {%r1696,%r1697,%r1698,%r1699}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1696,%r1697,%r1698,%r1699}, {%r1731,%r1738,%r1745,%r1752}, {%r1822,%r1823}, {%r1696,%r1697,%r1698,%r1699}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1704,%r1705,%r1706,%r1707}, {%r1758,%r1759,%r1760,%r1761}, {%r1826,%r1827}, {%r1704,%r1705,%r1706,%r1707}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1704,%r1705,%r1706,%r1707}, {%r1731,%r1738,%r1745,%r1752}, {%r1828,%r1829}, {%r1704,%r1705,%r1706,%r1707}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1704,%r1705,%r1706,%r1707}, {%r1731,%r1738,%r1745,%r1752}, {%r1826,%r1827}, {%r1704,%r1705,%r1706,%r1707}; + // end inline asm + add.s32 %r1830, %r1580, 4576; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1832,%r1833,%r1836,%r1837}, [%r1830]; + // end inline asm + add.s32 %r1831, %r1580, 21984; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1834,%r1835,%r1838,%r1839}, [%r1831]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1714,%r1715,%r1716,%r1717}, {%r1758,%r1759,%r1760,%r1761}, {%r1832,%r1833}, {%r1714,%r1715,%r1716,%r1717}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1714,%r1715,%r1716,%r1717}, {%r1731,%r1738,%r1745,%r1752}, {%r1834,%r1835}, {%r1714,%r1715,%r1716,%r1717}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1714,%r1715,%r1716,%r1717}, {%r1731,%r1738,%r1745,%r1752}, {%r1832,%r1833}, {%r1714,%r1715,%r1716,%r1717}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1722,%r1723,%r1724,%r1725}, {%r1758,%r1759,%r1760,%r1761}, {%r1836,%r1837}, {%r1722,%r1723,%r1724,%r1725}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1722,%r1723,%r1724,%r1725}, {%r1731,%r1738,%r1745,%r1752}, {%r1838,%r1839}, {%r1722,%r1723,%r1724,%r1725}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1722,%r1723,%r1724,%r1725}, {%r1731,%r1738,%r1745,%r1752}, {%r1836,%r1837}, {%r1722,%r1723,%r1724,%r1725}; + // end inline asm + mul.f32 %r1921, %r1588, %r111; + mul.f32 %r1922, %r1589, %r111; + mul.f32 %r1923, %r1590, %r111; + mul.f32 %r1924, %r1591, %r111; + mul.f32 %r1925, %r1596, %r111; + mul.f32 %r1926, %r1597, %r111; + mul.f32 %r1927, %r1598, %r111; + mul.f32 %r1928, %r1599, %r111; + mul.f32 %r1929, %r1606, %r111; + mul.f32 %r1930, %r1607, %r111; + mul.f32 %r1931, %r1608, %r111; + mul.f32 %r1932, %r1609, %r111; + mul.f32 %r1933, %r1614, %r111; + mul.f32 %r1934, %r1615, %r111; + mul.f32 %r1935, %r1616, %r111; + mul.f32 %r1936, %r1617, %r111; + mul.f32 %r1937, %r1624, %r111; + mul.f32 %r1938, %r1625, %r111; + mul.f32 %r1939, %r1626, %r111; + mul.f32 %r1940, %r1627, %r111; + mul.f32 %r1941, %r1632, %r111; + mul.f32 %r1942, %r1633, %r111; + mul.f32 %r1943, %r1634, %r111; + mul.f32 %r1944, %r1635, %r111; + mul.f32 %r1945, %r1642, %r111; + mul.f32 %r1946, %r1643, %r111; + mul.f32 %r1947, %r1644, %r111; + mul.f32 %r1948, %r1645, %r111; + mul.f32 %r1949, %r1650, %r111; + mul.f32 %r1950, %r1651, %r111; + mul.f32 %r1951, %r1652, %r111; + mul.f32 %r1952, %r1653, %r111; + mul.f32 %r1953, %r1660, %r111; + mul.f32 %r1954, %r1661, %r111; + mul.f32 %r1955, %r1662, %r111; + mul.f32 %r1956, %r1663, %r111; + mul.f32 %r1957, %r1668, %r111; + mul.f32 %r1958, %r1669, %r111; + mul.f32 %r1959, %r1670, %r111; + mul.f32 %r1960, %r1671, %r111; + mul.f32 %r1961, %r1678, %r111; + mul.f32 %r1962, %r1679, %r111; + mul.f32 %r1963, %r1680, %r111; + mul.f32 %r1964, %r1681, %r111; + mul.f32 %r1965, %r1686, %r111; + mul.f32 %r1966, %r1687, %r111; + mul.f32 %r1967, %r1688, %r111; + mul.f32 %r1968, %r1689, %r111; + mul.f32 %r1969, %r1696, %r111; + mul.f32 %r1970, %r1697, %r111; + mul.f32 %r1971, %r1698, %r111; + mul.f32 %r1972, %r1699, %r111; + mul.f32 %r1973, %r1704, %r111; + mul.f32 %r1974, %r1705, %r111; + mul.f32 %r1975, %r1706, %r111; + mul.f32 %r1976, %r1707, %r111; + mul.f32 %r1977, %r1714, %r111; + mul.f32 %r1978, %r1715, %r111; + mul.f32 %r1979, %r1716, %r111; + mul.f32 %r1980, %r1717, %r111; + mul.f32 %r1981, %r1722, %r111; + mul.f32 %r1982, %r1723, %r111; + mul.f32 %r1983, %r1724, %r111; + mul.f32 %r1984, %r1725, %r111; + setp.eq.b32 %p40, %r1985, %r113; + @%p40 bra $L__BB1_89; + bra.uni $L__BB1_26; +$L__BB1_89: + cvta.to.global.u64 %rd164, %rd26; + add.s64 %rd165, %rd164, %rd2; + add.s64 %rd166, %rd165, %rd41; + st.global.b32 [%rd166], %r1921; + st.global.b32 [%rd166+24576], %r1922; + st.global.b32 [%rd166+32], %r1923; + st.global.b32 [%rd166+24608], %r1924; + abs.f32 %r1854, %r1921; + setp.equ.f32 %p41, %r1854, 0f7F800000; + abs.f32 %r1855, %r1922; + setp.equ.f32 %p42, %r1855, 0f7F800000; + or.pred %p43, %p41, %p42; + abs.f32 %r1856, %r1923; + setp.equ.f32 %p44, %r1856, 0f7F800000; + or.pred %p45, %p43, %p44; + abs.f32 %r1857, %r1924; + setp.equ.f32 %p46, %r1857, 0f7F800000; + or.pred %p47, %p45, %p46; + st.global.b32 [%rd166+196608], %r1925; + st.global.b32 [%rd166+221184], %r1926; + st.global.b32 [%rd166+196640], %r1927; + st.global.b32 [%rd166+221216], %r1928; + abs.f32 %r1858, %r1925; + setp.equ.f32 %p48, %r1858, 0f7F800000; + or.pred %p49, %p47, %p48; + abs.f32 %r1859, %r1926; + setp.equ.f32 %p50, %r1859, 0f7F800000; + or.pred %p51, %p49, %p50; + abs.f32 %r1860, %r1927; + setp.equ.f32 %p52, %r1860, 0f7F800000; + or.pred %p53, %p51, %p52; + abs.f32 %r1861, %r1928; + setp.equ.f32 %p54, %r1861, 0f7F800000; + or.pred %p55, %p53, %p54; + st.global.b32 [%rd166+393216], %r1929; + st.global.b32 [%rd166+417792], %r1930; + st.global.b32 [%rd166+393248], %r1931; + st.global.b32 [%rd166+417824], %r1932; + abs.f32 %r1862, %r1929; + setp.equ.f32 %p56, %r1862, 0f7F800000; + or.pred %p57, %p55, %p56; + abs.f32 %r1863, %r1930; + setp.equ.f32 %p58, %r1863, 0f7F800000; + or.pred %p59, %p57, %p58; + abs.f32 %r1864, %r1931; + setp.equ.f32 %p60, %r1864, 0f7F800000; + or.pred %p61, %p59, %p60; + abs.f32 %r1865, %r1932; + setp.equ.f32 %p62, %r1865, 0f7F800000; + or.pred %p63, %p61, %p62; + st.global.b32 [%rd166+589824], %r1933; + st.global.b32 [%rd166+614400], %r1934; + st.global.b32 [%rd166+589856], %r1935; + st.global.b32 [%rd166+614432], %r1936; + abs.f32 %r1866, %r1933; + setp.equ.f32 %p64, %r1866, 0f7F800000; + or.pred %p65, %p63, %p64; + abs.f32 %r1867, %r1934; + setp.equ.f32 %p66, %r1867, 0f7F800000; + or.pred %p67, %p65, %p66; + abs.f32 %r1868, %r1935; + setp.equ.f32 %p68, %r1868, 0f7F800000; + or.pred %p69, %p67, %p68; + abs.f32 %r1869, %r1936; + setp.equ.f32 %p70, %r1869, 0f7F800000; + or.pred %p71, %p69, %p70; + st.global.b32 [%rd166+786432], %r1937; + st.global.b32 [%rd166+811008], %r1938; + st.global.b32 [%rd166+786464], %r1939; + st.global.b32 [%rd166+811040], %r1940; + abs.f32 %r1870, %r1937; + setp.equ.f32 %p72, %r1870, 0f7F800000; + or.pred %p73, %p71, %p72; + abs.f32 %r1871, %r1938; + setp.equ.f32 %p74, %r1871, 0f7F800000; + or.pred %p75, %p73, %p74; + abs.f32 %r1872, %r1939; + setp.equ.f32 %p76, %r1872, 0f7F800000; + or.pred %p77, %p75, %p76; + abs.f32 %r1873, %r1940; + setp.equ.f32 %p78, %r1873, 0f7F800000; + or.pred %p79, %p77, %p78; + st.global.b32 [%rd166+983040], %r1941; + st.global.b32 [%rd166+1007616], %r1942; + st.global.b32 [%rd166+983072], %r1943; + st.global.b32 [%rd166+1007648], %r1944; + abs.f32 %r1874, %r1941; + setp.equ.f32 %p80, %r1874, 0f7F800000; + or.pred %p81, %p79, %p80; + abs.f32 %r1875, %r1942; + setp.equ.f32 %p82, %r1875, 0f7F800000; + or.pred %p83, %p81, %p82; + abs.f32 %r1876, %r1943; + setp.equ.f32 %p84, %r1876, 0f7F800000; + or.pred %p85, %p83, %p84; + abs.f32 %r1877, %r1944; + setp.equ.f32 %p86, %r1877, 0f7F800000; + or.pred %p87, %p85, %p86; + st.global.b32 [%rd166+1179648], %r1945; + st.global.b32 [%rd166+1204224], %r1946; + st.global.b32 [%rd166+1179680], %r1947; + st.global.b32 [%rd166+1204256], %r1948; + abs.f32 %r1878, %r1945; + setp.equ.f32 %p88, %r1878, 0f7F800000; + or.pred %p89, %p87, %p88; + abs.f32 %r1879, %r1946; + setp.equ.f32 %p90, %r1879, 0f7F800000; + or.pred %p91, %p89, %p90; + abs.f32 %r1880, %r1947; + setp.equ.f32 %p92, %r1880, 0f7F800000; + or.pred %p93, %p91, %p92; + abs.f32 %r1881, %r1948; + setp.equ.f32 %p94, %r1881, 0f7F800000; + or.pred %p95, %p93, %p94; + st.global.b32 [%rd166+1376256], %r1949; + st.global.b32 [%rd166+1400832], %r1950; + st.global.b32 [%rd166+1376288], %r1951; + st.global.b32 [%rd166+1400864], %r1952; + abs.f32 %r1882, %r1949; + setp.equ.f32 %p96, %r1882, 0f7F800000; + or.pred %p97, %p95, %p96; + abs.f32 %r1883, %r1950; + setp.equ.f32 %p98, %r1883, 0f7F800000; + or.pred %p99, %p97, %p98; + abs.f32 %r1884, %r1951; + setp.equ.f32 %p100, %r1884, 0f7F800000; + or.pred %p101, %p99, %p100; + abs.f32 %r1885, %r1952; + setp.equ.f32 %p102, %r1885, 0f7F800000; + or.pred %p103, %p101, %p102; + st.global.b32 [%rd166+1572864], %r1953; + st.global.b32 [%rd166+1597440], %r1954; + st.global.b32 [%rd166+1572896], %r1955; + st.global.b32 [%rd166+1597472], %r1956; + abs.f32 %r1886, %r1953; + setp.equ.f32 %p104, %r1886, 0f7F800000; + or.pred %p105, %p103, %p104; + abs.f32 %r1887, %r1954; + setp.equ.f32 %p106, %r1887, 0f7F800000; + or.pred %p107, %p105, %p106; + abs.f32 %r1888, %r1955; + setp.equ.f32 %p108, %r1888, 0f7F800000; + or.pred %p109, %p107, %p108; + abs.f32 %r1889, %r1956; + setp.equ.f32 %p110, %r1889, 0f7F800000; + or.pred %p111, %p109, %p110; + st.global.b32 [%rd166+1769472], %r1957; + st.global.b32 [%rd166+1794048], %r1958; + st.global.b32 [%rd166+1769504], %r1959; + st.global.b32 [%rd166+1794080], %r1960; + abs.f32 %r1890, %r1957; + setp.equ.f32 %p112, %r1890, 0f7F800000; + or.pred %p113, %p111, %p112; + abs.f32 %r1891, %r1958; + setp.equ.f32 %p114, %r1891, 0f7F800000; + or.pred %p115, %p113, %p114; + abs.f32 %r1892, %r1959; + setp.equ.f32 %p116, %r1892, 0f7F800000; + or.pred %p117, %p115, %p116; + abs.f32 %r1893, %r1960; + setp.equ.f32 %p118, %r1893, 0f7F800000; + or.pred %p119, %p117, %p118; + st.global.b32 [%rd166+1966080], %r1961; + st.global.b32 [%rd166+1990656], %r1962; + st.global.b32 [%rd166+1966112], %r1963; + st.global.b32 [%rd166+1990688], %r1964; + abs.f32 %r1894, %r1961; + setp.equ.f32 %p120, %r1894, 0f7F800000; + or.pred %p121, %p119, %p120; + abs.f32 %r1895, %r1962; + setp.equ.f32 %p122, %r1895, 0f7F800000; + or.pred %p123, %p121, %p122; + abs.f32 %r1896, %r1963; + setp.equ.f32 %p124, %r1896, 0f7F800000; + or.pred %p125, %p123, %p124; + abs.f32 %r1897, %r1964; + setp.equ.f32 %p126, %r1897, 0f7F800000; + or.pred %p127, %p125, %p126; + st.global.b32 [%rd166+2162688], %r1965; + st.global.b32 [%rd166+2187264], %r1966; + st.global.b32 [%rd166+2162720], %r1967; + st.global.b32 [%rd166+2187296], %r1968; + abs.f32 %r1898, %r1965; + setp.equ.f32 %p128, %r1898, 0f7F800000; + or.pred %p129, %p127, %p128; + abs.f32 %r1899, %r1966; + setp.equ.f32 %p130, %r1899, 0f7F800000; + or.pred %p131, %p129, %p130; + abs.f32 %r1900, %r1967; + setp.equ.f32 %p132, %r1900, 0f7F800000; + or.pred %p133, %p131, %p132; + abs.f32 %r1901, %r1968; + setp.equ.f32 %p134, %r1901, 0f7F800000; + or.pred %p135, %p133, %p134; + st.global.b32 [%rd166+2359296], %r1969; + st.global.b32 [%rd166+2383872], %r1970; + st.global.b32 [%rd166+2359328], %r1971; + st.global.b32 [%rd166+2383904], %r1972; + abs.f32 %r1902, %r1969; + setp.equ.f32 %p136, %r1902, 0f7F800000; + or.pred %p137, %p135, %p136; + abs.f32 %r1903, %r1970; + setp.equ.f32 %p138, %r1903, 0f7F800000; + or.pred %p139, %p137, %p138; + abs.f32 %r1904, %r1971; + setp.equ.f32 %p140, %r1904, 0f7F800000; + or.pred %p141, %p139, %p140; + abs.f32 %r1905, %r1972; + setp.equ.f32 %p142, %r1905, 0f7F800000; + or.pred %p143, %p141, %p142; + st.global.b32 [%rd166+2555904], %r1973; + st.global.b32 [%rd166+2580480], %r1974; + st.global.b32 [%rd166+2555936], %r1975; + st.global.b32 [%rd166+2580512], %r1976; + abs.f32 %r1906, %r1973; + setp.equ.f32 %p144, %r1906, 0f7F800000; + or.pred %p145, %p143, %p144; + abs.f32 %r1907, %r1974; + setp.equ.f32 %p146, %r1907, 0f7F800000; + or.pred %p147, %p145, %p146; + abs.f32 %r1908, %r1975; + setp.equ.f32 %p148, %r1908, 0f7F800000; + or.pred %p149, %p147, %p148; + abs.f32 %r1909, %r1976; + setp.equ.f32 %p150, %r1909, 0f7F800000; + or.pred %p151, %p149, %p150; + st.global.b32 [%rd166+2752512], %r1977; + st.global.b32 [%rd166+2777088], %r1978; + st.global.b32 [%rd166+2752544], %r1979; + st.global.b32 [%rd166+2777120], %r1980; + abs.f32 %r1910, %r1977; + setp.equ.f32 %p152, %r1910, 0f7F800000; + or.pred %p153, %p151, %p152; + abs.f32 %r1911, %r1978; + setp.equ.f32 %p154, %r1911, 0f7F800000; + or.pred %p155, %p153, %p154; + abs.f32 %r1912, %r1979; + setp.equ.f32 %p156, %r1912, 0f7F800000; + or.pred %p157, %p155, %p156; + abs.f32 %r1913, %r1980; + setp.equ.f32 %p158, %r1913, 0f7F800000; + or.pred %p159, %p157, %p158; + st.global.b32 [%rd166+2949120], %r1981; + st.global.b32 [%rd166+2973696], %r1982; + st.global.b32 [%rd166+2949152], %r1983; + st.global.b32 [%rd166+2973728], %r1984; + abs.f32 %r1914, %r1981; + setp.equ.f32 %p160, %r1914, 0f7F800000; + or.pred %p161, %p159, %p160; + abs.f32 %r1915, %r1982; + setp.equ.f32 %p162, %r1915, 0f7F800000; + or.pred %p163, %p161, %p162; + abs.f32 %r1916, %r1983; + setp.equ.f32 %p164, %r1916, 0f7F800000; + or.pred %p165, %p163, %p164; + abs.f32 %r1917, %r1984; + setp.equ.f32 %p166, %r1917, 0f7F800000; + or.pred %p167, %p165, %p166; + @%p167 bra $L__BB1_90; + bra.uni $L__BB1_91; +$L__BB1_90: + cvta.to.global.u64 %rd167, %rd36; + atom.global.or.b32 %r1918, [%rd167], 1; +$L__BB1_91: + ret; + +} + // .globl leleka_gdn_tc_scan_t2 +.visible .entry leleka_gdn_tc_scan_t2( + .param .u64 .ptr .align 1 leleka_gdn_tc_scan_t2_param_0, + .param .u64 .ptr .align 1 leleka_gdn_tc_scan_t2_param_1, + .param .u64 .ptr .align 1 leleka_gdn_tc_scan_t2_param_2, + .param .u64 .ptr .align 1 leleka_gdn_tc_scan_t2_param_3, + .param .u64 .ptr .align 1 leleka_gdn_tc_scan_t2_param_4, + .param .u64 .ptr .align 1 leleka_gdn_tc_scan_t2_param_5, + .param .u64 .ptr .align 1 leleka_gdn_tc_scan_t2_param_6, + .param .u64 .ptr .align 1 leleka_gdn_tc_scan_t2_param_7, + .param .u64 .ptr .align 1 leleka_gdn_tc_scan_t2_param_8, + .param .u64 leleka_gdn_tc_scan_t2_param_9, + .param .u32 leleka_gdn_tc_scan_t2_param_10, + .param .u64 leleka_gdn_tc_scan_t2_param_11, + .param .u64 .ptr .align 1 leleka_gdn_tc_scan_t2_param_12 +) +.maxntid 256 +.minnctapersm 1 +{ + .reg .pred %p<186>; + .reg .b32 %r<2169>; + .reg .b64 %rd<230>; + + ld.param.b64 %rd35, [leleka_gdn_tc_scan_t2_param_0]; + ld.param.b64 %rd25, [leleka_gdn_tc_scan_t2_param_2]; + ld.param.b64 %rd26, [leleka_gdn_tc_scan_t2_param_3]; + ld.param.b64 %rd27, [leleka_gdn_tc_scan_t2_param_4]; + ld.param.b64 %rd28, [leleka_gdn_tc_scan_t2_param_5]; + ld.param.b64 %rd29, [leleka_gdn_tc_scan_t2_param_6]; + ld.param.b64 %rd30, [leleka_gdn_tc_scan_t2_param_7]; + ld.param.b64 %rd31, [leleka_gdn_tc_scan_t2_param_8]; + ld.param.b64 %rd32, [leleka_gdn_tc_scan_t2_param_9]; + ld.param.b32 %r121, [leleka_gdn_tc_scan_t2_param_10]; + ld.param.b64 %rd33, [leleka_gdn_tc_scan_t2_param_11]; + cvta.to.global.u64 %rd36, %rd35; + mov.u32 %r123, %ctaid.x; + shr.u32 %r124, %r123, 1; + shl.b32 %r125, %r123, 6; + and.b32 %r1, %r125, 64; + mov.u32 %r2, %tid.x; + shr.u32 %r3, %r2, 2; + and.b32 %r4, %r3, 7; + and.b32 %r5, %r2, 3; + shr.u32 %r6, %r2, 1; + and.b32 %r7, %r6, 496; + add.s32 %r8, %r1, %r7; + cvt.u64.u32 %rd1, %r124; + mul.wide.u32 %rd2, %r124, 512; + add.s64 %rd37, %rd36, %rd2; + or.b32 %r126, %r8, %r4; + mul.lo.s32 %r127, %r5, 12288; + or.b32 %r9, %r126, %r127; + mul.wide.u32 %rd38, %r9, 4; + add.s64 %rd39, %rd37, %rd38; + ld.global.b32 %r2097, [%rd39]; + ld.global.b32 %r2098, [%rd39+24576]; + ld.global.b32 %r2099, [%rd39+32]; + ld.global.b32 %r2100, [%rd39+24608]; + ld.global.b32 %r2101, [%rd39+196608]; + ld.global.b32 %r2102, [%rd39+221184]; + ld.global.b32 %r2103, [%rd39+196640]; + ld.global.b32 %r2104, [%rd39+221216]; + ld.global.b32 %r2105, [%rd39+393216]; + ld.global.b32 %r2106, [%rd39+417792]; + ld.global.b32 %r2107, [%rd39+393248]; + ld.global.b32 %r2108, [%rd39+417824]; + ld.global.b32 %r2109, [%rd39+589824]; + ld.global.b32 %r2110, [%rd39+614400]; + ld.global.b32 %r2111, [%rd39+589856]; + ld.global.b32 %r2112, [%rd39+614432]; + ld.global.b32 %r2113, [%rd39+786432]; + ld.global.b32 %r2114, [%rd39+811008]; + ld.global.b32 %r2115, [%rd39+786464]; + ld.global.b32 %r2116, [%rd39+811040]; + ld.global.b32 %r2117, [%rd39+983040]; + ld.global.b32 %r2118, [%rd39+1007616]; + ld.global.b32 %r2119, [%rd39+983072]; + ld.global.b32 %r2120, [%rd39+1007648]; + ld.global.b32 %r2121, [%rd39+1179648]; + ld.global.b32 %r2122, [%rd39+1204224]; + ld.global.b32 %r2123, [%rd39+1179680]; + ld.global.b32 %r2124, [%rd39+1204256]; + ld.global.b32 %r2125, [%rd39+1376256]; + ld.global.b32 %r2126, [%rd39+1400832]; + ld.global.b32 %r2127, [%rd39+1376288]; + ld.global.b32 %r2128, [%rd39+1400864]; + ld.global.b32 %r2129, [%rd39+1572864]; + ld.global.b32 %r2130, [%rd39+1597440]; + ld.global.b32 %r2131, [%rd39+1572896]; + ld.global.b32 %r2132, [%rd39+1597472]; + ld.global.b32 %r2133, [%rd39+1769472]; + ld.global.b32 %r2134, [%rd39+1794048]; + ld.global.b32 %r2135, [%rd39+1769504]; + ld.global.b32 %r2136, [%rd39+1794080]; + ld.global.b32 %r2137, [%rd39+1966080]; + ld.global.b32 %r2138, [%rd39+1990656]; + ld.global.b32 %r2139, [%rd39+1966112]; + ld.global.b32 %r2140, [%rd39+1990688]; + ld.global.b32 %r2141, [%rd39+2162688]; + ld.global.b32 %r2142, [%rd39+2187264]; + ld.global.b32 %r2143, [%rd39+2162720]; + ld.global.b32 %r2144, [%rd39+2187296]; + ld.global.b32 %r2145, [%rd39+2359296]; + ld.global.b32 %r2146, [%rd39+2383872]; + ld.global.b32 %r2147, [%rd39+2359328]; + ld.global.b32 %r2148, [%rd39+2383904]; + ld.global.b32 %r2149, [%rd39+2555904]; + ld.global.b32 %r2150, [%rd39+2580480]; + ld.global.b32 %r2151, [%rd39+2555936]; + ld.global.b32 %r2152, [%rd39+2580512]; + ld.global.b32 %r2153, [%rd39+2752512]; + ld.global.b32 %r2154, [%rd39+2777088]; + ld.global.b32 %r2155, [%rd39+2752544]; + ld.global.b32 %r2156, [%rd39+2777120]; + ld.global.b32 %r2157, [%rd39+2949120]; + ld.global.b32 %r2158, [%rd39+2973696]; + ld.global.b32 %r2159, [%rd39+2949152]; + ld.global.b32 %r2160, [%rd39+2973728]; + sub.s64 %rd40, %rd33, %rd32; + min.s64 %rd41, %rd40, 32; + cvt.u32.u64 %r10, %rd41; + shl.b32 %r128, %r123, 13; + shl.b32 %r11, %r2, 3; + or.b32 %r129, %r128, %r11; + and.b32 %r12, %r11, 120; + and.b32 %r13, %r129, 245880; + shr.u32 %r130, %r2, 9; + shr.u32 %r14, %r2, 4; + and.b32 %r15, %r14, 31; + setp.eq.b32 %p1, %r130, 0; + mov.b32 %r2091, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r131, %r2091, 17408; + selp.b32 %r16, %r2091, %r131, %p1; + mad.lo.s32 %r17, %r15, 136, %r12; + shl.b32 %r132, %r130, 12; + and.b32 %r18, %r11, 3968; + or.b32 %r133, %r13, %r132; + or.b32 %r134, %r133, %r18; + mul.wide.u32 %rd42, %r134, 2; + add.s64 %rd34, %rd29, %rd42; + shl.b32 %r135, %r17, 1; + add.s32 %r122, %r16, %r135; + // begin inline asm + cp.async.cg.shared.global [%r122], [%rd34], 16; + + // end inline asm + add.s32 %r19, %r2, 128; + shr.u32 %r20, %r19, 9; + shr.u32 %r21, %r19, 4; + and.b32 %r22, %r21, 31; + setp.eq.b32 %p2, %r20, 0; + @%p2 bra $L__BB2_4; + setp.eq.b32 %p3, %r20, 1; + @%p3 bra $L__BB2_3; + mov.b32 %r136, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r2091, %r136, 34816; + bra.uni $L__BB2_4; +$L__BB2_3: + mov.b32 %r137, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r2091, %r137, 17408; +$L__BB2_4: + mad.lo.s32 %r139, %r22, 136, %r12; + shl.b32 %r140, %r20, 12; + shl.b32 %r141, %r22, 7; + add.s32 %r142, %r13, %r140; + add.s32 %r143, %r142, %r141; + mul.wide.u32 %rd44, %r143, 2; + add.s64 %rd43, %rd29, %rd44; + shl.b32 %r144, %r139, 1; + add.s32 %r138, %r2091, %r144; + // begin inline asm + cp.async.cg.shared.global [%r138], [%rd43], 16; + + // end inline asm + add.s32 %r145, %r2, 256; + shr.u32 %r23, %r145, 9; + shr.u32 %r24, %r145, 4; + and.b32 %r25, %r24, 31; + mov.b32 %r2092, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + setp.eq.b32 %p4, %r23, 0; + @%p4 bra $L__BB2_8; + setp.eq.b32 %p5, %r23, 1; + @%p5 bra $L__BB2_7; + mov.b32 %r146, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r2092, %r146, 34816; + bra.uni $L__BB2_8; +$L__BB2_7: + mov.b32 %r147, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r2092, %r147, 17408; +$L__BB2_8: + mad.lo.s32 %r149, %r25, 136, %r12; + shl.b32 %r150, %r23, 12; + shl.b32 %r151, %r25, 7; + add.s32 %r152, %r13, %r150; + add.s32 %r153, %r152, %r151; + mul.wide.u32 %rd46, %r153, 2; + add.s64 %rd45, %rd29, %rd46; + shl.b32 %r154, %r149, 1; + add.s32 %r148, %r2092, %r154; + // begin inline asm + cp.async.cg.shared.global [%r148], [%rd45], 16; + + // end inline asm + add.s32 %r155, %r2, 384; + shr.u32 %r26, %r155, 9; + shr.u32 %r27, %r155, 4; + and.b32 %r28, %r27, 31; + mov.b32 %r2093, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + setp.eq.b32 %p6, %r26, 0; + @%p6 bra $L__BB2_12; + setp.eq.b32 %p7, %r26, 1; + @%p7 bra $L__BB2_11; + mov.b32 %r156, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r2093, %r156, 34816; + bra.uni $L__BB2_12; +$L__BB2_11: + mov.b32 %r157, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r2093, %r157, 17408; +$L__BB2_12: + mad.lo.s32 %r160, %r28, 136, %r12; + shl.b32 %r161, %r26, 12; + shl.b32 %r162, %r28, 7; + add.s32 %r163, %r13, %r161; + add.s32 %r164, %r163, %r162; + mul.wide.u32 %rd49, %r164, 2; + add.s64 %rd47, %rd29, %rd49; + shl.b32 %r165, %r160, 1; + add.s32 %r158, %r2093, %r165; + // begin inline asm + cp.async.cg.shared.global [%r158], [%rd47], 16; + + // end inline asm + add.s32 %r166, %r2, 512; + shr.u32 %r167, %r166, 9; + setp.eq.b32 %p8, %r167, 2; + mov.b32 %r168, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r169, %r168, 17408; + add.s32 %r2094, %r168, 34816; + selp.b32 %r29, %r2094, %r169, %p8; + shl.b32 %r30, %r167, 12; + add.s32 %r170, %r13, %r30; + add.s32 %r171, %r170, %r18; + mul.wide.u32 %rd50, %r171, 2; + add.s64 %rd48, %rd29, %rd50; + add.s32 %r159, %r29, %r135; + // begin inline asm + cp.async.cg.shared.global [%r159], [%rd48], 16; + + // end inline asm + add.s32 %r172, %r2, 640; + shr.u32 %r31, %r172, 9; + shr.u32 %r173, %r172, 4; + and.b32 %r32, %r173, 31; + setp.eq.b32 %p9, %r31, 3; + @%p9 bra $L__BB2_15; + setp.eq.b32 %p10, %r31, 2; + @%p10 bra $L__BB2_16; + mov.b32 %r174, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r2094, %r174, 17408; + bra.uni $L__BB2_16; +$L__BB2_15: + mov.b32 %r175, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r2094, %r175, 52224; +$L__BB2_16: + mad.lo.s32 %r177, %r32, 136, %r12; + shl.b32 %r178, %r31, 12; + shl.b32 %r179, %r32, 7; + add.s32 %r180, %r13, %r178; + add.s32 %r181, %r180, %r179; + mul.wide.u32 %rd52, %r181, 2; + add.s64 %rd51, %rd29, %rd52; + shl.b32 %r182, %r177, 1; + add.s32 %r176, %r2094, %r182; + // begin inline asm + cp.async.cg.shared.global [%r176], [%rd51], 16; + + // end inline asm + add.s32 %r183, %r2, 768; + shr.u32 %r33, %r183, 9; + shr.u32 %r184, %r183, 4; + mov.b32 %r185, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r2095, %r185, 34816; + and.b32 %r34, %r184, 31; + setp.eq.b32 %p11, %r33, 3; + @%p11 bra $L__BB2_19; + setp.eq.b32 %p12, %r33, 2; + @%p12 bra $L__BB2_20; + mov.b32 %r186, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r2095, %r186, 17408; + bra.uni $L__BB2_20; +$L__BB2_19: + mov.b32 %r187, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r2095, %r187, 52224; +$L__BB2_20: + mad.lo.s32 %r189, %r34, 136, %r12; + shl.b32 %r190, %r33, 12; + shl.b32 %r191, %r34, 7; + add.s32 %r192, %r13, %r190; + add.s32 %r193, %r192, %r191; + mul.wide.u32 %rd54, %r193, 2; + add.s64 %rd53, %rd29, %rd54; + shl.b32 %r194, %r189, 1; + add.s32 %r188, %r2095, %r194; + // begin inline asm + cp.async.cg.shared.global [%r188], [%rd53], 16; + + // end inline asm + add.s32 %r195, %r2, 896; + shr.u32 %r35, %r195, 9; + shr.u32 %r196, %r195, 4; + mov.b32 %r197, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r2096, %r197, 34816; + and.b32 %r36, %r196, 31; + setp.eq.b32 %p13, %r35, 3; + @%p13 bra $L__BB2_23; + setp.eq.b32 %p14, %r35, 2; + @%p14 bra $L__BB2_24; + mov.b32 %r198, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r2096, %r198, 17408; + bra.uni $L__BB2_24; +$L__BB2_23: + mov.b32 %r199, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r2096, %r199, 52224; +$L__BB2_24: + mad.lo.s32 %r209, %r36, 136, %r12; + shl.b32 %r210, %r35, 12; + shl.b32 %r211, %r36, 7; + add.s32 %r212, %r13, %r210; + add.s32 %r213, %r212, %r211; + mul.wide.u32 %rd64, %r213, 2; + add.s64 %rd55, %rd29, %rd64; + shl.b32 %r214, %r209, 1; + add.s32 %r200, %r2096, %r214; + // begin inline asm + cp.async.cg.shared.global [%r200], [%rd55], 16; + + // end inline asm + or.b32 %r215, %r2, 1024; + shr.u32 %r216, %r215, 9; + setp.eq.b32 %p15, %r216, 2; + mov.b32 %r217, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r218, %r217, 52224; + add.s32 %r219, %r217, 34816; + selp.b32 %r37, %r219, %r218, %p15; + shl.b32 %r38, %r216, 12; + add.s32 %r220, %r13, %r38; + add.s32 %r221, %r220, %r18; + mul.wide.u32 %rd65, %r221, 2; + add.s64 %rd56, %rd29, %rd65; + add.s32 %r201, %r37, %r135; + // begin inline asm + cp.async.cg.shared.global [%r201], [%rd56], 16; + + // end inline asm + add.s32 %r222, %r2, 1152; + shr.u32 %r223, %r222, 9; + shr.u32 %r224, %r222, 4; + and.b32 %r39, %r224, 31; + setp.eq.b32 %p16, %r223, 2; + selp.b32 %r40, %r219, %r218, %p16; + mad.lo.s32 %r225, %r39, 136, %r12; + shl.b32 %r41, %r223, 12; + shl.b32 %r226, %r222, 3; + and.b32 %r42, %r226, 3968; + add.s32 %r227, %r13, %r41; + add.s32 %r228, %r227, %r42; + mul.wide.u32 %rd66, %r228, 2; + add.s64 %rd57, %rd29, %rd66; + shl.b32 %r229, %r225, 1; + add.s32 %r202, %r40, %r229; + // begin inline asm + cp.async.cg.shared.global [%r202], [%rd57], 16; + + // end inline asm + add.s32 %r230, %r2, 1280; + shr.u32 %r231, %r230, 9; + shr.u32 %r232, %r230, 4; + and.b32 %r43, %r232, 31; + setp.eq.b32 %p17, %r231, 2; + selp.b32 %r44, %r219, %r218, %p17; + mad.lo.s32 %r233, %r43, 136, %r12; + shl.b32 %r45, %r231, 12; + shl.b32 %r234, %r230, 3; + and.b32 %r46, %r234, 3968; + add.s32 %r235, %r13, %r45; + add.s32 %r236, %r235, %r46; + mul.wide.u32 %rd67, %r236, 2; + add.s64 %rd58, %rd29, %rd67; + shl.b32 %r237, %r233, 1; + add.s32 %r203, %r44, %r237; + // begin inline asm + cp.async.cg.shared.global [%r203], [%rd58], 16; + + // end inline asm + add.s32 %r238, %r2, 1408; + shr.u32 %r239, %r238, 9; + shr.u32 %r240, %r238, 4; + and.b32 %r47, %r240, 31; + setp.eq.b32 %p18, %r239, 2; + selp.b32 %r48, %r219, %r218, %p18; + mad.lo.s32 %r241, %r47, 136, %r12; + shl.b32 %r49, %r239, 12; + shl.b32 %r242, %r238, 3; + and.b32 %r50, %r242, 3968; + add.s32 %r243, %r13, %r49; + add.s32 %r244, %r243, %r50; + mul.wide.u32 %rd68, %r244, 2; + add.s64 %rd59, %rd29, %rd68; + shl.b32 %r245, %r241, 1; + add.s32 %r204, %r48, %r245; + // begin inline asm + cp.async.cg.shared.global [%r204], [%rd59], 16; + + // end inline asm + add.s32 %r246, %r11, 12288; + and.b32 %r51, %r246, 28672; + add.s32 %r247, %r13, %r51; + add.s32 %r248, %r247, %r18; + mul.wide.u32 %rd69, %r248, 2; + add.s64 %rd60, %rd29, %rd69; + add.s32 %r205, %r218, %r135; + // begin inline asm + cp.async.cg.shared.global [%r205], [%rd60], 16; + + // end inline asm + add.s32 %r249, %r2, 1664; + shr.u32 %r250, %r249, 4; + and.b32 %r52, %r250, 31; + mad.lo.s32 %r251, %r52, 136, %r12; + shl.b32 %r252, %r249, 3; + and.b32 %r53, %r252, 28672; + and.b32 %r54, %r252, 3968; + add.s32 %r253, %r13, %r53; + add.s32 %r254, %r253, %r54; + mul.wide.u32 %rd70, %r254, 2; + add.s64 %rd61, %rd29, %rd70; + shl.b32 %r255, %r251, 1; + add.s32 %r206, %r218, %r255; + // begin inline asm + cp.async.cg.shared.global [%r206], [%rd61], 16; + + // end inline asm + add.s32 %r256, %r2, 1792; + shr.u32 %r257, %r256, 4; + and.b32 %r55, %r257, 31; + mad.lo.s32 %r258, %r55, 136, %r12; + shl.b32 %r259, %r256, 3; + and.b32 %r260, %r259, 28672; + and.b32 %r261, %r259, 3968; + add.s32 %r262, %r13, %r260; + add.s32 %r263, %r262, %r261; + mul.wide.u32 %rd71, %r263, 2; + add.s64 %rd62, %rd29, %rd71; + shl.b32 %r264, %r258, 1; + add.s32 %r207, %r218, %r264; + // begin inline asm + cp.async.cg.shared.global [%r207], [%rd62], 16; + + // end inline asm + add.s32 %r265, %r2, 1920; + shr.u32 %r266, %r265, 4; + and.b32 %r56, %r266, 31; + mad.lo.s32 %r267, %r56, 136, %r12; + shl.b32 %r268, %r265, 3; + and.b32 %r269, %r268, 28672; + and.b32 %r270, %r268, 3968; + add.s32 %r271, %r13, %r269; + add.s32 %r272, %r271, %r270; + mul.wide.u32 %rd72, %r272, 2; + add.s64 %rd63, %rd29, %rd72; + shl.b32 %r273, %r267, 1; + add.s32 %r208, %r218, %r273; + // begin inline asm + cp.async.cg.shared.global [%r208], [%rd63], 16; + + // end inline asm + setp.gt.u32 %p19, %r2, 31; + @%p19 bra $L__BB2_26; + add.s64 %rd74, %rd28, %rd2; + mul.wide.u32 %rd75, %r2, 16; + add.s64 %rd73, %rd74, %rd75; + shl.b32 %r275, %r2, 4; + mov.b32 %r276, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r277, %r276, %r275; + add.s32 %r274, %r277, 96768; + // begin inline asm + cp.async.cg.shared.global [%r274], [%rd73], 16; + + // end inline asm +$L__BB2_26: + setp.ne.b32 %p20, %r2, 0; + shl.b64 %rd76, %rd1, 2; + add.s64 %rd3, %rd27, %rd76; + @%p20 bra $L__BB2_28; + mov.b32 %r279, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r278, %r279, 97792; + // begin inline asm + cp.async.ca.shared.global [%r278], [%rd3], 4; + + // end inline asm +$L__BB2_28: + cvt.u32.u64 %r280, %rd1; + shl.b32 %r281, %r2, 2; + and.b32 %r57, %r281, 60; + shl.b32 %r282, %r280, 7; + or.b32 %r283, %r282, %r1; + add.s32 %r284, %r283, %r57; + mul.wide.u32 %rd77, %r284, 4; + add.s64 %rd4, %rd25, %rd77; + mad.lo.s32 %r285, %r14, 132, %r57; + setp.ge.s32 %p21, %r14, %r10; + shl.b32 %r286, %r285, 2; + mov.b32 %r287, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r58, %r287, %r286; + @%p21 bra $L__BB2_30; + cvt.u64.u32 %rd80, %r14; + add.s64 %rd81, %rd32, %rd80; + mad.lo.s64 %rd82, %rd81, 40960, %rd4; + add.s64 %rd79, %rd82, 16384; + add.s32 %r289, %r58, 69632; + // begin inline asm + cp.async.cg.shared.global [%r289], [%rd79], 16; + + // end inline asm + bra.uni $L__BB2_31; +$L__BB2_30: + mov.b32 %r288, 0f00000000; + mov.b64 %rd78, {%r288, %r288}; + st.shared.v2.b64 [%r58+69632], {%rd78, %rd78}; +$L__BB2_31: + mad.lo.s32 %r290, %r21, 132, %r57; + setp.lt.s32 %p22, %r21, %r10; + shl.b32 %r291, %r290, 2; + mov.b32 %r292, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r59, %r292, %r291; + @%p22 bra $L__BB2_33; + mov.b32 %r293, 0f00000000; + mov.b64 %rd83, {%r293, %r293}; + st.shared.v2.b64 [%r59+69632], {%rd83, %rd83}; + bra.uni $L__BB2_34; +$L__BB2_33: + cvt.u64.u32 %rd85, %r21; + add.s64 %rd86, %rd32, %rd85; + mad.lo.s64 %rd87, %rd86, 40960, %rd4; + add.s64 %rd84, %rd87, 16384; + add.s32 %r294, %r59, 69632; + // begin inline asm + cp.async.cg.shared.global [%r294], [%rd84], 16; + + // end inline asm +$L__BB2_34: + mad.lo.s32 %r295, %r24, 132, %r57; + setp.lt.s32 %p23, %r24, %r10; + shl.b32 %r296, %r295, 2; + mov.b32 %r297, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r60, %r297, %r296; + @%p23 bra $L__BB2_36; + mov.b32 %r298, 0f00000000; + mov.b64 %rd88, {%r298, %r298}; + st.shared.v2.b64 [%r60+69632], {%rd88, %rd88}; + bra.uni $L__BB2_37; +$L__BB2_36: + cvt.u64.u32 %rd90, %r24; + add.s64 %rd91, %rd32, %rd90; + mad.lo.s64 %rd92, %rd91, 40960, %rd4; + add.s64 %rd89, %rd92, 16384; + add.s32 %r299, %r60, 69632; + // begin inline asm + cp.async.cg.shared.global [%r299], [%rd89], 16; + + // end inline asm +$L__BB2_37: + mad.lo.s32 %r300, %r27, 132, %r57; + setp.lt.s32 %p24, %r27, %r10; + shl.b32 %r301, %r300, 2; + mov.b32 %r302, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r61, %r302, %r301; + @%p24 bra $L__BB2_39; + mov.b32 %r303, 0f00000000; + mov.b64 %rd93, {%r303, %r303}; + st.shared.v2.b64 [%r61+69632], {%rd93, %rd93}; + bra.uni $L__BB2_40; +$L__BB2_39: + cvt.u64.u32 %rd95, %r27; + add.s64 %rd96, %rd32, %rd95; + mad.lo.s64 %rd97, %rd96, 40960, %rd4; + add.s64 %rd94, %rd97, 16384; + add.s32 %r304, %r61, 69632; + // begin inline asm + cp.async.cg.shared.global [%r304], [%rd94], 16; + + // end inline asm +$L__BB2_40: + and.b32 %r305, %r3, 31; + and.b32 %r306, %r11, 24; + shl.b64 %rd102, %rd1, 6; + cvt.u64.u32 %rd5, %r305; + or.b64 %rd103, %rd102, %rd5; + mad.lo.s32 %r307, %r305, 40, %r306; + cvt.u64.u32 %rd6, %r306; + and.b32 %r308, %r3, 224; + cvt.u64.u32 %rd7, %r308; + add.s64 %rd104, %rd103, %rd7; + setp.lt.u32 %p25, %r2, 128; + shl.b64 %rd105, %rd104, 6; + shl.b32 %r309, %r11, 1; + cvt.u64.u32 %rd106, %r309; + and.b64 %rd107, %rd106, 48; + or.b64 %rd108, %rd105, %rd107; + add.s64 %rd98, %rd26, %rd108; + mov.b32 %r310, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r311, %r310, 89088; + add.s32 %r312, %r310, 86528; + selp.b32 %r313, %r312, %r311, %p25; + shl.b32 %r314, %r307, 1; + add.s32 %r1675, %r313, %r314; + // begin inline asm + cp.async.cg.shared.global [%r1675], [%rd98], 16; + + // end inline asm + add.s64 %rd99, %rd30, %rd108; + add.s32 %r315, %r310, 94208; + add.s32 %r316, %r310, 91648; + selp.b32 %r317, %r316, %r315, %p25; + add.s32 %r1676, %r317, %r314; + // begin inline asm + cp.async.cg.shared.global [%r1676], [%rd99], 16; + + // end inline asm + shr.u32 %r318, %r19, 2; + and.b32 %r319, %r318, 480; + cvt.u64.u32 %rd8, %r319; + add.s64 %rd109, %rd103, %rd8; + shl.b64 %rd110, %rd109, 6; + or.b64 %rd111, %rd110, %rd107; + add.s64 %rd100, %rd26, %rd111; + add.s32 %r320, %r310, %r314; + add.s32 %r1677, %r320, 89088; + // begin inline asm + cp.async.cg.shared.global [%r1677], [%rd100], 16; + + // end inline asm + add.s64 %rd101, %rd30, %rd111; + add.s32 %r1678, %r320, 94208; + // begin inline asm + cp.async.cg.shared.global [%r1678], [%rd101], 16; + + // end inline asm + // begin inline asm + cp.async.commit_group; + + // end inline asm + mov.b32 %r321, 0f43000000; + rsqrt.approx.f32 %r62, %r321; + setp.lt.s32 %p26, %r121, 1; + @%p26 bra $L__BB2_121; + cvt.u64.u32 %rd9, %r13; + mul.wide.u32 %rd112, %r2, 16; + add.s64 %rd10, %rd28, %rd112; + and.b32 %r322, %r6, 8; + and.b32 %r323, %r2, 7; + or.b32 %r324, %r322, %r323; + and.b32 %r325, %r2, 8; + mad.lo.s32 %r63, %r324, 136, %r325; + shl.b32 %r326, %r5, 1; + add.s32 %r327, %r4, %r7; + mad.lo.s32 %r328, %r324, -96, %r63; + shl.b64 %rd113, %rd1, 7; + cvt.u64.u32 %rd114, %r8; + cvt.u64.u32 %rd115, %r4; + or.b64 %rd116, %rd113, %rd115; + add.s64 %rd11, %rd116, %rd114; + or.b32 %r329, %r325, %r323; + shl.b32 %r330, %r14, 3; + and.b32 %r331, %r330, 8; + mad.lo.s32 %r64, %r329, 136, %r331; + add.s32 %r332, %r30, %r18; + cvt.u64.u32 %rd12, %r332; + add.s32 %r333, %r38, %r18; + cvt.u64.u32 %rd13, %r333; + add.s32 %r334, %r41, %r42; + cvt.u64.u32 %rd14, %r334; + add.s32 %r335, %r45, %r46; + cvt.u64.u32 %rd15, %r335; + add.s32 %r336, %r49, %r50; + cvt.u64.u32 %rd16, %r336; + add.s32 %r337, %r51, %r18; + cvt.u64.u32 %rd17, %r337; + add.s32 %r338, %r53, %r54; + cvt.u64.u32 %rd18, %r338; + mad.lo.s32 %r339, %r5, 264, %r327; + shl.b32 %r340, %r339, 2; + mov.b32 %r341, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r65, %r341, %r340; + or.b32 %r66, %r326, 8; + shl.b32 %r342, %r328, 1; + add.s32 %r343, %r341, %r342; + add.s32 %r1352, %r343, 86528; + add.s32 %r1353, %r343, 89088; + add.s32 %r1374, %r343, 87808; + add.s32 %r1375, %r343, 90368; + add.s32 %r1420, %r343, 87840; + add.s32 %r1421, %r343, 90400; + add.s32 %r1494, %r343, 91648; + add.s32 %r1495, %r343, 94208; + add.s32 %r1516, %r343, 92928; + add.s32 %r1517, %r343, 95488; + add.s32 %r1562, %r343, 92960; + add.s32 %r1563, %r343, 95520; + cvt.u64.u32 %rd19, %r326; + add.s32 %r67, %r58, 69632; + add.s32 %r68, %r59, 69632; + add.s32 %r69, %r60, 69632; + add.s32 %r70, %r61, 69632; + cvta.to.global.u64 %rd20, %rd31; + mov.b32 %r2161, 0; + shl.b64 %rd219, %rd6, 1; +$L__BB2_42: + and.b32 %r71, %r2161, 1; + mul.wide.u32 %rd117, %r2161, 32; + add.s64 %rd21, %rd117, %rd32; + sub.s64 %rd118, %rd33, %rd21; + min.s64 %rd119, %rd118, 32; + cvt.u32.u64 %r72, %rd119; + // begin inline asm + cp.async.wait_all; + + // end inline asm + bar.sync 0; + add.s32 %r2161, %r2161, 1; + setp.ge.s32 %p27, %r2161, %r121; + @%p27 bra $L__BB2_72; + xor.b32 %r73, %r71, 1; + mul.wide.u32 %rd121, %r2161, 262144; + shl.b32 %r345, %r71, 5; + xor.b32 %r74, %r345, 32; + or.b64 %rd22, %rd121, %rd9; + or.b32 %r346, %r74, %r15; + mad.lo.s32 %r75, %r346, 136, %r12; + and.b32 %r347, %r11, 4096; + shl.b32 %r348, %r15, 7; + or.b32 %r349, %r347, %r348; + cvt.u64.u32 %rd122, %r349; + add.s64 %rd123, %rd22, %rd122; + shl.b64 %rd124, %rd123, 1; + add.s64 %rd120, %rd29, %rd124; + shl.b32 %r350, %r75, 1; + add.s32 %r344, %r16, %r350; + // begin inline asm + cp.async.cg.shared.global [%r344], [%rd120], 16; + + // end inline asm + mov.b32 %r2162, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + setp.eq.b32 %p28, %r20, 0; + @%p28 bra $L__BB2_47; + setp.eq.b32 %p29, %r20, 1; + @%p29 bra $L__BB2_46; + mov.b32 %r351, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r2162, %r351, 34816; + bra.uni $L__BB2_47; +$L__BB2_46: + mov.b32 %r352, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r2162, %r352, 17408; +$L__BB2_47: + add.s32 %r354, %r74, %r22; + mad.lo.s32 %r355, %r354, 136, %r12; + shl.b32 %r356, %r21, 7; + and.b32 %r357, %r356, 3968; + or.b32 %r358, %r140, %r357; + cvt.u64.u32 %rd126, %r358; + add.s64 %rd127, %rd22, %rd126; + shl.b64 %rd128, %rd127, 1; + add.s64 %rd125, %rd29, %rd128; + shl.b32 %r359, %r355, 1; + add.s32 %r353, %r2162, %r359; + // begin inline asm + cp.async.cg.shared.global [%r353], [%rd125], 16; + + // end inline asm + mov.b32 %r2163, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + setp.eq.b32 %p30, %r23, 0; + @%p30 bra $L__BB2_51; + setp.eq.b32 %p31, %r23, 1; + @%p31 bra $L__BB2_50; + mov.b32 %r360, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r2163, %r360, 34816; + bra.uni $L__BB2_51; +$L__BB2_50: + mov.b32 %r361, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r2163, %r361, 17408; +$L__BB2_51: + add.s32 %r363, %r74, %r25; + mad.lo.s32 %r364, %r363, 136, %r12; + shl.b32 %r365, %r24, 7; + and.b32 %r366, %r365, 3968; + or.b32 %r367, %r150, %r366; + cvt.u64.u32 %rd130, %r367; + add.s64 %rd131, %rd22, %rd130; + shl.b64 %rd132, %rd131, 1; + add.s64 %rd129, %rd29, %rd132; + shl.b32 %r368, %r364, 1; + add.s32 %r362, %r2163, %r368; + // begin inline asm + cp.async.cg.shared.global [%r362], [%rd129], 16; + + // end inline asm + mov.b32 %r2164, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + setp.eq.b32 %p32, %r26, 0; + @%p32 bra $L__BB2_55; + setp.eq.b32 %p33, %r26, 1; + @%p33 bra $L__BB2_54; + mov.b32 %r369, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r2164, %r369, 34816; + bra.uni $L__BB2_55; +$L__BB2_54: + mov.b32 %r370, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r2164, %r370, 17408; +$L__BB2_55: + add.s32 %r373, %r74, %r28; + mad.lo.s32 %r374, %r373, 136, %r12; + shl.b32 %r375, %r27, 7; + and.b32 %r376, %r375, 3968; + or.b32 %r377, %r161, %r376; + cvt.u64.u32 %rd135, %r377; + add.s64 %rd136, %rd22, %rd135; + shl.b64 %rd137, %rd136, 1; + add.s64 %rd133, %rd29, %rd137; + shl.b32 %r378, %r374, 1; + add.s32 %r371, %r2164, %r378; + // begin inline asm + cp.async.cg.shared.global [%r371], [%rd133], 16; + + // end inline asm + add.s64 %rd138, %rd22, %rd12; + shl.b64 %rd139, %rd138, 1; + add.s64 %rd134, %rd29, %rd139; + add.s32 %r372, %r29, %r350; + // begin inline asm + cp.async.cg.shared.global [%r372], [%rd134], 16; + + // end inline asm + mov.b32 %r379, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r2165, %r379, 34816; + setp.eq.b32 %p34, %r31, 3; + @%p34 bra $L__BB2_58; + setp.eq.b32 %p35, %r31, 2; + @%p35 bra $L__BB2_59; + mov.b32 %r380, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r2165, %r380, 17408; + bra.uni $L__BB2_59; +$L__BB2_58: + mov.b32 %r381, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r2165, %r381, 52224; +$L__BB2_59: + add.s32 %r383, %r74, %r32; + mad.lo.s32 %r384, %r383, 136, %r12; + or.b32 %r385, %r178, %r179; + cvt.u64.u32 %rd141, %r385; + add.s64 %rd142, %rd22, %rd141; + shl.b64 %rd143, %rd142, 1; + add.s64 %rd140, %rd29, %rd143; + shl.b32 %r386, %r384, 1; + add.s32 %r382, %r2165, %r386; + // begin inline asm + cp.async.cg.shared.global [%r382], [%rd140], 16; + + // end inline asm + mov.b32 %r387, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r2166, %r387, 34816; + setp.eq.b32 %p36, %r33, 3; + @%p36 bra $L__BB2_62; + setp.eq.b32 %p37, %r33, 2; + @%p37 bra $L__BB2_63; + mov.b32 %r388, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r2166, %r388, 17408; + bra.uni $L__BB2_63; +$L__BB2_62: + mov.b32 %r389, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r2166, %r389, 52224; +$L__BB2_63: + add.s32 %r391, %r74, %r34; + mad.lo.s32 %r392, %r391, 136, %r12; + or.b32 %r393, %r190, %r191; + cvt.u64.u32 %rd145, %r393; + add.s64 %rd146, %rd22, %rd145; + shl.b64 %rd147, %rd146, 1; + add.s64 %rd144, %rd29, %rd147; + shl.b32 %r394, %r392, 1; + add.s32 %r390, %r2166, %r394; + // begin inline asm + cp.async.cg.shared.global [%r390], [%rd144], 16; + + // end inline asm + mov.b32 %r395, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r2167, %r395, 34816; + setp.eq.b32 %p38, %r35, 3; + @%p38 bra $L__BB2_66; + setp.eq.b32 %p39, %r35, 2; + @%p39 bra $L__BB2_67; + mov.b32 %r396, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r2167, %r396, 17408; + bra.uni $L__BB2_67; +$L__BB2_66: + mov.b32 %r397, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r2167, %r397, 52224; +$L__BB2_67: + setp.gt.u32 %p40, %r2, 31; + add.s32 %r407, %r74, %r36; + mad.lo.s32 %r408, %r407, 136, %r12; + or.b32 %r409, %r210, %r211; + cvt.u64.u32 %rd157, %r409; + add.s64 %rd158, %rd22, %rd157; + shl.b64 %rd159, %rd158, 1; + add.s64 %rd148, %rd29, %rd159; + shl.b32 %r410, %r408, 1; + add.s32 %r398, %r2167, %r410; + // begin inline asm + cp.async.cg.shared.global [%r398], [%rd148], 16; + + // end inline asm + add.s64 %rd160, %rd22, %rd13; + shl.b64 %rd161, %rd160, 1; + add.s64 %rd149, %rd29, %rd161; + add.s32 %r399, %r37, %r350; + // begin inline asm + cp.async.cg.shared.global [%r399], [%rd149], 16; + + // end inline asm + add.s32 %r411, %r74, %r39; + mad.lo.s32 %r412, %r411, 136, %r12; + add.s64 %rd162, %rd22, %rd14; + shl.b64 %rd163, %rd162, 1; + add.s64 %rd150, %rd29, %rd163; + shl.b32 %r413, %r412, 1; + add.s32 %r400, %r40, %r413; + // begin inline asm + cp.async.cg.shared.global [%r400], [%rd150], 16; + + // end inline asm + add.s32 %r414, %r74, %r43; + mad.lo.s32 %r415, %r414, 136, %r12; + add.s64 %rd164, %rd22, %rd15; + shl.b64 %rd165, %rd164, 1; + add.s64 %rd151, %rd29, %rd165; + shl.b32 %r416, %r415, 1; + add.s32 %r401, %r44, %r416; + // begin inline asm + cp.async.cg.shared.global [%r401], [%rd151], 16; + + // end inline asm + add.s32 %r417, %r74, %r47; + mad.lo.s32 %r418, %r417, 136, %r12; + add.s64 %rd166, %rd22, %rd16; + shl.b64 %rd167, %rd166, 1; + add.s64 %rd152, %rd29, %rd167; + shl.b32 %r419, %r418, 1; + add.s32 %r402, %r48, %r419; + // begin inline asm + cp.async.cg.shared.global [%r402], [%rd152], 16; + + // end inline asm + add.s64 %rd168, %rd22, %rd17; + shl.b64 %rd169, %rd168, 1; + add.s64 %rd153, %rd29, %rd169; + mov.b32 %r420, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r421, %r420, %r350; + add.s32 %r403, %r421, 52224; + // begin inline asm + cp.async.cg.shared.global [%r403], [%rd153], 16; + + // end inline asm + add.s32 %r422, %r74, %r52; + mad.lo.s32 %r423, %r422, 136, %r12; + add.s64 %rd170, %rd22, %rd18; + shl.b64 %rd171, %rd170, 1; + add.s64 %rd154, %rd29, %rd171; + shl.b32 %r424, %r423, 1; + add.s32 %r425, %r420, %r424; + add.s32 %r404, %r425, 52224; + // begin inline asm + cp.async.cg.shared.global [%r404], [%rd154], 16; + + // end inline asm + add.s32 %r426, %r74, %r55; + mad.lo.s32 %r427, %r426, 136, %r12; + add.s32 %r428, %r11, 14336; + and.b32 %r429, %r428, 28672; + shl.b32 %r430, %r55, 7; + or.b32 %r431, %r429, %r430; + cvt.u64.u32 %rd172, %r431; + add.s64 %rd173, %rd22, %rd172; + shl.b64 %rd174, %rd173, 1; + add.s64 %rd155, %rd29, %rd174; + shl.b32 %r432, %r427, 1; + add.s32 %r433, %r420, %r432; + add.s32 %r405, %r433, 52224; + // begin inline asm + cp.async.cg.shared.global [%r405], [%rd155], 16; + + // end inline asm + add.s32 %r434, %r74, %r56; + mad.lo.s32 %r435, %r434, 136, %r12; + add.s32 %r436, %r11, 15360; + and.b32 %r437, %r436, 28672; + shl.b32 %r438, %r56, 7; + or.b32 %r439, %r437, %r438; + cvt.u64.u32 %rd175, %r439; + add.s64 %rd176, %rd22, %rd175; + shl.b64 %rd177, %rd176, 1; + add.s64 %rd156, %rd29, %rd177; + shl.b32 %r440, %r435, 1; + add.s32 %r441, %r420, %r440; + add.s32 %r406, %r441, 52224; + // begin inline asm + cp.async.cg.shared.global [%r406], [%rd156], 16; + + // end inline asm + @%p40 bra $L__BB2_69; + add.s32 %r443, %r74, %r2; + mul.wide.u32 %rd179, %r2161, 48; + add.s64 %rd180, %rd179, %rd1; + shl.b64 %rd181, %rd180, 9; + add.s64 %rd178, %rd10, %rd181; + shl.b32 %r444, %r443, 4; + mov.b32 %r445, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r446, %r445, %r444; + add.s32 %r442, %r446, 96768; + // begin inline asm + cp.async.cg.shared.global [%r442], [%rd178], 16; + + // end inline asm +$L__BB2_69: + setp.ne.b32 %p41, %r2, 0; + @%p41 bra $L__BB2_71; + mul.wide.u32 %rd183, %r2161, 192; + add.s64 %rd182, %rd3, %rd183; + shl.b32 %r448, %r73, 2; + mov.b32 %r449, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r450, %r449, %r448; + add.s32 %r447, %r450, 97792; + // begin inline asm + cp.async.ca.shared.global [%r447], [%rd182], 4; + + // end inline asm +$L__BB2_71: + // begin inline asm + cp.async.commit_group; + + // end inline asm +$L__BB2_72: + cvt.u32.u64 %r1091, %rd19; + mul.lo.s32 %r76, %r71, 4352; + shl.b32 %r77, %r71, 5; + abs.f32 %r1092, %r2097; + max.f32 %r1093, %r1092, 0f00000000; + abs.f32 %r1094, %r2098; + max.f32 %r1095, %r1093, %r1094; + abs.f32 %r1096, %r2099; + max.f32 %r1097, %r1096, 0f00000000; + abs.f32 %r1098, %r2100; + max.f32 %r1099, %r1097, %r1098; + abs.f32 %r1100, %r2101; + max.f32 %r1101, %r1100, 0f00000000; + abs.f32 %r1102, %r2102; + max.f32 %r1103, %r1101, %r1102; + abs.f32 %r1104, %r2103; + max.f32 %r1105, %r1104, 0f00000000; + abs.f32 %r1106, %r2104; + max.f32 %r1107, %r1105, %r1106; + abs.f32 %r1108, %r2105; + max.f32 %r1109, %r1108, 0f00000000; + abs.f32 %r1110, %r2106; + max.f32 %r1111, %r1109, %r1110; + abs.f32 %r1112, %r2107; + max.f32 %r1113, %r1112, 0f00000000; + abs.f32 %r1114, %r2108; + max.f32 %r1115, %r1113, %r1114; + abs.f32 %r1116, %r2109; + max.f32 %r1117, %r1116, 0f00000000; + abs.f32 %r1118, %r2110; + max.f32 %r1119, %r1117, %r1118; + abs.f32 %r1120, %r2111; + max.f32 %r1121, %r1120, 0f00000000; + abs.f32 %r1122, %r2112; + max.f32 %r1123, %r1121, %r1122; + abs.f32 %r1124, %r2113; + max.f32 %r1125, %r1095, %r1124; + abs.f32 %r1126, %r2114; + max.f32 %r1127, %r1125, %r1126; + abs.f32 %r1128, %r2115; + max.f32 %r1129, %r1099, %r1128; + abs.f32 %r1130, %r2116; + max.f32 %r1131, %r1129, %r1130; + abs.f32 %r1132, %r2117; + max.f32 %r1133, %r1103, %r1132; + abs.f32 %r1134, %r2118; + max.f32 %r1135, %r1133, %r1134; + abs.f32 %r1136, %r2119; + max.f32 %r1137, %r1107, %r1136; + abs.f32 %r1138, %r2120; + max.f32 %r1139, %r1137, %r1138; + abs.f32 %r1140, %r2121; + max.f32 %r1141, %r1111, %r1140; + abs.f32 %r1142, %r2122; + max.f32 %r1143, %r1141, %r1142; + abs.f32 %r1144, %r2123; + max.f32 %r1145, %r1115, %r1144; + abs.f32 %r1146, %r2124; + max.f32 %r1147, %r1145, %r1146; + abs.f32 %r1148, %r2125; + max.f32 %r1149, %r1119, %r1148; + abs.f32 %r1150, %r2126; + max.f32 %r1151, %r1149, %r1150; + abs.f32 %r1152, %r2127; + max.f32 %r1153, %r1123, %r1152; + abs.f32 %r1154, %r2128; + max.f32 %r1155, %r1153, %r1154; + abs.f32 %r1156, %r2129; + max.f32 %r1157, %r1127, %r1156; + abs.f32 %r1158, %r2130; + max.f32 %r1159, %r1157, %r1158; + abs.f32 %r1160, %r2131; + max.f32 %r1161, %r1131, %r1160; + abs.f32 %r1162, %r2132; + max.f32 %r1163, %r1161, %r1162; + abs.f32 %r1164, %r2133; + max.f32 %r1165, %r1135, %r1164; + abs.f32 %r1166, %r2134; + max.f32 %r1167, %r1165, %r1166; + abs.f32 %r1168, %r2135; + max.f32 %r1169, %r1139, %r1168; + abs.f32 %r1170, %r2136; + max.f32 %r1171, %r1169, %r1170; + abs.f32 %r1172, %r2137; + max.f32 %r1173, %r1143, %r1172; + abs.f32 %r1174, %r2138; + max.f32 %r1175, %r1173, %r1174; + abs.f32 %r1176, %r2139; + max.f32 %r1177, %r1147, %r1176; + abs.f32 %r1178, %r2140; + max.f32 %r1179, %r1177, %r1178; + abs.f32 %r1180, %r2141; + max.f32 %r1181, %r1151, %r1180; + abs.f32 %r1182, %r2142; + max.f32 %r1183, %r1181, %r1182; + abs.f32 %r1184, %r2143; + max.f32 %r1185, %r1155, %r1184; + abs.f32 %r1186, %r2144; + max.f32 %r1187, %r1185, %r1186; + abs.f32 %r1188, %r2145; + max.f32 %r1189, %r1159, %r1188; + abs.f32 %r1190, %r2146; + max.f32 %r1191, %r1189, %r1190; + abs.f32 %r1192, %r2147; + max.f32 %r1193, %r1163, %r1192; + abs.f32 %r1194, %r2148; + max.f32 %r1195, %r1193, %r1194; + abs.f32 %r1196, %r2149; + max.f32 %r1197, %r1167, %r1196; + abs.f32 %r1198, %r2150; + max.f32 %r1199, %r1197, %r1198; + abs.f32 %r1200, %r2151; + max.f32 %r1201, %r1171, %r1200; + abs.f32 %r1202, %r2152; + max.f32 %r1203, %r1201, %r1202; + abs.f32 %r1204, %r2153; + max.f32 %r1205, %r1175, %r1204; + abs.f32 %r1206, %r2154; + max.f32 %r1207, %r1205, %r1206; + abs.f32 %r1208, %r2155; + max.f32 %r1209, %r1179, %r1208; + abs.f32 %r1210, %r2156; + max.f32 %r1211, %r1209, %r1210; + abs.f32 %r1212, %r2157; + max.f32 %r1213, %r1183, %r1212; + abs.f32 %r1214, %r2158; + max.f32 %r1215, %r1213, %r1214; + abs.f32 %r1216, %r2159; + max.f32 %r1217, %r1187, %r1216; + abs.f32 %r1218, %r2160; + max.f32 %r1219, %r1217, %r1218; + max.f32 %r1220, %r1191, %r1195; + max.f32 %r1221, %r1199, %r1203; + max.f32 %r1222, %r1220, %r1221; + max.f32 %r1223, %r1207, %r1211; + max.f32 %r1224, %r1215, %r1219; + max.f32 %r1225, %r1223, %r1224; + max.f32 %r1226, %r1222, %r1225; + mov.b32 %r1227, -1; + redux.sync.max.u32 %r1228, %r1226, %r1227; + and.b32 %r1229, %r1228, 2147483647; + setp.eq.b32 %p42, %r1229, 0; + shr.s32 %r1230, %r1228, 23; + sub.s32 %r1231, 141, %r1230; + max.s32 %r1232, %r1231, -40; + min.s32 %r1233, %r1232, 40; + selp.b32 %r78, 0, %r1233, %p42; + shl.b32 %r1234, %r78, 23; + add.s32 %r1235, %r1234, 1065353216; + mul.f32 %r451, %r2097, %r1235; + mul.f32 %r452, %r2098, %r1235; + // begin inline asm + { cvt.rn.f16x2.f32 %r454, %r452, %r451; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r454; + cvt.f32.f16 %r453, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r454; + cvt.f32.f16 %r455, high;} + + // end inline asm + sub.f32 %r456, %r451, %r453; + sub.f32 %r457, %r452, %r455; + // begin inline asm + { cvt.rn.f16x2.f32 %r481, %r457, %r456; } + + // end inline asm + mul.f32 %r458, %r2099, %r1235; + mul.f32 %r459, %r2100, %r1235; + // begin inline asm + { cvt.rn.f16x2.f32 %r461, %r459, %r458; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r461; + cvt.f32.f16 %r460, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r461; + cvt.f32.f16 %r462, high;} + + // end inline asm + sub.f32 %r463, %r458, %r460; + sub.f32 %r464, %r459, %r462; + // begin inline asm + { cvt.rn.f16x2.f32 %r482, %r464, %r463; } + + // end inline asm + mul.f32 %r465, %r2101, %r1235; + mul.f32 %r466, %r2102, %r1235; + // begin inline asm + { cvt.rn.f16x2.f32 %r468, %r466, %r465; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r468; + cvt.f32.f16 %r467, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r468; + cvt.f32.f16 %r469, high;} + + // end inline asm + sub.f32 %r470, %r465, %r467; + sub.f32 %r471, %r466, %r469; + // begin inline asm + { cvt.rn.f16x2.f32 %r483, %r471, %r470; } + + // end inline asm + mul.f32 %r472, %r2103, %r1235; + mul.f32 %r473, %r2104, %r1235; + // begin inline asm + { cvt.rn.f16x2.f32 %r475, %r473, %r472; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r475; + cvt.f32.f16 %r474, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r475; + cvt.f32.f16 %r476, high;} + + // end inline asm + sub.f32 %r477, %r472, %r474; + sub.f32 %r478, %r473, %r476; + // begin inline asm + { cvt.rn.f16x2.f32 %r484, %r478, %r477; } + + // end inline asm + add.s32 %r1236, %r63, %r76; + shl.b32 %r1237, %r1236, 1; + mov.b32 %r1238, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r479, %r1238, %r1237; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r485,%r486,%r493,%r494}, [%r479]; + // end inline asm + add.s32 %r480, %r479, 17408; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r491,%r492,%r499,%r500}, [%r480]; + // end inline asm + mov.b32 %r2168, 0; + mov.b32 %r487, %r2168; + mov.b32 %r488, %r2168; + mov.b32 %r489, %r2168; + mov.b32 %r490, %r2168; + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r487,%r488,%r489,%r490}, {%r481,%r482,%r483,%r484}, {%r485,%r486}, {%r487,%r488,%r489,%r490}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r487,%r488,%r489,%r490}, {%r454,%r461,%r468,%r475}, {%r491,%r492}, {%r487,%r488,%r489,%r490}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r487,%r488,%r489,%r490}, {%r454,%r461,%r468,%r475}, {%r485,%r486}, {%r487,%r488,%r489,%r490}; + // end inline asm + mov.b32 %r495, %r2168; + mov.b32 %r496, %r2168; + mov.b32 %r497, %r2168; + mov.b32 %r498, %r2168; + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r495,%r496,%r497,%r498}, {%r481,%r482,%r483,%r484}, {%r493,%r494}, {%r495,%r496,%r497,%r498}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r495,%r496,%r497,%r498}, {%r454,%r461,%r468,%r475}, {%r499,%r500}, {%r495,%r496,%r497,%r498}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r495,%r496,%r497,%r498}, {%r454,%r461,%r468,%r475}, {%r493,%r494}, {%r495,%r496,%r497,%r498}; + // end inline asm + add.s32 %r501, %r479, 34816; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r503,%r504,%r511,%r512}, [%r501]; + // end inline asm + add.s32 %r502, %r479, 52224; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r509,%r510,%r517,%r518}, [%r502]; + // end inline asm + mov.b32 %r505, %r2168; + mov.b32 %r506, %r2168; + mov.b32 %r507, %r2168; + mov.b32 %r508, %r2168; + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r505,%r506,%r507,%r508}, {%r481,%r482,%r483,%r484}, {%r503,%r504}, {%r505,%r506,%r507,%r508}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r505,%r506,%r507,%r508}, {%r454,%r461,%r468,%r475}, {%r509,%r510}, {%r505,%r506,%r507,%r508}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r505,%r506,%r507,%r508}, {%r454,%r461,%r468,%r475}, {%r503,%r504}, {%r505,%r506,%r507,%r508}; + // end inline asm + mov.b32 %r513, %r2168; + mov.b32 %r514, %r2168; + mov.b32 %r515, %r2168; + mov.b32 %r516, %r2168; + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r513,%r514,%r515,%r516}, {%r481,%r482,%r483,%r484}, {%r511,%r512}, {%r513,%r514,%r515,%r516}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r513,%r514,%r515,%r516}, {%r454,%r461,%r468,%r475}, {%r517,%r518}, {%r513,%r514,%r515,%r516}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r513,%r514,%r515,%r516}, {%r454,%r461,%r468,%r475}, {%r511,%r512}, {%r513,%r514,%r515,%r516}; + // end inline asm + add.s32 %r519, %r479, 4352; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r521,%r522,%r529,%r530}, [%r519]; + // end inline asm + add.s32 %r520, %r479, 21760; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r527,%r528,%r535,%r536}, [%r520]; + // end inline asm + mov.b32 %r523, %r2168; + mov.b32 %r524, %r2168; + mov.b32 %r525, %r2168; + mov.b32 %r526, %r2168; + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r523,%r524,%r525,%r526}, {%r481,%r482,%r483,%r484}, {%r521,%r522}, {%r523,%r524,%r525,%r526}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r523,%r524,%r525,%r526}, {%r454,%r461,%r468,%r475}, {%r527,%r528}, {%r523,%r524,%r525,%r526}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r523,%r524,%r525,%r526}, {%r454,%r461,%r468,%r475}, {%r521,%r522}, {%r523,%r524,%r525,%r526}; + // end inline asm + mov.b32 %r531, %r2168; + mov.b32 %r532, %r2168; + mov.b32 %r533, %r2168; + mov.b32 %r534, %r2168; + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r531,%r532,%r533,%r534}, {%r481,%r482,%r483,%r484}, {%r529,%r530}, {%r531,%r532,%r533,%r534}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r531,%r532,%r533,%r534}, {%r454,%r461,%r468,%r475}, {%r535,%r536}, {%r531,%r532,%r533,%r534}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r531,%r532,%r533,%r534}, {%r454,%r461,%r468,%r475}, {%r529,%r530}, {%r531,%r532,%r533,%r534}; + // end inline asm + add.s32 %r537, %r479, 39168; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r539,%r540,%r547,%r548}, [%r537]; + // end inline asm + add.s32 %r538, %r479, 56576; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r545,%r546,%r553,%r554}, [%r538]; + // end inline asm + mov.b32 %r541, %r2168; + mov.b32 %r542, %r2168; + mov.b32 %r543, %r2168; + mov.b32 %r544, %r2168; + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r541,%r542,%r543,%r544}, {%r481,%r482,%r483,%r484}, {%r539,%r540}, {%r541,%r542,%r543,%r544}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r541,%r542,%r543,%r544}, {%r454,%r461,%r468,%r475}, {%r545,%r546}, {%r541,%r542,%r543,%r544}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r541,%r542,%r543,%r544}, {%r454,%r461,%r468,%r475}, {%r539,%r540}, {%r541,%r542,%r543,%r544}; + // end inline asm + mov.b32 %r549, %r2168; + mov.b32 %r550, %r2168; + mov.b32 %r551, %r2168; + mov.b32 %r552, %r2168; + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r549,%r550,%r551,%r552}, {%r481,%r482,%r483,%r484}, {%r547,%r548}, {%r549,%r550,%r551,%r552}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r549,%r550,%r551,%r552}, {%r454,%r461,%r468,%r475}, {%r553,%r554}, {%r549,%r550,%r551,%r552}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r549,%r550,%r551,%r552}, {%r454,%r461,%r468,%r475}, {%r547,%r548}, {%r549,%r550,%r551,%r552}; + // end inline asm + mul.f32 %r555, %r2105, %r1235; + mul.f32 %r556, %r2106, %r1235; + // begin inline asm + { cvt.rn.f16x2.f32 %r558, %r556, %r555; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r558; + cvt.f32.f16 %r557, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r558; + cvt.f32.f16 %r559, high;} + + // end inline asm + sub.f32 %r560, %r555, %r557; + sub.f32 %r561, %r556, %r559; + // begin inline asm + { cvt.rn.f16x2.f32 %r585, %r561, %r560; } + + // end inline asm + mul.f32 %r562, %r2107, %r1235; + mul.f32 %r563, %r2108, %r1235; + // begin inline asm + { cvt.rn.f16x2.f32 %r565, %r563, %r562; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r565; + cvt.f32.f16 %r564, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r565; + cvt.f32.f16 %r566, high;} + + // end inline asm + sub.f32 %r567, %r562, %r564; + sub.f32 %r568, %r563, %r566; + // begin inline asm + { cvt.rn.f16x2.f32 %r586, %r568, %r567; } + + // end inline asm + mul.f32 %r569, %r2109, %r1235; + mul.f32 %r570, %r2110, %r1235; + // begin inline asm + { cvt.rn.f16x2.f32 %r572, %r570, %r569; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r572; + cvt.f32.f16 %r571, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r572; + cvt.f32.f16 %r573, high;} + + // end inline asm + sub.f32 %r574, %r569, %r571; + sub.f32 %r575, %r570, %r573; + // begin inline asm + { cvt.rn.f16x2.f32 %r587, %r575, %r574; } + + // end inline asm + mul.f32 %r576, %r2111, %r1235; + mul.f32 %r577, %r2112, %r1235; + // begin inline asm + { cvt.rn.f16x2.f32 %r579, %r577, %r576; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r579; + cvt.f32.f16 %r578, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r579; + cvt.f32.f16 %r580, high;} + + // end inline asm + sub.f32 %r581, %r576, %r578; + sub.f32 %r582, %r577, %r580; + // begin inline asm + { cvt.rn.f16x2.f32 %r588, %r582, %r581; } + + // end inline asm + add.s32 %r583, %r479, 32; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r589,%r590,%r593,%r594}, [%r583]; + // end inline asm + add.s32 %r584, %r479, 17440; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r591,%r592,%r595,%r596}, [%r584]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r487,%r488,%r489,%r490}, {%r585,%r586,%r587,%r588}, {%r589,%r590}, {%r487,%r488,%r489,%r490}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r487,%r488,%r489,%r490}, {%r558,%r565,%r572,%r579}, {%r591,%r592}, {%r487,%r488,%r489,%r490}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r487,%r488,%r489,%r490}, {%r558,%r565,%r572,%r579}, {%r589,%r590}, {%r487,%r488,%r489,%r490}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r495,%r496,%r497,%r498}, {%r585,%r586,%r587,%r588}, {%r593,%r594}, {%r495,%r496,%r497,%r498}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r495,%r496,%r497,%r498}, {%r558,%r565,%r572,%r579}, {%r595,%r596}, {%r495,%r496,%r497,%r498}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r495,%r496,%r497,%r498}, {%r558,%r565,%r572,%r579}, {%r593,%r594}, {%r495,%r496,%r497,%r498}; + // end inline asm + add.s32 %r597, %r479, 34848; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r599,%r600,%r603,%r604}, [%r597]; + // end inline asm + add.s32 %r598, %r479, 52256; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r601,%r602,%r605,%r606}, [%r598]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r505,%r506,%r507,%r508}, {%r585,%r586,%r587,%r588}, {%r599,%r600}, {%r505,%r506,%r507,%r508}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r505,%r506,%r507,%r508}, {%r558,%r565,%r572,%r579}, {%r601,%r602}, {%r505,%r506,%r507,%r508}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r505,%r506,%r507,%r508}, {%r558,%r565,%r572,%r579}, {%r599,%r600}, {%r505,%r506,%r507,%r508}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r513,%r514,%r515,%r516}, {%r585,%r586,%r587,%r588}, {%r603,%r604}, {%r513,%r514,%r515,%r516}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r513,%r514,%r515,%r516}, {%r558,%r565,%r572,%r579}, {%r605,%r606}, {%r513,%r514,%r515,%r516}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r513,%r514,%r515,%r516}, {%r558,%r565,%r572,%r579}, {%r603,%r604}, {%r513,%r514,%r515,%r516}; + // end inline asm + add.s32 %r607, %r479, 4384; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r609,%r610,%r613,%r614}, [%r607]; + // end inline asm + add.s32 %r608, %r479, 21792; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r611,%r612,%r615,%r616}, [%r608]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r523,%r524,%r525,%r526}, {%r585,%r586,%r587,%r588}, {%r609,%r610}, {%r523,%r524,%r525,%r526}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r523,%r524,%r525,%r526}, {%r558,%r565,%r572,%r579}, {%r611,%r612}, {%r523,%r524,%r525,%r526}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r523,%r524,%r525,%r526}, {%r558,%r565,%r572,%r579}, {%r609,%r610}, {%r523,%r524,%r525,%r526}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r531,%r532,%r533,%r534}, {%r585,%r586,%r587,%r588}, {%r613,%r614}, {%r531,%r532,%r533,%r534}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r531,%r532,%r533,%r534}, {%r558,%r565,%r572,%r579}, {%r615,%r616}, {%r531,%r532,%r533,%r534}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r531,%r532,%r533,%r534}, {%r558,%r565,%r572,%r579}, {%r613,%r614}, {%r531,%r532,%r533,%r534}; + // end inline asm + add.s32 %r617, %r479, 39200; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r619,%r620,%r623,%r624}, [%r617]; + // end inline asm + add.s32 %r618, %r479, 56608; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r621,%r622,%r625,%r626}, [%r618]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r541,%r542,%r543,%r544}, {%r585,%r586,%r587,%r588}, {%r619,%r620}, {%r541,%r542,%r543,%r544}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r541,%r542,%r543,%r544}, {%r558,%r565,%r572,%r579}, {%r621,%r622}, {%r541,%r542,%r543,%r544}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r541,%r542,%r543,%r544}, {%r558,%r565,%r572,%r579}, {%r619,%r620}, {%r541,%r542,%r543,%r544}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r549,%r550,%r551,%r552}, {%r585,%r586,%r587,%r588}, {%r623,%r624}, {%r549,%r550,%r551,%r552}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r549,%r550,%r551,%r552}, {%r558,%r565,%r572,%r579}, {%r625,%r626}, {%r549,%r550,%r551,%r552}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r549,%r550,%r551,%r552}, {%r558,%r565,%r572,%r579}, {%r623,%r624}, {%r549,%r550,%r551,%r552}; + // end inline asm + mul.f32 %r627, %r2113, %r1235; + mul.f32 %r628, %r2114, %r1235; + // begin inline asm + { cvt.rn.f16x2.f32 %r630, %r628, %r627; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r630; + cvt.f32.f16 %r629, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r630; + cvt.f32.f16 %r631, high;} + + // end inline asm + sub.f32 %r632, %r627, %r629; + sub.f32 %r633, %r628, %r631; + // begin inline asm + { cvt.rn.f16x2.f32 %r657, %r633, %r632; } + + // end inline asm + mul.f32 %r634, %r2115, %r1235; + mul.f32 %r635, %r2116, %r1235; + // begin inline asm + { cvt.rn.f16x2.f32 %r637, %r635, %r634; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r637; + cvt.f32.f16 %r636, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r637; + cvt.f32.f16 %r638, high;} + + // end inline asm + sub.f32 %r639, %r634, %r636; + sub.f32 %r640, %r635, %r638; + // begin inline asm + { cvt.rn.f16x2.f32 %r658, %r640, %r639; } + + // end inline asm + mul.f32 %r641, %r2117, %r1235; + mul.f32 %r642, %r2118, %r1235; + // begin inline asm + { cvt.rn.f16x2.f32 %r644, %r642, %r641; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r644; + cvt.f32.f16 %r643, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r644; + cvt.f32.f16 %r645, high;} + + // end inline asm + sub.f32 %r646, %r641, %r643; + sub.f32 %r647, %r642, %r645; + // begin inline asm + { cvt.rn.f16x2.f32 %r659, %r647, %r646; } + + // end inline asm + mul.f32 %r648, %r2119, %r1235; + mul.f32 %r649, %r2120, %r1235; + // begin inline asm + { cvt.rn.f16x2.f32 %r651, %r649, %r648; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r651; + cvt.f32.f16 %r650, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r651; + cvt.f32.f16 %r652, high;} + + // end inline asm + sub.f32 %r653, %r648, %r650; + sub.f32 %r654, %r649, %r652; + // begin inline asm + { cvt.rn.f16x2.f32 %r660, %r654, %r653; } + + // end inline asm + add.s32 %r655, %r479, 64; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r661,%r662,%r665,%r666}, [%r655]; + // end inline asm + add.s32 %r656, %r479, 17472; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r663,%r664,%r667,%r668}, [%r656]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r487,%r488,%r489,%r490}, {%r657,%r658,%r659,%r660}, {%r661,%r662}, {%r487,%r488,%r489,%r490}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r487,%r488,%r489,%r490}, {%r630,%r637,%r644,%r651}, {%r663,%r664}, {%r487,%r488,%r489,%r490}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r487,%r488,%r489,%r490}, {%r630,%r637,%r644,%r651}, {%r661,%r662}, {%r487,%r488,%r489,%r490}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r495,%r496,%r497,%r498}, {%r657,%r658,%r659,%r660}, {%r665,%r666}, {%r495,%r496,%r497,%r498}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r495,%r496,%r497,%r498}, {%r630,%r637,%r644,%r651}, {%r667,%r668}, {%r495,%r496,%r497,%r498}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r495,%r496,%r497,%r498}, {%r630,%r637,%r644,%r651}, {%r665,%r666}, {%r495,%r496,%r497,%r498}; + // end inline asm + add.s32 %r669, %r479, 34880; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r671,%r672,%r675,%r676}, [%r669]; + // end inline asm + add.s32 %r670, %r479, 52288; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r673,%r674,%r677,%r678}, [%r670]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r505,%r506,%r507,%r508}, {%r657,%r658,%r659,%r660}, {%r671,%r672}, {%r505,%r506,%r507,%r508}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r505,%r506,%r507,%r508}, {%r630,%r637,%r644,%r651}, {%r673,%r674}, {%r505,%r506,%r507,%r508}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r505,%r506,%r507,%r508}, {%r630,%r637,%r644,%r651}, {%r671,%r672}, {%r505,%r506,%r507,%r508}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r513,%r514,%r515,%r516}, {%r657,%r658,%r659,%r660}, {%r675,%r676}, {%r513,%r514,%r515,%r516}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r513,%r514,%r515,%r516}, {%r630,%r637,%r644,%r651}, {%r677,%r678}, {%r513,%r514,%r515,%r516}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r513,%r514,%r515,%r516}, {%r630,%r637,%r644,%r651}, {%r675,%r676}, {%r513,%r514,%r515,%r516}; + // end inline asm + add.s32 %r679, %r479, 4416; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r681,%r682,%r685,%r686}, [%r679]; + // end inline asm + add.s32 %r680, %r479, 21824; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r683,%r684,%r687,%r688}, [%r680]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r523,%r524,%r525,%r526}, {%r657,%r658,%r659,%r660}, {%r681,%r682}, {%r523,%r524,%r525,%r526}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r523,%r524,%r525,%r526}, {%r630,%r637,%r644,%r651}, {%r683,%r684}, {%r523,%r524,%r525,%r526}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r523,%r524,%r525,%r526}, {%r630,%r637,%r644,%r651}, {%r681,%r682}, {%r523,%r524,%r525,%r526}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r531,%r532,%r533,%r534}, {%r657,%r658,%r659,%r660}, {%r685,%r686}, {%r531,%r532,%r533,%r534}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r531,%r532,%r533,%r534}, {%r630,%r637,%r644,%r651}, {%r687,%r688}, {%r531,%r532,%r533,%r534}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r531,%r532,%r533,%r534}, {%r630,%r637,%r644,%r651}, {%r685,%r686}, {%r531,%r532,%r533,%r534}; + // end inline asm + add.s32 %r689, %r479, 39232; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r691,%r692,%r695,%r696}, [%r689]; + // end inline asm + add.s32 %r690, %r479, 56640; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r693,%r694,%r697,%r698}, [%r690]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r541,%r542,%r543,%r544}, {%r657,%r658,%r659,%r660}, {%r691,%r692}, {%r541,%r542,%r543,%r544}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r541,%r542,%r543,%r544}, {%r630,%r637,%r644,%r651}, {%r693,%r694}, {%r541,%r542,%r543,%r544}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r541,%r542,%r543,%r544}, {%r630,%r637,%r644,%r651}, {%r691,%r692}, {%r541,%r542,%r543,%r544}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r549,%r550,%r551,%r552}, {%r657,%r658,%r659,%r660}, {%r695,%r696}, {%r549,%r550,%r551,%r552}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r549,%r550,%r551,%r552}, {%r630,%r637,%r644,%r651}, {%r697,%r698}, {%r549,%r550,%r551,%r552}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r549,%r550,%r551,%r552}, {%r630,%r637,%r644,%r651}, {%r695,%r696}, {%r549,%r550,%r551,%r552}; + // end inline asm + mul.f32 %r699, %r2121, %r1235; + mul.f32 %r700, %r2122, %r1235; + // begin inline asm + { cvt.rn.f16x2.f32 %r702, %r700, %r699; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r702; + cvt.f32.f16 %r701, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r702; + cvt.f32.f16 %r703, high;} + + // end inline asm + sub.f32 %r704, %r699, %r701; + sub.f32 %r705, %r700, %r703; + // begin inline asm + { cvt.rn.f16x2.f32 %r729, %r705, %r704; } + + // end inline asm + mul.f32 %r706, %r2123, %r1235; + mul.f32 %r707, %r2124, %r1235; + // begin inline asm + { cvt.rn.f16x2.f32 %r709, %r707, %r706; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r709; + cvt.f32.f16 %r708, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r709; + cvt.f32.f16 %r710, high;} + + // end inline asm + sub.f32 %r711, %r706, %r708; + sub.f32 %r712, %r707, %r710; + // begin inline asm + { cvt.rn.f16x2.f32 %r730, %r712, %r711; } + + // end inline asm + mul.f32 %r713, %r2125, %r1235; + mul.f32 %r714, %r2126, %r1235; + // begin inline asm + { cvt.rn.f16x2.f32 %r716, %r714, %r713; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r716; + cvt.f32.f16 %r715, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r716; + cvt.f32.f16 %r717, high;} + + // end inline asm + sub.f32 %r718, %r713, %r715; + sub.f32 %r719, %r714, %r717; + // begin inline asm + { cvt.rn.f16x2.f32 %r731, %r719, %r718; } + + // end inline asm + mul.f32 %r720, %r2127, %r1235; + mul.f32 %r721, %r2128, %r1235; + // begin inline asm + { cvt.rn.f16x2.f32 %r723, %r721, %r720; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r723; + cvt.f32.f16 %r722, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r723; + cvt.f32.f16 %r724, high;} + + // end inline asm + sub.f32 %r725, %r720, %r722; + sub.f32 %r726, %r721, %r724; + // begin inline asm + { cvt.rn.f16x2.f32 %r732, %r726, %r725; } + + // end inline asm + add.s32 %r727, %r479, 96; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r733,%r734,%r737,%r738}, [%r727]; + // end inline asm + add.s32 %r728, %r479, 17504; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r735,%r736,%r739,%r740}, [%r728]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r487,%r488,%r489,%r490}, {%r729,%r730,%r731,%r732}, {%r733,%r734}, {%r487,%r488,%r489,%r490}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r487,%r488,%r489,%r490}, {%r702,%r709,%r716,%r723}, {%r735,%r736}, {%r487,%r488,%r489,%r490}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r487,%r488,%r489,%r490}, {%r702,%r709,%r716,%r723}, {%r733,%r734}, {%r487,%r488,%r489,%r490}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r495,%r496,%r497,%r498}, {%r729,%r730,%r731,%r732}, {%r737,%r738}, {%r495,%r496,%r497,%r498}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r495,%r496,%r497,%r498}, {%r702,%r709,%r716,%r723}, {%r739,%r740}, {%r495,%r496,%r497,%r498}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r495,%r496,%r497,%r498}, {%r702,%r709,%r716,%r723}, {%r737,%r738}, {%r495,%r496,%r497,%r498}; + // end inline asm + add.s32 %r741, %r479, 34912; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r743,%r744,%r747,%r748}, [%r741]; + // end inline asm + add.s32 %r742, %r479, 52320; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r745,%r746,%r749,%r750}, [%r742]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r505,%r506,%r507,%r508}, {%r729,%r730,%r731,%r732}, {%r743,%r744}, {%r505,%r506,%r507,%r508}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r505,%r506,%r507,%r508}, {%r702,%r709,%r716,%r723}, {%r745,%r746}, {%r505,%r506,%r507,%r508}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r505,%r506,%r507,%r508}, {%r702,%r709,%r716,%r723}, {%r743,%r744}, {%r505,%r506,%r507,%r508}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r513,%r514,%r515,%r516}, {%r729,%r730,%r731,%r732}, {%r747,%r748}, {%r513,%r514,%r515,%r516}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r513,%r514,%r515,%r516}, {%r702,%r709,%r716,%r723}, {%r749,%r750}, {%r513,%r514,%r515,%r516}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r513,%r514,%r515,%r516}, {%r702,%r709,%r716,%r723}, {%r747,%r748}, {%r513,%r514,%r515,%r516}; + // end inline asm + add.s32 %r751, %r479, 4448; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r753,%r754,%r757,%r758}, [%r751]; + // end inline asm + add.s32 %r752, %r479, 21856; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r755,%r756,%r759,%r760}, [%r752]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r523,%r524,%r525,%r526}, {%r729,%r730,%r731,%r732}, {%r753,%r754}, {%r523,%r524,%r525,%r526}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r523,%r524,%r525,%r526}, {%r702,%r709,%r716,%r723}, {%r755,%r756}, {%r523,%r524,%r525,%r526}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r523,%r524,%r525,%r526}, {%r702,%r709,%r716,%r723}, {%r753,%r754}, {%r523,%r524,%r525,%r526}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r531,%r532,%r533,%r534}, {%r729,%r730,%r731,%r732}, {%r757,%r758}, {%r531,%r532,%r533,%r534}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r531,%r532,%r533,%r534}, {%r702,%r709,%r716,%r723}, {%r759,%r760}, {%r531,%r532,%r533,%r534}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r531,%r532,%r533,%r534}, {%r702,%r709,%r716,%r723}, {%r757,%r758}, {%r531,%r532,%r533,%r534}; + // end inline asm + add.s32 %r761, %r479, 39264; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r763,%r764,%r767,%r768}, [%r761]; + // end inline asm + add.s32 %r762, %r479, 56672; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r765,%r766,%r769,%r770}, [%r762]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r541,%r542,%r543,%r544}, {%r729,%r730,%r731,%r732}, {%r763,%r764}, {%r541,%r542,%r543,%r544}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r541,%r542,%r543,%r544}, {%r702,%r709,%r716,%r723}, {%r765,%r766}, {%r541,%r542,%r543,%r544}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r541,%r542,%r543,%r544}, {%r702,%r709,%r716,%r723}, {%r763,%r764}, {%r541,%r542,%r543,%r544}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r549,%r550,%r551,%r552}, {%r729,%r730,%r731,%r732}, {%r767,%r768}, {%r549,%r550,%r551,%r552}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r549,%r550,%r551,%r552}, {%r702,%r709,%r716,%r723}, {%r769,%r770}, {%r549,%r550,%r551,%r552}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r549,%r550,%r551,%r552}, {%r702,%r709,%r716,%r723}, {%r767,%r768}, {%r549,%r550,%r551,%r552}; + // end inline asm + mul.f32 %r771, %r2129, %r1235; + mul.f32 %r772, %r2130, %r1235; + // begin inline asm + { cvt.rn.f16x2.f32 %r774, %r772, %r771; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r774; + cvt.f32.f16 %r773, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r774; + cvt.f32.f16 %r775, high;} + + // end inline asm + sub.f32 %r776, %r771, %r773; + sub.f32 %r777, %r772, %r775; + // begin inline asm + { cvt.rn.f16x2.f32 %r801, %r777, %r776; } + + // end inline asm + mul.f32 %r778, %r2131, %r1235; + mul.f32 %r779, %r2132, %r1235; + // begin inline asm + { cvt.rn.f16x2.f32 %r781, %r779, %r778; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r781; + cvt.f32.f16 %r780, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r781; + cvt.f32.f16 %r782, high;} + + // end inline asm + sub.f32 %r783, %r778, %r780; + sub.f32 %r784, %r779, %r782; + // begin inline asm + { cvt.rn.f16x2.f32 %r802, %r784, %r783; } + + // end inline asm + mul.f32 %r785, %r2133, %r1235; + mul.f32 %r786, %r2134, %r1235; + // begin inline asm + { cvt.rn.f16x2.f32 %r788, %r786, %r785; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r788; + cvt.f32.f16 %r787, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r788; + cvt.f32.f16 %r789, high;} + + // end inline asm + sub.f32 %r790, %r785, %r787; + sub.f32 %r791, %r786, %r789; + // begin inline asm + { cvt.rn.f16x2.f32 %r803, %r791, %r790; } + + // end inline asm + mul.f32 %r792, %r2135, %r1235; + mul.f32 %r793, %r2136, %r1235; + // begin inline asm + { cvt.rn.f16x2.f32 %r795, %r793, %r792; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r795; + cvt.f32.f16 %r794, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r795; + cvt.f32.f16 %r796, high;} + + // end inline asm + sub.f32 %r797, %r792, %r794; + sub.f32 %r798, %r793, %r796; + // begin inline asm + { cvt.rn.f16x2.f32 %r804, %r798, %r797; } + + // end inline asm + add.s32 %r799, %r479, 128; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r805,%r806,%r809,%r810}, [%r799]; + // end inline asm + add.s32 %r800, %r479, 17536; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r807,%r808,%r811,%r812}, [%r800]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r487,%r488,%r489,%r490}, {%r801,%r802,%r803,%r804}, {%r805,%r806}, {%r487,%r488,%r489,%r490}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r487,%r488,%r489,%r490}, {%r774,%r781,%r788,%r795}, {%r807,%r808}, {%r487,%r488,%r489,%r490}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r487,%r488,%r489,%r490}, {%r774,%r781,%r788,%r795}, {%r805,%r806}, {%r487,%r488,%r489,%r490}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r495,%r496,%r497,%r498}, {%r801,%r802,%r803,%r804}, {%r809,%r810}, {%r495,%r496,%r497,%r498}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r495,%r496,%r497,%r498}, {%r774,%r781,%r788,%r795}, {%r811,%r812}, {%r495,%r496,%r497,%r498}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r495,%r496,%r497,%r498}, {%r774,%r781,%r788,%r795}, {%r809,%r810}, {%r495,%r496,%r497,%r498}; + // end inline asm + add.s32 %r813, %r479, 34944; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r815,%r816,%r819,%r820}, [%r813]; + // end inline asm + add.s32 %r814, %r479, 52352; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r817,%r818,%r821,%r822}, [%r814]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r505,%r506,%r507,%r508}, {%r801,%r802,%r803,%r804}, {%r815,%r816}, {%r505,%r506,%r507,%r508}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r505,%r506,%r507,%r508}, {%r774,%r781,%r788,%r795}, {%r817,%r818}, {%r505,%r506,%r507,%r508}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r505,%r506,%r507,%r508}, {%r774,%r781,%r788,%r795}, {%r815,%r816}, {%r505,%r506,%r507,%r508}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r513,%r514,%r515,%r516}, {%r801,%r802,%r803,%r804}, {%r819,%r820}, {%r513,%r514,%r515,%r516}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r513,%r514,%r515,%r516}, {%r774,%r781,%r788,%r795}, {%r821,%r822}, {%r513,%r514,%r515,%r516}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r513,%r514,%r515,%r516}, {%r774,%r781,%r788,%r795}, {%r819,%r820}, {%r513,%r514,%r515,%r516}; + // end inline asm + add.s32 %r823, %r479, 4480; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r825,%r826,%r829,%r830}, [%r823]; + // end inline asm + add.s32 %r824, %r479, 21888; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r827,%r828,%r831,%r832}, [%r824]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r523,%r524,%r525,%r526}, {%r801,%r802,%r803,%r804}, {%r825,%r826}, {%r523,%r524,%r525,%r526}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r523,%r524,%r525,%r526}, {%r774,%r781,%r788,%r795}, {%r827,%r828}, {%r523,%r524,%r525,%r526}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r523,%r524,%r525,%r526}, {%r774,%r781,%r788,%r795}, {%r825,%r826}, {%r523,%r524,%r525,%r526}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r531,%r532,%r533,%r534}, {%r801,%r802,%r803,%r804}, {%r829,%r830}, {%r531,%r532,%r533,%r534}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r531,%r532,%r533,%r534}, {%r774,%r781,%r788,%r795}, {%r831,%r832}, {%r531,%r532,%r533,%r534}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r531,%r532,%r533,%r534}, {%r774,%r781,%r788,%r795}, {%r829,%r830}, {%r531,%r532,%r533,%r534}; + // end inline asm + add.s32 %r833, %r479, 39296; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r835,%r836,%r839,%r840}, [%r833]; + // end inline asm + add.s32 %r834, %r479, 56704; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r837,%r838,%r841,%r842}, [%r834]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r541,%r542,%r543,%r544}, {%r801,%r802,%r803,%r804}, {%r835,%r836}, {%r541,%r542,%r543,%r544}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r541,%r542,%r543,%r544}, {%r774,%r781,%r788,%r795}, {%r837,%r838}, {%r541,%r542,%r543,%r544}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r541,%r542,%r543,%r544}, {%r774,%r781,%r788,%r795}, {%r835,%r836}, {%r541,%r542,%r543,%r544}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r549,%r550,%r551,%r552}, {%r801,%r802,%r803,%r804}, {%r839,%r840}, {%r549,%r550,%r551,%r552}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r549,%r550,%r551,%r552}, {%r774,%r781,%r788,%r795}, {%r841,%r842}, {%r549,%r550,%r551,%r552}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r549,%r550,%r551,%r552}, {%r774,%r781,%r788,%r795}, {%r839,%r840}, {%r549,%r550,%r551,%r552}; + // end inline asm + mul.f32 %r843, %r2137, %r1235; + mul.f32 %r844, %r2138, %r1235; + // begin inline asm + { cvt.rn.f16x2.f32 %r846, %r844, %r843; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r846; + cvt.f32.f16 %r845, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r846; + cvt.f32.f16 %r847, high;} + + // end inline asm + sub.f32 %r848, %r843, %r845; + sub.f32 %r849, %r844, %r847; + // begin inline asm + { cvt.rn.f16x2.f32 %r873, %r849, %r848; } + + // end inline asm + mul.f32 %r850, %r2139, %r1235; + mul.f32 %r851, %r2140, %r1235; + // begin inline asm + { cvt.rn.f16x2.f32 %r853, %r851, %r850; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r853; + cvt.f32.f16 %r852, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r853; + cvt.f32.f16 %r854, high;} + + // end inline asm + sub.f32 %r855, %r850, %r852; + sub.f32 %r856, %r851, %r854; + // begin inline asm + { cvt.rn.f16x2.f32 %r874, %r856, %r855; } + + // end inline asm + mul.f32 %r857, %r2141, %r1235; + mul.f32 %r858, %r2142, %r1235; + // begin inline asm + { cvt.rn.f16x2.f32 %r860, %r858, %r857; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r860; + cvt.f32.f16 %r859, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r860; + cvt.f32.f16 %r861, high;} + + // end inline asm + sub.f32 %r862, %r857, %r859; + sub.f32 %r863, %r858, %r861; + // begin inline asm + { cvt.rn.f16x2.f32 %r875, %r863, %r862; } + + // end inline asm + mul.f32 %r864, %r2143, %r1235; + mul.f32 %r865, %r2144, %r1235; + // begin inline asm + { cvt.rn.f16x2.f32 %r867, %r865, %r864; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r867; + cvt.f32.f16 %r866, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r867; + cvt.f32.f16 %r868, high;} + + // end inline asm + sub.f32 %r869, %r864, %r866; + sub.f32 %r870, %r865, %r868; + // begin inline asm + { cvt.rn.f16x2.f32 %r876, %r870, %r869; } + + // end inline asm + add.s32 %r871, %r479, 160; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r877,%r878,%r881,%r882}, [%r871]; + // end inline asm + add.s32 %r872, %r479, 17568; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r879,%r880,%r883,%r884}, [%r872]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r487,%r488,%r489,%r490}, {%r873,%r874,%r875,%r876}, {%r877,%r878}, {%r487,%r488,%r489,%r490}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r487,%r488,%r489,%r490}, {%r846,%r853,%r860,%r867}, {%r879,%r880}, {%r487,%r488,%r489,%r490}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r487,%r488,%r489,%r490}, {%r846,%r853,%r860,%r867}, {%r877,%r878}, {%r487,%r488,%r489,%r490}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r495,%r496,%r497,%r498}, {%r873,%r874,%r875,%r876}, {%r881,%r882}, {%r495,%r496,%r497,%r498}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r495,%r496,%r497,%r498}, {%r846,%r853,%r860,%r867}, {%r883,%r884}, {%r495,%r496,%r497,%r498}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r495,%r496,%r497,%r498}, {%r846,%r853,%r860,%r867}, {%r881,%r882}, {%r495,%r496,%r497,%r498}; + // end inline asm + add.s32 %r885, %r479, 34976; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r887,%r888,%r891,%r892}, [%r885]; + // end inline asm + add.s32 %r886, %r479, 52384; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r889,%r890,%r893,%r894}, [%r886]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r505,%r506,%r507,%r508}, {%r873,%r874,%r875,%r876}, {%r887,%r888}, {%r505,%r506,%r507,%r508}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r505,%r506,%r507,%r508}, {%r846,%r853,%r860,%r867}, {%r889,%r890}, {%r505,%r506,%r507,%r508}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r505,%r506,%r507,%r508}, {%r846,%r853,%r860,%r867}, {%r887,%r888}, {%r505,%r506,%r507,%r508}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r513,%r514,%r515,%r516}, {%r873,%r874,%r875,%r876}, {%r891,%r892}, {%r513,%r514,%r515,%r516}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r513,%r514,%r515,%r516}, {%r846,%r853,%r860,%r867}, {%r893,%r894}, {%r513,%r514,%r515,%r516}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r513,%r514,%r515,%r516}, {%r846,%r853,%r860,%r867}, {%r891,%r892}, {%r513,%r514,%r515,%r516}; + // end inline asm + add.s32 %r895, %r479, 4512; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r897,%r898,%r901,%r902}, [%r895]; + // end inline asm + add.s32 %r896, %r479, 21920; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r899,%r900,%r903,%r904}, [%r896]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r523,%r524,%r525,%r526}, {%r873,%r874,%r875,%r876}, {%r897,%r898}, {%r523,%r524,%r525,%r526}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r523,%r524,%r525,%r526}, {%r846,%r853,%r860,%r867}, {%r899,%r900}, {%r523,%r524,%r525,%r526}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r523,%r524,%r525,%r526}, {%r846,%r853,%r860,%r867}, {%r897,%r898}, {%r523,%r524,%r525,%r526}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r531,%r532,%r533,%r534}, {%r873,%r874,%r875,%r876}, {%r901,%r902}, {%r531,%r532,%r533,%r534}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r531,%r532,%r533,%r534}, {%r846,%r853,%r860,%r867}, {%r903,%r904}, {%r531,%r532,%r533,%r534}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r531,%r532,%r533,%r534}, {%r846,%r853,%r860,%r867}, {%r901,%r902}, {%r531,%r532,%r533,%r534}; + // end inline asm + add.s32 %r905, %r479, 39328; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r907,%r908,%r911,%r912}, [%r905]; + // end inline asm + add.s32 %r906, %r479, 56736; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r909,%r910,%r913,%r914}, [%r906]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r541,%r542,%r543,%r544}, {%r873,%r874,%r875,%r876}, {%r907,%r908}, {%r541,%r542,%r543,%r544}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r541,%r542,%r543,%r544}, {%r846,%r853,%r860,%r867}, {%r909,%r910}, {%r541,%r542,%r543,%r544}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r541,%r542,%r543,%r544}, {%r846,%r853,%r860,%r867}, {%r907,%r908}, {%r541,%r542,%r543,%r544}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r549,%r550,%r551,%r552}, {%r873,%r874,%r875,%r876}, {%r911,%r912}, {%r549,%r550,%r551,%r552}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r549,%r550,%r551,%r552}, {%r846,%r853,%r860,%r867}, {%r913,%r914}, {%r549,%r550,%r551,%r552}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r549,%r550,%r551,%r552}, {%r846,%r853,%r860,%r867}, {%r911,%r912}, {%r549,%r550,%r551,%r552}; + // end inline asm + mul.f32 %r915, %r2145, %r1235; + mul.f32 %r916, %r2146, %r1235; + // begin inline asm + { cvt.rn.f16x2.f32 %r918, %r916, %r915; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r918; + cvt.f32.f16 %r917, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r918; + cvt.f32.f16 %r919, high;} + + // end inline asm + sub.f32 %r920, %r915, %r917; + sub.f32 %r921, %r916, %r919; + // begin inline asm + { cvt.rn.f16x2.f32 %r945, %r921, %r920; } + + // end inline asm + mul.f32 %r922, %r2147, %r1235; + mul.f32 %r923, %r2148, %r1235; + // begin inline asm + { cvt.rn.f16x2.f32 %r925, %r923, %r922; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r925; + cvt.f32.f16 %r924, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r925; + cvt.f32.f16 %r926, high;} + + // end inline asm + sub.f32 %r927, %r922, %r924; + sub.f32 %r928, %r923, %r926; + // begin inline asm + { cvt.rn.f16x2.f32 %r946, %r928, %r927; } + + // end inline asm + mul.f32 %r929, %r2149, %r1235; + mul.f32 %r930, %r2150, %r1235; + // begin inline asm + { cvt.rn.f16x2.f32 %r932, %r930, %r929; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r932; + cvt.f32.f16 %r931, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r932; + cvt.f32.f16 %r933, high;} + + // end inline asm + sub.f32 %r934, %r929, %r931; + sub.f32 %r935, %r930, %r933; + // begin inline asm + { cvt.rn.f16x2.f32 %r947, %r935, %r934; } + + // end inline asm + mul.f32 %r936, %r2151, %r1235; + mul.f32 %r937, %r2152, %r1235; + // begin inline asm + { cvt.rn.f16x2.f32 %r939, %r937, %r936; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r939; + cvt.f32.f16 %r938, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r939; + cvt.f32.f16 %r940, high;} + + // end inline asm + sub.f32 %r941, %r936, %r938; + sub.f32 %r942, %r937, %r940; + // begin inline asm + { cvt.rn.f16x2.f32 %r948, %r942, %r941; } + + // end inline asm + add.s32 %r943, %r479, 192; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r949,%r950,%r953,%r954}, [%r943]; + // end inline asm + add.s32 %r944, %r479, 17600; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r951,%r952,%r955,%r956}, [%r944]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r487,%r488,%r489,%r490}, {%r945,%r946,%r947,%r948}, {%r949,%r950}, {%r487,%r488,%r489,%r490}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r487,%r488,%r489,%r490}, {%r918,%r925,%r932,%r939}, {%r951,%r952}, {%r487,%r488,%r489,%r490}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r487,%r488,%r489,%r490}, {%r918,%r925,%r932,%r939}, {%r949,%r950}, {%r487,%r488,%r489,%r490}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r495,%r496,%r497,%r498}, {%r945,%r946,%r947,%r948}, {%r953,%r954}, {%r495,%r496,%r497,%r498}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r495,%r496,%r497,%r498}, {%r918,%r925,%r932,%r939}, {%r955,%r956}, {%r495,%r496,%r497,%r498}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r495,%r496,%r497,%r498}, {%r918,%r925,%r932,%r939}, {%r953,%r954}, {%r495,%r496,%r497,%r498}; + // end inline asm + add.s32 %r957, %r479, 35008; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r959,%r960,%r963,%r964}, [%r957]; + // end inline asm + add.s32 %r958, %r479, 52416; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r961,%r962,%r965,%r966}, [%r958]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r505,%r506,%r507,%r508}, {%r945,%r946,%r947,%r948}, {%r959,%r960}, {%r505,%r506,%r507,%r508}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r505,%r506,%r507,%r508}, {%r918,%r925,%r932,%r939}, {%r961,%r962}, {%r505,%r506,%r507,%r508}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r505,%r506,%r507,%r508}, {%r918,%r925,%r932,%r939}, {%r959,%r960}, {%r505,%r506,%r507,%r508}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r513,%r514,%r515,%r516}, {%r945,%r946,%r947,%r948}, {%r963,%r964}, {%r513,%r514,%r515,%r516}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r513,%r514,%r515,%r516}, {%r918,%r925,%r932,%r939}, {%r965,%r966}, {%r513,%r514,%r515,%r516}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r513,%r514,%r515,%r516}, {%r918,%r925,%r932,%r939}, {%r963,%r964}, {%r513,%r514,%r515,%r516}; + // end inline asm + add.s32 %r967, %r479, 4544; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r969,%r970,%r973,%r974}, [%r967]; + // end inline asm + add.s32 %r968, %r479, 21952; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r971,%r972,%r975,%r976}, [%r968]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r523,%r524,%r525,%r526}, {%r945,%r946,%r947,%r948}, {%r969,%r970}, {%r523,%r524,%r525,%r526}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r523,%r524,%r525,%r526}, {%r918,%r925,%r932,%r939}, {%r971,%r972}, {%r523,%r524,%r525,%r526}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r523,%r524,%r525,%r526}, {%r918,%r925,%r932,%r939}, {%r969,%r970}, {%r523,%r524,%r525,%r526}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r531,%r532,%r533,%r534}, {%r945,%r946,%r947,%r948}, {%r973,%r974}, {%r531,%r532,%r533,%r534}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r531,%r532,%r533,%r534}, {%r918,%r925,%r932,%r939}, {%r975,%r976}, {%r531,%r532,%r533,%r534}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r531,%r532,%r533,%r534}, {%r918,%r925,%r932,%r939}, {%r973,%r974}, {%r531,%r532,%r533,%r534}; + // end inline asm + add.s32 %r977, %r479, 39360; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r979,%r980,%r983,%r984}, [%r977]; + // end inline asm + add.s32 %r978, %r479, 56768; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r981,%r982,%r985,%r986}, [%r978]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r541,%r542,%r543,%r544}, {%r945,%r946,%r947,%r948}, {%r979,%r980}, {%r541,%r542,%r543,%r544}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r541,%r542,%r543,%r544}, {%r918,%r925,%r932,%r939}, {%r981,%r982}, {%r541,%r542,%r543,%r544}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r541,%r542,%r543,%r544}, {%r918,%r925,%r932,%r939}, {%r979,%r980}, {%r541,%r542,%r543,%r544}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r549,%r550,%r551,%r552}, {%r945,%r946,%r947,%r948}, {%r983,%r984}, {%r549,%r550,%r551,%r552}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r549,%r550,%r551,%r552}, {%r918,%r925,%r932,%r939}, {%r985,%r986}, {%r549,%r550,%r551,%r552}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r549,%r550,%r551,%r552}, {%r918,%r925,%r932,%r939}, {%r983,%r984}, {%r549,%r550,%r551,%r552}; + // end inline asm + mul.f32 %r987, %r2153, %r1235; + mul.f32 %r988, %r2154, %r1235; + // begin inline asm + { cvt.rn.f16x2.f32 %r990, %r988, %r987; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r990; + cvt.f32.f16 %r989, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r990; + cvt.f32.f16 %r991, high;} + + // end inline asm + sub.f32 %r992, %r987, %r989; + sub.f32 %r993, %r988, %r991; + // begin inline asm + { cvt.rn.f16x2.f32 %r1017, %r993, %r992; } + + // end inline asm + mul.f32 %r994, %r2155, %r1235; + mul.f32 %r995, %r2156, %r1235; + // begin inline asm + { cvt.rn.f16x2.f32 %r997, %r995, %r994; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r997; + cvt.f32.f16 %r996, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r997; + cvt.f32.f16 %r998, high;} + + // end inline asm + sub.f32 %r999, %r994, %r996; + sub.f32 %r1000, %r995, %r998; + // begin inline asm + { cvt.rn.f16x2.f32 %r1018, %r1000, %r999; } + + // end inline asm + mul.f32 %r1001, %r2157, %r1235; + mul.f32 %r1002, %r2158, %r1235; + // begin inline asm + { cvt.rn.f16x2.f32 %r1004, %r1002, %r1001; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1004; + cvt.f32.f16 %r1003, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1004; + cvt.f32.f16 %r1005, high;} + + // end inline asm + sub.f32 %r1006, %r1001, %r1003; + sub.f32 %r1007, %r1002, %r1005; + // begin inline asm + { cvt.rn.f16x2.f32 %r1019, %r1007, %r1006; } + + // end inline asm + mul.f32 %r1008, %r2159, %r1235; + mul.f32 %r1009, %r2160, %r1235; + // begin inline asm + { cvt.rn.f16x2.f32 %r1011, %r1009, %r1008; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1011; + cvt.f32.f16 %r1010, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1011; + cvt.f32.f16 %r1012, high;} + + // end inline asm + sub.f32 %r1013, %r1008, %r1010; + sub.f32 %r1014, %r1009, %r1012; + // begin inline asm + { cvt.rn.f16x2.f32 %r1020, %r1014, %r1013; } + + // end inline asm + add.s32 %r1015, %r479, 224; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r1021,%r1022,%r1025,%r1026}, [%r1015]; + // end inline asm + add.s32 %r1016, %r479, 17632; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r1023,%r1024,%r1027,%r1028}, [%r1016]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r487,%r488,%r489,%r490}, {%r1017,%r1018,%r1019,%r1020}, {%r1021,%r1022}, {%r487,%r488,%r489,%r490}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r487,%r488,%r489,%r490}, {%r990,%r997,%r1004,%r1011}, {%r1023,%r1024}, {%r487,%r488,%r489,%r490}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r487,%r488,%r489,%r490}, {%r990,%r997,%r1004,%r1011}, {%r1021,%r1022}, {%r487,%r488,%r489,%r490}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r495,%r496,%r497,%r498}, {%r1017,%r1018,%r1019,%r1020}, {%r1025,%r1026}, {%r495,%r496,%r497,%r498}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r495,%r496,%r497,%r498}, {%r990,%r997,%r1004,%r1011}, {%r1027,%r1028}, {%r495,%r496,%r497,%r498}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r495,%r496,%r497,%r498}, {%r990,%r997,%r1004,%r1011}, {%r1025,%r1026}, {%r495,%r496,%r497,%r498}; + // end inline asm + add.s32 %r1029, %r479, 35040; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r1031,%r1032,%r1035,%r1036}, [%r1029]; + // end inline asm + add.s32 %r1030, %r479, 52448; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r1033,%r1034,%r1037,%r1038}, [%r1030]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r505,%r506,%r507,%r508}, {%r1017,%r1018,%r1019,%r1020}, {%r1031,%r1032}, {%r505,%r506,%r507,%r508}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r505,%r506,%r507,%r508}, {%r990,%r997,%r1004,%r1011}, {%r1033,%r1034}, {%r505,%r506,%r507,%r508}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r505,%r506,%r507,%r508}, {%r990,%r997,%r1004,%r1011}, {%r1031,%r1032}, {%r505,%r506,%r507,%r508}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r513,%r514,%r515,%r516}, {%r1017,%r1018,%r1019,%r1020}, {%r1035,%r1036}, {%r513,%r514,%r515,%r516}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r513,%r514,%r515,%r516}, {%r990,%r997,%r1004,%r1011}, {%r1037,%r1038}, {%r513,%r514,%r515,%r516}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r513,%r514,%r515,%r516}, {%r990,%r997,%r1004,%r1011}, {%r1035,%r1036}, {%r513,%r514,%r515,%r516}; + // end inline asm + add.s32 %r1039, %r479, 4576; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r1041,%r1042,%r1045,%r1046}, [%r1039]; + // end inline asm + add.s32 %r1040, %r479, 21984; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r1043,%r1044,%r1047,%r1048}, [%r1040]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r523,%r524,%r525,%r526}, {%r1017,%r1018,%r1019,%r1020}, {%r1041,%r1042}, {%r523,%r524,%r525,%r526}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r523,%r524,%r525,%r526}, {%r990,%r997,%r1004,%r1011}, {%r1043,%r1044}, {%r523,%r524,%r525,%r526}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r523,%r524,%r525,%r526}, {%r990,%r997,%r1004,%r1011}, {%r1041,%r1042}, {%r523,%r524,%r525,%r526}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r531,%r532,%r533,%r534}, {%r1017,%r1018,%r1019,%r1020}, {%r1045,%r1046}, {%r531,%r532,%r533,%r534}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r531,%r532,%r533,%r534}, {%r990,%r997,%r1004,%r1011}, {%r1047,%r1048}, {%r531,%r532,%r533,%r534}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r531,%r532,%r533,%r534}, {%r990,%r997,%r1004,%r1011}, {%r1045,%r1046}, {%r531,%r532,%r533,%r534}; + // end inline asm + add.s32 %r1049, %r479, 39392; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r1051,%r1052,%r1055,%r1056}, [%r1049]; + // end inline asm + add.s32 %r1050, %r479, 56800; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r1053,%r1054,%r1057,%r1058}, [%r1050]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r541,%r542,%r543,%r544}, {%r1017,%r1018,%r1019,%r1020}, {%r1051,%r1052}, {%r541,%r542,%r543,%r544}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r541,%r542,%r543,%r544}, {%r990,%r997,%r1004,%r1011}, {%r1053,%r1054}, {%r541,%r542,%r543,%r544}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r541,%r542,%r543,%r544}, {%r990,%r997,%r1004,%r1011}, {%r1051,%r1052}, {%r541,%r542,%r543,%r544}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r549,%r550,%r551,%r552}, {%r1017,%r1018,%r1019,%r1020}, {%r1055,%r1056}, {%r549,%r550,%r551,%r552}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r549,%r550,%r551,%r552}, {%r990,%r997,%r1004,%r1011}, {%r1057,%r1058}, {%r549,%r550,%r551,%r552}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r549,%r550,%r551,%r552}, {%r990,%r997,%r1004,%r1011}, {%r1055,%r1056}, {%r549,%r550,%r551,%r552}; + // end inline asm + sub.s32 %r1239, 998244352, %r1234; + neg.f32 %r1240, %r1239; + or.b32 %r1241, %r1091, %r77; + shl.b32 %r1242, %r1241, 4; + add.s32 %r1243, %r1238, %r1242; + add.s32 %r1688, %r1243, 96768; + // begin inline asm + ld.shared.v4.f32 {%r1059,%r1060,%r1061,%r1062}, [%r1688]; + // end inline asm + add.s32 %r1693, %r1243, 96784; + // begin inline asm + ld.shared.v4.f32 {%r1063,%r1064,%r1065,%r1066}, [%r1693]; + // end inline asm + mul.f32 %r1244, %r1060, %r1240; + ld.shared.b32 %r1245, [%r65+69632]; + fma.rn.f32 %r1246, %r1244, %r487, %r1245; + mul.f32 %r79, %r1059, %r1246; + mul.f32 %r1247, %r1064, %r1240; + ld.shared.b32 %r1248, [%r65+70160]; + fma.rn.f32 %r1249, %r1247, %r488, %r1248; + mul.f32 %r80, %r1063, %r1249; + ld.shared.b32 %r1250, [%r65+69664]; + fma.rn.f32 %r1251, %r1244, %r489, %r1250; + mul.f32 %r81, %r1059, %r1251; + ld.shared.b32 %r1252, [%r65+70192]; + fma.rn.f32 %r1253, %r1247, %r490, %r1252; + mul.f32 %r82, %r1063, %r1253; + add.s32 %r1698, %r1243, 96896; + // begin inline asm + ld.shared.v4.f32 {%r1067,%r1068,%r1069,%r1070}, [%r1698]; + // end inline asm + add.s32 %r1703, %r1243, 96912; + // begin inline asm + ld.shared.v4.f32 {%r1071,%r1072,%r1073,%r1074}, [%r1703]; + // end inline asm + mul.f32 %r1254, %r1068, %r1240; + ld.shared.b32 %r1255, [%r65+73856]; + fma.rn.f32 %r1256, %r1254, %r495, %r1255; + mul.f32 %r83, %r1067, %r1256; + mul.f32 %r1257, %r1072, %r1240; + ld.shared.b32 %r1258, [%r65+74384]; + fma.rn.f32 %r1259, %r1257, %r496, %r1258; + mul.f32 %r84, %r1071, %r1259; + ld.shared.b32 %r1260, [%r65+73888]; + fma.rn.f32 %r1261, %r1254, %r497, %r1260; + mul.f32 %r85, %r1067, %r1261; + ld.shared.b32 %r1262, [%r65+74416]; + fma.rn.f32 %r1263, %r1257, %r498, %r1262; + mul.f32 %r86, %r1071, %r1263; + add.s32 %r1708, %r1243, 97024; + // begin inline asm + ld.shared.v4.f32 {%r1075,%r1076,%r1077,%r1078}, [%r1708]; + // end inline asm + add.s32 %r1713, %r1243, 97040; + // begin inline asm + ld.shared.v4.f32 {%r1079,%r1080,%r1081,%r1082}, [%r1713]; + // end inline asm + mul.f32 %r1264, %r1076, %r1240; + ld.shared.b32 %r1265, [%r65+78080]; + fma.rn.f32 %r1266, %r1264, %r523, %r1265; + mul.f32 %r87, %r1075, %r1266; + mul.f32 %r1267, %r1080, %r1240; + ld.shared.b32 %r1268, [%r65+78608]; + fma.rn.f32 %r1269, %r1267, %r524, %r1268; + mul.f32 %r88, %r1079, %r1269; + ld.shared.b32 %r1270, [%r65+78112]; + fma.rn.f32 %r1271, %r1264, %r525, %r1270; + mul.f32 %r89, %r1075, %r1271; + ld.shared.b32 %r1272, [%r65+78640]; + fma.rn.f32 %r1273, %r1267, %r526, %r1272; + mul.f32 %r90, %r1079, %r1273; + add.s32 %r1718, %r1243, 97152; + // begin inline asm + ld.shared.v4.f32 {%r1083,%r1084,%r1085,%r1086}, [%r1718]; + // end inline asm + add.s32 %r1723, %r1243, 97168; + // begin inline asm + ld.shared.v4.f32 {%r1087,%r1088,%r1089,%r1090}, [%r1723]; + // end inline asm + mul.f32 %r1274, %r1084, %r1240; + ld.shared.b32 %r1275, [%r65+82304]; + fma.rn.f32 %r1276, %r1274, %r531, %r1275; + mul.f32 %r91, %r1083, %r1276; + mul.f32 %r1277, %r1088, %r1240; + ld.shared.b32 %r1278, [%r65+82832]; + fma.rn.f32 %r1279, %r1277, %r532, %r1278; + mul.f32 %r92, %r1087, %r1279; + ld.shared.b32 %r1280, [%r65+82336]; + fma.rn.f32 %r1281, %r1274, %r533, %r1280; + mul.f32 %r93, %r1083, %r1281; + ld.shared.b32 %r1282, [%r65+82864]; + fma.rn.f32 %r1283, %r1277, %r534, %r1282; + mul.f32 %r94, %r1087, %r1283; + abs.f32 %r1284, %r79; + max.f32 %r1285, %r1284, 0f00000000; + abs.f32 %r1286, %r80; + max.f32 %r1287, %r1286, 0f00000000; + abs.f32 %r1288, %r81; + max.f32 %r1289, %r1288, 0f00000000; + abs.f32 %r1290, %r82; + max.f32 %r1291, %r1290, 0f00000000; + abs.f32 %r1292, %r83; + max.f32 %r1293, %r1285, %r1292; + abs.f32 %r1294, %r84; + max.f32 %r1295, %r1287, %r1294; + abs.f32 %r1296, %r85; + max.f32 %r1297, %r1289, %r1296; + abs.f32 %r1298, %r86; + max.f32 %r1299, %r1291, %r1298; + abs.f32 %r1300, %r87; + max.f32 %r1301, %r1293, %r1300; + abs.f32 %r1302, %r88; + max.f32 %r1303, %r1295, %r1302; + abs.f32 %r1304, %r89; + max.f32 %r1305, %r1297, %r1304; + abs.f32 %r1306, %r90; + max.f32 %r1307, %r1299, %r1306; + abs.f32 %r1308, %r91; + max.f32 %r1309, %r1301, %r1308; + abs.f32 %r1310, %r92; + max.f32 %r1311, %r1303, %r1310; + abs.f32 %r1312, %r93; + max.f32 %r1313, %r1305, %r1312; + abs.f32 %r1314, %r94; + max.f32 %r1315, %r1307, %r1314; + max.f32 %r1316, %r1309, %r1311; + max.f32 %r1317, %r1313, %r1315; + max.f32 %r1318, %r1316, %r1317; + redux.sync.max.u32 %r95, %r1318, %r1227; + and.b32 %r1319, %r95, 2147483647; + setp.eq.b32 %p43, %r1319, 0; + @%p43 bra $L__BB2_74; + shr.s32 %r1320, %r95, 23; + sub.s32 %r1321, 141, %r1320; + max.s32 %r1322, %r1321, -40; + min.s32 %r1323, %r1322, 40; + shl.b32 %r2168, %r1323, 23; +$L__BB2_74: + add.s32 %r1576, %r2168, 1065353216; + mul.f32 %r1324, %r79, %r1576; + mul.f32 %r1325, %r80, %r1576; + // begin inline asm + { cvt.rn.f16x2.f32 %r1327, %r1325, %r1324; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1327; + cvt.f32.f16 %r1326, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1327; + cvt.f32.f16 %r1328, high;} + + // end inline asm + sub.f32 %r1329, %r1324, %r1326; + sub.f32 %r1330, %r1325, %r1328; + // begin inline asm + { cvt.rn.f16x2.f32 %r1354, %r1330, %r1329; } + + // end inline asm + mul.f32 %r1331, %r81, %r1576; + mul.f32 %r1332, %r82, %r1576; + // begin inline asm + { cvt.rn.f16x2.f32 %r1334, %r1332, %r1331; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1334; + cvt.f32.f16 %r1333, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1334; + cvt.f32.f16 %r1335, high;} + + // end inline asm + sub.f32 %r1336, %r1331, %r1333; + sub.f32 %r1337, %r1332, %r1335; + // begin inline asm + { cvt.rn.f16x2.f32 %r1355, %r1337, %r1336; } + + // end inline asm + mul.f32 %r1338, %r83, %r1576; + mul.f32 %r1339, %r84, %r1576; + // begin inline asm + { cvt.rn.f16x2.f32 %r1341, %r1339, %r1338; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1341; + cvt.f32.f16 %r1340, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1341; + cvt.f32.f16 %r1342, high;} + + // end inline asm + sub.f32 %r1343, %r1338, %r1340; + sub.f32 %r1344, %r1339, %r1342; + // begin inline asm + { cvt.rn.f16x2.f32 %r1356, %r1344, %r1343; } + + // end inline asm + mul.f32 %r1345, %r85, %r1576; + mul.f32 %r1346, %r86, %r1576; + // begin inline asm + { cvt.rn.f16x2.f32 %r1348, %r1346, %r1345; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1348; + cvt.f32.f16 %r1347, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1348; + cvt.f32.f16 %r1349, high;} + + // end inline asm + sub.f32 %r1350, %r1345, %r1347; + sub.f32 %r1351, %r1346, %r1349; + // begin inline asm + { cvt.rn.f16x2.f32 %r1357, %r1351, %r1350; } + + // end inline asm + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r1358,%r1359,%r1366,%r1367}, [%r1352]; + // end inline asm + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r1364,%r1365,%r1372,%r1373}, [%r1353]; + // end inline asm + mov.b32 %r1389, 0; + mov.b32 %r1360, %r1389; + mov.b32 %r1361, %r1389; + mov.b32 %r1362, %r1389; + mov.b32 %r1363, %r1389; + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1360,%r1361,%r1362,%r1363}, {%r1354,%r1355,%r1356,%r1357}, {%r1358,%r1359}, {%r1360,%r1361,%r1362,%r1363}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1360,%r1361,%r1362,%r1363}, {%r1327,%r1334,%r1341,%r1348}, {%r1364,%r1365}, {%r1360,%r1361,%r1362,%r1363}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1360,%r1361,%r1362,%r1363}, {%r1327,%r1334,%r1341,%r1348}, {%r1358,%r1359}, {%r1360,%r1361,%r1362,%r1363}; + // end inline asm + mov.b32 %r1368, %r1389; + mov.b32 %r1369, %r1389; + mov.b32 %r1370, %r1389; + mov.b32 %r1371, %r1389; + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1368,%r1369,%r1370,%r1371}, {%r1354,%r1355,%r1356,%r1357}, {%r1366,%r1367}, {%r1368,%r1369,%r1370,%r1371}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1368,%r1369,%r1370,%r1371}, {%r1327,%r1334,%r1341,%r1348}, {%r1372,%r1373}, {%r1368,%r1369,%r1370,%r1371}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1368,%r1369,%r1370,%r1371}, {%r1327,%r1334,%r1341,%r1348}, {%r1366,%r1367}, {%r1368,%r1369,%r1370,%r1371}; + // end inline asm + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r1376,%r1377,%r1384,%r1385}, [%r1374]; + // end inline asm + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r1382,%r1383,%r1390,%r1391}, [%r1375]; + // end inline asm + mov.b32 %r1378, %r1389; + mov.b32 %r1379, %r1389; + mov.b32 %r1380, %r1389; + mov.b32 %r1381, %r1389; + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1378,%r1379,%r1380,%r1381}, {%r1354,%r1355,%r1356,%r1357}, {%r1376,%r1377}, {%r1378,%r1379,%r1380,%r1381}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1378,%r1379,%r1380,%r1381}, {%r1327,%r1334,%r1341,%r1348}, {%r1382,%r1383}, {%r1378,%r1379,%r1380,%r1381}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1378,%r1379,%r1380,%r1381}, {%r1327,%r1334,%r1341,%r1348}, {%r1376,%r1377}, {%r1378,%r1379,%r1380,%r1381}; + // end inline asm + mov.b32 %r1386, %r1389; + mov.b32 %r1387, %r1389; + mov.b32 %r1388, %r1389; + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1386,%r1387,%r1388,%r1389}, {%r1354,%r1355,%r1356,%r1357}, {%r1384,%r1385}, {%r1386,%r1387,%r1388,%r1389}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1386,%r1387,%r1388,%r1389}, {%r1327,%r1334,%r1341,%r1348}, {%r1390,%r1391}, {%r1386,%r1387,%r1388,%r1389}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1386,%r1387,%r1388,%r1389}, {%r1327,%r1334,%r1341,%r1348}, {%r1384,%r1385}, {%r1386,%r1387,%r1388,%r1389}; + // end inline asm + mul.f32 %r1392, %r87, %r1576; + mul.f32 %r1393, %r88, %r1576; + // begin inline asm + { cvt.rn.f16x2.f32 %r1395, %r1393, %r1392; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1395; + cvt.f32.f16 %r1394, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1395; + cvt.f32.f16 %r1396, high;} + + // end inline asm + sub.f32 %r1397, %r1392, %r1394; + sub.f32 %r1398, %r1393, %r1396; + // begin inline asm + { cvt.rn.f16x2.f32 %r1422, %r1398, %r1397; } + + // end inline asm + mul.f32 %r1399, %r89, %r1576; + mul.f32 %r1400, %r90, %r1576; + // begin inline asm + { cvt.rn.f16x2.f32 %r1402, %r1400, %r1399; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1402; + cvt.f32.f16 %r1401, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1402; + cvt.f32.f16 %r1403, high;} + + // end inline asm + sub.f32 %r1404, %r1399, %r1401; + sub.f32 %r1405, %r1400, %r1403; + // begin inline asm + { cvt.rn.f16x2.f32 %r1423, %r1405, %r1404; } + + // end inline asm + mul.f32 %r1406, %r91, %r1576; + mul.f32 %r1407, %r92, %r1576; + // begin inline asm + { cvt.rn.f16x2.f32 %r1409, %r1407, %r1406; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1409; + cvt.f32.f16 %r1408, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1409; + cvt.f32.f16 %r1410, high;} + + // end inline asm + sub.f32 %r1411, %r1406, %r1408; + sub.f32 %r1412, %r1407, %r1410; + // begin inline asm + { cvt.rn.f16x2.f32 %r1424, %r1412, %r1411; } + + // end inline asm + mul.f32 %r1413, %r93, %r1576; + mul.f32 %r1414, %r94, %r1576; + // begin inline asm + { cvt.rn.f16x2.f32 %r1416, %r1414, %r1413; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1416; + cvt.f32.f16 %r1415, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1416; + cvt.f32.f16 %r1417, high;} + + // end inline asm + sub.f32 %r1418, %r1413, %r1415; + sub.f32 %r1419, %r1414, %r1417; + // begin inline asm + { cvt.rn.f16x2.f32 %r1425, %r1419, %r1418; } + + // end inline asm + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r1426,%r1427,%r1430,%r1431}, [%r1420]; + // end inline asm + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r1428,%r1429,%r1432,%r1433}, [%r1421]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1378,%r1379,%r1380,%r1381}, {%r1422,%r1423,%r1424,%r1425}, {%r1426,%r1427}, {%r1378,%r1379,%r1380,%r1381}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1378,%r1379,%r1380,%r1381}, {%r1395,%r1402,%r1409,%r1416}, {%r1428,%r1429}, {%r1378,%r1379,%r1380,%r1381}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1378,%r1379,%r1380,%r1381}, {%r1395,%r1402,%r1409,%r1416}, {%r1426,%r1427}, {%r1378,%r1379,%r1380,%r1381}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1386,%r1387,%r1388,%r1389}, {%r1422,%r1423,%r1424,%r1425}, {%r1430,%r1431}, {%r1386,%r1387,%r1388,%r1389}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1386,%r1387,%r1388,%r1389}, {%r1395,%r1402,%r1409,%r1416}, {%r1432,%r1433}, {%r1386,%r1387,%r1388,%r1389}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1386,%r1387,%r1388,%r1389}, {%r1395,%r1402,%r1409,%r1416}, {%r1430,%r1431}, {%r1386,%r1387,%r1388,%r1389}; + // end inline asm + sub.s32 %r1577, 1065353216, %r2168; + shl.b32 %r1578, %r71, 2; + mov.b32 %r1579, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r1580, %r1579, %r1578; + ld.shared.b32 %r1581, [%r1580+97792]; + mul.f32 %r1582, %r1581, %r1577; + mul.f32 %r96, %r1582, %r1360; + mul.f32 %r97, %r1582, %r1361; + mul.f32 %r98, %r1582, %r1362; + mul.f32 %r99, %r1582, %r1363; + mul.f32 %r100, %r1582, %r1368; + mul.f32 %r101, %r1582, %r1369; + mul.f32 %r102, %r1582, %r1370; + mul.f32 %r103, %r1582, %r1371; + mul.f32 %r104, %r1582, %r1378; + mul.f32 %r105, %r1582, %r1379; + mul.f32 %r106, %r1582, %r1380; + mul.f32 %r107, %r1582, %r1381; + mul.f32 %r108, %r1582, %r1386; + mul.f32 %r109, %r1582, %r1387; + mul.f32 %r110, %r1582, %r1388; + mul.f32 %r111, %r1582, %r1389; + abs.f32 %r1583, %r96; + max.f32 %r1584, %r1583, 0f00000000; + abs.f32 %r1585, %r97; + max.f32 %r1586, %r1585, 0f00000000; + abs.f32 %r1587, %r98; + max.f32 %r1588, %r1587, 0f00000000; + abs.f32 %r1589, %r99; + max.f32 %r1590, %r1589, 0f00000000; + abs.f32 %r1591, %r100; + max.f32 %r1592, %r1584, %r1591; + abs.f32 %r1593, %r101; + max.f32 %r1594, %r1586, %r1593; + abs.f32 %r1595, %r102; + max.f32 %r1596, %r1588, %r1595; + abs.f32 %r1597, %r103; + max.f32 %r1598, %r1590, %r1597; + abs.f32 %r1599, %r104; + max.f32 %r1600, %r1592, %r1599; + abs.f32 %r1601, %r105; + max.f32 %r1602, %r1594, %r1601; + abs.f32 %r1603, %r106; + max.f32 %r1604, %r1596, %r1603; + abs.f32 %r1605, %r107; + max.f32 %r1606, %r1598, %r1605; + abs.f32 %r1607, %r108; + max.f32 %r1608, %r1600, %r1607; + abs.f32 %r1609, %r109; + max.f32 %r1610, %r1602, %r1609; + abs.f32 %r1611, %r110; + max.f32 %r1612, %r1604, %r1611; + abs.f32 %r1613, %r111; + max.f32 %r1614, %r1606, %r1613; + max.f32 %r1615, %r1608, %r1610; + max.f32 %r1616, %r1612, %r1614; + max.f32 %r1617, %r1615, %r1616; + mov.b32 %r1618, -1; + redux.sync.max.u32 %r1619, %r1617, %r1618; + and.b32 %r1620, %r1619, 2147483647; + setp.eq.b32 %p44, %r1620, 0; + shr.s32 %r1621, %r1619, 23; + sub.s32 %r1622, 141, %r1621; + max.s32 %r1623, %r1622, -40; + min.s32 %r1624, %r1623, 40; + selp.b32 %r1625, 0, %r1624, %p44; + shl.b32 %r1626, %r1625, 23; + add.s32 %r112, %r1626, 1065353216; + add.s32 %r113, %r1626, 1132462080; + sub.s32 %r114, 998244352, %r1626; + sub.s32 %r1627, %r1625, %r78; + shl.b32 %r1628, %r1627, 23; + add.s32 %r1629, %r1628, 1065353216; + // begin inline asm + ld.shared.v4.f32 {%r1434,%r1435,%r1436,%r1437}, [%r1688]; + // end inline asm + mul.f32 %r1630, %r1435, %r1629; + // begin inline asm + ld.shared.v4.f32 {%r1438,%r1439,%r1440,%r1441}, [%r1693]; + // end inline asm + mul.f32 %r1631, %r1439, %r1629; + mul.f32 %r1502, %r505, %r1630; + mul.f32 %r1503, %r1631, %r506; + mul.f32 %r1504, %r1630, %r507; + mul.f32 %r1505, %r1631, %r508; + // begin inline asm + ld.shared.v4.f32 {%r1442,%r1443,%r1444,%r1445}, [%r1698]; + // end inline asm + mul.f32 %r1632, %r1443, %r1629; + // begin inline asm + ld.shared.v4.f32 {%r1446,%r1447,%r1448,%r1449}, [%r1703]; + // end inline asm + mul.f32 %r1633, %r1447, %r1629; + mul.f32 %r1510, %r513, %r1632; + mul.f32 %r1511, %r1633, %r514; + mul.f32 %r1512, %r1632, %r515; + mul.f32 %r1513, %r1633, %r516; + // begin inline asm + ld.shared.v4.f32 {%r1450,%r1451,%r1452,%r1453}, [%r1708]; + // end inline asm + mul.f32 %r1634, %r1451, %r1629; + // begin inline asm + ld.shared.v4.f32 {%r1454,%r1455,%r1456,%r1457}, [%r1713]; + // end inline asm + mul.f32 %r1635, %r1455, %r1629; + mul.f32 %r1520, %r541, %r1634; + mul.f32 %r1521, %r1635, %r542; + mul.f32 %r1522, %r1634, %r543; + mul.f32 %r1523, %r1635, %r544; + // begin inline asm + ld.shared.v4.f32 {%r1458,%r1459,%r1460,%r1461}, [%r1718]; + // end inline asm + mul.f32 %r1636, %r1459, %r1629; + // begin inline asm + ld.shared.v4.f32 {%r1462,%r1463,%r1464,%r1465}, [%r1723]; + // end inline asm + mul.f32 %r1637, %r1463, %r1629; + mul.f32 %r1528, %r549, %r1636; + mul.f32 %r1529, %r1637, %r550; + mul.f32 %r1530, %r1636, %r551; + mul.f32 %r1531, %r1637, %r552; + mul.f32 %r1466, %r96, %r112; + mul.f32 %r1467, %r97, %r112; + // begin inline asm + { cvt.rn.f16x2.f32 %r1469, %r1467, %r1466; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1469; + cvt.f32.f16 %r1468, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1469; + cvt.f32.f16 %r1470, high;} + + // end inline asm + sub.f32 %r1471, %r1466, %r1468; + sub.f32 %r1472, %r1467, %r1470; + // begin inline asm + { cvt.rn.f16x2.f32 %r1496, %r1472, %r1471; } + + // end inline asm + mul.f32 %r1473, %r98, %r112; + mul.f32 %r1474, %r99, %r112; + // begin inline asm + { cvt.rn.f16x2.f32 %r1476, %r1474, %r1473; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1476; + cvt.f32.f16 %r1475, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1476; + cvt.f32.f16 %r1477, high;} + + // end inline asm + sub.f32 %r1478, %r1473, %r1475; + sub.f32 %r1479, %r1474, %r1477; + // begin inline asm + { cvt.rn.f16x2.f32 %r1497, %r1479, %r1478; } + + // end inline asm + mul.f32 %r1480, %r100, %r112; + mul.f32 %r1481, %r101, %r112; + // begin inline asm + { cvt.rn.f16x2.f32 %r1483, %r1481, %r1480; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1483; + cvt.f32.f16 %r1482, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1483; + cvt.f32.f16 %r1484, high;} + + // end inline asm + sub.f32 %r1485, %r1480, %r1482; + sub.f32 %r1486, %r1481, %r1484; + // begin inline asm + { cvt.rn.f16x2.f32 %r1498, %r1486, %r1485; } + + // end inline asm + mul.f32 %r1487, %r102, %r112; + mul.f32 %r1488, %r103, %r112; + // begin inline asm + { cvt.rn.f16x2.f32 %r1490, %r1488, %r1487; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1490; + cvt.f32.f16 %r1489, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1490; + cvt.f32.f16 %r1491, high;} + + // end inline asm + sub.f32 %r1492, %r1487, %r1489; + sub.f32 %r1493, %r1488, %r1491; + // begin inline asm + { cvt.rn.f16x2.f32 %r1499, %r1493, %r1492; } + + // end inline asm + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r1500,%r1501,%r1508,%r1509}, [%r1494]; + // end inline asm + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r1506,%r1507,%r1514,%r1515}, [%r1495]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1502,%r1503,%r1504,%r1505}, {%r1496,%r1497,%r1498,%r1499}, {%r1500,%r1501}, {%r1502,%r1503,%r1504,%r1505}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1502,%r1503,%r1504,%r1505}, {%r1469,%r1476,%r1483,%r1490}, {%r1506,%r1507}, {%r1502,%r1503,%r1504,%r1505}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1502,%r1503,%r1504,%r1505}, {%r1469,%r1476,%r1483,%r1490}, {%r1500,%r1501}, {%r1502,%r1503,%r1504,%r1505}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1510,%r1511,%r1512,%r1513}, {%r1496,%r1497,%r1498,%r1499}, {%r1508,%r1509}, {%r1510,%r1511,%r1512,%r1513}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1510,%r1511,%r1512,%r1513}, {%r1469,%r1476,%r1483,%r1490}, {%r1514,%r1515}, {%r1510,%r1511,%r1512,%r1513}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1510,%r1511,%r1512,%r1513}, {%r1469,%r1476,%r1483,%r1490}, {%r1508,%r1509}, {%r1510,%r1511,%r1512,%r1513}; + // end inline asm + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r1518,%r1519,%r1526,%r1527}, [%r1516]; + // end inline asm + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r1524,%r1525,%r1532,%r1533}, [%r1517]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1520,%r1521,%r1522,%r1523}, {%r1496,%r1497,%r1498,%r1499}, {%r1518,%r1519}, {%r1520,%r1521,%r1522,%r1523}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1520,%r1521,%r1522,%r1523}, {%r1469,%r1476,%r1483,%r1490}, {%r1524,%r1525}, {%r1520,%r1521,%r1522,%r1523}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1520,%r1521,%r1522,%r1523}, {%r1469,%r1476,%r1483,%r1490}, {%r1518,%r1519}, {%r1520,%r1521,%r1522,%r1523}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1528,%r1529,%r1530,%r1531}, {%r1496,%r1497,%r1498,%r1499}, {%r1526,%r1527}, {%r1528,%r1529,%r1530,%r1531}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1528,%r1529,%r1530,%r1531}, {%r1469,%r1476,%r1483,%r1490}, {%r1532,%r1533}, {%r1528,%r1529,%r1530,%r1531}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1528,%r1529,%r1530,%r1531}, {%r1469,%r1476,%r1483,%r1490}, {%r1526,%r1527}, {%r1528,%r1529,%r1530,%r1531}; + // end inline asm + mul.f32 %r1534, %r104, %r112; + mul.f32 %r1535, %r105, %r112; + // begin inline asm + { cvt.rn.f16x2.f32 %r1537, %r1535, %r1534; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1537; + cvt.f32.f16 %r1536, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1537; + cvt.f32.f16 %r1538, high;} + + // end inline asm + sub.f32 %r1539, %r1534, %r1536; + sub.f32 %r1540, %r1535, %r1538; + // begin inline asm + { cvt.rn.f16x2.f32 %r1564, %r1540, %r1539; } + + // end inline asm + mul.f32 %r1541, %r106, %r112; + mul.f32 %r1542, %r107, %r112; + // begin inline asm + { cvt.rn.f16x2.f32 %r1544, %r1542, %r1541; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1544; + cvt.f32.f16 %r1543, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1544; + cvt.f32.f16 %r1545, high;} + + // end inline asm + sub.f32 %r1546, %r1541, %r1543; + sub.f32 %r1547, %r1542, %r1545; + // begin inline asm + { cvt.rn.f16x2.f32 %r1565, %r1547, %r1546; } + + // end inline asm + mul.f32 %r1548, %r108, %r112; + mul.f32 %r1549, %r109, %r112; + // begin inline asm + { cvt.rn.f16x2.f32 %r1551, %r1549, %r1548; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1551; + cvt.f32.f16 %r1550, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1551; + cvt.f32.f16 %r1552, high;} + + // end inline asm + sub.f32 %r1553, %r1548, %r1550; + sub.f32 %r1554, %r1549, %r1552; + // begin inline asm + { cvt.rn.f16x2.f32 %r1566, %r1554, %r1553; } + + // end inline asm + mul.f32 %r1555, %r110, %r112; + mul.f32 %r1556, %r111, %r112; + // begin inline asm + { cvt.rn.f16x2.f32 %r1558, %r1556, %r1555; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1558; + cvt.f32.f16 %r1557, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1558; + cvt.f32.f16 %r1559, high;} + + // end inline asm + sub.f32 %r1560, %r1555, %r1557; + sub.f32 %r1561, %r1556, %r1559; + // begin inline asm + { cvt.rn.f16x2.f32 %r1567, %r1561, %r1560; } + + // end inline asm + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r1568,%r1569,%r1572,%r1573}, [%r1562]; + // end inline asm + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.shared.b16 {%r1570,%r1571,%r1574,%r1575}, [%r1563]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1520,%r1521,%r1522,%r1523}, {%r1564,%r1565,%r1566,%r1567}, {%r1568,%r1569}, {%r1520,%r1521,%r1522,%r1523}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1520,%r1521,%r1522,%r1523}, {%r1537,%r1544,%r1551,%r1558}, {%r1570,%r1571}, {%r1520,%r1521,%r1522,%r1523}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1520,%r1521,%r1522,%r1523}, {%r1537,%r1544,%r1551,%r1558}, {%r1568,%r1569}, {%r1520,%r1521,%r1522,%r1523}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1528,%r1529,%r1530,%r1531}, {%r1564,%r1565,%r1566,%r1567}, {%r1572,%r1573}, {%r1528,%r1529,%r1530,%r1531}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1528,%r1529,%r1530,%r1531}, {%r1537,%r1544,%r1551,%r1558}, {%r1574,%r1575}, {%r1528,%r1529,%r1530,%r1531}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1528,%r1529,%r1530,%r1531}, {%r1537,%r1544,%r1551,%r1558}, {%r1572,%r1573}, {%r1528,%r1529,%r1530,%r1531}; + // end inline asm + setp.ge.s32 %p45, %r1091, %r72; + add.s64 %rd184, %rd21, %rd19; + mad.lo.s64 %rd185, %rd184, 6144, %rd11; + shl.b64 %rd186, %rd185, 2; + add.s64 %rd23, %rd20, %rd186; + @%p45 bra $L__BB2_76; + mul.f32 %r1638, %r1502, %r114; + mul.f32 %r1639, %r62, %r1638; + st.global.b32 [%rd23], %r1639; +$L__BB2_76: + add.s32 %r1640, %r66, -7; + setp.ge.s32 %p46, %r1640, %r72; + @%p46 bra $L__BB2_78; + mul.f32 %r1641, %r1503, %r114; + mul.f32 %r1642, %r62, %r1641; + st.global.b32 [%rd23+24576], %r1642; +$L__BB2_78: + @%p45 bra $L__BB2_80; + mul.f32 %r1643, %r1504, %r114; + mul.f32 %r1644, %r62, %r1643; + st.global.b32 [%rd23+32], %r1644; +$L__BB2_80: + @%p46 bra $L__BB2_82; + mul.f32 %r1645, %r1505, %r114; + mul.f32 %r1646, %r62, %r1645; + st.global.b32 [%rd23+24608], %r1646; +$L__BB2_82: + setp.ge.s32 %p47, %r66, %r72; + @%p47 bra $L__BB2_84; + mul.f32 %r1647, %r1510, %r114; + mul.f32 %r1648, %r62, %r1647; + st.global.b32 [%rd23+196608], %r1648; +$L__BB2_84: + add.s32 %r115, %r66, 1; + setp.ge.s32 %p48, %r115, %r72; + @%p48 bra $L__BB2_86; + mul.f32 %r1649, %r1511, %r114; + mul.f32 %r1650, %r62, %r1649; + st.global.b32 [%rd23+221184], %r1650; +$L__BB2_86: + @%p47 bra $L__BB2_88; + mul.f32 %r1651, %r1512, %r114; + mul.f32 %r1652, %r62, %r1651; + st.global.b32 [%rd23+196640], %r1652; +$L__BB2_88: + @%p48 bra $L__BB2_90; + mul.f32 %r1653, %r1513, %r114; + mul.f32 %r1654, %r62, %r1653; + st.global.b32 [%rd23+221216], %r1654; +$L__BB2_90: + add.s32 %r116, %r66, 8; + setp.ge.s32 %p49, %r116, %r72; + @%p49 bra $L__BB2_92; + mul.f32 %r1655, %r1520, %r114; + mul.f32 %r1656, %r62, %r1655; + st.global.b32 [%rd23+393216], %r1656; +$L__BB2_92: + add.s32 %r117, %r66, 9; + setp.ge.s32 %p50, %r117, %r72; + @%p50 bra $L__BB2_94; + mul.f32 %r1657, %r1521, %r114; + mul.f32 %r1658, %r62, %r1657; + st.global.b32 [%rd23+417792], %r1658; +$L__BB2_94: + @%p49 bra $L__BB2_96; + mul.f32 %r1659, %r1522, %r114; + mul.f32 %r1660, %r62, %r1659; + st.global.b32 [%rd23+393248], %r1660; +$L__BB2_96: + @%p50 bra $L__BB2_98; + mul.f32 %r1661, %r1523, %r114; + mul.f32 %r1662, %r62, %r1661; + st.global.b32 [%rd23+417824], %r1662; +$L__BB2_98: + or.b32 %r118, %r66, 16; + setp.ge.s32 %p51, %r118, %r72; + @%p51 bra $L__BB2_100; + mul.f32 %r1663, %r1528, %r114; + mul.f32 %r1664, %r62, %r1663; + st.global.b32 [%rd23+589824], %r1664; +$L__BB2_100: + add.s32 %r119, %r66, 17; + setp.ge.s32 %p52, %r119, %r72; + @%p52 bra $L__BB2_102; + mul.f32 %r1665, %r1529, %r114; + mul.f32 %r1666, %r62, %r1665; + st.global.b32 [%rd23+614400], %r1666; +$L__BB2_102: + @%p51 bra $L__BB2_104; + mul.f32 %r1667, %r1530, %r114; + mul.f32 %r1668, %r62, %r1667; + st.global.b32 [%rd23+589856], %r1668; +$L__BB2_104: + @%p52 bra $L__BB2_106; + mul.f32 %r1669, %r1531, %r114; + mul.f32 %r1670, %r62, %r1669; + st.global.b32 [%rd23+614432], %r1670; +$L__BB2_106: + setp.ge.s32 %p53, %r2161, %r121; + bar.sync 0; + @%p53 bra $L__BB2_120; + add.s64 %rd24, %rd21, 32; + sub.s64 %rd187, %rd33, %rd24; + min.s64 %rd188, %rd187, 32; + cvt.u32.u64 %r120, %rd188; + setp.ge.s32 %p54, %r14, %r120; + @%p54 bra $L__BB2_109; + cvt.u64.u32 %rd191, %r14; + add.s64 %rd192, %rd24, %rd191; + mad.lo.s64 %rd193, %rd192, 40960, %rd4; + add.s64 %rd190, %rd193, 16384; + // begin inline asm + cp.async.cg.shared.global [%r67], [%rd190], 16; + + // end inline asm + bra.uni $L__BB2_110; +$L__BB2_109: + mov.b32 %r1671, 0f00000000; + mov.b64 %rd189, {%r1671, %r1671}; + st.shared.v2.b64 [%r67], {%rd189, %rd189}; +$L__BB2_110: + setp.lt.s32 %p55, %r21, %r120; + @%p55 bra $L__BB2_112; + mov.b32 %r1672, 0f00000000; + mov.b64 %rd194, {%r1672, %r1672}; + st.shared.v2.b64 [%r68], {%rd194, %rd194}; + bra.uni $L__BB2_113; +$L__BB2_112: + cvt.u64.u32 %rd196, %r21; + add.s64 %rd197, %rd24, %rd196; + mad.lo.s64 %rd198, %rd197, 40960, %rd4; + add.s64 %rd195, %rd198, 16384; + // begin inline asm + cp.async.cg.shared.global [%r68], [%rd195], 16; + + // end inline asm +$L__BB2_113: + setp.lt.s32 %p56, %r24, %r120; + @%p56 bra $L__BB2_115; + mov.b32 %r1673, 0f00000000; + mov.b64 %rd199, {%r1673, %r1673}; + st.shared.v2.b64 [%r69], {%rd199, %rd199}; + bra.uni $L__BB2_116; +$L__BB2_115: + cvt.u64.u32 %rd201, %r24; + add.s64 %rd202, %rd24, %rd201; + mad.lo.s64 %rd203, %rd202, 40960, %rd4; + add.s64 %rd200, %rd203, 16384; + // begin inline asm + cp.async.cg.shared.global [%r69], [%rd200], 16; + + // end inline asm +$L__BB2_116: + setp.lt.s32 %p57, %r27, %r120; + @%p57 bra $L__BB2_118; + mov.b32 %r1674, 0f00000000; + mov.b64 %rd204, {%r1674, %r1674}; + st.shared.v2.b64 [%r70], {%rd204, %rd204}; + bra.uni $L__BB2_119; +$L__BB2_118: + cvt.u64.u32 %rd206, %r27; + add.s64 %rd207, %rd24, %rd206; + mad.lo.s64 %rd208, %rd207, 40960, %rd4; + add.s64 %rd205, %rd208, 16384; + // begin inline asm + cp.async.cg.shared.global [%r70], [%rd205], 16; + + // end inline asm +$L__BB2_119: + mul.wide.u32 %rd213, %r2161, 48; + add.s64 %rd214, %rd213, %rd1; + shl.b64 %rd215, %rd214, 6; + or.b64 %rd216, %rd215, %rd5; + add.s64 %rd217, %rd216, %rd7; + shl.b64 %rd218, %rd217, 6; + or.b64 %rd220, %rd218, %rd219; + add.s64 %rd209, %rd26, %rd220; + // begin inline asm + cp.async.cg.shared.global [%r1675], [%rd209], 16; + + // end inline asm + add.s64 %rd210, %rd30, %rd220; + // begin inline asm + cp.async.cg.shared.global [%r1676], [%rd210], 16; + + // end inline asm + add.s64 %rd221, %rd216, %rd8; + shl.b64 %rd222, %rd221, 6; + or.b64 %rd223, %rd222, %rd219; + add.s64 %rd211, %rd26, %rd223; + // begin inline asm + cp.async.cg.shared.global [%r1677], [%rd211], 16; + + // end inline asm + add.s64 %rd212, %rd30, %rd223; + // begin inline asm + cp.async.cg.shared.global [%r1678], [%rd212], 16; + + // end inline asm + // begin inline asm + cp.async.commit_group; + + // end inline asm +$L__BB2_120: + shl.b32 %r2012, %r77, 4; + mov.b32 %r2013, _ZN50_GLOBAL__N__9c8cba9c_17_gdn_prefill_tc_cu_4b52ad976gtc_smE; + add.s32 %r2014, %r2013, %r2012; + add.s32 %r1683, %r2014, 97264; + // begin inline asm + ld.shared.v4.f32 {%r1679,%r1680,%r1681,%r1682}, [%r1683]; + // end inline asm + mul.f32 %r2015, %r1680, %r113; + mul.f32 %r1760, %r2015, %r2097; + mul.f32 %r1761, %r2015, %r2098; + mul.f32 %r1762, %r2015, %r2099; + mul.f32 %r1763, %r2015, %r2100; + mul.f32 %r1768, %r2015, %r2101; + mul.f32 %r1769, %r2015, %r2102; + mul.f32 %r1770, %r2015, %r2103; + mul.f32 %r1771, %r2015, %r2104; + mul.f32 %r1778, %r2015, %r2105; + mul.f32 %r1779, %r2015, %r2106; + mul.f32 %r1780, %r2015, %r2107; + mul.f32 %r1781, %r2015, %r2108; + mul.f32 %r1786, %r2015, %r2109; + mul.f32 %r1787, %r2015, %r2110; + mul.f32 %r1788, %r2015, %r2111; + mul.f32 %r1789, %r2015, %r2112; + mul.f32 %r1796, %r2015, %r2113; + mul.f32 %r1797, %r2015, %r2114; + mul.f32 %r1798, %r2015, %r2115; + mul.f32 %r1799, %r2015, %r2116; + mul.f32 %r1804, %r2015, %r2117; + mul.f32 %r1805, %r2015, %r2118; + mul.f32 %r1806, %r2015, %r2119; + mul.f32 %r1807, %r2015, %r2120; + mul.f32 %r1814, %r2015, %r2121; + mul.f32 %r1815, %r2015, %r2122; + mul.f32 %r1816, %r2015, %r2123; + mul.f32 %r1817, %r2015, %r2124; + mul.f32 %r1822, %r2015, %r2125; + mul.f32 %r1823, %r2015, %r2126; + mul.f32 %r1824, %r2015, %r2127; + mul.f32 %r1825, %r2015, %r2128; + mul.f32 %r1832, %r2015, %r2129; + mul.f32 %r1833, %r2015, %r2130; + mul.f32 %r1834, %r2015, %r2131; + mul.f32 %r1835, %r2015, %r2132; + mul.f32 %r1840, %r2015, %r2133; + mul.f32 %r1841, %r2015, %r2134; + mul.f32 %r1842, %r2015, %r2135; + mul.f32 %r1843, %r2015, %r2136; + mul.f32 %r1850, %r2015, %r2137; + mul.f32 %r1851, %r2015, %r2138; + mul.f32 %r1852, %r2015, %r2139; + mul.f32 %r1853, %r2015, %r2140; + mul.f32 %r1858, %r2015, %r2141; + mul.f32 %r1859, %r2015, %r2142; + mul.f32 %r1860, %r2015, %r2143; + mul.f32 %r1861, %r2015, %r2144; + mul.f32 %r1868, %r2015, %r2145; + mul.f32 %r1869, %r2015, %r2146; + mul.f32 %r1870, %r2015, %r2147; + mul.f32 %r1871, %r2015, %r2148; + mul.f32 %r1876, %r2015, %r2149; + mul.f32 %r1877, %r2015, %r2150; + mul.f32 %r1878, %r2015, %r2151; + mul.f32 %r1879, %r2015, %r2152; + mul.f32 %r1886, %r2015, %r2153; + mul.f32 %r1887, %r2015, %r2154; + mul.f32 %r1888, %r2015, %r2155; + mul.f32 %r1889, %r2015, %r2156; + mul.f32 %r1894, %r2015, %r2157; + mul.f32 %r1895, %r2015, %r2158; + mul.f32 %r1896, %r2015, %r2159; + mul.f32 %r1897, %r2015, %r2160; + // begin inline asm + ld.shared.v4.f32 {%r1684,%r1685,%r1686,%r1687}, [%r1688]; + // end inline asm + mul.f32 %r2016, %r1686, %r112; + // begin inline asm + ld.shared.v4.f32 {%r1689,%r1690,%r1691,%r1692}, [%r1693]; + // end inline asm + mul.f32 %r2017, %r1691, %r112; + mul.f32 %r1724, %r96, %r2016; + mul.f32 %r1725, %r2017, %r97; + mul.f32 %r1731, %r2016, %r98; + mul.f32 %r1732, %r2017, %r99; + // begin inline asm + ld.shared.v4.f32 {%r1694,%r1695,%r1696,%r1697}, [%r1698]; + // end inline asm + mul.f32 %r2018, %r1696, %r112; + // begin inline asm + ld.shared.v4.f32 {%r1699,%r1700,%r1701,%r1702}, [%r1703]; + // end inline asm + mul.f32 %r2019, %r1701, %r112; + mul.f32 %r1738, %r100, %r2018; + mul.f32 %r1739, %r2019, %r101; + mul.f32 %r1745, %r2018, %r102; + mul.f32 %r1746, %r2019, %r103; + // begin inline asm + ld.shared.v4.f32 {%r1704,%r1705,%r1706,%r1707}, [%r1708]; + // end inline asm + mul.f32 %r2020, %r1706, %r112; + // begin inline asm + ld.shared.v4.f32 {%r1709,%r1710,%r1711,%r1712}, [%r1713]; + // end inline asm + mul.f32 %r2021, %r1711, %r112; + mul.f32 %r1900, %r104, %r2020; + mul.f32 %r1901, %r2021, %r105; + mul.f32 %r1907, %r2020, %r106; + mul.f32 %r1908, %r2021, %r107; + // begin inline asm + ld.shared.v4.f32 {%r1714,%r1715,%r1716,%r1717}, [%r1718]; + // end inline asm + mul.f32 %r2022, %r1716, %r112; + // begin inline asm + ld.shared.v4.f32 {%r1719,%r1720,%r1721,%r1722}, [%r1723]; + // end inline asm + mul.f32 %r2023, %r1721, %r112; + mul.f32 %r1914, %r108, %r2022; + mul.f32 %r1915, %r2023, %r109; + mul.f32 %r1921, %r2022, %r110; + mul.f32 %r1922, %r2023, %r111; + // begin inline asm + { cvt.rn.f16x2.f32 %r1727, %r1725, %r1724; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1727; + cvt.f32.f16 %r1726, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1727; + cvt.f32.f16 %r1728, high;} + + // end inline asm + sub.f32 %r1729, %r1724, %r1726; + sub.f32 %r1730, %r1725, %r1728; + // begin inline asm + { cvt.rn.f16x2.f32 %r1754, %r1730, %r1729; } + + // end inline asm + // begin inline asm + { cvt.rn.f16x2.f32 %r1734, %r1732, %r1731; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1734; + cvt.f32.f16 %r1733, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1734; + cvt.f32.f16 %r1735, high;} + + // end inline asm + sub.f32 %r1736, %r1731, %r1733; + sub.f32 %r1737, %r1732, %r1735; + // begin inline asm + { cvt.rn.f16x2.f32 %r1755, %r1737, %r1736; } + + // end inline asm + // begin inline asm + { cvt.rn.f16x2.f32 %r1741, %r1739, %r1738; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1741; + cvt.f32.f16 %r1740, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1741; + cvt.f32.f16 %r1742, high;} + + // end inline asm + sub.f32 %r1743, %r1738, %r1740; + sub.f32 %r1744, %r1739, %r1742; + // begin inline asm + { cvt.rn.f16x2.f32 %r1756, %r1744, %r1743; } + + // end inline asm + // begin inline asm + { cvt.rn.f16x2.f32 %r1748, %r1746, %r1745; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1748; + cvt.f32.f16 %r1747, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1748; + cvt.f32.f16 %r1749, high;} + + // end inline asm + sub.f32 %r1750, %r1745, %r1747; + sub.f32 %r1751, %r1746, %r1749; + // begin inline asm + { cvt.rn.f16x2.f32 %r1757, %r1751, %r1750; } + + // end inline asm + add.s32 %r2024, %r64, %r76; + shl.b32 %r2025, %r2024, 1; + add.s32 %r1752, %r2013, %r2025; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1758,%r1759,%r1766,%r1767}, [%r1752]; + // end inline asm + add.s32 %r1753, %r1752, 17408; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1764,%r1765,%r1772,%r1773}, [%r1753]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1760,%r1761,%r1762,%r1763}, {%r1754,%r1755,%r1756,%r1757}, {%r1758,%r1759}, {%r1760,%r1761,%r1762,%r1763}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1760,%r1761,%r1762,%r1763}, {%r1727,%r1734,%r1741,%r1748}, {%r1764,%r1765}, {%r1760,%r1761,%r1762,%r1763}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1760,%r1761,%r1762,%r1763}, {%r1727,%r1734,%r1741,%r1748}, {%r1758,%r1759}, {%r1760,%r1761,%r1762,%r1763}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1768,%r1769,%r1770,%r1771}, {%r1754,%r1755,%r1756,%r1757}, {%r1766,%r1767}, {%r1768,%r1769,%r1770,%r1771}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1768,%r1769,%r1770,%r1771}, {%r1727,%r1734,%r1741,%r1748}, {%r1772,%r1773}, {%r1768,%r1769,%r1770,%r1771}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1768,%r1769,%r1770,%r1771}, {%r1727,%r1734,%r1741,%r1748}, {%r1766,%r1767}, {%r1768,%r1769,%r1770,%r1771}; + // end inline asm + add.s32 %r1774, %r1752, 32; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1776,%r1777,%r1784,%r1785}, [%r1774]; + // end inline asm + add.s32 %r1775, %r1752, 17440; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1782,%r1783,%r1790,%r1791}, [%r1775]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1778,%r1779,%r1780,%r1781}, {%r1754,%r1755,%r1756,%r1757}, {%r1776,%r1777}, {%r1778,%r1779,%r1780,%r1781}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1778,%r1779,%r1780,%r1781}, {%r1727,%r1734,%r1741,%r1748}, {%r1782,%r1783}, {%r1778,%r1779,%r1780,%r1781}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1778,%r1779,%r1780,%r1781}, {%r1727,%r1734,%r1741,%r1748}, {%r1776,%r1777}, {%r1778,%r1779,%r1780,%r1781}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1786,%r1787,%r1788,%r1789}, {%r1754,%r1755,%r1756,%r1757}, {%r1784,%r1785}, {%r1786,%r1787,%r1788,%r1789}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1786,%r1787,%r1788,%r1789}, {%r1727,%r1734,%r1741,%r1748}, {%r1790,%r1791}, {%r1786,%r1787,%r1788,%r1789}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1786,%r1787,%r1788,%r1789}, {%r1727,%r1734,%r1741,%r1748}, {%r1784,%r1785}, {%r1786,%r1787,%r1788,%r1789}; + // end inline asm + add.s32 %r1792, %r1752, 64; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1794,%r1795,%r1802,%r1803}, [%r1792]; + // end inline asm + add.s32 %r1793, %r1752, 17472; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1800,%r1801,%r1808,%r1809}, [%r1793]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1796,%r1797,%r1798,%r1799}, {%r1754,%r1755,%r1756,%r1757}, {%r1794,%r1795}, {%r1796,%r1797,%r1798,%r1799}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1796,%r1797,%r1798,%r1799}, {%r1727,%r1734,%r1741,%r1748}, {%r1800,%r1801}, {%r1796,%r1797,%r1798,%r1799}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1796,%r1797,%r1798,%r1799}, {%r1727,%r1734,%r1741,%r1748}, {%r1794,%r1795}, {%r1796,%r1797,%r1798,%r1799}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1804,%r1805,%r1806,%r1807}, {%r1754,%r1755,%r1756,%r1757}, {%r1802,%r1803}, {%r1804,%r1805,%r1806,%r1807}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1804,%r1805,%r1806,%r1807}, {%r1727,%r1734,%r1741,%r1748}, {%r1808,%r1809}, {%r1804,%r1805,%r1806,%r1807}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1804,%r1805,%r1806,%r1807}, {%r1727,%r1734,%r1741,%r1748}, {%r1802,%r1803}, {%r1804,%r1805,%r1806,%r1807}; + // end inline asm + add.s32 %r1810, %r1752, 96; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1812,%r1813,%r1820,%r1821}, [%r1810]; + // end inline asm + add.s32 %r1811, %r1752, 17504; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1818,%r1819,%r1826,%r1827}, [%r1811]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1814,%r1815,%r1816,%r1817}, {%r1754,%r1755,%r1756,%r1757}, {%r1812,%r1813}, {%r1814,%r1815,%r1816,%r1817}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1814,%r1815,%r1816,%r1817}, {%r1727,%r1734,%r1741,%r1748}, {%r1818,%r1819}, {%r1814,%r1815,%r1816,%r1817}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1814,%r1815,%r1816,%r1817}, {%r1727,%r1734,%r1741,%r1748}, {%r1812,%r1813}, {%r1814,%r1815,%r1816,%r1817}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1822,%r1823,%r1824,%r1825}, {%r1754,%r1755,%r1756,%r1757}, {%r1820,%r1821}, {%r1822,%r1823,%r1824,%r1825}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1822,%r1823,%r1824,%r1825}, {%r1727,%r1734,%r1741,%r1748}, {%r1826,%r1827}, {%r1822,%r1823,%r1824,%r1825}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1822,%r1823,%r1824,%r1825}, {%r1727,%r1734,%r1741,%r1748}, {%r1820,%r1821}, {%r1822,%r1823,%r1824,%r1825}; + // end inline asm + add.s32 %r1828, %r1752, 128; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1830,%r1831,%r1838,%r1839}, [%r1828]; + // end inline asm + add.s32 %r1829, %r1752, 17536; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1836,%r1837,%r1844,%r1845}, [%r1829]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1832,%r1833,%r1834,%r1835}, {%r1754,%r1755,%r1756,%r1757}, {%r1830,%r1831}, {%r1832,%r1833,%r1834,%r1835}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1832,%r1833,%r1834,%r1835}, {%r1727,%r1734,%r1741,%r1748}, {%r1836,%r1837}, {%r1832,%r1833,%r1834,%r1835}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1832,%r1833,%r1834,%r1835}, {%r1727,%r1734,%r1741,%r1748}, {%r1830,%r1831}, {%r1832,%r1833,%r1834,%r1835}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1840,%r1841,%r1842,%r1843}, {%r1754,%r1755,%r1756,%r1757}, {%r1838,%r1839}, {%r1840,%r1841,%r1842,%r1843}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1840,%r1841,%r1842,%r1843}, {%r1727,%r1734,%r1741,%r1748}, {%r1844,%r1845}, {%r1840,%r1841,%r1842,%r1843}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1840,%r1841,%r1842,%r1843}, {%r1727,%r1734,%r1741,%r1748}, {%r1838,%r1839}, {%r1840,%r1841,%r1842,%r1843}; + // end inline asm + add.s32 %r1846, %r1752, 160; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1848,%r1849,%r1856,%r1857}, [%r1846]; + // end inline asm + add.s32 %r1847, %r1752, 17568; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1854,%r1855,%r1862,%r1863}, [%r1847]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1850,%r1851,%r1852,%r1853}, {%r1754,%r1755,%r1756,%r1757}, {%r1848,%r1849}, {%r1850,%r1851,%r1852,%r1853}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1850,%r1851,%r1852,%r1853}, {%r1727,%r1734,%r1741,%r1748}, {%r1854,%r1855}, {%r1850,%r1851,%r1852,%r1853}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1850,%r1851,%r1852,%r1853}, {%r1727,%r1734,%r1741,%r1748}, {%r1848,%r1849}, {%r1850,%r1851,%r1852,%r1853}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1858,%r1859,%r1860,%r1861}, {%r1754,%r1755,%r1756,%r1757}, {%r1856,%r1857}, {%r1858,%r1859,%r1860,%r1861}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1858,%r1859,%r1860,%r1861}, {%r1727,%r1734,%r1741,%r1748}, {%r1862,%r1863}, {%r1858,%r1859,%r1860,%r1861}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1858,%r1859,%r1860,%r1861}, {%r1727,%r1734,%r1741,%r1748}, {%r1856,%r1857}, {%r1858,%r1859,%r1860,%r1861}; + // end inline asm + add.s32 %r1864, %r1752, 192; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1866,%r1867,%r1874,%r1875}, [%r1864]; + // end inline asm + add.s32 %r1865, %r1752, 17600; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1872,%r1873,%r1880,%r1881}, [%r1865]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1868,%r1869,%r1870,%r1871}, {%r1754,%r1755,%r1756,%r1757}, {%r1866,%r1867}, {%r1868,%r1869,%r1870,%r1871}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1868,%r1869,%r1870,%r1871}, {%r1727,%r1734,%r1741,%r1748}, {%r1872,%r1873}, {%r1868,%r1869,%r1870,%r1871}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1868,%r1869,%r1870,%r1871}, {%r1727,%r1734,%r1741,%r1748}, {%r1866,%r1867}, {%r1868,%r1869,%r1870,%r1871}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1876,%r1877,%r1878,%r1879}, {%r1754,%r1755,%r1756,%r1757}, {%r1874,%r1875}, {%r1876,%r1877,%r1878,%r1879}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1876,%r1877,%r1878,%r1879}, {%r1727,%r1734,%r1741,%r1748}, {%r1880,%r1881}, {%r1876,%r1877,%r1878,%r1879}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1876,%r1877,%r1878,%r1879}, {%r1727,%r1734,%r1741,%r1748}, {%r1874,%r1875}, {%r1876,%r1877,%r1878,%r1879}; + // end inline asm + add.s32 %r1882, %r1752, 224; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1884,%r1885,%r1892,%r1893}, [%r1882]; + // end inline asm + add.s32 %r1883, %r1752, 17632; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1890,%r1891,%r1898,%r1899}, [%r1883]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1886,%r1887,%r1888,%r1889}, {%r1754,%r1755,%r1756,%r1757}, {%r1884,%r1885}, {%r1886,%r1887,%r1888,%r1889}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1886,%r1887,%r1888,%r1889}, {%r1727,%r1734,%r1741,%r1748}, {%r1890,%r1891}, {%r1886,%r1887,%r1888,%r1889}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1886,%r1887,%r1888,%r1889}, {%r1727,%r1734,%r1741,%r1748}, {%r1884,%r1885}, {%r1886,%r1887,%r1888,%r1889}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1894,%r1895,%r1896,%r1897}, {%r1754,%r1755,%r1756,%r1757}, {%r1892,%r1893}, {%r1894,%r1895,%r1896,%r1897}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1894,%r1895,%r1896,%r1897}, {%r1727,%r1734,%r1741,%r1748}, {%r1898,%r1899}, {%r1894,%r1895,%r1896,%r1897}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1894,%r1895,%r1896,%r1897}, {%r1727,%r1734,%r1741,%r1748}, {%r1892,%r1893}, {%r1894,%r1895,%r1896,%r1897}; + // end inline asm + // begin inline asm + { cvt.rn.f16x2.f32 %r1903, %r1901, %r1900; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1903; + cvt.f32.f16 %r1902, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1903; + cvt.f32.f16 %r1904, high;} + + // end inline asm + sub.f32 %r1905, %r1900, %r1902; + sub.f32 %r1906, %r1901, %r1904; + // begin inline asm + { cvt.rn.f16x2.f32 %r1930, %r1906, %r1905; } + + // end inline asm + // begin inline asm + { cvt.rn.f16x2.f32 %r1910, %r1908, %r1907; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1910; + cvt.f32.f16 %r1909, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1910; + cvt.f32.f16 %r1911, high;} + + // end inline asm + sub.f32 %r1912, %r1907, %r1909; + sub.f32 %r1913, %r1908, %r1911; + // begin inline asm + { cvt.rn.f16x2.f32 %r1931, %r1913, %r1912; } + + // end inline asm + // begin inline asm + { cvt.rn.f16x2.f32 %r1917, %r1915, %r1914; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1917; + cvt.f32.f16 %r1916, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1917; + cvt.f32.f16 %r1918, high;} + + // end inline asm + sub.f32 %r1919, %r1914, %r1916; + sub.f32 %r1920, %r1915, %r1918; + // begin inline asm + { cvt.rn.f16x2.f32 %r1932, %r1920, %r1919; } + + // end inline asm + // begin inline asm + { cvt.rn.f16x2.f32 %r1924, %r1922, %r1921; } + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1924; + cvt.f32.f16 %r1923, low;} + + // end inline asm + // begin inline asm + {.reg .f16 low,high; + mov.b32 {low,high},%r1924; + cvt.f32.f16 %r1925, high;} + + // end inline asm + sub.f32 %r1926, %r1921, %r1923; + sub.f32 %r1927, %r1922, %r1925; + // begin inline asm + { cvt.rn.f16x2.f32 %r1933, %r1927, %r1926; } + + // end inline asm + add.s32 %r1928, %r1752, 4352; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1934,%r1935,%r1938,%r1939}, [%r1928]; + // end inline asm + add.s32 %r1929, %r1752, 21760; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1936,%r1937,%r1940,%r1941}, [%r1929]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1760,%r1761,%r1762,%r1763}, {%r1930,%r1931,%r1932,%r1933}, {%r1934,%r1935}, {%r1760,%r1761,%r1762,%r1763}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1760,%r1761,%r1762,%r1763}, {%r1903,%r1910,%r1917,%r1924}, {%r1936,%r1937}, {%r1760,%r1761,%r1762,%r1763}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1760,%r1761,%r1762,%r1763}, {%r1903,%r1910,%r1917,%r1924}, {%r1934,%r1935}, {%r1760,%r1761,%r1762,%r1763}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1768,%r1769,%r1770,%r1771}, {%r1930,%r1931,%r1932,%r1933}, {%r1938,%r1939}, {%r1768,%r1769,%r1770,%r1771}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1768,%r1769,%r1770,%r1771}, {%r1903,%r1910,%r1917,%r1924}, {%r1940,%r1941}, {%r1768,%r1769,%r1770,%r1771}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1768,%r1769,%r1770,%r1771}, {%r1903,%r1910,%r1917,%r1924}, {%r1938,%r1939}, {%r1768,%r1769,%r1770,%r1771}; + // end inline asm + add.s32 %r1942, %r1752, 4384; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1944,%r1945,%r1948,%r1949}, [%r1942]; + // end inline asm + add.s32 %r1943, %r1752, 21792; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1946,%r1947,%r1950,%r1951}, [%r1943]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1778,%r1779,%r1780,%r1781}, {%r1930,%r1931,%r1932,%r1933}, {%r1944,%r1945}, {%r1778,%r1779,%r1780,%r1781}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1778,%r1779,%r1780,%r1781}, {%r1903,%r1910,%r1917,%r1924}, {%r1946,%r1947}, {%r1778,%r1779,%r1780,%r1781}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1778,%r1779,%r1780,%r1781}, {%r1903,%r1910,%r1917,%r1924}, {%r1944,%r1945}, {%r1778,%r1779,%r1780,%r1781}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1786,%r1787,%r1788,%r1789}, {%r1930,%r1931,%r1932,%r1933}, {%r1948,%r1949}, {%r1786,%r1787,%r1788,%r1789}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1786,%r1787,%r1788,%r1789}, {%r1903,%r1910,%r1917,%r1924}, {%r1950,%r1951}, {%r1786,%r1787,%r1788,%r1789}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1786,%r1787,%r1788,%r1789}, {%r1903,%r1910,%r1917,%r1924}, {%r1948,%r1949}, {%r1786,%r1787,%r1788,%r1789}; + // end inline asm + add.s32 %r1952, %r1752, 4416; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1954,%r1955,%r1958,%r1959}, [%r1952]; + // end inline asm + add.s32 %r1953, %r1752, 21824; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1956,%r1957,%r1960,%r1961}, [%r1953]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1796,%r1797,%r1798,%r1799}, {%r1930,%r1931,%r1932,%r1933}, {%r1954,%r1955}, {%r1796,%r1797,%r1798,%r1799}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1796,%r1797,%r1798,%r1799}, {%r1903,%r1910,%r1917,%r1924}, {%r1956,%r1957}, {%r1796,%r1797,%r1798,%r1799}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1796,%r1797,%r1798,%r1799}, {%r1903,%r1910,%r1917,%r1924}, {%r1954,%r1955}, {%r1796,%r1797,%r1798,%r1799}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1804,%r1805,%r1806,%r1807}, {%r1930,%r1931,%r1932,%r1933}, {%r1958,%r1959}, {%r1804,%r1805,%r1806,%r1807}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1804,%r1805,%r1806,%r1807}, {%r1903,%r1910,%r1917,%r1924}, {%r1960,%r1961}, {%r1804,%r1805,%r1806,%r1807}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1804,%r1805,%r1806,%r1807}, {%r1903,%r1910,%r1917,%r1924}, {%r1958,%r1959}, {%r1804,%r1805,%r1806,%r1807}; + // end inline asm + add.s32 %r1962, %r1752, 4448; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1964,%r1965,%r1968,%r1969}, [%r1962]; + // end inline asm + add.s32 %r1963, %r1752, 21856; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1966,%r1967,%r1970,%r1971}, [%r1963]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1814,%r1815,%r1816,%r1817}, {%r1930,%r1931,%r1932,%r1933}, {%r1964,%r1965}, {%r1814,%r1815,%r1816,%r1817}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1814,%r1815,%r1816,%r1817}, {%r1903,%r1910,%r1917,%r1924}, {%r1966,%r1967}, {%r1814,%r1815,%r1816,%r1817}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1814,%r1815,%r1816,%r1817}, {%r1903,%r1910,%r1917,%r1924}, {%r1964,%r1965}, {%r1814,%r1815,%r1816,%r1817}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1822,%r1823,%r1824,%r1825}, {%r1930,%r1931,%r1932,%r1933}, {%r1968,%r1969}, {%r1822,%r1823,%r1824,%r1825}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1822,%r1823,%r1824,%r1825}, {%r1903,%r1910,%r1917,%r1924}, {%r1970,%r1971}, {%r1822,%r1823,%r1824,%r1825}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1822,%r1823,%r1824,%r1825}, {%r1903,%r1910,%r1917,%r1924}, {%r1968,%r1969}, {%r1822,%r1823,%r1824,%r1825}; + // end inline asm + add.s32 %r1972, %r1752, 4480; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1974,%r1975,%r1978,%r1979}, [%r1972]; + // end inline asm + add.s32 %r1973, %r1752, 21888; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1976,%r1977,%r1980,%r1981}, [%r1973]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1832,%r1833,%r1834,%r1835}, {%r1930,%r1931,%r1932,%r1933}, {%r1974,%r1975}, {%r1832,%r1833,%r1834,%r1835}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1832,%r1833,%r1834,%r1835}, {%r1903,%r1910,%r1917,%r1924}, {%r1976,%r1977}, {%r1832,%r1833,%r1834,%r1835}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1832,%r1833,%r1834,%r1835}, {%r1903,%r1910,%r1917,%r1924}, {%r1974,%r1975}, {%r1832,%r1833,%r1834,%r1835}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1840,%r1841,%r1842,%r1843}, {%r1930,%r1931,%r1932,%r1933}, {%r1978,%r1979}, {%r1840,%r1841,%r1842,%r1843}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1840,%r1841,%r1842,%r1843}, {%r1903,%r1910,%r1917,%r1924}, {%r1980,%r1981}, {%r1840,%r1841,%r1842,%r1843}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1840,%r1841,%r1842,%r1843}, {%r1903,%r1910,%r1917,%r1924}, {%r1978,%r1979}, {%r1840,%r1841,%r1842,%r1843}; + // end inline asm + add.s32 %r1982, %r1752, 4512; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1984,%r1985,%r1988,%r1989}, [%r1982]; + // end inline asm + add.s32 %r1983, %r1752, 21920; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1986,%r1987,%r1990,%r1991}, [%r1983]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1850,%r1851,%r1852,%r1853}, {%r1930,%r1931,%r1932,%r1933}, {%r1984,%r1985}, {%r1850,%r1851,%r1852,%r1853}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1850,%r1851,%r1852,%r1853}, {%r1903,%r1910,%r1917,%r1924}, {%r1986,%r1987}, {%r1850,%r1851,%r1852,%r1853}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1850,%r1851,%r1852,%r1853}, {%r1903,%r1910,%r1917,%r1924}, {%r1984,%r1985}, {%r1850,%r1851,%r1852,%r1853}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1858,%r1859,%r1860,%r1861}, {%r1930,%r1931,%r1932,%r1933}, {%r1988,%r1989}, {%r1858,%r1859,%r1860,%r1861}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1858,%r1859,%r1860,%r1861}, {%r1903,%r1910,%r1917,%r1924}, {%r1990,%r1991}, {%r1858,%r1859,%r1860,%r1861}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1858,%r1859,%r1860,%r1861}, {%r1903,%r1910,%r1917,%r1924}, {%r1988,%r1989}, {%r1858,%r1859,%r1860,%r1861}; + // end inline asm + add.s32 %r1992, %r1752, 4544; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1994,%r1995,%r1998,%r1999}, [%r1992]; + // end inline asm + add.s32 %r1993, %r1752, 21952; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r1996,%r1997,%r2000,%r2001}, [%r1993]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1868,%r1869,%r1870,%r1871}, {%r1930,%r1931,%r1932,%r1933}, {%r1994,%r1995}, {%r1868,%r1869,%r1870,%r1871}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1868,%r1869,%r1870,%r1871}, {%r1903,%r1910,%r1917,%r1924}, {%r1996,%r1997}, {%r1868,%r1869,%r1870,%r1871}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1868,%r1869,%r1870,%r1871}, {%r1903,%r1910,%r1917,%r1924}, {%r1994,%r1995}, {%r1868,%r1869,%r1870,%r1871}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1876,%r1877,%r1878,%r1879}, {%r1930,%r1931,%r1932,%r1933}, {%r1998,%r1999}, {%r1876,%r1877,%r1878,%r1879}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1876,%r1877,%r1878,%r1879}, {%r1903,%r1910,%r1917,%r1924}, {%r2000,%r2001}, {%r1876,%r1877,%r1878,%r1879}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1876,%r1877,%r1878,%r1879}, {%r1903,%r1910,%r1917,%r1924}, {%r1998,%r1999}, {%r1876,%r1877,%r1878,%r1879}; + // end inline asm + add.s32 %r2002, %r1752, 4576; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r2004,%r2005,%r2008,%r2009}, [%r2002]; + // end inline asm + add.s32 %r2003, %r1752, 21984; + // begin inline asm + ldmatrix.sync.aligned.m8n8.x4.trans.shared.b16 {%r2006,%r2007,%r2010,%r2011}, [%r2003]; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1886,%r1887,%r1888,%r1889}, {%r1930,%r1931,%r1932,%r1933}, {%r2004,%r2005}, {%r1886,%r1887,%r1888,%r1889}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1886,%r1887,%r1888,%r1889}, {%r1903,%r1910,%r1917,%r1924}, {%r2006,%r2007}, {%r1886,%r1887,%r1888,%r1889}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1886,%r1887,%r1888,%r1889}, {%r1903,%r1910,%r1917,%r1924}, {%r2004,%r2005}, {%r1886,%r1887,%r1888,%r1889}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1894,%r1895,%r1896,%r1897}, {%r1930,%r1931,%r1932,%r1933}, {%r2008,%r2009}, {%r1894,%r1895,%r1896,%r1897}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1894,%r1895,%r1896,%r1897}, {%r1903,%r1910,%r1917,%r1924}, {%r2010,%r2011}, {%r1894,%r1895,%r1896,%r1897}; + // end inline asm + // begin inline asm + mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%r1894,%r1895,%r1896,%r1897}, {%r1903,%r1910,%r1917,%r1924}, {%r2008,%r2009}, {%r1894,%r1895,%r1896,%r1897}; + // end inline asm + mul.f32 %r2097, %r1760, %r114; + mul.f32 %r2098, %r1761, %r114; + mul.f32 %r2099, %r1762, %r114; + mul.f32 %r2100, %r1763, %r114; + mul.f32 %r2101, %r1768, %r114; + mul.f32 %r2102, %r1769, %r114; + mul.f32 %r2103, %r1770, %r114; + mul.f32 %r2104, %r1771, %r114; + mul.f32 %r2105, %r1778, %r114; + mul.f32 %r2106, %r1779, %r114; + mul.f32 %r2107, %r1780, %r114; + mul.f32 %r2108, %r1781, %r114; + mul.f32 %r2109, %r1786, %r114; + mul.f32 %r2110, %r1787, %r114; + mul.f32 %r2111, %r1788, %r114; + mul.f32 %r2112, %r1789, %r114; + mul.f32 %r2113, %r1796, %r114; + mul.f32 %r2114, %r1797, %r114; + mul.f32 %r2115, %r1798, %r114; + mul.f32 %r2116, %r1799, %r114; + mul.f32 %r2117, %r1804, %r114; + mul.f32 %r2118, %r1805, %r114; + mul.f32 %r2119, %r1806, %r114; + mul.f32 %r2120, %r1807, %r114; + mul.f32 %r2121, %r1814, %r114; + mul.f32 %r2122, %r1815, %r114; + mul.f32 %r2123, %r1816, %r114; + mul.f32 %r2124, %r1817, %r114; + mul.f32 %r2125, %r1822, %r114; + mul.f32 %r2126, %r1823, %r114; + mul.f32 %r2127, %r1824, %r114; + mul.f32 %r2128, %r1825, %r114; + mul.f32 %r2129, %r1832, %r114; + mul.f32 %r2130, %r1833, %r114; + mul.f32 %r2131, %r1834, %r114; + mul.f32 %r2132, %r1835, %r114; + mul.f32 %r2133, %r1840, %r114; + mul.f32 %r2134, %r1841, %r114; + mul.f32 %r2135, %r1842, %r114; + mul.f32 %r2136, %r1843, %r114; + mul.f32 %r2137, %r1850, %r114; + mul.f32 %r2138, %r1851, %r114; + mul.f32 %r2139, %r1852, %r114; + mul.f32 %r2140, %r1853, %r114; + mul.f32 %r2141, %r1858, %r114; + mul.f32 %r2142, %r1859, %r114; + mul.f32 %r2143, %r1860, %r114; + mul.f32 %r2144, %r1861, %r114; + mul.f32 %r2145, %r1868, %r114; + mul.f32 %r2146, %r1869, %r114; + mul.f32 %r2147, %r1870, %r114; + mul.f32 %r2148, %r1871, %r114; + mul.f32 %r2149, %r1876, %r114; + mul.f32 %r2150, %r1877, %r114; + mul.f32 %r2151, %r1878, %r114; + mul.f32 %r2152, %r1879, %r114; + mul.f32 %r2153, %r1886, %r114; + mul.f32 %r2154, %r1887, %r114; + mul.f32 %r2155, %r1888, %r114; + mul.f32 %r2156, %r1889, %r114; + mul.f32 %r2157, %r1894, %r114; + mul.f32 %r2158, %r1895, %r114; + mul.f32 %r2159, %r1896, %r114; + mul.f32 %r2160, %r1897, %r114; + setp.eq.b32 %p58, %r2161, %r121; + @%p58 bra $L__BB2_121; + bra.uni $L__BB2_42; +$L__BB2_121: + ld.param.b64 %rd228, [leleka_gdn_tc_scan_t2_param_1]; + cvta.to.global.u64 %rd224, %rd228; + add.s64 %rd225, %rd224, %rd2; + add.s64 %rd226, %rd225, %rd38; + st.global.b32 [%rd226], %r2097; + st.global.b32 [%rd226+24576], %r2098; + st.global.b32 [%rd226+32], %r2099; + st.global.b32 [%rd226+24608], %r2100; + abs.f32 %r2026, %r2097; + setp.equ.f32 %p59, %r2026, 0f7F800000; + abs.f32 %r2027, %r2098; + setp.equ.f32 %p60, %r2027, 0f7F800000; + or.pred %p61, %p59, %p60; + abs.f32 %r2028, %r2099; + setp.equ.f32 %p62, %r2028, 0f7F800000; + or.pred %p63, %p61, %p62; + abs.f32 %r2029, %r2100; + setp.equ.f32 %p64, %r2029, 0f7F800000; + or.pred %p65, %p63, %p64; + st.global.b32 [%rd226+196608], %r2101; + st.global.b32 [%rd226+221184], %r2102; + st.global.b32 [%rd226+196640], %r2103; + st.global.b32 [%rd226+221216], %r2104; + abs.f32 %r2030, %r2101; + setp.equ.f32 %p66, %r2030, 0f7F800000; + or.pred %p67, %p65, %p66; + abs.f32 %r2031, %r2102; + setp.equ.f32 %p68, %r2031, 0f7F800000; + or.pred %p69, %p67, %p68; + abs.f32 %r2032, %r2103; + setp.equ.f32 %p70, %r2032, 0f7F800000; + or.pred %p71, %p69, %p70; + abs.f32 %r2033, %r2104; + setp.equ.f32 %p72, %r2033, 0f7F800000; + or.pred %p73, %p71, %p72; + st.global.b32 [%rd226+393216], %r2105; + st.global.b32 [%rd226+417792], %r2106; + st.global.b32 [%rd226+393248], %r2107; + st.global.b32 [%rd226+417824], %r2108; + abs.f32 %r2034, %r2105; + setp.equ.f32 %p74, %r2034, 0f7F800000; + or.pred %p75, %p73, %p74; + abs.f32 %r2035, %r2106; + setp.equ.f32 %p76, %r2035, 0f7F800000; + or.pred %p77, %p75, %p76; + abs.f32 %r2036, %r2107; + setp.equ.f32 %p78, %r2036, 0f7F800000; + or.pred %p79, %p77, %p78; + abs.f32 %r2037, %r2108; + setp.equ.f32 %p80, %r2037, 0f7F800000; + or.pred %p81, %p79, %p80; + st.global.b32 [%rd226+589824], %r2109; + st.global.b32 [%rd226+614400], %r2110; + st.global.b32 [%rd226+589856], %r2111; + st.global.b32 [%rd226+614432], %r2112; + abs.f32 %r2038, %r2109; + setp.equ.f32 %p82, %r2038, 0f7F800000; + or.pred %p83, %p81, %p82; + abs.f32 %r2039, %r2110; + setp.equ.f32 %p84, %r2039, 0f7F800000; + or.pred %p85, %p83, %p84; + abs.f32 %r2040, %r2111; + setp.equ.f32 %p86, %r2040, 0f7F800000; + or.pred %p87, %p85, %p86; + abs.f32 %r2041, %r2112; + setp.equ.f32 %p88, %r2041, 0f7F800000; + or.pred %p89, %p87, %p88; + st.global.b32 [%rd226+786432], %r2113; + st.global.b32 [%rd226+811008], %r2114; + st.global.b32 [%rd226+786464], %r2115; + st.global.b32 [%rd226+811040], %r2116; + abs.f32 %r2042, %r2113; + setp.equ.f32 %p90, %r2042, 0f7F800000; + or.pred %p91, %p89, %p90; + abs.f32 %r2043, %r2114; + setp.equ.f32 %p92, %r2043, 0f7F800000; + or.pred %p93, %p91, %p92; + abs.f32 %r2044, %r2115; + setp.equ.f32 %p94, %r2044, 0f7F800000; + or.pred %p95, %p93, %p94; + abs.f32 %r2045, %r2116; + setp.equ.f32 %p96, %r2045, 0f7F800000; + or.pred %p97, %p95, %p96; + st.global.b32 [%rd226+983040], %r2117; + st.global.b32 [%rd226+1007616], %r2118; + st.global.b32 [%rd226+983072], %r2119; + st.global.b32 [%rd226+1007648], %r2120; + abs.f32 %r2046, %r2117; + setp.equ.f32 %p98, %r2046, 0f7F800000; + or.pred %p99, %p97, %p98; + abs.f32 %r2047, %r2118; + setp.equ.f32 %p100, %r2047, 0f7F800000; + or.pred %p101, %p99, %p100; + abs.f32 %r2048, %r2119; + setp.equ.f32 %p102, %r2048, 0f7F800000; + or.pred %p103, %p101, %p102; + abs.f32 %r2049, %r2120; + setp.equ.f32 %p104, %r2049, 0f7F800000; + or.pred %p105, %p103, %p104; + st.global.b32 [%rd226+1179648], %r2121; + st.global.b32 [%rd226+1204224], %r2122; + st.global.b32 [%rd226+1179680], %r2123; + st.global.b32 [%rd226+1204256], %r2124; + abs.f32 %r2050, %r2121; + setp.equ.f32 %p106, %r2050, 0f7F800000; + or.pred %p107, %p105, %p106; + abs.f32 %r2051, %r2122; + setp.equ.f32 %p108, %r2051, 0f7F800000; + or.pred %p109, %p107, %p108; + abs.f32 %r2052, %r2123; + setp.equ.f32 %p110, %r2052, 0f7F800000; + or.pred %p111, %p109, %p110; + abs.f32 %r2053, %r2124; + setp.equ.f32 %p112, %r2053, 0f7F800000; + or.pred %p113, %p111, %p112; + st.global.b32 [%rd226+1376256], %r2125; + st.global.b32 [%rd226+1400832], %r2126; + st.global.b32 [%rd226+1376288], %r2127; + st.global.b32 [%rd226+1400864], %r2128; + abs.f32 %r2054, %r2125; + setp.equ.f32 %p114, %r2054, 0f7F800000; + or.pred %p115, %p113, %p114; + abs.f32 %r2055, %r2126; + setp.equ.f32 %p116, %r2055, 0f7F800000; + or.pred %p117, %p115, %p116; + abs.f32 %r2056, %r2127; + setp.equ.f32 %p118, %r2056, 0f7F800000; + or.pred %p119, %p117, %p118; + abs.f32 %r2057, %r2128; + setp.equ.f32 %p120, %r2057, 0f7F800000; + or.pred %p121, %p119, %p120; + st.global.b32 [%rd226+1572864], %r2129; + st.global.b32 [%rd226+1597440], %r2130; + st.global.b32 [%rd226+1572896], %r2131; + st.global.b32 [%rd226+1597472], %r2132; + abs.f32 %r2058, %r2129; + setp.equ.f32 %p122, %r2058, 0f7F800000; + or.pred %p123, %p121, %p122; + abs.f32 %r2059, %r2130; + setp.equ.f32 %p124, %r2059, 0f7F800000; + or.pred %p125, %p123, %p124; + abs.f32 %r2060, %r2131; + setp.equ.f32 %p126, %r2060, 0f7F800000; + or.pred %p127, %p125, %p126; + abs.f32 %r2061, %r2132; + setp.equ.f32 %p128, %r2061, 0f7F800000; + or.pred %p129, %p127, %p128; + st.global.b32 [%rd226+1769472], %r2133; + st.global.b32 [%rd226+1794048], %r2134; + st.global.b32 [%rd226+1769504], %r2135; + st.global.b32 [%rd226+1794080], %r2136; + abs.f32 %r2062, %r2133; + setp.equ.f32 %p130, %r2062, 0f7F800000; + or.pred %p131, %p129, %p130; + abs.f32 %r2063, %r2134; + setp.equ.f32 %p132, %r2063, 0f7F800000; + or.pred %p133, %p131, %p132; + abs.f32 %r2064, %r2135; + setp.equ.f32 %p134, %r2064, 0f7F800000; + or.pred %p135, %p133, %p134; + abs.f32 %r2065, %r2136; + setp.equ.f32 %p136, %r2065, 0f7F800000; + or.pred %p137, %p135, %p136; + st.global.b32 [%rd226+1966080], %r2137; + st.global.b32 [%rd226+1990656], %r2138; + st.global.b32 [%rd226+1966112], %r2139; + st.global.b32 [%rd226+1990688], %r2140; + abs.f32 %r2066, %r2137; + setp.equ.f32 %p138, %r2066, 0f7F800000; + or.pred %p139, %p137, %p138; + abs.f32 %r2067, %r2138; + setp.equ.f32 %p140, %r2067, 0f7F800000; + or.pred %p141, %p139, %p140; + abs.f32 %r2068, %r2139; + setp.equ.f32 %p142, %r2068, 0f7F800000; + or.pred %p143, %p141, %p142; + abs.f32 %r2069, %r2140; + setp.equ.f32 %p144, %r2069, 0f7F800000; + or.pred %p145, %p143, %p144; + st.global.b32 [%rd226+2162688], %r2141; + st.global.b32 [%rd226+2187264], %r2142; + st.global.b32 [%rd226+2162720], %r2143; + st.global.b32 [%rd226+2187296], %r2144; + abs.f32 %r2070, %r2141; + setp.equ.f32 %p146, %r2070, 0f7F800000; + or.pred %p147, %p145, %p146; + abs.f32 %r2071, %r2142; + setp.equ.f32 %p148, %r2071, 0f7F800000; + or.pred %p149, %p147, %p148; + abs.f32 %r2072, %r2143; + setp.equ.f32 %p150, %r2072, 0f7F800000; + or.pred %p151, %p149, %p150; + abs.f32 %r2073, %r2144; + setp.equ.f32 %p152, %r2073, 0f7F800000; + or.pred %p153, %p151, %p152; + st.global.b32 [%rd226+2359296], %r2145; + st.global.b32 [%rd226+2383872], %r2146; + st.global.b32 [%rd226+2359328], %r2147; + st.global.b32 [%rd226+2383904], %r2148; + abs.f32 %r2074, %r2145; + setp.equ.f32 %p154, %r2074, 0f7F800000; + or.pred %p155, %p153, %p154; + abs.f32 %r2075, %r2146; + setp.equ.f32 %p156, %r2075, 0f7F800000; + or.pred %p157, %p155, %p156; + abs.f32 %r2076, %r2147; + setp.equ.f32 %p158, %r2076, 0f7F800000; + or.pred %p159, %p157, %p158; + abs.f32 %r2077, %r2148; + setp.equ.f32 %p160, %r2077, 0f7F800000; + or.pred %p161, %p159, %p160; + st.global.b32 [%rd226+2555904], %r2149; + st.global.b32 [%rd226+2580480], %r2150; + st.global.b32 [%rd226+2555936], %r2151; + st.global.b32 [%rd226+2580512], %r2152; + abs.f32 %r2078, %r2149; + setp.equ.f32 %p162, %r2078, 0f7F800000; + or.pred %p163, %p161, %p162; + abs.f32 %r2079, %r2150; + setp.equ.f32 %p164, %r2079, 0f7F800000; + or.pred %p165, %p163, %p164; + abs.f32 %r2080, %r2151; + setp.equ.f32 %p166, %r2080, 0f7F800000; + or.pred %p167, %p165, %p166; + abs.f32 %r2081, %r2152; + setp.equ.f32 %p168, %r2081, 0f7F800000; + or.pred %p169, %p167, %p168; + st.global.b32 [%rd226+2752512], %r2153; + st.global.b32 [%rd226+2777088], %r2154; + st.global.b32 [%rd226+2752544], %r2155; + st.global.b32 [%rd226+2777120], %r2156; + abs.f32 %r2082, %r2153; + setp.equ.f32 %p170, %r2082, 0f7F800000; + or.pred %p171, %p169, %p170; + abs.f32 %r2083, %r2154; + setp.equ.f32 %p172, %r2083, 0f7F800000; + or.pred %p173, %p171, %p172; + abs.f32 %r2084, %r2155; + setp.equ.f32 %p174, %r2084, 0f7F800000; + or.pred %p175, %p173, %p174; + abs.f32 %r2085, %r2156; + setp.equ.f32 %p176, %r2085, 0f7F800000; + or.pred %p177, %p175, %p176; + st.global.b32 [%rd226+2949120], %r2157; + st.global.b32 [%rd226+2973696], %r2158; + st.global.b32 [%rd226+2949152], %r2159; + st.global.b32 [%rd226+2973728], %r2160; + abs.f32 %r2086, %r2157; + setp.equ.f32 %p178, %r2086, 0f7F800000; + or.pred %p179, %p177, %p178; + abs.f32 %r2087, %r2158; + setp.equ.f32 %p180, %r2087, 0f7F800000; + or.pred %p181, %p179, %p180; + abs.f32 %r2088, %r2159; + setp.equ.f32 %p182, %r2088, 0f7F800000; + or.pred %p183, %p181, %p182; + abs.f32 %r2089, %r2160; + setp.equ.f32 %p184, %r2089, 0f7F800000; + or.pred %p185, %p183, %p184; + @%p185 bra $L__BB2_122; + bra.uni $L__BB2_123; +$L__BB2_122: + ld.param.b64 %rd229, [leleka_gdn_tc_scan_t2_param_12]; + cvta.to.global.u64 %rd227, %rd229; + atom.global.or.b32 %r2090, [%rd227], 1; +$L__BB2_123: + ret; + +} diff --git a/crates/cuda-driver/src/gdn_prefill_tc.rs b/crates/cuda-driver/src/gdn_prefill_tc.rs new file mode 100644 index 00000000..278ef80f --- /dev/null +++ b/crates/cuda-driver/src/gdn_prefill_tc.rs @@ -0,0 +1,299 @@ +//! Fixed asset `gdn_prefill_tc.cu` (EXPERIMENTAL, LOSSY, off by default): the prompt GDN recurrence as a chunked +//! scan on the tensor cores, a port of Strata upstream `src/prefill/gdn_tc.cuh` (step-ledger row U1). +//! +//! This module is the host side that needs no device: the sealed PTX with its pin, the launch geometry, the scratch +//! layout, the decision table "may this run take the tensor-core scan?" and the launch list of one prompt chunk. The +//! device owner (`gdn_prompt_device`) loads the module, reads the device and executes the list. +//! +//! The scan is NOT bitwise equal to `leleka_prefill_gdn_rec_kh` (the reduction order changes; every product is an f16x3 +//! split on `mma.sync`). Whether it may ever be a default is decided by the lossy gate of docs/quality-gate.md. +use crate::kar_decode_levels::{KarDecodeError, PtxPin, admit_ptx}; +use crate::ple_batch_ffi::{BatchArg, DeviceGeometry}; +use crate::{Error, Result, ffi::BufferHandle}; +use std::ffi::CStr; + +/// The PTX plus the single ABI NUL, like every other fixed asset. +pub(crate) static PTX: &[u8] = concat!(include_str!("gdn_prefill_tc.ptx"), "\0").as_bytes(); +/// Module entry order: the index passed to `KernelModule::launch_dynamic`. +pub(crate) const ENTRIES: &[&CStr] = &[c"leleka_gdn_tc_prep", c"leleka_gdn_tc_scan_t1", c"leleka_gdn_tc_scan_t2"]; +const PREP: usize = 0; +const SCAN_ONE_TILE: usize = 1; +const SCAN_TWO_TILES: usize = 2; + +/// Frozen by `scripts/gpu-bringup/reseal_own.py` after `compile_assets.py` (extra-seal-plan.json, group +/// gdn-prefill-tc). +pub(crate) const PIN: PtxPin = PtxPin { + source_sha256: [ + 140, 121, 176, 81, 97, 167, 229, 92, 123, 79, 111, 249, 182, 76, 245, 54, 123, 180, 179, 251, 37, 236, 33, 38, + 136, 203, 250, 118, 228, 111, 207, 65, + ], + ptx_sha256: [ + 84, 91, 216, 169, 217, 214, 20, 131, 163, 13, 60, 51, 198, 226, 196, 128, 60, 146, 243, 71, 219, 96, 55, 223, + 64, 7, 233, 68, 123, 153, 107, 33, + ], +}; +pub(crate) fn admit() -> std::result::Result<(), KarDecodeError> { + admit_ptx(PTX, &PIN) +} + +/// Tokens a chunk of the scan (the prep solves a lane per token). +pub(crate) const CHUNK_TOKENS: usize = 32; +/// Upstream `kGdnTcMin`: the prep and scan launches cost about 20 us, below this the sequential kernel wins. +pub(crate) const MIN_TOKENS: usize = 128; +const KEY_HEADS: usize = 16; +const VALUE_HEADS: usize = 48; +/// Dynamic shared memory of one scan block (`kTcScanSmemSplit`, the 99-KB plan) and of one prep block. +pub(crate) const SCAN_SMEM: u32 = 97_808; +pub(crate) const PREP_SMEM: u32 = 43_264; +const PREP_THREADS: u32 = 256; +/// Upstream `GSB / GCH`: chunks of one super-block at the frozen scratch of 60,305,408 bytes. +pub(crate) const UPSTREAM_CHUNKS: usize = 64; +/// Scratch bytes a chunk, in the order the kernels take them: T images, T scales, token scalars, k/q images, P images. +const SCRATCH_PARTS: [usize; 5] = [ + VALUE_HEADS * 2 * CHUNK_TOKENS * CHUNK_TOKENS * 2, + VALUE_HEADS * 4, + VALUE_HEADS * CHUNK_TOKENS * 16, + KEY_HEADS * 4 * CHUNK_TOKENS * 128 * 2, + VALUE_HEADS * 2 * CHUNK_TOKENS * CHUNK_TOKENS * 2, +]; +/// Scratch bytes a chunk (942,272). +pub(crate) const SCRATCH_PER_CHUNK: usize = + SCRATCH_PARTS[0] + SCRATCH_PARTS[1] + SCRATCH_PARTS[2] + SCRATCH_PARTS[3] + SCRATCH_PARTS[4]; + +/// Chunks of one super-block that a scratch of `bytes` holds, at most upstream's 64. +pub(crate) fn chunks_fitting(bytes: usize) -> usize { + (bytes / SCRATCH_PER_CHUNK).min(UPSTREAM_CHUNKS) +} + +/// Why a run does not take the scan; the device owner prints it once. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub(crate) enum Refusal { + NotRequested, + /// The sealed image is sm_120: the compute capability major of the device is below 12. + ComputeCapability(u32), + /// Fewer multiprocessors than value heads: the scan would run in several waves. + Multiprocessors(u32), + /// The opt-in shared memory a block is below the plan's 97,808 bytes. + SharedMemory(u32), + /// The scratch holds no chunk. + Scratch, +} + +impl std::fmt::Display for Refusal { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Self::NotRequested => write!(f, "not requested"), + Self::ComputeCapability(major) => write!(f, "compute capability {major}.x, the sealed image is sm_120"), + Self::Multiprocessors(n) => write!(f, "{n} multiprocessors, fewer than the {VALUE_HEADS} value heads"), + Self::SharedMemory(n) => write!(f, "{n} bytes of shared memory a block, the plan needs {SCAN_SMEM}"), + Self::Scratch => write!(f, "the scratch holds no chunk"), + } + } +} + +/// What a device owner decided once: value tiles a head and chunks of a super-block. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub(crate) struct ScanPlan { + tiles: u32, + chunks: usize, +} + +/// The decision table. Upstream's runtime gate (compute capability >= 8, one multiprocessor per value head, shared +/// memory) plus this repository's: the image is sealed for sm_120. Two value tiles a head on cards with at least +/// twice as many multiprocessors as value heads (upstream 51567de1a: one wave of 96 blocks; an RTX A6000 with 84 SMs +/// was 1.25x slower with two tiles, a card with 110 SMs 1.47x faster). +pub(crate) fn plan( + requested: bool, + device: DeviceGeometry, + scratch_bytes: usize, +) -> std::result::Result { + if !requested { + return Err(Refusal::NotRequested); + } + if device.cc_major < 12 { + return Err(Refusal::ComputeCapability(device.cc_major)); + } + if (device.multiprocessors as usize) < VALUE_HEADS { + return Err(Refusal::Multiprocessors(device.multiprocessors)); + } + if device.shared_optin < SCAN_SMEM { + return Err(Refusal::SharedMemory(device.shared_optin)); + } + let chunks = chunks_fitting(scratch_bytes); + if chunks == 0 { + return Err(Refusal::Scratch); + } + let tiles = if device.multiprocessors as usize >= 2 * VALUE_HEADS { 2 } else { 1 }; + Ok(ScanPlan { tiles, chunks }) +} + +impl ScanPlan { + /// Value tiles a head (1: 48 blocks of 256 threads, 2: 96 blocks of 128 threads). + pub(crate) fn tiles(&self) -> u32 { + self.tiles + } + /// Chunks of one super-block (the scratch holds this many). + pub(crate) fn chunks(&self) -> usize { + self.chunks + } + /// Per-run dispatch: a prompt chunk of `tokens` takes the scan from `MIN_TOKENS` on. + pub(crate) fn takes(&self, tokens: usize) -> bool { + tokens >= MIN_TOKENS + } + /// `(first token, chunks)` of every super-block of a run of `tokens`. + pub(crate) fn super_blocks(&self, tokens: usize) -> Vec<(usize, usize)> { + let span = self.chunks * CHUNK_TOKENS; + (0..tokens.div_ceil(span)).map(|i| (i * span, (tokens - i * span).min(span).div_ceil(CHUNK_TOKENS))).collect() + } + /// Tests only: the same plan with `tiles` value tiles a head (1 or 2). + #[cfg(test)] + pub(crate) fn with_tiles(self, tiles: u32) -> Self { + Self { tiles, ..self } + } + /// Tests only: the same plan with super-blocks of `chunks` chunks (small values chain the state through many + /// launches). + #[cfg(test)] + pub(crate) fn with_chunks(self, chunks: usize) -> Self { + Self { chunks, ..self } + } + fn scan_entry(&self) -> usize { + if self.tiles == 2 { SCAN_TWO_TILES } else { SCAN_ONE_TILE } + } + /// `(grid, block)` of the scan launch. + pub(crate) fn scan_shape(&self) -> (u32, u32) { + let heads = VALUE_HEADS as u32; + if self.tiles == 2 { (heads * 2, 128) } else { (heads, 256) } + } +} + +/// The buffers of one run: the recurrence's own interface (as `leleka_prefill_gdn_rec_kh`) and the scratch. +#[derive(Clone, Copy)] +pub(crate) struct RecurrenceIo { + pub(crate) state_in: BufferHandle, + pub(crate) state_out: BufferHandle, + pub(crate) h: BufferHandle, + pub(crate) gate: BufferHandle, + pub(crate) beta: BufferHandle, + pub(crate) y: BufferHandle, + pub(crate) witness: BufferHandle, + pub(crate) scratch: BufferHandle, +} + +/// One kernel launch of the list: module entry, grid and block (1-D), dynamic shared memory and arguments. +pub(crate) struct TcLaunch { + pub(crate) entry: usize, + pub(crate) grid: u32, + pub(crate) block: u32, + pub(crate) smem: u32, + pub(crate) args: Vec, +} + +/// The five sub-buffers of the scratch, `chunks` chunks each. +#[derive(Clone, Copy)] +struct Scratch { + ti: BufferHandle, + te: BufferHandle, + sc: BufferHandle, + kq: BufferHandle, + pi: BufferHandle, +} + +impl Scratch { + /// Carves a scratch allocation of `len` bytes starting at `base`. + fn carve(base: BufferHandle, len: usize, chunks: usize) -> Result { + let mut offset = 0; + let mut parts = [base; 5]; + for (part, bytes) in parts.iter_mut().zip(SCRATCH_PARTS) { + let bytes = bytes * chunks; + *part = base.checked_subspan(len, offset, bytes)?; + offset += bytes; + } + let [ti, te, sc, kq, pi] = parts; + Ok(Self { ti, te, sc, kq, pi }) + } +} + +/// One super-block: first token, chunks, and the tokens of the whole run. +#[derive(Clone, Copy)] +struct Block { + t0: i64, + chunks: i32, + tokens: i64, +} + +fn prep_launch(io: &RecurrenceIo, s: &Scratch, b: Block) -> TcLaunch { + let a = BatchArg::Address; + TcLaunch { + entry: PREP, + grid: b.chunks as u32 * KEY_HEADS as u32, + block: PREP_THREADS, + smem: PREP_SMEM, + args: vec![ + a(io.h), + a(io.gate), + a(io.beta), + a(s.ti), + a(s.te), + a(s.sc), + a(s.kq), + a(s.pi), + BatchArg::I64(b.t0), + BatchArg::I64(b.tokens), + ], + } +} + +fn scan_launch(plan: &ScanPlan, (io, s): (&RecurrenceIo, &Scratch), (state_in, b): (BufferHandle, Block)) -> TcLaunch { + let a = BatchArg::Address; + let (grid, block) = plan.scan_shape(); + TcLaunch { + entry: plan.scan_entry(), + grid, + block, + smem: SCAN_SMEM, + args: vec![ + a(state_in), + a(io.state_out), + a(io.h), + a(s.ti), + a(s.te), + a(s.sc), + a(s.kq), + a(s.pi), + a(io.y), + BatchArg::I64(b.t0), + BatchArg::I32(b.chunks), + BatchArg::I64(b.tokens), + a(io.witness), + ], + } +} + +/// The launches of one prompt chunk of `tokens` tokens (the caller asks `ScanPlan::takes` first; the kernels +/// themselves run any `tokens >= 1`, which the parity test uses): per super-block the prep and the scan, in stream +/// order. The first scan reads `state_in`, the later ones the `state_out` the scan before wrote (in place: a block +/// reads and writes only its own columns). The witness word is raised by every scan whose final state is not finite. +pub(crate) fn launches( + plan: &ScanPlan, + io: &RecurrenceIo, + (scratch_len, tokens): (usize, usize), +) -> Result> { + if tokens == 0 || scratch_len < SCRATCH_PER_CHUNK * plan.chunks { + return Err(Error::InvalidQwenShape); + } + let scratch = Scratch::carve(io.scratch, scratch_len, plan.chunks)?; + let blocks = plan.super_blocks(tokens); + let mut list = Vec::new(); + list.try_reserve_exact(2 * blocks.len()).map_err(|_| Error::HostAllocation)?; + for (index, (t0, chunks)) in blocks.into_iter().enumerate() { + let b = Block { t0: t0 as i64, chunks: chunks as i32, tokens: tokens as i64 }; + list.push(prep_launch(io, &scratch, b)); + let from = if index == 0 { io.state_in } else { io.state_out }; + list.push(scan_launch(plan, (io, &scratch), (from, b))); + } + Ok(list) +} + +#[cfg(test)] +#[path = "gdn_prefill_tc_tests.rs"] +mod tests; diff --git a/crates/cuda-driver/src/gdn_prefill_tc_tests.rs b/crates/cuda-driver/src/gdn_prefill_tc_tests.rs new file mode 100644 index 00000000..bcf35527 --- /dev/null +++ b/crates/cuda-driver/src/gdn_prefill_tc_tests.rs @@ -0,0 +1,201 @@ +//! Host tests of `gdn_prefill_tc`: layout, launch parameters, the dispatch decision table and the launch list. +//! No device. +use super::*; + +fn device(cc_major: u32, multiprocessors: u32, shared_optin: u32) -> DeviceGeometry { + DeviceGeometry { cc_major, multiprocessors, shared_optin } +} +/// The RTX 5090: compute capability 12.0, 170 SMs, 101,376 bytes of opt-in shared memory a block. +const RTX_5090: DeviceGeometry = DeviceGeometry { cc_major: 12, multiprocessors: 170, shared_optin: 101_376 }; +/// The prompt device's dequantization scratch the scan runs in. +const SCRATCH: usize = 52_428_800; + +fn handle(address: u64) -> BufferHandle { + BufferHandle::synthetic(address) +} +fn io() -> RecurrenceIo { + let [state_in, state_out, h, gate, beta, y, witness, scratch] = + [0x1000u64, 0x2000, 0x3000, 0x4000, 0x5000, 0x6000, 0x7000, 0x1_0000_0000].map(handle); + RecurrenceIo { state_in, state_out, h, gate, beta, y, witness, scratch } +} +fn address(arg: &BatchArg) -> u64 { + match arg { + BatchArg::Address(h) => h.qwen_address(), + _ => panic!("not an address"), + } +} +fn int(arg: &BatchArg) -> i64 { + match arg { + BatchArg::I64(x) => *x, + BatchArg::I32(x) => i64::from(*x), + _ => panic!("not an integer"), + } +} + +#[test] +fn the_shared_memory_and_scratch_plans_are_the_frozen_ones() { + // kTcScanSmemSplit: 2 (4 GCH KP 2 + GCH 16) + GCH VP 4 + 4 GCH PP 2 + 16, + // with KP = 136, VP = 132, PP = 40, GCH = 32 + assert_eq!(2 * (4 * 32 * 136 * 2 + 32 * 16) + 32 * 132 * 4 + 4 * 32 * 40 * 2 + 16, SCAN_SMEM as usize); + assert_eq!(4 * 32 * 136 * 2 + 2 * 32 * 33 * 4, PREP_SMEM as usize); + // the 99-KB opt-in of sm_86 / sm_89 / sm_120 holds the scan + const { assert!(SCAN_SMEM <= 101_376 && PREP_SMEM <= 48 * 1024) }; + assert_eq!(SCRATCH_PER_CHUNK, 942_272); + assert_eq!(SCRATCH_PER_CHUNK * UPSTREAM_CHUNKS, 60_305_408, "upstream's frozen scratch for HV 48 / HK 16"); + // cp.async copies 16-byte pieces: every part starts on a 16-byte boundary for any chunk count (the 4-byte scales + // are 192 bytes a chunk) + for chunks in 1..=UPSTREAM_CHUNKS { + let mut offset = 0; + for (i, bytes) in SCRATCH_PARTS.iter().enumerate() { + assert_eq!(offset % 16, 0, "part {i} at {offset} with {chunks} chunks"); + offset += bytes * chunks; + } + } +} + +#[test] +fn the_source_names_the_same_plans() { + let source = include_str!("gdn_prefill_tc.cu"); + for needle in + ["kTcScanSmemSplit == 97808", "kTcPrepSmem == 43264", "constexpr int S = 128, HK = 16, HV = 48, C = 10240"] + { + assert!(source.contains(needle), "gdn_prefill_tc.cu lacks {needle:?}"); + } + for entry in ENTRIES { + let name = entry.to_str().expect("ascii"); + assert!(source.contains(name), "gdn_prefill_tc.cu lacks the entry {name}"); + } +} + +#[test] +fn the_dequantization_scratch_holds_55_chunks_so_the_scan_costs_no_extra_memory() { + assert_eq!(chunks_fitting(SCRATCH), 55); + assert_eq!(chunks_fitting(60_305_408), UPSTREAM_CHUNKS); + assert_eq!(chunks_fitting(2 * 60_305_408), UPSTREAM_CHUNKS); + assert_eq!(chunks_fitting(SCRATCH_PER_CHUNK - 1), 0); + const { assert!(55 * SCRATCH_PER_CHUNK <= SCRATCH && 56 * SCRATCH_PER_CHUNK > SCRATCH) }; +} + +#[test] +fn the_decision_table_refuses_every_card_the_plan_does_not_fit() { + let plan_of = |d, bytes| plan(true, d, bytes); + assert_eq!(plan(false, RTX_5090, SCRATCH), Err(Refusal::NotRequested), "off unless asked"); + assert_eq!( + plan_of(device(8, 170, 101_376), SCRATCH), + Err(Refusal::ComputeCapability(8)), + "sm_86 has no companion image" + ); + assert_eq!(plan_of(device(11, 170, 101_376), SCRATCH), Err(Refusal::ComputeCapability(11))); + assert_eq!( + plan_of(device(12, 47, 101_376), SCRATCH), + Err(Refusal::Multiprocessors(47)), + "fewer SMs than value heads" + ); + assert_eq!(plan_of(device(12, 170, SCAN_SMEM - 1), SCRATCH), Err(Refusal::SharedMemory(SCAN_SMEM - 1))); + assert_eq!(plan_of(device(12, 170, 48 * 1024), SCRATCH), Err(Refusal::SharedMemory(48 * 1024)), "no opt-in"); + assert_eq!(plan_of(RTX_5090, SCRATCH_PER_CHUNK - 1), Err(Refusal::Scratch)); + assert!(plan_of(device(12, 48, SCAN_SMEM), SCRATCH).is_ok()); +} + +#[test] +fn two_value_tiles_a_head_from_96_multiprocessors() { + let tiles = |sms| plan(true, device(12, sms, 101_376), SCRATCH).expect("plan").tiles(); + assert_eq!([tiles(48), tiles(84), tiles(95), tiles(96), tiles(110), tiles(170)], [1, 1, 1, 2, 2, 2]); + let five_thousand_ninety = plan(true, RTX_5090, SCRATCH).expect("plan"); + assert_eq!((five_thousand_ninety.tiles(), five_thousand_ninety.chunks()), (2, 55)); + assert_eq!(five_thousand_ninety.scan_shape(), (96, 128), "96 blocks of 4 warps, one wave on 170 SMs"); + assert_eq!(plan(true, device(12, 84, 101_376), SCRATCH).expect("plan").scan_shape(), (48, 256)); +} + +#[test] +fn a_run_takes_the_scan_from_128_tokens_and_walks_super_blocks_of_the_scratch() { + let p = plan(true, RTX_5090, SCRATCH).expect("plan"); + assert!(!p.takes(1) && !p.takes(127) && p.takes(128) && p.takes(8192)); + assert_eq!(p.super_blocks(128), [(0, 4)]); + assert_eq!(p.super_blocks(129), [(0, 5)], "a partial chunk is a chunk"); + assert_eq!(p.super_blocks(1760), [(0, 55)]); + assert_eq!(p.super_blocks(1761), [(0, 55), (1760, 1)]); + let all = p.super_blocks(8192); + assert_eq!(all.len(), 5); + assert_eq!(all.iter().map(|b| b.1).sum::(), 256, "8192 tokens are 256 chunks"); + assert_eq!(all[4], (7040, 36)); + for t in [128usize, 200, 1759, 1760, 1761, 3520, 3521, 4099, 8191, 8192] { + let blocks = p.super_blocks(t); + assert_eq!(blocks[0].0, 0); + for pair in blocks.windows(2) { + assert_eq!(pair[1].0, pair[0].0 + pair[0].1 * CHUNK_TOKENS, "t={t}: contiguous"); + } + let (last_t0, last) = *blocks.last().unwrap(); + assert!(last_t0 < t && last_t0 + last * CHUNK_TOKENS >= t && last_t0 + (last - 1) * CHUNK_TOKENS < t, "t={t}"); + } +} + +#[test] +fn the_launch_list_orders_prep_and_scan_and_chains_the_state() { + let p = plan(true, RTX_5090, SCRATCH).expect("plan"); + let io = io(); + let list = launches(&p, &io, (SCRATCH, 8192)).expect("launches"); + assert_eq!(list.len(), 10, "a prep and a scan for each of the 5 super-blocks"); + for (i, pair) in list.chunks(2).enumerate() { + let (prep, scan) = (&pair[0], &pair[1]); + assert_eq!((prep.entry, prep.block, prep.smem, prep.args.len()), (0, 256, PREP_SMEM, 10)); + assert_eq!(prep.grid as usize, [55, 55, 55, 55, 36][i] * 16, "a block a (chunk, key head)"); + assert_eq!((scan.entry, scan.grid, scan.block, scan.smem, scan.args.len()), (2, 96, 128, SCAN_SMEM, 13)); + // state: the first scan reads the prior state, the others what the scan before wrote; all write state_out + assert_eq!(address(&scan.args[0]), if i == 0 { 0x1000 } else { 0x2000 }); + assert_eq!(address(&scan.args[1]), 0x2000); + assert_eq!(int(&scan.args[9]), (i * 1760) as i64, "first token of the super-block"); + assert_eq!(int(&scan.args[10]), [55, 55, 55, 55, 36][i]); + assert_eq!(int(&scan.args[11]), 8192, "tokens of the whole run"); + assert_eq!(address(&scan.args[12]), 0x7000, "the state witness word"); + assert_eq!(address(&scan.args[8]), 0x6000, "the readout buffer"); + } +} + +#[test] +fn the_launch_list_stays_inside_the_scratch_and_refuses_what_does_not_fit() { + let p = plan(true, RTX_5090, SCRATCH).expect("plan"); + let io = io(); + let list = launches(&p, &io, (SCRATCH, 4096)).expect("launches"); + let base = 0x1_0000_0000u64; + let mut parts: Vec<(u64, usize)> = list[0].args[3..8].iter().map(address).map(|a| (a, 0)).collect(); + parts.iter_mut().zip(SCRATCH_PARTS).for_each(|(p, bytes)| p.1 = bytes * 55); + assert_eq!(parts[0].0, base, "T images first"); + for pair in parts.windows(2) { + assert_eq!(pair[1].0, pair[0].0 + pair[0].1 as u64, "parts follow each other"); + } + let end = parts[4].0 + parts[4].1 as u64; + assert!(end - base <= SCRATCH as u64, "the five parts end at {} of {SCRATCH}", end - base); + assert!(launches(&p, &io, (SCRATCH, 0)).is_err(), "an empty run launches nothing"); + assert_eq!( + launches(&p, &io, (SCRATCH, 1)).expect("one token").len(), + 2, + "the kernels run any length; takes() is the dispatch" + ); + assert!(launches(&p, &io, (SCRATCH - 1_000_000, 4096)).is_err(), "a scratch shorter than the plan's chunks"); +} + +#[test] +fn the_sealed_image_is_pinned_and_exports_the_three_entries() { + assert!(admit().is_ok(), "gdn_prefill_tc.ptx must match PIN (scripts/gpu-bringup/reseal_own.py)"); + let ptx = std::str::from_utf8(&PTX[..PTX.len() - 1]).expect("ascii"); + assert!(ptx.lines().any(|l| l == ".target sm_120") && ptx.lines().any(|l| l == ".address_size 64")); + for entry in ENTRIES { + let name = entry.to_str().expect("ascii"); + assert!(ptx.contains(&format!(".visible .entry {name}(")), "{name}"); + } + assert_eq!(ptx.matches(".entry ").count(), ENTRIES.len(), "no other kernel in the asset"); + assert!(!ptx.contains("UNSEALED")); +} + +#[test] +fn small_super_blocks_chain_the_state_through_state_out() { + let p = plan(true, RTX_5090, SCRATCH).expect("plan").with_chunks(3).with_tiles(1); + assert_eq!(p.super_blocks(200), [(0, 3), (96, 3), (192, 1)]); + let list = launches(&p, &io(), (SCRATCH, 200)).expect("launches"); + let scans: Vec<_> = list.iter().filter(|l| l.entry == 1).collect(); + assert_eq!(scans.len(), 3); + assert_eq!(scans.iter().map(|l| (l.grid, l.block)).collect::>(), [(48, 256); 3]); + assert_eq!(scans.iter().map(|l| address(&l.args[0])).collect::>(), [0x1000, 0x2000, 0x2000]); + assert!(scans.iter().all(|l| address(&l.args[1]) == 0x2000), "every scan writes state_out"); +} diff --git a/crates/cuda-driver/src/gdn_prompt_device.rs b/crates/cuda-driver/src/gdn_prompt_device.rs index 05f8d383..3085d923 100644 --- a/crates/cuda-driver/src/gdn_prompt_device.rs +++ b/crates/cuda-driver/src/gdn_prompt_device.rs @@ -18,8 +18,21 @@ pub struct OriginalGdnPromptDevice<'ctx> { history: [Option>; 2], /// `prefill_stage.cu`: element-parallel weight dequantization and the kernels with their guards folded in. stage: Option, + options: GdnPromptOptions, + /// The EXPERIMENTAL tensor-core scan of the recurrence (`gdn_prefill_tc.cu`): off unless `options` ask, decided + /// once. + tensor_core: TensorCoreState, failed: bool, } +/// What the operator chose for the prompt GDN device. Every field is off by default. +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] +pub struct GdnPromptOptions { + /// `LELEKA_PREFILL_GDN_TC` (EXPERIMENTAL, LOSSY): runs of 128 tokens and more take the chunked tensor-core scan + /// of the recurrence when the device fits it (sm_120, 48 or more SMs, 97,808 bytes of shared memory a block); + /// anything else keeps the sequential kernel. Not bitwise equal to it; the lossy gate of docs/quality-gate.md + /// decides. + pub tensor_core_scan: bool, +} /// Actual complete role owners; source/row/current prior are authenticated by runtime. pub struct OriginalGdnPromptWeights<'w, 'ctx> { pub matrices: [&'w DeviceBuffer<'ctx>; 5], // QKV,Z,Out,Alpha,Beta @@ -57,6 +70,14 @@ enum DeviceCommand { block: u32, args: KernelArguments, }, + /// A kernel of the experimental tensor-core scan module (1-D grid, dynamic shared memory). + TensorCore { + entry: usize, + grid: u32, + block: u32, + smem: u32, + args: KernelArguments, + }, } #[cfg(test)] @@ -67,5 +88,6 @@ mod stage_gpu_tests; mod context; #[path = "gdn_prompt_device/original_gdn_prompt_device.rs"] mod original_gdn_prompt_device; +use original_gdn_prompt_device::TensorCoreState; #[path = "gdn_prompt_device/original_gdn_prompt_device_drop.rs"] mod original_gdn_prompt_device_drop; diff --git a/crates/cuda-driver/src/gdn_prompt_device/context.rs b/crates/cuda-driver/src/gdn_prompt_device/context.rs index 64514eea..1af8d99a 100644 --- a/crates/cuda-driver/src/gdn_prompt_device/context.rs +++ b/crates/cuda-driver/src/gdn_prompt_device/context.rs @@ -9,6 +9,15 @@ impl<'ctx> Context<'ctx> { capacity: usize, profile: crate::GrNativeProfile, ) -> Result> { - OriginalGdnPromptDevice::new(self, capacity, profile) + self.original_gdn_prompt_device_with(capacity, profile, GdnPromptOptions::default()) + } + /// `original_gdn_prompt_device` with the operator's options (all off by default). + pub fn original_gdn_prompt_device_with( + &'ctx self, + capacity: usize, + profile: crate::GrNativeProfile, + options: GdnPromptOptions, + ) -> Result> { + OriginalGdnPromptDevice::new(self, (capacity, profile), options) } } diff --git a/crates/cuda-driver/src/gdn_prompt_device/original_gdn_prompt_device.rs b/crates/cuda-driver/src/gdn_prompt_device/original_gdn_prompt_device.rs index 18934fe2..afc709a9 100644 --- a/crates/cuda-driver/src/gdn_prompt_device/original_gdn_prompt_device.rs +++ b/crates/cuda-driver/src/gdn_prompt_device/original_gdn_prompt_device.rs @@ -15,5 +15,8 @@ mod original_gdn_prompt_device_drain; mod prompt_block_produce; #[path = "original_gdn_prompt_device/prompt_command_list.rs"] mod prompt_command_list; +#[path = "original_gdn_prompt_device/prompt_tensor_core_scan.rs"] +mod prompt_tensor_core_scan; #[allow(unused_imports)] use gdn_prompt_run_buffer_binder::{Binder, Carve, Carved, Handles, Phase}; +pub(super) use prompt_tensor_core_scan::TensorCoreState; diff --git a/crates/cuda-driver/src/gdn_prompt_device/original_gdn_prompt_device/original_gdn_prompt_device_admit_open.rs b/crates/cuda-driver/src/gdn_prompt_device/original_gdn_prompt_device/original_gdn_prompt_device_admit_open.rs index 0fc3c07d..fe540935 100644 --- a/crates/cuda-driver/src/gdn_prompt_device/original_gdn_prompt_device/original_gdn_prompt_device_admit_open.rs +++ b/crates/cuda-driver/src/gdn_prompt_device/original_gdn_prompt_device/original_gdn_prompt_device_admit_open.rs @@ -12,8 +12,8 @@ impl<'ctx> OriginalGdnPromptDevice<'ctx> { } pub(in super::super) fn new( context: &'ctx Context<'ctx>, - capacity: usize, - profile: crate::GrNativeProfile, + (capacity, profile): (usize, crate::GrNativeProfile), + options: GdnPromptOptions, ) -> Result { Self::admit_budget(context, capacity)?; let mut owner = Self { @@ -24,6 +24,8 @@ impl<'ctx> OriginalGdnPromptDevice<'ctx> { scratch: None, history: [None, None], stage: None, + options, + tensor_core: TensorCoreState::new(options.tensor_core_scan), failed: false, }; let operation = owner.open(); diff --git a/crates/cuda-driver/src/gdn_prompt_device/original_gdn_prompt_device/original_gdn_prompt_device_close.rs b/crates/cuda-driver/src/gdn_prompt_device/original_gdn_prompt_device/original_gdn_prompt_device_close.rs index b2be42ec..f60fdc0e 100644 --- a/crates/cuda-driver/src/gdn_prompt_device/original_gdn_prompt_device/original_gdn_prompt_device_close.rs +++ b/crates/cuda-driver/src/gdn_prompt_device/original_gdn_prompt_device/original_gdn_prompt_device_close.rs @@ -26,6 +26,7 @@ impl<'ctx> OriginalGdnPromptDevice<'ctx> { if let Some(m) = self.stage.take() { result = combine(result, self.release_stage(m)); } + result = combine(result, self.release_tensor_core()); if let Some(b) = self.batch.take() { result = combine(result, self.release_batch(b)); } @@ -35,7 +36,7 @@ impl<'ctx> OriginalGdnPromptDevice<'ctx> { } result } - fn release_stage(&self, m: KernelModule) -> Result<()> { + pub(super) fn release_stage(&self, m: KernelModule) -> Result<()> { if self.context.is_poisoned() { std::mem::forget(m); return Err(Error::ContextPoisoned); diff --git a/crates/cuda-driver/src/gdn_prompt_device/original_gdn_prompt_device/original_gdn_prompt_device_drain.rs b/crates/cuda-driver/src/gdn_prompt_device/original_gdn_prompt_device/original_gdn_prompt_device_drain.rs index 47dee542..0eec13ea 100644 --- a/crates/cuda-driver/src/gdn_prompt_device/original_gdn_prompt_device/original_gdn_prompt_device_drain.rs +++ b/crates/cuda-driver/src/gdn_prompt_device/original_gdn_prompt_device/original_gdn_prompt_device_drain.rs @@ -40,6 +40,7 @@ fn command_label(cmd: &DeviceCommand) -> &'static str { DeviceCommand::Kernel { .. } => "kernel", DeviceCommand::Gemm { .. } => "gemm", DeviceCommand::Stage { .. } => "stage", + DeviceCommand::TensorCore { .. } => "tensor-core", } } @@ -56,7 +57,7 @@ impl<'ctx> OriginalGdnPromptDevice<'ctx> { let host = self.execute(workspace, (commands, host), run)?; self.decode_run(host) } - fn fail_context(&mut self) { + pub(super) fn fail_context(&mut self) { self.failed = true; self.context.poison(); self.context.retain_driver(); @@ -172,6 +173,9 @@ impl<'ctx> OriginalGdnPromptDevice<'ctx> { Some(module) => module.launch(*index, LinearLaunch::new(*grid, *block, blas.stream()), args), None => Err(Error::ContextPoisoned), }, + DeviceCommand::TensorCore { entry, grid, block, smem, args } => { + self.launch_tensor_core(blas, (*entry, *grid, *block, *smem), args) + } } } fn read_back(&self, hd: &Handles, host: &mut Host) -> Result<()> { diff --git a/crates/cuda-driver/src/gdn_prompt_device/original_gdn_prompt_device/prompt_block_produce.rs b/crates/cuda-driver/src/gdn_prompt_device/original_gdn_prompt_device/prompt_block_produce.rs index ee7a0119..e8c7e54c 100644 --- a/crates/cuda-driver/src/gdn_prompt_device/original_gdn_prompt_device/prompt_block_produce.rs +++ b/crates/cuda-driver/src/gdn_prompt_device/original_gdn_prompt_device/prompt_block_produce.rs @@ -19,6 +19,7 @@ impl<'ctx> OriginalGdnPromptDevice<'ctx> { let t = read.rows(); self.admit(&read, workspace, history)?; let handles = self.admit_handles(read.lease(), (workspace, t), &weights, (state, next_state))?; + self.prepare_tensor_core()?; let commands = self.build_commands(&handles, weights.formats, t)?; let values = self.drain(workspace, commands, history, (&handles, t))?; Ok((read.from_completed_block(), values)) diff --git a/crates/cuda-driver/src/gdn_prompt_device/original_gdn_prompt_device/prompt_command_list.rs b/crates/cuda-driver/src/gdn_prompt_device/original_gdn_prompt_device/prompt_command_list.rs index 8ee40b4b..52372493 100644 --- a/crates/cuda-driver/src/gdn_prompt_device/original_gdn_prompt_device/prompt_command_list.rs +++ b/crates/cuda-driver/src/gdn_prompt_device/original_gdn_prompt_device/prompt_command_list.rs @@ -3,6 +3,7 @@ #[allow(unused_imports)] use super::*; +use crate::gdn_prefill_tc as tc; /// The commands of one run under construction. struct Cmds<'f, 'ctx> { @@ -14,6 +15,8 @@ struct Cmds<'f, 'ctx> { /// its FP16 image ride on the kernels that read or write those tensors (same status words). fused: bool, fast_dequant: bool, + /// The experimental tensor-core scan of the recurrence, when the device owner admitted it. + tensor_core: Option, list: Vec, } @@ -44,10 +47,11 @@ impl<'ctx> OriginalGdnPromptDevice<'ctx> { t: usize, ) -> Result> { let mut list = Vec::new(); - list.try_reserve_exact(48).map_err(|_| Error::HostAllocation)?; + list.try_reserve_exact(64).map_err(|_| Error::HostAllocation)?; let funcs = self.batch.as_ref().ok_or(Error::ContextPoisoned)?.functions.as_ref(); let funcs = funcs.ok_or(Error::ContextPoisoned)?; let mut c = Cmds::new(funcs, self.context, (*hd, t), list); + c.tensor_core = self.tensor_core.plan(); c.begin()?; c.projections(formats)?; c.gates()?; @@ -67,7 +71,8 @@ impl<'f, 'ctx> Cmds<'f, 'ctx> { ) -> Self { let (hd, t) = run; let fused = crate::prefill_stage::fused_scans() && t > 64; - Self { funcs, context, hd, t, fused, fast_dequant: crate::prefill_stage::fast_dequant(), list } + let fast_dequant = crate::prefill_stage::fast_dequant(); + Self { funcs, context, hd, t, fused, fast_dequant, tensor_core: None, list } } fn kernel(&mut self, kernel: Kernel, geometry: ([u32; 3], [u32; 3]), args: &[ffi::KernelArg]) -> Result<()> { self.list.push(DeviceCommand::Kernel { @@ -260,16 +265,51 @@ impl<'f, 'ctx> Cmds<'f, 'ctx> { self.kernel(Kernel::L2, ([32, t as u32, 1], [128, 1, 1]), &args)?; self.scan(GdnBatchStage::Qk, h) } - /// The state recurrence: the staged kernel when requested or usable, the original pipe kernel otherwise. + /// The state recurrence: the experimental tensor-core scan when the device admitted it and the run is long + /// enough, else the sequential kernels. fn recurrence(&mut self) -> Result<()> { let witness = self.word(GdnBatchStage::StateSteps)?; - if crate::prefill_stage::fast_rec() || crate::prefill_stage::gdn_kh_usable(self.context) { - self.recurrence_staged(witness); - } else { - self.recurrence_pipe(witness)?; + if !self.recurrence_tensor_core(witness)? { + self.recurrence_sequential(witness)?; } self.scan(GdnBatchStage::NextState, self.hd.sout) } + /// The token-serial recurrence: the staged kernel when requested or usable, the original pipe kernel otherwise. + fn recurrence_sequential(&mut self, witness: ffi::BufferHandle) -> Result<()> { + if crate::prefill_stage::fast_rec() || crate::prefill_stage::gdn_kh_usable(self.context) { + self.recurrence_staged(witness); + Ok(()) + } else { + self.recurrence_pipe(witness) + } + } + /// `LELEKA_PREFILL_GDN_TC` (EXPERIMENTAL, LOSSY): the prep and scan launches of every super-block of the run, same + /// interface as the kernels they replace (state in/out, readout `y`, the state witness). False: not taken. + fn recurrence_tensor_core(&mut self, witness: ffi::BufferHandle) -> Result { + let Some(plan) = self.tensor_core.filter(|p| p.takes(self.t)) else { return Ok(false) }; + let (hd, p) = (self.hd, self.hd.c.p); + let io = tc::RecurrenceIo { + state_in: hd.sin, + state_out: hd.sout, + h: p.h, + gate: p.gate, + beta: p.beta, + y: p.y, + witness, + scratch: hd.scratch, + }; + for l in tc::launches(&plan, &io, (SCRATCH, self.t))? { + let args = KernelArguments::new(l.args); + self.list.push(DeviceCommand::TensorCore { + entry: l.entry, + grid: l.grid, + block: l.block, + smem: l.smem, + args, + }); + } + Ok(true) + } fn recurrence_staged(&mut self, witness: ffi::BufferHandle) { let kh = !crate::prefill_stage::fast_rec(); let index = if kh { crate::prefill_stage::GDN_REC_KH } else { crate::prefill_stage::GDN_REC }; diff --git a/crates/cuda-driver/src/gdn_prompt_device/original_gdn_prompt_device/prompt_tensor_core_scan.rs b/crates/cuda-driver/src/gdn_prompt_device/original_gdn_prompt_device/prompt_tensor_core_scan.rs new file mode 100644 index 00000000..33b79de9 --- /dev/null +++ b/crates/cuda-driver/src/gdn_prompt_device/original_gdn_prompt_device/prompt_tensor_core_scan.rs @@ -0,0 +1,126 @@ +//! The EXPERIMENTAL tensor-core scan of the prompt GDN recurrence, device-owner side (`LELEKA_PREFILL_GDN_TC`, off +//! by default; kernels and launch list: `gdn_prefill_tc.rs` / `gdn_prefill_tc.cu`, ledger row U1). It loads the +//! sealed module once, reads the device, and decides once whether this device takes the scan. Nothing here +//! allocates: the scan runs in the dequantization scratch the owner already holds, which is idle during the +//! recurrence (every command of a run is on one stream; the projections' dequantization wrote it before and the +//! output projection's rewrites it after), so it costs no device memory and the prefill budget is unchanged. + +#[allow(unused_imports)] +use super::*; +use crate::gdn_prefill_tc as tc; +use crate::ple_batch_ffi::LinearLaunch; + +/// The loaded module and the plan the device admitted. +pub(in super::super) struct TensorCoreScan { + pub(super) module: KernelModule, + pub(super) plan: tc::ScanPlan, +} + +/// `Off` until asked for; `Pending` until the first run decides; then `Ready` or `Refused` for good. +pub(in super::super) enum TensorCoreState { + Off, + Pending, + Ready(TensorCoreScan), + Refused, +} + +impl TensorCoreState { + pub(in super::super) fn new(requested: bool) -> Self { + if requested { Self::Pending } else { Self::Off } + } + /// The plan of the scan when this device runs it. + pub(super) fn plan(&self) -> Option { + match self { + Self::Ready(scan) => Some(scan.plan), + _ => None, + } + } +} + +impl<'ctx> OriginalGdnPromptDevice<'ctx> { + /// Decides once, before the first command list of the device is recorded. A device that does not fit the scan + /// (or a module that does not load) keeps the sequential kernel and says so once on stderr; only a context + /// failure is an error. + pub(in super::super) fn prepare_tensor_core(&mut self) -> Result<()> { + if !matches!(self.tensor_core, TensorCoreState::Pending) { + return Ok(()); + } + let guard = self.context.enter()?; + let probed = combine(Self::probe_tensor_core(), guard.finish()); + if probed.is_err() { + self.fail_context(); + } + self.tensor_core = match probed? { + Ok(scan) => { + Self::say_tensor_core_taken(&scan.plan); + TensorCoreState::Ready(scan) + } + Err(why) => { + eprintln!("leleka: LELEKA_PREFILL_GDN_TC=1 requested, the sequential GDN recurrence stays: {why}"); + TensorCoreState::Refused + } + }; + Ok(()) + } + fn say_tensor_core_taken(plan: &tc::ScanPlan) { + eprintln!( + "leleka: LELEKA_PREFILL_GDN_TC=1 (EXPERIMENTAL, LOSSY): the prompt GDN recurrence of runs of {} tokens \ + and more runs on the tensor cores ({} value tile(s) a head, {} chunks of {} tokens a super-block)", + tc::MIN_TOKENS, + plan.tiles(), + plan.chunks(), + tc::CHUNK_TOKENS + ); + } + /// Loads the module and reads the device (the context is current). `Err(reason)` inside is a refusal, not a + /// failure. + fn probe_tensor_core() -> Result> { + if let Err(e) = tc::admit() { + return Ok(Err(format!("the sealed PTX does not match its pin ({e:?})"))); + } + let module = match KernelModule::load(tc::PTX, tc::ENTRIES) { + Ok(m) => m, + Err(e) => return Ok(Err(format!("the module does not load on this device ({e:?})"))), + }; + let geometry = module.device_geometry()?; + Ok(match tc::plan(true, geometry, SCRATCH) { + Ok(plan) => Ok(TensorCoreScan { module, plan }), + Err(refusal) => { + module.close()?; + Err(refusal.to_string()) + } + }) + } + /// Closes the scan's module (the owner's `close_inner`). + pub(in super::super) fn release_tensor_core(&mut self) -> Result<()> { + match std::mem::replace(&mut self.tensor_core, TensorCoreState::Refused) { + TensorCoreState::Ready(scan) => self.release_stage(scan.module), + _ => Ok(()), + } + } + /// One command of the scan on the batch stream: `(entry, grid, block, dynamic shared bytes)`. + pub(in super::super) fn launch_tensor_core( + &self, + blas: &crate::ple_batch_ffi::Blas, + (entry, grid, block, smem): (usize, u32, u32, u32), + args: &mut KernelArguments, + ) -> Result<()> { + let TensorCoreState::Ready(scan) = &self.tensor_core else { return Err(Error::ContextPoisoned) }; + scan.module.launch_dynamic(entry, LinearLaunch::new(grid, block, blas.stream()), smem, args) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn the_scan_is_off_unless_the_options_ask_for_it() { + assert!(!GdnPromptOptions::default().tensor_core_scan); + assert!(matches!(TensorCoreState::new(false), TensorCoreState::Off)); + assert!(matches!(TensorCoreState::new(true), TensorCoreState::Pending)); + for state in [TensorCoreState::Off, TensorCoreState::Pending, TensorCoreState::Refused] { + assert!(state.plan().is_none(), "only a Ready scan has a plan"); + } + } +} diff --git a/crates/cuda-driver/src/lib.rs b/crates/cuda-driver/src/lib.rs index 79ef106f..fa0d800c 100644 --- a/crates/cuda-driver/src/lib.rs +++ b/crates/cuda-driver/src/lib.rs @@ -33,7 +33,7 @@ use std::{ pub(crate) use leleka_cuda_model::bringup_trace_enabled; pub use leleka_cuda_model::{ command_profile, device_arena, host_profile, mmq_original_prefill_misc, native_flash_attn, - original_prefill_schedule, qsa_prompt_attention_select, s_gemv_legacy, + original_prefill_schedule, qsa_prompt_attention_select, ring_prefetch, s_gemv_legacy, }; use leleka_cuda_model::{original_expert_slots, original_mtp_loader, serving_context}; @@ -59,6 +59,8 @@ mod original_gpu_schedule; mod original_moe_prompt_device; mod original_prefill_arena; mod original_prefill_layout; +#[cfg_attr(not(feature = "cuda-driver"), allow(dead_code))] +mod owner_loan; mod routed_group_workspace; mod routed_stage_finite_guard; pub mod vram_ledger; @@ -157,6 +159,12 @@ mod grouped_down_columns_gpu; #[allow(unsafe_code)] mod api; mod async_owned_copy; +// The lent-slot refill's batched copies (`LELEKA_REFILL_BATCH`): the call plan (pure) and its issue. +mod refill_batch_copy; +pub use refill_batch_copy::RefillBatchReport; +#[cfg(all(test, feature = "cuda-driver", any(target_os = "linux", target_os = "windows"), target_pointer_width = "64"))] +#[path = "refill_batch_copy_gpu.rs"] +mod refill_batch_copy_gpu; // Explicit experimental resident pipeline; original entry bodies remain unchanged. mod routed_resident_queue; @@ -183,6 +191,9 @@ mod qsa_index_ffi; mod qsa_prompt_index; // Genuine page4 INT8 owners and literal Original prompt/decode programs. +#[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] +#[allow(unsafe_code)] +mod exact_fill; #[cfg(all(test, any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] mod kv_stream_gpu; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] @@ -216,6 +227,7 @@ mod sealed_ptx; #[cfg(feature = "sm86")] mod sm86_table; +mod gdn_prefill_tc; mod launch_ex; mod native_prompt_device; mod prefill_stage; diff --git a/crates/cuda-driver/src/mmq_original_group.rs b/crates/cuda-driver/src/mmq_original_group.rs index d5f78e87..25c36ec1 100644 --- a/crates/cuda-driver/src/mmq_original_group.rs +++ b/crates/cuda-driver/src/mmq_original_group.rs @@ -124,7 +124,7 @@ pub struct OriginalMmqOutput<'lease, 'layer, 'ctx> { mod copy_ring; use copy_ring::GatherDest; pub(crate) use copy_ring::prefetch_point; -pub use copy_ring::{OriginalMmqCopySchedule, RingExperts}; +pub use copy_ring::{OriginalMmqCopySchedule, PrefetchSource, PrefetchTarget, RingExperts}; // Closed global issuer consumer. Old per-layer/synchronous producers unchanged. #[path = "mmq_original_stream_all.rs"] diff --git a/crates/cuda-driver/src/mmq_original_group/copy_ring_layer.rs b/crates/cuda-driver/src/mmq_original_group/copy_ring_layer.rs index 8fb57980..8a16ae5a 100644 --- a/crates/cuda-driver/src/mmq_original_group/copy_ring_layer.rs +++ b/crates/cuda-driver/src/mmq_original_group/copy_ring_layer.rs @@ -14,11 +14,18 @@ impl<'layer, 'ctx> OriginalMmqLayer<'layer, 'ctx> { experts: RingExperts<'_, 'ctx>, ) -> Result<()> { let (formats, sources) = (experts.formats, experts.sources); - self.copy_ring_preflight(read, sources.len())?; + if let Err(e) = self.copy_ring_preflight(read, sources.len()) { + schedule.trace_refusal(experts.layer, "layer.preflight", (sources.len(), (0, 0, 0, self.counts.len())), &e); + return Err(e); + } let groups = self.counts.len().div_ceil(16); + let init_span = crate::host_profile::span("ring.init"); let mut ring = copy_ring::Ring::new(self.workspace.context, read, schedule, experts, groups)?; + drop(init_span); let operation = self.stream_through_ring(&mut ring, read, formats, sources.len()); + let close_span = crate::host_profile::span("ring.close"); let close = ring.close(); + drop(close_span); if operation.is_err() || close.is_err() { // A failed layer cannot masquerade as a completed output or resume midway. // Numeric refusal does not poison Context; caller must discard this lease. @@ -69,23 +76,33 @@ impl<'layer, 'ctx> OriginalMmqLayer<'layer, 'ctx> { let lookahead = stages - 1; let mut staged = 0usize; for j in 0..sources { + let stage_span = crate::host_profile::span("ring.stage"); Self::ring_stage_ahead(ring, formats, (&mut staged, j + lookahead, sources))?; + drop(stage_span); + let gather_span = crate::host_profile::span("ring.gather"); self.ring_gather(ring, j, formats)?; + drop(gather_span); if self.staged < 16 && j + 1 < sources { continue; } + let enqueue_span = crate::host_profile::span("ring.enqueue"); self.ring_enqueue_group(ring, formats)?; + drop(enqueue_span); } - Self::check_ring_statuses(ring.finish_statuses()?) + let statuses_span = crate::host_profile::span("ring.finish_statuses"); + let statuses = ring.finish_statuses()?; + drop(statuses_span); + Self::check_ring_statuses(statuses) } - /// Stages experts up to `limit` (the literal STAGE-1 lookahead) that are not yet staged. + /// Stages experts up to `limit` (the literal STAGE-1 lookahead) that are not yet staged. With prefetched slots + /// reserved in the ring (`LELEKA_PREFILL_RING_PREFETCH`) a copy that has no free slot yet waits for a later gather. fn ring_stage_ahead( ring: &mut copy_ring::Ring<'_, 'ctx>, formats: [MmqFormat; 3], (staged, limit, sources): (&mut usize, usize, usize), ) -> Result<()> { - while *staged < sources && *staged <= limit { + while *staged < sources && *staged <= limit && ring.stage_room(*staged) { ring.stage_one(*staged, formats)?; *staged += 1; } diff --git a/crates/cuda-driver/src/mmq_original_ring.rs b/crates/cuda-driver/src/mmq_original_ring.rs index efb768b3..9e1b1573 100644 --- a/crates/cuda-driver/src/mmq_original_ring.rs +++ b/crates/cuda-driver/src/mmq_original_ring.rs @@ -45,8 +45,8 @@ trait RingArena: GroupArena { struct Slot { span: ffi::BufferHandle, bytes: usize, - live: bool, - gathered: bool, + /// filled / read / held for a prefetched source until its gather (`LELEKA_PREFILL_RING_PREFETCH`) + state: crate::ring_prefetch::SlotState, } struct Events<'ctx> { copied: Option>, @@ -89,6 +89,9 @@ pub struct OriginalMmqCopySchedule<'ctx> { /// The per-layer status words, kept between layers: a cuMemFree per layer would synchronize the whole device /// (the copy stream included) and wait for every queued expert copy. `(bytes, buffer)`. status_pool: Option<(usize, DeviceBuffer<'ctx>)>, + /// EXPERIMENTAL ring prefetch (`LELEKA_PREFILL_RING_PREFETCH`, off by default): the policy, the per-layer miss + /// history and the experts copied ahead for the next layer's ring. + prefetch: RingPrefetch<'ctx>, } struct Source<'read> { spans: &'read [ResidentExpertBankSpan; 3], @@ -101,6 +104,8 @@ struct Source<'read> { /// slot offsets of gate, up and down after a page-aligned copy (claude/ledger); `None`: the literal blob layout 0, /// gu, 2*gu dest: Option<[usize; 3]>, + /// the expert was prefetched into `slot` before the router ran: no stage copy + prefetched: bool, } /// Private owner: no external pointer/ready event can manufacture a stage. /// The actual source Rc prevents unregister/free during H2D or gathered use. @@ -121,6 +126,8 @@ pub(super) struct Ring<'read, 'ctx> { streamed: bool, layer: u8, stage_done: usize, + /// slots still reserved for a prefetched expert (0 without the prefetch: the literal ring) + reserved: usize, submitted: bool, drained: bool, closed: bool, @@ -147,3 +154,7 @@ mod original_mmq_copy_schedule_drop; mod ring; #[path = "mmq_original_ring/ring_drop.rs"] mod ring_drop; +#[path = "mmq_original_ring/ring_prefetch_issue.rs"] +mod ring_prefetch_issue; +use ring_prefetch_issue::RingPrefetch; +pub use ring_prefetch_issue::{PrefetchSource, PrefetchTarget}; diff --git a/crates/cuda-driver/src/mmq_original_ring/original_mmq_copy_schedule.rs b/crates/cuda-driver/src/mmq_original_ring/original_mmq_copy_schedule.rs index 71346433..318592f0 100644 --- a/crates/cuda-driver/src/mmq_original_ring/original_mmq_copy_schedule.rs +++ b/crates/cuda-driver/src/mmq_original_ring/original_mmq_copy_schedule.rs @@ -65,6 +65,8 @@ impl<'ctx> OriginalMmqCopySchedule<'ctx> { bytes_per_second: f64, ) -> Result<()> { use crate::ffi::original_stager::Api as StagerApi; + // the stream owns the stage slots from here: a ring prefetch no ring took is drained and dropped + self.cancel_ring_prefetch()?; self.stream_admit(read, bank, first)?; let lease = read.lease(); let ring = lease.copy_ring_slots()?; @@ -80,9 +82,15 @@ impl<'ctx> OriginalMmqCopySchedule<'ctx> { self.stream_launch(api, bank, StreamPlan { first, ring, entries, targets }, events) } /// End the chunk's expert stream: stop and join the issuer, drain the copy and compute streams, release the - /// raw events. Idempotent; a failure poisons the schedule. + /// raw events. Idempotent; a failure poisons the schedule. A ring prefetch no ring took is dropped first (its + /// copies drained), so no copy outlives the chunk's row lease. pub fn end_prompt_stream(&mut self) -> Result<()> { - let Some(mut stream) = self.stream.take() else { return Ok(()) }; + let cancelled = self.cancel_ring_prefetch(); + let Some(stream) = self.stream.take() else { return cancelled }; + combine(cancelled, self.end_stream(stream)) + } + + fn end_stream(&mut self, mut stream: ChunkStream) -> Result<()> { let stopped = stream.stop(); let copy = self.copy.as_ref().map_or(Ok(()), OriginalGpuStream::synchronize); let compute = self.compute.as_ref().map_or(Ok(()), OriginalGpuStream::synchronize); diff --git a/crates/cuda-driver/src/mmq_original_ring/ring.rs b/crates/cuda-driver/src/mmq_original_ring/ring.rs index 74dd525a..6217e4f3 100644 --- a/crates/cuda-driver/src/mmq_original_ring/ring.rs +++ b/crates/cuda-driver/src/mmq_original_ring/ring.rs @@ -8,6 +8,9 @@ mod ring_construction; #[path = "ring/ring_gather_and_finish.rs"] mod ring_gather_and_finish; mod ring_init; +#[path = "ring/ring_prefetch.rs"] +mod ring_prefetch; +pub(super) use ring_prefetch::profile_prefetch; #[path = "ring/ring_stage_expert_copies.rs"] mod ring_stage_expert_copies; -use ring_init::RingPlan; +pub(super) use ring_init::RingPlan; diff --git a/crates/cuda-driver/src/mmq_original_ring/ring/ring_construction.rs b/crates/cuda-driver/src/mmq_original_ring/ring/ring_construction.rs index fb92884f..f9011351 100644 --- a/crates/cuda-driver/src/mmq_original_ring/ring/ring_construction.rs +++ b/crates/cuda-driver/src/mmq_original_ring/ring/ring_construction.rs @@ -3,6 +3,31 @@ #[allow(unused_imports)] use super::*; +/// Whether a schedule that owns `schedule_slots` slot events serves an arena ring of `arena_slots` slots. The +/// schedule is opened once with the full prompt layout's ring (384 slots). A smaller arena of the prompt loan ladder +/// (the 512-row rung carves the literal 8-slot ring below `stream_all_min`) uses the first `arena_slots` events: slot +/// `i` is `i % arena_slots`, so the surplus events stay idle. A schedule with fewer events than the ring needs is +/// refused. +fn schedule_serves_ring(schedule_slots: usize, arena_slots: usize) -> bool { + arena_slots <= schedule_slots +} + +#[cfg(test)] +mod schedule_tests { + use super::schedule_serves_ring; + + #[test] + fn a_smaller_ring_uses_the_first_events_of_a_larger_schedule() { + assert!(schedule_serves_ring(384, 384)); + assert!(schedule_serves_ring(384, 8)); + } + + #[test] + fn a_schedule_with_fewer_events_than_the_ring_is_refused() { + assert!(!schedule_serves_ring(8, 384)); + } +} + impl<'read, 'ctx> Ring<'read, 'ctx> { pub(in super::super::super) fn new( context: &'ctx Context<'ctx>, @@ -12,14 +37,13 @@ impl<'read, 'ctx> Ring<'read, 'ctx> { groups: usize, ) -> Result { let RingExperts { layer, bank, formats, sources: spans } = experts; - Self::validate_new(context, read, &bank, (layer, groups, spans.len()), &formats)?; - let (gu, down, blob) = Self::blob_geometry(&formats)?; - let admitted: &dyn RingArena = read; - let count = admitted.stage_slots()?; - schedule.validate_context(context)?; - if schedule.ring_slots() != count { - return Err(Error::InvalidProjectionShape); + let shape = (layer, groups, spans.len()); + if let Err(e) = Self::validate_new(context, read, &bank, shape, &formats) { + schedule.trace_refusal(layer, "new.validate", (spans.len(), (0, 0, 0, spans.len())), &e); + return Err(e); } + let (gu, down, blob) = Self::blob_geometry(&formats)?; + let count = Self::admitted_slots(context, read, schedule, layer)?; let mut owner = Self::empty(context, read, bank, schedule, layer); let plan = RingPlan { layer, groups, formats, gu, down, blob, count }; if let Err(primary) = owner.init(spans, &plan) { @@ -27,4 +51,22 @@ impl<'read, 'ctx> Ring<'read, 'ctx> { } Ok(owner) } + + /// The arena's stage slot count, refused when the schedule has fewer slot events. + fn admitted_slots( + context: &'ctx Context<'ctx>, + read: &crate::OriginalDeviceGrRead<'_, '_, 'ctx>, + schedule: &OriginalMmqCopySchedule<'ctx>, + layer: usize, + ) -> Result { + let admitted: &dyn RingArena = read; + let count = admitted.stage_slots()?; + schedule.validate_context(context)?; + if !schedule_serves_ring(schedule.ring_slots(), count) { + let e = Error::InvalidProjectionShape; + schedule.trace_refusal(layer, "new.schedule_slots", (schedule.ring_slots(), (0, 0, count, 0)), &e); + return Err(e); + } + Ok(count) + } } diff --git a/crates/cuda-driver/src/mmq_original_ring/ring/ring_gather_and_finish.rs b/crates/cuda-driver/src/mmq_original_ring/ring/ring_gather_and_finish.rs index a8e6439d..25eaa30a 100644 --- a/crates/cuda-driver/src/mmq_original_ring/ring/ring_gather_and_finish.rs +++ b/crates/cuda-driver/src/mmq_original_ring/ring/ring_gather_and_finish.rs @@ -2,6 +2,7 @@ #[allow(unused_imports)] use super::*; +use crate::ring_prefetch::RingRefusal; impl<'read, 'ctx> Ring<'read, 'ctx> { pub(in super::super::super) fn gather( @@ -12,7 +13,10 @@ impl<'read, 'ctx> Ring<'read, 'ctx> { dest: GatherDest, ) -> Result<()> { let GatherDest { gate_up, down_out } = dest; - let source = self.sources.get(index).ok_or(Error::InvalidProjectionShape)?; + let source = self + .sources + .get(index) + .ok_or_else(|| self.traced("gather.no_source", index, Error::InvalidProjectionShape))?; let gu = formats[0].layout(1)?.raw_weight; let down = formats[2].layout(1)?.raw_weight; let (sl, entry, dest, resident) = (source.slot, source.entry, source.dest, source.resident); @@ -21,7 +25,7 @@ impl<'read, 'ctx> Ring<'read, 'ctx> { } else if let Some(k) = entry { self.gather_streamed(k, (gu, down))? } else { - self.gather_slot(sl, dest, (gu, down))? + self.gather_slot(sl, dest, (gu, down)).map_err(|e| self.traced("gather.slot", index, e))? }; Self::check_gather_destination(raw, (gate_up, down_out), (gu, down))?; self.enqueue(Command::Gather( @@ -51,12 +55,12 @@ impl<'read, 'ctx> Ring<'read, 'ctx> { dest: Option<[usize; 3]>, (gu, down): (usize, usize), ) -> Result<[ffi::BufferHandle; 3]> { - let sl = sl.ok_or(Error::InvalidProjectionShape)?; - let slot = &mut self.slots[sl]; - let events = &mut self.schedule.events[sl]; - if !slot.live || slot.gathered { - return Err(Error::InvalidProjectionShape); + let sl = sl.ok_or_else(|| self.refuse(RingRefusal::GatherNoSlot, usize::MAX))?; + if let Err(refusal) = self.slots[sl].state.check_gather() { + return Err(self.refuse(refusal, sl)); } + let slot = &self.slots[sl]; + let events = &mut self.schedule.events[sl]; events .copied .as_mut() @@ -104,7 +108,9 @@ impl<'read, 'ctx> Ring<'read, 'ctx> { .as_mut() .ok_or(Error::ContextPoisoned)? .record(self.schedule.compute.as_ref().ok_or(Error::ContextPoisoned)?)?; - slot.gathered = true; + if slot.state.gathered() { + self.reserved -= 1; + } } Ok(()) } diff --git a/crates/cuda-driver/src/mmq_original_ring/ring/ring_prefetch.rs b/crates/cuda-driver/src/mmq_original_ring/ring/ring_prefetch.rs new file mode 100644 index 00000000..5d852281 --- /dev/null +++ b/crates/cuda-driver/src/mmq_original_ring/ring/ring_prefetch.rs @@ -0,0 +1,174 @@ +//! The copy ring's side of the EXPERIMENTAL prefetch (`LELEKA_PREFILL_RING_PREFETCH`, +//! docs/experiments/ring-prefetch.md): one prefetch copy into a stage slot, the miss history a ring feeds, and the +//! adoption of the prefetched set when the router result is known. A prefetched expert is read by the same gather from +//! the same bytes; only the time of its copy changes. + +use super::super::ring_prefetch_issue::{PendingPrefetch, PrefetchEntry}; +#[allow(unused_imports)] +use super::*; +use crate::ring_prefetch::{self, ExpertMask, RingRefusal, SlotState, mask_set, match_prefetch}; + +/// `(address, length)` of the gate, up and down host ranges: the identity of the bytes a copy moved. +pub(in super::super) type Pieces = [(usize, usize); 3]; + +impl<'read, 'ctx> Ring<'read, 'ctx> { + /// The host ranges of an expert as addresses, compared between the prefetch and the routed source. + pub(in super::super) fn piece_ids( + bank: &crate::MappedExpertBank<'ctx>, + spans: &[ResidentExpertBankSpan; 3], + ) -> Result { + Ok(Self::source_pieces(bank, spans)?.map(|p| (p.as_ptr() as usize, p.len()))) + } + + /// Copies one expert into stage slot `slot` (span `span`) on the schedule's copy stream exactly as `stage_one` does + /// and records the slot's `copied` event. The spans are checked like a routed source's first. + pub(in super::super) fn prefetch_into_slot( + schedule: &mut OriginalMmqCopySchedule<'ctx>, + bank: &crate::MappedExpertBank<'ctx>, + spans: &[ResidentExpertBankSpan; 3], + (slot, span): (usize, (ffi::BufferHandle, usize)), + plan: &RingPlan, + ) -> Result { + Self::check_source_spans(bank, spans, true, plan)?; + let target = Slot { span: span.0, bytes: span.1, state: Default::default() }; + if target.bytes < plan.blob { + return Err(Error::InvalidSize); + } + let dest = Self::prefetch_copy(schedule, bank, spans, &target, plan)?; + let copy = schedule.copy.as_mut().ok_or(Error::ContextPoisoned)?; + let events = schedule.events.get_mut(slot).ok_or(Error::InvalidProjectionShape)?; + events.copied.as_mut().ok_or(Error::ContextPoisoned)?.record(copy)?; + let expert = spans[0].expert(); + Ok(PrefetchEntry { expert, slot, span, pieces: Self::piece_ids(bank, spans)?, dest }) + } + + /// The page-aligned supersets side by side when they fit, else the exact pieces (`stage_copy_pieces`). + fn prefetch_copy( + schedule: &mut OriginalMmqCopySchedule<'ctx>, + bank: &crate::MappedExpertBank<'ctx>, + spans: &[ResidentExpertBankSpan; 3], + slot: &Slot, + plan: &RingPlan, + ) -> Result> { + let api = schedule.api.as_ref().ok_or(Error::ContextPoisoned)?; + let copy = schedule.copy.as_mut().ok_or(Error::ContextPoisoned)?; + if let Some(parts) = Self::aligned_parts(bank, spans, slot.bytes)? { + Self::copy_aligned(copy, api, slot, &parts)?; + return Ok(Some([parts[0].2 + parts[0].1, parts[1].2 + parts[1].1, parts[2].2 + parts[2].1])); + } + let operands = Self::exact_operands(bank, slot, spans, (plan.gu, plan.down))?; + Self::copy_exact(copy, api, bank, operands)?; + Ok(None) + } + + /// With the prefetch on, this layer's missed set (routed and not resident) joins the layer's history. + pub(super) fn record_ring_misses(&mut self, plan: &RingPlan) { + let Some(history) = self.schedule.prefetch.history.as_mut() else { return }; + let mut missed: ExpertMask = [0; 8]; + for source in self.sources.iter().filter(|s| s.resident.is_none()) { + mask_set(&mut missed, source.spans[0].expert() as usize); + } + history.record(plan.layer, missed); + } + + /// Takes the schedule's prefetched set: a routed, non-resident source whose bytes a prefetch copied is read from + /// that slot (reserved until its gather); every other prefetched slot stays free. A set issued for another layer, + /// bank or arena is dropped once its copies are drained. + pub(super) fn adopt_prefetch(&mut self, plan: &RingPlan) -> Result<()> { + let Some(pending) = self.schedule.take_ring_prefetch() else { return Ok(()) }; + // the ring's drain also covers the prefetch copies, whatever happens below + self.submitted = true; + self.drained = false; + if !self.prefetch_usable(&pending, plan) { + let (layer, n) = (pending.layer, pending.entries.len()); + self.schedule.trace_prefetch(format_args!("layer={} dropped={n} issued_for={layer}", plan.layer)); + profile_prefetch("ring.prefetch_wasted", pending.entries.len(), plan.blob); + return self.schedule.drain_dropped_prefetch(pending); + } + let experts: Vec = pending.entries.iter().map(|e| e.expert).collect(); + let needs: Vec> = self + .sources + .iter() + .map(|s| (s.resident.is_none() && s.job.is_none()).then(|| s.spans[0].expert())) + .collect(); + let matched = match_prefetch(&experts, &needs); + let mut hits = 0; + for (source, entry) in matched.hits { + hits += usize::from(self.consume_prefetched(source, &pending.entries[entry])?); + } + let wasted = pending.entries.len() - hits; + self.schedule.trace_prefetch(format_args!("layer={} hits={hits} wasted={wasted}", plan.layer)); + profile_prefetch("ring.prefetch_hit", hits, plan.blob); + profile_prefetch("ring.prefetch_wasted", wasted, plan.blob); + Ok(()) + } + + /// Whether the set was issued for this layer, from this ring's bank, into this arena's slots, with no chunk stream. + fn prefetch_usable(&self, pending: &PendingPrefetch<'ctx>, plan: &RingPlan) -> bool { + let same_bank = self.bank.as_ref().is_some_and(|b| Rc::ptr_eq(b, &pending.bank)); + let same_slots = pending.entries.iter().all(|e| { + self.slots.get(e.slot).is_some_and(|s| (s.span, s.bytes) == e.span && s.state == SlotState::default()) + }); + pending.layer == plan.layer + && pending.blob == plan.blob + && same_bank + && same_slots + && self.schedule.stream.is_none() + } + + /// Source `source` reads the prefetched slot when the copied bytes are its own; returns whether it does. + fn consume_prefetched(&mut self, source: usize, entry: &PrefetchEntry) -> Result { + let bank = self.bank.as_ref().ok_or(Error::ContextPoisoned)?; + if Self::piece_ids(bank, self.sources[source].spans)? != entry.pieces { + return Ok(false); + } + let slot = &mut self.slots[entry.slot]; + slot.state = SlotState::PREFETCHED; + self.reserved += 1; + let source = &mut self.sources[source]; + (source.slot, source.dest, source.prefetched) = (Some(entry.slot), entry.dest, true); + Ok(true) + } + + /// Whether `stage_one` copies source `index` (`Ok(false)`: resident, a chunk-stream entry or prefetched). + pub(super) fn stage_needed(&self, index: usize) -> std::result::Result { + let source = &self.sources[index]; + let no_copy = source.resident.is_some() || source.entry.is_some(); + ring_prefetch::stage_needed(no_copy, source.prefetched, source.slot.is_some()) + } + + /// The slot `stage_one` copies into: the next one in ring order no prefetched source holds (`stage_next` itself + /// without a prefetch), refused when it still holds an unread copy. + pub(super) fn stage_target(&self) -> std::result::Result { + ring_prefetch::stage_target(self.slots.len(), self.stage_next, |s| self.slots[s].state) + } + + /// Whether source `index` can be staged now: it needs no copy, or some unreserved slot is free. Always true for the + /// literal ring (no prefetch adopted); after a prefetch, a copy waits for a gather when every unreserved slot still + /// holds an unread copy (also once every hit was gathered: the slot order no longer follows the gather order). + pub(in super::super::super) fn stage_room(&self, index: usize) -> bool { + if index >= self.sources.len() { + return true; + } + !matches!(self.stage_needed(index), Ok(true)) || self.stage_target().is_ok() + } + + /// The error of a refused ring check (`InvalidProjectionShape`); with the driver error trace on, a `RING-REFUSE` + /// line names the check, the layer, the source and the slot bookkeeping. + pub(in super::super::super) fn refuse(&self, refusal: RingRefusal, index: usize) -> Error { + self.traced(refusal.check(), index, Error::InvalidProjectionShape) + } + + /// `error`, traced under the check name `check` when the driver error trace is on. + pub(in super::super::super) fn traced(&self, check: &'static str, index: usize, error: Error) -> Error { + let state = (self.stage_next, self.reserved, self.slots.len(), self.sources.len()); + self.schedule.trace_refusal(usize::from(self.layer), check, (index, state), &error); + error + } +} +/// `LELEKA_SERVE_PROFILE`: one call of `name` per expert, its MB as the value. +pub(in super::super) fn profile_prefetch(name: &'static str, experts: usize, blob: usize) { + for _ in 0..experts { + crate::host_profile::add(name, blob as f64 / 1e6); + } +} diff --git a/crates/cuda-driver/src/mmq_original_ring/ring/ring_stage_expert_copies.rs b/crates/cuda-driver/src/mmq_original_ring/ring/ring_stage_expert_copies.rs index 61977bee..c9d54825 100644 --- a/crates/cuda-driver/src/mmq_original_ring/ring/ring_stage_expert_copies.rs +++ b/crates/cuda-driver/src/mmq_original_ring/ring/ring_stage_expert_copies.rs @@ -15,7 +15,11 @@ impl<'read, 'ctx> Ring<'read, 'ctx> { } pub(in super::super::super) fn enqueue(&mut self, command: Command) -> Result<()> { if self.closed || self.commands.len() == COMMAND_CAP || !self.read.matches_context(self.context) { - return Err(Error::InvalidProjectionShape); + return Err(self.traced( + "enqueue.closed_full_or_context", + self.commands.len(), + Error::InvalidProjectionShape, + )); } self.commands.push(command); self.submitted = true; @@ -45,31 +49,29 @@ impl<'read, 'ctx> Ring<'read, 'ctx> { ) } pub(in super::super::super) fn stage_one(&mut self, index: usize, formats: [MmqFormat; 3]) -> Result<()> { - let source = self.sources.get(index).ok_or(Error::InvalidProjectionShape)?; - if source.resident.is_some() || source.entry.is_some() { + if index >= self.sources.len() { + return Err(self.traced("stage.no_source", index, Error::InvalidProjectionShape)); + } + if !self.stage_needed(index).map_err(|r| self.refuse(r, index))? { return Ok(()); } - if source.slot.is_some() { - return Err(Error::InvalidProjectionShape); - } - let sl = self.stage_next; + let sl = self.stage_target().map_err(|r| self.refuse(r, index))?; let next = (sl + 1) % self.slots.len(); self.stage_wait_slot(sl)?; let new_dest = self.stage_copy(index, sl, formats)?; + profile_copied(formats)?; self.stage_record(index, sl, new_dest)?; self.stage_next = next; Ok(()) } - /// A live slot is reused only after its gather; the copy stream waits the previous gather. + /// A live slot is reused only after its gather (`stage_target` refused an ungathered one); the copy stream waits + /// the previous gather. fn stage_wait_slot(&mut self, sl: usize) -> Result<()> { let slot = &self.slots[sl]; let events = &mut self.schedule.events[sl]; let copy = self.schedule.copy.as_mut().ok_or(Error::ContextPoisoned)?; - if slot.live { - if !slot.gathered { - return Err(Error::InvalidProjectionShape); - } + if slot.state.live { // Re-recorded copied and used events have the same real source // streams; the copy stream waits the previous gather before reuse. events.used.as_mut().ok_or(Error::ContextPoisoned)?.wait_on(copy)?; @@ -149,7 +151,7 @@ impl<'read, 'ctx> Ring<'read, 'ctx> { /// `(superset, lead, offset)` of the three pieces side by side at page offsets, when they fit `slot_bytes`. #[allow(clippy::type_complexity)] - fn aligned_parts<'b>( + pub(super) fn aligned_parts<'b>( bank: &'b crate::MappedExpertBank<'ctx>, spans: &[ResidentExpertBankSpan; 3], slot_bytes: usize, @@ -167,7 +169,7 @@ impl<'read, 'ctx> Ring<'read, 'ctx> { Ok((off <= slot_bytes).then_some(parts)) } - fn copy_aligned( + pub(super) fn copy_aligned( copy: &mut OriginalGpuStream<'ctx>, api: &Api, slot: &Slot, @@ -183,7 +185,7 @@ impl<'read, 'ctx> Ring<'read, 'ctx> { /// The exact gate, up and down host ranges and their destinations back to back in the slot. #[allow(clippy::type_complexity)] - fn exact_operands<'b>( + pub(super) fn exact_operands<'b>( bank: &'b crate::MappedExpertBank<'ctx>, slot: &Slot, spans: &[ResidentExpertBankSpan; 3], @@ -198,7 +200,7 @@ impl<'read, 'ctx> Ring<'read, 'ctx> { Ok((sources, destinations)) } - fn copy_exact( + pub(super) fn copy_exact( copy: &mut OriginalGpuStream<'ctx>, api: &Api, bank: &crate::MappedExpertBank<'ctx>, @@ -229,10 +231,18 @@ impl<'read, 'ctx> Ring<'read, 'ctx> { if serialize_ring(Drain::Copies) { copy.synchronize()?; } - self.slots[sl].live = true; - self.slots[sl].gathered = false; + self.slots[sl].state.staged(); self.sources[index].slot = Some(sl); self.sources[index].dest = new_dest; Ok(()) } } + +/// `LELEKA_SERVE_PROFILE`: the count of experts copied over PCIe (the call count of `ring.copied_mb`) and their MB. +fn profile_copied(formats: [MmqFormat; 3]) -> Result<()> { + if crate::host_profile::enabled() { + let blob = formats[0].layout(1)?.raw_weight * 2 + formats[2].layout(1)?.raw_weight; + crate::host_profile::add("ring.copied_mb", blob as f64 / 1e6); + } + Ok(()) +} diff --git a/crates/cuda-driver/src/mmq_original_ring/ring_init.rs b/crates/cuda-driver/src/mmq_original_ring/ring_init.rs index fcbd5832..8399377b 100644 --- a/crates/cuda-driver/src/mmq_original_ring/ring_init.rs +++ b/crates/cuda-driver/src/mmq_original_ring/ring_init.rs @@ -5,18 +5,18 @@ use super::*; /// Layer-wide numbers every construction phase needs. -pub(super) struct RingPlan { - pub(super) layer: usize, - pub(super) groups: usize, - pub(super) formats: [MmqFormat; 3], +pub(in super::super) struct RingPlan { + pub(in super::super) layer: usize, + pub(in super::super) groups: usize, + pub(in super::super) formats: [MmqFormat; 3], /// raw bytes of one gate or up matrix - pub(super) gu: usize, + pub(in super::super) gu: usize, /// raw bytes of one down matrix - pub(super) down: usize, + pub(in super::super) down: usize, /// bytes of one expert blob (gate + up + down) - pub(super) blob: usize, + pub(in super::super) blob: usize, /// number of stage slots of the arena - pub(super) count: usize, + pub(in super::super) count: usize, } impl<'read, 'ctx> Ring<'read, 'ctx> { @@ -44,7 +44,7 @@ impl<'read, 'ctx> Ring<'read, 'ctx> { } /// `(gate/up bytes, down bytes, blob bytes)` of one expert. - pub(super) fn blob_geometry(formats: &[MmqFormat; 3]) -> Result<(usize, usize, usize)> { + pub(in super::super) fn blob_geometry(formats: &[MmqFormat; 3]) -> Result<(usize, usize, usize)> { let gu = formats[0].layout(1)?.raw_weight; let down = formats[2].layout(1)?.raw_weight; let blob = gu.checked_mul(2).and_then(|n| n.checked_add(down)).ok_or(Error::InvalidSize)?; @@ -74,6 +74,7 @@ impl<'read, 'ctx> Ring<'read, 'ctx> { streamed: false, layer: layer as u8, stage_done: 0, + reserved: 0, submitted: false, drained: false, closed: false, @@ -86,6 +87,8 @@ impl<'read, 'ctx> Ring<'read, 'ctx> { self.check_metadata_budget()?; self.admit_slots(plan)?; self.admit_sources(spans, plan)?; + self.record_ring_misses(plan); + self.adopt_prefetch(plan)?; self.attach_stream(plan)?; let jobs = self.plan_host_jobs(plan)?; self.admit_status(plan)?; @@ -95,7 +98,9 @@ impl<'read, 'ctx> Ring<'read, 'ctx> { fn start_jobs(&mut self, jobs: Vec, plan: &RingPlan) -> Result<()> { // The old input quantization/metadata upload used default stream. // Admit that dependency once before starting nonblocking producers. + let sync_span = crate::host_profile::span("ring.init_sync"); self.context.synchronize()?; + drop(sync_span); if !jobs.is_empty() { self.start_host_stage(jobs, plan)?; } @@ -145,7 +150,7 @@ impl<'read, 'ctx> Ring<'read, 'ctx> { return Err(Error::OutputAliasesInput); } } - self.slots.push(Slot { span: h, bytes: n, live: false, gathered: false }); + self.slots.push(Slot { span: h, bytes: n, state: Default::default() }); } Ok(()) } @@ -154,14 +159,15 @@ impl<'read, 'ctx> Ring<'read, 'ctx> { let bank = self.bank.as_ref().ok_or(Error::ContextPoisoned)?; for (i, spans) in spans.iter().enumerate() { let ordered = i == 0 || spans[0].expert() > self.sources[i - 1].spans[0].expert(); - Self::check_source_spans(bank, spans, ordered, plan)?; + Self::check_source_spans(bank, spans, ordered, plan).map_err(|e| self.traced("sources.spans", i, e))?; let resident = self.resident_blob(spans[0].expert() as usize, plan)?; - self.sources.push(Source { spans, resident, slot: None, job: None, entry: None, dest: None }); + let source = Source { spans, resident, slot: None, job: None, entry: None, dest: None, prefetched: false }; + self.sources.push(source); } Ok(()) } - fn check_source_spans( + pub(super) fn check_source_spans( bank: &crate::MappedExpertBank<'ctx>, spans: &[ResidentExpertBankSpan; 3], ordered: bool, @@ -202,30 +208,39 @@ impl<'read, 'ctx> Ring<'read, 'ctx> { /// With an active chunk stream for this layer, every non-resident expert is the stream's entry. fn attach_stream(&mut self, plan: &RingPlan) -> Result<()> { - let bank = self.bank.as_ref().ok_or(Error::ContextPoisoned)?; - if let Some(stream) = self.schedule.stream.as_ref() { - if !stream.next_layer_is(plan.layer as u8) { - return Err(Error::InvalidProjectionShape); - } - for source in &mut self.sources { - if source.resident.is_some() { - continue; - } - let entry = - stream.entry(plan.layer as u8, source.spans[0].expert()).ok_or(Error::InvalidProjectionShape)?; - // the stream copies exactly the bytes this span names - if !stream.entry_matches(entry, Self::source_pieces(bank, source.spans)?) { - return Err(Error::InvalidProjectionShape); - } - source.entry = Some(entry); - } - self.streamed = true; + let Some(stream) = self.schedule.stream.as_ref() else { return Ok(()) }; + if !stream.next_layer_is(plan.layer as u8) { + return Err(self.traced("stream.layer", 0, Error::InvalidProjectionShape)); } + for index in 0..self.sources.len() { + let entry = self.stream_entry(index, plan).map_err(|(check, e)| self.traced(check, index, e))?; + self.sources[index].entry = entry; + } + self.streamed = true; Ok(()) } + /// The chunk stream's entry of a non-resident source (`None` for a resident one), or the refused check. + fn stream_entry(&self, index: usize, plan: &RingPlan) -> std::result::Result, (&'static str, Error)> { + let source = &self.sources[index]; + if source.resident.is_some() { + return Ok(None); + } + let poisoned = || ("stream.bank", Error::ContextPoisoned); + let bank = self.bank.as_ref().ok_or_else(poisoned)?; + let stream = self.schedule.stream.as_ref().ok_or_else(poisoned)?; + let refused = |check| (check, Error::InvalidProjectionShape); + let entry = stream.entry(plan.layer as u8, source.spans[0].expert()).ok_or(refused("stream.no_entry"))?; + // the stream copies exactly the bytes this span names + let pieces = Self::source_pieces(bank, source.spans).map_err(|e| ("stream.pieces", e))?; + if !stream.entry_matches(entry, pieces) { + return Err(refused("stream.entry_bytes")); + } + Ok(Some(entry)) + } + /// The gate, up and down host ranges of one expert. - fn source_pieces<'b>( + pub(super) fn source_pieces<'b>( bank: &'b crate::MappedExpertBank<'ctx>, spans: &[ResidentExpertBankSpan; 3], ) -> Result<[&'b [u8]; 3]> { diff --git a/crates/cuda-driver/src/mmq_original_ring/ring_prefetch_issue.rs b/crates/cuda-driver/src/mmq_original_ring/ring_prefetch_issue.rs new file mode 100644 index 00000000..e9b97744 --- /dev/null +++ b/crates/cuda-driver/src/mmq_original_ring/ring_prefetch_issue.rs @@ -0,0 +1,252 @@ +//! EXPERIMENTAL prompt copy-ring prefetch (`LELEKA_PREFILL_RING_PREFETCH`, off by default; +//! docs/experiments/ring-prefetch.md): the schedule's half. After a layer's ring has drained, the experts the NEXT +//! layer missed most often in its recent chunks are copied into the next ring's stage slots on the copy stream while +//! the layer's combine and the next mixer run. The next `Ring::new` takes the set (`adopt_prefetch`). The policy comes +//! from the engine's settings; nothing here reads the environment. + +use super::ring::{RingPlan, profile_prefetch}; +#[allow(unused_imports)] +use super::*; +use crate::ring_prefetch::{MissHistory, RingPrefetchPolicy}; + +/// One expert copied ahead into a stage slot. +pub(super) struct PrefetchEntry { + pub(super) expert: u32, + pub(super) slot: usize, + /// the stage slot's `(span, bytes)` at the copy: the adopting ring must see the same arena slot + pub(super) span: (ffi::BufferHandle, usize), + /// `(address, length)` of the copied gate, up and down host ranges + pub(super) pieces: [(usize, usize); 3], + /// the page-aligned lead offsets, as `stage_record` keeps them + pub(super) dest: Option<[usize; 3]>, +} + +/// The experts copied for the next ring of `layer`, with the bank the copies read (held while they may run). +pub(super) struct PendingPrefetch<'ctx> { + pub(super) layer: usize, + pub(super) bank: Rc>, + pub(super) blob: usize, + pub(super) entries: Vec, +} + +/// The policy (none: off), the per-layer miss history and the copied set waiting for its ring. +#[derive(Default)] +pub(super) struct RingPrefetch<'ctx> { + pub(super) policy: Option, + pub(super) history: Option, + pub(super) pending: Option>, + /// the engine's driver error trace (`LELEKA_TRACE_DRIVER_ERRORS` / `LELEKA_BRINGUP_TRACE`): name every refused ring + /// check and every prefetch decision on stderr + pub(super) trace_errors: bool, +} + +/// The bank spans and matrix formats of one predicted expert, as the caller resolved them; `None` skips it. +pub type PrefetchSource = Option<([ResidentExpertBankSpan; 3], [MmqFormat; 3])>; + +/// The ring the prefetch fills: the row lease's read, the registered bank and the layer about to run. +pub struct PrefetchTarget<'a, 'arena, 'loan, 'ctx> { + pub read: &'a crate::OriginalDeviceGrRead<'arena, 'loan, 'ctx>, + pub bank: &'a Rc>, + pub layer: usize, +} + +impl<'ctx> OriginalMmqCopySchedule<'ctx> { + /// Switches the prefetch on (with its policy) or off; the miss history starts empty. + pub fn set_ring_prefetch(&mut self, policy: Option) { + self.prefetch.history = policy.map(|p| MissHistory::new(p.window)); + self.prefetch.policy = policy; + } + + /// The engine's driver error trace: a refused copy-ring check prints a `RING-REFUSE` line naming it, and the + /// prefetch prints its decisions (`RING-PREFETCH`). No environment is read here. + pub fn set_ring_error_trace(&mut self, on: bool) { + self.prefetch.trace_errors = on; + } + + /// With the trace on: `RING-REFUSE layer check source stage_next reserved slots sources error`. + pub(crate) fn trace_refusal( + &self, + layer: usize, + check: &str, + (index, state): (usize, (usize, usize, usize, usize)), + error: &Error, + ) { + if self.prefetch.trace_errors { + let (next, reserved, slots, sources) = state; + let ring = format!("stage_next={next} reserved={reserved} slots={slots} sources={sources}"); + eprintln!("RING-REFUSE layer={layer} check={check} source={index} {ring} error={error:?}"); + } + } + + /// With the trace on: one `RING-PREFETCH` line per decision. + pub(super) fn trace_prefetch(&self, what: std::fmt::Arguments<'_>) { + if self.prefetch.trace_errors { + eprintln!("RING-PREFETCH {what}"); + } + } + + pub fn ring_prefetch(&self) -> Option { + self.prefetch.policy + } + + /// Copies the predicted missing experts of `target.layer` into its ring's stage slots; returns how many. Never + /// fails the caller: a refused or failed prefetch copies less (or nothing) and the ring copies the rest as usual. + pub fn prefetch_ring_layer( + &mut self, + target: PrefetchTarget<'_, '_, '_, 'ctx>, + mut sources: impl FnMut(u32) -> PrefetchSource, + ) -> usize { + if self.prefetch.policy.is_none() || self.cancel_ring_prefetch().is_err() || !self.prefetch_allowed(&target) { + return 0; + } + let _span = crate::host_profile::span("ring.prefetch_issue"); + let issued = self.issue_prefetch(&target, &mut sources); + if let Err(error) = &issued { + // a copy may have been queued for the failed expert: let it land before anything is dropped + crate::host_profile::add("ring.prefetch_failed", 1.0); + self.trace_prefetch(format_args!("layer={} issue failed: {error:?}", target.layer)); + let _ = self.copy.as_ref().map(OriginalGpuStream::synchronize); + } + let count = self.prefetch.pending.as_ref().map_or(0, |p| p.entries.len()); + self.trace_prefetch(format_args!("layer={} issued={count}", target.layer)); + if count == 0 { + self.prefetch.pending = None; + } else { + self.detach_drains(); + } + count + } + + /// `detach_drains` only (EXPERIMENTAL): the mixer's drains stop waiting for the prefetch copies; the next ring's + /// `take_ring_prefetch` restores them. + fn detach_drains(&mut self) { + if !self.prefetch.policy.is_some_and(|p| p.detach_drains) { + return; + } + if let Some(Ok(copy)) = self.copy.as_mut().map(|c| c.with_enqueue(Ok)) { + crate::compute_drain::set_background(copy); + } + } + + /// No chunk stream, a registered (page-locked) bank, a healthy schedule and a layer that exists. + fn prefetch_allowed(&self, target: &PrefetchTarget<'_, '_, '_, 'ctx>) -> bool { + self.stream.is_none() + && !self.is_failed() + && target.layer < 48 + && !target.bank.pageable() + && target.bank.cache_context_matches(self.context) + && target.read.context_matches(self.context) + && !skip_expert_dma() + && crate::compute_drain::background() == 0 + } + + /// Predicts, then copies expert after expert into slots 0, 1, ...; the set is kept as it grows. + fn issue_prefetch( + &mut self, + target: &PrefetchTarget<'_, '_, '_, 'ctx>, + sources: &mut impl FnMut(u32) -> PrefetchSource, + ) -> Result<()> { + let lease = target.read.lease(); + let slots = lease.copy_ring_slots()?.min(self.events.len()); + let policy = self.prefetch.policy.ok_or(Error::ContextPoisoned)?; + let history = self.prefetch.history.as_ref().ok_or(Error::ContextPoisoned)?; + let resident = |e: u32| lease.cache_expert_span(target.layer, e as usize).map_or(true, |s| s.is_some()); + let experts = history.predict(target.layer, policy.budget(slots), resident); + for expert in experts { + let Some((spans, formats)) = sources(expert) else { continue }; + self.prefetch_one(target, &spans, formats)?; + } + Ok(()) + } + + /// Copies one expert into the next free prefetch slot; an expert of another format than the set is skipped. + fn prefetch_one( + &mut self, + target: &PrefetchTarget<'_, '_, '_, 'ctx>, + spans: &[ResidentExpertBankSpan; 3], + formats: [MmqFormat; 3], + ) -> Result<()> { + let plan = Self::prefetch_plan(target.layer, formats)?; + let pending = self.prefetch.pending.get_or_insert_with(|| PendingPrefetch { + layer: target.layer, + bank: Rc::clone(target.bank), + blob: plan.blob, + entries: Vec::new(), + }); + if pending.blob != plan.blob { + return Ok(()); + } + let slot = pending.entries.len(); + let span = target.read.lease().copy_ring_span(slot)?; + Self::check_prefetch_slot(target.read, span, plan.blob)?; + let entry = Ring::prefetch_into_slot(self, target.bank, spans, (slot, span), &plan)?; + self.prefetch.pending.as_mut().ok_or(Error::ContextPoisoned)?.entries.push(entry); + profile_prefetch("ring.prefetch_issued", 1, plan.blob); + Ok(()) + } + + /// The ring plan of one expert of `layer` in `formats` (the same checks as `Ring::new`). + fn prefetch_plan(layer: usize, formats: [MmqFormat; 3]) -> Result { + if formats[0] != formats[1] || !FORMATS[..5].contains(&formats[0]) || !FORMATS[5..].contains(&formats[2]) { + return Err(Error::InvalidProjectionShape); + } + let (gu, down, blob) = Ring::blob_geometry(&formats)?; + Ok(RingPlan { layer, groups: 0, formats, gu, down, blob, count: 0 }) + } + + /// A stage slot holds the blob and overlaps no temporary role of the arena (`Ring::admit_slots`). + fn check_prefetch_slot( + read: &crate::OriginalDeviceGrRead<'_, '_, 'ctx>, + (h, n): (ffi::BufferHandle, usize), + blob: usize, + ) -> Result<()> { + if n < blob { + return Err(Error::InvalidSize); + } + h.validate_projection_extent(n, 256)?; + for role in 0..TMP { + let (a, m) = GroupArena::span(read, role)?; + if h.overlaps(blob, a, m) { + return Err(Error::OutputAliasesInput); + } + } + Ok(()) + } + + /// The copied set for the ring being built (the drains wait for the copy stream again from here on). + pub(super) fn take_ring_prefetch(&mut self) -> Option> { + let pending = self.prefetch.pending.take()?; + self.restore_drains(); + Some(pending) + } + + /// Drops a set no ring consumes: its copies finish before the bank reference goes. + pub(super) fn drain_dropped_prefetch(&mut self, pending: PendingPrefetch<'ctx>) -> Result<()> { + let drained = self.copy.as_ref().map_or(Ok(()), OriginalGpuStream::synchronize); + if drained.is_err() { + self.failed = true; + std::mem::forget(pending); + return drained; + } + drop(pending); + Ok(()) + } + + /// Drops a set no ring took (a failed chunk, a chunk stream starting, the forward's exit). Idempotent. + pub fn cancel_ring_prefetch(&mut self) -> Result<()> { + let Some(pending) = self.take_ring_prefetch() else { return Ok(()) }; + self.trace_prefetch(format_args!("layer={} cancelled={}", pending.layer, pending.entries.len())); + profile_prefetch("ring.prefetch_wasted", pending.entries.len(), pending.blob); + self.drain_dropped_prefetch(pending) + } + + /// Drains wait for the copy stream again; buffers freed meanwhile are released now. + fn restore_drains(&mut self) { + if crate::compute_drain::background() != 0 && self.stream.is_none() { + crate::compute_drain::set_background(0); + if self.context.flush_deferred_frees().is_err() { + self.failed = true; + } + } + } +} diff --git a/crates/cuda-driver/src/mmq_original_ring/skip_expert_dma.rs b/crates/cuda-driver/src/mmq_original_ring/skip_expert_dma.rs index 7bceafba..08bfd5a6 100644 --- a/crates/cuda-driver/src/mmq_original_ring/skip_expert_dma.rs +++ b/crates/cuda-driver/src/mmq_original_ring/skip_expert_dma.rs @@ -127,6 +127,7 @@ impl<'ctx> OriginalMmqCopySchedule<'ctx> { stream_events: Vec::new(), stream_started: None, status_pool: None, + prefetch: RingPrefetch::default(), } } /// Create the copy and compute streams and the copied/used events of `slots` ring slots. diff --git a/crates/cuda-driver/src/mtp_original_check_batch.cu b/crates/cuda-driver/src/mtp_original_check_batch.cu new file mode 100644 index 00000000..bbc54282 --- /dev/null +++ b/crates/cuda-driver/src/mtp_original_check_batch.cu @@ -0,0 +1,45 @@ +// Batched numerical guard of the MTP draft step (LELEKA_DRAFT_CHECK_MERGE, off by default). +// +// One launch runs the guards of a run of ADJACENT check launches of the step program: grid.y selects the entry, and +// every entry is checked by exactly the loop and the predicate of the single-check kernels +// `mtp_original_finite` and `mtp_original_q8_guard` (mtp_original_tail.cu / mtp_original_full_checks.cu), and sets +// the same status word of its own with the same `atomicOr(status, 1)`. Nothing is read from device memory but the +// checked buffer, nothing is written but the entry's status word; the status words are therefore bit-identical to the +// ones the separate launches leave. +// +// The descriptor is ONE by-value parameter of 114 u64 words (the shape of the GrMulti parameter, so the host side +// reuses its argument type): +// w[0] number of entries (1..=28) +// w[1 + 4*e] address of the checked buffer of entry e +// w[2 + 4*e] low 32 bits: element count n (floats, or Q8_1 blocks); high 32 bits: kind (0 = f32 words, 1 = Q8_1 +// block scales) +// w[3 + 4*e] address of the entry's status word +// w[4 + 4*e] reserved, zero +// Launch: grid (ceil(max n / 256), entries, 1), block (256, 1, 1). The grid-stride loop covers every element for any +// grid.x, so an entry shorter than the longest one simply has idle blocks. +#include +#include +#include +namespace strata::kernels { +struct Q81Block { half2 ds; int8_t qs[32]; }; +static_assert(sizeof(Q81Block) == 36, "Q8_1 block layout"); +struct CheckBatch { unsigned long long w[114]; }; +static_assert(sizeof(CheckBatch) == 912, "the descriptor is the 912-byte by-value parameter of GrMulti"); +extern "C" __global__ void mtp_original_check_batch(CheckBatch b) { + const unsigned entry = blockIdx.y; + if (entry >= static_cast(b.w[0])) return; + const unsigned long long data = b.w[1 + 4 * entry]; + const unsigned long long meta = b.w[2 + 4 * entry]; + int* status = reinterpret_cast(b.w[3 + 4 * entry]); + const int n = static_cast(meta & 0xffffffffull); + const int q8 = static_cast(meta >> 32) == 1; + for (int i = blockIdx.x * blockDim.x + threadIdx.x; i < n; i += gridDim.x * blockDim.x) { + if (!q8) { + if (!isfinite(reinterpret_cast(data)[i])) atomicOr(status, 1); + } else { + float2 ds = __half22float2(reinterpret_cast(data)[i].ds); + if (!isfinite(ds.x) || !isfinite(ds.y)) atomicOr(status, 1); + } + } +} +} // namespace strata::kernels diff --git a/crates/cuda-driver/src/mtp_original_check_batch.ptx b/crates/cuda-driver/src/mtp_original_check_batch.ptx new file mode 100644 index 00000000..01be593b Binary files /dev/null and b/crates/cuda-driver/src/mtp_original_check_batch.ptx differ diff --git a/crates/cuda-driver/src/mtp_original_check_batch_program.rs b/crates/cuda-driver/src/mtp_original_check_batch_program.rs new file mode 100644 index 00000000..717df39d --- /dev/null +++ b/crates/cuda-driver/src/mtp_original_check_batch_program.rs @@ -0,0 +1,155 @@ +//! `LELEKA_DRAFT_CHECK_MERGE` (off by default): the adjacent finite and Q8_1 scale guards of a draft step program are +//! launched as one `mtp_original_check_batch` (docs/experiments/step-ledger.md, row O8). The grouping and the +//! descriptor are the pure `leleka_cuda_model::draft_check_batch`; this module classifies the commands of the two +//! command lists (the scalar prefix and the tail), builds the batched commands, owns the batch module and launches it. +//! +//! Only checks that are neighbours in the list are grouped, so no check moves across another command. + +#[allow(unused_imports)] +use super::*; +use leleka_cuda_model::draft_check_batch::{self as batch, Check, CheckKind, THREADS}; + +/// Placeholder asset of a batched check in both command lists (the real module tables are far shorter). +const BATCH_ASSET: usize = usize::MAX; +/// Module of the single-check kernels in the tail command list, and their entries (finite, Q8_1 scales). +const TAIL_CHECKS: usize = 18; +const TAIL_CHECK_ENTRIES: (usize, usize) = (0, 1); +/// The same in the scalar prefix command list. +const PREFIX_CHECKS: usize = 2; +const PREFIX_CHECK_ENTRIES: (usize, usize) = (11, 12); +/// The first prefix commands are the status reset and the embedding lookup; the native embedding is captured by their +/// index, so they stay where they are. +const PREFIX_KEEP: usize = 2; + +/// The sealed batch module, loaded once for each of the two launch interfaces of the program. +pub(super) struct CheckBatchModules { + tail: Rc, + prefix: Rc, +} + +impl CheckBatchModules { + /// Loads the sealed `mtp_original_check_batch.ptx` into `context`. + pub(super) fn load(context: &Context<'_>) -> Result { + let g = context.enter().inspect_err(|_| { + context.poison(); + context.retain_driver(); + })?; + let loaded = Self::load_current(); + let pop = g.finish(); + if pop.is_err() { + context.poison(); + context.retain_driver(); + } + combine(loaded, pop) + } + + fn load_current() -> Result { + let (ptx, entries) = (symbols::CHECK_BATCH.0, symbols::CHECK_BATCH.1); + let sealed = crate::sealed_ptx::pinned(ptx, Some(symbols::CHECK_BATCH_PIN)); + let ptx = sealed.ok_or(Error::UnsupportedQwenOperation)?; + Ok(Self { tail: Rc::new(FM::load(ptx, entries)?), prefix: Rc::new(Module::load(ptx, entries)?) }) + } +} + +/// Is `shape` the launch shape of the separate check of `check`? +fn is_single_launch(shape: &LaunchShape, check: &Check) -> bool { + shape.dims.grid == [check.single_grid(), 1, 1] && shape.dims.block == [THREADS, 1, 1] && shape.shared == 0 +} + +fn check_of(kind: CheckKind, words: (u64, i32, u64), shape: &LaunchShape) -> Option { + let (data, count, flag) = words; + let check = Check { kind, data, count: u32::try_from(count).ok()?, flag }; + is_single_launch(shape, &check).then_some(check) +} + +/// Which single-check kernel `(asset, index)` is, given the module and the entries of the list. +fn kind_of((asset, index): (usize, usize), module: usize, entries: (usize, usize)) -> Option { + if asset != module { + None + } else if index == entries.0 { + Some(CheckKind::Finite) + } else if index == entries.1 { + Some(CheckKind::Q8Scale) + } else { + None + } +} + +/// The check a tail command is, if it is exactly one separate check launch. +fn tail_check(command: &FullCommand) -> Option { + let kind = kind_of((command.asset, command.index), TAIL_CHECKS, TAIL_CHECK_ENTRIES)?; + check_of(kind, command.args.check_words()?, &command.shape) +} + +/// The check a scalar prefix command is, if it is exactly one separate check launch. +fn prefix_check(command: &ScalarCommand) -> Option { + let ScalarCommand::Kernel { asset, index, shape, args } = command else { return None }; + let kind = kind_of((*asset, *index), PREFIX_CHECKS, PREFIX_CHECK_ENTRIES)?; + check_of(kind, args.check_words()?, shape) +} + +fn batch_shape(launch: &batch::BatchLaunch) -> LaunchShape { + LaunchShape::new(launch.grid, [THREADS, 1, 1], 0) +} + +fn tail_batch(checks: &[Check]) -> Result { + let launch = batch::encode(checks)?; + let shape = batch_shape(&launch); + Ok(FullCommand { asset: BATCH_ASSET, index: 0, shape, args: FA::new(vec![F::GrMulti(launch.words)])? }) +} + +fn prefix_batch(checks: &[Check]) -> Result { + let launch = batch::encode(checks)?; + let shape = batch_shape(&launch); + Ok(ScalarCommand::Kernel { + asset: BATCH_ASSET, + index: 0, + shape, + args: Arguments::new(vec![Arg::GrMulti(launch.words)])?, + }) +} + +/// The tail commands with every run of adjacent checks launched as one batch. +pub(super) fn merge_tail(commands: Vec) -> Result> { + batch::merge_adjacent(commands, 0, tail_check, tail_batch) +} + +/// The scalar prefix commands with every run of adjacent checks launched as one batch. +pub(super) fn merge_prefix(commands: Vec) -> Result> { + batch::merge_adjacent(commands, PREFIX_KEEP, prefix_check, prefix_batch) +} + +/// Launch one command of a scalar prefix list (the catch-up and the step prefix). +pub(super) fn launch_prefix_command( + modules: &[Rc; 6], + batch: Option<&CheckBatchModules>, + stream: usize, + command: &mut ScalarCommand, +) -> Result<()> { + let ScalarCommand::Kernel { asset, index, shape, args } = command else { + return Err(Error::InvalidQwenShape); + }; + if *asset == BATCH_ASSET { + return batch.ok_or(Error::ContextPoisoned)?.prefix.launch(*index, *shape, stream, args); + } + modules.get(*asset).ok_or(Error::InvalidQwenShape)?.launch(*index, *shape, stream, args) +} + +/// Launch a batched tail command. +pub(super) fn launch_tail_batch( + batch: Option<&CheckBatchModules>, + stream: usize, + command: &mut FullCommand, +) -> Result<()> { + batch.ok_or(Error::ContextPoisoned)?.tail.launch(command.index, command.shape, stream, &mut command.args) +} + +/// Does the tail command launch a batch? +pub(super) fn is_tail_batch(command: &FullCommand) -> bool { + command.asset == BATCH_ASSET +} + +#[cfg(test)] +mod gpu_tests; +#[cfg(test)] +mod tests; diff --git a/crates/cuda-driver/src/mtp_original_check_batch_program/gpu_tests.rs b/crates/cuda-driver/src/mtp_original_check_batch_program/gpu_tests.rs new file mode 100644 index 00000000..4fa2da23 --- /dev/null +++ b/crates/cuda-driver/src/mtp_original_check_batch_program/gpu_tests.rs @@ -0,0 +1,186 @@ +//! Model-free GPU proof of `mtp_original_check_batch`: for a finite buffer set and for a NaN or Inf placed at the +//! edges and in the middle of every checked buffer (floats and Q8_1 scale pairs), the status words of one batched +//! launch, through the tail interface and through the scalar prefix interface, equal the ones of the separate +//! launches of `mtp_original_finite` and `mtp_original_q8_guard`. +//! Run: `cargo test -p leleka-cuda-driver --features cuda-driver --lib check_batch_program_gpu -- --ignored`. +use super::*; +use crate::{DeviceBuffer, Driver}; +use leleka_cuda_model::draft_check_batch::encode; + +const FLOATS: [usize; 3] = [12288, 640, 4]; +const BLOCKS: usize = 80; +const WORDS: usize = 16; + +fn floats_bytes(n: usize, at: Option<(usize, f32)>) -> Vec { + let mut v = vec![1.0f32; n]; + if let Some((i, x)) = at { + v[i] = x; + } + v.iter().flat_map(|x| x.to_le_bytes()).collect() +} + +/// `BLOCKS` Q8_1 blocks of 36 bytes: a finite scale pair, one half replaced by a non-finite code at (block, half). +fn blocks_bytes(at: Option<(usize, usize, u16)>) -> Vec { + let mut b = vec![0u8; BLOCKS * 36]; + for i in 0..BLOCKS { + b[i * 36..i * 36 + 4].copy_from_slice(&[0x00, 0x38, 0x00, 0x40]); + } + if let Some((block, half, code)) = at { + let o = block * 36 + 2 * half; + b[o..o + 2].copy_from_slice(&code.to_le_bytes()); + } + b +} + +struct Fault { + floats: [Option<(usize, f32)>; 3], + scale: Option<(usize, usize, u16)>, +} + +fn faults() -> Vec { + let none = || Fault { floats: [None; 3], scale: None }; + let mut all = vec![none()]; + for (buffer, n) in FLOATS.into_iter().enumerate() { + for i in [0, 1, 255, 256, n / 2, n - 1] { + for x in [f32::NAN, f32::INFINITY, f32::NEG_INFINITY] { + let mut f = none(); + f.floats[buffer] = Some((i.min(n - 1), x)); + all.push(f); + } + } + } + for block in [0, 1, 79] { + for half in [0, 1] { + for code in [0x7e00u16, 0x7c00, 0xfc00] { + all.push(Fault { floats: [None; 3], scale: Some((block, half, code)) }); + } + } + } + all +} + +fn address(buffer: &DeviceBuffer<'_>) -> u64 { + buffer.handle.expect("handle").qwen_address() +} + +fn read_status(status: &DeviceBuffer<'_>) -> Vec { + let bytes = status.copy_to_owned(WORDS * 4).expect("read"); + bytes.chunks_exact(4).map(|b| u32::from_le_bytes(b.try_into().unwrap())).collect() +} + +/// The device buffers, the checks over them and the two ways to launch them. +struct Rig<'a> { + context: &'a Context<'a>, + stream: usize, + data: Vec>, + blocks: DeviceBuffer<'a>, + status: DeviceBuffer<'a>, + checks: Vec, + batch: CheckBatchModules, + singles: FM, +} + +impl<'a> Rig<'a> { + fn new(context: &'a Context<'a>, stream: usize) -> Self { + let data: Vec> = FLOATS.iter().map(|n| context.allocate(n * 4).expect("alloc")).collect(); + let blocks = context.allocate(BLOCKS * 36).expect("alloc"); + let status = context.allocate(WORDS * 4).expect("alloc"); + let bases = [(CheckKind::Finite, &data[0], FLOATS[0]), (CheckKind::Finite, &data[1], FLOATS[1])]; + let bases = bases.into_iter().chain([(CheckKind::Finite, &data[2], FLOATS[2])]); + let bases = bases.chain([(CheckKind::Q8Scale, &blocks, BLOCKS)]); + let flag = address(&status); + let checks = bases + .enumerate() + .map(|(i, (kind, b, count))| Check { + kind, + data: address(b), + count: count as u32, + flag: flag + 4 * i as u64, + }) + .collect(); + let batch = CheckBatchModules::load(context).expect("sealed batch asset"); + Self { context, stream, data, blocks, status, checks, batch, singles: Self::load_singles(context) } + } + + /// The separate guard kernels; loading a module needs the context current, as `CheckBatchModules::load` does. + fn load_singles(context: &Context<'_>) -> FM { + let (ptx, entries) = symbols::ASSETS[TAIL_CHECKS]; + let guard = context.enter().expect("enter"); + let singles = FM::load(ptx, entries).expect("single checks"); + guard.finish().expect("pop"); + singles + } + + fn upload(&mut self, fault: &Fault) { + for (i, buffer) in self.data.iter_mut().enumerate() { + buffer.copy_from(&floats_bytes(FLOATS[i], fault.floats[i])).expect("upload"); + } + self.blocks.copy_from(&blocks_bytes(fault.scale)).expect("upload"); + } + + fn run(&mut self, launch: impl FnOnce(&Self)) -> Vec { + self.status.copy_from(&[0u8; WORDS * 4]).expect("zero"); + launch(self); + self.context.synchronize().expect("sync"); + read_status(&self.status) + } + + fn separate(&self) { + for c in &self.checks { + let index = usize::from(c.kind == CheckKind::Q8Scale); + let mut args = FA::new(vec![F::U64(c.data), F::I32(c.count as i32), F::U64(c.flag)]).unwrap(); + let shape = single_shape(c.single_grid()); + self.singles.launch(index, shape, self.stream, &mut args).expect("single"); + } + } + + fn tail(&self) { + let launch = encode(&self.checks).unwrap(); + let mut args = FA::new(vec![F::GrMulti(launch.words.clone())]).unwrap(); + self.batch.tail.launch(0, batch_shape(&launch), self.stream, &mut args).expect("batch"); + } + + fn prefix(&self) { + let launch = encode(&self.checks).unwrap(); + let mut args = Arguments::new(vec![Arg::GrMulti(launch.words.clone())]).unwrap(); + self.batch.prefix.launch(0, batch_shape(&launch), self.stream, &mut args).expect("batch"); + } +} + +/// A readable name of a case for the verdict line. +fn describe(fault: &Fault) -> String { + let floats = fault.floats.iter().enumerate().find_map(|(i, f)| f.map(|(at, x)| format!("floats[{i}][{at}]={x}"))); + let scale = fault.scale.map(|(block, half, code)| format!("scale block {block} half {half} code {code:#06x}")); + floats.or(scale).unwrap_or_else(|| "clean".to_string()) +} + +#[test] +#[ignore = "Root-only: needs a CUDA device"] +fn the_batched_guard_leaves_the_status_words_of_the_separate_launches() { + let driver = Driver::load().expect("driver"); + let context = driver.device(0).expect("device").create_context(1usize << 30).expect("context"); + // the workspace owns the stream: it must outlive every launch + let workspace = context.native_batch_workspace().expect("workspace"); + let stream = workspace.blas().expect("blas").stream(); + let mut rig = Rig::new(&context, stream); + let guard = context.enter().expect("enter"); + let (mut total, mut caught, mut differ) = (0, 0, 0); + for fault in faults() { + rig.upload(&fault); + let separate = rig.run(Rig::separate); + let (tail, prefix) = (rig.run(Rig::tail), rig.run(Rig::prefix)); + let verdict = if tail == separate && prefix == separate { "equal" } else { "DIFFER" }; + println!("CHECK-BATCH case {} status words {verdict} (separate {separate:?})", describe(&fault)); + total += 1; + caught += usize::from(separate.iter().any(|w| *w != 0)); + differ += usize::from(verdict == "DIFFER"); + } + guard.finish().expect("pop"); + println!("CHECK-BATCH summary: {total} cases, {caught} raise a flag, {differ} differ"); + assert_eq!(differ, 0, "the batched guard must leave the separate launches' status words"); + assert_eq!(total - caught, 1, "exactly the clean case raises nothing"); +} + +fn single_shape(grid: u32) -> LaunchShape { + LaunchShape::new([grid, 1, 1], [THREADS, 1, 1], 0) +} diff --git a/crates/cuda-driver/src/mtp_original_check_batch_program/tests.rs b/crates/cuda-driver/src/mtp_original_check_batch_program/tests.rs new file mode 100644 index 00000000..10eed3f2 --- /dev/null +++ b/crates/cuda-driver/src/mtp_original_check_batch_program/tests.rs @@ -0,0 +1,194 @@ +//! The command lists of a draft step with merged checks: the adapters recognise exactly the separate check launches, +//! the merged lists stand for the separate ones, and the sealed batch asset is the one the kernel source builds. +use super::*; +use crate::sealed_ptx::test_support::{assert_nvcc_13_2_86, assert_real_sm120_ptx, one_byte_corrupted}; +use leleka_cuda_model::draft_check_batch::{BATCH_WORDS, ENTRY_WORDS}; + +/// What a command is, for comparing a list before and after merging. +#[derive(Debug, PartialEq)] +enum Item { + Check(Check), + Other(usize, usize), +} + +fn single_shape(count: u32) -> LaunchShape { + LaunchShape::new([count.div_ceil(THREADS), 1, 1], [THREADS, 1, 1], 0) +} + +fn tail_check_command(index: usize, buffer: u64, count: i32, slot: u64) -> FullCommand { + let args = vec![F::U64(buffer), F::I32(count), F::U64(0x9000 + 4 * slot)]; + FullCommand { asset: TAIL_CHECKS, index, shape: single_shape(count as u32), args: FA::new(args).unwrap() } +} + +fn tail_other(asset: usize, index: usize) -> FullCommand { + let shape = LaunchShape::new([1, 1, 1], [32, 1, 1], 0); + FullCommand { asset, index, shape, args: FA::new(vec![F::U64(8)]).unwrap() } +} + +fn prefix_check_command(index: usize, buffer: u64, count: i32, slot: u64) -> ScalarCommand { + let args = Arguments::new(vec![Arg::U64(buffer), Arg::I32(count), Arg::U64(0x9000 + 4 * slot)]).unwrap(); + ScalarCommand::Kernel { asset: PREFIX_CHECKS, index, shape: single_shape(count as u32), args } +} + +fn prefix_other(asset: usize, index: usize) -> ScalarCommand { + let shape = LaunchShape::new([1, 1, 1], [32, 1, 1], 0); + ScalarCommand::Kernel { asset, index, shape, args: Arguments::new(vec![Arg::U64(8)]).unwrap() } +} + +/// Decodes a batched command's descriptor back into the checks it stands for. +fn decode(words: &[u64; BATCH_WORDS], shape: &LaunchShape) -> Vec { + let entries = words[0] as usize; + assert!(entries >= 2, "a batch of one is never built"); + assert_eq!(shape.dims.grid[1] as usize, entries); + assert_eq!((shape.dims.block, shape.shared), ([THREADS, 1, 1], 0)); + (0..entries) + .map(|e| { + let meta = words[2 + ENTRY_WORDS * e]; + let kind = if meta >> 32 == 1 { CheckKind::Q8Scale } else { CheckKind::Finite }; + Check { kind, data: words[1 + ENTRY_WORDS * e], count: meta as u32, flag: words[3 + ENTRY_WORDS * e] } + }) + .collect() +} + +fn tail_items(commands: &[FullCommand]) -> Vec { + let mut items = Vec::new(); + for c in commands { + if c.asset == BATCH_ASSET { + items.extend(decode(c.args.gr_words().unwrap(), &c.shape).into_iter().map(Item::Check)); + } else { + items.push(tail_check(c).map_or(Item::Other(c.asset, c.index), Item::Check)); + } + } + items +} + +fn prefix_items(commands: &[ScalarCommand]) -> Vec { + let mut items = Vec::new(); + for c in commands { + let ScalarCommand::Kernel { asset, index, shape, args } = c else { panic!("copy") }; + if *asset == BATCH_ASSET { + items.extend(decode(args.gr_words().unwrap(), shape).into_iter().map(Item::Check)); + } else { + items.push(prefix_check(c).map_or(Item::Other(*asset, *index), Item::Check)); + } + } + items +} + +fn tail_list() -> Vec { + vec![ + tail_other(13, 5), + tail_check_command(0, 0x1000, 12288, 0), + tail_other(16, 0), + tail_check_command(0, 0x2000, 6144, 1), + tail_check_command(0, 0x3000, 10240, 7), + tail_check_command(1, 0x4000, 192, 5), + tail_check_command(0, 0x5000, 4, 10), + tail_other(13, 6), + tail_check_command(0, 0x6000, 2560, 11), + ] +} + +#[test] +fn the_tail_list_loses_the_adjacent_check_launches_and_nothing_else() { + let list = tail_list(); + let before = tail_items(&list); + let merged = merge_tail(list).unwrap(); + assert_eq!(tail_items(&merged), before); + // 9 commands: kernel, check, kernel, 4 adjacent checks (one batch), kernel, check + assert_eq!(merged.len(), 6); + assert_eq!(merged.iter().filter(|c| c.asset == BATCH_ASSET).count(), 1); +} + +#[test] +fn the_prefix_list_keeps_its_first_commands_and_merges_the_rest() { + let list = vec![ + prefix_other(0, 11), + prefix_check_command(11, 0x1000, 2560, 0), + prefix_check_command(11, 0x2000, 2560, 1), + prefix_other(3, 0), + prefix_check_command(11, 0x3000, 2560, 6), + prefix_check_command(12, 0x4000, 80, 6), + prefix_check_command(11, 0x5000, 10240, 7), + ]; + let before = prefix_items(&list); + let merged = prefix_items(&merge_prefix(list).unwrap()); + assert_eq!(merged, before); + let list = vec![ + prefix_other(0, 11), + prefix_check_command(11, 0x1000, 2560, 0), + prefix_check_command(11, 0x2000, 2560, 1), + prefix_check_command(11, 0x3000, 2560, 2), + ]; + // index 1 is not merged (the native embedding is captured by command index), 2 and 3 are + let merged = merge_prefix(list).unwrap(); + assert_eq!(merged.len(), 3); + assert!(matches!(&merged[2], ScalarCommand::Kernel { asset, .. } if *asset == BATCH_ASSET)); +} + +#[test] +fn only_the_exact_separate_check_launches_are_recognised() { + let good = tail_check_command(0, 0x1000, 600, 3); + assert_eq!(tail_check(&good), Some(Check { kind: CheckKind::Finite, data: 0x1000, count: 600, flag: 0x900c })); + // another kernel of the module, another module, a different grid, other arguments, a negative count + let mut other_entry = tail_check_command(0, 0x1000, 600, 3); + other_entry.index = 2; + let mut other_module = tail_check_command(0, 0x1000, 600, 3); + other_module.asset = 17; + let mut other_grid = tail_check_command(0, 0x1000, 600, 3); + other_grid.shape = LaunchShape::new([4, 1, 1], [THREADS, 1, 1], 0); + let mut shared = tail_check_command(0, 0x1000, 600, 3); + shared.shape = LaunchShape::new([3, 1, 1], [THREADS, 1, 1], 16); + let mut extra_arg = tail_check_command(0, 0x1000, 600, 3); + extra_arg.args = FA::new(vec![F::U64(0x1000), F::I32(600), F::U64(0x900c), F::I32(1)]).unwrap(); + let negative = tail_check_command(0, 0x1000, -1, 3); + for command in [&other_entry, &other_module, &other_grid, &shared, &extra_arg, &negative] { + assert!(tail_check(command).is_none()); + } + assert_eq!(tail_check(&tail_check_command(1, 0x2000, 20, 5)).unwrap().kind, CheckKind::Q8Scale); +} + +#[test] +fn a_command_that_is_not_a_check_is_never_swallowed() { + let mut seed = 0x9e37_79b9_7f4a_7c15u64; + let mut next = move || { + seed ^= seed << 13; + seed ^= seed >> 7; + seed ^= seed << 17; + seed + }; + for _ in 0..100 { + let list: Vec = (0..40) + .map(|i| match next() % 4 { + 0 => tail_other(13, (next() % 5) as usize), + 1 => tail_check_command(1, 0x1000 * (i + 1), 20 + (next() % 500) as i32, i % 30), + _ => tail_check_command(0, 0x1000 * (i + 1), 1 + (next() % 12000) as i32, i % 30), + }) + .collect(); + let before = tail_items(&list); + assert_eq!(tail_items(&merge_tail(list).unwrap()), before); + } +} + +#[test] +fn the_check_kernels_are_the_entries_the_lists_name() { + let (_, tail) = symbols::ASSETS[TAIL_CHECKS]; + assert_eq!(tail[TAIL_CHECK_ENTRIES.0], c"mtp_original_finite"); + assert_eq!(tail[TAIL_CHECK_ENTRIES.1], c"mtp_original_q8_guard"); + assert_eq!(TAIL_ENTRIES[PREFIX_CHECK_ENTRIES.0], c"mtp_original_finite"); + assert_eq!(TAIL_ENTRIES[PREFIX_CHECK_ENTRIES.1], c"mtp_original_q8_guard"); +} + +#[test] +fn the_batch_asset_is_the_sealed_ptx_of_its_source() { + let (ptx, entries) = symbols::CHECK_BATCH; + assert_eq!(entries, [c"mtp_original_check_batch"]); + assert!(crate::sealed_ptx::pinned(ptx, Some(symbols::CHECK_BATCH_PIN)).is_some()); + assert!(crate::sealed_ptx::pinned(one_byte_corrupted(ptx), Some(symbols::CHECK_BATCH_PIN)).is_none()); + assert_real_sm120_ptx("check batch", ptx, ["mtp_original_check_batch"]); + assert_nvcc_13_2_86("check batch", ptx); + let text = std::str::from_utf8(&ptx[..ptx.len() - 1]).unwrap(); + assert!(text.contains("mtp_original_check_batch_param_0[912]"), "one 114-word by-value parameter"); + assert_eq!(text.matches(".entry").count(), 1); + assert_eq!(text.matches("atom.global.or.b32").count(), 2, "one atomicOr per kind, as the single kernels"); +} diff --git a/crates/cuda-driver/src/mtp_original_full_drafter/original_mtp_drafter.rs b/crates/cuda-driver/src/mtp_original_full_drafter/original_mtp_drafter.rs index daa422b0..67e0a0cf 100644 --- a/crates/cuda-driver/src/mtp_original_full_drafter/original_mtp_drafter.rs +++ b/crates/cuda-driver/src/mtp_original_full_drafter/original_mtp_drafter.rs @@ -3,8 +3,12 @@ #[allow(unused_imports)] use super::*; +#[path = "original_mtp_drafter/original_mtp_drafter_chain_gate.rs"] +mod original_mtp_drafter_chain_gate; #[path = "original_mtp_drafter/original_mtp_drafter_finish_chain.rs"] mod original_mtp_drafter_finish_chain; +#[path = "original_mtp_drafter/original_mtp_drafter_keep_bank.rs"] +mod original_mtp_drafter_keep_bank; #[path = "original_mtp_drafter/original_mtp_drafter_launch_rounds.rs"] mod original_mtp_drafter_launch_rounds; #[path = "original_mtp_drafter/original_mtp_drafter_new_draft.rs"] diff --git a/crates/cuda-driver/src/mtp_original_full_drafter/original_mtp_drafter/original_mtp_drafter_chain_gate.rs b/crates/cuda-driver/src/mtp_original_full_drafter/original_mtp_drafter/original_mtp_drafter_chain_gate.rs new file mode 100644 index 00000000..956dabdf --- /dev/null +++ b/crates/cuda-driver/src/mtp_original_full_drafter/original_mtp_drafter/original_mtp_drafter_chain_gate.rs @@ -0,0 +1,16 @@ +//! The profile label of the pipelined-chain gate (split out of the finish-chain file to keep it under its line limit). + +/// Which condition of the pipelined chain decided this draft (profile counters `mtp.chain_gate.*`, one per draft). +pub(super) fn chain_gate(switch_on: bool, (coupled, min_p, limit): (bool, f32, i32)) -> &'static str { + if !switch_on { + "mtp.chain_gate.switch_off" + } else if coupled { + "mtp.chain_gate.coupled" + } else if min_p > 0.0 { + "mtp.chain_gate.min_p" + } else if limit <= 2 { + "mtp.chain_gate.short" + } else { + "mtp.chain_gate.pipelined" + } +} diff --git a/crates/cuda-driver/src/mtp_original_full_drafter/original_mtp_drafter/original_mtp_drafter_finish_chain.rs b/crates/cuda-driver/src/mtp_original_full_drafter/original_mtp_drafter/original_mtp_drafter_finish_chain.rs index 8b3b2f41..42ee18b5 100644 --- a/crates/cuda-driver/src/mtp_original_full_drafter/original_mtp_drafter/original_mtp_drafter_finish_chain.rs +++ b/crates/cuda-driver/src/mtp_original_full_drafter/original_mtp_drafter/original_mtp_drafter_finish_chain.rs @@ -42,19 +42,170 @@ impl<'ctx> OriginalMtpDrafter<'ctx> { ) -> Result<([i32; 8], [f32; 8], usize)> { let mut ids = [0i32; 8]; let mut probabilities = [0f32; 8]; - let output = self.finish_first_step(key)?; - ids[0] = output.token; - probabilities[0] = output.probability; // draft j writes the cell first + a + j, and the ring ends at MTP_ORIGINAL_MAX_CELLS (upstream `max_steps`) let limit = crate::original_mtp_actor::chain_end_within_cells( (self.max_t as i32 - 1).min(max_drafts), first.saturating_add(a), MTP_ORIGINAL_MAX_CELLS, ); + let gate = super::original_mtp_drafter_chain_gate::chain_gate(policy.chain_pipeline, (cp, min_p, limit)); + crate::host_profile::add(gate, 0.0); + if policy.chain_pipeline && !cp && min_p <= 0.0 && limit > 2 { + let count = self.finish_chain_pipelined(ring, policy, (key, limit), (&mut ids, &mut probabilities))?; + return Ok((ids, probabilities, count)); + } + let output = self.finish_first_step(key)?; + ids[0] = output.token; + probabilities[0] = output.probability; let count = self.finish_chain_steps(ring, policy, (cp, limit, min_p), (&mut ids, &mut probabilities))?; Ok((ids, probabilities, count)) } + /// Chain steps 1..limit enqueued back to back behind the round graph (greedy drafts with `min_p` 0: the depth is + /// known up front, every step's cell record is static and its token comes from the device), one stream drain, then + /// every step's output is read and the shared numerical flags are checked once. The kernels and their order are + /// those of the sequential path; only the host round trip between two steps (stream sync, flag read-back, record + /// write, launch) is gone. The step graphs of this path are recorded without the flag resets, so a fault of any + /// step stays set until the single read. While a graph is missing it is recorded first, on the idle stream. + fn finish_chain_pipelined( + &mut self, + ring: &mut MtpOriginalInt8<'ctx>, + policy: &OriginalMtpFullPolicy, + (key, limit): (OriginalGraphKey, i32), + (ids, probabilities): (&mut [i32; 8], &mut [f32; 8]), + ) -> Result { + let steps = 1..limit as usize; + let first = if self.chain_graphs_recorded(steps.clone())? { + None + } else { + let first = self.finish_first_step(key)?; + self.record_chain_graphs(ring, policy, steps.clone())?; + Some(first) + }; + let _span = crate::host_profile::span("mtp.chain_pipelined"); + let stream = self.stream.as_mut().ok_or(Error::ContextPoisoned)?; + let graphs = self.graphs.as_mut().ok_or(Error::ContextPoisoned)?; + let outputs = Self::run_chain(self.context, (graphs, stream), (key, steps), first); + let outputs = outputs.inspect_err(|_| self.fail_if_poisoned())?; + for (j, output) in outputs.into_iter().enumerate() { + ids[j] = output.token; + probabilities[j] = output.probability; + } + Ok(limit as usize) + } + + /// Enqueues the steps back to back, drains the stream once and reads every output. + fn run_chain( + context: &'ctx Context<'ctx>, + (graphs, stream): (&mut ChainGraphs<'ctx>, &mut OriginalGpuStream<'ctx>), + (key, steps): (OriginalGraphKey, std::ops::Range), + first: Option, + ) -> Result> { + // LELEKA_SERVE_PROFILE: the GPU time of the whole run (events around the enqueues), next to its wall time + let mut timing = Self::timing_events(context); + if let Some((a, _)) = timing.as_mut() { + let _ = a.record(stream); + } + Self::enqueue_chain(graphs, stream, steps.clone())?; + if let Some((_, b)) = timing.as_mut() { + let _ = b.record(stream); + } + let done = stream.synchronize_with_receipt()?; + if let Some(ms) = timing.as_ref().and_then(|(a, b)| a.elapsed_ms(b).ok()) { + crate::host_profile::add("gpu.mtp_chain_pipelined", f64::from(ms)); + } + Self::chain_outputs(graphs, key, steps, &done, first) + } + + fn enqueue_chain( + graphs: &mut ChainGraphs<'ctx>, + stream: &mut OriginalGpuStream<'ctx>, + steps: std::ops::Range, + ) -> Result<()> { + for j in steps { + let graph = graphs.find_mut(chain_key(j))?.ok_or(Error::InvalidQwenShape)?; + graph.mtp_stage_chain_ahead()?; + graph.enqueue(stream)?; + } + Ok(()) + } + + /// The outputs of the round graph (when its read was deferred) and of every step, after the one drain; the flag + /// words are checked with the last step. + fn chain_outputs( + graphs: &mut ChainGraphs<'ctx>, + key: OriginalGraphKey, + steps: std::ops::Range, + done: &crate::OriginalStreamDrained<'ctx>, + first: Option, + ) -> Result> { + let mut outputs = Vec::with_capacity(steps.len() + 1); + outputs.push(match first { + Some(output) => output, + None => graphs.find_mut(key)?.ok_or(Error::InvalidQwenShape)?.mtp_finish_drained(done, false)?, + }); + let last = steps.end - 1; + for j in steps { + let graph = graphs.find_mut(chain_key(j))?.ok_or(Error::InvalidQwenShape)?; + outputs.push(graph.mtp_finish_drained(done, j == last)?); + } + Ok(outputs) + } + + fn chain_graphs_recorded(&mut self, steps: std::ops::Range) -> Result { + let graphs = self.graphs.as_mut().ok_or(Error::ContextPoisoned)?; + for j in steps { + if graphs.find_mut(chain_key(j))?.is_none() { + return Ok(false); + } + } + Ok(true) + } + + /// Records the missing no-reset step graphs; the stream must be idle (the round graph was read back). + fn record_chain_graphs( + &mut self, + ring: &mut MtpOriginalInt8<'ctx>, + policy: &OriginalMtpFullPolicy, + steps: std::ops::Range, + ) -> Result<()> { + for j in steps { + self.record_chain_graph(ring, policy, j)?; + } + Ok(()) + } + + fn record_chain_graph( + &mut self, + ring: &mut MtpOriginalInt8<'ctx>, + policy: &OriginalMtpFullPolicy, + j: usize, + ) -> Result<()> { + let full = self.full.as_ref().ok_or(Error::ContextPoisoned)?; + let scalar = self.scalar.as_ref().ok_or(Error::ContextPoisoned)?; + let graphs = self.graphs.as_mut().ok_or(Error::ContextPoisoned)?; + let stream = self.stream.as_mut().ok_or(Error::ContextPoisoned)?; + let captures = graphs.captures(); + let pol = policy.for_capture(j, false); + let graph = graphs.record( + chain_key(j), + stream, + || full.prepare_chain_step(scalar, ring, j, &pol), + |c, r| r.capture(c), + )?; + let metadata = graph.mtp_resource_metadata()?; + if graphs.captures() != captures { + self.graph_metadata = self.graph_metadata.checked_add(metadata).ok_or(Error::BudgetExceeded)?; + } + Ok(()) + } + + fn fail_if_poisoned(&mut self) { + if self.context.is_poisoned() { + self.failed = true; + } + } + fn finish_first_step(&mut self, key: OriginalGraphKey) -> Result { let graphs = self.graphs.as_mut().ok_or(Error::ContextPoisoned)?; let stream = self.stream.as_mut().ok_or(Error::ContextPoisoned)?; @@ -240,3 +391,10 @@ impl<'ctx> OriginalMtpDrafter<'ctx> { combine(combine(combine(graphs, scalar), stream), full) } } + +type ChainGraphs<'ctx> = OriginalGraphRegistry<'ctx, OriginalMtpDraftProgram<'ctx>>; + +/// The graph key of the no-reset chain step `j`. +fn chain_key(j: usize) -> OriginalGraphKey { + OriginalGraphKey::MtpChain { step: j as u8 } +} diff --git a/crates/cuda-driver/src/mtp_original_full_drafter/original_mtp_drafter/original_mtp_drafter_keep_bank.rs b/crates/cuda-driver/src/mtp_original_full_drafter/original_mtp_drafter/original_mtp_drafter_keep_bank.rs new file mode 100644 index 00000000..7baa7134 --- /dev/null +++ b/crates/cuda-driver/src/mtp_original_full_drafter/original_mtp_drafter/original_mtp_drafter_keep_bank.rs @@ -0,0 +1,24 @@ +//! The drafter's side of a kept verifier bank (`LELEKA_DECODE_GRAPH_REUSE`, docs/experiments/decode-graph-reuse.md). + +#[allow(unused_imports)] +use super::*; + +impl<'ctx> OriginalMtpDrafter<'ctx> { + /// End of a request over a verifier bank that STAYS (`LELEKA_DECODE_GRAPH_REUSE`, + /// docs/experiments/decode-graph-reuse.md): the state keyed on the request goes, the programs bound to the bank do + /// not. Drain the draft stream, forget a draft that was launched and never finished (its ring mutation stays open, + /// as in `release_verifier_bindings`) and drop the verifier window the last round staged (the tail owner keeps it + /// until the next stage, and after the bank's re-arm it is a window of an older generation). The cached round + /// programs, the direct mode, the ring owner and the policy key stay: they name the bank's final-R span and the + /// draft ring, both unchanged for the same bank, and `stage_round` refuses a window at another address. + pub fn end_request_keep_bank(&mut self) -> Result<()> { + self.validate_context(self.context)?; + self.stream.as_ref().ok_or(Error::ContextPoisoned)?.synchronize()?; + self.in_flight = None; + let source = self.full.as_ref().ok_or(Error::ContextPoisoned)?.release_staged_source(); + if source.is_err() { + self.failed = true; + } + source + } +} diff --git a/crates/cuda-driver/src/mtp_original_full_drafter/original_mtp_drafter_from_verifier.rs b/crates/cuda-driver/src/mtp_original_full_drafter/original_mtp_drafter_from_verifier.rs index 4981fff6..ada69fb8 100644 --- a/crates/cuda-driver/src/mtp_original_full_drafter/original_mtp_drafter_from_verifier.rs +++ b/crates/cuda-driver/src/mtp_original_full_drafter/original_mtp_drafter_from_verifier.rs @@ -13,14 +13,6 @@ impl OriginalMtpFullPolicy { pub(super) fn for_capture(&self, j: usize, coupled: bool) -> Self { let k = &self.kv; Self { - native_router: self.native_router, - legacy_router_mode: self.legacy_router_mode, - native_shared_scalar: self.native_shared_scalar, - native_combine: self.native_combine, - old_grouped_s2: self.old_grouped_s2, - native_final_gr: self.native_final_gr, - fp32_final_gr: self.fp32_final_gr, - gr: self.gr, kv: DraftKvPolicy { disabled: k.disabled, hybrid: k.hybrid, @@ -38,6 +30,7 @@ impl OriginalMtpFullPolicy { mscale: k.mscale, }, coupled_j: if coupled { Some(j as u8) } else { None }, + ..*self } } } diff --git a/crates/cuda-driver/src/mtp_original_full_ffi.rs b/crates/cuda-driver/src/mtp_original_full_ffi.rs index 2d3e064f..2f4a248f 100644 --- a/crates/cuda-driver/src/mtp_original_full_ffi.rs +++ b/crates/cuda-driver/src/mtp_original_full_ffi.rs @@ -24,6 +24,22 @@ impl Arguments { + self.values.iter().map(|a| if matches!(a, Arg::GrMulti(_)) { 114 * 8 } else { 0 }).sum::() } + /// The three words of a check launch (buffer, count, status word), when the arguments are exactly those. + pub(crate) fn check_words(&self) -> Option<(u64, i32, u64)> { + match &*self.values { + [Arg::U64(data), Arg::I32(count), Arg::U64(flag)] => Some((*data, *count, *flag)), + _ => None, + } + } + + #[cfg(test)] + pub(crate) fn gr_words(&self) -> Option<&[u64; 114]> { + match &*self.values { + [Arg::GrMulti(words)] => Some(words), + _ => None, + } + } + pub(crate) fn new(values: Vec) -> Result { let mut pointers = Vec::new(); pointers.try_reserve_exact(values.len()).map_err(|_| Error::HostAllocation)?; diff --git a/crates/cuda-driver/src/mtp_original_full_forward.rs b/crates/cuda-driver/src/mtp_original_full_forward.rs index e2e3719c..216629a2 100644 --- a/crates/cuda-driver/src/mtp_original_full_forward.rs +++ b/crates/cuda-driver/src/mtp_original_full_forward.rs @@ -74,6 +74,12 @@ pub struct OriginalMtpFullPolicy { pub gr: OriginalMtpGrVariant, pub kv: DraftKvPolicy, pub coupled_j: Option, + /// Enqueue the chain steps of a greedy draft with `min_p` 0 back to back and read them after one stream drain + /// (`LELEKA_DRAFT_CHAIN_PIPELINE`; the kernels and their order are the sequential path's). + pub chain_pipeline: bool, + /// Launch the adjacent finite and Q8_1 scale guards of a step as one batched guard + /// (`LELEKA_DRAFT_CHECK_MERGE`; the same checks of the same buffers at the same positions, fewer launches). + pub check_merge: bool, } struct TailLayout { sizes: [usize; 36], @@ -147,6 +153,12 @@ pub struct OriginalMtpForwardProgram<'ctx> { native_embedding: Option>, coupled_stage: Option, addrs: ScalarAddrs, + /// Captured without the tail flag reset (the prefix plan drops its status reset too): the numerical flags of + /// a chain step OR into the words the draft round's own resets cleared, so the host reads them once for a run + /// of steps enqueued back to back. + accumulate_flags: bool, + /// The batched guard module, loaded when the policy asks for merged checks. + check_batch: Option, } /// The scalar prefix's modules and the buffers its commands run on. @@ -306,6 +318,7 @@ mod role_map_tests { mod context; #[path = "mtp_original_full_forward/full_owned.rs"] mod full_owned; +mod mtp_original_check_batch_program; mod mtp_original_full_init; #[path = "mtp_original_full_forward/original_mtp_full_forward.rs"] mod original_mtp_full_forward; diff --git a/crates/cuda-driver/src/mtp_original_full_forward/full_forward_prefix_program/full_forward_program_alias_checks.rs b/crates/cuda-driver/src/mtp_original_full_forward/full_forward_prefix_program/full_forward_program_alias_checks.rs index b9bc3f3c..7d43b59a 100644 --- a/crates/cuda-driver/src/mtp_original_full_forward/full_forward_prefix_program/full_forward_program_alias_checks.rs +++ b/crates/cuda-driver/src/mtp_original_full_forward/full_forward_prefix_program/full_forward_program_alias_checks.rs @@ -1,5 +1,6 @@ //! Moved out of the parent module by STRA-338: impl OriginalMtpFullForward (2). +use super::super::mtp_original_check_batch_program::{CheckBatchModules, merge_prefix, merge_tail}; #[allow(unused_imports)] use super::*; @@ -16,7 +17,7 @@ impl<'ctx> OriginalMtpFullForward<'ctx> { let ScalarPrefixPlan { commands: prefix, native_embedding, step_row } = plan; self.program_reject_aliases(scalar, ring)?; let p = self.program_prefix(scalar, ring, step_row)?; - let commands = self.plan(&p, policy)?; + let (prefix, commands, check_batch) = self.program_commands(scalar.context, &p, (prefix, policy))?; let window = self.program_window(&p, ring)?; let coupled_stage = self.program_coupled_stage(policy)?; Ok(OriginalMtpForwardProgram { @@ -30,9 +31,27 @@ impl<'ctx> OriginalMtpFullForward<'ctx> { native_embedding, coupled_stage, addrs: Self::program_addrs(scalar)?, + accumulate_flags: false, + check_batch, }) } + /// The tail commands of the step, and with `LELEKA_DRAFT_CHECK_MERGE` the adjacent checks of the scalar prefix and + /// of the tail launched as batches, with the module that launches them. Without it the lists are as planned. + fn program_commands( + &self, + context: &'ctx Context<'ctx>, + p: &ForwardPrefix<'_, 'ctx>, + (prefix, policy): (Vec, &OriginalMtpFullPolicy), + ) -> Result<(Vec, Vec, Option)> { + let tail = self.plan(p, policy)?; + if !policy.check_merge { + return Ok((prefix, tail, None)); + } + let batch = CheckBatchModules::load(context)?; + Ok((merge_prefix(prefix)?, merge_tail(tail)?, Some(batch))) + } + fn program_addrs(scalar: &OriginalMtpScalarPrefill<'ctx>) -> Result { Ok(ScalarAddrs { residual_offset: scalar.layout.offsets[1], diff --git a/crates/cuda-driver/src/mtp_original_full_forward/original_mtp_forward_program.rs b/crates/cuda-driver/src/mtp_original_full_forward/original_mtp_forward_program.rs index 08b62081..db15901c 100644 --- a/crates/cuda-driver/src/mtp_original_full_forward/original_mtp_forward_program.rs +++ b/crates/cuda-driver/src/mtp_original_full_forward/original_mtp_forward_program.rs @@ -1,6 +1,9 @@ //! Moved out of the parent module by STRA-338: impl OriginalMtpForwardProgram, impl OriginalMtpForwardProgram, impl //! OriginalMtpForwardProgram. +use super::mtp_original_check_batch_program::{ + CheckBatchModules, is_tail_batch, launch_prefix_command, launch_tail_batch, +}; #[allow(unused_imports)] use super::*; use abi::LaunchShape; @@ -20,7 +23,7 @@ impl OriginalMtpForwardProgram<'_> { (&self.tail, &self.ring), (&self.args.split, &mut self.args.window), stream, - command, + (self.check_batch.as_ref(), command), )?; } Ok(()) @@ -29,35 +32,47 @@ impl OriginalMtpForwardProgram<'_> { /// The coupled sampler stage, the tail flag reset and the scalar prefix commands (the native embedding is /// captured before the second one). fn capture_prefix(&mut self, capture: &mut OriginalCapture<'_, '_>, stream: usize) -> Result<()> { - if let Some(stage) = &mut self.coupled_stage { - self.tail.modules[20].launch(1, LaunchShape::new([1, 1, 1], [256, 1, 1], 0), stream, stage)?; - } - self.owners.modules[0].launch(11, LaunchShape::new([1, 1, 1], [256, 1, 1], 0), stream, &mut self.args.reset)?; + self.capture_coupled_stage(stream)?; + self.capture_flag_reset(stream)?; for (i, command) in self.prefix.iter_mut().enumerate() { if i == 1 && let Some(e) = &mut self.native_embedding { e.capture(capture)?; } - Self::launch_scalar(&self.owners.modules, stream, command)?; + if !(i == 0 && self.accumulate_flags) { + launch_prefix_command(&self.owners.modules, self.check_batch.as_ref(), stream, command)?; + } } Ok(()) } - fn launch_scalar(modules: &[Rc; 6], stream: usize, command: &mut ScalarCommand) -> Result<()> { - match command { - ScalarCommand::Kernel { asset, index, shape, args } => modules[*asset].launch(*index, *shape, stream, args), - ScalarCommand::Copy { .. } => Err(Error::InvalidQwenShape), + fn capture_coupled_stage(&mut self, stream: usize) -> Result<()> { + match &mut self.coupled_stage { + Some(stage) => self.tail.modules[20].launch(1, LaunchShape::new([1, 1, 1], [256, 1, 1], 0), stream, stage), + None => Ok(()), } } + /// The tail flag reset, unless this program accumulates its flags with the steps around it. + fn capture_flag_reset(&mut self, stream: usize) -> Result<()> { + if self.accumulate_flags { + return Ok(()); + } + let shape = LaunchShape::new([1, 1, 1], [256, 1, 1], 0); + self.owners.modules[0].launch(11, shape, stream, &mut self.args.reset) + } + /// One tail command, preceded by the Q split copy or the window-ids transport where Original puts them. fn launch_tail_command( (tail, ring): (&FullOwned<'_>, &MtpOriginalRingResources<'_>), (split, window): (&full_abi::Copy2D, &mut abi::Arguments), stream: usize, - command: &mut FullCommand, + (batch, command): (Option<&CheckBatchModules>, &mut FullCommand), ) -> Result<()> { + if is_tail_batch(command) { + return launch_tail_batch(batch, stream, command); + } if command.asset == 16 && command.index == 0 { tail.modules[13].copy2d(split, stream)?; } @@ -88,6 +103,16 @@ impl OriginalMtpForwardProgram<'_> { } } impl OriginalMtpForwardProgram<'_> { + /// Capture this program without the tail flag reset and without the prefix plan's leading status reset (the plan + /// keeps the command: the native embedding is captured by command index). + pub(crate) fn accumulate_flags(&mut self) -> Result<()> { + if !matches!(self.prefix.first(), Some(ScalarCommand::Kernel { asset: 0, index: 11, .. })) { + return Err(Error::InvalidQwenShape); + } + self.accumulate_flags = true; + Ok(()) + } + pub(crate) fn validate_flags_after_actual_drain(&self) -> Result<()> { self.validate_context(self.context)?; let h = self.tail.handle(27)?; diff --git a/crates/cuda-driver/src/mtp_original_full_graph.rs b/crates/cuda-driver/src/mtp_original_full_graph.rs index 26a2baf1..49f0ee23 100644 --- a/crates/cuda-driver/src/mtp_original_full_graph.rs +++ b/crates/cuda-driver/src/mtp_original_full_graph.rs @@ -68,6 +68,27 @@ impl<'ctx> OriginalGpuGraph<'ctx, OriginalMtpDraftProgram<'ctx>> { } self.resources.as_ref().ok_or(Error::ContextPoisoned)?.stage_chain() } + /// `mtp_stage_chain` for a step enqueued behind a step that is still in flight on the same stream. + pub(crate) fn mtp_stage_chain_ahead(&mut self) -> Result<()> { + self.validate()?; + if self.launched { + return Err(Error::InvalidQwenShape); + } + self.resources.as_ref().ok_or(Error::ContextPoisoned)?.stage_chain_ahead() + } + /// The output of a step that is already drained: `done` is the receipt of ONE stream drain after the last step + /// of a run enqueued back to back. `check_flags` reads the shared numerical flag words (last step of the run). + pub(crate) fn mtp_finish_drained( + &mut self, + done: &crate::OriginalStreamDrained<'ctx>, + check_flags: bool, + ) -> Result { + self.validate()?; + if !self.launched { + return Err(Error::InvalidQwenShape); + } + self.resources_after_stream_drain(done)?.finish_after_drain_flags(check_flags) + } pub(crate) fn mtp_stage_sampling(&mut self, params: crate::SamplerParams, history: &[i32; 4096]) -> Result<()> { self.validate()?; if self.launched { diff --git a/crates/cuda-driver/src/mtp_original_full_round/original_mtp_draft_program.rs b/crates/cuda-driver/src/mtp_original_full_round/original_mtp_draft_program.rs index 2278420e..2d044a26 100644 --- a/crates/cuda-driver/src/mtp_original_full_round/original_mtp_draft_program.rs +++ b/crates/cuda-driver/src/mtp_original_full_round/original_mtp_draft_program.rs @@ -1,6 +1,7 @@ //! Moved out of the parent module by STRA-338: impl OriginalMtpDraftProgram. #[allow(unused_imports)] +use super::super::mtp_original_check_batch_program::launch_prefix_command; use super::*; impl<'ctx> OriginalMtpDraftProgram<'ctx> { @@ -52,12 +53,8 @@ impl<'ctx> OriginalMtpDraftProgram<'ctx> { { e.capture(c)?; } - match cmd { - ScalarCommand::Kernel { asset, index, shape, args } => { - self.program.owners.modules[*asset].launch(*index, *shape, stream, args)? - } - ScalarCommand::Copy { .. } => return Err(Error::InvalidQwenShape), - } + let (modules, batch) = (&self.program.owners.modules, self.program.check_batch.as_ref()); + launch_prefix_command(modules, batch, stream, cmd)?; } Ok(()) } @@ -253,14 +250,41 @@ impl<'ctx> OriginalMtpDraftProgram<'ctx> { std::sync::atomic::fence(std::sync::atomic::Ordering::SeqCst); Ok(()) } + /// Stages the cell record of chain step `j` while step `j - 1` is still in flight on the same stream (a run of + /// steps enqueued back to back): the sequential path moves `next_j` on only after reading the previous step's + /// output, here stream order guarantees the previous step finishes first, so the position is advanced now. + pub(crate) fn stage_chain_ahead(&self) -> Result<()> { + if self.j == 0 { + return Err(Error::InvalidQwenShape); + } + { + let mut source = self.program.tail.source.try_borrow_mut().map_err(|_| Error::InvalidQwenShape)?; + let s = source.as_mut().ok_or(Error::InvalidQwenShape)?; + if s.next_j + 1 != self.j && s.next_j != self.j { + return Err(Error::InvalidQwenShape); + } + s.next_j = self.j; + } + self.stage_chain() + } + pub(crate) fn finish_after_drain(&self) -> Result { self.program.tail.validate_staged(self.j)?; - self.program.validate_flags_after_actual_drain()?; + self.finish_after_drain_flags(true) + } + + /// The step's output after the stream drained; `check_flags` reads the numerical flag words too (the steps of a + /// run enqueued back to back share them, so only the last step's read covers the whole run). + pub(crate) fn finish_after_drain_flags(&self, check_flags: bool) -> Result { + self.program.tail.validate_staged_ahead(self.j)?; + if check_flags { + self.program.validate_flags_after_actual_drain()?; + } let (token, probability) = self.read_step_output()?; let mut b = self.program.tail.source.try_borrow_mut().map_err(|_| Error::InvalidQwenShape)?; let s = b.as_mut().ok_or(Error::InvalidQwenShape)?; s.validate(self.program.context)?; - s.next_j = self.j + 1; + s.next_j = s.next_j.max(self.j + 1); Ok(OriginalMtpStepOutput { token, probability }) } diff --git a/crates/cuda-driver/src/mtp_original_full_round/staged_source.rs b/crates/cuda-driver/src/mtp_original_full_round/staged_source.rs index 89ffeb64..fea5ff92 100644 --- a/crates/cuda-driver/src/mtp_original_full_round/staged_source.rs +++ b/crates/cuda-driver/src/mtp_original_full_round/staged_source.rs @@ -2,6 +2,7 @@ //! crate_original_gpu_schedule_resources, impl OriginalGraphResources_for_OriginalMtpDraftProgram, impl //! OriginalMtpFullForward, fn mapped_i32 .... +use super::super::mtp_original_check_batch_program::merge_prefix; #[allow(unused_imports)] use super::*; @@ -38,6 +39,17 @@ impl FullOwned<'_> { } Ok(()) } + /// As `validate_staged` for a step of a run enqueued back to back: later steps may already be staged. + pub(super) fn validate_staged_ahead(&self, j: usize) -> Result<()> { + self.validate(self.context)?; + let source = self.source.try_borrow().map_err(|_| Error::InvalidQwenShape)?; + let source = source.as_ref().ok_or(Error::InvalidQwenShape)?; + source.validate(self.context)?; + if !source.ready || source.next_j < j { + return Err(Error::InvalidQwenShape); + } + Ok(()) + } } impl crate::original_gpu_schedule::resources::Sealed for OriginalMtpDraftProgram<'_> {} impl OriginalGraphResources for OriginalMtpDraftProgram<'_> { @@ -84,6 +96,7 @@ impl<'ctx> OriginalMtpFullForward<'ctx> { let ra = 2 * self.inner.max_t - 1; let prefix = self.round_prefix(scalar, ring, policy, ra)?; let mut program = self.program(scalar, ring, prefix, policy)?; + let catchup_commands = Self::catchup_commands(&program, catchup.commands)?; let coupled_stage = program.coupled_stage.take(); let before = self.round_before(scalar, rows)?; let after = self.round_after(scalar, rows, ra)?; @@ -95,12 +108,19 @@ impl<'ctx> OriginalMtpFullForward<'ctx> { before, after, post, - catchup: catchup.commands, + catchup: catchup_commands, catchup_embed: catchup.native_embedding, coupled_stage, direct_window: None, }) } + /// The catch-up commands, with their adjacent checks batched when the program's are. + fn catchup_commands( + program: &OriginalMtpForwardProgram<'ctx>, + commands: Vec, + ) -> Result> { + if program.check_batch.is_some() { merge_prefix(commands) } else { Ok(commands) } + } fn check_round_rows( &self, scalar: &OriginalMtpScalarPrefill<'ctx>, @@ -215,11 +235,45 @@ impl<'ctx> OriginalMtpFullForward<'ctx> { ring: &MtpOriginalInt8<'ctx>, j: usize, policy: &OriginalMtpFullPolicy, + ) -> Result> { + self.step_program(scalar, ring, (j, false), policy) + } + + /// The chain step `j` for a run of steps enqueued back to back (`LELEKA_DRAFT_CHAIN_PIPELINE`): the same + /// kernels as `prepare_step` without the two flag resets (tail flags, prefix status words), so a fault of any + /// step stays set until the host reads the words once after the last step. + pub fn prepare_chain_step( + &self, + scalar: &OriginalMtpScalarPrefill<'ctx>, + ring: &MtpOriginalInt8<'ctx>, + j: usize, + policy: &OriginalMtpFullPolicy, + ) -> Result> { + self.step_program(scalar, ring, (j, true), policy) + } + + fn step_program( + &self, + scalar: &OriginalMtpScalarPrefill<'ctx>, + ring: &MtpOriginalInt8<'ctx>, + (j, accumulate): (usize, bool), + policy: &OriginalMtpFullPolicy, ) -> Result> { self.check_step_index(scalar, j, policy)?; let row = self.inner.max_t + j - 1; let prefix = self.prefix_commands(scalar, ring, policy, PrefixRows { rows: 1, step_row: row })?; - let program = self.program(scalar, ring, prefix, policy)?; + let mut program = self.program(scalar, ring, prefix, policy)?; + if accumulate { + program.accumulate_flags()?; + } + self.step_draft(program, (row, j)) + } + + fn step_draft( + &self, + program: OriginalMtpForwardProgram<'ctx>, + (row, j): (usize, usize), + ) -> Result> { let mut before = Vec::new(); self.push_row_records(&mut before, row)?; let post = post_select(&program, j)?; diff --git a/crates/cuda-driver/src/mtp_original_full_symbols.rs b/crates/cuda-driver/src/mtp_original_full_symbols.rs index 5c6d9b73..fc3453db 100644 --- a/crates/cuda-driver/src/mtp_original_full_symbols.rs +++ b/crates/cuda-driver/src/mtp_original_full_symbols.rs @@ -22,3 +22,20 @@ pub(super) use chain_asset_types::DAILY_ASSET; pub(super) use chain_asset_types::DAILY_CHUNK; #[allow(unused_imports)] pub(super) use chain_asset_types::DAILY_MERGE_V2; + +/// The sealed batched numerical guard (`LELEKA_DRAFT_CHECK_MERGE`); loaded only when the switch is on, so it is not a +/// slot of `ASSETS` and moves no index. +#[allow(unused_imports)] +pub(super) static CHECK_BATCH: (&[u8], &[&std::ffi::CStr]) = + (include_bytes!("mtp_original_check_batch.ptx"), &[c"mtp_original_check_batch"]); + +/// Length (with the terminal NUL) and sha256 of the body of `mtp_original_check_batch.ptx`, compiled from +/// `mtp_original_check_batch.cu` by `scripts/gpu-bringup/compile_assets.py` (nvcc 13.2.86, the plan entry of +/// `extra-seal-plan.json`) and installed by `seal_pins.py`. +pub(super) const CHECK_BATCH_PIN: (usize, [u8; 32]) = ( + 2050, + [ + 0x89, 0x7d, 0xf5, 0x42, 0x89, 0x1f, 0x07, 0x6f, 0xdc, 0x3e, 0x9c, 0x12, 0x80, 0xfb, 0xd0, 0x94, 0x82, 0x5a, + 0x19, 0x79, 0xfc, 0x74, 0xac, 0x15, 0x12, 0x4f, 0xce, 0x82, 0x34, 0x70, 0x6a, 0x66, + ], +); diff --git a/crates/cuda-driver/src/mtp_original_scalar_ffi.rs b/crates/cuda-driver/src/mtp_original_scalar_ffi.rs index b4c6ac95..15946075 100644 --- a/crates/cuda-driver/src/mtp_original_scalar_ffi.rs +++ b/crates/cuda-driver/src/mtp_original_scalar_ffi.rs @@ -23,6 +23,22 @@ impl Arguments { + self.values.iter().map(|a| if matches!(a, Arg::GrMulti(_)) { 114 * 8 } else { 0 }).sum::() } + /// The three words of a check launch (buffer, count, status word), when the arguments are exactly those. + pub(crate) fn check_words(&self) -> Option<(u64, i32, u64)> { + match &*self.values { + [Arg::U64(data), Arg::I32(count), Arg::U64(flag)] => Some((*data, *count, *flag)), + _ => None, + } + } + + #[cfg(test)] + pub(crate) fn gr_words(&self) -> Option<&[u64; 114]> { + match &*self.values { + [Arg::GrMulti(words)] => Some(words), + _ => None, + } + } + pub(crate) fn new(values: Vec) -> Result { let mut pointers = Vec::new(); pointers.try_reserve_exact(values.len()).map_err(|_| Error::HostAllocation)?; diff --git a/crates/cuda-driver/src/original_expert_cache.rs b/crates/cuda-driver/src/original_expert_cache.rs index 93f57500..2fae65a3 100644 --- a/crates/cuda-driver/src/original_expert_cache.rs +++ b/crates/cuda-driver/src/original_expert_cache.rs @@ -45,6 +45,11 @@ pub struct OriginalExpertCache<'ctx> { /// Non-blocking stream of `fill_slot_queued_async` (the lent-slot refill): its copies do not order the legacy /// default stream's other users behind them; `sync_queued` waits for it as well. fill_stream: Option, + /// Batched refill from the default stream: recorded there and waited for by `fill_stream`, so the batch (which + /// the legacy default stream does not take) runs after everything queued before it, as the per-copy path does. + fill_event: Option, + /// Set when the driver refused a batch call once: later refills of this cache are issued per copy. + batch_refused: bool, swap_event: Option, /// Slots whose swap copy is queued on `swap_stream`, with the retained sources they read. swapping: Vec, @@ -56,3 +61,4 @@ pub struct OriginalExpertCache<'ctx> { mod original_cache_prefix; mod original_expert_cache_drop; mod original_expert_cache_methods; +pub use original_expert_cache_methods::RefillBatchOptions; diff --git a/crates/cuda-driver/src/original_expert_cache/original_expert_cache_methods.rs b/crates/cuda-driver/src/original_expert_cache/original_expert_cache_methods.rs index 20d2c518..3428d591 100644 --- a/crates/cuda-driver/src/original_expert_cache/original_expert_cache_methods.rs +++ b/crates/cuda-driver/src/original_expert_cache/original_expert_cache_methods.rs @@ -4,6 +4,8 @@ use super::*; mod original_expert_cache_adaptive_swaps; +mod original_expert_cache_batched_refill; +pub use original_expert_cache_batched_refill::RefillBatchOptions; mod original_expert_cache_file_slot_fill; mod original_expert_cache_open_and_slots; mod original_expert_cache_verify_and_lend; diff --git a/crates/cuda-driver/src/original_expert_cache/original_expert_cache_methods/original_expert_cache_adaptive_swaps.rs b/crates/cuda-driver/src/original_expert_cache/original_expert_cache_methods/original_expert_cache_adaptive_swaps.rs index 96d6c9ef..254d228d 100644 --- a/crates/cuda-driver/src/original_expert_cache/original_expert_cache_methods/original_expert_cache_adaptive_swaps.rs +++ b/crates/cuda-driver/src/original_expert_cache/original_expert_cache_methods/original_expert_cache_adaptive_swaps.rs @@ -183,10 +183,10 @@ impl<'ctx> OriginalExpertCache<'ctx> { self.fills = next_fills; Ok(()) } - fn check_fill( + pub(in super::super) fn check_fill( &self, slot: usize, - bank: &Rc>, + bank: &MappedExpertBank<'ctx>, spans: &[ResidentExpertBankSpan; 3], ) -> Result<(ffi::BufferHandle, usize)> { self.ensure_live()?; @@ -201,7 +201,7 @@ impl<'ctx> OriginalExpertCache<'ctx> { check_total(bank, spans, capacity)?; Ok((handle, capacity)) } - fn fill_layer(&self, bank: &Rc>, spans: &[ResidentExpertBankSpan; 3]) -> Result { + fn fill_layer(&self, bank: &MappedExpertBank<'ctx>, spans: &[ResidentExpertBankSpan; 3]) -> Result { if self.file_source_digest.is_some() { return Err(Error::InvalidSize); } @@ -235,7 +235,7 @@ impl<'ctx> OriginalExpertCache<'ctx> { Ok(()) } /// The default stream, or the cache's own non-blocking fill stream (created on first use). - fn fill_stream_for( + pub(in super::super) fn fill_stream_for( api: Option<&api::AsyncApi>, fill_stream: &mut Option, own_stream: bool, diff --git a/crates/cuda-driver/src/original_expert_cache/original_expert_cache_methods/original_expert_cache_batched_refill.rs b/crates/cuda-driver/src/original_expert_cache/original_expert_cache_methods/original_expert_cache_batched_refill.rs new file mode 100644 index 00000000..e6535cb6 --- /dev/null +++ b/crates/cuda-driver/src/original_expert_cache/original_expert_cache_methods/original_expert_cache_batched_refill.rs @@ -0,0 +1,160 @@ +//! The lent-slot refill with batched copies (`LELEKA_REFILL_BATCH`, EXPERIMENTAL, off by default): the same pieces as +//! `fill_slot_queued_on`, slot by slot and role by role, handed to `cuMemcpyBatchAsync_v2` in calls of a few hundred +//! copies inside one context entry. The bytes, destinations and source order are those of the per-copy path. +#[allow(unused_imports)] +use super::*; +use crate::RefillBatchReport; +use crate::refill_batch_copy::{HostCopy, issue_copies, per_copy}; + +/// How one batched refill is issued. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub struct RefillBatchOptions { + /// The copies belong on the cache's own non-blocking fill stream (`fill_slot_queued_async`); otherwise they are + /// ordered after the legacy default stream's earlier work (`fill_slot_queued`). + pub own_stream: bool, + /// Copies per `cuMemcpyBatchAsync_v2` call (1 to 4096). + pub max_copies_per_call: usize, +} + +impl<'ctx> OriginalExpertCache<'ctx> { + /// `fill_slot_queued`/`_async` of every `(slot, spans)` in order, with the copies batched. All slots are checked + /// and their sources retained before anything is queued; a check failure queues nothing. A driver failure poisons + /// the cache as the per-copy path does; a refused batch call is reported once and the rest goes per copy. + /// `sync_queued` is the fence, as for the per-copy fills. + pub fn fill_slots_queued_batched( + &mut self, + bank: &Rc>, + fills: Vec<(usize, [ResidentExpertBankSpan; 3])>, + options: RefillBatchOptions, + ) -> Result { + if fills.is_empty() { + return self.ensure_live().map(|()| RefillBatchReport::default()); + } + let copies = self.refill_copies(bank, &fills)?; + let next_fills = self.fills.checked_add(fills.len() as u64).ok_or(Error::InvalidSize)?; + let slots = self.retain_refill(bank, fills)?; + let guard = self.context.enter()?; + let issued = self.issue_refill(&copies, options, !bank.pageable()); + let mut report = match combine(issued, guard.finish()) { + Ok(report) => report, + Err(error) => { + self.poison(); + return Err(error); + } + }; + for &slot in &slots { + self.states[slot] = State::Queued; + } + self.fills = next_fills; + report.slots = slots.len(); + count_refill(&report); + Ok(report) + } + /// Every piece of every slot, in the per-copy path's order; checks each slot like `fill_slot_queued_on`. + fn refill_copies<'b>( + &self, + bank: &'b MappedExpertBank<'ctx>, + fills: &[(usize, [ResidentExpertBankSpan; 3])], + ) -> Result>> { + let mut seen = vec![false; self.states.len()]; + let mut copies = Vec::new(); + copies.try_reserve(fills.len() * 3).map_err(|_| Error::HostAllocation)?; + for (slot, spans) in fills { + if std::mem::replace(seen.get_mut(*slot).ok_or(Error::InvalidSize)?, true) { + return Err(Error::InvalidSize); + } + self.slot_copies(bank, (*slot, spans), &mut copies)?; + } + Ok(copies) + } + fn slot_copies<'b>( + &self, + bank: &'b MappedExpertBank<'ctx>, + (slot, spans): (usize, &[ResidentExpertBankSpan; 3]), + copies: &mut Vec>, + ) -> Result<()> { + let (handle, capacity) = self.check_fill(slot, bank, spans)?; + let mut offset = 0usize; + for span in spans { + let source = bank.cache_source(span)?; + for (at, bytes) in bank.copy_pieces(source) { + let destination = handle.checked_subspan(capacity, offset + at, bytes)?.qwen_address(); + copies.push(HostCopy { destination, source: &source[at..at + bytes] }); + } + offset += source.len(); + } + Ok(()) + } + /// The real registered sources retained BEFORE any enqueue; returns the slots in order. + fn retain_refill( + &mut self, + bank: &Rc>, + fills: Vec<(usize, [ResidentExpertBankSpan; 3])>, + ) -> Result> { + self.pending.try_reserve(fills.len()).map_err(|_| Error::HostAllocation)?; + let mut slots = Vec::new(); + slots.try_reserve_exact(fills.len()).map_err(|_| Error::HostAllocation)?; + for (slot, spans) in fills { + self.pending.push(RetainedFill::Mapped { bank: Rc::clone(bank), spans }); + slots.push(slot); + } + Ok(slots) + } + /// Inside the entered context: batched on the fill stream, or per copy on the per-copy path's stream when the + /// driver has no batch entry, refused one before, or the bank is pageable (the batch is used for registered + /// sources only). + fn issue_refill( + &mut self, + copies: &[HostCopy<'_>], + options: RefillBatchOptions, + registered: bool, + ) -> Result { + self.attempted = true; + let api = self.api.as_ref().ok_or(Error::ContextPoisoned)?; + if self.batch_refused || !registered || !api.can_batch() { + let stream = Self::fill_stream_for(Some(api), &mut self.fill_stream, options.own_stream)?; + per_copy(api, copies, stream)?; + return Ok(RefillBatchReport { + copies: copies.len(), + per_copy: copies.len(), + ..RefillBatchReport::default() + }); + } + let stream = Self::batch_stream(api, (&mut self.fill_stream, &mut self.fill_event), options.own_stream)?; + let (report, refused) = issue_copies(api, copies, stream, options.max_copies_per_call)?; + if let Some(error) = refused { + self.batch_refused = true; + eprintln!( + "leleka-serve: WARNING: the driver refused a batched expert refill ({error:?}); the rest of it and \ + every later refill of this cache are issued one copy at a time (LELEKA_REFILL_BATCH)" + ); + } + Ok(report) + } + /// The fill stream; for a default-stream refill it first waits for an event recorded on the legacy default + /// stream, so the batch runs after everything queued there before it (`cuMemcpyBatchAsync_v2` does not take the + /// legacy default stream itself). + fn batch_stream( + api: &api::AsyncApi, + (stream, event): (&mut Option, &mut Option), + own_stream: bool, + ) -> Result { + let fill = Self::fill_stream_for(Some(api), stream, true)?; + if !own_stream { + if event.is_none() { + *event = Some(api.create_event()?); + } + let after = event.ok_or(Error::ContextPoisoned)?; + api.record(after, api::Stream(0))?; + api.wait_event(fill, after)?; + } + Ok(fill) + } +} + +/// The refill's profile counters (`LELEKA_SERVE_PROFILE`): batch calls, copies they carried, copies issued singly. +fn count_refill(report: &RefillBatchReport) { + crate::host_profile::add("refill.batch_calls", report.batch_calls as f64); + crate::host_profile::add("refill.batch_copies", (report.copies - report.per_copy) as f64); + crate::host_profile::add("refill.per_copy", report.per_copy as f64); +} diff --git a/crates/cuda-driver/src/original_expert_cache/original_expert_cache_methods/original_expert_cache_open_and_slots.rs b/crates/cuda-driver/src/original_expert_cache/original_expert_cache_methods/original_expert_cache_open_and_slots.rs index d883237b..f28ac706 100644 --- a/crates/cuda-driver/src/original_expert_cache/original_expert_cache_methods/original_expert_cache_open_and_slots.rs +++ b/crates/cuda-driver/src/original_expert_cache/original_expert_cache_methods/original_expert_cache_open_and_slots.rs @@ -75,6 +75,8 @@ impl<'ctx> OriginalExpertCache<'ctx> { failed: false, swap_stream: None, fill_stream: None, + fill_event: None, + batch_refused: false, swap_event: None, swapping: Vec::new(), swap_sources: Vec::new(), diff --git a/crates/cuda-driver/src/original_expert_cache/original_expert_cache_methods/original_expert_cache_verify_and_lend.rs b/crates/cuda-driver/src/original_expert_cache/original_expert_cache_methods/original_expert_cache_verify_and_lend.rs index c2daa8d1..e6329f20 100644 --- a/crates/cuda-driver/src/original_expert_cache/original_expert_cache_methods/original_expert_cache_verify_and_lend.rs +++ b/crates/cuda-driver/src/original_expert_cache/original_expert_cache_methods/original_expert_cache_verify_and_lend.rs @@ -151,13 +151,14 @@ impl<'ctx> OriginalExpertCache<'ctx> { std::mem::forget(api); } } - /// Destroys the adaptive and fill streams and the swap event; the outer error is a failed context entry. + /// Destroys the adaptive and fill streams and the swap and fill events; the outer error is a failed context entry. fn release_streams(&mut self) -> Result> { let mut released = Ok(()); - if self.swap_event.is_some() || self.swap_stream.is_some() || self.fill_stream.is_some() { + let events = self.swap_event.is_some() || self.fill_event.is_some(); + if events || self.swap_stream.is_some() || self.fill_stream.is_some() { let guard = self.context.enter()?; if let Some(api) = self.api.as_ref() { - if let Some(event) = self.swap_event.take() { + for event in [self.swap_event.take(), self.fill_event.take()].into_iter().flatten() { released = combine(released, api.destroy_event(event)); } if let Some(stream) = self.fill_stream.take() { diff --git a/crates/cuda-driver/src/original_gpu_schedule.rs b/crates/cuda-driver/src/original_gpu_schedule.rs index 9cfb2275..b931580a 100644 --- a/crates/cuda-driver/src/original_gpu_schedule.rs +++ b/crates/cuda-driver/src/original_gpu_schedule.rs @@ -120,7 +120,8 @@ pub struct OriginalGraphFlight<'g, 'ctx, R: OriginalGraphResources> { active: bool, } -/// Literal graph identities, with Original layer/token/window/coupled separation. +/// Literal graph identities, with Original layer/token/window/coupled separation. `MtpChain` is a chain step +/// recorded without the flag resets (`LELEKA_DRAFT_CHAIN_PIPELINE`, greedy drafts only). #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum OriginalGraphKey { LayerPre(u8), @@ -134,6 +135,7 @@ pub enum OriginalGraphKey { MtpPrefill { rows: u8, device_inputs: bool }, MtpRound { rows: u8, coupled: bool }, MtpStep { step: u8, coupled: bool }, + MtpChain { step: u8 }, Registry { qsa: bool, tokens: u32 }, } /// Fixed upfront capacity, capture-once/replay-many: a hit never calls either diff --git a/crates/cuda-driver/src/original_gpu_schedule/original_graph_key.rs b/crates/cuda-driver/src/original_gpu_schedule/original_graph_key.rs index 322165a0..c0c24fd4 100644 --- a/crates/cuda-driver/src/original_gpu_schedule/original_graph_key.rs +++ b/crates/cuda-driver/src/original_gpu_schedule/original_graph_key.rs @@ -12,7 +12,7 @@ impl OriginalGraphKey { Self::Token | Self::VerifyCommit => true, Self::VerifyWindow(t) => (1..=8).contains(&t), Self::MtpPrefill { rows, .. } | Self::MtpRound { rows, .. } => (1..=8).contains(&rows), - Self::MtpStep { step, .. } => (1..=6).contains(&step), + Self::MtpStep { step, .. } | Self::MtpChain { step } => (1..=6).contains(&step), Self::Registry { tokens, .. } => tokens > 0, }; if valid { Ok(()) } else { Err(Error::InvalidQwenShape) } @@ -21,7 +21,9 @@ impl OriginalGraphKey { match self { Self::VerifyWindow(_) => OriginalCapturePolicy::VerifierWindow, Self::VerifyCommit => OriginalCapturePolicy::VerifierCommit, - Self::MtpPrefill { .. } | Self::MtpRound { .. } | Self::MtpStep { .. } => OriginalCapturePolicy::Mtp, + Self::MtpPrefill { .. } | Self::MtpRound { .. } | Self::MtpStep { .. } | Self::MtpChain { .. } => { + OriginalCapturePolicy::Mtp + } Self::Registry { .. } => OriginalCapturePolicy::Registry, _ => OriginalCapturePolicy::Session, } diff --git a/crates/cuda-driver/src/original_moe_prompt_device/original_moe_prompt_device_drop.rs b/crates/cuda-driver/src/original_moe_prompt_device/original_moe_prompt_device_drop.rs index 44eb5ac9..ba45a861 100644 --- a/crates/cuda-driver/src/original_moe_prompt_device/original_moe_prompt_device_drop.rs +++ b/crates/cuda-driver/src/original_moe_prompt_device/original_moe_prompt_device_drop.rs @@ -49,6 +49,18 @@ impl<'program, 'arena, 'loan, 'ctx> OriginalMoePromptLayer<'program, 'arena, 'lo self.completed_experts = self.order.len(); Ok(()) } + /// EXPERIMENTAL (`LELEKA_PREFILL_RING_PREFETCH`, docs/experiments/ring-prefetch.md): after this layer's copy ring + /// drained, copy the experts `layer` (the next one) is predicted to miss into its ring's stage slots, through this + /// layer's row lease. Returns how many were copied; never fails (the next ring copies whatever is missing). + pub fn prefetch_ring_layer( + &self, + schedule: &mut crate::OriginalMmqCopySchedule<'ctx>, + bank: &std::rc::Rc>, + layer: usize, + sources: impl FnMut(u32) -> crate::PrefetchSource, + ) -> usize { + schedule.prefetch_ring_layer(crate::PrefetchTarget { read: &self.read, bank, layer }, sources) + } pub fn execute_mmq( &mut self, workspace: &mut MmqWorkspace<'ctx>, diff --git a/crates/cuda-driver/src/original_mtp_actor_loaded/original_mtp_actor/original_mtp_actor_adopt_loaded.rs b/crates/cuda-driver/src/original_mtp_actor_loaded/original_mtp_actor/original_mtp_actor_adopt_loaded.rs index c11d6e54..7afe2a7f 100644 --- a/crates/cuda-driver/src/original_mtp_actor_loaded/original_mtp_actor/original_mtp_actor_adopt_loaded.rs +++ b/crates/cuda-driver/src/original_mtp_actor_loaded/original_mtp_actor/original_mtp_actor_adopt_loaded.rs @@ -216,6 +216,11 @@ impl<'ctx> OriginalMtpActor<'ctx> { self.drafter.as_mut().ok_or(Error::ContextPoisoned)?.release_verifier_bindings() } + /// The end of a request over a verifier bank that stays (see `OriginalMtpDrafter::end_request_keep_bank`). + pub fn end_request_keep_bank(&mut self) -> Result<()> { + self.drafter.as_mut().ok_or(Error::ContextPoisoned)?.end_request_keep_bank() + } + /// `kv_restore(upto)`: refill the draft ring's window for a sequence that /// continues at `upto` from the host pages `prior` authenticates. A no-op /// when the ring is fully resident, exactly as in Original. diff --git a/crates/cuda-driver/src/original_prefill_layout.rs b/crates/cuda-driver/src/original_prefill_layout.rs index 0a30a14e..c646c3be 100644 --- a/crates/cuda-driver/src/original_prefill_layout.rs +++ b/crates/cuda-driver/src/original_prefill_layout.rs @@ -19,7 +19,9 @@ const MMQ_GROUP: usize = 16; const MMQ_TAIL: usize = 4096; mod carve_parts; +mod mmq_identity; use carve_parts::{merge_spans, take_kv_int8, take_kv_q4, take_ple}; +use mmq_identity::mmq_identity_words; #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum PrefillPhase { @@ -327,7 +329,7 @@ impl PrefillLayoutOptions { fn take_mmq_groups(&self, a: &mut Alloc, t: usize) -> Result<()> { if self.mmq_any { - a.rows("ids_identity", t, K, 4)?; + a.take("ids_identity", mmq_identity_words(t)?, 4)?; let bounds = self.mmq_bounds_words()?; a.take("bounds_dev", bounds, 4)?; for (name, max) in [("grp_gu", self.mmq_gu_max), ("grp_d", self.mmq_down_max)] { diff --git a/crates/cuda-driver/src/original_prefill_layout/mmq_identity.rs b/crates/cuda-driver/src/original_prefill_layout/mmq_identity.rs new file mode 100644 index 00000000..174c48a1 --- /dev/null +++ b/crates/cuda-driver/src/original_prefill_layout/mmq_identity.rs @@ -0,0 +1,35 @@ +//! Size of the identity row table of the prompt MMQ launches (ledger row U3). + +#[allow(unused_imports)] +use super::*; + +/// Widest column tile of the grouped MMQ launches (ggml `mul_mat_q_switch_J`: J = 8 .. 128 in steps of 8). +const MMQ_TILE_COLS_MAX: usize = 128; + +/// Entries of the identity row table of the prompt MMQ launches: the `t * K` routed rows plus the margin that the +/// stream-k fixup (`mul_mat_q_stream_k_fixup`) reads past them. It loads `ids_dst[col_low + jt * J + j]` for a whole +/// J-column tile before it compares the tile with the expert's rows, and a tile runs to `ceil(max_rows / J) * J` with +/// `max_rows <= t` (an expert takes at most one row per token), so the table needs `roundup(t, J) + J` more entries +/// for the widest J (upstream Strata `f225844d1`). The values past `t * K` are never routed to: results are unchanged. +pub(super) fn mmq_identity_words(t: usize) -> Result { + let tile_rounded = add(t, MMQ_TILE_COLS_MAX - 1)? / MMQ_TILE_COLS_MAX * MMQ_TILE_COLS_MAX; + add(add(mul(t, K)?, tile_rounded)?, MMQ_TILE_COLS_MAX) +} + +#[cfg(test)] +mod mmq_identity_margin_tests { + use super::*; + + #[test] + fn the_identity_table_covers_every_index_the_stream_k_fixup_can_read() { + for t in [1usize, 7, 127, 128, 129, 1000, 8192] { + let words = mmq_identity_words(t).unwrap(); + // the last column tile of the widest J starts below t and ends at roundup(t, J); the table index adds the + // experts' column offset, which is at most t * K - 1 + let last_read = t * K - 1 + t.div_ceil(MMQ_TILE_COLS_MAX) * MMQ_TILE_COLS_MAX; + assert!(last_read < words, "t {t}: reads index {last_read}, table has {words} entries"); + assert!(words > t * K, "t {t}: no margin"); + } + assert!(mmq_identity_words(usize::MAX / 4).is_err(), "a size that does not fit must fail, not wrap"); + } +} diff --git a/crates/cuda-driver/src/original_verify_gpu_plan.rs b/crates/cuda-driver/src/original_verify_gpu_plan.rs index 3b8cd7d3..a5f96a9b 100644 --- a/crates/cuda-driver/src/original_verify_gpu_plan.rs +++ b/crates/cuda-driver/src/original_verify_gpu_plan.rs @@ -62,6 +62,8 @@ pub(crate) use original_verify_gpu_plan_methods::{PlanEntryShape, encode_plan_bl mod cpu_sink_publish_gpu_plan; #[path = "original_verify_gpu_plan/plan_phases.rs"] mod plan_phases; +#[path = "original_verify_gpu_plan/plan_tier_tally.rs"] +mod plan_tier_tally; #[allow(unused_imports)] pub(crate) use cpu_sink_publish_gpu_plan::dma_options; #[path = "original_verify_gpu_plan/dma_options_for.rs"] diff --git a/crates/cuda-driver/src/original_verify_gpu_plan/cpu_sink_publish_gpu_plan.rs b/crates/cuda-driver/src/original_verify_gpu_plan/cpu_sink_publish_gpu_plan.rs index 22684db2..e83f15d3 100644 --- a/crates/cuda-driver/src/original_verify_gpu_plan/cpu_sink_publish_gpu_plan.rs +++ b/crates/cuda-driver/src/original_verify_gpu_plan/cpu_sink_publish_gpu_plan.rs @@ -44,6 +44,7 @@ impl<'ctx> schedule::OriginalVerifyCpuSink<'_, 'ctx> { copy: &mut OriginalGpuStream<'ctx>, ) -> Result<()> { let (layout, cap, ids) = self.plan_preflight(cache, copy)?; + super::plan_tier_tally::tally(self.layer, plan, &ids); let vram = self.plan_vram(plan, cache, &ids)?; let stride = self.check_pcie(plan, pcie.as_ref(), &ids)?; let staging = self.staging_base(plan)?; diff --git a/crates/cuda-driver/src/original_verify_gpu_plan/plan_tier_tally.rs b/crates/cuda-driver/src/original_verify_gpu_plan/plan_tier_tally.rs new file mode 100644 index 00000000..7bb52ab1 --- /dev/null +++ b/crates/cuda-driver/src/original_verify_gpu_plan/plan_tier_tally.rs @@ -0,0 +1,171 @@ +//! Profile-only tally of the tier legs of every verify layer group (`LELEKA_SERVE_PROFILE=1`): per layer, how many +//! distinct routed experts the window used and how they split between the VRAM tier, the PCIe share and the CPU +//! pool. The value of `tier.lNN.vram|pcie|cpu` is an expert count (the profile prints `value/windows`); nothing +//! here changes what the plan does. Ledger V5/V7: which layers carry the CPU/PCIe legs. +use super::OriginalVerifyGpuPlan; +use crate::host_profile; + +const VRAM: [&str; 48] = [ + "tier.l00.vram", + "tier.l01.vram", + "tier.l02.vram", + "tier.l03.vram", + "tier.l04.vram", + "tier.l05.vram", + "tier.l06.vram", + "tier.l07.vram", + "tier.l08.vram", + "tier.l09.vram", + "tier.l10.vram", + "tier.l11.vram", + "tier.l12.vram", + "tier.l13.vram", + "tier.l14.vram", + "tier.l15.vram", + "tier.l16.vram", + "tier.l17.vram", + "tier.l18.vram", + "tier.l19.vram", + "tier.l20.vram", + "tier.l21.vram", + "tier.l22.vram", + "tier.l23.vram", + "tier.l24.vram", + "tier.l25.vram", + "tier.l26.vram", + "tier.l27.vram", + "tier.l28.vram", + "tier.l29.vram", + "tier.l30.vram", + "tier.l31.vram", + "tier.l32.vram", + "tier.l33.vram", + "tier.l34.vram", + "tier.l35.vram", + "tier.l36.vram", + "tier.l37.vram", + "tier.l38.vram", + "tier.l39.vram", + "tier.l40.vram", + "tier.l41.vram", + "tier.l42.vram", + "tier.l43.vram", + "tier.l44.vram", + "tier.l45.vram", + "tier.l46.vram", + "tier.l47.vram", +]; +const PCIE: [&str; 48] = [ + "tier.l00.pcie", + "tier.l01.pcie", + "tier.l02.pcie", + "tier.l03.pcie", + "tier.l04.pcie", + "tier.l05.pcie", + "tier.l06.pcie", + "tier.l07.pcie", + "tier.l08.pcie", + "tier.l09.pcie", + "tier.l10.pcie", + "tier.l11.pcie", + "tier.l12.pcie", + "tier.l13.pcie", + "tier.l14.pcie", + "tier.l15.pcie", + "tier.l16.pcie", + "tier.l17.pcie", + "tier.l18.pcie", + "tier.l19.pcie", + "tier.l20.pcie", + "tier.l21.pcie", + "tier.l22.pcie", + "tier.l23.pcie", + "tier.l24.pcie", + "tier.l25.pcie", + "tier.l26.pcie", + "tier.l27.pcie", + "tier.l28.pcie", + "tier.l29.pcie", + "tier.l30.pcie", + "tier.l31.pcie", + "tier.l32.pcie", + "tier.l33.pcie", + "tier.l34.pcie", + "tier.l35.pcie", + "tier.l36.pcie", + "tier.l37.pcie", + "tier.l38.pcie", + "tier.l39.pcie", + "tier.l40.pcie", + "tier.l41.pcie", + "tier.l42.pcie", + "tier.l43.pcie", + "tier.l44.pcie", + "tier.l45.pcie", + "tier.l46.pcie", + "tier.l47.pcie", +]; +const CPU: [&str; 48] = [ + "tier.l00.cpu", + "tier.l01.cpu", + "tier.l02.cpu", + "tier.l03.cpu", + "tier.l04.cpu", + "tier.l05.cpu", + "tier.l06.cpu", + "tier.l07.cpu", + "tier.l08.cpu", + "tier.l09.cpu", + "tier.l10.cpu", + "tier.l11.cpu", + "tier.l12.cpu", + "tier.l13.cpu", + "tier.l14.cpu", + "tier.l15.cpu", + "tier.l16.cpu", + "tier.l17.cpu", + "tier.l18.cpu", + "tier.l19.cpu", + "tier.l20.cpu", + "tier.l21.cpu", + "tier.l22.cpu", + "tier.l23.cpu", + "tier.l24.cpu", + "tier.l25.cpu", + "tier.l26.cpu", + "tier.l27.cpu", + "tier.l28.cpu", + "tier.l29.cpu", + "tier.l30.cpu", + "tier.l31.cpu", + "tier.l32.cpu", + "tier.l33.cpu", + "tier.l34.cpu", + "tier.l35.cpu", + "tier.l36.cpu", + "tier.l37.cpu", + "tier.l38.cpu", + "tier.l39.cpu", + "tier.l40.cpu", + "tier.l41.cpu", + "tier.l42.cpu", + "tier.l43.cpu", + "tier.l44.cpu", + "tier.l45.cpu", + "tier.l46.cpu", + "tier.l47.cpu", +]; + +/// Adds the expert counts of one layer group; a no-op unless the profile is on. +pub(super) fn tally(layer: usize, plan: &OriginalVerifyGpuPlan, ids: &[i32]) { + if !host_profile::enabled() || layer >= VRAM.len() { + return; + } + let mut distinct = ids.to_vec(); + distinct.sort_unstable(); + distinct.dedup(); + let (vram, pcie) = (plan.vram.len(), plan.pcie.len()); + host_profile::add(VRAM[layer], vram as f64); + host_profile::add(PCIE[layer], pcie as f64); + host_profile::add(CPU[layer], distinct.len().saturating_sub(vram + pcie) as f64); +} diff --git a/crates/cuda-driver/src/original_verify_window_ops.rs b/crates/cuda-driver/src/original_verify_window_ops.rs index de81f8da..89582823 100644 --- a/crates/cuda-driver/src/original_verify_window_ops.rs +++ b/crates/cuda-driver/src/original_verify_window_ops.rs @@ -29,8 +29,8 @@ use super::planner::{Planner, WindowWeights}; use super::proj::{self, GdnProjectionAddrs, OriginalVerifyProjBinding, QsaProjectionAddrs}; use super::qsa::{self, OriginalVerifyQsaBinding, OriginalVerifyQsaKvBinding, QsaLayerAddrs, QsaRope}; use super::sm120; -use super::window_plan::{gdn_index, qsa_layer}; use super::window_plan::{PlanLayout, WINDOW_LAYERS, staging_blobs_per_group}; +use super::window_plan::{gdn_index, qsa_layer}; use super::window_record::{ExpertTier, HcHalf, Projection, QuantSource, Rows, WindowOps, WindowPolicy, record_window}; use super::*; use crate::{OriginalNativeEmbedRows, OriginalNativeHeadGraphResources}; diff --git a/crates/cuda-driver/src/owner_loan.rs b/crates/cuda-driver/src/owner_loan.rs new file mode 100644 index 00000000..6fbbbef5 --- /dev/null +++ b/crates/cuda-driver/src/owner_loan.rs @@ -0,0 +1,123 @@ +//! Bookkeeping of the loan of the twelve resident QSA owners (`OriginalVerifyQsaJournal::lend` / `take_back`). +//! +//! A captured window graph holds the device and mapped-host addresses of the owners' buffers. The journal that the +//! graphs retain may hand the owners back to the prompt executor between two requests, without dropping the graphs, but +//! only on one condition: what returns is the same set of buffers at the same addresses. The loan records a fingerprint +//! of those addresses when it lends and compares it when the owners come back. Any difference - or any later use of a +//! failed loan - is final: the journal is failed and the graph set that retains it must be retired, never replayed. +//! This module is the pure state machine; the journal supplies the fingerprints. + +/// Why a loan step was refused. +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub(crate) enum LoanError { + /// The owners are already out. + AlreadyLent, + /// The owners are home: nothing to take back. + NotLent, + /// The returned owners are not the lent ones (an address changed, or the fingerprint could not be taken). + Changed, + /// An earlier step failed the loan for good. + Failed, +} + +#[derive(Debug)] +enum State { + Home, + Lent(F), + Failed, +} + +/// Home, lent with the fingerprint of the owners that left, or failed. +#[derive(Debug)] +pub(crate) struct OwnerLoan { + state: State, +} + +impl OwnerLoan { + pub(crate) fn new() -> Self { + Self { state: State::Home } + } + + pub(crate) fn is_lent(&self) -> bool { + matches!(self.state, State::Lent(_)) + } + + #[cfg(test)] + pub(crate) fn is_failed(&self) -> bool { + matches!(self.state, State::Failed) + } + + /// The owners leave with `fingerprint`. + pub(crate) fn lend(&mut self, fingerprint: F) -> Result<(), LoanError> { + match self.state { + State::Home => { + self.state = State::Lent(fingerprint); + Ok(()) + } + State::Lent(_) => Err(LoanError::AlreadyLent), + State::Failed => Err(LoanError::Failed), + } + } + + /// The owners are about to return; `now` is the fingerprint of the ones that come back (`None`: it could not be + /// taken). Equal: the loan ends. Anything else fails it for good. + pub(crate) fn take_back(&mut self, now: Option) -> Result<(), LoanError> { + match &self.state { + State::Home => Err(LoanError::NotLent), + State::Failed => Err(LoanError::Failed), + State::Lent(lent) if now.as_ref() == Some(lent) => { + self.state = State::Home; + Ok(()) + } + State::Lent(_) => { + self.state = State::Failed; + Err(LoanError::Changed) + } + } + } + + /// Fail the loan (the journal itself failed). + pub(crate) fn fail(&mut self) { + self.state = State::Failed; + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn owners_that_come_back_at_the_same_addresses_end_the_loan() { + let mut loan = OwnerLoan::new(); + assert!(!loan.is_lent()); + loan.lend([1u64, 2, 3]).unwrap(); + assert!(loan.is_lent()); + loan.take_back(Some([1, 2, 3])).unwrap(); + assert!(!loan.is_lent() && !loan.is_failed()); + loan.lend([1, 2, 3]).unwrap(); + } + + #[test] + fn a_changed_address_or_a_missing_fingerprint_fails_the_loan_for_good() { + for now in [Some([1u64, 2, 4]), None] { + let mut loan = OwnerLoan::new(); + loan.lend([1u64, 2, 3]).unwrap(); + assert_eq!(loan.take_back(now), Err(LoanError::Changed)); + assert!(loan.is_failed()); + assert_eq!(loan.lend([1, 2, 3]), Err(LoanError::Failed)); + assert_eq!(loan.take_back(Some([1, 2, 3])), Err(LoanError::Failed)); + } + } + + #[test] + fn the_steps_out_of_order_are_refused_and_change_nothing() { + let mut loan = OwnerLoan::new(); + assert_eq!(loan.take_back(Some(7u32)), Err(LoanError::NotLent)); + loan.lend(7).unwrap(); + assert_eq!(loan.lend(7), Err(LoanError::AlreadyLent)); + assert!(loan.is_lent() && !loan.is_failed()); + loan.take_back(Some(7)).unwrap(); + loan.fail(); + assert!(loan.is_failed()); + } +} diff --git a/crates/cuda-driver/src/ple_batch_ffi.rs b/crates/cuda-driver/src/ple_batch_ffi.rs index 8609f93e..113f7082 100644 --- a/crates/cuda-driver/src/ple_batch_ffi.rs +++ b/crates/cuda-driver/src/ple_batch_ffi.rs @@ -63,6 +63,14 @@ impl LinearLaunch { Self { grid, block, stream } } } +/// What a kernel module's host code needs to know about the current device: compute capability major, multiprocessor +/// count and the opt-in limit of dynamic shared memory a block. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub(crate) struct DeviceGeometry { + pub(crate) cc_major: u32, + pub(crate) multiprocessors: u32, + pub(crate) shared_optin: u32, +} /// The grid `[x, y]`, `block` threads, cluster width and dynamic shared memory of one cluster launch. #[derive(Clone, Copy)] pub(crate) struct ClusterShape { diff --git a/crates/cuda-driver/src/ple_batch_ffi/enabled/kernel_module_launch_and_close.rs b/crates/cuda-driver/src/ple_batch_ffi/enabled/kernel_module_launch_and_close.rs index 165fe8a2..420bd263 100644 --- a/crates/cuda-driver/src/ple_batch_ffi/enabled/kernel_module_launch_and_close.rs +++ b/crates/cuda-driver/src/ple_batch_ffi/enabled/kernel_module_launch_and_close.rs @@ -79,18 +79,63 @@ impl KernelModule { Ok(()) } pub(crate) fn launch(&self, index: usize, launch: LinearLaunch, args: &mut KernelArguments) -> Result<()> { + self.launch_dynamic(index, launch, 0, args) + } + /// `launch` with `smem` bytes of dynamic shared memory. Above the 48 KiB default the function is first opted in + /// with `cuFuncSetAttribute(MAX_DYNAMIC_SHARED_SIZE_BYTES)` (the device's opt-in limit is the caller's check). + pub(crate) fn launch_dynamic( + &self, + index: usize, + launch: LinearLaunch, + smem: u32, + args: &mut KernelArguments, + ) -> Result<()> { let LinearLaunch { grid, block, stream } = launch; if grid == 0 || !matches!(block, 128 | 256 | 512 | 1024) || stream == 0 { return Err(Error::InvalidQwenShape); } let function = *self.functions.get(index).ok_or(Error::UnsupportedQwenOperation)?; + if smem > 48 * 1024 { + self.allow_dynamic_shared(function, smem)?; + } args.pack()?; // SAFETY: owned boxed command fields and exact producer-declared // ABI persist until drain; Driver copies the parameter pointer array // during this call. No pointer/entry escapes to public callers. let (function, stream, pointers) = (function as *mut c_void, stream as *mut c_void, args.pointers.as_mut_ptr()); check("cuLaunchKernel", unsafe { - (self.launch)(function, grid, 1, 1, block, 1, 1, 0, stream, pointers, std::ptr::null_mut()) + (self.launch)(function, grid, 1, 1, block, 1, 1, smem, stream, pointers, std::ptr::null_mut()) + }) + } + /// `cuFuncSetAttribute(MAX_DYNAMIC_SHARED_SIZE_BYTES, smem)` of one function of this module. + fn allow_dynamic_shared(&self, function: usize, smem: u32) -> Result<()> { + let library = self._library.as_ref().ok_or(Error::LibraryUnavailable)?; + let set_attribute = symbol!(library, c"cuFuncSetAttribute", FuncSetAttribute); + let attribute = crate::launch_ex::FUNC_ATTRIBUTE_MAX_DYNAMIC_SHARED; + // SAFETY: the function belongs to this live module and the context is current (the launch contract). + check("cuFuncSetAttribute", unsafe { set_attribute(function as *mut c_void, attribute, smem as c_int) }) + } + /// Compute capability, multiprocessor count and opt-in shared memory of the device that is current (the caller runs + /// inside `Context::enter`). + pub(crate) fn device_geometry(&self) -> Result { + type CtxGetDevice = unsafe extern "C" fn(*mut c_int) -> c_int; + type DeviceAttribute = unsafe extern "C" fn(*mut c_int, c_int, c_int) -> c_int; + let library = self._library.as_ref().ok_or(Error::LibraryUnavailable)?; + let device = symbol!(library, c"cuCtxGetDevice", CtxGetDevice); + let attribute = symbol!(library, c"cuDeviceGetAttribute", DeviceAttribute); + let mut d: c_int = 0; + // SAFETY: a valid out-pointer to a live local; a current context is the caller's precondition. + check("cuCtxGetDevice", unsafe { device(&mut d) })?; + let read = |id: c_int, what: &'static str| -> Result { + let mut value: c_int = 0; + // SAFETY: valid out-pointer to a live local and the device just returned by the driver. + check(what, unsafe { attribute(&mut value, id, d) })?; + u32::try_from(value).map_err(|_| Error::InvalidDriverValue(what)) + }; + Ok(crate::ple_batch_ffi::DeviceGeometry { + cc_major: read(75, "cuDeviceGetAttribute(compute capability major)")?, + multiprocessors: read(16, "cuDeviceGetAttribute(multiprocessors)")?, + shared_optin: read(97, "cuDeviceGetAttribute(shared memory opt-in)")?, }) } /// `cuLaunchKernelEx` with a thread-block cluster (sm_90+): grid `[x, y, 1]`, `block` threads, cluster `[cx, 1, diff --git a/crates/cuda-driver/src/ple_batch_ffi/kernel_arguments.rs b/crates/cuda-driver/src/ple_batch_ffi/kernel_arguments.rs index 6236943a..1cbd6a85 100644 --- a/crates/cuda-driver/src/ple_batch_ffi/kernel_arguments.rs +++ b/crates/cuda-driver/src/ple_batch_ffi/kernel_arguments.rs @@ -55,6 +55,12 @@ impl KernelModule { pub(crate) fn launch_cluster(&self, _: usize, _: ClusterShape, _: usize, _: &mut KernelArguments) -> Result<()> { Err(Error::UnsupportedPlatform) } + pub(crate) fn launch_dynamic(&self, _: usize, _: LinearLaunch, _: u32, _: &mut KernelArguments) -> Result<()> { + Err(Error::UnsupportedPlatform) + } + pub(crate) fn device_geometry(&self) -> Result { + Err(Error::UnsupportedPlatform) + } pub(crate) fn close(self) -> Result<()> { Ok(()) } diff --git a/crates/cuda-driver/src/prefill_stage_gdn_gpu.rs b/crates/cuda-driver/src/prefill_stage_gdn_gpu.rs index d30112f0..43381329 100644 --- a/crates/cuda-driver/src/prefill_stage_gdn_gpu.rs +++ b/crates/cuda-driver/src/prefill_stage_gdn_gpu.rs @@ -32,3 +32,5 @@ use enable_types::Rng; mod gdn_recurrence_equals_the_original; #[path = "prefill_stage_gdn_gpu/gdn_stage_kernels_equal.rs"] mod gdn_stage_kernels_equal; +#[path = "prefill_stage_gdn_gpu/gdn_tensor_core_scan_parity.rs"] +mod gdn_tensor_core_scan_parity; diff --git a/crates/cuda-driver/src/prefill_stage_gdn_gpu/gdn_tensor_core_scan_parity.rs b/crates/cuda-driver/src/prefill_stage_gdn_gpu/gdn_tensor_core_scan_parity.rs new file mode 100644 index 00000000..134ed0f1 --- /dev/null +++ b/crates/cuda-driver/src/prefill_stage_gdn_gpu/gdn_tensor_core_scan_parity.rs @@ -0,0 +1,366 @@ +//! GPU parity of the EXPERIMENTAL tensor-core scan of the prompt GDN recurrence (`gdn_prefill_tc.cu`, ledger row U1) +//! against the sequential `leleka_prefill_gdn_rec` kernel (bit-identical to the Original's recurrence). The scan is +//! LOSSY by design: this test is the upstream harness's gate (1e-4 absolute / relative, `gdn_rec_parity`), not an +//! identity probe, and the quality gate of docs/quality-gate.md decides whether it may ever be used. Needs a CUDA +//! device with compute capability 12 and no model: +//! LELEKA_PREFILL_STAGE_GPU=yes cargo test -p leleka-cuda-driver --features cuda-driver --release --lib \ +//! gdn_tensor_core_scan -- --ignored --nocapture +//! Every case is run and printed before the verdict, so one run shows all failures (`PREFILL-GDN-TC` lines). + +use super::gdn_recurrence_equals_the_original::{Rig, with_rig}; +#[allow(unused_imports)] +use super::*; +use crate::gdn_prefill_tc as tc; +use crate::ple_batch_ffi::LinearLaunch; + +const STATE_LEN: usize = 128 * 48 * 128; +/// The prompt device's dequantization scratch the scan runs in. +const SCRATCH: usize = 52_428_800; +/// Upstream's gate: |scan - sequential| <= 1e-4 max(1, |sequential|), element by element. +const TOLERANCE: f32 = 1e-4; +/// Ill-conditioned inputs (identical keys, no decay): T = (I + A)^-1 grows; reported, with a looser bound. +const STRESS_TOLERANCE: f32 = 1e-3; + +/// What a case feeds the recurrence. +#[derive(Clone, Copy, Debug, PartialEq)] +enum Inputs { + /// Unit q/k, decay exp(-0.02..-0.7), beta 0.05..1, v and state O(1): the shape of a real prompt. + Typical, + /// Almost no decay and beta near 1: the state keeps everything it was given. + NoDecay, + /// v 8x and the state 4x larger than typical (the per-chunk power-of-two scales move). + Large, + /// Every token of a key head has (almost) the same k, beta 1, no decay: T = (I + A)^-1 spans 2^30. + CollinearKeys, + /// One infinite value in the prior state: both kernels must raise the witness. + InfiniteState, +} + +impl Inputs { + fn stress(self) -> bool { + matches!(self, Self::CollinearKeys | Self::NoDecay) + } +} + +/// A unit vector of `n` values from the generator (the L2 norm of the real chain). +fn unit(rng: &mut Rng, out: &mut [f32]) { + out.iter_mut().for_each(|x| *x = rng.f(1.0)); + let norm = out.iter().map(|x| x * x).sum::().sqrt().max(1e-6); + out.iter_mut().for_each(|x| *x /= norm); +} + +/// One run's inputs on the host: state [128][48][128], h [t][10240] (q | k | v), gate and beta [t][48]. +struct Host { + state: Vec, + h: Vec, + gate: Vec, + beta: Vec, +} + +fn generate(rng: &mut Rng, t: usize, kind: Inputs) -> Host { + let (state_scale, v_scale) = if kind == Inputs::Large { (4.0, 8.0) } else { (0.5, 1.0) }; + let mut state: Vec = (0..STATE_LEN).map(|_| rng.f(state_scale)).collect(); + if kind == Inputs::InfiniteState { + state[1234] = f32::INFINITY; + } + let mut h = vec![0.0f32; t * 10240]; + let first_k: Vec = (0..16 * 128).map(|_| rng.f(1.0)).collect(); + for row in h.chunks_mut(10240) { + for head in 0..16 { + unit(rng, &mut row[head * 128..(head + 1) * 128]); + let k = &mut row[2048 + head * 128..2048 + (head + 1) * 128]; + unit(rng, k); + if kind == Inputs::CollinearKeys { + k.iter_mut().zip(&first_k[head * 128..]).for_each(|(x, f)| *x = f + 1e-3 * *x); + let norm = k.iter().map(|x| x * x).sum::().sqrt(); + k.iter_mut().for_each(|x| *x /= norm); + } + } + row[4096..].iter_mut().for_each(|x| *x = rng.f(v_scale)); + } + let (gate, beta) = match kind { + Inputs::NoDecay | Inputs::CollinearKeys => (vec![-1e-3; t * 48], vec![0.95; t * 48]), + _ => ( + (0..t * 48).map(|_| -0.02 - rng.f(0.34).abs() * 2.0).collect(), + (0..t * 48).map(|_| 0.05 + (rng.f(0.5) + 0.5).abs() * 0.95).collect(), + ), + }; + Host { state, h, gate, beta } +} + +/// The device side of one case; `_s` the sequential kernel's outputs, `_t` the scan's. +struct Device<'c> { + sin: DeviceBuffer<'c>, + h: DeviceBuffer<'c>, + gate: DeviceBuffer<'c>, + beta: DeviceBuffer<'c>, + sout_s: DeviceBuffer<'c>, + sout_t: DeviceBuffer<'c>, + y_s: DeviceBuffer<'c>, + y_t: DeviceBuffer<'c>, + w_s: DeviceBuffer<'c>, + w_t: DeviceBuffer<'c>, + scratch: DeviceBuffer<'c>, +} + +impl<'c> Device<'c> { + fn new(context: &'c Context<'c>, host: &Host, t: usize) -> Self { + let zero = |bytes: usize| upload(context, &vec![0u8; bytes]); + Self { + sin: upload(context, &f32_bytes(&host.state)), + h: upload(context, &f32_bytes(&host.h)), + gate: upload(context, &f32_bytes(&host.gate)), + beta: upload(context, &f32_bytes(&host.beta)), + sout_s: zero(STATE_LEN * 4), + sout_t: zero(STATE_LEN * 4), + y_s: zero(t * 6144 * 4), + y_t: zero(t * 6144 * 4), + w_s: zero(16), + w_t: zero(16), + scratch: context.allocate(SCRATCH).expect("scratch"), + } + } + fn io(&self) -> tc::RecurrenceIo { + tc::RecurrenceIo { + state_in: hd(&self.sin), + state_out: hd(&self.sout_t), + h: hd(&self.h), + gate: hd(&self.gate), + beta: hd(&self.beta), + y: hd(&self.y_t), + witness: hd(&self.w_t), + scratch: hd(&self.scratch), + } + } + /// A sequential kernel (`entry` of the stage module, `grid` blocks of 128 threads) into the `_s` buffers. + fn run_sequential(&self, rig: &Rig<'_>, t: usize, (entry, grid): (usize, u32)) { + let mut args = KernelArguments::new(vec![ + A::Address(hd(&self.sin)), + A::Address(hd(&self.sout_s)), + A::Address(hd(&self.h)), + A::Address(hd(&self.gate)), + A::Address(hd(&self.beta)), + A::Address(hd(&self.y_s)), + A::I64(t as i64), + A::Address(hd(&self.w_s)), + ]); + let guard = rig.context.enter().expect("enter"); + let launch = LinearLaunch::new(grid, 128, rig.stream); + rig.stage.launch(entry, launch, &mut args).expect("launch sequential"); + rig.context.driver.api.synchronize().expect("sync"); + guard.finish().expect("finish"); + } + /// The prep and scan launches of the plan into the `_t` buffers, `reps` times (the state is re-read from `sin`). + fn run_scan(&self, (rig, module): (&Rig<'_>, &KernelModule), plan: &tc::ScanPlan, (t, reps): (usize, usize)) { + let guard = rig.context.enter().expect("enter"); + let mut keep = Vec::new(); + for _ in 0..reps { + for l in tc::launches(plan, &self.io(), (SCRATCH, t)).expect("launches") { + let mut args = KernelArguments::new(l.args); + let launch = LinearLaunch::new(l.grid, l.block, rig.stream); + module.launch_dynamic(l.entry, launch, l.smem, &mut args).expect("launch scan"); + keep.push(args); + } + } + rig.context.driver.api.synchronize().expect("sync"); + guard.finish().expect("finish"); + } +} + +/// Worst element of one tensor against the gate `|a - b| <= tolerance max(1, |b|)`. +#[derive(Default, Clone, Copy)] +struct Worst { + /// the largest |a - b| / max(1, |b|) + scaled: f32, + /// the largest |b| + reference: f32, + non_finite: usize, +} + +fn compare(scan: &[u8], reference: &[u8]) -> Worst { + let to_f32 = |b: &[u8]| -> Vec { b.chunks(4).map(|c| f32::from_le_bytes(c.try_into().unwrap())).collect() }; + let (a, b) = (to_f32(scan), to_f32(reference)); + let mut worst = Worst::default(); + for (x, y) in a.iter().zip(&b) { + if !x.is_finite() || !y.is_finite() { + worst.non_finite += usize::from(x.is_finite() != y.is_finite()); + continue; + } + worst.scaled = worst.scaled.max((x - y).abs() / y.abs().max(1.0)); + worst.reference = worst.reference.max(y.abs()); + } + worst +} + +/// One row of the table. +struct Row { + label: String, + readout: Worst, + state: Worst, + witness: (u32, u32), + tolerance: f32, +} + +impl Row { + fn failure(&self, kind: Inputs) -> Option { + let (w_scan, w_ref) = self.witness; + let expect_bad = kind == Inputs::InfiniteState; + if (w_ref != 0) != expect_bad || (w_scan != 0) != expect_bad { + return Some(format!("witness scan {w_scan} sequential {w_ref} (expected {})", u32::from(expect_bad))); + } + if expect_bad { + return None; + } + let bad = |w: &Worst| w.scaled > self.tolerance || w.non_finite > 0; + (bad(&self.readout) || bad(&self.state)).then(|| "beyond the gate".to_string()) + } +} + +/// One token count, one input kind, one plan: the sequential kernel, then the scan, then the comparison. +fn case(rig: &Rig<'_>, module: &KernelModule, host_of: (&Host, Inputs), (t, plan): (usize, &tc::ScanPlan)) -> Row { + let (host, kind) = host_of; + let device = Device::new(rig.context, host, t); + device.run_sequential(rig, t, (crate::prefill_stage::GDN_REC, 192)); + device.run_scan((rig, module), plan, (t, 1)); + let readout = compare(&download(&device.y_t, t * 6144 * 4), &download(&device.y_s, t * 6144 * 4)); + let state = compare(&download(&device.sout_t, STATE_LEN * 4), &download(&device.sout_s, STATE_LEN * 4)); + Row { + label: format!("t={t} {kind:?} tiles={} chunks/block={}", plan.tiles(), plan.chunks()), + readout, + state, + witness: (words(&device.w_t, 1)[0], words(&device.w_s, 1)[0]), + tolerance: if kind.stress() { STRESS_TOLERANCE } else { TOLERANCE }, + } +} + +fn print(row: &Row) { + let w = |w: &Worst| format!("{:.2e} (max|ref| {:.3}, {} non-finite)", w.scaled, w.reference, w.non_finite); + eprintln!( + "PREFILL-GDN-TC {}: readout {} state {} witness scan {} seq {} gate {:.0e}", + row.label, + w(&row.readout), + w(&row.state), + row.witness.0, + row.witness.1, + row.tolerance + ); +} + +/// The device's plan, or None (with the reason printed) when this card cannot run the asset. +fn device_plan(module: &KernelModule, rig: &Rig<'_>) -> Option { + let guard = rig.context.enter().expect("enter"); + let geometry = module.device_geometry().expect("device geometry"); + guard.finish().expect("finish"); + match tc::plan(true, geometry, SCRATCH) { + Ok(plan) => Some(plan), + Err(refusal) => { + eprintln!("PREFILL-GDN-TC skipped: {refusal} ({geometry:?})"); + None + } + } +} + +fn load_module(rig: &Rig<'_>) -> KernelModule { + tc::admit().expect("gdn_prefill_tc.ptx must match its pin"); + let guard = rig.context.enter().expect("enter"); + let module = KernelModule::load(tc::PTX, tc::ENTRIES).expect("tensor-core scan module"); + guard.finish().expect("finish"); + module +} + +/// Token counts of the gate: every chunk edge near 32, 128 (the dispatch minimum), the super-block edge of the +/// scratch (1,760) and of upstream's 2,048, the harness's 4,099 and a full 8,192-token prompt chunk, then eight +/// pseudo-random lengths up to 4,099. +fn token_counts(rng: &mut Rng) -> Vec { + let mut counts = vec![ + 1, 2, 31, 32, 33, 63, 64, 65, 127, 128, 129, 200, 255, 256, 257, 1000, 1759, 1760, 1761, 2047, 2048, 2049, + 3520, 3521, 4096, 4097, 4099, 8192, + ]; + counts.extend((0..8).map(|_| 1 + (rng.next() % 4099) as usize)); + counts +} + +/// The cases run so far, and what they run on. +struct Gate<'a> { + rig: &'a Rig<'a>, + module: KernelModule, + rng: Rng, + table: Vec<(Row, Inputs)>, +} + +impl Gate<'_> { + fn run(&mut self, t: usize, kind: Inputs, plan: &tc::ScanPlan) { + let host = generate(&mut self.rng, t, kind); + let row = case(self.rig, &self.module, (&host, kind), (t, plan)); + print(&row); + self.table.push((row, kind)); + } + /// Typical inputs, every length, both value-tile plans of the 99-KB card. + fn typical_lengths(&mut self, plan: &tc::ScanPlan) { + for t in token_counts(&mut self.rng) { + for tiles in [1, 2] { + self.run(t, Inputs::Typical, &plan.with_tiles(tiles)); + } + } + // small super-blocks chain the state through many launches (in place, as the product does) + for t in [200, 1000, 4099] { + self.run(t, Inputs::Typical, &plan.with_chunks(3)); + } + } + fn stress(&mut self, plan: &tc::ScanPlan) { + for kind in [Inputs::NoDecay, Inputs::Large, Inputs::CollinearKeys, Inputs::InfiniteState] { + for t in [128, 129, 1000, 2049, 8192] { + self.run(t, kind, plan); + } + } + } + fn verdict(&self) { + let fails = |(r, k): &(Row, Inputs)| r.failure(*k).map(|why| format!("{}: {why}", r.label)); + let failures: Vec = self.table.iter().filter_map(fails).collect(); + let (n, list) = (self.table.len(), failures.join("\n")); + assert!(failures.is_empty(), "{} of {n} cases fail:\n{list}", failures.len()); + } +} + +#[test] +#[ignore = "Root-only: needs a CUDA device with compute capability 12"] +fn gdn_tensor_core_scan_stays_within_the_gate_of_the_sequential_recurrence() { + with_rig(6usize << 30, 2048, |rig| { + let module = load_module(rig); + let Some(plan) = device_plan(&module, rig) else { return }; + let mut gate = Gate { rig, module, rng: Rng(0x7e57_0c0d_e5ca_17ed), table: Vec::new() }; + gate.typical_lengths(&plan); + gate.stress(&plan); + gate.verdict(); + }); +} + +/// Timing on warm data, a SYNTHETIC kernel number (not an end-to-end prefill gain): 20 runs of the scan's prep + scan +/// against 20 of the kh recurrence (64 blocks, the product's sequential kernel), for the lengths of a prompt chunk. +/// The span to compare in a real run is the `gdn` stage of the prefill profile. +#[test] +#[ignore = "Root-only: needs a CUDA device with compute capability 12"] +fn gdn_tensor_core_scan_timing_against_the_kh_recurrence() { + with_rig(6usize << 30, 2048, |rig| { + let module = load_module(rig); + let Some(plan) = device_plan(&module, rig) else { return }; + let mut rng = Rng(0x71_3e_71_3e_71_3e); + for t in [512usize, 2048, 8192] { + let device = Device::new(rig.context, &generate(&mut rng, t, Inputs::Typical), t); + let reps = 20; + let started = std::time::Instant::now(); + for _ in 0..reps { + device.run_sequential(rig, t, (crate::prefill_stage::GDN_REC_KH, 64)); + } + let sequential = started.elapsed().as_secs_f64() * 1e3 / reps as f64; + let started = std::time::Instant::now(); + device.run_scan((rig, &module), &plan, (t, reps)); + let scan = started.elapsed().as_secs_f64() * 1e3 / reps as f64; + eprintln!( + "PREFILL-GDN-TC timing t={t} tiles={}: kh recurrence {sequential:.3} ms (one sync each), \ + tensor-core prep+scan {scan:.3} ms (mean of {reps}, warm; synthetic)", + plan.tiles() + ); + } + }); +} diff --git a/crates/cuda-driver/src/qsa_mapped_journal.rs b/crates/cuda-driver/src/qsa_mapped_journal.rs index a89a830c..37e8b675 100644 --- a/crates/cuda-driver/src/qsa_mapped_journal.rs +++ b/crates/cuda-driver/src/qsa_mapped_journal.rs @@ -136,6 +136,14 @@ mod parked_tests { assert_eq!(*out, sub_span(kv, pages, 100, 150)); // beyond the reachable end is refused assert!(journal.export_pages(500, 13, out).is_err()); + // the fast export (drained context, no zero fill) returns the same bytes and refuses the same spans + let mut fast = vec![7u8; 3]; + journal.export_pages_fast(0, pages, &mut fast).unwrap(); + assert_eq!(fast, kv, "the fast export is byte for byte the export"); + journal.export_pages_fast(100, 50, &mut fast).unwrap(); + assert_eq!(fast, sub_span(kv, pages, 100, 150)); + assert!(journal.export_pages_fast(500, 13, &mut fast).is_err()); + assert!(journal.export_pages_fast(0, 0, &mut fast).is_err()); } /// Rolled back, the image is written back in two pieces, and malformed spans are refused. @@ -165,6 +173,16 @@ mod parked_tests { assert_eq!(out, kv); } + /// The fast export of the index image returns the rows of the export and refuses the same spans. + fn fast_rows_match(index: &OriginalQsaResidentIndex<'_>, rows: &[u8]) { + let (row, mut fast) = (OriginalQsaResidentIndex::ROW_BYTES, vec![7u8; 3]); + index.export_rows_fast(0, rows.len() / row, &mut fast).unwrap(); + assert_eq!(fast, rows, "the fast export is byte for byte the export"); + index.export_rows_fast(10, 20, &mut fast).unwrap(); + assert_eq!(fast, rows[10 * row..30 * row]); + assert!(index.export_rows_fast(rows.len() / row, 1, &mut fast).is_err(), "rows beyond end / 4 are refused"); + } + /// The index: pooled rows below end/4 plus a 2564-byte tail, written back whole and then in part. fn index_round_trip<'c>( index: &mut OriginalQsaResidentIndex<'c>, @@ -181,6 +199,7 @@ mod parked_tests { index.validate_checkpoint(&checkpoint).unwrap(); index.export_rows(0, cells / 4, out).unwrap(); assert_eq!(*out, rows, "the pooled rows come back"); + fast_rows_match(index, &rows); assert_eq!(index.export_tail(&checkpoint).unwrap(), tail_bytes, "the tail round-trips through the image"); // partial write-back: only the second half of the rows, on top of an image that already holds the first let second = rows[(cells / 8) * OriginalQsaResidentIndex::ROW_BYTES..].to_vec(); diff --git a/crates/cuda-driver/src/qsa_mapped_journal/original_qsa_mapped_journal.rs b/crates/cuda-driver/src/qsa_mapped_journal/original_qsa_mapped_journal.rs index 17577e89..d49a700b 100644 --- a/crates/cuda-driver/src/qsa_mapped_journal/original_qsa_mapped_journal.rs +++ b/crates/cuda-driver/src/qsa_mapped_journal/original_qsa_mapped_journal.rs @@ -189,17 +189,20 @@ impl<'ctx> OriginalQsaMappedJournal<'ctx> { pub const HOST_PAGE_BYTES: usize = QSA_PROMPT_HOST_PAGE_BYTES; /// Copy the pages `first_page..first_page + pages` of the reachable prefix out of the host image. pub fn export_pages(&self, first_page: usize, pages: usize, out: &mut Vec) -> Result<()> { - self.validate_context(self.owner.context)?; - // whole pages up to the one holding the last reachable cell (a request-end checkpoint ends inside a page) - if pages == 0 || first_page.checked_add(pages).is_none_or(|e| e > self.end.div_ceil(4)) { - return Err(Error::InvalidQwenShape); - } + self.check_export(first_page, pages)?; // the GPU wrote these cells through the mapped alias; every public writer drains, this keeps the read ordered // after it - self.owner.context.synchronize()?; + { + let _p = crate::host_profile::span("export.sync"); + self.owner.context.synchronize()?; + } out.clear(); - out.try_reserve_exact(pages * Self::HOST_PAGE_BYTES).map_err(|_| Error::HostAllocation)?; - out.resize(pages * Self::HOST_PAGE_BYTES, 0); + { + let _p = crate::host_profile::span("export.alloc"); + out.try_reserve_exact(pages * Self::HOST_PAGE_BYTES).map_err(|_| Error::HostAllocation)?; + out.resize(pages * Self::HOST_PAGE_BYTES, 0); + } + let _p = crate::host_profile::span("export.copy"); let m = self.owner.mapped.as_ref().ok_or(Error::ContextPoisoned)?; let offsets = super::super::offsets()?; let mut at = 0; @@ -210,6 +213,35 @@ impl<'ctx> OriginalQsaMappedJournal<'ctx> { } Ok(()) } + /// The journal is this context's and the pages lie in the reachable prefix: whole pages up to the one holding the + /// last reachable cell (a request-end checkpoint ends inside a page). + fn check_export(&self, first_page: usize, pages: usize) -> Result<()> { + self.validate_context(self.owner.context)?; + if pages == 0 || first_page.checked_add(pages).is_none_or(|e| e > self.end.div_ceil(4)) { + return Err(Error::InvalidQwenShape); + } + Ok(()) + } + /// `export_pages` for a caller that has drained the context since the last enqueue (one + /// `Context::synchronize` for all the layers of a park, not one per layer) and for a buffer that is only ever + /// written by the copy: the bytes are the same as `export_pages`, with no synchronize and no zero fill first. + /// With an undrained context the cells the GPU wrote last may not have landed: the caller owns that ordering. + pub fn export_pages_fast(&self, first_page: usize, pages: usize, out: &mut Vec) -> Result<()> { + self.check_export(first_page, pages)?; + let m = self.owner.mapped.as_ref().ok_or(Error::ContextPoisoned)?; + let offsets = super::super::offsets()?; + let _p = crate::host_profile::span("export.copy_fast"); + crate::exact_fill::fill_exact(out, pages * Self::HOST_PAGE_BYTES, |dst| { + let mut rest = dst; + let mut written = 0; + for (i, &page) in super::super::PAGE.iter().enumerate() { + let (run, tail) = rest.split_at_mut(pages * page); + m.read_uninit(offsets[i] + first_page * page, run)?; + (written, rest) = (written + run.len(), tail); + } + Ok(written) + }) + } /// Put parked spans `(first_page, bytes)` back into the host image and make the journal's reachable prefix end at /// `end` cells: the cells below `end` that no span names must already hold the prefix (the caller's live-prefix /// bookkeeping). Any written cell may have a stale copy in the VRAM resident window, so the resolver is reset diff --git a/crates/cuda-driver/src/qsa_prompt_host_ffi.rs b/crates/cuda-driver/src/qsa_prompt_host_ffi.rs index 5940ad22..ef090030 100644 --- a/crates/cuda-driver/src/qsa_prompt_host_ffi.rs +++ b/crates/cuda-driver/src/qsa_prompt_host_ffi.rs @@ -126,6 +126,17 @@ mod enabled { } Ok(()) } + /// `read` into bytes that are not initialised yet (the prefix-cache export fills a fresh buffer without + /// zeroing it first); every byte of `out` is written. + pub(crate) fn read_uninit(&self, o: usize, out: &mut [std::mem::MaybeUninit]) -> Result<()> { + let p = self.range(o, out.len())?; + // SAFETY: as `read`: `range` proved `[p, p + out.len())` lies inside the live allocation and `out` is a + // caller slice that cannot overlap it; the copy writes all `out.len()` bytes of `out`. + unsafe { + std::ptr::copy_nonoverlapping(p as *const u8, out.as_mut_ptr().cast::(), out.len()); + } + Ok(()) + } pub(crate) fn close(&mut self) -> Result<()> { if let Some(p) = self.host { // SAFETY: `p` is the base returned by cuMemHostAlloc and not yet freed (`host` is cleared only after a @@ -174,6 +185,9 @@ impl MappedAllocation { pub(crate) fn read(&self, _: usize, _: &mut [u8]) -> Result<()> { Err(Error::UnsupportedPlatform) } + pub(crate) fn read_uninit(&self, _: usize, _: &mut [std::mem::MaybeUninit]) -> Result<()> { + Err(Error::UnsupportedPlatform) + } pub(crate) fn write(&mut self, _: usize, _: &[u8]) -> Result<()> { Err(Error::UnsupportedPlatform) } diff --git a/crates/cuda-driver/src/qsa_prompt_index.rs b/crates/cuda-driver/src/qsa_prompt_index.rs index 398883bc..8f3d0bf3 100644 --- a/crates/cuda-driver/src/qsa_prompt_index.rs +++ b/crates/cuda-driver/src/qsa_prompt_index.rs @@ -82,7 +82,7 @@ mod resident_scalar_index; pub use resident_scalar_index::{OriginalQsaResidentScalarIndex, OriginalQsaResidentScalarSelection, ScalarStepRows}; #[cfg(all(feature = "cuda-driver", any(target_os = "linux", target_os = "windows"), target_pointer_width = "64"))] -pub use resident_index::verification_commit::{OriginalVerifyQsaJournal, OriginalVerifyRope}; +pub use resident_index::verification_commit::{OriginalQsaOwners, OriginalVerifyQsaJournal, OriginalVerifyRope}; mod max_blocks; #[allow(unused_imports)] diff --git a/crates/cuda-driver/src/qsa_resident_index/qsa_resident_index_checkpoint_restore.rs b/crates/cuda-driver/src/qsa_resident_index/qsa_resident_index_checkpoint_restore.rs index 06d69a09..e2b6a3bd 100644 --- a/crates/cuda-driver/src/qsa_resident_index/qsa_resident_index_checkpoint_restore.rs +++ b/crates/cuda-driver/src/qsa_resident_index/qsa_resident_index_checkpoint_restore.rs @@ -193,6 +193,18 @@ impl<'ctx> OriginalQsaResidentIndex<'ctx> { pub const TAIL_BYTES: usize = CHECKPOINT_BYTES; /// Copy the pooled key rows `first_row..first_row + rows` (all below the current end / 4) to the host. pub fn export_rows(&self, first_row: usize, rows: usize, out: &mut Vec) -> Result<()> { + self.check_export(first_row, rows)?; + out.clear(); + { + let _p = crate::host_profile::span("export.index_alloc"); + out.try_reserve_exact(rows * Self::ROW_BYTES).map_err(|_| Error::HostAllocation)?; + out.resize(rows * Self::ROW_BYTES, 0); + } + let _p = crate::host_profile::span("export.index_copy"); + self.image[0].as_ref().ok_or(Error::ContextPoisoned)?.copy_to_range(first_row * Self::ROW_BYTES, out) + } + /// The image is settled and the rows lie below the current end / 4. + fn check_export(&self, first_row: usize, rows: usize) -> Result<()> { self.validate()?; if self.in_flight || self.unpublished { return Err(Error::InvalidQwenShape); @@ -200,10 +212,18 @@ impl<'ctx> OriginalQsaResidentIndex<'ctx> { if rows == 0 || first_row.checked_add(rows).is_none_or(|e| e > self.end / 4) { return Err(Error::InvalidQwenShape); } - out.clear(); - out.try_reserve_exact(rows * Self::ROW_BYTES).map_err(|_| Error::HostAllocation)?; - out.resize(rows * Self::ROW_BYTES, 0); - self.image[0].as_ref().ok_or(Error::ContextPoisoned)?.copy_to_range(first_row * Self::ROW_BYTES, out) + Ok(()) + } + /// `export_rows` that takes the device read's own staging as the result instead of zero filling `out` and copying + /// the staging into it: the same bytes, one allocation, one zero fill and one copy fewer. `out` is replaced. + pub fn export_rows_fast(&self, first_row: usize, rows: usize, out: &mut Vec) -> Result<()> { + self.check_export(first_row, rows)?; + let _p = crate::host_profile::span("export.index_copy_fast"); + *out = self.image[0] + .as_ref() + .ok_or(Error::ContextPoisoned)? + .copy_to_range_owned(first_row * Self::ROW_BYTES, rows * Self::ROW_BYTES)?; + Ok(()) } /// The bytes of a checkpoint of this lineage: everything `import` needs besides the rows below its end. pub fn export_tail(&self, s: &OriginalQsaIndexCheckpoint<'ctx>) -> Result> { diff --git a/crates/cuda-driver/src/qsa_verification_commit.rs b/crates/cuda-driver/src/qsa_verification_commit.rs index 2455f395..49030478 100644 --- a/crates/cuda-driver/src/qsa_verification_commit.rs +++ b/crates/cuda-driver/src/qsa_verification_commit.rs @@ -5,6 +5,7 @@ use super::*; use crate::OriginalCapture; use crate::original_verify::abi::{Arg, Command}; use crate::original_verify::{OriginalVerifyBank, OriginalVerifyGdnJournal}; +use crate::owner_loan::OwnerLoan; use std::cell::RefCell; /// Resolved Original analytic constants, and actual optional retained device /// tables. Process policy is fixed before capture by the genuine model adapter. @@ -20,6 +21,7 @@ pub struct OriginalVerifyRope<'ctx> { pub angles: Option<(DeviceRef<'ctx>, DeviceRef<'ctx>, usize)>, } /// Addresses of one QSA layer's fixed owners (see `OriginalVerifyQsaJournal::window_addresses`). +#[derive(Clone, Copy, Debug, Eq, PartialEq)] pub(crate) struct OriginalVerifyQsaWindowAddresses { pub resident: [u64; 4], pub table: u64, @@ -44,8 +46,10 @@ struct Live { /// before the indexer and resolves attention from that same K/V prefix. pub struct OriginalVerifyQsaJournal<'ctx> { context: &'ctx Context<'ctx>, - indices: [RefCell>; 12], - mapped: [RefCell>; 12], + /// The owners; `None` while they are out on loan (`lend` / `take_back`). + indices: [RefCell>>; 12], + mapped: [RefCell>>; 12], + loan: RefCell>, gamma: [DeviceRef<'ctx>; 12], rope: OriginalVerifyRope<'ctx>, live: RefCell, @@ -65,6 +69,9 @@ use original_verify_rope::overlaps; use original_verify_rope::whole; #[path = "qsa_verification_commit/original_verify_qsa_journal.rs"] mod original_verify_qsa_journal; +#[path = "qsa_verification_commit/verify_qsa_journal_loan.rs"] +mod verify_qsa_journal_loan; +pub use verify_qsa_journal_loan::OriginalQsaOwners; #[path = "qsa_verification_commit/verify_qsa_journal_capture_commit.rs"] mod verify_qsa_journal_capture_commit; #[path = "qsa_verification_commit/verify_qsa_journal_index_image.rs"] diff --git a/crates/cuda-driver/src/qsa_verification_commit/original_verify_qsa_journal.rs b/crates/cuda-driver/src/qsa_verification_commit/original_verify_qsa_journal.rs index 9045ea12..7f4934b1 100644 --- a/crates/cuda-driver/src/qsa_verification_commit/original_verify_qsa_journal.rs +++ b/crates/cuda-driver/src/qsa_verification_commit/original_verify_qsa_journal.rs @@ -1,6 +1,7 @@ //! Moved out of the parent module by STRA-338: impl OriginalVerifyQsaJournal. #[allow(unused_imports)] +use super::verify_qsa_journal_loan::print_of; use super::*; type Indices<'ctx> = [OriginalQsaResidentIndex<'ctx>; 12]; @@ -69,7 +70,7 @@ fn check_rope_clear(rope: &OriginalVerifyRope<'_>, indices: &Indices<'_>) -> Res Ok(()) } /// Every index and journal belongs to `context`, is idle and stands at `end`. -fn check_aligned<'ctx>( +pub(super) fn check_aligned<'ctx>( context: &'ctx Context<'ctx>, indices: &Indices<'ctx>, mapped: &[OriginalQsaMappedJournal<'ctx>; 12], @@ -99,8 +100,9 @@ impl<'ctx> OriginalVerifyQsaJournal<'ctx> { check_rope_clear(&rope, &indices)?; Ok(Rc::new(Self { context, - indices: indices.map(RefCell::new), - mapped: mapped.map(RefCell::new), + indices: indices.map(|i| RefCell::new(Some(i))), + mapped: mapped.map(|m| RefCell::new(Some(m))), + loan: RefCell::new(OwnerLoan::new()), gamma, rope, live: RefCell::new(Live { generation: 0, position: end, rows: 0, armed: false }), @@ -117,9 +119,8 @@ impl<'ctx> OriginalVerifyQsaJournal<'ctx> { if self.failed.get() || c.is_poisoned() { return Err(Error::ContextPoisoned); } - for (i, m) in self.indices.iter().zip(self.mapped.iter()) { - let i = i.try_borrow().map_err(|_| Error::InvalidQwenShape)?; - let m = m.try_borrow().map_err(|_| Error::InvalidQwenShape)?; + for layer in 0..12 { + let (i, m) = (self.index(layer)?, self.kv(layer)?); i.validate_context(c)?; m.validate_context(c)?; if i.next_position() != m.next_position() { @@ -142,7 +143,7 @@ impl<'ctx> OriginalVerifyQsaJournal<'ctx> { if layer >= 12 { return Err(Error::InvalidQwenShape); } - let i = self.indices[layer].try_borrow().map_err(|_| Error::InvalidQwenShape)?; + let i = self.index(layer)?; consume( [ i.image[0].as_ref().ok_or(Error::ContextPoisoned)?, @@ -162,7 +163,7 @@ impl<'ctx> OriginalVerifyQsaJournal<'ctx> { if layer >= 12 || self.live.try_borrow().map_err(|_| Error::InvalidQwenShape)?.armed { return Err(Error::InvalidQwenShape); } - let mut i = self.indices[layer].try_borrow_mut().map_err(|_| Error::InvalidQwenShape)?; + let mut i = self.index_mut(layer)?; if i.in_flight || i.unpublished { return Err(Error::InvalidQwenShape); } @@ -180,8 +181,8 @@ impl<'ctx> OriginalVerifyQsaJournal<'ctx> { } let mut held = Vec::new(); held.try_reserve_exact(12).map_err(|_| Error::HostAllocation)?; - for i in &self.indices { - held.push(i.try_borrow_mut().map_err(|_| Error::InvalidQwenShape)?) + for layer in 0..12 { + held.push(self.index_mut(layer)?) } let mut refs: Vec<&mut OriginalQsaResidentIndex<'ctx>> = held.iter_mut().map(|i| &mut **i).collect(); let saved = OriginalQsaResidentIndex::checkpoint_fenced_all(&mut refs, ws)?; @@ -198,7 +199,7 @@ impl<'ctx> OriginalVerifyQsaJournal<'ctx> { if layer >= 12 || self.live.try_borrow().map_err(|_| Error::InvalidQwenShape)?.armed { return Err(Error::InvalidQwenShape); } - let mut m = self.mapped[layer].try_borrow_mut().map_err(|_| Error::InvalidQwenShape)?; + let mut m = self.kv_mut(layer)?; consume(&mut m) } /// The resolved Original RoPE constants and optional retained tables (read only). @@ -213,39 +214,17 @@ impl<'ctx> OriginalVerifyQsaJournal<'ctx> { if layer >= 12 { return Err(Error::InvalidQwenShape); } - let (resident, table, host, resolver, slots) = - self.mapped[layer].try_borrow().map_err(|_| Error::InvalidQwenShape)?.window_kv_addresses()?; - let ((pooled, pooled_bytes), (dead, dead_bytes)) = self.index_spans(layer)?; - Ok(OriginalVerifyQsaWindowAddresses { - resident, - table, - host, - resolver, - slots, - pooled, - pooled_bytes, - dead, - dead_bytes, - }) - } - /// The device address and byte length of the index image's pooled keys and of its spare key, as `(pooled, dead)`. - fn index_spans(&self, layer: usize) -> Result<((u64, usize), (u64, usize))> { - let i = self.indices[layer].try_borrow().map_err(|_| Error::InvalidQwenShape)?; - let pooled = i.image[0].as_ref().ok_or(Error::ContextPoisoned)?; - let dead = i.image[2].as_ref().ok_or(Error::ContextPoisoned)?; - let address = - |b: &DeviceBuffer<'ctx>| -> Result { Ok(b.handle.ok_or(Error::ContextPoisoned)?.qwen_address()) }; - Ok(((address(pooled)?, pooled.len()), (address(dead)?, dead.len()))) + let (index, kv) = (self.index(layer)?, self.kv(layer)?); + Ok(print_of(&index, &kv)?.window) } pub fn allocated_bytes(&self) -> usize { - self.indices.iter().map(|i| i.borrow().allocated_bytes()).sum::() - + self.mapped.iter().map(|m| m.borrow().allocated_bytes()).sum::() + self.indices.iter().filter_map(|i| i.borrow().as_ref().map(|i| i.allocated_bytes())).sum::() + + self.mapped.iter().filter_map(|m| m.borrow().as_ref().map(|m| m.allocated_bytes())).sum::() } /// Every index and journal is idle and stands at `position`. pub(super) fn check_idle_at(&self, position: usize) -> Result<()> { - for (i, m) in self.indices.iter().zip(self.mapped.iter()) { - let i = i.try_borrow().map_err(|_| Error::InvalidQwenShape)?; - let m = m.try_borrow().map_err(|_| Error::InvalidQwenShape)?; + for layer in 0..12 { + let (i, m) = (self.index(layer)?, self.kv(layer)?); if i.in_flight || i.unpublished || i.end != position || m.next_position() != position { return Err(Error::InvalidQwenShape); } @@ -263,8 +242,8 @@ impl<'ctx> OriginalVerifyQsaJournal<'ctx> { snapshot.clear(); snapshot.try_reserve_exact(12 * n).map_err(|_| Error::HostAllocation)?; snapshot.resize(12 * n, 0); - for (layer, i) in self.indices.iter().enumerate() { - let i = i.try_borrow().map_err(|_| Error::InvalidQwenShape)?; + for layer in 0..12 { + let i = self.index(layer)?; i.read_window_state(&mut snapshot[layer * n..(layer + 1) * n])?; } Ok(()) @@ -281,8 +260,8 @@ impl<'ctx> OriginalVerifyQsaJournal<'ctx> { self.snapshot_window_state()?; // All immutable borrows above are gone. This single-thread-affine owner // has no escaping RefMut; the fixed pass performs no fallible allocation. - for i in &self.indices { - let mut i = i.borrow_mut(); + for layer in 0..12 { + let mut i = self.index_mut(layer)?; i.in_flight = true; i.unpublished = true; } @@ -301,7 +280,7 @@ impl<'ctx> OriginalVerifyQsaJournal<'ctx> { if layer >= 12 { return Err(Error::InvalidQwenShape); } - let i = self.indices[layer].try_borrow().map_err(|_| Error::InvalidQwenShape)?; + let i = self.index(layer)?; journal.submit( capture, vec![Command::new( diff --git a/crates/cuda-driver/src/qsa_verification_commit/verify_qsa_journal_capture_commit.rs b/crates/cuda-driver/src/qsa_verification_commit/verify_qsa_journal_capture_commit.rs index d6782c91..fb7f4a28 100644 --- a/crates/cuda-driver/src/qsa_verification_commit/verify_qsa_journal_capture_commit.rs +++ b/crates/cuda-driver/src/qsa_verification_commit/verify_qsa_journal_capture_commit.rs @@ -17,7 +17,7 @@ impl<'ctx> OriginalVerifyQsaJournal<'ctx> { if layer >= 12 { return Err(Error::InvalidQwenShape); } - let i = self.indices[layer].try_borrow().map_err(|_| Error::InvalidQwenShape)?; + let i = self.index(layer)?; let t = journal.geometry().max_t; journal.submit( capture, @@ -71,7 +71,7 @@ impl<'ctx> OriginalVerifyQsaJournal<'ctx> { fn fused_layers(&self) -> Result<[[u64; 12]; 5]> { let mut layers = [[0u64; 12]; 5]; for layer in 0..12 { - let i = self.indices[layer].try_borrow().map_err(|_| Error::InvalidQwenShape)?; + let i = self.index(layer)?; let [tail, dead, pooled, block_pos] = image_addresses(&i)?; layers[0][layer] = tail; layers[1][layer] = dead; @@ -135,7 +135,7 @@ impl<'ctx> OriginalVerifyQsaJournal<'ctx> { if layer >= 12 || begin >= end || end > t { return Err(Error::InvalidQwenShape); } - let i = self.indices[layer].try_borrow().map_err(|_| Error::InvalidQwenShape)?; + let i = self.index(layer)?; let gamma = whole(self.context, &self.gamma[layer], 512)?; let commands = self.append_commands(journal, &i, (layer * t, begin..end), (commit, gamma))?; journal.submit_qsa(capture, commands) @@ -225,8 +225,8 @@ impl<'ctx> OriginalVerifyQsaJournal<'ctx> { self.validate_context(self.context)?; workspace.validate_context(self.context)?; let keep = self.check_appended(bank, &appended)?; - for (m, a) in self.mapped.iter().zip(appended) { - let result = m.try_borrow_mut().map_err(|_| Error::InvalidQwenShape)?.accept_prefix(workspace, &a, keep); + for (layer, a) in appended.into_iter().enumerate() { + let result = self.kv_mut(layer)?.accept_prefix(workspace, &a, keep); if let Err(e) = result { self.failed.set(true); return Err(e); @@ -245,18 +245,17 @@ impl<'ctx> OriginalVerifyQsaJournal<'ctx> { let staged = bank.staged_window()?; let keep = bank.staged_keep()?; check_armed_window(&live, staged, keep)?; - for (m, a) in self.mapped.iter().zip(appended.iter()) { - Self::check_receipt(m, a, (staged.1, staged.2))?; + for (layer, a) in appended.iter().enumerate() { + Self::check_receipt(&*self.kv(layer)?, a, (staged.1, staged.2))?; } Ok(keep) } /// A receipt covers exactly the staged window, and its journal accepts the final prefix. fn check_receipt( - m: &RefCell>, + m: &OriginalQsaMappedJournal<'ctx>, a: &OriginalQsaMappedAppend, (position, rows): (usize, usize), ) -> Result<()> { - let m = m.try_borrow().map_err(|_| Error::InvalidQwenShape)?; if a.first_position() != position || a.rows() != rows || a.final_prefix().next_position() != position.checked_add(rows).ok_or(Error::InvalidSize)? diff --git a/crates/cuda-driver/src/qsa_verification_commit/verify_qsa_journal_index_image.rs b/crates/cuda-driver/src/qsa_verification_commit/verify_qsa_journal_index_image.rs index d9c39b36..7e804081 100644 --- a/crates/cuda-driver/src/qsa_verification_commit/verify_qsa_journal_index_image.rs +++ b/crates/cuda-driver/src/qsa_verification_commit/verify_qsa_journal_index_image.rs @@ -20,7 +20,7 @@ impl<'ctx> OriginalVerifyQsaJournal<'ctx> { if self.rope.angles.is_some() { return Ok(None); } - let i = self.indices[layer].try_borrow().map_err(|_| Error::InvalidQwenShape)?; + let i = self.index(layer)?; let [tail, dead, pooled, block_pos] = image_addresses(&i)?; let gamma = whole(self.context, &self.gamma[layer], 512)?; let positions = self diff --git a/crates/cuda-driver/src/qsa_verification_commit/verify_qsa_journal_loan.rs b/crates/cuda-driver/src/qsa_verification_commit/verify_qsa_journal_loan.rs new file mode 100644 index 00000000..7869463d --- /dev/null +++ b/crates/cuda-driver/src/qsa_verification_commit/verify_qsa_journal_loan.rs @@ -0,0 +1,162 @@ +//! The owner loan of `OriginalVerifyQsaJournal` (ledger row Q7, docs/experiments/decode-graph-reuse.md). +//! +//! The captured window graphs retain this journal and bind the addresses of the twelve index images and mapped K/V +//! journals it owns. The prompt executor needs those owners again for the next request. `lend` hands them out without +//! dropping the journal (and so the graphs), `take_back` receives them, and the journal accepts them only if every +//! address the graphs bound is unchanged. While the owners are out every use of the journal is refused (the accessors +//! find nothing); a mismatch fails the journal for good, so the graph set that retains it is retired and never +//! replayed. + +use super::original_verify_qsa_journal::{check_aligned, image_addresses}; +#[allow(unused_imports)] +use super::*; +use crate::owner_loan::LoanError; +use std::cell::{Ref, RefMut}; + +/// The twelve index images and mapped journals of a loan. +pub type OriginalQsaOwners<'ctx> = ([OriginalQsaResidentIndex<'ctx>; 12], [OriginalQsaMappedJournal<'ctx>; 12]); + +/// Every address one layer's captured kernels bind: the window addresses plus the image's tail and block position. +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub(crate) struct OwnerPrint { + pub(super) window: OriginalVerifyQsaWindowAddresses, + image: [u64; 4], +} + +/// The addresses the window graphs bind for one layer's owners. +pub(super) fn print_of(index: &OriginalQsaResidentIndex<'_>, kv: &OriginalQsaMappedJournal<'_>) -> Result { + let (resident, table, host, resolver, slots) = kv.window_kv_addresses()?; + let address = |b: &DeviceBuffer<'_>| -> Result { Ok(b.handle.ok_or(Error::ContextPoisoned)?.qwen_address()) }; + let pooled = index.image[0].as_ref().ok_or(Error::ContextPoisoned)?; + let dead = index.image[2].as_ref().ok_or(Error::ContextPoisoned)?; + let window = OriginalVerifyQsaWindowAddresses { + resident, + table, + host, + resolver, + slots, + pooled: address(pooled)?, + pooled_bytes: pooled.len(), + dead: address(dead)?, + dead_bytes: dead.len(), + }; + Ok(OwnerPrint { window, image: image_addresses(index)? }) +} + +/// The accessors every use of the owners goes through: an error while the owners are out. +impl<'ctx> OriginalVerifyQsaJournal<'ctx> { + pub(super) fn index(&self, layer: usize) -> Result>> { + let cell = self.indices.get(layer).ok_or(Error::InvalidQwenShape)?; + let held = cell.try_borrow().map_err(|_| Error::InvalidQwenShape)?; + Ref::filter_map(held, Option::as_ref).map_err(|_| Error::InvalidQwenShape) + } + + pub(super) fn index_mut(&self, layer: usize) -> Result>> { + let cell = self.indices.get(layer).ok_or(Error::InvalidQwenShape)?; + let held = cell.try_borrow_mut().map_err(|_| Error::InvalidQwenShape)?; + RefMut::filter_map(held, Option::as_mut).map_err(|_| Error::InvalidQwenShape) + } + + pub(super) fn kv(&self, layer: usize) -> Result>> { + let cell = self.mapped.get(layer).ok_or(Error::InvalidQwenShape)?; + let held = cell.try_borrow().map_err(|_| Error::InvalidQwenShape)?; + Ref::filter_map(held, Option::as_ref).map_err(|_| Error::InvalidQwenShape) + } + + pub(super) fn kv_mut(&self, layer: usize) -> Result>> { + let cell = self.mapped.get(layer).ok_or(Error::InvalidQwenShape)?; + let held = cell.try_borrow_mut().map_err(|_| Error::InvalidQwenShape)?; + RefMut::filter_map(held, Option::as_mut).map_err(|_| Error::InvalidQwenShape) + } + + /// The addresses of the twelve layers' owners, as the graphs bound them. + fn prints(&self) -> Result<[OwnerPrint; 12]> { + let mut prints = Vec::new(); + prints.try_reserve_exact(12).map_err(|_| Error::HostAllocation)?; + for layer in 0..12 { + let (index, kv) = (self.index(layer)?, self.kv(layer)?); + prints.push(print_of(&index, &kv)?); + } + prints.try_into().map_err(|_| Error::InvalidQwenShape) + } + + /// Whether the owners are out on loan. + pub fn owners_lent(&self) -> bool { + self.loan.try_borrow().map(|loan| loan.is_lent()).unwrap_or(true) + } + + /// Hand the twelve owners out (to the prompt executor) and keep the journal, and so the graphs that retain it. + /// Needs the journal idle: no window armed, every index published and standing where its journal does. The + /// fingerprint of the owners' addresses is kept for `take_back`. Any use of the journal fails until then. + pub fn lend(&self) -> Result> { + self.require_idle()?; + let prints = self.prints()?; + let mut loan = self.loan.try_borrow_mut().map_err(|_| Error::InvalidQwenShape)?; + loan.lend(prints).map_err(|_| Error::InvalidQwenShape)?; + let (indices, mapped) = (self.take_all(&self.indices)?, self.take_all(&self.mapped)?); + Ok((indices, mapped)) + } + + /// Move the twelve values out of their cells: all twelve are borrowed and found full before the first moves. + pub(super) fn take_all(&self, cells: &[RefCell>; 12]) -> Result<[T; 12]> { + let mut held = Vec::new(); + held.try_reserve_exact(12).map_err(|_| Error::HostAllocation)?; + for cell in cells { + held.push(cell.try_borrow_mut().map_err(|_| Error::InvalidQwenShape)?); + } + if held.iter().any(|value| value.is_none()) { + return Err(Error::InvalidQwenShape); + } + let taken: Vec = held.iter_mut().filter_map(|value| value.take()).collect(); + taken.try_into().map_err(|_| Error::InvalidQwenShape) + } + + /// Receive the owners back. They must be the lent ones: every address the graphs bound unchanged, all twelve idle + /// and standing at one position. Otherwise the journal is failed for good (the graph set must be retired) and the + /// owners come back to the caller with the error, so that none is lost. + pub fn take_back( + &self, + owners: OriginalQsaOwners<'ctx>, + ) -> std::result::Result<(), (Error, OriginalQsaOwners<'ctx>)> { + let now = self.print_owners(&owners); + let end = owners.0[0].next_position(); + let aligned = check_aligned(self.context, &owners.0, &owners.1, end); + let outcome = match (aligned, self.loan.try_borrow_mut()) { + (Ok(()), Ok(mut loan)) => loan.take_back(now.ok()), + (_, Ok(mut loan)) => { + loan.fail(); + Err(LoanError::Changed) + } + (_, Err(_)) => Err(LoanError::Failed), + }; + match outcome { + Ok(()) => Ok(self.receive(owners, end)), + Err(_) => { + self.failed.set(true); + Err((Error::InvalidQwenShape, owners)) + } + } + } + + fn print_owners(&self, owners: &OriginalQsaOwners<'ctx>) -> Result<[OwnerPrint; 12]> { + let mut prints = Vec::new(); + prints.try_reserve_exact(12).map_err(|_| Error::HostAllocation)?; + for (index, kv) in owners.0.iter().zip(owners.1.iter()) { + prints.push(print_of(index, kv)?); + } + prints.try_into().map_err(|_| Error::InvalidQwenShape) + } + + /// Put the accepted owners in their cells and stand the journal at their position, disarmed. + fn receive(&self, owners: OriginalQsaOwners<'ctx>, end: usize) { + let (indices, mapped) = owners; + for (cell, index) in self.indices.iter().zip(indices) { + *cell.borrow_mut() = Some(index); + } + for (cell, kv) in self.mapped.iter().zip(mapped) { + *cell.borrow_mut() = Some(kv); + } + let mut live = self.live.borrow_mut(); + *live = Live { generation: live.generation, position: end, rows: 0, armed: false }; + } +} diff --git a/crates/cuda-driver/src/qsa_verification_commit/verify_qsa_journal_publish_discard.rs b/crates/cuda-driver/src/qsa_verification_commit/verify_qsa_journal_publish_discard.rs index eb5a8e98..5b01396c 100644 --- a/crates/cuda-driver/src/qsa_verification_commit/verify_qsa_journal_publish_discard.rs +++ b/crates/cuda-driver/src/qsa_verification_commit/verify_qsa_journal_publish_discard.rs @@ -22,8 +22,8 @@ impl<'ctx> OriginalVerifyQsaJournal<'ctx> { } /// Every index is still in flight and unpublished. fn check_all_in_flight(&self) -> Result<()> { - for i in &self.indices { - let i = i.try_borrow().map_err(|_| Error::InvalidQwenShape)?; + for layer in 0..12 { + let i = self.index(layer)?; if !i.in_flight || !i.unpublished { return Err(Error::InvalidQwenShape); } @@ -32,8 +32,8 @@ impl<'ctx> OriginalVerifyQsaJournal<'ctx> { } /// Advance every index to `end` and publish it. fn publish_window_indices(&self, position: usize, end: usize) { - for i in &self.indices { - let mut i = i.borrow_mut(); + for layer in 0..12 { + let Ok(mut i) = self.index_mut(layer) else { continue }; i.coverage.end.set(i.coverage.end.get().min(position)); i.coverage = Rc::new(Coverage { end: Cell::new(end) }); i.end = end; @@ -45,13 +45,13 @@ impl<'ctx> OriginalVerifyQsaJournal<'ctx> { /// visible; publish that K/V half on the host here, after the commit drain, and only then the index half. Do not /// publish an index-only verifier state: every journal must stand at `position` and every one is advanced together. fn publish_window_kv(&self, position: usize, keep: usize) -> Result<()> { - for m in &self.mapped { - if m.try_borrow().map_err(|_| Error::InvalidQwenShape)?.next_position() != position { + for layer in 0..12 { + if self.kv(layer)?.next_position() != position { return Err(Error::InvalidQwenShape); } } - for m in &self.mapped { - m.try_borrow_mut().map_err(|_| Error::InvalidQwenShape)?.publish_window_rows(position, keep)?; + for layer in 0..12 { + self.kv_mut(layer)?.publish_window_rows(position, keep)?; } Ok(()) } @@ -113,10 +113,8 @@ impl<'ctx> OriginalVerifyQsaJournal<'ctx> { /// Write the snapshots back: each index image, then the PLE history. fn restore_window_state(&self, snapshot: &[u8], ple: Option<(&DeviceBuffer<'ctx>, &[u8])>) -> Result<()> { let n = OriginalQsaResidentIndex::WINDOW_STATE_BYTES; - for (layer, i) in self.indices.iter().enumerate() { - i.try_borrow_mut() - .map_err(|_| Error::InvalidQwenShape)? - .write_window_state(&snapshot[layer * n..(layer + 1) * n])?; + for layer in 0..12 { + self.index_mut(layer)?.write_window_state(&snapshot[layer * n..(layer + 1) * n])?; } if let Some((ple, bytes)) = ple { ple.copy_from_range_shared(0, bytes)?; @@ -139,9 +137,8 @@ impl<'ctx> OriginalVerifyQsaJournal<'ctx> { self.check_in_flight_at(position) } fn check_in_flight_at(&self, position: usize) -> Result<()> { - for (i, m) in self.indices.iter().zip(self.mapped.iter()) { - let i = i.try_borrow().map_err(|_| Error::InvalidQwenShape)?; - let m = m.try_borrow().map_err(|_| Error::InvalidQwenShape)?; + for layer in 0..12 { + let (i, m) = (self.index(layer)?, self.kv(layer)?); if !i.in_flight || !i.unpublished || i.end != position || m.next_position() != position { return Err(Error::InvalidQwenShape); } @@ -151,8 +148,8 @@ impl<'ctx> OriginalVerifyQsaJournal<'ctx> { /// Publish every index at its restored position and disarm the journal. fn release_window(&self) -> Result<()> { let mut live = self.live.try_borrow_mut().map_err(|_| Error::InvalidQwenShape)?; - for i in &self.indices { - let mut i = i.try_borrow_mut().map_err(|_| Error::InvalidQwenShape)?; + for layer in 0..12 { + let mut i = self.index_mut(layer)?; i.in_flight = false; i.unpublished = false; } @@ -161,8 +158,8 @@ impl<'ctx> OriginalVerifyQsaJournal<'ctx> { } pub(crate) fn abandon_after_drain(&self) { self.failed.set(true); - for i in &self.indices { - if let Ok(mut i) = i.try_borrow_mut() { + for layer in 0..12 { + if let Ok(mut i) = self.index_mut(layer) { i.in_flight = false; i.unpublished = true; } @@ -178,7 +175,8 @@ impl<'ctx> OriginalVerifyQsaJournal<'ctx> { if s.live.borrow().armed && !s.failed.get() { return Err(Error::InvalidQwenShape); } - Ok((s.indices.map(RefCell::into_inner), s.mapped.map(RefCell::into_inner))) + let taken = (s.take_all(&s.indices)?, s.take_all(&s.mapped)?); + Ok(taken) } Err(_) => Err(Error::InvalidQwenShape), } diff --git a/crates/cuda-driver/src/qsa_verification_commit/verify_qsa_journal_rearm.rs b/crates/cuda-driver/src/qsa_verification_commit/verify_qsa_journal_rearm.rs index a11bc4c1..8155a6b7 100644 --- a/crates/cuda-driver/src/qsa_verification_commit/verify_qsa_journal_rearm.rs +++ b/crates/cuda-driver/src/qsa_verification_commit/verify_qsa_journal_rearm.rs @@ -13,7 +13,7 @@ impl OriginalVerifyQsaJournal<'_> { if self.live.try_borrow().map_err(|_| Error::InvalidQwenShape)?.armed { return Err(Error::InvalidQwenShape); } - let end = self.indices[0].try_borrow().map_err(|_| Error::InvalidQwenShape)?.next_position(); + let end = self.index(0)?.next_position(); self.check_idle_at(end) } } diff --git a/crates/cuda-driver/src/refill_batch_copy.rs b/crates/cuda-driver/src/refill_batch_copy.rs new file mode 100644 index 00000000..ef46dae9 --- /dev/null +++ b/crates/cuda-driver/src/refill_batch_copy.rs @@ -0,0 +1,168 @@ +//! Batched host-to-device copies of the lent-slot refill (`LELEKA_REFILL_BATCH`, EXPERIMENTAL, off by default). +//! +//! The per-copy refill issues one `cuMemcpyHtoDAsync_v2` per piece (three or more per slot). This path hands the same +//! pieces, in the same order, with the same sources, destinations and sizes, to `cuMemcpyBatchAsync_v2` in calls of +//! at most `max_per_call` copies, so only the host's issue cost changes. A call the driver refuses is reported once +//! and the refused call and every later one are issued per copy on the same stream (a copy the refused call may have +//! queued is copied again with the same bytes, so the slot bytes stay identical). +use crate::api::{AsyncApi, Stream}; +use crate::{Error, Result}; + +/// Upper bound of copies in one batch call (the descriptor arrays are built on the host for each call). +pub(crate) const MAX_COPIES_PER_CALL: usize = 4096; + +/// One host-to-device piece: a device address and the host bytes copied there. +#[derive(Clone, Copy)] +pub(crate) struct HostCopy<'a> { + pub(crate) destination: u64, + pub(crate) source: &'a [u8], +} + +/// The descriptor arrays of one `cuMemcpyBatchAsync_v2` call; `range` is the slice of the copy list it covers. +#[derive(Debug, PartialEq, Eq)] +pub(crate) struct BatchCall { + pub(crate) range: std::ops::Range, + pub(crate) destinations: Vec, + pub(crate) sources: Vec, + pub(crate) sizes: Vec, +} + +/// What one batched issue did. +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] +pub struct RefillBatchReport { + /// Slots whose copies were queued. + pub slots: usize, + /// Copies queued (batched or per copy). + pub copies: usize, + /// `cuMemcpyBatchAsync_v2` calls the driver accepted. + pub batch_calls: usize, + /// Copies issued one call each (no batch entry, a refused call, or a pageable bank). + pub per_copy: usize, +} + +/// The batch calls of `copies` in order: consecutive runs of at most `max_per_call` non-empty copies. An empty copy +/// moves no byte, so it is left out (`cuMemcpyBatchAsync_v2` refuses a zero size). +pub(crate) fn plan_batch_calls(copies: &[HostCopy<'_>], max_per_call: usize) -> Result> { + if max_per_call == 0 || max_per_call > MAX_COPIES_PER_CALL { + return Err(Error::InvalidSize); + } + let mut calls = Vec::new(); + let mut start = 0; + while start < copies.len() { + let end = (start + max_per_call).min(copies.len()); + calls.push(batch_call(copies, start..end)); + start = end; + } + Ok(calls) +} + +fn batch_call(copies: &[HostCopy<'_>], range: std::ops::Range) -> BatchCall { + let kept = || copies[range.clone()].iter().filter(|c| !c.source.is_empty()); + BatchCall { + destinations: kept().map(|c| c.destination).collect(), + sources: kept().map(|c| c.source.as_ptr() as u64).collect(), + sizes: kept().map(|c| c.source.len()).collect(), + range, + } +} + +/// Issue `copies` on `stream`: batched when the driver has the entry, per copy otherwise or from the first refused +/// call on. Returns the report and the refusal (the caller decides whether to stop batching); an error of a per-copy +/// call is returned as the per-copy path returns it. +pub(crate) fn issue_copies( + api: &AsyncApi, + copies: &[HostCopy<'_>], + stream: Stream, + max_per_call: usize, +) -> Result<(RefillBatchReport, Option)> { + let mut report = RefillBatchReport { copies: copies.len(), ..RefillBatchReport::default() }; + if !api.can_batch() { + per_copy(api, copies, stream)?; + report.per_copy = copies.len(); + return Ok((report, None)); + } + for mut call in plan_batch_calls(copies, max_per_call)? { + if let Err(refused) = api.copy_batch(&mut call, stream) { + let rest = &copies[call.range.start..]; + per_copy(api, rest, stream)?; + report.per_copy = rest.len(); + return Ok((report, Some(refused))); + } + report.batch_calls += 1; + } + Ok((report, None)) +} + +/// One `cuMemcpyHtoDAsync_v2` per copy, in order (the per-copy refill). +pub(crate) fn per_copy(api: &AsyncApi, copies: &[HostCopy<'_>], stream: Stream) -> Result<()> { + copies.iter().try_for_each(|c| api.copy(c.destination, c.source, stream)) +} + +#[cfg(test)] +mod tests { + use super::*; + + fn copies<'a>(bytes: &'a [u8], lens: &[usize]) -> Vec> { + let mut at = 0; + lens.iter() + .enumerate() + .map(|(i, &n)| { + let c = HostCopy { destination: 0x1000_0000 + 0x1_0000 * i as u64, source: &bytes[at..at + n] }; + at += n; + c + }) + .collect() + } + + #[test] + fn copies_split_into_ordered_calls_of_at_most_the_cap() { + let bytes = vec![7u8; 4096]; + let list = copies(&bytes, &[16; 7]); + let calls = plan_batch_calls(&list, 3).unwrap(); + assert_eq!(calls.iter().map(|c| c.range.clone()).collect::>(), vec![0..3, 3..6, 6..7]); + let flat: Vec = calls.iter().flat_map(|c| c.destinations.clone()).collect(); + assert_eq!(flat, list.iter().map(|c| c.destination).collect::>(), "same order, same destinations"); + let sources: Vec = calls.iter().flat_map(|c| c.sources.clone()).collect(); + assert_eq!(sources, list.iter().map(|c| c.source.as_ptr() as u64).collect::>()); + assert!(calls.iter().all(|c| c.sizes.iter().all(|&n| n == 16))); + } + + #[test] + fn a_list_within_the_cap_is_one_call_and_an_empty_list_none() { + let bytes = vec![1u8; 1 << 20]; + let list = copies(&bytes, &[1000, 300_000, 5, 64]); + let calls = plan_batch_calls(&list, 512).unwrap(); + assert_eq!(calls.len(), 1); + assert_eq!(calls[0].sizes, vec![1000, 300_000, 5, 64]); + assert!(plan_batch_calls(&[], 512).unwrap().is_empty()); + } + + #[test] + fn a_refill_of_2226_slots_takes_fourteen_calls_of_512() { + let bytes = vec![0u8; 3 * 2226]; + let list = copies(&bytes, &vec![1; 3 * 2226]); + let calls = plan_batch_calls(&list, 512).unwrap(); + assert_eq!(calls.len(), 14); + assert_eq!(calls.iter().map(|c| c.sizes.len()).sum::(), 3 * 2226); + assert_eq!(calls.last().unwrap().range.end, 3 * 2226); + } + + #[test] + fn empty_copies_are_left_out_but_keep_their_place_in_the_ranges() { + let bytes = vec![3u8; 64]; + let list = copies(&bytes, &[8, 0, 8, 0]); + let calls = plan_batch_calls(&list, 2).unwrap(); + assert_eq!(calls[0].range, 0..2); + assert_eq!(calls[0].sizes, vec![8]); + assert_eq!(calls[1].destinations, vec![list[2].destination]); + } + + #[test] + fn a_cap_outside_one_to_the_maximum_is_refused() { + let bytes = vec![0u8; 8]; + let list = copies(&bytes, &[8]); + assert!(plan_batch_calls(&list, 0).is_err()); + assert!(plan_batch_calls(&list, MAX_COPIES_PER_CALL + 1).is_err()); + assert!(plan_batch_calls(&list, MAX_COPIES_PER_CALL).is_ok()); + } +} diff --git a/crates/cuda-driver/src/refill_batch_copy_gpu.rs b/crates/cuda-driver/src/refill_batch_copy_gpu.rs new file mode 100644 index 00000000..b93ccb49 --- /dev/null +++ b/crates/cuda-driver/src/refill_batch_copy_gpu.rs @@ -0,0 +1,115 @@ +//! Model-free GPU check of the batched lent-slot refill (`LELEKA_REFILL_BATCH`): `N` slots are filled from one +//! registered host buffer twice, once one `cuMemcpyHtoDAsync_v2` per piece (the per-copy refill) and once through +//! `issue_copies` (`cuMemcpyBatchAsync_v2` in calls of 512), with three pieces per slot taken role-major from three +//! regions of the buffer (gate, up, down) like `MappedExpertBank::copy_pieces` does. Every slot byte must be equal in +//! both destinations and equal to the host bytes, and the bytes between the pieces must keep their fill pattern. +//! +//! Run (one process; a fault poisons the context): +//! cargo test --release -p leleka-cuda-driver --features cuda-driver,sm120 --lib -- --ignored --nocapture \ +//! refill_batch_copy_gpu +use crate::api::{AsyncApi, Stream}; +use crate::refill_batch_copy::{HostCopy, issue_copies, per_copy}; +use crate::{Context, DeviceBuffer, Driver}; + +const SLOTS: usize = 1024; +const SLOT: usize = 64 << 10; +const PIECE_MAX: usize = 20 << 10; +const REGION: usize = SLOTS * PIECE_MAX; +const UNTOUCHED: u8 = 0xA5; + +/// The three role pieces of a slot: (source offset in the host buffer, destination offset in the slot, bytes). +fn pieces(slot: usize) -> [(usize, usize, usize); 3] { + let len = |role: usize| 16 * (1 + (slot * 7 + role * 13) % (PIECE_MAX / 16 - 1)); + let (g, u, d) = (len(0), len(1), len(2)); + [(slot * PIECE_MAX, 0, g), (REGION + slot * PIECE_MAX, g, u), (2 * REGION + slot * PIECE_MAX, g + u, d)] +} + +fn host_bytes() -> Vec { + let mut x = 0x9E37_79B9_7F4A_7C15u64; + (0..3 * REGION) + .map(|_| { + x ^= x << 13; + x ^= x >> 7; + x ^= x << 17; + (x >> 24) as u8 + }) + .collect() +} + +fn slot_copies<'a>(host: &'a [u8], destination: u64) -> Vec> { + (0..SLOTS) + .flat_map(|slot| pieces(slot).map(move |p| (slot, p))) + .map(|(slot, (from, at, n))| HostCopy { + destination: destination + (slot * SLOT + at) as u64, + source: &host[from..from + n], + }) + .collect() +} + +fn expected(host: &[u8]) -> Vec { + let mut out = vec![UNTOUCHED; SLOTS * SLOT]; + for slot in 0..SLOTS { + for (from, at, n) in pieces(slot) { + out[slot * SLOT + at..slot * SLOT + at + n].copy_from_slice(&host[from..from + n]); + } + } + out +} + +/// Fill `dest` from `host` on `stream`, batched or per copy, and read it back. +fn fill(api: &AsyncApi, (host, dest): (&[u8], &mut DeviceBuffer<'_>), stream: Stream, batched: bool) -> Vec { + dest.copy_from(&vec![UNTOUCHED; SLOTS * SLOT]).unwrap(); + let copies = slot_copies(host, dest.handle.expect("live buffer").qwen_address()); + eprintln!("fill batched={batched}: {} copies issued next", copies.len()); + if batched { + let (report, refused) = issue_copies(api, &copies, stream, 512).unwrap(); + assert!(refused.is_none(), "the driver refused the batch: {refused:?}"); + assert_eq!((report.batch_calls, report.per_copy), ((3 * SLOTS).div_ceil(512), 0)); + } else { + per_copy(api, &copies, stream).unwrap(); + } + eprintln!("fill batched={batched}: issued, synchronising"); + api.synchronize_stream(stream).unwrap_or_else(|e| panic!("batched={batched}: synchronise failed: {e:?}")); + dest.copy_to_owned(SLOTS * SLOT).unwrap() +} + +fn compare(ctx: &Context<'_>, api: &AsyncApi, host: &[u8]) { + let (mut one, mut batch) = (ctx.allocate(SLOTS * SLOT).unwrap(), ctx.allocate(SLOTS * SLOT).unwrap()); + let guard = ctx.enter().unwrap(); + let stream = api.create_stream().unwrap(); + guard.finish().unwrap(); + let per_copy_bytes = fill(api, (host, &mut one), stream, false); + let batched_bytes = fill(api, (host, &mut batch), stream, true); + let want = expected(host); + let first_difference = (0..want.len()).find(|&i| batched_bytes[i] != per_copy_bytes[i]); + assert_eq!( + first_difference, + None, + "batched and per-copy slots differ (slot {:?})", + first_difference.map(|i| i / SLOT) + ); + assert!(per_copy_bytes == want, "the per-copy slots are not the host bytes"); + let guard = ctx.enter().unwrap(); + api.destroy_stream(stream).unwrap(); + guard.finish().unwrap(); +} + +#[test] +#[ignore = "needs a CUDA GPU"] +fn refill_batch_copy_gpu_slots_equal_per_copy() { + let driver = Driver::load().unwrap(); + let ctx = driver.device(0).unwrap().create_context(256 << 20).unwrap(); + let mut host = host_bytes(); + let api = AsyncApi::load().unwrap(); + assert!(api.can_batch(), "the driver does not export cuMemcpyBatchAsync_v2"); + let guard = ctx.enter().unwrap(); + api.register(&mut host).unwrap(); + guard.finish().unwrap(); + compare(&ctx, &api, &host); + let guard = ctx.enter().unwrap(); + api.unregister(&mut host).unwrap(); + guard.finish().unwrap(); + println!("refill batch copy: {SLOTS} slots x 3 pieces, batched == per copy == host bytes"); + drop(api); + ctx.close().unwrap(); +} diff --git a/crates/cuda-driver/src/root_exports.rs b/crates/cuda-driver/src/root_exports.rs index 71c5d8f0..e8e55d89 100644 --- a/crates/cuda-driver/src/root_exports.rs +++ b/crates/cuda-driver/src/root_exports.rs @@ -8,8 +8,8 @@ pub use device_slab::{DeviceSlice, SlabAllocator, SlabPolicy, SlabStats}; pub use gdn_state_finite_guard::GdnStateFiniteGuard; pub use head_greedy::{HEAD_GREEDY_WORKSPACE_BYTES, HeadGreedySelection, HeadGreedyWorkspace}; pub use mmq::resident::original_group::{ - OriginalMmqCopySchedule, OriginalMmqLayer, OriginalMmqOutput, OriginalStreamAllLayer, RingExperts, - original_mmq_group_bank_bytes, + OriginalMmqCopySchedule, OriginalMmqLayer, OriginalMmqOutput, OriginalStreamAllLayer, PrefetchSource, + PrefetchTarget, RingExperts, original_mmq_group_bank_bytes, }; pub use mmq::resident::{FiniteMmqOutput, MmqChunkActivation, MmqGroupActivation, MmqHidden, MmqWorkspace}; pub use mmq::{MmqExperiment, MmqFormat, MmqProfile, MmqRequest, MmqWeights}; @@ -19,7 +19,7 @@ pub use mtp_dense_kv::{ CompletedMtpAttention, CompletedMtpKvReplay, MtpInt8OwnerId, MtpInt8Snapshot, MtpOriginalInt8, MtpOriginalMixed, MtpOriginalQuery, }; -pub use original_expert_cache::OriginalExpertCache; +pub use original_expert_cache::{OriginalExpertCache, RefillBatchOptions}; pub use original_gpu_schedule::{ OriginalCapture, OriginalCapturePolicy, OriginalEventKind, OriginalGpuEvent, OriginalGpuGraph, OriginalGpuStream, OriginalGraphFlight, OriginalGraphKey, OriginalGraphRegistry, OriginalGraphResources, OriginalStreamKind, @@ -87,8 +87,8 @@ pub(crate) use qwen_dispatch::gdn_native_batch::GdnGeometry; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64", feature = "cuda-driver"))] pub use qwen_dispatch::gdn_native_batch::{ GDN_BATCH_EPSILON, GDN_BATCH_MAX_TOKENS, GdnBatchCompletion, GdnBatchPrefix, GdnBatchStage, GdnGemm, - GdnNativeFormat, GdnPrefillBatch, GdnStream, GemmShape, OriginalGdnPromptDevice, OriginalGdnPromptState, - OriginalGdnPromptWeights, + GdnNativeFormat, GdnPrefillBatch, GdnPromptOptions, GdnStream, GemmShape, OriginalGdnPromptDevice, + OriginalGdnPromptState, OriginalGdnPromptWeights, }; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64", feature = "cuda-driver"))] pub use qwen_dispatch::moe_prefill_batch::{ @@ -314,4 +314,4 @@ pub use prompt_sync_trace_types::RoutedGateUpQ8; #[allow(unused_imports)] pub use q5_kshape_types::DeviceBuffer; #[cfg(all(feature = "cuda-driver", any(target_os = "linux", target_os = "windows"), target_pointer_width = "64"))] -pub use qsa_prompt_index::{OriginalVerifyQsaJournal, OriginalVerifyRope}; +pub use qsa_prompt_index::{OriginalQsaOwners, OriginalVerifyQsaJournal, OriginalVerifyRope}; diff --git a/crates/cuda-driver/tests/original_serve_preflight_probe/synthetic_verifier/replay.rs b/crates/cuda-driver/tests/original_serve_preflight_probe/synthetic_verifier/replay.rs index 67cacdc2..2fa6ffe4 100644 --- a/crates/cuda-driver/tests/original_serve_preflight_probe/synthetic_verifier/replay.rs +++ b/crates/cuda-driver/tests/original_serve_preflight_probe/synthetic_verifier/replay.rs @@ -57,6 +57,8 @@ fn full_policy() -> OriginalMtpFullPolicy { gr: OriginalMtpGrVariant::Plain, kv: DraftKvPolicy::original_int8(1e7f32.powf(-2.0 / 64.0)), coupled_j: None, + chain_pipeline: false, + check_merge: false, } } impl<'ctx> Replay<'ctx> { diff --git a/crates/cuda-model/src/draft_check_batch.rs b/crates/cuda-model/src/draft_check_batch.rs new file mode 100644 index 00000000..e3548247 --- /dev/null +++ b/crates/cuda-model/src/draft_check_batch.rs @@ -0,0 +1,120 @@ +//! The batched numerical guard of the MTP draft step (`LELEKA_DRAFT_CHECK_MERGE`, off by default): the host half. +//! +//! A draft step launches a finite check (`mtp_original_finite`, floats) or a Q8_1 scale check (`mtp_original_q8_guard`, +//! blocks) after almost every kernel, one launch per buffer. Where several of those launches are ADJACENT in the +//! program (no other kernel or copy between them) the buffers cannot change between the first and the last of them, so +//! the run can be checked by one launch of `mtp_original_check_batch` at the position of the run, each entry setting +//! the status word its own launch set. Nothing is moved across another command: the checked (buffer, moment) pairs and +//! the status words are the ones of the separate launches. +//! +//! This module holds the pure parts: the descriptor the kernel reads (`encode`, the layout of +//! `mtp_original_check_batch.cu`), the grouping of adjacent checks (`merge_adjacent`), and, in the tests, a reference +//! of the kernel and the proof that a merged schedule leaves the same status words as the separate one for a +//! non-finite value placed anywhere. +use crate::{Error, Result}; + +/// By-value words of the kernel parameter (the shape of the GrMulti parameter). +pub const BATCH_WORDS: usize = 114; +/// Words of one entry: buffer address, count and kind, status address, reserved. +pub const ENTRY_WORDS: usize = 4; +/// Entries one launch holds: word 0 is the count. +pub const MAX_ENTRIES: usize = (BATCH_WORDS - 1) / ENTRY_WORDS; +/// Threads per block of every check launch, single or batched. +pub const THREADS: u32 = 256; + +/// What a check reads: f32 words, or the `half2` scale pair at the head of each 36-byte Q8_1 block. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum CheckKind { + Finite, + Q8Scale, +} + +/// One check launch: `count` floats or blocks at `data`, a non-finite one sets bit 0 of the word at `flag`. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub struct Check { + pub kind: CheckKind, + pub data: u64, + pub count: u32, + pub flag: u64, +} + +impl Check { + /// The grid of the separate launch of this check (block `THREADS`). + pub fn single_grid(&self) -> u32 { + self.count.div_ceil(THREADS) + } +} + +/// The descriptor words and the grid of one batched launch. +pub struct BatchLaunch { + pub words: Box<[u64; BATCH_WORDS]>, + pub grid: [u32; 3], +} + +/// The launch that checks `checks` (1 to `MAX_ENTRIES`): grid.y is the entry, grid.x covers the longest one. +pub fn encode(checks: &[Check]) -> Result { + if checks.is_empty() || checks.len() > MAX_ENTRIES { + return Err(Error::InvalidSize); + } + let mut words = Box::new([0u64; BATCH_WORDS]); + words[0] = checks.len() as u64; + for (e, check) in checks.iter().enumerate() { + if check.count == 0 || check.count > i32::MAX as u32 || check.flag % 4 != 0 || check.data == 0 { + return Err(Error::InvalidSize); + } + let kind = u64::from(check.kind == CheckKind::Q8Scale); + words[1 + ENTRY_WORDS * e] = check.data; + words[2 + ENTRY_WORDS * e] = u64::from(check.count) | kind << 32; + words[3 + ENTRY_WORDS * e] = check.flag; + } + let x = checks.iter().map(Check::single_grid).max().unwrap_or(1); + Ok(BatchLaunch { words, grid: [x, checks.len() as u32, 1] }) +} + +/// Replaces every maximal run of adjacent checks (as `view` sees them) by batches of at most `MAX_ENTRIES`; a run or +/// a chunk of one check, and every item before `keep`, stay as they are. Order and every other item are untouched. +pub fn merge_adjacent( + items: Vec, + keep: usize, + view: impl Fn(&T) -> Option, + mut batch: impl FnMut(&[Check]) -> Result, +) -> Result> { + let mut out = Vec::new(); + out.try_reserve_exact(items.len()).map_err(|_| Error::HostAllocation)?; + let mut run: Vec<(T, Check)> = Vec::new(); + for (i, item) in items.into_iter().enumerate() { + match view(&item).filter(|_| i >= keep) { + Some(check) => run.push((item, check)), + None => { + flush_run(&mut run, &mut out, &mut batch)?; + out.push(item); + } + } + } + flush_run(&mut run, &mut out, &mut batch)?; + Ok(out) +} + +fn flush_run( + run: &mut Vec<(T, Check)>, + out: &mut Vec, + batch: &mut impl FnMut(&[Check]) -> Result, +) -> Result<()> { + let mut rest = std::mem::take(run); + while !rest.is_empty() { + let tail = rest.split_off(rest.len().min(MAX_ENTRIES)); + if rest.len() == 1 { + out.extend(rest.drain(..).map(|(item, _)| item)); + } else { + let checks: Vec = rest.iter().map(|(_, check)| *check).collect(); + out.push(batch(&checks)?); + } + rest = tail; + } + Ok(()) +} + +#[cfg(test)] +mod model; +#[cfg(test)] +mod tests; diff --git a/crates/cuda-model/src/draft_check_batch/model.rs b/crates/cuda-model/src/draft_check_batch/model.rs new file mode 100644 index 00000000..3c04b02a --- /dev/null +++ b/crates/cuda-model/src/draft_check_batch/model.rs @@ -0,0 +1,249 @@ +//! The model of the device and of the draft step the tests run: memory, the single and batched kernels, schedules, and +//! the checks of one step in program order. +use super::*; +use std::collections::BTreeMap; + +const BLOCK: u32 = THREADS; + +// ------------------------------------------------------------------------------------- memory and kernels + +/// Device memory of the model: f32 buffers, Q8_1 scale pairs, and the status words by address. +#[derive(Clone, Default)] +pub(super) struct Memory { + pub(super) floats: BTreeMap>, + pub(super) scales: BTreeMap>, + pub(super) flags: BTreeMap, +} + +impl Memory { + /// `atomicOr(status, 1)` of the thread that found a non-finite value. + fn raise(&mut self, flag: u64) { + *self.flags.entry(flag).or_insert(0) |= 1; + } + fn bad(&self, kind: CheckKind, data: u64, i: usize) -> bool { + match kind { + CheckKind::Finite => !self.floats[&data][i].is_finite(), + CheckKind::Q8Scale => self.scales[&data][i].iter().any(|v| !v.is_finite()), + } + } + /// The grid-stride loop of one entry, for every (block, thread) of grid `x`; the body of both kernels. + fn entry(&mut self, (kind, data, count, flag): (CheckKind, u64, u32, u64), x: u32) { + for block in 0..x { + for thread in 0..BLOCK { + let mut i = block * BLOCK + thread; + while i < count { + if self.bad(kind, data, i as usize) { + self.raise(flag); + } + i += x * BLOCK; + } + } + } + } + /// The separate launch: `mtp_original_finite` or `mtp_original_q8_guard`. + pub(super) fn single(&mut self, c: &Check) { + self.entry((c.kind, c.data, c.count, c.flag), c.single_grid()); + } + /// `mtp_original_check_batch`, decoded from the descriptor words only, as the kernel does. + pub(super) fn batch(&mut self, launch: &BatchLaunch) { + let w = &launch.words; + for e in 0..launch.grid[1] as usize { + assert!(e < w[0] as usize, "a block row past the entry count returns"); + let meta = w[2 + ENTRY_WORDS * e]; + let kind = if meta >> 32 == 1 { CheckKind::Q8Scale } else { CheckKind::Finite }; + self.entry((kind, w[1 + ENTRY_WORDS * e], meta as u32, w[3 + ENTRY_WORDS * e]), launch.grid[0]); + } + } +} + +// ------------------------------------------------------------------------------------------- schedules + +/// A kernel that (re)writes buffers, a separate check, or a batch of checks. +#[derive(Clone, Debug, PartialEq)] +pub(super) enum Op { + Kernel(usize, Vec), + Check(Check), + Batch(Vec), +} + +pub(super) fn view(op: &Op) -> Option { + match op { + Op::Check(c) => Some(*c), + _ => None, + } +} + +pub(super) fn merge(ops: Vec, keep: usize) -> Vec { + merge_adjacent(ops, keep, view, |checks| Ok(Op::Batch(checks.to_vec()))).unwrap() +} + +/// The separate schedule a merged one stands for. +pub(super) fn expand(ops: &[Op]) -> Vec { + ops.iter() + .flat_map(|op| match op { + Op::Batch(checks) => checks.iter().copied().map(Op::Check).collect(), + other => vec![other.clone()], + }) + .collect() +} + +/// A non-finite value placed in `buffer[element]` right after kernel `after` wrote it. +#[derive(Clone, Copy)] +pub(super) struct Fault { + pub(super) after: usize, + pub(super) buffer: u64, + pub(super) element: usize, + pub(super) value: f32, +} + +pub(super) fn write(memory: &mut Memory, buffer: u64, fault: Option, kernel: usize) { + if let Some(v) = memory.floats.get_mut(&buffer) { + v.fill(1.0); + } + if let Some(v) = memory.scales.get_mut(&buffer) { + v.fill([0.5, 2.0]); + } + let Some(f) = fault.filter(|f| f.after == kernel && f.buffer == buffer) else { return }; + if let Some(v) = memory.floats.get_mut(&buffer) { + let len = v.len(); + v[f.element % len] = f.value; + } + if let Some(v) = memory.scales.get_mut(&buffer) { + let len = v.len(); + v[f.element / 2 % len][f.element % 2] = f.value; + } +} + +pub(super) fn run(ops: &[Op], blank: &Memory, fault: Option) -> BTreeMap { + let mut memory = blank.clone(); + for op in ops { + match op { + Op::Kernel(id, buffers) => buffers.iter().for_each(|b| write(&mut memory, *b, fault, *id)), + Op::Check(c) => memory.single(c), + Op::Batch(checks) => memory.batch(&encode(checks).unwrap()), + } + } + memory.flags +} + +// ----------------------------------------------------------------------------------- the draft step + +pub(super) const FLAGS: u64 = 0x9000_0000; +pub(super) const SCRATCH: u64 = 0x1000_0000; + +pub(super) fn flag(slot: u64) -> u64 { + FLAGS + 4 * slot +} +pub(super) fn buf(i: u64) -> u64 { + SCRATCH + 0x10_0000 * i +} +pub(super) fn finite(i: u64, count: u32, slot: u64) -> Op { + Op::Check(Check { kind: CheckKind::Finite, data: buf(i), count, flag: flag(slot) }) +} +pub(super) fn q8(i: u64, count: u32, slot: u64) -> Op { + Op::Check(Check { kind: CheckKind::Q8Scale, data: buf(i), count, flag: flag(slot) }) +} +pub(super) fn kernel(id: usize, writes: &[u64]) -> Op { + Op::Kernel(id, writes.iter().map(|i| buf(*i)).collect()) +} + +/// The checked buffers with their sizes: floats, or Q8_1 blocks for the ones in `Q8`. +pub(super) const SIZES: [(u64, usize); 13] = [ + (0, 12288), + (1, 6144), + (2, 6144), + (3, 6144), + (4, 2560), + (5, 10240), + (6, 10240), + (7, 320), + (8, 4), + (9, 2560), + (10, 640), + (11, 640), + (12, 1), +]; +pub(super) const Q8: [(u64, usize); 2] = [(20, 192), (21, 20)]; + +pub(super) fn blank() -> Memory { + let mut m = Memory::default(); + for (i, n) in SIZES { + m.floats.insert(buf(i), vec![1.0; n]); + } + for (i, n) in Q8 { + m.scales.insert(buf(i), vec![[0.5, 2.0]; n]); + } + m +} + +/// The checks of one draft step in the order of the program: the prefix (with its run of five guards after the GR +/// block) and the tail (with its runs of five after the MLP GR and of two after the shared gate and up), the kernels +/// between written as buffer writers. Buffers 1, 5, 6, 7 and 8 are written more than once, like `qcur`, `r`, `xn` and +/// `lo`. +pub(super) fn draft_step() -> Vec { + [prefix_part(), tail_part()].concat() +} + +/// The scalar prefix: its guards, with the run of five after the GR block. +pub(super) fn prefix_part() -> Vec { + vec![ + kernel(0, &[9]), + finite(9, 2560, 0), + kernel(1, &[5]), + finite(5, 10240, 1), + kernel(2, &[20]), + q8(20, 192, 2), + kernel(3, &[6]), + finite(6, 10240, 3), + kernel(4, &[6, 7, 8, 9, 12]), + finite(8, 4, 6), + finite(6, 10240, 6), + finite(7, 320, 7), + finite(12, 1, 7), + finite(9, 2560, 8), + kernel(5, &[10]), + finite(10, 640, 10), + kernel(6, &[11]), + finite(11, 640, 11), + ] +} + +/// The tail: attention and gate, the MLP GR with its run of five, the router and experts, the shared expert with its +/// run of two, the combine. +pub(super) fn tail_part() -> Vec { + vec![ + kernel(7, &[0]), + finite(0, 12288, 0), + kernel(8, &[1]), + finite(1, 6144, 1), + kernel(9, &[1]), + finite(1, 6144, 2), + kernel(10, &[2, 3]), + finite(2, 6144, 3), + kernel(11, &[4]), + finite(3, 6144, 4), + kernel(17, &[21]), + q8(21, 20, 5), + kernel(12, &[4]), + finite(4, 2560, 6), + kernel(13, &[5, 6, 7, 8, 12]), + finite(5, 10240, 7), + finite(6, 10240, 8), + finite(7, 320, 9), + finite(8, 4, 10), + finite(9, 2560, 11), + kernel(14, &[10]), + finite(10, 640, 12), + kernel(15, &[11]), + finite(11, 640, 13), + finite(12, 1, 13), + ] +} + +pub(super) fn checks_in(ops: &[Op]) -> usize { + ops.iter().map(|op| expand(std::slice::from_ref(op)).iter().filter(|o| view(o).is_some()).count()).sum() +} + +pub(super) fn launches_in(ops: &[Op]) -> usize { + ops.len() +} diff --git a/crates/cuda-model/src/draft_check_batch/tests.rs b/crates/cuda-model/src/draft_check_batch/tests.rs new file mode 100644 index 00000000..f4fcc98c --- /dev/null +++ b/crates/cuda-model/src/draft_check_batch/tests.rs @@ -0,0 +1,163 @@ +//! The batched guard leaves the status words of the separate launches, for a non-finite value anywhere. +use super::model::*; +use super::*; + +// ------------------------------------------------------------------------------------------------ tests + +#[test] +fn the_step_loses_exactly_the_adjacent_check_launches() { + let step = draft_step(); + let merged = merge(step.clone(), 0); + assert_eq!(checks_in(&merged), checks_in(&step)); + // runs of five (prefix guards), five (MLP GR outputs) and two (shared gate and up): 12 launches become 3 + assert_eq!(launches_in(&step) - launches_in(&merged), 9); + assert_eq!(merged.iter().filter(|op| matches!(op, Op::Batch(_))).count(), 3); +} + +#[test] +fn the_merged_schedule_expands_to_the_separate_one() { + let step = draft_step(); + assert_eq!(expand(&merge(step.clone(), 0)), step); +} + +#[test] +fn a_non_finite_value_anywhere_leaves_the_same_status_words() { + let step = draft_step(); + let merged = merge(step.clone(), 0); + let memory = blank(); + assert_eq!(run(&step, &memory, None), run(&merged, &memory, None)); + let (mut caught, mut missed) = (0, 0); + for fault in faults(&step, &memory) { + let separate = run(&step, &memory, Some(fault)); + let together = run(&merged, &memory, Some(fault)); + assert_eq!(separate, together, "fault {:?} after kernel {}", fault.value, fault.after); + if separate.is_empty() { missed += 1 } else { caught += 1 } + } + // the model is not vacuous: most faults are caught, and the ones that are not (a buffer overwritten before its + // check) are missed by both + assert!(caught > 400 && missed > 0, "caught {caught}, missed {missed}"); +} + +/// Every kernel output, at the first, the last, the block edges and a middle element, with NaN, +Inf and -Inf. +fn faults(ops: &[Op], memory: &Memory) -> Vec { + let mut all = Vec::new(); + for op in ops { + let Op::Kernel(after, buffers) = op else { continue }; + for &buffer in buffers { + let len = memory.floats.get(&buffer).map_or_else(|| memory.scales[&buffer].len() * 2, Vec::len); + let spots = [0, 1, 255, 256, 257, len / 2, len - 1].map(|e| e.min(len - 1)); + for element in spots { + for value in [f32::NAN, f32::INFINITY, f32::NEG_INFINITY] { + all.push(Fault { after: *after, buffer, element, value }); + } + } + } + } + all +} + +#[test] +fn every_status_word_stays_the_one_of_its_own_check() { + let step = draft_step(); + let merged = merge(step.clone(), 0); + let memory = blank(); + // a fault in a buffer raises the words of exactly the checks of that buffer after its last write, in both + let fault = Fault { after: 13, buffer: buf(6), element: 9000, value: f32::NAN }; + let words = run(&merged, &memory, Some(fault)); + assert_eq!(words.keys().copied().collect::>(), vec![flag(8)]); + assert_eq!(words, run(&step, &memory, Some(fault))); +} + +#[test] +fn runs_longer_than_a_launch_are_chunked_and_still_expand_to_the_original() { + for n in [1usize, 2, 27, 28, 29, 56, 57, 70] { + let ops: Vec = (0..n).map(|i| finite(i as u64 % 13, 4, i as u64)).collect(); + let merged = merge(ops.clone(), 0); + assert_eq!(expand(&merged), ops, "run of {n}"); + let expected = n / MAX_ENTRIES + usize::from(n % MAX_ENTRIES != 0); + assert_eq!(merged.len(), expected, "launches of a run of {n}"); + assert!(merged.iter().all(|op| !matches!(op, Op::Batch(c) if c.len() < 2 || c.len() > MAX_ENTRIES))); + } +} + +#[test] +fn only_adjacent_checks_are_merged_and_everything_else_is_untouched() { + let mut seed = 0x2545_f491_4f6c_dd1du64; + let mut next = move || { + seed ^= seed << 13; + seed ^= seed >> 7; + seed ^= seed << 17; + seed + }; + for _ in 0..200 { + let ops: Vec = (0..60) + .map(|i| if next() % 3 == 0 { kernel(i, &[next() % 13]) } else { finite(next() % 13, 8, i as u64) }) + .collect(); + let keep = (next() % 10) as usize; + let merged = merge(ops.clone(), keep); + assert_eq!(expand(&merged), ops); + assert_eq!(&merged[..keep.min(merged.len())], &ops[..keep.min(merged.len())].to_vec()[..], "items before keep"); + // between two batches or checks of the result there is a kernel: no two adjacent check launches remain unless + // they are on both sides of the protected prefix + for pair in merged.windows(2).skip(keep) { + let is_check = |op: &Op| matches!(op, Op::Check(_) | Op::Batch(_)); + assert!(!(is_check(&pair[0]) && is_check(&pair[1]))); + } + } +} + +#[test] +fn the_protected_prefix_is_never_merged() { + let ops = vec![finite(0, 4, 0), finite(1, 4, 1), finite(2, 4, 2), finite(3, 4, 3)]; + let merged = merge(ops.clone(), 2); + assert_eq!(merged.len(), 3); + assert_eq!(&merged[..2], &ops[..2]); + assert!(matches!(&merged[2], Op::Batch(c) if c.len() == 2)); +} + +#[test] +fn the_descriptor_is_the_layout_the_kernel_reads() { + let checks = [ + Check { kind: CheckKind::Finite, data: 0x1000, count: 10240, flag: 0x2004 }, + Check { kind: CheckKind::Q8Scale, data: 0x3000, count: 80, flag: 0x2008 }, + ]; + let launch = encode(&checks).unwrap(); + assert_eq!(launch.grid, [40, 2, 1]); + assert_eq!(launch.words[..9], [2, 0x1000, 10240, 0x2004, 0, 0x3000, 80 | 1 << 32, 0x2008, 0]); + assert!(launch.words[9..].iter().all(|w| *w == 0)); + let source = driver_source!("src/mtp_original_check_batch.cu"); + for needle in [ + "unsigned long long w[114]", + "sizeof(CheckBatch) == 912", + "b.w[1 + 4 * entry]", + "b.w[2 + 4 * entry]", + "b.w[3 + 4 * entry]", + "meta & 0xffffffffull", + "meta >> 32", + "blockIdx.y", + "!isfinite(reinterpret_cast(data)[i])", + "!isfinite(ds.x) || !isfinite(ds.y)", + "atomicOr(status, 1)", + ] { + assert!(source.contains(needle), "kernel source lost `{needle}`"); + } + assert_eq!(MAX_ENTRIES, 28); +} + +#[test] +fn a_descriptor_that_the_kernel_could_misread_is_refused() { + let ok = Check { kind: CheckKind::Finite, data: 0x1000, count: 4, flag: 0x2000 }; + assert!(encode(&[ok]).is_ok()); + assert!(encode(&[]).is_err()); + assert!(encode(&vec![ok; MAX_ENTRIES + 1]).is_err()); + assert!(encode(&[Check { count: 0, ..ok }]).is_err()); + assert!(encode(&[Check { count: i32::MAX as u32 + 1, ..ok }]).is_err()); + assert!(encode(&[Check { flag: 0x2001, ..ok }]).is_err()); + assert!(encode(&[Check { data: 0, ..ok }]).is_err()); +} + +#[test] +fn the_single_launch_grid_is_the_one_the_old_programs_used() { + let c = |count| Check { kind: CheckKind::Finite, data: 8, count, flag: 4 }; + assert_eq!([c(1).single_grid(), c(256).single_grid(), c(257).single_grid(), c(12288).single_grid()], [1, 1, 2, 48]); +} diff --git a/crates/cuda-model/src/lib.rs b/crates/cuda-model/src/lib.rs index 696bce8f..dd9130f4 100644 --- a/crates/cuda-model/src/lib.rs +++ b/crates/cuda-model/src/lib.rs @@ -18,6 +18,7 @@ macro_rules! driver_source { mod bringup_trace; pub mod command_profile; pub mod device_arena; +pub mod draft_check_batch; mod error; mod error_display; pub mod host_profile; @@ -28,6 +29,7 @@ pub mod original_mtp_loader; pub mod original_prefill_schedule; mod projection; pub mod qsa_prompt_attention_select; +pub mod ring_prefetch; pub mod s_gemv_legacy; pub mod serving_context; mod shapes; diff --git a/crates/cuda-model/src/ring_prefetch.rs b/crates/cuda-model/src/ring_prefetch.rs new file mode 100644 index 00000000..5fa16f12 --- /dev/null +++ b/crates/cuda-model/src/ring_prefetch.rs @@ -0,0 +1,261 @@ +//! Pure host-side half of the EXPERIMENTAL prompt copy-ring prefetch (`LELEKA_PREFILL_RING_PREFETCH`, off by +//! default; docs/experiments/ring-prefetch.md). +//! +//! The per-layer copy ring of a prompt chunk below the expert stream's row minimum copies every routed expert the +//! arena cache does not hold, but only after the layer's router ran. The PCIe link is idle during the layer's mixer +//! (GDN / QSA). The prefetch copies, while the previous layer's tail and this layer's mixer run, the experts this layer +//! MISSED most often in its recent chunks into the ring's own stage slots. When the router result arrives a +//! prefetched expert that is routed and still not resident is consumed from its slot (no second copy); every other +//! prefetched slot is dropped. The same experts reach the same kernels in the same group order: only the time and the +//! order of the copies change. +//! +//! This module holds what needs no GPU: the policy and its slot budget, the per-layer miss history and its ranking, +//! the matching of the prefetched set against the routed one, and the stage-slot search that skips reserved slots. +use std::collections::VecDeque; + +/// Experts per layer. +pub const EXPERTS: usize = 512; +/// Layers of the model. +pub const LAYERS: usize = 48; +/// A 512-bit set of experts of one layer. +pub type ExpertMask = [u64; EXPERTS / 64]; +/// A ring smaller than this (the literal 8-slot ring of the 512-row rung) is never prefetched into. +pub const MIN_RING_SLOTS: usize = 32; + +/// The prefetch switch: how many experts per layer at most, and over how many recent chunks the misses are counted. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub struct RingPrefetchPolicy { + /// at most this many experts per layer (also bounded by half of the ring, see [`RingPrefetchPolicy::budget`]) + pub top_k: usize, + /// the misses of the last `window` chunks of a layer are counted + pub window: usize, + /// EXPERIMENTAL on top of the prefetch: while the copies are pending, the copy stream is the `compute_drain` + /// background stream (the mixer's drains stop waiting for it; all-zero uploads become memsets; frees are deferred), + /// as under the chunk expert stream. Off: the drains stay context-wide and wait for the prefetch copies. + pub detach_drains: bool, +} + +impl RingPrefetchPolicy { + /// The offline study's operating point (57 % precision, 43 % of the need at K = 150 over N = 3..16 chunks). + pub const DEFAULT_TOP_K: usize = 150; + pub const DEFAULT_WINDOW: usize = 8; + pub const MAX_WINDOW: usize = 64; + + /// `top_k` and `window` clamped to what the ring and the history can hold; the drains stay context-wide. + pub fn new(top_k: usize, window: usize) -> Self { + Self { top_k: top_k.min(EXPERTS), window: window.clamp(1, Self::MAX_WINDOW), detach_drains: false } + } + + /// The same policy with [`RingPrefetchPolicy::detach_drains`] set to `on`. + pub fn with_detached_drains(self, on: bool) -> Self { + Self { detach_drains: on, ..self } + } + + /// The experts one layer may prefetch into a ring of `ring_slots` slots: none below [`MIN_RING_SLOTS`], else at + /// most half the ring, so the ring's own lookahead always keeps free slots for the mandatory copies. + pub fn budget(&self, ring_slots: usize) -> usize { + if ring_slots < MIN_RING_SLOTS { + return 0; + } + self.top_k.min(ring_slots / 2) + } +} + +/// Sets bit `expert` of `mask` (out-of-range experts are ignored). +pub fn mask_set(mask: &mut ExpertMask, expert: usize) { + if expert < EXPERTS { + mask[expert / 64] |= 1 << (expert % 64); + } +} + +/// Whether bit `expert` of `mask` is set. +pub fn mask_has(mask: &ExpertMask, expert: usize) -> bool { + expert < EXPERTS && mask[expert / 64] >> (expert % 64) & 1 == 1 +} + +/// The missed (routed and not resident) experts of the last `window` chunks, per layer, newest last. +#[derive(Clone, Debug)] +pub struct MissHistory { + window: usize, + layers: Vec>, +} + +impl MissHistory { + pub fn new(window: usize) -> Self { + let window = window.max(1); + Self { window, layers: (0..LAYERS).map(|_| VecDeque::with_capacity(window)).collect() } + } + + /// Appends one chunk's missed set of `layer`, forgetting the oldest beyond the window. + pub fn record(&mut self, layer: usize, missed: ExpertMask) { + let Some(chunks) = self.layers.get_mut(layer) else { return }; + if chunks.len() == self.window { + chunks.pop_front(); + } + chunks.push_back(missed); + } + + /// Chunks recorded for `layer` (at most the window). + pub fn depth(&self, layer: usize) -> usize { + self.layers.get(layer).map_or(0, VecDeque::len) + } + + /// At most `k` experts of `layer` ranked by how many of the recorded chunks missed them, then by the most recent + /// chunk that missed them, then by id; experts for which `skip` holds (resident now) are left out. + pub fn predict(&self, layer: usize, k: usize, skip: impl Fn(u32) -> bool) -> Vec { + let Some(chunks) = self.layers.get(layer) else { return Vec::new() }; + let mut ranked: Vec<(u32, usize, usize)> = Vec::new(); + for expert in 0..EXPERTS { + let (count, last) = Self::count_and_last(chunks, expert); + if count > 0 && !skip(expert as u32) { + ranked.push((expert as u32, count, last)); + } + } + ranked.sort_by(|a, b| b.1.cmp(&a.1).then(b.2.cmp(&a.2)).then(a.0.cmp(&b.0))); + ranked.into_iter().take(k).map(|(expert, _, _)| expert).collect() + } + + /// `(chunks that missed expert, 1 + index of the newest one)`; `(0, 0)` when none did. + fn count_and_last(chunks: &VecDeque, expert: usize) -> (usize, usize) { + let mut count = 0; + let mut last = 0; + for (index, mask) in chunks.iter().enumerate() { + if mask_has(mask, expert) { + count += 1; + last = index + 1; + } + } + (count, last) + } +} + +/// How the routed sources of a layer met the prefetched set. +#[derive(Clone, Debug, Default, PartialEq, Eq)] +pub struct PrefetchMatch { + /// `(source index, prefetch entry index)`: the source is consumed from the entry's slot + pub hits: Vec<(usize, usize)>, + /// prefetch entries no source consumed: their slots are returned unused + pub wasted: Vec, +} + +/// Matches the prefetched experts (`prefetched[i]` is entry `i`) against the sources that need a copy: +/// `needs_copy[s]` is `Some(expert)` for a routed source that is not resident (and not staged otherwise), `None` +/// otherwise. Every entry is consumed at most once and by at most one source; an entry whose expert is not among the +/// needing sources is wasted. +pub fn match_prefetch(prefetched: &[u32], needs_copy: &[Option]) -> PrefetchMatch { + let mut used = vec![false; prefetched.len()]; + let mut out = PrefetchMatch::default(); + for (source, expert) in needs_copy.iter().enumerate() { + let Some(expert) = expert else { continue }; + let found = prefetched.iter().enumerate().position(|(i, e)| e == expert && !used[i]); + if let Some(entry) = found { + used[entry] = true; + out.hits.push((source, entry)); + } + } + out.wasted = (0..prefetched.len()).filter(|i| !used[*i]).collect(); + out +} + +/// The first slot from `start` (wrapping over `slots`) that `reserved` does not hold, or `None` when every slot is +/// reserved. With no reservation this is `start` itself, the literal ring order. +pub fn next_unreserved_slot(start: usize, slots: usize, reserved: impl Fn(usize) -> bool) -> Option { + (0..slots).map(|step| (start + step) % slots).find(|slot| !reserved(*slot)) +} + +/// The copy-ring check that refused: the driver error stays `InvalidProjectionShape`, the trace names the check. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum RingRefusal { + /// `stage_one` of a source that already holds a slot and was not prefetched + SourceAlreadyStaged, + /// `stage_one` found every slot reserved by prefetched sources + AllSlotsReserved, + /// `stage_one`'s slot still holds a copy no gather read yet + SlotNotGathered, + /// `gather` of a source that needs a slot and has none + GatherNoSlot, + /// `gather` of a slot no copy filled + GatherSlotNotLive, + /// `gather` of a slot an earlier gather already read + GatherSlotGathered, +} + +impl RingRefusal { + /// The check's name in the `RING-REFUSE` trace line. + pub fn check(self) -> &'static str { + match self { + Self::SourceAlreadyStaged => "stage.source_already_staged", + Self::AllSlotsReserved => "stage.all_slots_reserved", + Self::SlotNotGathered => "stage.slot_not_gathered", + Self::GatherNoSlot => "gather.no_slot", + Self::GatherSlotNotLive => "gather.slot_not_live", + Self::GatherSlotGathered => "gather.slot_already_gathered", + } + } +} + +/// One stage slot of the copy ring: a copy filled it (`live`), a gather read it (`gathered`), a prefetched source +/// holds it until its gather (`reserved`). +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] +pub struct SlotState { + pub live: bool, + pub gathered: bool, + pub reserved: bool, +} + +impl SlotState { + /// A slot a prefetch copy filled for a routed source. + pub const PREFETCHED: Self = Self { live: true, gathered: false, reserved: true }; + + /// After a stage copy into it. + pub fn staged(&mut self) { + *self = Self { live: true, gathered: false, reserved: false }; + } + + /// A gather may read it: a copy filled it and no gather read it yet. + pub fn check_gather(self) -> Result<(), RingRefusal> { + match (self.live, self.gathered) { + (false, _) => Err(RingRefusal::GatherSlotNotLive), + (true, true) => Err(RingRefusal::GatherSlotGathered), + (true, false) => Ok(()), + } + } + + /// After its gather: the slot is free for the next copy; returns whether it was reserved. + pub fn gathered(&mut self) -> bool { + self.gathered = true; + std::mem::take(&mut self.reserved) + } +} + +/// What `stage_one` does with a source: `Ok(true)` copy it, `Ok(false)` nothing (resident, a chunk-stream entry or +/// prefetched); a source that already holds a slot without being prefetched is refused. +pub fn stage_needed(no_copy: bool, prefetched: bool, has_slot: bool) -> Result { + if no_copy || prefetched { + return Ok(false); + } + if has_slot { Err(RingRefusal::SourceAlreadyStaged) } else { Ok(true) } +} + +/// The slot `stage_one` copies into: the first one from `start` (in ring order, wrapping) that no prefetched source +/// holds and that is free (never filled, or its copy already gathered). Refused when every slot is reserved, or when +/// every unreserved slot still holds a copy no gather read; the stage-ahead walk then waits for a gather +/// (`Ring::stage_room`). +/// +/// The literal ring always finds `start` itself: its copies and gathers run in the same order and its lookahead is one +/// slot short of the ring, so the next slot in order holds the oldest copy, already gathered. With prefetched sources +/// the copies skip the hits, the slot order is no longer the gather order, and the next slot in order can hold a copy +/// of an earlier source of the same layer that is not gathered yet (PET.1: layers 46/47, 410-460 sources on 384 slots, +/// `stage.slot_not_gathered` with no slot reserved); the search skips it. +pub fn stage_target(slots: usize, start: usize, state: impl Fn(usize) -> SlotState) -> Result { + next_unreserved_slot(start, slots, |s| state(s).reserved).ok_or(RingRefusal::AllSlotsReserved)?; + let free = |s: usize| { + let target = state(s); + !target.reserved && (!target.live || target.gathered) + }; + (0..slots).map(|step| (start + step) % slots).find(|s| free(*s)).ok_or(RingRefusal::SlotNotGathered) +} + +#[cfg(test)] +#[path = "ring_prefetch/tests.rs"] +mod tests; diff --git a/crates/cuda-model/src/ring_prefetch/tests.rs b/crates/cuda-model/src/ring_prefetch/tests.rs new file mode 100644 index 00000000..f66bd6a6 --- /dev/null +++ b/crates/cuda-model/src/ring_prefetch/tests.rs @@ -0,0 +1,327 @@ +//! The ring prefetch's pure halves: the budget, the miss ranking, the consume-once matching and the slot search, plus +//! a host model of the copy ring's stage-ahead walk with reserved (prefetched) slots. +use super::*; + +fn mask(experts: &[usize]) -> ExpertMask { + let mut m = [0u64; EXPERTS / 64]; + for &e in experts { + mask_set(&mut m, e); + } + m +} + +#[test] +fn the_budget_is_bounded_by_half_the_ring_and_zero_on_the_small_ring() { + let policy = RingPrefetchPolicy::new(150, 8); + assert_eq!(policy.budget(8), 0, "the literal 8-slot ring of the 512-row rung is never prefetched into"); + assert_eq!(policy.budget(31), 0); + assert_eq!(policy.budget(32), 16); + assert_eq!(policy.budget(96), 48); + assert_eq!(policy.budget(384), 150); + assert_eq!(RingPrefetchPolicy::new(10_000, 0), RingPrefetchPolicy { top_k: 512, window: 1, detach_drains: false }); + assert_eq!(RingPrefetchPolicy::new(1, 1_000).window, RingPrefetchPolicy::MAX_WINDOW); +} + +#[test] +fn masks_hold_exactly_the_experts_set() { + let m = mask(&[0, 63, 64, 511, 512]); + assert!(mask_has(&m, 0) && mask_has(&m, 63) && mask_has(&m, 64) && mask_has(&m, 511)); + assert!(!mask_has(&m, 1) && !mask_has(&m, 512), "out of range is never set"); +} + +#[test] +fn the_ranking_is_frequency_then_recency_then_id() { + let mut history = MissHistory::new(4); + history.record(3, mask(&[10, 20, 30])); + history.record(3, mask(&[10, 40])); + history.record(3, mask(&[10, 20, 50])); + // 10: 3 chunks; 20: 2 (newest 3); 50: 1 (newest 3); 40: 1 (newest 2); 30: 1 (newest 1) + assert_eq!(history.predict(3, 10, |_| false), [10, 20, 50, 40, 30]); + assert_eq!(history.predict(3, 2, |_| false), [10, 20], "bounded by k"); + assert!(history.predict(4, 10, |_| false).is_empty(), "history is per layer"); +} + +#[test] +fn resident_experts_are_skipped_and_ties_break_by_id() { + let mut history = MissHistory::new(2); + history.record(0, mask(&[7, 5, 9])); + assert_eq!(history.predict(0, 10, |_| false), [5, 7, 9]); + assert_eq!(history.predict(0, 10, |e| e == 7), [5, 9], "an expert resident now is not prefetched"); +} + +#[test] +fn the_window_forgets_the_oldest_chunk() { + let mut history = MissHistory::new(2); + history.record(1, mask(&[1])); + history.record(1, mask(&[2])); + history.record(1, mask(&[3])); + assert_eq!(history.depth(1), 2); + assert_eq!(history.predict(1, 10, |_| false), [3, 2], "expert 1 left the window"); + history.record(LAYERS, mask(&[1])); + assert!(history.predict(LAYERS, 10, |_| false).is_empty(), "an out-of-range layer is ignored"); +} + +#[test] +fn every_prefetched_entry_is_consumed_at_most_once_and_misses_are_dropped() { + let prefetched = [40, 10, 20, 99]; + // sources: 10 (copy), 15 (copy), 20 (resident -> None), 40 (copy), 40 again (impossible routing, consumed once) + let needs = [Some(10), Some(15), None, Some(40), Some(40)]; + let m = match_prefetch(&prefetched, &needs); + assert_eq!(m.hits, [(0, 1), (3, 0)]); + assert_eq!(m.wasted, [2, 3], "20 became resident, 99 was not routed"); + let consumed: Vec = m.hits.iter().map(|h| h.1).chain(m.wasted.iter().copied()).collect(); + let mut sorted = consumed.clone(); + sorted.sort_unstable(); + assert_eq!(sorted, [0, 1, 2, 3], "every entry is either consumed or dropped, exactly once"); +} + +#[test] +fn the_slot_search_is_the_literal_order_without_reservations() { + assert_eq!(next_unreserved_slot(5, 8, |_| false), Some(5)); + assert_eq!(next_unreserved_slot(7, 8, |s| s == 7 || s == 0), Some(1), "wraps past reserved slots"); + assert_eq!(next_unreserved_slot(0, 4, |_| true), None); +} + +/// One source of the ring model: resident, a prefetch hit holding a reserved slot, or a mandatory copy. +#[derive(Clone, Copy, PartialEq, Debug)] +enum Kind { + Resident, + Hit(usize), + Copy, +} + +/// The copy ring's slot bookkeeping driven by the same functions the driver's `Ring` calls (`stage_needed`, +/// `stage_target`, `SlotState`): the slots, the slot each source reads and the next slot of the rotation. +struct RingModel { + ring: Vec, + kinds: Vec, + at: Vec>, + next: usize, +} + +impl RingModel { + /// The ring after `adopt_prefetch`: every hit's slot is reserved for its source. + fn new(slots: usize, kinds: &[Kind]) -> Self { + let mut model = Self { + ring: vec![SlotState::default(); slots], + kinds: kinds.to_vec(), + at: vec![None; kinds.len()], + next: 0, + }; + for (i, kind) in kinds.iter().enumerate() { + if let Kind::Hit(slot) = kind { + model.ring[*slot] = SlotState::PREFETCHED; + model.at[i] = Some(*slot); + } + } + model + } + + /// `Ring::stage_room`: always true without reserved slots (the literal ring). + fn room(&self, index: usize) -> bool { + let found = stage_target(self.ring.len(), self.next, |s| self.ring[s]).is_ok(); + let free = self.ring.iter().any(|s| !s.reserved && (!s.live || s.gathered)); + assert_eq!(found, free, "stage_target refuses only when no unreserved slot is free (PET.1)"); + self.kinds[index] != Kind::Copy || found + } + + /// `Ring::stage_one`. + fn stage(&mut self, index: usize) -> Result<(), RingRefusal> { + let kind = self.kinds[index]; + let prefetched = matches!(kind, Kind::Hit(_)); + if !stage_needed(kind == Kind::Resident, prefetched, self.at[index].is_some())? { + return Ok(()); + } + let sl = stage_target(self.ring.len(), self.next, |s| self.ring[s])?; + let target = self.ring[sl]; + assert!(!target.reserved && !(target.live && !target.gathered), "source {index} overwrites slot {sl}"); + self.ring[sl].staged(); + self.at[index] = Some(sl); + self.next = (sl + 1) % self.ring.len(); + Ok(()) + } + + /// `Ring::gather` / `after_gather`. + fn gather(&mut self, j: usize) -> Result<(), RingRefusal> { + if self.kinds[j] == Kind::Resident { + return Ok(()); + } + let sl = self.at[j].ok_or(RingRefusal::GatherNoSlot)?; + self.ring[sl].check_gather()?; + self.ring[sl].gathered(); + Ok(()) + } +} + +/// The driver's stage-ahead walk (`stream_through_ring`); returns the slot each source was read from. +fn walk(slots: usize, kinds: &[Kind]) -> Vec> { + let mut model = RingModel::new(slots, kinds); + let mut staged = 0usize; + for j in 0..kinds.len() { + while staged < kinds.len() && staged < j + slots && model.room(staged) { + model.stage(staged).expect("stage_one refused"); + staged += 1; + } + assert!(staged > j, "source {j} is staged before its gather"); + model.gather(j).expect("gather refused"); + } + model.at +} + +#[test] +fn reserved_slots_are_never_overwritten_before_their_gather() { + let slots = 32; + let budget = RingPrefetchPolicy::new(150, 8).budget(slots); + let kinds: Vec = (0..120) + .map(|i| match i % 5 { + 0 if i / 5 < budget => Kind::Hit(i / 5), + 1 => Kind::Resident, + _ => Kind::Copy, + }) + .collect(); + let at = walk(slots, &kinds); + for (i, kind) in kinds.iter().enumerate() { + match kind { + Kind::Resident => assert_eq!(at[i], None), + Kind::Hit(slot) => assert_eq!(at[i], Some(*slot), "a hit is consumed from its prefetched slot"), + Kind::Copy => assert!(at[i].is_some()), + } + } +} + +#[test] +fn without_prefetch_the_walk_is_the_literal_rotation() { + let at = walk(8, &[Kind::Copy; 20]); + let want: Vec> = (0..20).map(|i| Some(i % 8)).collect(); + assert_eq!(at, want); +} + +#[test] +fn a_ring_half_reserved_still_stages_every_copy() { + let mut kinds: Vec = (0..16).map(Kind::Hit).collect(); + kinds.extend([Kind::Copy; 100]); + kinds.rotate_left(8); // copies before and after the hits + assert!(walk(32, &kinds).iter().all(Option::is_some)); +} + +#[test] +fn a_prefetched_source_is_never_staged_again() { + let mut model = RingModel::new(8, &[Kind::Hit(3), Kind::Copy]); + model.stage(0).expect("a prefetched source needs no stage copy"); + assert_eq!((model.at[0], model.ring[3]), (Some(3), SlotState::PREFETCHED), "its slot and state are untouched"); + model.stage(1).unwrap(); + assert_eq!(model.at[1], Some(0), "the next copy skips nothing but the reserved slot 3"); + assert_eq!(stage_needed(false, false, true), Err(RingRefusal::SourceAlreadyStaged)); + assert_eq!(stage_needed(false, true, true), Ok(false)); + assert_eq!(stage_needed(true, false, false), Ok(false)); +} + +#[test] +fn a_reserved_slot_is_skipped_until_its_gather_then_reused() { + let mut ring = [SlotState::PREFETCHED, SlotState::default(), SlotState::default()]; + assert_eq!(stage_target(3, 0, |s| ring[s]), Ok(1), "slot 0 is reserved"); + ring[1].staged(); + ring[2].staged(); + assert_eq!(stage_target(3, 1, |s| ring[s]), Err(RingRefusal::SlotNotGathered), "1 holds an unread copy"); + assert!(ring[0].gathered(), "the gather releases the reservation"); + assert_eq!(stage_target(3, 0, |s| ring[s]), Ok(0), "a gathered slot takes the next copy"); + let all = [SlotState::PREFETCHED; 2]; + assert_eq!(stage_target(2, 0, |s| all[s]), Err(RingRefusal::AllSlotsReserved)); +} + +#[test] +fn a_gather_reads_a_slot_exactly_once() { + let mut slot = SlotState::default(); + assert_eq!(slot.check_gather(), Err(RingRefusal::GatherSlotNotLive)); + slot.staged(); + assert_eq!(slot.check_gather(), Ok(())); + assert!(!slot.gathered(), "a staged slot was not reserved"); + assert_eq!(slot.check_gather(), Err(RingRefusal::GatherSlotGathered)); + let mut model = RingModel::new(4, &[Kind::Copy]); + assert_eq!(model.gather(0), Err(RingRefusal::GatherNoSlot), "a gather before the stage copy is refused"); +} + +#[test] +fn every_refusal_has_its_own_trace_name() { + use RingRefusal::*; + let all = + [SourceAlreadyStaged, AllSlotsReserved, SlotNotGathered, GatherNoSlot, GatherSlotNotLive, GatherSlotGathered]; + let mut names: Vec<&str> = all.iter().map(|r| r.check()).collect(); + names.sort_unstable(); + names.dedup(); + assert_eq!(names.len(), all.len()); +} + +#[test] +fn the_drains_stay_context_wide_unless_detached() { + let policy = RingPrefetchPolicy::new(150, 8); + assert!(!policy.detach_drains); + assert!(policy.with_detached_drains(true).detach_drains); +} + +/// A small deterministic generator for the randomized ring walks. +struct Lcg(u64); + +impl Lcg { + fn below(&mut self, n: usize) -> usize { + self.0 = self.0.wrapping_mul(6364136223846793005).wrapping_add(1442695040888963407); + ((self.0 >> 33) as usize) % n + } +} + +/// `sources` routed experts on `slots` stage slots: about a tenth resident, and the prefetch's `budget` entries in +/// slots `0..budget`, each consumed (a hit) with probability ~55 % by a random copy source among the first ones. +fn prefetched_layer(seed: u64, sources: usize, slots: usize) -> Vec { + let mut rng = Lcg(seed); + let mut kinds: Vec = + (0..sources).map(|_| if rng.below(10) == 0 { Kind::Resident } else { Kind::Copy }).collect(); + let budget = RingPrefetchPolicy::new(150, 8).budget(slots); + for slot in 0..budget { + if rng.below(100) < 55 { + let source = rng.below(sources.min(300)); + if kinds[source] == Kind::Copy { + kinds[source] = Kind::Hit(slot); + } + } + } + kinds +} + +#[test] +fn more_sources_than_slots_with_prefetch_hits_never_stage_onto_an_unread_slot() { + // PET.1: layers 46/47 route 410-460 experts on the 384-slot ring; the stage order wraps past the hits + for seed in 0..200 { + let kinds = prefetched_layer(seed, 460, 384); + let at = walk(384, &kinds); + for (i, kind) in kinds.iter().enumerate() { + match kind { + Kind::Resident => assert_eq!(at[i], None), + Kind::Hit(slot) => assert_eq!(at[i], Some(*slot), "seed {seed}: hit {i} reads its prefetched slot"), + Kind::Copy => assert!(at[i].is_some(), "seed {seed}: copy {i} was staged"), + } + } + } +} + +#[test] +fn the_next_slot_in_order_may_be_unread_after_hits_and_the_search_skips_it() { + // slot 1 holds an unread copy (an earlier source), slot 2 is free: the literal "next in order" would be refused + let mut ring = [SlotState::default(); 4]; + ring[0].staged(); + ring[0].gathered(); + ring[1].staged(); + assert_eq!(stage_target(4, 1, |s| ring[s]), Ok(2)); + ring[2].staged(); + ring[3].staged(); + assert_eq!(stage_target(4, 1, |s| ring[s]), Ok(0), "wraps to the gathered slot"); +} + +#[test] +fn every_size_and_seed_keeps_the_ring_sound() { + for (sources, slots) in [(40, 32), (100, 32), (200, 96), (460, 384), (512, 384), (300, 384)] { + for seed in 0..50 { + let kinds = prefetched_layer(seed, sources, slots); + assert!(walk(slots, &kinds).iter().zip(&kinds).all(|(at, k)| at.is_some() == (*k != Kind::Resident))); + } + } +} diff --git a/crates/deploy/src/config/tests.rs b/crates/deploy/src/config/tests.rs index df59bd86..faaa7c3f 100644 --- a/crates/deploy/src/config/tests.rs +++ b/crates/deploy/src/config/tests.rs @@ -259,6 +259,47 @@ fn tokens_are_printable_distinct_and_long_enough() { assert!((32..=4096).contains(&a.len()) && a.bytes().all(|c| (0x21..=0x7e).contains(&c))); } +#[test] +fn the_prompt_loan_ladder_is_on_for_the_5090_profiles_and_not_for_the_laptop() { + let key = "LELEKA_PREFILL_LOAN_TIERS"; + for name in ["rtx5090-32g", "rtx5090-32g-file", "rtx5090-32g-gguf-ple"] { + assert_eq!( + config(name) + .engine_environment() + .get(key) + .map(String::as_str), + Some("1"), + "{name}" + ); + } + assert!(!config("rtx3080-16g").engine_environment().contains_key(key)); +} + +#[test] +fn the_switches_that_passed_the_bitwise_gate_are_on_for_the_5090_profiles_only() { + // teacher-forced identity: 2057 rows, 1036 draft lines, A/A floor (step ledger, rows O8, B3, Q7) + for key in [ + "LELEKA_DRAFT_CHECK_MERGE", + "LELEKA_PREFIX_PARK_FAST", + "LELEKA_DECODE_GRAPH_REUSE", + ] { + for name in ["rtx5090-32g", "rtx5090-32g-file", "rtx5090-32g-gguf-ple"] { + assert_eq!( + config(name) + .engine_environment() + .get(key) + .map(String::as_str), + Some("1"), + "{name} {key}" + ); + } + assert!( + !config("rtx3080-16g").engine_environment().contains_key(key), + "{key}" + ); + } +} + #[test] fn the_server_profile_switches_reach_the_engine_environment_through_the_saved_config() { // `up` saves the RunConfig (profile.engine_env inside) as leleka.json; `run` loads it and `start_engine` hands @@ -308,3 +349,23 @@ fn expert_environment_wins_over_the_profile() { assert_eq!(env["LELEKA_ORIGINAL_SERVE_PCIE_FRAC"], "0.2"); assert_eq!(env["LELEKA_ORIGINAL_SERVE_EXPERT_SLOTS"], "auto"); } + +#[test] +fn the_expert_stream_starts_at_1536_rows_for_the_5090_profiles_only() { + // chunk residual hashes equal, prefill.read -180 ms at tails of 1.5-4k tokens (step ledger, row Q5) + for name in ["rtx5090-32g", "rtx5090-32g-file", "rtx5090-32g-gguf-ple"] { + assert_eq!( + config(name) + .engine_environment() + .get("STRATA_PREFILL_STREAM_MIN") + .map(String::as_str), + Some("1536"), + "{name}" + ); + } + assert!( + !config("rtx3080-16g") + .engine_environment() + .contains_key("STRATA_PREFILL_STREAM_MIN") + ); +} diff --git a/crates/deploy/src/profile/profile_limits.rs b/crates/deploy/src/profile/profile_limits.rs index 213785ac..d9983dbf 100644 --- a/crates/deploy/src/profile/profile_limits.rs +++ b/crates/deploy/src/profile/profile_limits.rs @@ -111,8 +111,7 @@ impl Profile { for (key, value) in &self.engine_env { if !engine_env_key_ok(key) { return Err(format!( - "engine_env key {key} must be an upper-case LELEKA_ORIGINAL_SERVE_*, LELEKA_SM120_*, \ - LELEKA_DRAFT_* or LELEKA_PLE_* name (or LELEKA_CHAIN)" + "engine_env key {key} must be an upper-case name starting with one of {ENGINE_ENV_PREFIXES:?}" )); } if value.is_empty() || value.len() > 1024 || value.chars().any(char::is_control) { @@ -127,14 +126,27 @@ impl Profile { /// LELEKA_CHAIN selects the chain-kernel group (docs/chain-kernels.md), LELEKA_SM120_* the compute-capability-12 /// kernel switches, LELEKA_DRAFT_* the draft-round ones (docs/experiments/draft-round-5090.md), LELEKA_PLE_* the -/// GGUF PLE row reader -/// (`kar_source: none`); every other switch is a serve-stack one. +/// GGUF PLE row reader (`kar_source: none`), LELEKA_PREFILL_* the prompt-prefill switches (the loan ladder, +/// docs/prefill-throughput.md), LELEKA_PREFIX_* the prefix-cache parking and LELEKA_DECODE_* the decode graph reuse +/// (docs/experiments/step-ledger.md rows B3, Q7), STRATA_PREFILL_STREAM_MIN the chunk size from which the prompt +/// streams every non-resident expert (row Q5); every other switch is a serve-stack one. +/// The name prefixes a profile `engine_env` key may start with. +const ENGINE_ENV_PREFIXES: [&str; 9] = [ + "LELEKA_ORIGINAL_SERVE_", + "LELEKA_SM120_", + "LELEKA_DRAFT_", + "LELEKA_PLE_", + "LELEKA_PREFILL_", + "LELEKA_PREFIX_", + "LELEKA_DECODE_", + "LELEKA_CHAIN", + "STRATA_PREFILL_STREAM_", +]; + fn engine_env_key_ok(key: &str) -> bool { - let known = key.starts_with("LELEKA_ORIGINAL_SERVE_") - || key.starts_with("LELEKA_SM120_") - || key.starts_with("LELEKA_DRAFT_") - || key.starts_with("LELEKA_PLE_") - || key == "LELEKA_CHAIN"; + let known = ENGINE_ENV_PREFIXES + .iter() + .any(|prefix| key.starts_with(prefix)); known && key .bytes() diff --git a/crates/deploy/src/sealed.rs b/crates/deploy/src/sealed.rs index 3520c663..0ae33c25 100644 --- a/crates/deploy/src/sealed.rs +++ b/crates/deploy/src/sealed.rs @@ -30,6 +30,9 @@ mod tests; mod exec_arguments; pub use exec_arguments::{archive_serve_extents, parse_seal_exec, substitute}; +mod single_copy; +pub use single_copy::{ALLOW_FULL_MEMFD_ENV, SINGLE_COPY_SLACK_BYTES, single_copy_verdict}; + #[cfg(not(target_os = "linux"))] mod unsupported_host; #[cfg(not(target_os = "linux"))] diff --git a/crates/deploy/src/sealed/linux.rs b/crates/deploy/src/sealed/linux.rs index 900d632e..a4f654b2 100644 --- a/crates/deploy/src/sealed/linux.rs +++ b/crates/deploy/src/sealed/linux.rs @@ -240,6 +240,16 @@ pub fn check_inherited_archive(fd: u32, expect_bytes: u64) -> Result<(), String> Ok(()) } +/// RAM the inherited sealed memfd really holds: allocated blocks (`st_blocks`), not the apparent length. A sparse copy +/// (`memfd_extents: ple_only`) holds only its extents, a full copy holds the whole archive. +pub fn inherited_archive_allocated_bytes(fd: u32) -> Result { + use std::os::unix::fs::MetadataExt; + let meta = open_inherited(fd)? + .metadata() + .map_err(|e| format!("cannot inspect descriptor {fd}: {e}"))?; + Ok(meta.blocks() * 512) +} + /// `leleka exec-inherit -- COMMAND ARG...`: standard input is the sealed archive. Move it to a descriptor /// number >= 3 (inheritable), give the command `/dev/null` as standard input, replace `{FD}` and `exec`. pub fn exec_inherit(args: &[String]) -> Result { diff --git a/crates/deploy/src/sealed/single_copy.rs b/crates/deploy/src/sealed/single_copy.rs new file mode 100644 index 00000000..90c515b6 --- /dev/null +++ b/crates/deploy/src/sealed/single_copy.rs @@ -0,0 +1,45 @@ +//! The single-copy rule for an inherited sealed memfd: a `ple_only` profile must not be handed the whole archive. +//! +//! The lab holder (`scripts/e2e/decode/single-copy-holder.sh`, `kar_holder2.py`) seals the memfd before the engine +//! starts. A holder that copies the whole 55.3 GB archive leaves 36.6 GiB of level-2 re-encodings in shmem that no +//! reader touches, next to the 46.8 GiB resident expert bank (measured on the 5090, 2026-11-09: +//! docs/design/single-copy-ram-2026-11-09.md). The engine still starts with such a memfd (the extents it hashes are +//! inside the full copy), so only this check can make the second copy visible. + +use crate::profile::{MemfdExtents, SPARSE_MEMFD_BYTES_ESTIMATE}; + +/// Environment variable that lets a start proceed with a full memfd where the profile asks for a sparse one. +pub const ALLOW_FULL_MEMFD_ENV: &str = "LELEKA_ALLOW_FULL_MEMFD"; + +/// Allocated bytes accepted above the extents of the real archive (16,000,348,672 B): metadata pages, huge-page +/// rounding of the shmem allocator and the header block. +pub const SINGLE_COPY_SLACK_BYTES: u64 = 1 << 30; + +/// Does the sealed memfd hold only what the profile says it should? `allocated_bytes` is `st_blocks * 512` of the +/// descriptor. A full-copy profile accepts any allocation; a `ple_only` profile accepts the extents plus +/// [`SINGLE_COPY_SLACK_BYTES`], unless `allow_full_copy` is set (an explicit, logged choice of the operator). +pub fn single_copy_verdict( + form: MemfdExtents, + allocated_bytes: u64, + allow_full_copy: bool, +) -> Result<(), String> { + if form == MemfdExtents::Full || allow_full_copy { + return Ok(()); + } + let ceiling = SPARSE_MEMFD_BYTES_ESTIMATE + SINGLE_COPY_SLACK_BYTES; + if allocated_bytes <= ceiling { + return Ok(()); + } + let gib = |bytes: u64| bytes as f64 / 1073741824.0; + Err(format!( + concat!( + "the inherited sealed memfd holds {:.1} GiB of RAM but the profile (memfd_extents=ple_only) ", + "needs {:.1} GiB: the holder sealed the whole archive, a second copy of model bytes that nothing ", + "reads next to the resident expert bank. Seal it with `leleka seal-exec --sparse-ple` ", + "(scripts/e2e/decode/single-copy-holder.sh), or set {}=1 to run with the full copy anyway" + ), + gib(allocated_bytes), + gib(SPARSE_MEMFD_BYTES_ESTIMATE), + ALLOW_FULL_MEMFD_ENV + )) +} diff --git a/crates/deploy/src/sealed/tests.rs b/crates/deploy/src/sealed/tests.rs index 40747681..e0bbd97e 100644 --- a/crates/deploy/src/sealed/tests.rs +++ b/crates/deploy/src/sealed/tests.rs @@ -61,3 +61,52 @@ fn placeholder_substitution() { ]; assert_eq!(substitute(&args, 7), ["--kar-archive-fd", "7", "x7y"]); } + +#[test] +fn a_sparse_profile_refuses_a_memfd_that_holds_the_whole_archive() { + use crate::profile::{ARCHIVE_BYTES, MemfdExtents::*, SPARSE_MEMFD_BYTES_ESTIMATE}; + // the sparse copy and the slack above it pass; the whole archive (55.3 GB) does not + single_copy_verdict(PleOnly, SPARSE_MEMFD_BYTES_ESTIMATE, false).unwrap(); + single_copy_verdict( + PleOnly, + SPARSE_MEMFD_BYTES_ESTIMATE + SINGLE_COPY_SLACK_BYTES, + false, + ) + .unwrap(); + let error = single_copy_verdict(PleOnly, ARCHIVE_BYTES, false).unwrap_err(); + assert!( + error.contains("51.5 GiB") && error.contains("--sparse-ple"), + "{error}" + ); + assert!( + single_copy_verdict( + PleOnly, + SPARSE_MEMFD_BYTES_ESTIMATE + SINGLE_COPY_SLACK_BYTES + 1, + false + ) + .is_err() + ); +} + +#[test] +fn a_full_profile_or_an_explicit_override_accepts_the_whole_archive() { + use crate::profile::{ARCHIVE_BYTES, MemfdExtents::*}; + single_copy_verdict(Full, ARCHIVE_BYTES, false).unwrap(); + single_copy_verdict(PleOnly, ARCHIVE_BYTES, true).unwrap(); +} + +#[cfg(target_os = "linux")] +#[test] +fn the_allocated_bytes_of_an_inherited_memfd_are_its_blocks_not_its_length() { + use std::os::{fd::AsRawFd, unix::fs::FileExt}; + // 1 GiB long, nothing written: a hole holds no RAM; 4 MiB written at the start: about 4 MiB held + let memfd = + rustix::fs::memfd_create("single-copy-test", rustix::fs::MemfdFlags::CLOEXEC).unwrap(); + let file = std::fs::File::from(memfd); + file.set_len(1 << 30).unwrap(); + let fd = u32::try_from(file.as_raw_fd()).unwrap(); + assert!(inherited_archive_allocated_bytes(fd).unwrap() < (1 << 20)); + file.write_all_at(&vec![7u8; 4 << 20], 0).unwrap(); + let held = inherited_archive_allocated_bytes(fd).unwrap(); + assert!((4 << 20..64 << 20).contains(&held), "{held}"); +} diff --git a/crates/deploy/src/sealed/unsupported_host.rs b/crates/deploy/src/sealed/unsupported_host.rs index 69a1eb08..59c8c462 100644 --- a/crates/deploy/src/sealed/unsupported_host.rs +++ b/crates/deploy/src/sealed/unsupported_host.rs @@ -62,6 +62,11 @@ pub fn check_inherited_archive(_fd: u32, _expect_bytes: u64) -> Result<(), Strin Err("inherited descriptors require Linux".into()) } +#[cfg(not(target_os = "linux"))] +pub fn inherited_archive_allocated_bytes(_fd: u32) -> Result { + Err("inherited descriptors require Linux".into()) +} + #[cfg(not(target_os = "linux"))] pub fn open_inherited(_fd: u32) -> Result { Err("inherited descriptors require Linux".into()) diff --git a/crates/deploy/src/supervisor/archive.rs b/crates/deploy/src/supervisor/archive.rs index 0270c78e..d1b70900 100644 --- a/crates/deploy/src/supervisor/archive.rs +++ b/crates/deploy/src/supervisor/archive.rs @@ -49,9 +49,29 @@ impl ServiceSupervisor { "using the sealed archive descriptor {fd} inherited from the parent" )); self.archive_sparse_pin = self.sparse_pin()?; + self.check_single_copy(fd)?; sealed::open_inherited(fd).map_err(|message| Flow::Fatal(Failure { code: 2, message })) } + /// A `ple_only` profile must not be handed a memfd that holds the whole archive (a second copy in shmem). + fn check_single_copy(&self, fd: u32) -> Result<(), Flow> { + let allocated = sealed::inherited_archive_allocated_bytes(fd) + .map_err(|message| Flow::Fatal(Failure { code: 2, message }))?; + let allow_full_copy = + Self::operator_env(sealed::ALLOW_FULL_MEMFD_ENV).as_deref() == Some("1"); + let form = self.config.profile.memfd_extents; + sealed::single_copy_verdict(form, allocated, allow_full_copy) + .or_else(|message| fail(2, message))?; + if allow_full_copy && form == MemfdExtents::PleOnly { + self.log.line(&format!( + "{} is set: the inherited memfd may hold the whole archive ({:.1} GiB allocated)", + sealed::ALLOW_FULL_MEMFD_ENV, + allocated as f64 / 1073741824.0 + )); + } + Ok(()) + } + async fn seal_archive(&mut self) -> Result { let kar = self.paths.kar(); // `memfd_extents: ple_only`: only the byte ranges the serve path reads (about 16 GB of 55) go into the memfd. diff --git a/crates/deploy/src/supervisor/sparse.rs b/crates/deploy/src/supervisor/sparse.rs index f9c2a195..3e3d5690 100644 --- a/crates/deploy/src/supervisor/sparse.rs +++ b/crates/deploy/src/supervisor/sparse.rs @@ -42,13 +42,19 @@ impl ServiceSupervisor { } } + /// The operator's environment as the supervisor sees it: the one place that reads it (the extents pin and the + /// single-copy override). + pub(super) fn operator_env(key: &str) -> Option { + std::env::var(key).ok() + } + /// The pin of the extents when the profile asks for a sparse memfd (`None` for the full copy); refuses to start /// without one. pub(super) fn sparse_pin(&self) -> Result, Flow> { if self.config.profile.memfd_extents != MemfdExtents::PleOnly { return Ok(None); } - match extents_sha256(&|key| std::env::var(key).ok()) { + match extents_sha256(&Self::operator_env) { Ok((pin, source)) => { self.log.line(&format!( "memfd_extents=ple_only: only the byte ranges the serve path reads are in the sealed memfd; the \ diff --git a/crates/engine-qwen35-cuda/src/backend/lifecycle_tests.rs b/crates/engine-qwen35-cuda/src/backend/lifecycle_tests.rs index 81afe230..35ef7acd 100644 --- a/crates/engine-qwen35-cuda/src/backend/lifecycle_tests.rs +++ b/crates/engine-qwen35-cuda/src/backend/lifecycle_tests.rs @@ -12,6 +12,7 @@ use crate::qwen_forward::original_serve_stack::lifecycle_fake::{FakeDevice, Fake use leleka_obs::time::ManualClock; mod ends; +mod graphs; mod prefix; /// An id the model never produces: no request stops on it. diff --git a/crates/engine-qwen35-cuda/src/backend/lifecycle_tests/graphs.rs b/crates/engine-qwen35-cuda/src/backend/lifecycle_tests/graphs.rs new file mode 100644 index 00000000..e1ab927e --- /dev/null +++ b/crates/engine-qwen35-cuda/src/backend/lifecycle_tests/graphs.rs @@ -0,0 +1,168 @@ +//! The decode graphs under the lifecycle (ledger row Q7, `LELEKA_DECODE_GRAPH_REUSE`): a kept graph set gives the same +//! text as re-recording, costs no recording, and is replaced - never replayed - when anything it was recorded over +//! changed. These scenarios are the ones the real verify bank (`park` / `rearm`) and the journal's owner loan +//! (`lend` / `take_back`) must pass; docs/experiments/decode-graph-reuse.md lists them. +use super::*; +use crate::qwen_forward::original_serve_stack::decode_graph_reuse::{Armed, DecodeGraphKey, Why}; + +/// What recording the graph set costs on the manual clock. +const RECORD_MS: u64 = 90; + +impl Rig { + fn with_graphs(self, enabled: bool) -> Self { + Self { stack: self.stack.with_graph_reuse(enabled, RECORD_MS), ..self } + } + + /// One request with its own prompt: its text (checked against the model) and its decode milliseconds. + fn request(&mut self, i: usize) -> (String, f64) { + let p = prompt_of(300 + 10 * i, i); + let run = self.run(&p, 12, NO_EOS); + assert_eq!(run.text, expect(&p, 12), "request {i}"); + (run.text, self.stack.last_timing().1) + } + + /// Runs `count` requests with different prompts: the text of each, and the decode milliseconds of each. + fn requests(&mut self, count: usize) -> (Vec, Vec) { + (0..count).map(|i| self.request(i)).unzip() + } +} + +fn rig(enabled: bool) -> Rig { + Rig::new(Script::default(), false).with_graphs(enabled) +} + +#[test] +fn with_the_switch_off_every_request_records_and_releases_like_before() { + let mut rig = rig(false); + let (_, decode_ms) = rig.requests(3); + let graphs = rig.stack.graphs(); + assert_eq!((graphs.recordings, graphs.reuses, graphs.drafter_releases), (3, 0, 3)); + assert_eq!(decode_ms, [90.0; 3]); + assert_eq!(graphs.last, Some(Armed::Recorded(Why::Disabled))); + assert!(!graphs.is_held()); +} + +#[test] +fn a_kept_graph_set_gives_the_text_of_re_recording_and_costs_no_recording() { + let (mut kept, mut fresh) = (rig(true), rig(false)); + let (kept_text, kept_ms) = kept.requests(4); + let (fresh_text, _) = fresh.requests(4); + assert_eq!(kept_text, fresh_text, "the same text per request"); + let graphs = kept.stack.graphs(); + assert_eq!((graphs.recordings, graphs.reuses, graphs.drafter_releases), (1, 3, 0)); + assert_eq!(kept_ms, [90.0, 0.0, 0.0, 0.0], "only the first request records"); + assert_eq!(kept.dev.digest(), fresh.dev.digest(), "the device ends in the same state"); + assert_eq!(kept.log("graphs"), ["graphs recorded: NothingHeld", "graphs reused", "graphs reused", "graphs reused"]); +} + +#[test] +fn the_full_cycle_parks_re_arms_and_refuses_the_windows_of_the_request_before() { + let mut rig = rig(true); + rig.request(0); + let first = rig.stack.last_window().expect("request 1 ran windows"); + let parked = rig.stack.graphs().held_bank().expect("request 1 kept its set"); + assert!(parked.parked, "parked at the end of the request"); + assert_eq!((parked.generation, parked.windows > 0), (1, true)); + assert_eq!(rig.stack.kept_accepts(first), Some(true), "its own windows are accepted until the re-arm"); + rig.request(1); + let rearmed = rig.stack.graphs().held_bank().expect("request 2 kept the set"); + assert_eq!(rearmed.generation, 2, "the re-arm advanced the generation"); + assert_eq!(rig.stack.kept_accepts(first), Some(false), "a window of request 1 is refused"); + let second = rig.stack.last_window().expect("request 2 ran windows"); + assert_eq!(rig.stack.kept_accepts(second), Some(true)); + assert_eq!((rearmed.windows, rearmed.commits, rearmed.flags), (4, 4, 4), "request 2's four rounds, not 4 + 4"); + assert_eq!(parked.windows, 4); + assert_eq!(rearmed.canonical, rig.dev.digest(), "the canonical image holds request 2's seed"); + assert_ne!(rearmed.canonical, parked.canonical, "and not the image of request 1"); + assert!(rearmed.parked); + assert_eq!(rig.stack.graphs().recordings, 1); +} + +/// The inputs of the key, by the name `first_difference` gives them. +const INPUTS: [&str; 7] = + ["max_t", "max_cells", "pcie_mode", "expert tier", "cluster top-k", "weights epoch", "owners epoch"]; + +/// Changes the named input of the key. +fn change(name: &str, k: &mut DecodeGraphKey) { + match name { + "max_t" => k.max_t -= 1, + "max_cells" => k.max_cells *= 2, + "pcie_mode" => k.pcie_mode = 2, + "expert tier" => k.tier = true, + "cluster top-k" => k.cluster_topk = false, + "weights epoch" => k.weights_epoch += 1, + _ => k.owners_epoch += 1, + } +} + +#[test] +fn a_changed_input_of_the_key_forces_a_re_record_and_the_new_set_is_kept_again() { + for name in INPUTS { + let mut rig = rig(true); + rig.requests(1); + change(name, rig.stack.graph_key()); + rig.request(1); + let graphs = rig.stack.graphs(); + assert_eq!(graphs.recordings, 2, "{name}"); + assert_eq!(graphs.last, Some(Armed::Recorded(Why::KeyChanged(name))), "{name}"); + assert_eq!(graphs.drafter_releases, 1, "{name}: the drafter let go of the retired bank"); + rig.request(2); + let graphs = rig.stack.graphs(); + assert_eq!((graphs.recordings, graphs.reuses), (2, 1), "{name}: kept for the new key"); + } +} + +#[test] +fn owners_that_moved_between_the_requests_retire_the_set_and_none_is_lost() { + let mut rig = rig(true); + rig.request(0); + rig.stack.move_owners(); + rig.request(1); + let graphs = rig.stack.graphs(); + assert_eq!(graphs.last, Some(Armed::Recorded(Why::OwnersChanged))); + assert_eq!((graphs.recordings, graphs.drafter_releases), (2, 1)); + rig.request(2); + assert_eq!(rig.stack.graphs().reuses, 1, "the set recorded over the moved owners is kept"); +} + +#[test] +fn a_set_that_refuses_to_be_re_armed_is_retired_and_recorded_again_not_replayed() { + let mut rig = rig(true); + rig.stack.graphs().refusals.rearm = true; + rig.request(0); + rig.stack.graphs().refusals.rearm = false; + rig.request(1); + let graphs = rig.stack.graphs(); + assert_eq!(graphs.last, Some(Armed::Recorded(Why::RearmRefused))); + assert_eq!((graphs.recordings, graphs.reuses, graphs.drafter_releases), (2, 0, 1)); + rig.request(2); + assert_eq!(rig.stack.graphs().reuses, 1, "the next set re-arms: the owners were not lost by the refusal"); +} + +#[test] +fn a_set_that_cannot_park_is_not_kept_and_the_owners_go_home() { + let mut rig = rig(true); + rig.stack.graphs().refusals.park = true; + rig.requests(2); + let graphs = rig.stack.graphs(); + assert_eq!((graphs.recordings, graphs.reuses, graphs.drafter_releases), (2, 0, 2)); + assert_eq!(graphs.last, Some(Armed::Recorded(Why::NothingHeld))); + assert!(!graphs.is_held()); +} + +#[test] +fn a_request_that_fails_or_is_cancelled_does_not_keep_its_graphs() { + let mut rig = Rig::new(Script { fail_round: Some(0), ..Script::default() }, false).with_graphs(true); + let p = prompt(300); + assert!(matches!(rig.run(&p, 12, NO_EOS).ended, Ended::Failed(..))); + assert!(!rig.stack.graphs().is_held()); + assert_eq!(rig.stack.graphs().drafter_releases, 1); + let run = rig.run(&p, 12, NO_EOS); + assert_eq!(run.text, expect(&p, 12), "the owners came home from the failed request"); + assert_eq!(rig.stack.graphs().last, Some(Armed::Recorded(Why::NothingHeld))); + assert_eq!((rig.stack.graphs().recordings, rig.stack.graphs().reuses), (2, 0)); + assert!(rig.stack.graphs().is_held(), "the clean request keeps its set"); + rig.stack.graphs().invalidate(); + assert!(!rig.stack.graphs().is_held()); + assert_eq!(rig.stack.graphs().drafter_releases, 2, "retiring the kept set releases the drafter once"); +} diff --git a/crates/engine-qwen35-cuda/src/backend/proxy.rs b/crates/engine-qwen35-cuda/src/backend/proxy.rs index 19b9c4e6..1b4ec276 100644 --- a/crates/engine-qwen35-cuda/src/backend/proxy.rs +++ b/crates/engine-qwen35-cuda/src/backend/proxy.rs @@ -242,6 +242,20 @@ impl Drop for ActiveGuard<'_> { clear_active(self.0); } } +/// Work the owner thread still has for a request after its response was published +/// (`LELEKA_PREFIX_PARK_ASYNC`: the end-of-decode prefix checkpoint). +pub(super) trait DeferredTail { + fn run_deferred_tail(&mut self); +} +impl ActiveGuard<'_> { + /// The request is over for its client: the busy mark goes first, then the deferred tail runs. A request that + /// arrives meanwhile passes the admission (`Proxy::idle`) and waits in the control queue, which the owner reads + /// after the tail; it is never refused with `native generation is active`. + pub(super) fn release_then(self, tail: &mut impl DeferredTail) { + drop(self); + tail.run_deferred_tail(); + } +} pub(super) fn cancel_active(shared: &Shared) { if let Ok(active) = shared.active.lock() && let Some(active) = active.as_ref() diff --git a/crates/engine-qwen35-cuda/src/backend/tests.rs b/crates/engine-qwen35-cuda/src/backend/tests.rs index b7cab903..33cd5052 100644 --- a/crates/engine-qwen35-cuda/src/backend/tests.rs +++ b/crates/engine-qwen35-cuda/src/backend/tests.rs @@ -332,3 +332,38 @@ fn preview_and_the_auto_fallback_are_refused_without_the_preview_path_feature() assert!(error.message.contains("preview-path"), "{}", error.message); } } + +/// A deferred tail that plays the next client: while the owner is still busy with it, the proxy admits a request +/// and puts its command in the control queue. +struct ClientDuringTail<'a> { + proxy: &'a Proxy, + admitted: Option>, + queued: Option>, +} +impl DeferredTail for ClientDuringTail<'_> { + fn run_deferred_tail(&mut self) { + self.admitted = Some(self.proxy.idle()); + let (reply, _) = mpsc::sync_channel(1); + self.queued = Some(self.proxy.send(Command::Reconfigure("{}".into(), reply))); + } +} +#[test] +fn a_request_arriving_during_the_deferred_tail_is_admitted_and_queued_not_refused() { + let (tx, rx) = mpsc::sync_channel(QUEUE); + let cancel = Arc::new(AtomicBool::new(false)); + let shared = Arc::new(Shared { + ready: AtomicBool::new(true), + shutdown: AtomicBool::new(false), + active: Mutex::new(Some(Active { id: "finished".into(), cancel })), + }); + let proxy = native_proxy(tx, Arc::clone(&shared)); + // while the request runs, the next one is refused + assert!(proxy.idle().is_err()); + let mut tail = ClientDuringTail { proxy: &proxy, admitted: None, queued: None }; + ActiveGuard(&shared).release_then(&mut tail); + assert!(tail.admitted.expect("the tail ran").is_ok(), "the busy mark is gone before the tail starts"); + assert!(tail.queued.expect("the tail ran").is_ok()); + // the owner reads its queue after the tail: the command is there, in order + assert!(matches!(rx.try_recv(), Ok(Command::Reconfigure(..)))); + assert!(shared.active.lock().unwrap().is_none()); +} diff --git a/crates/engine-qwen35-cuda/src/backend_original_serve/runner.rs b/crates/engine-qwen35-cuda/src/backend_original_serve/runner.rs index 850edb72..ea03af0a 100644 --- a/crates/engine-qwen35-cuda/src/backend_original_serve/runner.rs +++ b/crates/engine-qwen35-cuda/src/backend_original_serve/runner.rs @@ -1,7 +1,7 @@ //! Moved out of the parent file by STRA-338 (same module path as before). use super::super::{ - ActiveGuard, BackendError, Command, ErrorCode, FinishReason, GENERATION_TIMEOUT, GenerationEvent, + ActiveGuard, BackendError, Command, DeferredTail, ErrorCode, FinishReason, GENERATION_TIMEOUT, GenerationEvent, GenerationFailure, GenerationSink, GenerationTerminal, LoadPhase, LoadedModel, ModelBinding, QUEUE, Reply, Shared, Tokenizer, Usage, Utf8Pending, clock_seed, emit_event, emit_terminal, exhausted, invalid, load_failure, prepare_prompt, request_sampler, unavailable, diff --git a/crates/engine-qwen35-cuda/src/backend_original_serve/runner/owner_run_steps.rs b/crates/engine-qwen35-cuda/src/backend_original_serve/runner/owner_run_steps.rs index 52bf1fd1..6312395b 100644 --- a/crates/engine-qwen35-cuda/src/backend_original_serve/runner/owner_run_steps.rs +++ b/crates/engine-qwen35-cuda/src/backend_original_serve/runner/owner_run_steps.rs @@ -182,7 +182,7 @@ pub(super) fn serve_generate( command: (LoadedModel, GenerationRequest, Arc, Reply), ) -> Result<(), BackendError> { let (candidate, request, cancel, reply) = command; - let _guard = ActiveGuard(env.shared); + let guard = ActiveGuard(env.shared); let prompt = match admit_generate(env, &candidate, &request) { Ok(prompt) => prompt, Err(error) => { @@ -200,9 +200,24 @@ pub(super) fn serve_generate( return Ok(()); }; run_generation(env, owner, (&sink, &cancel), &prompt, &request); + guard.release_then(&mut AfterResponse { owner, shared: env.shared }); Ok(()) } +/// The owner after a request's terminal event: the end-of-decode prefix checkpoint it deferred +/// (`LELEKA_PREFIX_PARK_ASYNC`), then the prefix summary with the new node in it. +struct AfterResponse<'a, 'b, 'c> { + owner: &'a mut Stack<'b, 'c>, + shared: &'a Shared, +} +impl DeferredTail for AfterResponse<'_, '_, '_> { + fn run_deferred_tail(&mut self) { + if self.owner.prefix_after_response() { + publish_prefix_summary(self.owner, self.shared); + } + } +} + fn stack_unavailable() -> GenerationTerminal { GenerationTerminal::Failed { code: ErrorCode::BackendUnavailable, diff --git a/crates/engine-qwen35-cuda/src/backend_original_serve/runner/stack_config_and_reports.rs b/crates/engine-qwen35-cuda/src/backend_original_serve/runner/stack_config_and_reports.rs index a7eab5dc..b47b2e9c 100644 --- a/crates/engine-qwen35-cuda/src/backend_original_serve/runner/stack_config_and_reports.rs +++ b/crates/engine-qwen35-cuda/src/backend_original_serve/runner/stack_config_and_reports.rs @@ -43,6 +43,7 @@ fn prefix_config(prefix: &super::super::PrefixCacheOptions) -> crate::qwen_forwa Some(bytes) => PrefixBudget::Bytes(bytes), }, block_tokens: prefix.block_tokens, + defer_decode_tail: crate::settings::process().serve.prefix_park_async, ..PrefixConfig::auto() }; if let Some(seconds) = prefix.retention_s { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_prompt/moe_weight_cache.rs b/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_prompt/moe_weight_cache.rs index 77b14e07..47767cc0 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_prompt/moe_weight_cache.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_prompt/moe_weight_cache.rs @@ -85,8 +85,11 @@ impl<'ctx> MoeWeightCache<'ctx> { // Create persistent actual streams/events before model cache fills. // Slot count comes from the same options used to carve the arena. let slots = options.original_ring_slots().map_err(|e| arena_driver_error(2, e))?; - self.original_copy_schedule = - Some(context.original_mmq_copy_schedule(slots).map_err(|e| arena_driver_error(3, e))?); + let mut schedule = context.original_mmq_copy_schedule(slots).map_err(|e| arena_driver_error(3, e))?; + // EXPERIMENTAL, off by default: docs/experiments/ring-prefetch.md + schedule.set_ring_prefetch(crate::settings::process().serve.prefill_ring_prefetch); + schedule.set_ring_error_trace(crate::driver_errors_traced()); + self.original_copy_schedule = Some(schedule); let device = context.original_moe_prompt_device(capacity as usize).map_err(|e| arena_driver_error(4, e))?; self.original_prompt_device = Some(device); let bank = context.mapped_expert_bank(lease, members).map_err(|e| arena_driver_error(5, e))?; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_prompt/prompt_layer_fns.rs b/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_prompt/prompt_layer_fns.rs index 01daa91c..88510138 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_prompt/prompt_layer_fns.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_prompt/prompt_layer_fns.rs @@ -7,6 +7,8 @@ use leleka_cuda_driver::{ MappedExpertBank, MmqFormat, MmqWorkspace, OriginalMmqCopySchedule, OriginalMoePromptDevice, OriginalMoePromptLayer, }; +mod prompt_ring_prefetch; + type SpanCache = (usize, Vec>); type Spans = [ResidentExpertBankSpan; 3]; const BITS: usize = 48 * 512; @@ -81,6 +83,7 @@ pub(super) fn run_prompt_layer<'arena, 'loan, 'ctx>( let ring = RingOwners { mmq: io.mmq, schedule: io.schedule, layer: io.layer, bank: scan.bank }; copy_ring(&mut layer_program, ring, &sources, routed)?; drop(ring_span); + prompt_ring_prefetch::prefetch_next_layer(&layer_program, io.schedule, scan); let _span = prof::span(PStage::MoeFinish, drain); let block = layer_program.finish(shared).map_err(driver_error)?; end_stream_if_last(io)?; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_prompt/prompt_ring_prefetch.rs b/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_prompt/prompt_ring_prefetch.rs new file mode 100644 index 00000000..40eca1c6 --- /dev/null +++ b/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_prompt/prompt_ring_prefetch.rs @@ -0,0 +1,60 @@ +//! EXPERIMENTAL prompt copy-ring prefetch (`LELEKA_PREFILL_RING_PREFETCH`, off by default; +//! docs/experiments/ring-prefetch.md): once a layer's copy ring has drained, the experts the next layer is predicted to +//! miss are copied into its ring's stage slots through this layer's row lease, so the PCIe copies run under this +//! layer's combine and the next layer's mixer instead of after the next router. + +#[allow(unused_imports)] +use super::*; +use crate::qwen_forward::contract::Dimension; +use leleka_cuda_driver::{OriginalMmqCopySchedule, OriginalMoePromptLayer, PrefetchSource}; + +/// Copies the next layer's predicted misses ahead; nothing when the switch is off or this is the last layer. Never +/// fails the layer: the next ring copies whatever was not prefetched. +pub(super) fn prefetch_next_layer<'ctx>( + layer_program: &OriginalMoePromptLayer<'_, '_, '_, 'ctx>, + schedule: &mut OriginalMmqCopySchedule<'ctx>, + scan: &mut SpanScan<'_, 'ctx>, +) { + if schedule.ring_prefetch().is_none() { + return; + } + let Some(next) = next_layer(scan) else { return }; + let bank = scan.bank; + let lookup = SpanScan { + binding: scan.binding, + layer: next, + bank, + finite: &mut *scan.finite, + span_cache: &mut *scan.span_cache, + span_cache_on: scan.span_cache_on, + }; + let sources = |expert: u32| lookup.prefetch_source(expert); + let copied = layer_program.prefetch_ring_layer(schedule, bank, next.get() as usize, sources); + crate::bringup_trace!("DBG ring prefetch: layer {} copied {copied}", next.get()); +} + +/// The layer after this one, unless this is the last. +fn next_layer(scan: &SpanScan<'_, '_>) -> Option { + let count = scan.binding.layer_count(); + let next = scan.layer.get().checked_add(1).filter(|n| *n < count)?; + LayerId::new(u64::from(next), Dimension::new(u64::from(count)).ok()?).ok() +} + +impl SpanScan<'_, '_> { + /// The bank spans and formats of an expert of this scan's layer that was admitted before (its bytes passed the + /// finite scan), from the span cache or a walk of the binding that changes nothing; `None` for any other expert. + fn prefetch_source(&self, expert: u32) -> PrefetchSource { + let bit = self.layer.get() as usize * 512 + expert as usize; + if bit >= BITS || self.finite[bit / 64] >> (bit % 64) & 1 == 0 { + return None; + } + if self.span_cache_on + && let Some((spans, format)) = self.span_cache.1.get(bit).and_then(Option::as_ref) + { + return Some((spans.clone(), *format)); + } + let bound = self.bound_weights(expert).ok()?; + let ((spans, _), format) = self.walk(&bound, expert, true).ok()?; + Some((spans, format)) + } +} diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor_original_prompt.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor_original_prompt.rs index 078f7ce3..35ea64e8 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor_original_prompt.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor_original_prompt.rs @@ -12,7 +12,9 @@ use super::super::prompt_device_rows::{ use super::super::prompt_device_rows::{ PromptDeviceFinal, PromptDeviceNormedRows, PromptDeviceRows, PromptDeviceSource, }; -use super::super::qsa_index::prompt_device::resident_device::{ResidentQsaLayer, ResidentQsaOwners, ResidentQsaPrior}; +use super::super::qsa_index::prompt_device::resident_device::{ + ResidentQsaLayer, ResidentQsaOwners, ResidentQsaPrior, SpanExport, +}; use super::super::session::original_prompt::draft::{OriginalDraftCheckpoint, OriginalDraftSession}; use super::super::session::original_prompt::{ OriginalPromptInput, OriginalPromptTxn, OriginalSessionCheckpoint, ParkedBlock, ParkedSession, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor_original_prompt/original_prompt_executor/construction_and_parking/executor_construction.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor_original_prompt/original_prompt_executor/construction_and_parking/executor_construction.rs index 5c326286..077cd6a8 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor_original_prompt/original_prompt_executor/construction_and_parking/executor_construction.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor_original_prompt/original_prompt_executor/construction_and_parking/executor_construction.rs @@ -2,7 +2,7 @@ #[allow(unused_imports)] use super::*; -use leleka_cuda_driver::NativeBatchWorkspace; +use leleka_cuda_driver::{GdnPromptOptions, NativeBatchWorkspace}; impl<'ctx> OriginalPromptExecutor<'ctx> { /// Eager model/session owners precede expert prefix planning. The twelve @@ -99,7 +99,9 @@ impl<'ctx> OriginalPromptExecutor<'ctx> { let (context, capacity) = (self.context, self.capacity); let prompt = context.original_prompt_device(capacity, PleBf16Mode::HighOnly, GrNativeProfile::HighOnly); self.prompt = Some(prompt.map_err(driver_error)?); - let gdn = context.original_gdn_prompt_device(capacity, GrNativeProfile::HighOnly); + // LELEKA_PREFILL_GDN_TC (EXPERIMENTAL, LOSSY, off by default): the tensor-core scan of the prompt recurrence + let options = GdnPromptOptions { tensor_core_scan: crate::settings::process().serve.prefill_gdn_tc }; + let gdn = context.original_gdn_prompt_device_with(capacity, GrNativeProfile::HighOnly, options); self.gdn = Some(gdn.map_err(driver_error)?); let qsa = context.original_qsa_resident_prompt_device(capacity, QsaNativePacking::HighOnly); self.qsa = Some(qsa.map_err(driver_error)?); @@ -262,6 +264,12 @@ impl<'ctx> OriginalPromptExecutor<'ctx> { pub(in crate::qwen_forward) fn mtp_release_verifier(&mut self, binding: &ModelBinding) -> Result<()> { self.mtp_actor(binding)?.release_verifier_bindings().map_err(driver_error) } + /// End of a request whose verifier bank is kept for the next one (`LELEKA_DECODE_GRAPH_REUSE`): the drafter keeps + /// its programs bound to the bank and forgets what belongs to the request. See + /// `OriginalMtpActor::end_request_keep_bank`. + pub(in crate::qwen_forward) fn mtp_end_request_keep_bank(&mut self, binding: &ModelBinding) -> Result<()> { + self.mtp_actor(binding)?.end_request_keep_bank().map_err(driver_error) + } /// `MtpDrafter::device()`. pub(in crate::qwen_forward) fn mtp_device(&mut self, binding: &ModelBinding) -> Result { Ok(self.mtp_actor(binding)?.device()) diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor_original_prompt/original_prompt_executor/construction_and_parking/session_park_and_qsa_owners.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor_original_prompt/original_prompt_executor/construction_and_parking/session_park_and_qsa_owners.rs index c5bd6496..37a30ccc 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor_original_prompt/original_prompt_executor/construction_and_parking/session_park_and_qsa_owners.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor_original_prompt/original_prompt_executor/construction_and_parking/session_park_and_qsa_owners.rs @@ -140,7 +140,18 @@ impl<'ctx> OriginalPromptExecutor<'ctx> { if self.layers.iter().flatten().count() != 12 { return Err(Error::IdentityMismatch); } - session.park_block(&self.layers, first, tokens) + let mode = self.span_export()?; + session.park_block(&self.layers, first, tokens, mode) + } + /// How this park reads the layers out: with `LELEKA_PREFIX_PARK_FAST` the context is drained here once, for all + /// twelve layers, instead of once per layer inside each read (nothing is enqueued between the reads). + fn span_export(&self) -> Result { + if !crate::settings::process().serve.prefix_park_fast { + return Ok(SpanExport::Checked); + } + let _p = crate::qwen_forward::original_serve_profile::span("prefix.export_drain"); + self.context.synchronize().map_err(|_| Error::CudaExecution)?; + Ok(SpanExport::Drained) } /// Prefix cache: make the session and the twelve layers stand at `parked`, writing `blocks`. A failure poisons /// the executor, as for `restore_session`. diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor_original_prompt/original_prompt_executor/prompt_executor_forward_and_close/prompt_chunk_forward.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor_original_prompt/original_prompt_executor/prompt_executor_forward_and_close/prompt_chunk_forward.rs index 0a2a5341..588698cd 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor_original_prompt/original_prompt_executor/prompt_executor_forward_and_close/prompt_chunk_forward.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor_original_prompt/original_prompt_executor/prompt_executor_forward_and_close/prompt_chunk_forward.rs @@ -27,6 +27,33 @@ fn trace_step(step: &str) { crate::bringup_trace!("DBG[{:.0}s] {step}", crate::qwen_forward::original_serve_stack::dbg_el()); } +/// Whether a chunk of `rows` rows runs in an arena of `arena_capacity` rows on an executor sized for +/// `executor_capacity` rows. The executor's own buffers are sized for its capacity; an arena up to that size serves +/// the chunk (the prompt loan ladder lends a smaller arena to a smaller chunk). An arena that cannot hold the rows +/// or that exceeds the executor's capacity is refused. +fn arena_serves_chunk(rows: usize, arena_capacity: usize, executor_capacity: usize) -> bool { + rows != 0 && rows <= arena_capacity && arena_capacity <= executor_capacity +} + +#[cfg(test)] +mod arena_tests { + use super::arena_serves_chunk; + + #[test] + fn a_smaller_arena_serves_a_chunk_that_fits_it() { + assert!(arena_serves_chunk(1815, 2048, 8192)); + assert!(arena_serves_chunk(512, 512, 8192)); + assert!(arena_serves_chunk(8192, 8192, 8192)); + } + + #[test] + fn an_arena_that_cannot_hold_the_rows_or_exceeds_the_executor_is_refused() { + assert!(!arena_serves_chunk(0, 2048, 8192)); + assert!(!arena_serves_chunk(513, 512, 8192)); + assert!(!arena_serves_chunk(100, 16384, 8192)); + } +} + /// Traces a failing step of the chunk and passes the error on. fn trace_error(step: &str, error: Error) -> Error { crate::bringup_trace!("DBG[{:.0}s] {step} err {error:?}", crate::qwen_forward::original_serve_stack::dbg_el()); @@ -48,7 +75,7 @@ impl<'ctx> OriginalPromptExecutor<'ctx> { let ChunkCaches { kar, moe, arena } = caches; let (window, first_position) = self.admit_window(weights, session, chunk_source, arena.capacity())?; let _launch_sync = leleka_cuda_driver::PromptSyncTrace::enter(); - if window.is_empty() || window.len() > self.capacity || arena.capacity() != self.capacity { + if !self.arena_holds_window(window.len(), arena.capacity()) { return Err(Error::InvalidDimension); } let checkpoint = session.original_checkpoint(binding)?; @@ -62,6 +89,11 @@ impl<'ctx> OriginalPromptExecutor<'ctx> { self.finish_forward(operation, weights, OpenChunk { txn, moe }, rollback) } + /// Whether a chunk of `rows` rows runs in an arena of `arena_capacity` rows (see `arena_serves_chunk`). + fn arena_holds_window(&self, rows: usize, arena_capacity: usize) -> bool { + arena_serves_chunk(rows, arena_capacity, self.capacity) + } + /// The prompt window of the chunk and its first position, after the executor accepted the session. fn admit_window<'src>( &self, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache.rs index 4ac1fd93..156f30f9 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache.rs @@ -172,6 +172,9 @@ pub(crate) struct MoeWeightCache<'ctx> { #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] adaptive_shared: Option, age: u64, + /// The entries a held decode graph set reads in place, and how many of them were freed (`window_pins.rs`). + window_pins: RefCell, + raw_evictions: Cell, failed: Cell, bank: Option>>, dense: Vec>, @@ -353,6 +356,9 @@ pub(in crate::qwen_forward) use original_mtp_weights::{MtpHeadSources, RetainedO mod validate_ranked_profile; #[allow(unused_imports)] +// pinning and the epoch are read by the decode graph reuse, which the stack does not wire yet +#[allow(dead_code)] +mod window_pins; use validate_ranked_profile::dual_layout; #[allow(unused_imports)] use validate_ranked_profile::integer_iq3_triplet; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_mmq_constructors.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_mmq_constructors.rs index acb458ec..21b44cff 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_mmq_constructors.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_mmq_constructors.rs @@ -30,6 +30,8 @@ macro_rules! blank_cache { #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] adaptive_shared: None, age: 0, + window_pins: Default::default(), + raw_evictions: Cell::new(0), failed: Cell::new(false), bank: None, dense: Vec::new(), diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_shared_tail_constructors.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_shared_tail_constructors.rs index a4c0f240..7d2e3e51 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_shared_tail_constructors.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_shared_tail_constructors.rs @@ -139,6 +139,9 @@ impl<'ctx> MoeWeightCache<'ctx> { self.routed_workspace.as_ref().map(Rc::clone).ok_or(Error::IdentityMismatch) } pub(in super::super) fn is_pinned(&self, key: MoeWeightDescriptor) -> bool { + if self.window_pinned(&key) { + return true; + } #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] if self.adaptive_shared.as_ref().is_some_and(|pool| pool.contains(key)) { return true; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_triplet_plan_upload.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_triplet_plan_upload.rs index bd058881..bc566864 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_triplet_plan_upload.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_triplet_plan_upload.rs @@ -279,6 +279,7 @@ impl<'ctx> MoeWeightCache<'ctx> { let key = self.eviction_key(protected)?; self.remove_lru_entry(key)?; let entry = self.main.remove(&key).ok_or(Error::IdentityMismatch)?; + self.note_eviction(&key); if entry.weight.close().is_err() { self.failed.set(true); return Err(Error::CudaExecution); diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_validate_prepare_step.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_validate_prepare_step.rs index 17810b85..a59091e7 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_validate_prepare_step.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_validate_prepare_step.rs @@ -72,6 +72,7 @@ impl<'ctx> MoeWeightCache<'ctx> { let key = self.eviction_key(&[])?; self.remove_lru_entry(key)?; let entry = self.main.remove(&key).ok_or(Error::IdentityMismatch)?; + self.note_eviction(&key); if entry.weight.close().is_err() { self.failed.set(true); return Err(Error::CudaExecution); diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/window_pins.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/window_pins.rs new file mode 100644 index 00000000..c2494e94 --- /dev/null +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/window_pins.rs @@ -0,0 +1,56 @@ +//! The shared experts a kept decode graph set reads in place (`LELEKA_DECODE_GRAPH_REUSE`, ledger row Q7). +//! +//! The window graphs hold the device addresses of the shared-expert tensors of all 48 layers. The assembly keeps the +//! allocations alive through its handles, but while a graph set is held across requests the prompt path should not even +//! evict them (the cache would load them again at new addresses and the held copies would stay as dead weight): +//! `pin_for_window` makes the cache skip them when it needs room, the same rule as the profile's permanent pool. +//! `window_keys` remembers which entries a window reads; freeing one of them (only possible while unpinned) and +//! releasing the pins both bump `weights_epoch`, which is part of the graph key, so a set recorded before is retired. +//! Everything is `&self` (cells): the assembly holds the cache by shared reference while a request runs. +use super::*; + +/// The entries a window reads, and whether the cache currently protects them. +#[derive(Default)] +pub(super) struct WindowPins { + keys: std::collections::HashSet, + pinned: bool, +} + +impl<'ctx> MoeWeightCache<'ctx> { + /// Keep the shared experts `keys` (from `ensure_original_verify_shared`) resident until `unpin_window`. + pub(in crate::qwen_forward) fn pin_for_window(&self, keys: &[[MoeWeightDescriptor; 4]]) -> Result<()> { + if keys.iter().flatten().any(|key| !self.main.contains_key(key)) { + return Err(Error::IdentityMismatch); + } + let mut pins = self.window_pins.borrow_mut(); + pins.keys = keys.iter().flatten().copied().collect(); + pins.pinned = true; + Ok(()) + } + + /// Release the pins: the entries can be evicted again, so a graph set that read them is no longer replayable. + pub(in crate::qwen_forward) fn unpin_window(&self) { + let mut pins = self.window_pins.borrow_mut(); + if std::mem::take(&mut pins.pinned) { + self.raw_evictions.set(self.raw_evictions.get().wrapping_add(1)); + } + } + + /// Entries of the window freed so far, plus the pins released: unchanged between two requests means every tensor a + /// window graph read is still the live entry. + pub(in crate::qwen_forward) fn weights_epoch(&self) -> u64 { + self.raw_evictions.get() + } + + pub(super) fn window_pinned(&self, key: &MoeWeightDescriptor) -> bool { + let pins = self.window_pins.borrow(); + pins.pinned && pins.keys.contains(key) + } + + /// Account an entry the cache is about to free: freeing one a window reads moves the epoch. + pub(super) fn note_eviction(&self, key: &MoeWeightDescriptor) { + if self.window_pins.borrow().keys.contains(key) { + self.raw_evictions.set(self.raw_evictions.get().wrapping_add(1)); + } + } +} diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_config.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_config.rs index 129cffb3..9d02e2c9 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_config.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_config.rs @@ -222,6 +222,8 @@ pub(in crate::qwen_forward) fn mtp_full_policy(rope: &RopeConstants) -> Original gr: mtp_gr_variant(), kv: rope.draft_kv(), coupled_j: None, + chain_pipeline: crate::settings::process().serve.draft_chain_pipeline, + check_merge: crate::settings::process().serve.draft_check_merge, } } pub(in crate::qwen_forward) fn mtp_scalar_policy(rope: &RopeConstants) -> OriginalMtpScalarPolicy { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_config/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_config/tests.rs index 7b5b6075..a8ff35a6 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_config/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_config/tests.rs @@ -71,6 +71,8 @@ fn mtp_policies_stay_inside_the_closed_profile_and_share_one_kv_policy() { let scalar = mtp_scalar_policy(&rope); assert!(full.native_router && full.native_combine && full.native_shared_scalar && full.native_final_gr); assert!(!full.old_grouped_s2 && !full.fp32_final_gr && full.coupled_j.is_none() && full.legacy_router_mode == 0); + assert!(!full.chain_pipeline, "the chain pipeline is opt-in"); + assert!(!full.check_merge, "the merged draft checks are opt-in"); assert!(full.gr == OriginalMtpGrVariant::Plain && scalar.gr == OriginalMtpGrVariant::Plain); assert!(!scalar.per_group_sync); assert_eq!(full.kv.theta_scale, scalar.kv.theta_scale); diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_prefix.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_prefix.rs index b81caebb..47104736 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_prefix.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_prefix.rs @@ -70,6 +70,10 @@ pub(crate) struct PrefixConfig { pub(crate) policy: PolicyParams, /// The laptop profile of `auto` (smaller floor and ceiling). pub(crate) laptop: bool, + /// `LELEKA_PREFIX_PARK_ASYNC`: the checkpoint at the end of the decode (`TailMode::Reply`) is not taken inside the + /// request but when the stack runs `after_response`, right after the response was published and before the next + /// request (default off). + pub(crate) defer_decode_tail: bool, } /// What the binding needs from the stack's owners. @@ -123,6 +127,8 @@ pub(super) enum ChunkOutcome { Rejected(Reject), /// The host is short of memory: nothing was built. LowMemory, + /// The end-of-decode checkpoint is left for `after_response` (`PrefixConfig::defer_decode_tail`). + Deferred, Admitted { tokens: usize, new_blocks: usize, @@ -131,6 +137,13 @@ pub(super) enum ChunkOutcome { }, } +/// The end-of-decode checkpoint a request left for after its response: the tokens the session holds and the prompt-end +/// checkpoint that stays (`Req::limit`, which `finish` forgets). +struct PendingTail { + consumed: Vec, + keep: Option, +} + struct Req { /// Last prompt position a checkpoint may cover (the last prompt token starts the first verify window). limit: usize, @@ -146,6 +159,8 @@ pub(super) struct PrefixServe { store: PrefixStore, live: Vec, req: Option, + /// The end-of-decode checkpoint the last request deferred; dropped by the next `begin` and by `invalidate`. + pending_tail: Option, /// Sizes measured on the last real payloads (the estimates for the next admission). seen_state_bytes: Option, seen_block_bytes: Option, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_prefix/prefix_config.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_prefix/prefix_config.rs index 6871db35..434963a0 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_prefix/prefix_config.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_prefix/prefix_config.rs @@ -21,6 +21,7 @@ impl PrefixConfig { policy }, laptop: false, + defer_decode_tail: false, } } pub(crate) fn validate(&self, capacity: usize) -> Result<(), Error> { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_prefix/prefix_serve/prefix_serve_after_phase_parking.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_prefix/prefix_serve/prefix_serve_after_phase_parking.rs index 87d91fbe..dd78e3ce 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_prefix/prefix_serve/prefix_serve_after_phase_parking.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_prefix/prefix_serve/prefix_serve_after_phase_parking.rs @@ -183,6 +183,36 @@ impl PrefixServe { // the prompt-end checkpoint of this request stays: a client that resends the history without the reasoning // of the reply continues from the prompt, not from the decode end let keep = self.req.as_ref().map(|r| r.limit); + if self.cfg.defer_decode_tail { + self.pending_tail = Some(PendingTail { consumed: consumed.to_vec(), keep }); + return Ok(ChunkOutcome::Deferred); + } + self.take_decode_tail(device, consumed, keep) + } + + /// A request left its end-of-decode checkpoint for `after_response`. + pub(in super::super::super) fn has_deferred_tail(&self) -> bool { + self.pending_tail.is_some() + } + + /// After the response of the request that deferred its end-of-decode checkpoint: take it now. The session stands + /// where the decode left it (nothing ran on the device since), so this is the checkpoint `after_decode` would + /// have taken. `None`: nothing was deferred. + pub(in super::super::super) fn after_response>( + &mut self, + device: &mut D, + ) -> Result, Error> { + let Some(PendingTail { consumed, keep }) = self.pending_tail.take() else { return Ok(None) }; + self.note = None; + self.take_decode_tail(device, &consumed, keep).map(Some) + } + + fn take_decode_tail>( + &mut self, + device: &mut D, + consumed: &[i32], + keep: Option, + ) -> Result { let outcome = self.admit_tail(device, consumed, keep)?; if matches!(outcome, ChunkOutcome::Admitted { .. } | ChunkOutcome::Exists) { // the buffer holds exactly these cells, and the node has a copy of them diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_prefix/prefix_serve/prefix_serve_store_and_shedding.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_prefix/prefix_serve/prefix_serve_store_and_shedding.rs index 1818289e..bddbac4a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_prefix/prefix_serve/prefix_serve_store_and_shedding.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_prefix/prefix_serve/prefix_serve_store_and_shedding.rs @@ -31,6 +31,7 @@ impl PrefixServe { store, live: Vec::new(), req: None, + pending_tail: None, seen_state_bytes: None, seen_block_bytes: None, park_ms_request: 0.0, @@ -162,6 +163,7 @@ impl PrefixServe { self.store.clear(); self.live.clear(); self.req = None; + self.pending_tail = None; } /// Head of a request: install the deepest checkpoint that is a prefix of `prompt`, if any (`None` = read from 0; @@ -172,9 +174,7 @@ impl PrefixServe { prompt: &[i32], ) -> Result, Error> { let g = self.block_tokens; - self.park_ms_request = 0.0; - self.consider_ms_request = 0.0; - self.admitted_request = 0; + self.start_request_counters(); if self.bypass { self.req = None; return Ok(None); @@ -195,6 +195,14 @@ impl PrefixServe { }; self.import_hit(device, prompt, (hit, limit), match_us) } + /// A new request: its counters start at zero, and a checkpoint the last request deferred and nobody took is + /// dropped (it names a device state that is gone). + fn start_request_counters(&mut self) { + self.pending_tail = None; + self.park_ms_request = 0.0; + self.consider_ms_request = 0.0; + self.admitted_request = 0; + } /// Where a hit lands in the positional buffer: how much of it the buffer already holds and what is copied back. fn import_plan(&self, hit: &Match, head: &[i32]) -> ImportPlan { let g = self.block_tokens; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_prefix/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_prefix/tests.rs index c2d47e1c..f55bafbc 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_prefix/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_prefix/tests.rs @@ -236,6 +236,8 @@ fn governor() -> leleka_memory::Governor { leleka_memory::Governor::new(cfg, std::sync::Arc::new(leleka_memory::FakeProc::default())) } +#[path = "tests/deferred_decode_tail.rs"] +mod deferred_decode_tail; #[path = "tests/one_token_prompt_reads.rs"] mod one_token_prompt_reads; #[path = "tests/second_session.rs"] diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_prefix/tests/deferred_decode_tail.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_prefix/tests/deferred_decode_tail.rs new file mode 100644 index 00000000..2b70a723 --- /dev/null +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_prefix/tests/deferred_decode_tail.rs @@ -0,0 +1,123 @@ +//! `PrefixConfig::defer_decode_tail` (`LELEKA_PREFIX_PARK_ASYNC`): the checkpoint at the end of the decode is taken +//! after the response, from the same device state, and is the checkpoint the immediate path takes. +use super::*; + +fn deferring() -> PrefixServe { + PrefixServe::new(PrefixConfig { tail: TailMode::Reply, defer_decode_tail: true, ..cfg() }, 1024, 1 << 30, "test") +} + +/// An agent turn up to the end of the decode: `begin`, the prompt, the decode of `reply`; returns the session's +/// tokens and what `after_decode` answered. The request is not finished. +fn decode_turn( + s: &mut PrefixServe, + d: &mut Fake, + (prompt, reply): (&[i32], &[i32]), +) -> (Vec, ChunkOutcome) { + let (_, resume) = begin_request(s, d, prompt); + read_chunks(s, d, prompt, (resume, None)); + s.after_prefill(d, prompt).unwrap(); + let mut consumed = prompt[..prompt.len() - 1].to_vec(); + let decoded: Vec = + std::iter::once(prompt[prompt.len() - 1]).chain(reply[..reply.len() - 1].iter().copied()).collect(); + d.read(&decoded, consumed.len()); + consumed.extend_from_slice(&decoded); + let outcome = s.after_decode(d, &consumed).unwrap(); + (consumed, outcome) +} + +/// What a store holds, for comparing two caches. +fn shape(s: &PrefixServe) -> (usize, usize, usize, usize) { + (s.node_count(), s.block_count(), s.bytes(), s.live_tokens()) +} + +#[test] +fn the_deferral_is_off_by_default() { + assert!(!PrefixConfig::auto().defer_decode_tail); + assert!(!cfg().defer_decode_tail); +} + +#[test] +fn a_deferred_checkpoint_is_taken_after_the_response_and_equals_the_immediate_one() { + let (mut now, mut later) = (tail_serve(TailMode::Reply), deferring()); + let (mut d_now, mut d_later) = (Fake::new(), Fake::new()); + let (first, reply) = (session(1, 0, 4, 12), doc(33, 0, 300)); + let (consumed, immediate) = decode_turn(&mut now, &mut d_now, (&first, &reply)); + now.finish(true); + let (consumed_later, deferred) = decode_turn(&mut later, &mut d_later, (&first, &reply)); + assert_eq!(consumed, consumed_later); + assert_eq!(deferred, ChunkOutcome::Deferred); + let before = shape(&later); + assert!(before.0 < shape(&now).0, "the decode-end node is not in the store while the response is produced"); + // the request is finished (its claim on the buffer ends) and then the response is out + later.finish(true); + let taken = later.after_response(&mut d_later).unwrap().expect("a checkpoint was deferred"); + let ( + ChunkOutcome::Admitted { tokens, new_blocks, bytes, .. }, + ChunkOutcome::Admitted { tokens: t, new_blocks: n, bytes: b, .. }, + ) = (taken, immediate) + else { + panic!("both paths admit: {taken:?} / {immediate:?}"); + }; + assert_eq!((tokens, new_blocks, bytes), (t, n, b)); + assert_eq!(shape(&later), shape(&now), "the same nodes, blocks, bytes and live claim"); + assert_eq!(later.after_response(&mut d_later).unwrap(), None, "taken once"); +} + +#[test] +fn the_next_turn_resumes_from_the_deferred_checkpoint_exactly_as_from_the_immediate_one() { + let (mut now, mut later) = (tail_serve(TailMode::Reply), deferring()); + let (mut d_now, mut d_later) = (Fake::new(), Fake::new()); + let (first, reply) = (session(1, 0, 4, 12), doc(33, 0, 300)); + decode_turn(&mut now, &mut d_now, (&first, &reply)); + now.finish(true); + let (consumed, _) = decode_turn(&mut later, &mut d_later, (&first, &reply)); + later.finish(true); + later.after_response(&mut d_later).unwrap(); + let mut second = first.clone(); + second.extend(reply.iter().copied()); + second.extend(doc(34, 0, 60)); + let (a, b) = + (now.begin(&mut d_now, &second).unwrap().unwrap(), later.begin(&mut d_later, &second).unwrap().unwrap()); + assert_eq!(a.resume, consumed.len(), "the end of the previous decode"); + assert_eq!((a.resume, a.switched, a.branch, a.copied_tokens), (b.resume, b.switched, b.branch, b.copied_tokens)); + assert_eq!((d_now.position, d_now.digest), (d_later.position, d_later.digest)); +} + +#[test] +fn a_deferred_checkpoint_nobody_took_is_dropped_by_the_next_request_and_by_invalidate() { + let mut s = deferring(); + let mut d = Fake::new(); + let (first, reply) = (session(1, 0, 4, 12), doc(33, 0, 300)); + decode_turn(&mut s, &mut d, (&first, &reply)); + s.finish(true); + let nodes = s.node_count(); + // the next request starts first: the device state the checkpoint named is gone + s.begin(&mut d, &session(2, 0, 3, 5)).unwrap(); + assert_eq!(s.after_response(&mut d).unwrap(), None); + assert_eq!(s.node_count(), nodes, "nothing was parked"); + decode_turn(&mut s, &mut d, (&first, &reply)); + s.finish(true); + s.invalidate(); + assert_eq!(s.after_response(&mut d).unwrap(), None); + assert_eq!(s.node_count(), 0); +} + +#[test] +fn nothing_is_deferred_when_the_tail_is_off_or_the_request_bypasses_the_cache() { + let mut off = PrefixServe::::new( + PrefixConfig { tail: TailMode::Prompt, defer_decode_tail: true, ..cfg() }, + 1024, + 1 << 30, + "test", + ); + let mut d = Fake::new(); + let (first, reply) = (session(1, 0, 4, 12), doc(33, 0, 300)); + let (_, outcome) = decode_turn(&mut off, &mut d, (&first, &reply)); + assert_eq!(outcome, ChunkOutcome::Nothing); + assert_eq!(off.after_response(&mut d).unwrap(), None); + let mut bypass = deferring(); + bypass.set_bypass(true); + let (_, outcome) = decode_turn(&mut bypass, &mut Fake::new(), (&first, &reply)); + assert_eq!(outcome, ChunkOutcome::Nothing); + assert_eq!(bypass.after_response(&mut Fake::new()).unwrap(), None); +} diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/open_tier.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/open_tier.rs index b5b07bd5..fefbcea0 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/open_tier.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/open_tier.rs @@ -1,8 +1,9 @@ //! Moved out of the parent module by STRA-338: fn open_tier, fn pin_resident_complement, fn loan_slots, fn -//! refill_lent, fn settle_refill, fn refill_defer_enabled. +//! refill_lent (per copy or batched), fn settle_refill, fn refill_defer_enabled, fn refill_batch_enabled. #[allow(unused_imports)] use super::*; +use leleka_cuda_driver::RefillBatchOptions; /// generate.cpp startup of the tier for the serve stack: size and open the cache after every other owner, /// fill it from the profile through the registered bank (blocking, rank order; per-layer skips a full @@ -201,18 +202,12 @@ pub(in crate::qwen_forward) fn refill_lent<'ctx>( known: &mut SpanCache, defer_wait: bool, ) -> Result { - let cached = span_cache_enabled(); let bank = moe.original_expert_bank().ok_or(Error::IdentityMismatch)?; - let mut refilled = 0usize; - for slot in 0..cache.slots() { - let Some((layer, expert)) = cache.needs_refill(slot).map_err(|e| driver_error(&e))? else { continue }; - let span_spans = super::super::original_serve_profile::span("refill.spans"); - let spans = lent_spans(binding, moe, (known, cached), (layer, expert))?; - drop(span_spans); - let _span_queue = super::super::original_serve_profile::span("refill.queue"); - queue_lent(cache, (slot, &bank, spans), defer_wait)?; - refilled += 1; - } + let refilled = if refill_batch_enabled() { + refill_lent_batched(binding, moe, cache, known, (&bank, defer_wait))? + } else { + refill_lent_per_copy(binding, moe, cache, known, (&bank, defer_wait))? + }; if defer_wait { // the copies run behind the host's assembly of the decode phase; `settle_refill` waits for them before any // window reads the cache @@ -221,6 +216,51 @@ pub(in crate::qwen_forward) fn refill_lent<'ctx>( settle_refill(cache)?; Ok(refilled) } +/// One `fill_slot_queued` (three or more `cuMemcpyHtoDAsync_v2`) per lent slot. +fn refill_lent_per_copy<'ctx>( + binding: &ModelBinding, + moe: &MoeWeightCache<'ctx>, + cache: &mut OriginalExpertCache<'ctx>, + known: &mut SpanCache, + (bank, defer_wait): (&Rc>, bool), +) -> Result { + let cached = span_cache_enabled(); + let mut refilled = 0usize; + for slot in 0..cache.slots() { + let Some((layer, expert)) = cache.needs_refill(slot).map_err(|e| driver_error(&e))? else { continue }; + let span_spans = super::super::original_serve_profile::span("refill.spans"); + let spans = lent_spans(binding, moe, (known, cached), (layer, expert))?; + drop(span_spans); + let _span_queue = super::super::original_serve_profile::span("refill.queue"); + queue_lent(cache, (slot, bank, spans), defer_wait)?; + refilled += 1; + } + Ok(refilled) +} +/// `LELEKA_REFILL_BATCH`: the same slots, spans and pieces in the same order, queued by one +/// `fill_slots_queued_batched` (`cuMemcpyBatchAsync_v2` calls of `REFILL_BATCH_COPIES` copies). +fn refill_lent_batched<'ctx>( + binding: &ModelBinding, + moe: &MoeWeightCache<'ctx>, + cache: &mut OriginalExpertCache<'ctx>, + known: &mut SpanCache, + (bank, defer_wait): (&Rc>, bool), +) -> Result { + let cached = span_cache_enabled(); + let mut fills = Vec::new(); + for slot in 0..cache.slots() { + let Some((layer, expert)) = cache.needs_refill(slot).map_err(|e| driver_error(&e))? else { continue }; + let _span_spans = super::super::original_serve_profile::span("refill.spans"); + fills.push((slot, lent_spans(binding, moe, (known, cached), (layer, expert))?)); + } + if fills.is_empty() { + return Ok(0); + } + let _span_queue = super::super::original_serve_profile::span("refill.queue"); + let options = RefillBatchOptions { own_stream: defer_wait, max_copies_per_call: REFILL_BATCH_COPIES }; + let report = cache.fill_slots_queued_batched(bank, fills, options).map_err(|e| driver_error(&e))?; + Ok(report.slots) +} /// The bank spans of a lent slot's own expert, from the span cache when it is on. fn lent_spans( binding: &ModelBinding, @@ -265,3 +305,11 @@ pub(in crate::qwen_forward) fn settle_refill(cache: &mut OriginalExpertCache<'_> pub(in crate::qwen_forward) fn refill_defer_enabled() -> bool { crate::settings::process().memory.refill_defer } + +/// Copies per `cuMemcpyBatchAsync_v2` call of the batched refill (about 170 slots of three pieces). +const REFILL_BATCH_COPIES: usize = 512; +/// `LELEKA_REFILL_BATCH=on` (EXPERIMENTAL, off by default): batch the lent-slot refill's copies; the slot bytes are the +/// per-copy path's, only the host's issue cost changes (docs/experiments/refill-batch-copy.md). +fn refill_batch_enabled() -> bool { + crate::settings::process().memory.refill_batch +} diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack.rs index 7cf55547..c3b8b0ce 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack.rs @@ -42,8 +42,8 @@ use super::{ original_serve_residency::{self, ExpertTierConfig, GpuExpertPool, ResidencyState}, original_serve_seed::{self, SeedReport}, original_serve_verifier::{ - AssembleFailure, AssembleInputs, DecodeResources, PLE_HISTORY_BYTES, ServeFailure, VerifyWeights, - assemble_with_window_fallback, disassemble, seed_ple_history, + AssembleFailure, AssembleInputs, DecodeResources, PLE_HISTORY_BYTES, RearmSeed, ServeFailure, VerifyWeights, + assemble_with_window_fallback, cluster_topk_requested, disassemble, seed_ple_history, }, original_spec_controller::{OriginalSpecController, SpecError}, output_native::{OriginalNativeOutput, OriginalNativePenaltyHistory}, @@ -192,6 +192,9 @@ pub(crate) struct OriginalServeStack<'a, 'ctx> { /// The prefix cache (`StackConfig::prefix`); replaces `conversation` when set. prefix: Option>, state: RequestState, + /// The assembled decode graphs kept for the next request (`LELEKA_DECODE_GRAPH_REUSE`): dropped before the + /// owners they read. + held: GraphReuse>, // Owners, dependents first (fields drop in declaration order). history: OriginalNativePenaltyHistory<'ctx>, ple_history: DeviceRef<'ctx>, @@ -234,6 +237,10 @@ mod tests; #[cfg(test)] pub(crate) mod lifecycle_fake; +// The reuse policy ahead of its stack wiring (see its module doc): driven by the lifecycle fake until then. +#[allow(dead_code)] +pub(crate) mod decode_graph_reuse; +use decode_graph_reuse::{Began, DecodeGraphKey, Ended, GraphReuse, Why}; mod stack_groups; use stack_groups::{RequestState, ServePolicy, TierState}; mod stack_config_and_ttft_marks; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/decode_graph_reuse.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/decode_graph_reuse.rs new file mode 100644 index 00000000..ea7a9e07 --- /dev/null +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/decode_graph_reuse.rs @@ -0,0 +1,371 @@ +//! When the assembled decode graphs may be kept for the next request (`LELEKA_DECODE_GRAPH_REUSE`, off by default; +//! docs/experiments/decode-graph-reuse.md). +//! +//! A captured graph holds the device and mapped-host ADDRESSES of every buffer its kernels touch, never the data, so a +//! graph set recorded for one request replays correctly in the next only when every address and every shape it was +//! recorded over is the same. `DecodeGraphKey` names those inputs; `GraphReuse` keeps one assembly together with the +//! key it was recorded for and hands it out again only for an equal key, after the assembly agreed to be re-armed with +//! the new request's seed. Anything else - a changed key, a refused re-arm, a request that did not end cleanly - +//! retires the held assembly and records a new one. There is no path that replays a graph set for a key it was not +//! recorded for. +//! +//! `HeldAssembly` is what the stack needs from a kept assembly: park it at the end of a request, lend the QSA owners +//! back to the prompt executor (`OriginalVerifyQsaJournal::lend`), receive them for the next request (`take_back`, +//! which refuses owners at other addresses) and re-arm it with the new seed (the verify bank's `rearm`, the speed +//! session's part). The lifecycle fake implements all four; the real assembly implements the owner loan and refuses +//! `park` and `rearm` until the bank has them, so the stack states at `open` that the switch is refused and records +//! every request as before. + +/// Everything the recorded decode graphs are specific to. Two requests may share a recording only when their keys are +/// equal. The two epochs are counters of the owners of the physical buffers: each owner bumps its counter whenever it +/// frees, moves or reallocates a buffer a window graph reads or writes in place (`MoeWeightCache::pin_epoch`, +/// the QSA journal's `OwnersFingerprint`). +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub(crate) struct DecodeGraphKey { + /// The widest recorded window (a graph per T = 1..=`max_t`, plus the commit graph). + pub(crate) max_t: usize, + /// The cell budget the verifier arena and the QSA journals are sized for. + pub(crate) max_cells: usize, + /// How the window stages the PCIe share of the experts: 0 DMA, 2 copy kernel (baked into the graph). + pub(crate) pcie_mode: u8, + /// Whether a VRAM expert tier stands behind the windows. + pub(crate) tier: bool, + /// The decode top-k as a thread-block cluster, as resolved for the card (the graph holds the kernel choice). + pub(crate) cluster_topk: bool, + /// The shared experts and routers the windows read in place (MoE and dense caches). + pub(crate) weights_epoch: u64, + /// The twelve resident QSA index images and mapped K/V journals, the PLE history and the canonical GDN image. + pub(crate) owners_epoch: u64, +} + +impl DecodeGraphKey { + /// The name of the first input that differs from `other`, or `None` for equal keys. + pub(crate) fn first_difference(&self, other: &Self) -> Option<&'static str> { + let checks = [ + ("max_t", self.max_t != other.max_t), + ("max_cells", self.max_cells != other.max_cells), + ("pcie_mode", self.pcie_mode != other.pcie_mode), + ("expert tier", self.tier != other.tier), + ("cluster top-k", self.cluster_topk != other.cluster_topk), + ("weights epoch", self.weights_epoch != other.weights_epoch), + ("owners epoch", self.owners_epoch != other.owners_epoch), + ]; + checks.into_iter().find_map(|(name, differs)| differs.then_some(name)) + } +} + +/// A recorded decode assembly the stack can keep between requests. `S` is what the next request seeds it with (the +/// session's recurrent priors and PLE prior), `O` the twelve QSA owners that travel between the assembly's journal and +/// the prompt executor. +pub(crate) trait HeldAssembly { + /// End of a request: both streams drained, every pending commit waited. `false` refuses: the assembly is retired. + fn park(&mut self) -> bool; + /// Hand the QSA owners out to the executor, keeping the assembly (and its graphs). `None`: they could not leave. + fn lend(&mut self) -> Option; + /// Receive the owners for the next request. Owners at other addresses than the lent ones are refused and returned. + fn take_back(&mut self, owners: O) -> Result<(), O>; + /// Start of the next request: reseed the images in place and reset the window state and every flag. `false` + /// refuses: the assembly is then retired, never replayed. Called with the owners home. + fn rearm(&mut self, seed: &S) -> bool; +} + +/// Why a request got a freshly recorded assembly. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub(crate) enum Why { + /// The switch is off. + Disabled, + /// Nothing was held (first request, or the previous one ended without keeping its assembly). + NothingHeld, + /// The held assembly was recorded for another key; the name of the first input that differs. + KeyChanged(&'static str), + /// The owners that came back are not at the addresses the graphs bound. + OwnersChanged, + /// The held assembly refused to be re-armed. + RearmRefused, +} + +/// How a request got its assembly. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub(crate) enum Armed { + /// The assembly kept from the previous request, re-armed. + Reused, + /// A new recording. + Recorded(Why), +} + +/// The start of a request: the kept assembly, or the owners back with the caller to record a new one. +pub(crate) enum Began { + /// The kept assembly, the owners inside it, re-armed. + Reused(A), + /// Record: the owners are the caller's again; `why` names the reason. + Record { owners: O, why: Why }, + /// A refused re-arm could not give the owners back: the stack has lost them and is broken. + Lost, +} + +/// The end of a request. +pub(crate) enum Ended { + /// The assembly is kept, the owners are home. + Kept, + /// The assembly is not kept. `owners_home`: the owners were already handed back (then close the assembly without + /// recovering them); otherwise they are still inside it and the existing teardown recovers them. + Retire { assembly: A, owners_home: bool }, +} + +/// One assembly kept between requests, with the key it was recorded for. +pub(crate) struct GraphReuse { + enabled: bool, + held: Option<(DecodeGraphKey, A)>, +} + +impl GraphReuse { + pub(crate) fn new(enabled: bool) -> Self { + Self { enabled, held: None } + } + + /// Whether the switch is on. + pub(crate) fn enabled(&self) -> bool { + self.enabled + } + + /// The start of a request over `key`, `seed` and the owners the executor gives: the held assembly when the key is + /// equal, the owners came back at the same addresses and it re-arms; otherwise the held assembly is retired + /// (`retire` runs first: the MTP drafter's bindings to its bank are released before the bank closes) and the owners + /// go back to the caller to record a new one. + pub(crate) fn begin( + &mut self, + (key, seed): (&DecodeGraphKey, &S), + owners: O, + mut retire: impl FnMut(), + ) -> Began + where + A: HeldAssembly, + { + let Some((held_for, mut assembly)) = self.held.take() else { + let why = if self.enabled { Why::NothingHeld } else { Why::Disabled }; + return Began::Record { owners, why }; + }; + if let Some(name) = held_for.first_difference(key) { + retire(); + return Began::Record { owners, why: Why::KeyChanged(name) }; + } + if let Err(owners) = assembly.take_back(owners) { + retire(); + return Began::Record { owners, why: Why::OwnersChanged }; + } + if assembly.rearm(seed) { + return Began::Reused(assembly); + } + let lent = assembly.lend(); + retire(); + lent.map_or(Began::Lost, |owners| Began::Record { owners, why: Why::RearmRefused }) + } + + /// The end of a clean request: park the assembly, lend the owners back through `home` and keep it. Anything that + /// fails retires it (the caller tears it down as it does with the switch off). + pub(crate) fn end(&mut self, key: &DecodeGraphKey, mut assembly: A, home: impl FnOnce(O) -> bool) -> Ended + where + A: HeldAssembly, + { + if !self.enabled || !assembly.park() { + return Ended::Retire { assembly, owners_home: false }; + } + let Some(owners) = assembly.lend() else { + return Ended::Retire { assembly, owners_home: false }; + }; + if !home(owners) { + return Ended::Retire { assembly, owners_home: true }; + } + self.held = Some((*key, assembly)); + Ended::Kept + } + + /// Retire the held assembly (a lost owner, a reconfigure, a narrowed window), after `retire` released the drafter. + pub(crate) fn invalidate(&mut self, retire: impl FnOnce()) { + if let Some(held) = self.held.take() { + retire(); + drop(held); + } + } + + /// The kept assembly, for a test that reads its state. + pub(crate) fn held(&self) -> Option<&A> { + self.held.as_ref().map(|(_, assembly)| assembly) + } + + /// Whether an assembly is held. + pub(crate) fn is_held(&self) -> bool { + self.held.is_some() + } +} + +/// The one line `open` writes when the switch is on. +pub(crate) fn enabled_line(requested: bool) -> Option<&'static str> { + requested.then_some(concat!( + "decode graph reuse (LELEKA_DECODE_GRAPH_REUSE) on: the assembled decode graphs are kept across requests ", + "while their key is unchanged and the verify bank re-arms (docs/experiments/decode-graph-reuse.md)", + )) +} + +#[cfg(test)] +mod tests { + use super::*; + use std::cell::RefCell; + use std::rc::Rc; + + type Log = Rc>>; + + /// An assembly that logs what the policy asks of it. `owners` stands for the QSA owners it holds while lent out + /// (`None`); `moved` makes `take_back` refuse; `rearm_ok` / `lend_ok` script the rest. + struct Probe { + log: Log, + home: Option, + moved: bool, + rearm_ok: bool, + lend_ok: bool, + } + + impl Probe { + fn new(log: &Log) -> Self { + Self { log: Rc::clone(log), home: Some(1), moved: false, rearm_ok: true, lend_ok: true } + } + } + + impl Drop for Probe { + fn drop(&mut self) { + self.log.borrow_mut().push("drop"); + } + } + + impl HeldAssembly<(), u32> for Probe { + fn park(&mut self) -> bool { + self.log.borrow_mut().push("park"); + true + } + fn lend(&mut self) -> Option { + self.log.borrow_mut().push("lend"); + self.lend_ok.then(|| self.home.take()).flatten() + } + fn take_back(&mut self, owners: u32) -> Result<(), u32> { + self.log.borrow_mut().push("take_back"); + if self.moved { + return Err(owners); + } + self.home = Some(owners); + Ok(()) + } + fn rearm(&mut self, _: &()) -> bool { + self.log.borrow_mut().push("rearm"); + self.rearm_ok + } + } + + fn key() -> DecodeGraphKey { + DecodeGraphKey { + max_t: 8, + max_cells: 1 << 16, + pcie_mode: 0, + tier: true, + cluster_topk: true, + weights_epoch: 0, + owners_epoch: 0, + } + } + + /// A reuse that holds a probe: one request ended cleanly with the owners home (`home` took them). + fn holding(log: &Log, configure: impl FnOnce(&mut Probe)) -> GraphReuse { + let mut reuse = GraphReuse::new(true); + let mut probe = Probe::new(log); + configure(&mut probe); + let mut home = None; + assert!(matches!(reuse.end(&key(), probe, |owners| home.replace(owners).is_none()), Ended::Kept)); + assert_eq!(home, Some(1)); + log.borrow_mut().clear(); + reuse + } + + fn release(log: &Log) -> impl FnMut() + '_ { + move || log.borrow_mut().push("release") + } + + #[test] + fn with_the_switch_off_the_policy_touches_nothing_and_keeps_nothing() { + let log = Log::default(); + let mut reuse = GraphReuse::::new(false); + match reuse.begin((&key(), &()), 5, release(&log)) { + Began::Record { owners: 5, why: Why::Disabled } => {} + _ => panic!("a disabled policy hands the owners straight back"), + } + let mut home = None; + let ended = reuse.end(&key(), Probe::new(&log), |owners| home.replace(owners).is_none()); + assert!(matches!(ended, Ended::Retire { owners_home: false, .. }), "the existing teardown recovers the owners"); + assert!(home.is_none() && !reuse.is_held()); + drop(ended); + assert_eq!(*log.borrow(), ["drop"], "no park, no lend, no release, no re-arm"); + } + + #[test] + fn a_changed_key_retires_the_assembly_after_the_drafter_let_go_of_its_bank() { + let log = Log::default(); + let mut reuse = holding(&log, |_| {}); + let mut other = key(); + other.pcie_mode = 2; + match reuse.begin((&other, &()), 7, release(&log)) { + Began::Record { owners: 7, why: Why::KeyChanged("pcie_mode") } => {} + _ => panic!("a changed key records again over the owners it was given"), + } + assert_eq!(*log.borrow(), ["release", "drop"], "the release comes first, then the bank closes"); + assert!(!reuse.is_held()); + } + + #[test] + fn owners_at_other_addresses_retire_the_assembly_without_a_re_arm() { + let log = Log::default(); + let mut reuse = holding(&log, |probe| probe.moved = true); + match reuse.begin((&key(), &()), 9, release(&log)) { + Began::Record { owners: 9, why: Why::OwnersChanged } => {} + _ => panic!("the refused owners go back to the caller"), + } + assert_eq!(*log.borrow(), ["take_back", "release", "drop"]); + } + + #[test] + fn a_refused_re_arm_lends_the_owners_out_again_and_retires_the_assembly() { + let log = Log::default(); + let mut reuse = holding(&log, |probe| probe.rearm_ok = false); + match reuse.begin((&key(), &()), 9, release(&log)) { + Began::Record { owners: 9, why: Why::RearmRefused } => {} + _ => panic!("the owners the re-arm refused come back from the journal"), + } + assert_eq!(*log.borrow(), ["take_back", "rearm", "lend", "release", "drop"]); + } + + #[test] + fn owners_that_cannot_leave_after_a_refused_re_arm_are_a_lost_stack() { + let log = Log::default(); + let mut reuse = holding(&log, |probe| probe.rearm_ok = false); + reuse.held.as_mut().unwrap().1.lend_ok = false; + assert!(matches!(reuse.begin((&key(), &()), 9, release(&log)), Began::Lost)); + assert_eq!(*log.borrow(), ["take_back", "rearm", "lend", "release", "drop"]); + } + + #[test] + fn a_clean_request_is_kept_and_the_next_one_re_arms_it() { + let log = Log::default(); + let mut reuse = holding(&log, |_| {}); + assert!(reuse.is_held()); + let began = reuse.begin((&key(), &()), 1, release(&log)); + assert!(matches!(began, Began::Reused(_))); + assert_eq!(*log.borrow(), ["take_back", "rearm"], "nothing is released while the bank is kept"); + } + + #[test] + fn invalidating_releases_the_drafter_before_the_bank_closes() { + let log = Log::default(); + let mut reuse = holding(&log, |_| {}); + reuse.invalidate(|| log.borrow_mut().push("release")); + assert_eq!(*log.borrow(), ["release", "drop"]); + reuse.invalidate(|| log.borrow_mut().push("release")); + assert_eq!(*log.borrow(), ["release", "drop"], "nothing held, nothing to release"); + } +} diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/lifecycle_fake.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/lifecycle_fake.rs index 14f151ae..1db86781 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/lifecycle_fake.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/lifecycle_fake.rs @@ -21,10 +21,12 @@ use std::rc::Rc; use std::sync::Arc; use std::sync::atomic::{AtomicBool, Ordering}; +mod graphs; mod port; mod prefix; mod stack; +pub(crate) use graphs::{Bank, GraphBook, Refusals}; pub(crate) use prefix::{FakeBlock, FakeState}; pub(crate) use stack::FakeStack; @@ -34,6 +36,8 @@ pub(crate) const VOCAB: u32 = 248_320; /// The prefix cache's grid and block size in the fake (the smallest the cache admits). pub(crate) const GRID: usize = 256; const CELLS: usize = 1 << 16; +/// Where the fake's QSA owners stand at first. +const OWNERS_AT: u64 = 0x10_0000; const FIRST: i32 = 33; const SPAN: i32 = 90; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/lifecycle_fake/graphs.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/lifecycle_fake/graphs.rs new file mode 100644 index 00000000..f88b9e71 --- /dev/null +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/lifecycle_fake/graphs.rs @@ -0,0 +1,225 @@ +//! The decode graphs of the scripted device: what the reuse policy keeps between requests (test support only). +//! +//! `FakeGraphs` stands for the nine recorded window graphs and the commit graph together with the verify bank they run +//! over. Recording costs `record_ms` on the manual clock (the part of the request that `LELEKA_DECODE_GRAPH_REUSE` +//! removes). A recording bakes the key it was made for, the address of the QSA owners and the seed of its request, +//! exactly as a captured graph bakes addresses, and the first window of a request checks all of them: a graph set +//! replayed for another key, over owners that moved, without a re-arm or over state the previous request left behind +//! fails the request instead of passing silently. The bank's `park` / `rearm` and the journal's `lend` / `take_back` +//! follow docs/experiments/decode-graph-reuse.md; the scenarios in `backend/lifecycle_tests/graphs.rs` are the ones the +//! real implementation must pass. +use super::super::decode_graph_reuse::{Armed, Began, DecodeGraphKey, Ended, GraphReuse, HeldAssembly}; +use crate::qwen_forward::contract::Error; + +/// What a request seeds the graphs with: the recurrent state the device stands at when its prompt is read. +pub(crate) type Seed = u64; + +/// The QSA owners the prompt executor and the verifier journal pass between them; `address` stands for the device +/// addresses the graphs bind. +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub(crate) struct FakeOwners { + pub(crate) address: u64, +} + +/// A window the bank ran, stamped with the bank's generation: a later generation refuses it. +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub(crate) struct WindowToken { + generation: u64, +} + +/// The state of the verify bank that a re-arm must reset. +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub(crate) struct Bank { + /// Advanced by every re-arm; windows of an older generation are refused. + pub(crate) generation: u64, + /// Windows and commits run since the recording or the last re-arm. + pub(crate) windows: u64, + pub(crate) commits: u64, + /// The flag the graphs wait on: it counts up inside a request and must restart at zero. + pub(crate) flags: u64, + /// The canonical image: the seed it was last written with. + pub(crate) canonical: Seed, + /// Both streams drained (between `park` and `rearm`). + pub(crate) parked: bool, +} + +/// What a test makes the next recording refuse. +#[derive(Clone, Copy, Debug, Default)] +pub(crate) struct Refusals { + pub(crate) park: bool, + pub(crate) rearm: bool, +} + +/// A recorded graph set of the fake. +pub(crate) struct FakeGraphs { + baked: DecodeGraphKey, + baked_owners: u64, + owners: Option, + refusals: Refusals, + failed: bool, + bank: Bank, +} + +impl FakeGraphs { + fn record(key: DecodeGraphKey, seed: Seed, owners: FakeOwners, refusals: Refusals) -> Self { + let bank = Bank { generation: 1, windows: 0, commits: 0, flags: 0, canonical: seed, parked: false }; + Self { baked: key, baked_owners: owners.address, owners: Some(owners), refusals, failed: false, bank } + } + + pub(crate) fn bank(&self) -> Bank { + self.bank + } + + /// The first window of a request: every address the graphs bound is the live one, the bank stands as a recording + /// leaves it and holds this request's seed. + pub(crate) fn replay(&self, key: &DecodeGraphKey, seed: Seed) -> Result<(), Error> { + let owners_ok = self.owners.is_some_and(|o| o.address == self.baked_owners); + let bank = &self.bank; + let pristine = bank.windows == 0 && bank.commits == 0 && bank.flags == 0 && !bank.parked; + if self.failed || self.baked != *key || !owners_ok || !pristine || bank.canonical != seed { + return Err(Error::IdentityMismatch); + } + Ok(()) + } + + /// The windows and commits of a request's rounds; returns the last window. + pub(crate) fn run_rounds(&mut self, rounds: usize) -> WindowToken { + for _ in 0..rounds { + self.bank.windows += 1; + self.bank.flags += 1; + self.bank.commits += 1; + } + WindowToken { generation: self.bank.generation } + } + + /// Whether the bank accepts a window run earlier. + pub(crate) fn accepts(&self, window: WindowToken) -> bool { + window.generation == self.bank.generation + } + + /// Close the set: the owners come back when they are inside. + fn close(self) -> Option { + self.owners + } +} + +impl HeldAssembly for FakeGraphs { + fn park(&mut self) -> bool { + if self.refusals.park || self.failed || self.owners.is_none() { + return false; + } + self.bank.parked = true; + true + } + + fn lend(&mut self) -> Option { + self.owners.take() + } + + fn take_back(&mut self, owners: FakeOwners) -> Result<(), FakeOwners> { + if self.owners.is_some() || self.failed || owners.address != self.baked_owners { + self.failed = true; + return Err(owners); + } + self.owners = Some(owners); + Ok(()) + } + + fn rearm(&mut self, seed: &Seed) -> bool { + if self.refusals.rearm || self.failed || self.owners.is_none() || !self.bank.parked { + return false; + } + let generation = self.bank.generation + 1; + self.bank = Bank { generation, windows: 0, commits: 0, flags: 0, canonical: *seed, parked: false }; + true + } +} + +/// The policy plus the counters a test reads. +pub(crate) struct GraphBook { + reuse: GraphReuse, + /// Graph sets recorded so far. + pub(crate) recordings: usize, + /// Requests that replayed a kept set. + pub(crate) reuses: usize, + /// Times the MTP drafter's bindings to the verifier's bank were released. + pub(crate) drafter_releases: usize, + /// What the next recording refuses (read when it is recorded). + pub(crate) refusals: Refusals, + /// How the last request got its graphs. + pub(crate) last: Option, +} + +impl GraphBook { + pub(crate) fn new(enabled: bool) -> Self { + Self { + reuse: GraphReuse::new(enabled), + recordings: 0, + reuses: 0, + drafter_releases: 0, + refusals: Refusals::default(), + last: None, + } + } + + /// The graphs for a request over `key`, `seed` and the owners the executor gives: a kept set or a recording. + pub(crate) fn begin( + &mut self, + (key, seed): (&DecodeGraphKey, Seed), + owners: FakeOwners, + ) -> Result<(FakeGraphs, Armed), Error> { + let releases = &mut self.drafter_releases; + let (graphs, armed) = match self.reuse.begin((key, &seed), owners, || *releases += 1) { + Began::Reused(graphs) => (graphs, Armed::Reused), + Began::Record { owners, why } => { + self.recordings += 1; + (FakeGraphs::record(*key, seed, owners, self.refusals), Armed::Recorded(why)) + } + Began::Lost => return Err(Error::IdentityMismatch), + }; + self.reuses += usize::from(armed == Armed::Reused); + self.last = Some(armed); + Ok((graphs, armed)) + } + + /// The end of a clean request: the set is kept and the owners go home, or the set is retired. + pub(crate) fn end(&mut self, key: &DecodeGraphKey, graphs: FakeGraphs, home: &mut Option) { + match self.reuse.end(key, graphs, |owners| home.replace(owners).is_none()) { + Ended::Kept => {} + Ended::Retire { assembly, owners_home } => self.retire(assembly, owners_home, home), + } + } + + /// A request that failed or was cancelled: the set is retired, the owners go home. + pub(crate) fn abandon(&mut self, graphs: FakeGraphs, home: &mut Option) { + self.retire(graphs, false, home); + } + + /// The drafter lets go of the bank, then the set closes and gives the owners back when they are inside. + fn retire(&mut self, graphs: FakeGraphs, owners_home: bool, home: &mut Option) { + self.drafter_releases += 1; + let inside = graphs.close(); + if !owners_home { + *home = inside; + } + } + + pub(crate) fn invalidate(&mut self) { + let releases = &mut self.drafter_releases; + self.reuse.invalidate(|| *releases += 1); + } + + pub(crate) fn is_held(&self) -> bool { + self.reuse.is_held() + } + + /// The kept set. + pub(crate) fn held(&self) -> Option<&FakeGraphs> { + self.reuse.held() + } + + /// The bank of the kept set. + pub(crate) fn held_bank(&self) -> Option { + self.reuse.held().map(FakeGraphs::bank) + } +} diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/lifecycle_fake/stack.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/lifecycle_fake/stack.rs index 2fef8e9c..1bd8d67b 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/lifecycle_fake/stack.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/lifecycle_fake/stack.rs @@ -1,9 +1,11 @@ //! `FakeStack`: the request-level seams of the stack over the scripted device. +use super::super::decode_graph_reuse::{Armed, DecodeGraphKey}; use super::super::{ PlanLimits, PrefixConfig, PrefixServe, PromptOptions, PromptPath, PromptPlan, RequestOwners, ResumePoint, ServeDevice, ServeError, ServeRequest, original_serve_residency, plan_error, run_request, }; -use super::{FakeBlock, FakeDevice, FakeState, GRID, VOCAB}; +use super::graphs::{FakeOwners, WindowToken}; +use super::{CELLS, FakeBlock, FakeDevice, FakeState, GRID, GraphBook, OWNERS_AT, VOCAB}; use crate::backend::original_prompt::PromptAction; use crate::qwen_forward::contract::Error; use crate::qwen_forward::original_serve_engine::{ @@ -12,6 +14,19 @@ use crate::qwen_forward::original_serve_engine::{ use crate::qwen_forward::original_spec_controller::{OriginalSpecController, SpecError}; use leleka_obs::time::{Clock, ManualClock}; +/// The inputs the fake's graphs are recorded over at first. +fn first_graph_key() -> DecodeGraphKey { + DecodeGraphKey { + max_t: 4, + max_cells: CELLS, + pcie_mode: 0, + tier: false, + cluster_topk: true, + weights_epoch: 0, + owners_epoch: 0, + } +} + /// An `OriginalServeStack` without a GPU. The settings are mode17's with the prompt-lookup drafter off, so that every /// drafted token comes from the scripted device: a window carries `1 + 3` rows at most. pub(crate) struct FakeStack { @@ -24,6 +39,11 @@ pub(crate) struct FakeStack { max_context: i64, reused: usize, timing: (f64, f64), + graphs: GraphBook, + graph_key: DecodeGraphKey, + record_ms: u64, + owners: Option, + last_window: Option, } impl FakeStack { @@ -45,9 +65,49 @@ impl FakeStack { max_context: 4096, reused: 0, timing: (0.0, 0.0), + graphs: GraphBook::new(false), + graph_key: first_graph_key(), + record_ms: 0, + owners: Some(FakeOwners { address: OWNERS_AT }), + last_window: None, } } + /// The prefill reallocated the QSA owners: they stand at other addresses when the next request lends them to the + /// verifier. + pub(crate) fn move_owners(&mut self) { + if let Some(owners) = self.owners.as_mut() { + owners.address += 0x1000; + } + } + + /// The last window the bank ran, for a test that offers it to a later generation. + pub(crate) fn last_window(&self) -> Option { + self.last_window + } + + /// Whether the kept set (if any) accepts `window`. + pub(crate) fn kept_accepts(&self, window: WindowToken) -> Option { + self.graphs.held().map(|graphs| graphs.accepts(window)) + } + + /// `LELEKA_DECODE_GRAPH_REUSE` on or off, and what recording the graph set costs on the manual clock. + pub(crate) fn with_graph_reuse(mut self, enabled: bool, record_ms: u64) -> Self { + self.graphs = GraphBook::new(enabled); + self.record_ms = record_ms; + self + } + + /// The policy's counters, and the switch for the next re-arm to refuse. + pub(crate) fn graphs(&mut self) -> &mut GraphBook { + &mut self.graphs + } + + /// The inputs the next request's graphs are keyed on (a test changes one between requests). + pub(crate) fn graph_key(&mut self) -> &mut DecodeGraphKey { + &mut self.graph_key + } + /// Checkpoint hits the prefix cache has counted. pub(crate) fn prefix_hits(&self) -> u64 { self.prefix.as_ref().map_or(0, |p| p.stats().hits) @@ -176,6 +236,35 @@ impl FakeStack { serve_request(&mut self.controller, &mut engine, speculative, callbacks) } + /// The graph set of the request (kept or recorded) over the QSA owners, the rounds over it, and the set kept again + /// after a clean end. The owners go home on every path. + fn decode_over_graphs( + &mut self, + request: &ServeRequest, + emit: &mut dyn FnMut(&[i32]) -> Result<(), Error>, + cancel: &mut dyn FnMut() -> bool, + ) -> Result { + let (key, seed) = (self.graph_key, self.dev.digest()); + let owners = self.owners.take().ok_or(Error::IdentityMismatch)?; + let (mut graphs, armed) = self.graphs.begin((&key, seed), owners)?; + if let Armed::Recorded(why) = armed { + self.clock.advance_ms(self.record_ms); + self.dev.log(format!("graphs recorded: {why:?}")); + } else { + self.dev.log("graphs reused"); + } + let served = graphs.replay(&key, seed).map_err(SpecError::from).and_then(|()| { + let outcome = self.serve_rounds(request, emit, cancel)?; + self.last_window = Some(graphs.run_rounds(outcome.rounds)); + Ok(outcome) + }); + match &served { + Ok(_) => self.graphs.end(&key, graphs, &mut self.owners), + Err(_) => self.graphs.abandon(graphs, &mut self.owners), + } + served + } + fn prefix_resume(&mut self, request: &ServeRequest) -> Option { let prefix = self.prefix.as_mut()?; match prefix.begin(&mut self.dev, &request.prompt) { @@ -230,7 +319,7 @@ impl RequestOwners for FakeStack { cancel: &mut dyn FnMut() -> bool, ) -> Result { let started = self.clock.now(); - let result = self.serve_rounds(request, emit, cancel); + let result = self.decode_over_graphs(request, emit, cancel); self.timing.1 = self.clock.since(started).as_secs_f64() * 1e3; result } diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods.rs index b191c7d6..ba66a301 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods.rs @@ -5,9 +5,11 @@ use super::*; mod decode_parts; use decode_parts::{ - QsaOwnerHome, RefillOwners, TierResources, assemble_decode, decode_pcie_mode, gpu_expert_pool, - narrow_window_policy, resolve_assembled, return_owners, settle_deferred_refill, teardown_decode, + QsaOwnerHome, QsaOwners, RefillOwners, TierResources, assemble_decode, decode_pcie_mode, gpu_expert_pool, + narrow_window_policy, resolve_assembled, return_owners, settle_deferred_refill, }; +mod decode_teardown; +use decode_teardown::{Ending, retire_kept, teardown_decode}; mod executor_opening; use executor_opening::ExecutorOpening; mod open_parts; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/decode_parts.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/decode_parts.rs index 0e1364d2..5aec34eb 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/decode_parts.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/decode_parts.rs @@ -4,10 +4,11 @@ #[allow(unused_imports)] use super::*; +use crate::qwen_forward::moe_weight_cache::SharedKeys; use crate::qwen_forward::original_serve_host::HostOutcome; use leleka_cuda_driver::{OriginalQsaMappedJournal, OriginalQsaResidentIndex}; -type QsaOwners<'ctx> = [Option<(OriginalQsaResidentIndex<'ctx>, OriginalQsaMappedJournal<'ctx>)>; 48]; +pub(super) type QsaOwners<'ctx> = [Option<(OriginalQsaResidentIndex<'ctx>, OriginalQsaMappedJournal<'ctx>)>; 48]; /// The executor, binding, dense cache and session the physical QSA owners go back to when a decode phase ends. pub(super) struct QsaOwnerHome<'a, 'ctx> { @@ -18,7 +19,7 @@ pub(super) struct QsaOwnerHome<'a, 'ctx> { } impl<'ctx> QsaOwnerHome<'_, 'ctx> { /// Hands the owners back to the executor at the session's lineage. - fn adopt(&mut self, owners: QsaOwners<'ctx>) -> Result<()> { + pub(super) fn adopt(&mut self, owners: QsaOwners<'ctx>) -> Result<()> { self.executor.adopt_qsa_owners(self.binding, self.dense, self.session, owners) } } @@ -58,7 +59,7 @@ pub(super) struct RefillOwners<'r, 'ctx> { impl<'ctx> RefillOwners<'_, 'ctx> { /// Queued after assembly's own uploads (canonical GDN image), before the graph capture. - fn queue(&mut self, binding: &ModelBinding, moe: &MoeWeightCache<'ctx>) -> Result<()> { + pub(super) fn queue(&mut self, binding: &ModelBinding, moe: &MoeWeightCache<'ctx>) -> Result<()> { if !std::mem::take(&mut *self.due) { return Ok(()); } @@ -82,12 +83,11 @@ fn note_window_retry(failed: usize, next: usize) { /// memory. pub(super) fn assemble_decode<'a, 'ctx>( inputs: &AssembleInputs<'_, 'a, 'ctx>, - executor: &mut OriginalPromptExecutor<'ctx>, + owners: QsaOwners<'ctx>, verifier_max_t: usize, moe: &MoeWeightCache<'ctx>, refill: RefillOwners<'_, 'ctx>, ) -> std::result::Result<(usize, std::result::Result, AssembleFailure<'ctx>>), SpecError> { - let owners = executor.take_qsa_owners()?; let p = profile::span("decode.assemble"); let mut refill = refill; let mut queue_refill = || refill.queue(inputs.binding, moe); @@ -225,32 +225,13 @@ pub(super) fn gpu_expert_pool<'p, 'a, 'ctx>( }) } -/// The end of the decode phase: release the MTP drafter's bindings to this verifier's bank, close the verifier and -/// take the -/// physical QSA owners back at the session's lineage (an abandoned window is rolled back there). -pub(super) fn teardown_decode<'ctx>( - resources: DecodeResources<'ctx>, - outcome: Option, - mut home: QsaOwnerHome<'_, 'ctx>, - context: &'ctx Context<'ctx>, - broken: &mut Option, -) { - release_mtp(&mut *home.executor, home.binding, broken); - // the card at the end of the decode phase, graph pools and all windows captured: the real low-water mark of a - // request - vram_note(context, "decode end before disassemble"); - let p = profile::span("decode.disassemble"); - let disassembled = disassemble(resources); - drop(p); - adopt_disassembled(disassembled, home, broken); - if outcome.is_some_and(|o| o.failed) { - broken.get_or_insert(Error::IdentityMismatch); - } -} - /// The MTP drafter's cached round programs and staged window are bound to THIS verifier's bank: release them before the /// bank closes (it is shared while they live) and so the next request captures against its own bank. -fn release_mtp(executor: &mut OriginalPromptExecutor<'_>, binding: &ModelBinding, broken: &mut Option) { +pub(super) fn release_mtp( + executor: &mut OriginalPromptExecutor<'_>, + binding: &ModelBinding, + broken: &mut Option, +) { let p = profile::span("decode.release_mtp"); let released = executor.mtp_release_verifier(binding); drop(p); @@ -261,7 +242,7 @@ fn release_mtp(executor: &mut OriginalPromptExecutor<'_>, binding: &ModelBinding } /// The owners the disassembly gave back return to the executor; a lost one marks the stack broken. -fn adopt_disassembled<'ctx>( +pub(super) fn adopt_disassembled<'ctx>( disassembled: std::result::Result, ServeFailure>, mut home: QsaOwnerHome<'_, 'ctx>, broken: &mut Option, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/decode_teardown.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/decode_teardown.rs new file mode 100644 index 00000000..40064df6 --- /dev/null +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/decode_teardown.rs @@ -0,0 +1,179 @@ +//! The end of a decode phase: close the assembly and take the QSA owners back, or - with `LELEKA_DECODE_GRAPH_REUSE` +//! and a request that ended cleanly - park it, lend the owners home and keep it for the next request (ledger row Q7). + +use super::decode_parts::{QsaOwnerHome, QsaOwners, adopt_disassembled, release_mtp}; +#[allow(unused_imports)] +use super::*; +use crate::qwen_forward::moe_weight_cache::SharedKeys; +use crate::qwen_forward::original_serve_host::HostOutcome; + +/// What the end of a decode needs to keep the assembly for the next request (`LELEKA_DECODE_GRAPH_REUSE`). +struct Keep<'k, 'ctx> { + reuse: &'k mut GraphReuse>, + key: DecodeGraphKey, + moe: &'k MoeWeightCache<'ctx>, + shared: &'k SharedKeys, +} + +/// How the decode ended: the host's outcome and, when the assembly may be kept, what keeping it needs. `keep` is `None` +/// with the switch off and after a request that did not end cleanly. +pub(super) struct Ending<'k, 'ctx> { + outcome: Option, + keep: Option>, +} + +impl<'k, 'ctx> Ending<'k, 'ctx> { + /// The ending of a request: the assembly may be kept when `key` was taken (the switch is on) and the request + /// `served` without an error. + pub(super) fn of( + outcome: Option, + (key, served): (Option, bool), + reuse: &'k mut GraphReuse>, + (moe, shared): (&'k MoeWeightCache<'ctx>, &'k SharedKeys), + ) -> Self { + let keep = key.filter(|_| served).map(|key| Keep { reuse, key, moe, shared }); + Self { outcome, keep } + } +} + +/// A kept assembly goes away (a changed key, a refused re-arm, a reconfigure, the stack closing): the drafter lets go +/// of the bank it was bound to, and the shared experts are no longer protected. The caller then drops the assembly. +pub(super) fn retire_kept( + executor: &mut OriginalPromptExecutor<'_>, + binding: &ModelBinding, + moe: &MoeWeightCache<'_>, + broken: &mut Option, +) { + release_mtp(executor, binding, broken); + moe.unpin_window(); +} + +/// Whether a request that ended like this may leave its assembly for the next one: the ledger saw no inconsistency and +/// no window is left unpublished (its owners would need the rollback `adopt_qsa_owners` does only after a disassembly). +fn keepable(outcome: Option) -> bool { + outcome.is_none_or(|o| !o.failed && !o.dirty) +} + +/// What `keep_assembly` made of the assembly. +enum Kept<'ctx> { + /// Parked, its owners lent home to the executor, held for the next request. + Done, + /// Not kept. `owners_home`: the owners were already handed back. + Retire { resources: DecodeResources<'ctx>, owners_home: bool }, +} + +/// The owners go home to the executor; a failure marks the stack broken. +fn adopt_or_break<'ctx>( + home: &mut QsaOwnerHome<'_, 'ctx>, + owners: QsaOwners<'ctx>, + broken: &mut Option, +) -> bool { + let adopted = home.adopt(owners); + if let Err(error) = adopted { + broken.get_or_insert(error); + } + adopted.is_ok() +} + +/// Try to keep the assembly of a request that ended cleanly: the drafter forgets the request but keeps the bank, the +/// shared experts are pinned, the verifier is parked and the QSA owners go home to the executor. +fn keep_assembly<'ctx>( + keep: Keep<'_, 'ctx>, + resources: DecodeResources<'ctx>, + home: &mut QsaOwnerHome<'_, 'ctx>, + broken: &mut Option, +) -> Kept<'ctx> { + let Keep { reuse, key, moe, shared } = keep; + let not_kept = |resources| Kept::Retire { resources, owners_home: false }; + if let Err(error) = home.executor.mtp_end_request_keep_bank(home.binding) { + operator_line("end the MTP request", &failure(error)); + broken.get_or_insert(error); + return not_kept(resources); + } + if moe.pin_for_window(shared).is_err() { + return not_kept(resources); + } + match reuse.end(&key, resources, |owners| adopt_or_break(home, owners, broken)) { + Ended::Kept => Kept::Done, + Ended::Retire { assembly, owners_home } => { + moe.unpin_window(); + Kept::Retire { resources: assembly, owners_home } + } + } +} + +/// The end of the decode phase: release the MTP drafter's bindings to this verifier's bank, close the verifier and +/// take the +/// physical QSA owners back at the session's lineage (an abandoned window is rolled back there). With +/// `LELEKA_DECODE_GRAPH_REUSE` and a clean request the assembly is kept instead (`keep_assembly`). +pub(super) fn teardown_decode<'ctx>( + resources: DecodeResources<'ctx>, + ending: Ending<'_, 'ctx>, + mut home: QsaOwnerHome<'_, 'ctx>, + context: &'ctx Context<'ctx>, + broken: &mut Option, +) { + let Ending { outcome, keep } = ending; + let (resources, owners_home) = match keep.filter(|_| keepable(outcome)) { + Some(keep) => { + let p = profile::span("decode.keep"); + let kept = keep_assembly(keep, resources, &mut home, broken); + drop(p); + match kept { + Kept::Done => return, + Kept::Retire { resources, owners_home } => (resources, owners_home), + } + } + None => (resources, false), + }; + close_assembly(resources, owners_home, home, context, broken); + if outcome.is_some_and(|o| o.failed) { + broken.get_or_insert(Error::IdentityMismatch); + } +} + +/// Release the drafter, close the verifier and take the QSA owners back (unless they are already home). +fn close_assembly<'ctx>( + resources: DecodeResources<'ctx>, + owners_home: bool, + home: QsaOwnerHome<'_, 'ctx>, + context: &'ctx Context<'ctx>, + broken: &mut Option, +) { + let mut home = home; + release_mtp(&mut *home.executor, home.binding, broken); + // the card at the end of the decode phase, graph pools and all windows captured: the real low-water mark of a + // request + vram_note(context, "decode end before disassemble"); + let p = profile::span("decode.disassemble"); + if owners_home { + let DecodeResources { verifier, qsa, .. } = resources; + if let Err(error) = verifier.close() { + broken.get_or_insert(ServeFailure::from(error).error); + } + drop(qsa); + return; + } + let disassembled = disassemble(resources); + drop(p); + adopt_disassembled(disassembled, home, broken); +} + +#[cfg(test)] +mod tests { + use super::*; + + fn outcome(failed: bool, dirty: bool, state_lag: bool) -> Option { + Some(HostOutcome { failed, dirty, state_lag, position: 7 }) + } + + #[test] + fn only_a_request_without_an_inconsistency_or_an_unpublished_window_leaves_its_assembly() { + assert!(keepable(None)); + assert!(keepable(outcome(false, false, false))); + assert!(keepable(outcome(false, false, true)), "a lagging prior is settled by the next request"); + assert!(!keepable(outcome(true, false, false))); + assert!(!keepable(outcome(false, true, false))); + assert!(!keepable(outcome(true, true, true))); + } +} diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_decode_phase/decode_steps.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_decode_phase/decode_steps.rs index f89f2f12..3f3f9771 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_decode_phase/decode_steps.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_decode_phase/decode_steps.rs @@ -3,7 +3,7 @@ //! log lines are those of the single function they were taken from. #[allow(unused_imports)] -use super::decode_view::{Book, DecodeView, Extra, Ids, Owners, Policy, Reads, Tier}; +use super::decode_view::{Book, DecodeView, Extra, Ids, Owners, Policy, Reads, Refill, Tier}; #[allow(unused_imports)] use super::*; use crate::qwen_forward::moe_weight_cache::SharedKeys; @@ -61,9 +61,102 @@ impl<'a, 'ctx> OriginalServeStack<'a, 'ctx> { } } +/// The owners the refill hook works on, from the view's groups. +fn refill_owners<'r, 'ctx>(refill: &'r mut Refill<'_>, tier: &'r mut Tier<'_, '_, 'ctx>) -> RefillOwners<'r, 'ctx> { + RefillOwners { + due: &mut *refill.due, + cache: &mut *tier.expert_cache, + residency: &mut *tier.residency, + pending: &mut *refill.pending, + } +} + +/// How a request starts its decode: with the kept assembly (or the failure of re-arming it), or with the QSA owners to +/// assemble a new one over. +pub(super) enum Start<'ctx> { + Assembled(std::result::Result, AssembleFailure<'ctx>>), + Record(QsaOwners<'ctx>), +} + impl<'s, 'a, 'ctx> DecodeView<'s, 'a, 'ctx> { - /// Hand the twelve QSA owners to a fresh verifier (windows repeated narrower when a graph does not fit). + /// The inputs a recorded decode graph set is specific to, as they stand now (`LELEKA_DECODE_GRAPH_REUSE`). + pub(super) fn graph_key(&self) -> std::result::Result { + let (cache, moe) = (&*self.tier.expert_cache, self.reads.moe); + Ok(DecodeGraphKey { + max_t: *self.arms.verifier_max_t, + max_cells: self.ids.max_cells, + pcie_mode: decode_pcie_mode(self.policy.config, cache, moe, self.consts.blobs)?, + tier: cache.is_some(), + cluster_topk: cluster_topk_requested(), + weights_epoch: moe.weights_epoch(), + // the journal compares the addresses of the owners that come back (`take_back`) + owners_epoch: 0, + }) + } + + /// The kept assembly for this request when there is one and it re-arms (the owners go back into its journal), + /// otherwise the owners to record a new one over. With the switch off: the owners, untouched. + fn begin_kept( + &mut self, + staged: &Staged<'ctx>, + owners: QsaOwners<'ctx>, + ) -> std::result::Result, SpecError> { + if !self.held.enabled() { + return Ok(Start::Record(owners)); + } + let p = profile::span("decode.reuse"); + let key = self.graph_key()?; + let seed = RearmSeed { binding: self.ids.binding, base: &staged.base }; + let (binding, moe) = (self.ids.binding, self.reads.moe); + let (executor, broken) = (&mut *self.owners.executor, &mut *self.book.broken); + let began = self.held.begin((&key, &seed), owners, || retire_kept(executor, binding, moe, broken)); + drop(p); + match began { + Began::Reused(resources) => Ok(self.start_reused(resources)), + Began::Record { owners, why } => { + if !matches!(why, Why::NothingHeld) { + operator_text(&format!("decode graphs recorded again: {why:?}")); + } + Ok(Start::Record(owners)) + } + Began::Lost => { + self.book.broken.get_or_insert(Error::IdentityMismatch); + Err(SpecError::Forward(Error::IdentityMismatch)) + } + } + } + + /// A kept assembly is re-armed: queue the refill of the lent slots that assembly's own prepare step would have + /// queued. A refill that cannot be queued gives the owners back with the failure and retires the assembly. + fn start_reused(&mut self, mut resources: DecodeResources<'ctx>) -> Start<'ctx> { + crate::bringup_trace!("DBG[{:.0}s] decode: graphs reused", dbg_el()); + let mut refill = refill_owners(&mut self.refill, &mut self.tier); + let Err(error) = refill.queue(self.ids.binding, self.reads.moe) else { + return Start::Assembled(Ok(resources)); + }; + let owners = resources.lend_owners(); + retire_kept(&mut *self.owners.executor, self.ids.binding, self.reads.moe, &mut *self.book.broken); + drop(resources); + Start::Assembled(Err(AssembleFailure { failure: error.into(), owners, window_cap: None })) + } + + /// Hand the twelve QSA owners to a fresh verifier (windows repeated narrower when a graph does not fit), or take + /// the kept one (`LELEKA_DECODE_GRAPH_REUSE`). pub(super) fn assemble(&mut self, staged: &Staged<'ctx>) -> std::result::Result, SpecError> { + let owners = self.owners.executor.take_qsa_owners()?; + let owners = match self.begin_kept(staged, owners)? { + Start::Assembled(assembled) => return Ok((*self.arms.verifier_max_t, assembled)), + Start::Record(owners) => owners, + }; + self.assemble_over(staged, owners) + } + + /// Assemble a new verifier over the QSA owners. + fn assemble_over( + &mut self, + staged: &Staged<'ctx>, + owners: QsaOwners<'ctx>, + ) -> std::result::Result, SpecError> { let (ids, reads, consts) = (&self.ids, &self.reads, &self.consts); let weights = VerifyWeights { dense: reads.dense, @@ -84,13 +177,8 @@ impl<'s, 'a, 'ctx> DecodeView<'s, 'a, 'ctx> { max_cells: ids.max_cells, pcie_mode: staged.pcie_mode, }; - let refill = RefillOwners { - due: &mut *self.refill.due, - cache: &mut *self.tier.expert_cache, - residency: &mut *self.tier.residency, - pending: &mut *self.refill.pending, - }; - assemble_decode(&inputs, &mut *self.owners.executor, *self.arms.verifier_max_t, reads.moe, refill) + let refill = refill_owners(&mut self.refill, &mut self.tier); + assemble_decode(&inputs, owners, *self.arms.verifier_max_t, reads.moe, refill) } /// Settle the deferred refill and the assembly's outcome, then narrow the window policy when the windows that fit @@ -161,6 +249,7 @@ impl<'s, 'a, 'ctx> DecodeView<'s, 'a, 'ctx> { resources: DecodeResources<'ctx>, (mut emit, mut cancel): (impl FnMut(&[i32]) -> Result<()>, impl FnMut() -> bool), ) -> std::result::Result { + let key = self.held.enabled().then(|| self.graph_key()).and_then(std::result::Result::ok); let DecodeResources { verifier, qsa, slots } = resources; // the NaN guard's retry takes a refused window back from these (OriginalVerifier::discard_window) qsa.set_window_snapshots(self.policy.settings.nan_guard.retries > 0); @@ -178,7 +267,9 @@ impl<'s, 'a, 'ctx> DecodeView<'s, 'a, 'ctx> { let resources = DecodeResources { verifier, qsa, slots }; let (executor, session) = (&mut *self.owners.executor, &mut *self.owners.session); let home = QsaOwnerHome { executor, binding: self.ids.binding, dense: self.reads.dense, session }; - teardown_decode(resources, outcome, home, self.ids.context, &mut *self.book.broken); + let tail = (self.reads.moe, self.ids.shared); + let ending = Ending::of(outcome, (key, served.is_ok()), &mut *self.held, tail); + teardown_decode(resources, ending, home, self.ids.context, &mut *self.book.broken); served } } diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_decode_phase/decode_view.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_decode_phase/decode_view.rs index 1c8c137e..e7e6534e 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_decode_phase/decode_view.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_decode_phase/decode_view.rs @@ -93,6 +93,8 @@ pub(super) struct DecodeView<'s, 'a, 'ctx> { pub(super) arms: Arms<'s>, pub(super) book: Book<'s, 'ctx>, pub(super) ple_history: &'s DeviceRef<'ctx>, + /// The kept decode graphs (empty and switched off unless `LELEKA_DECODE_GRAPH_REUSE`). + pub(super) held: &'s mut GraphReuse>, } impl<'a, 'ctx> OriginalServeStack<'a, 'ctx> { @@ -123,6 +125,7 @@ impl<'a, 'ctx> OriginalServeStack<'a, 'ctx> { prefix_live: self.prefix.is_some(), }, ple_history: &self.ple_history, + held: &mut self.held, } } } diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_memory_classes.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_memory_classes.rs index eae4bd08..29ec253f 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_memory_classes.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_memory_classes.rs @@ -278,6 +278,7 @@ impl<'a, 'ctx> OriginalServeStack<'a, 'ctx> { if let Some(error) = self.state.broken { return Err(error); } + self.retire_held(); self.tier.residency.clear_usage(); self.policy.controller = self.policy.settings.controller()?; match self.expert_cache.as_mut() { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_metrics_close.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_metrics_close.rs index 515c8f38..73e68e73 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_metrics_close.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_metrics_close.rs @@ -22,8 +22,17 @@ impl<'a, 'ctx> OriginalServeStack<'a, 'ctx> { self.prefix.as_ref().map_or(0, |prefix| prefix.budget_bytes()) } + /// Retire the kept decode graphs (`LELEKA_DECODE_GRAPH_REUSE`): the drafter lets go of their bank, the shared + /// experts are unpinned, then the assembly closes. Nothing happens when none is kept. + pub(super) fn retire_held(&mut self) { + let Self { held, executor, binding, moe, state, .. } = self; + let binding: &ModelBinding = binding; + held.invalidate(|| retire_kept(executor, binding, moe, &mut state.broken)); + } + /// Close every owner in dependency order; the first failure is reported after all were attempted. - pub(crate) fn close(self) -> Result<()> { + pub(crate) fn close(mut self) -> Result<()> { + self.retire_held(); drop(self.conversation); // the span cache retains registered-source spans of the bank `moe` closes below drop(self.tier.residency); diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_open.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_open.rs index 64a8e619..ea1ade56 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_open.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_open.rs @@ -31,6 +31,9 @@ impl<'a, 'ctx> OriginalServeStack<'a, 'ctx> { this.register_memory_classes(); crate::memory_governor::post_open(); log_open_inventory(); + if let Some(line) = decode_graph_reuse::enabled_line(crate::settings::process().serve.decode_graph_reuse) { + operator_text(line); + } Ok(this) } } diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_open/assemble.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_open/assemble.rs index 974d3539..55bc57b4 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_open/assemble.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_open/assemble.rs @@ -63,23 +63,23 @@ impl<'a, 'ctx> OriginalServeStack<'a, 'ctx> { /// Moves the opened parts into the stack: nothing is computed here but the two MTP policies. pub(super) fn assemble(parts: Assembly<'a, 'ctx>) -> Self { let Assembly { binding, context, config, prepared, core, buffers, tier } = parts; - let layout = prepared.layout; Self { binding, context, config, + tier: TierState::new(prepared.layout, tier.loan, tier.loan_tiers, tier.residency, tier.initial_owners), policy: serve_policy(prepared), empty_session: buffers.empty_session, empty_draft: buffers.empty_draft, conversation: tier.conversation, prefix: tier.prefix, state: RequestState::default(), + held: GraphReuse::new(crate::settings::process().serve.decode_graph_reuse), history: buffers.history, ple_history: buffers.ple_history, ple_scratch: buffers.ple_scratch, arena: buffers.arena, expert_cache: tier.expert_cache, - tier: TierState::new(layout, tier.loan, tier.loan_tiers, tier.residency, tier.initial_owners), executor: core.executor, draft: core.draft, session: core.session, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_prefill_chunk.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_prefill_chunk.rs index 01a927f5..c401b028 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_prefill_chunk.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_prefill_chunk.rs @@ -69,23 +69,31 @@ impl<'a, 'ctx> OriginalServeStack<'a, 'ctx> { pub(in super::super) fn prefix_after_decode(&mut self, consumed: &[i32]) { let Some(mut prefix) = self.prefix.take() else { return }; let _span = profile::span("prefix.after_decode"); - match prefix.after_decode(self, consumed) { - Ok(ChunkOutcome::Admitted { tokens, new_blocks, bytes, park_ms }) => { - operator_text(&format!( - "prefix tail admit (decode end): tokens={tokens} new_blocks={new_blocks} mib={} \ - park_ms={park_ms:.1}", - bytes >> 20 - )); - } - Ok(other) => operator_text(&format!( - "prefix tail (decode end) not taken: {other:?}: {}", - prefix.take_note().unwrap_or_default() - )), - Err(error) => { - operator_text(&format!("prefix cache: {error:?} while checkpointing the end of the decode; skipped")) - } + let taken = prefix.after_decode(self, consumed); + report_decode_tail(&mut prefix, taken.map(Some), "decode end"); + self.prefix = Some(prefix); + } + + /// After the response of a request was published (`LELEKA_PREFIX_PARK_ASYNC`): the end-of-decode checkpoint the + /// request deferred, taken before the next request can start. Nothing ran on the device since the decode ended, + /// so the parked bytes are those `prefix_after_decode` would have taken. Its profile sections are reported on + /// their own line, `park_deferred`. + /// + /// Returns whether a checkpoint was deferred and attempted (the prefix summary has changed). + pub(crate) fn prefix_after_response(&mut self) -> bool { + if self.state.broken.is_some() || !self.prefix.as_ref().is_some_and(PrefixServe::has_deferred_tail) { + return false; + } + let Some(mut prefix) = self.prefix.take() else { return false }; + { + let _span = profile::span("prefix.after_response"); + let taken = prefix.after_response(self); + report_decode_tail(&mut prefix, taken, "decode end, after the response"); } self.prefix = Some(prefix); + self.note_memory(); + profile::report("park_deferred"); + true } /// The prefix cache after a published chunk: a checkpoint at the grid point if the policy wants one. A checkpoint @@ -150,6 +158,26 @@ impl<'a, 'ctx> OriginalServeStack<'a, 'ctx> { } } +/// The operator line of an end-of-decode checkpoint attempt (`None`: nothing was deferred, nothing to say). +fn report_decode_tail( + prefix: &mut PrefixServe, + taken: std::result::Result, Error>, + when: &str, +) { + match taken { + Ok(Some(ChunkOutcome::Admitted { tokens, new_blocks, bytes, park_ms })) => operator_text(&format!( + "prefix tail admit ({when}): tokens={tokens} new_blocks={new_blocks} mib={} park_ms={park_ms:.1}", + bytes >> 20 + )), + Ok(None | Some(ChunkOutcome::Deferred)) => {} + Ok(Some(other)) => operator_text(&format!( + "prefix tail ({when}) not taken: {other:?}: {}", + prefix.take_note().unwrap_or_default() + )), + Err(error) => operator_text(&format!("prefix cache: {error:?} while checkpointing the {when}; skipped")), + } +} + /// The chunk's loan from the expert cache: the smallest rung of the ladder that holds `count` rows, else the full loan. fn lend_tail<'l, 'ctx>( cache: &'l mut OriginalExpertCache<'ctx>, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_verifier.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_verifier.rs index 9ddbb160..ad32eb80 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_verifier.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_verifier.rs @@ -33,6 +33,12 @@ pub(in crate::qwen_forward) const PLE_HISTORY_BYTES: usize = PLE_HISTORY_VALUES /// docs/upstream-port-plan.md row 2.5). const QSA_CLUSTER_DEFAULT: bool = true; +/// Whether the decode top-k is asked to run as a thread-block cluster (`LELEKA_QSA_CLUSTER`, else the default): part of +/// the key of a kept decode graph set, because the graph holds the kernel choice. +pub(in crate::qwen_forward) fn cluster_topk_requested() -> bool { + leleka_cuda_driver::qsa_cluster_requested(QSA_CLUSTER_DEFAULT) +} + /// A refusal with the driver's own words when it has them (an unbound producer, an unsealed asset). #[derive(Clone, Debug, Eq, PartialEq)] pub(crate) struct ServeFailure { @@ -326,6 +332,15 @@ pub(in crate::qwen_forward) fn disassemble<'ctx>( fn recover<'ctx>(qsa: Rc>, slots: [usize; 12]) -> Option> { let (indices, mapped) = OriginalVerifyQsaJournal::into_owners(qsa).ok()?; + place_owners(slots, indices, mapped) +} + +/// The twelve resident layers at their slots of the executor's forty-eight. +fn place_owners<'ctx>( + slots: [usize; 12], + indices: [OriginalQsaResidentIndex<'ctx>; 12], + mapped: [OriginalQsaMappedJournal<'ctx>; 12], +) -> Option> { let mut owners: QsaOwners<'ctx> = std::array::from_fn(|_| None); for ((slot, index), kv) in slots.into_iter().zip(indices).zip(mapped) { *owners.get_mut(slot)? = Some((index, kv)); @@ -334,7 +349,9 @@ fn recover<'ctx>(qsa: Rc>, slots: [usize; 12]) -> } mod assemble_parts; +mod held; use assemble_parts::{Prepared, RecordEnv, capture_verifier, split_owners}; +pub(in crate::qwen_forward) use held::RearmSeed; #[cfg(test)] mod tests; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_verifier/held.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_verifier/held.rs new file mode 100644 index 00000000..ea5f9662 --- /dev/null +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_verifier/held.rs @@ -0,0 +1,83 @@ +//! The decode assembly as the stack keeps it between requests (`LELEKA_DECODE_GRAPH_REUSE`, ledger row Q7). +//! +//! `lend` and `take_back` are the journal's owner loan (`OriginalVerifyQsaJournal::lend` / `take_back`): the twelve QSA +//! owners go home to the prompt executor and come back for the next request, and the journal refuses owners at other +//! addresses than the graphs bound. `park` and `rearm` are the verify bank's (`OriginalVerifier::park` / `rearm`): +//! drain at the end of a request, reseed the canonical GDN image and the PLE history in place and reset the window +//! state at the start of the next. Every refusal or error answers `false` / `None`, and the policy then retires the +//! assembly and records a new one: a kept assembly is never used after anything unexpected. + +#[allow(unused_imports)] +use super::*; +use crate::qwen_forward::original_serve_stack::decode_graph_reuse::HeldAssembly; +use leleka_cuda_driver::OriginalVerifyRearm; + +/// What the next request re-arms the kept assembly with: the model (for the layer order) and the session's priors. +pub(in crate::qwen_forward) struct RearmSeed<'x, 'ctx> { + pub(in crate::qwen_forward) binding: &'x ModelBinding, + pub(in crate::qwen_forward) base: &'x OriginalVerifiedBase<'ctx>, +} + +impl<'x, 'ctx> HeldAssembly, QsaOwners<'ctx>> for DecodeResources<'ctx> { + fn park(&mut self) -> bool { + self.verifier.park().is_ok() + } + + fn lend(&mut self) -> Option> { + self.lend_owners() + } + + fn take_back(&mut self, owners: QsaOwners<'ctx>) -> std::result::Result<(), QsaOwners<'ctx>> { + if !owners_at(&owners, &self.slots) { + return Err(owners); + } + let Ok((indices, mapped)) = split_slots(owners) else { return Err(none_owners()) }; + match self.qsa.take_back((indices, mapped)) { + Ok(()) => Ok(()), + Err((_, (indices, mapped))) => Err(place_owners(self.slots, indices, mapped).unwrap_or_else(none_owners)), + } + } + + fn rearm(&mut self, seed: &RearmSeed<'x, 'ctx>) -> bool { + let Ok(priors) = gdn_layer_priors(seed.binding, seed.base) else { return false }; + let Some(ple) = seed.base.ple.as_ref() else { return false }; + let rearm = OriginalVerifyRearm { + gdn_states: std::array::from_fn(|i| priors[i].values()), + gdn_histories: std::array::from_fn(|i| priors[i].history()), + ple_history: ple.history(), + }; + self.verifier.rearm(rearm).is_ok() + } +} + +impl<'ctx> DecodeResources<'ctx> { + /// The twelve QSA owners out of the journal and into the executor's slots, the assembly kept. + pub(in crate::qwen_forward) fn lend_owners(&mut self) -> Option> { + let (indices, mapped) = self.qsa.lend().ok()?; + place_owners(self.slots, indices, mapped) + } +} + +fn none_owners<'ctx>() -> QsaOwners<'ctx> { + std::array::from_fn(|_| None) +} + +/// The owners are present at exactly `slots`. +fn owners_at(owners: &QsaOwners<'_>, slots: &[usize; 12]) -> bool { + owners.iter().enumerate().filter(|(_, owner)| owner.is_some()).map(|(slot, _)| slot).eq(slots.iter().copied()) +} + +/// The twelve present owners, in slot order, as the journal takes them. +fn split_slots<'ctx>( + owners: QsaOwners<'ctx>, +) -> std::result::Result<([OriginalQsaResidentIndex<'ctx>; 12], [OriginalQsaMappedJournal<'ctx>; 12]), ()> { + let (mut indices, mut mapped) = (Vec::with_capacity(12), Vec::with_capacity(12)); + for (index, kv) in owners.into_iter().flatten() { + indices.push(index); + mapped.push(kv); + } + match (indices.try_into(), mapped.try_into()) { + (Ok(indices), Ok(mapped)) => Ok((indices, mapped)), + _ => Err(()), + } +} diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_resident_device.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_resident_device.rs index 740148db..765046c9 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_resident_device.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_resident_device.rs @@ -32,6 +32,15 @@ pub(in crate::qwen_forward) struct ParkedLayerSpan { pub(in crate::qwen_forward) kv: Vec, pub(in crate::qwen_forward) index: Vec, } +/// How a layer's span is read out for the prefix cache; both give the same bytes. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub(in crate::qwen_forward) enum SpanExport { + /// Each read drains the context itself and fills a zeroed buffer (the reference path). + Checked, + /// The caller drained the context once for all the layers of the park: the reads skip their own drain and write + /// buffers that are not zeroed first (`LELEKA_PREFIX_PARK_FAST`). + Drained, +} /// A parked prefix to install into a resident layer: the layer's spans up to the position `end`, and the tail of its /// index checkpoint at that position. #[derive(Clone, Copy)] diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_resident_device/resident_qsa_span_export_and_seal.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_resident_device/resident_qsa_span_export_and_seal.rs index 471961e1..a89b6af4 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_resident_device/resident_qsa_span_export_and_seal.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_resident_device/resident_qsa_span_export_and_seal.rs @@ -8,24 +8,45 @@ use super::*; impl<'ctx> ResidentQsaLayer<'ctx> { /// Bytes of the cells `first..first + tokens` of this layer as a prefix-cache span (host K/V pages and pooled index /// rows). `first` and `tokens` are multiples of four and lie below the layer's end. - pub(in crate::qwen_forward) fn export_span(&self, first: usize, tokens: usize) -> Result { + pub(in crate::qwen_forward) fn export_span( + &self, + first: usize, + tokens: usize, + mode: SpanExport, + ) -> Result { // `tokens` is a multiple of four for a grid block; a request-end checkpoint ends anywhere: whole pages cover // its cells, and only the complete 4-cell rows of the index image are copied (the checkpoint's tail carries // the partial one) if first % 4 != 0 || tokens == 0 || first + tokens > self.current.next_position() as usize { return Err(Error::InvalidPosition); } - let (mut kv, mut index) = (Vec::new(), Vec::new()); - { - let _p = crate::qwen_forward::original_serve_profile::span("prefix.export_kv"); - self.kv.export_pages(first / 4, (first + tokens).div_ceil(4) - first / 4, &mut kv).map_err(device_error)?; + let kv = self.export_kv(first, tokens, mode)?; + let index = self.export_index(first, tokens, mode)?; + Ok(ParkedLayerSpan { first_token: first, tokens, kv, index }) + } + /// The host K/V pages of the cells `first..first + tokens`: whole pages, up to the one holding the last cell. + fn export_kv(&self, first: usize, tokens: usize, mode: SpanExport) -> Result> { + let _p = crate::qwen_forward::original_serve_profile::span("prefix.export_kv"); + let (pages, mut kv) = ((first + tokens).div_ceil(4) - first / 4, Vec::new()); + match mode { + SpanExport::Checked => self.kv.export_pages(first / 4, pages, &mut kv), + SpanExport::Drained => self.kv.export_pages_fast(first / 4, pages, &mut kv), } - let rows = (first + tokens) / 4 - first / 4; + .map_err(device_error)?; + Ok(kv) + } + /// The pooled index rows of the complete 4-cell rows in `first..first + tokens` (none: an empty vector). + fn export_index(&self, first: usize, tokens: usize, mode: SpanExport) -> Result> { + let (rows, mut index) = ((first + tokens) / 4 - first / 4, Vec::new()); if rows > 0 { let _p = crate::qwen_forward::original_serve_profile::span("prefix.export_index"); - self.index.export_rows(first / 4, rows, &mut index).map_err(device_error)?; + match mode { + SpanExport::Checked => self.index.export_rows(first / 4, rows, &mut index), + SpanExport::Drained => self.index.export_rows_fast(first / 4, rows, &mut index), + } + .map_err(device_error)?; } - Ok(ParkedLayerSpan { first_token: first, tokens, kv, index }) + Ok(index) } /// The tail of the layer's index checkpoint at its current end (what `import` needs besides the spans). pub(in crate::qwen_forward) fn export_tail(&self) -> Result> { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session_original_prompt.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session_original_prompt.rs index 331ad078..76824491 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session_original_prompt.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session_original_prompt.rs @@ -4,7 +4,7 @@ use super::super::dense_weight_cache::DenseWeightCache; use super::super::prompt_device_rows::PromptWeights; use super::super::qsa_index::prompt_device::resident_device::{ - ParkedLayerSpan, ParkedPrefix, ResidentQsaLayer, ResidentQsaOwners, ResidentQsaPrior, ResidentQsaSeal, + ParkedLayerSpan, ParkedPrefix, ResidentQsaLayer, ResidentQsaOwners, ResidentQsaPrior, ResidentQsaSeal, SpanExport, }; use super::*; use std::cell::{Cell, RefCell}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session_original_prompt/original_prompt_input/qwen_session.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session_original_prompt/original_prompt_input/qwen_session.rs index c90b98d2..a08ddc85 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session_original_prompt/original_prompt_input/qwen_session.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session_original_prompt/original_prompt_input/qwen_session.rs @@ -241,6 +241,7 @@ impl<'driver> QwenSession<'driver> { layers: &[Option>; STATE_CAPACITY], first: usize, tokens: usize, + mode: SpanExport, ) -> Result { if self.state_lag.is_some() || (first + tokens) as u64 > self.next_position { return Err(Error::InvalidPosition); @@ -248,7 +249,7 @@ impl<'driver> QwenSession<'driver> { let mut out: [Option; STATE_CAPACITY] = std::array::from_fn(|_| None); for slot in 0..48 { match (&layers[slot], self.qsa_layers[slot]) { - (Some(layer), true) => out[slot] = Some(layer.export_span(first, tokens)?), + (Some(layer), true) => out[slot] = Some(layer.export_span(first, tokens, mode)?), (None, false) => {} _ => return Err(Error::IdentityMismatch), } diff --git a/crates/engine-qwen35-cuda/src/settings/memory.rs b/crates/engine-qwen35-cuda/src/settings/memory.rs index 2c6c3853..524c05a5 100644 --- a/crates/engine-qwen35-cuda/src/settings/memory.rs +++ b/crates/engine-qwen35-cuda/src/settings/memory.rs @@ -15,6 +15,9 @@ pub(crate) struct MemorySettings { pub(crate) span_cache: bool, /// `LELEKA_REFILL_DEFER` is `on` or `1` (EXPERIMENTAL, off by default). pub(crate) refill_defer: bool, + /// `LELEKA_REFILL_BATCH` is `on` or `1` (EXPERIMENTAL, off by default): the lent-slot refill hands its copies to + /// `cuMemcpyBatchAsync_v2` in calls of a few hundred instead of one `cuMemcpyHtoDAsync_v2` each. + pub(crate) refill_batch: bool, /// `LELEKA_SERVE_SWAP_WAIT`: on unless `off` or `0`. pub(crate) swap_wait: bool, /// `LELEKA_PCIE_LOCKED_ONLY` is `on` or `1`. @@ -69,6 +72,7 @@ impl MemorySettings { route_tail_skip_max_cached: trimmed_number::(env, "LELEKA_ROUTE_TAIL_SKIP_MAX_CACHED").unwrap_or(90.0), span_cache: on_unless_off(env, "LELEKA_SPAN_CACHE"), refill_defer: one_of(env, "LELEKA_REFILL_DEFER", &["on", "1"]), + refill_batch: one_of(env, "LELEKA_REFILL_BATCH", &["on", "1"]), swap_wait: on_unless_off(env, "LELEKA_SERVE_SWAP_WAIT"), pcie_locked_only: one_of(env, "LELEKA_PCIE_LOCKED_ONLY", &["on", "1"]), pcie_auto_lag: equals(env, "LELEKA_PCIE_AUTO", "lag"), diff --git a/crates/engine-qwen35-cuda/src/settings/memory_tests.rs b/crates/engine-qwen35-cuda/src/settings/memory_tests.rs index cfe74d0c..4f00d787 100644 --- a/crates/engine-qwen35-cuda/src/settings/memory_tests.rs +++ b/crates/engine-qwen35-cuda/src/settings/memory_tests.rs @@ -21,9 +21,10 @@ fn span_cache_and_swap_wait_are_on_unless_off_or_zero() { } #[test] -fn refill_defer_and_locked_only_are_on_or_one() { +fn refill_defer_batch_and_locked_only_are_on_or_one() { let spellings = [("on", true), ("1", true), ("off", false), ("0", false), ("yes", false), ("", false)]; rows("LELEKA_REFILL_DEFER", |m| m.refill_defer, false, &spellings); + rows("LELEKA_REFILL_BATCH", |m| m.refill_batch, false, &spellings); rows("LELEKA_PCIE_LOCKED_ONLY", |m| m.pcie_locked_only, false, &spellings); rows("LELEKA_ADAPT_TIE_SPREAD", |m| m.adapt_tie_spread, false, &spellings); } diff --git a/crates/engine-qwen35-cuda/src/settings/serve.rs b/crates/engine-qwen35-cuda/src/settings/serve.rs index 13be3d26..3f6ecc11 100644 --- a/crates/engine-qwen35-cuda/src/settings/serve.rs +++ b/crates/engine-qwen35-cuda/src/settings/serve.rs @@ -2,6 +2,7 @@ //! experimental switches the Original serve load honours. use super::parse::{equals, number, one_of, positive_gib}; use super::source::EnvSource; +use leleka_cuda_driver::ring_prefetch::RingPrefetchPolicy; use std::ffi::OsString; /// What the operator chose for one serve process. @@ -25,9 +26,38 @@ pub(crate) struct ServeSettings { pub(crate) cpu_workers: Option, /// `LELEKA_CPU_POOL_PLAN=on`: the CPU pool size comes from the host plan when the worker count is not set. pub(crate) cpu_pool_plan: bool, - /// `LELEKA_PREFILL_LOAN_TIERS` is `1` or `on`: the prefill loan ladder (OFF by default until the identity - /// gate and the paired A/B of docs/prefill-throughput.md have run). + /// `LELEKA_PREFILL_LOAN_TIERS` is `1` or `on`: the prefill loan ladder (off in the engine; the shipped + /// profiles set it: identity PASS and the paired A/B n=10 of docs/prefill-throughput.md). pub(crate) prefill_loan_tiers: bool, + /// `LELEKA_DRAFT_CHAIN_PIPELINE` is `1` or `on`: the MTP chain steps of a greedy draft run back to back, one + /// stream drain for the run (identity and paired A/B of docs/experiments/decode-tail-5090.md). + pub(crate) draft_chain_pipeline: bool, + /// `LELEKA_PREFIX_PARK_FAST` is `1` or `on`: the prefix-cache export of the K/V cells and index rows drains the + /// context once per park and writes into unzeroed buffers (the same bytes; identity and paired A/B of + /// docs/experiments/step-ledger.md row B3). + pub(crate) prefix_park_fast: bool, + /// `LELEKA_PREFIX_PARK_ASYNC` is `1` or `on`: the checkpoint at the end of a decode (`--prefix-cache-tail reply`) + /// is taken after the response was published, not before (row B3). + pub(crate) prefix_park_async: bool, + /// `LELEKA_DECODE_GRAPH_REUSE` is `1` or `on`: keep the assembled decode graphs for the next request when nothing + /// they bake in changed (OFF by default; docs/experiments/decode-graph-reuse.md). The stack refuses the reuse + /// (and records every request, as without the switch) until the verify bank has its re-arm API. + pub(crate) decode_graph_reuse: bool, + /// `LELEKA_DRAFT_CHECK_MERGE` is `1` or `on`: the adjacent finite and Q8_1 scale guards of the MTP draft step are + /// launched as one batched guard (the same checks of the same buffers, fewer launches; the ledger row O8). + pub(crate) draft_check_merge: bool, + /// `LELEKA_PREFILL_GDN_TC` is `1` or `on` (EXPERIMENTAL, LOSSY, off by default): the prompt GDN recurrence runs + /// as a chunked scan on the tensor cores (f16x3 products; not bitwise equal to the sequential kernel). Decided + /// by the first-token KL / logprob gates of docs/quality-gate.md, never by an identity probe. + pub(crate) prefill_gdn_tc: bool, + /// `LELEKA_PREFILL_RING_PREFETCH` (EXPERIMENTAL, off by default; docs/experiments/ring-prefetch.md): `1` or `on` + /// copies the most often recently missed experts of the next layer (top 150) into its copy ring's stage slots + /// before its router runs; a number `2..=512` sets that top K. `LELEKA_PREFILL_RING_PREFETCH_WINDOW` + /// (`1..=64`, default 8) is the number of recent chunks whose misses are counted. Bitwise neutral by + /// construction; the R-hash identity probe and the paired A/B are still owed. `LELEKA_PREFILL_RING_PREFETCH_DETACH` + /// (`1` / `on`, EXPERIMENTAL, off) also detaches the mixer's drains from the pending copies (the chunk stream's + /// background-stream mode); off, the drains stay context-wide and wait for them. + pub(crate) prefill_ring_prefetch: Option, } impl ServeSettings { @@ -43,6 +73,26 @@ impl ServeSettings { cpu_workers: number::(env, "LELEKA_ORIGINAL_SERVE_CPU_WORKERS").filter(|n| (1..=64).contains(n)), cpu_pool_plan: equals(env, "LELEKA_CPU_POOL_PLAN", "on"), prefill_loan_tiers: one_of(env, "LELEKA_PREFILL_LOAN_TIERS", &["1", "on"]), + draft_chain_pipeline: one_of(env, "LELEKA_DRAFT_CHAIN_PIPELINE", &["1", "on"]), + prefix_park_fast: one_of(env, "LELEKA_PREFIX_PARK_FAST", &["1", "on"]), + prefix_park_async: one_of(env, "LELEKA_PREFIX_PARK_ASYNC", &["1", "on"]), + decode_graph_reuse: one_of(env, "LELEKA_DECODE_GRAPH_REUSE", &["1", "on"]), + draft_check_merge: one_of(env, "LELEKA_DRAFT_CHECK_MERGE", &["1", "on"]), + prefill_gdn_tc: one_of(env, "LELEKA_PREFILL_GDN_TC", &["1", "on"]), + prefill_ring_prefetch: ring_prefetch(env), } } } + +/// `LELEKA_PREFILL_RING_PREFETCH`: `1` / `on` (the default top K) or a top K in `2..=512`; anything else is off. +pub(super) fn ring_prefetch(env: &impl EnvSource) -> Option { + let top_k = match env.get("LELEKA_PREFILL_RING_PREFETCH")?.as_str() { + "1" | "on" => RingPrefetchPolicy::DEFAULT_TOP_K, + value => value.parse::().ok().filter(|k| (2..=512).contains(k))?, + }; + let window = number::(env, "LELEKA_PREFILL_RING_PREFETCH_WINDOW") + .filter(|n| (1..=RingPrefetchPolicy::MAX_WINDOW).contains(n)) + .unwrap_or(RingPrefetchPolicy::DEFAULT_WINDOW); + let detach = one_of(env, "LELEKA_PREFILL_RING_PREFETCH_DETACH", &["1", "on"]); + Some(RingPrefetchPolicy::new(top_k, window).with_detached_drains(detach)) +} diff --git a/crates/engine-qwen35-cuda/src/settings/serve_tests.rs b/crates/engine-qwen35-cuda/src/settings/serve_tests.rs index 23b2bc12..3abac8b2 100644 --- a/crates/engine-qwen35-cuda/src/settings/serve_tests.rs +++ b/crates/engine-qwen35-cuda/src/settings/serve_tests.rs @@ -88,3 +88,78 @@ fn pool_plan_is_exactly_on_and_loan_tiers_are_one_or_on() { assert_eq!(serve(&[("LELEKA_PREFILL_LOAN_TIERS", value)]).prefill_loan_tiers, want, "tiers {value:?}"); } } + +#[test] +fn the_draft_chain_pipeline_is_one_or_on_and_off_by_default() { + assert!(!serve(&[]).draft_chain_pipeline); + for (value, want) in [("1", true), ("on", true), ("0", false), ("off", false), ("yes", false), ("", false)] { + assert_eq!(serve(&[("LELEKA_DRAFT_CHAIN_PIPELINE", value)]).draft_chain_pipeline, want, "pipeline {value:?}"); + } +} + +#[test] +fn the_prefix_park_switches_are_one_or_on_and_off_by_default() { + let defaults = serve(&[]); + assert!(!defaults.prefix_park_fast && !defaults.prefix_park_async); + for (value, want) in [("1", true), ("on", true), ("0", false), ("off", false), ("yes", false), ("", false)] { + assert_eq!(serve(&[("LELEKA_PREFIX_PARK_FAST", value)]).prefix_park_fast, want, "fast {value:?}"); + assert_eq!(serve(&[("LELEKA_PREFIX_PARK_ASYNC", value)]).prefix_park_async, want, "async {value:?}"); + } + let fast_only = serve(&[("LELEKA_PREFIX_PARK_FAST", "1")]); + assert!(fast_only.prefix_park_fast && !fast_only.prefix_park_async, "the two switches are independent"); +} + +#[test] +fn the_decode_graph_reuse_is_one_or_on_and_off_by_default() { + assert!(!serve(&[]).decode_graph_reuse); + for (value, want) in [("1", true), ("on", true), ("0", false), ("off", false), ("yes", false), ("", false)] { + assert_eq!(serve(&[("LELEKA_DECODE_GRAPH_REUSE", value)]).decode_graph_reuse, want, "reuse {value:?}"); + } +} + +#[test] +fn the_draft_check_merge_is_one_or_on_and_off_by_default() { + assert!(!serve(&[]).draft_check_merge); + for (value, want) in [("1", true), ("on", true), ("0", false), ("off", false), ("yes", false), ("", false)] { + assert_eq!(serve(&[("LELEKA_DRAFT_CHECK_MERGE", value)]).draft_check_merge, want, "merge {value:?}"); + } +} + +#[test] +fn the_ring_prefetch_is_one_on_or_a_top_k_and_off_by_default() { + use leleka_cuda_driver::ring_prefetch::RingPrefetchPolicy as P; + let key = "LELEKA_PREFILL_RING_PREFETCH"; + assert_eq!(serve(&[]).prefill_ring_prefetch, None); + let default = Some(P::new(P::DEFAULT_TOP_K, P::DEFAULT_WINDOW)); + #[rustfmt::skip] + let rows = [ + ("1", default), ("on", default), ("200", Some(P::new(200, 8))), ("2", Some(P::new(2, 8))), + ("512", Some(P::new(512, 8))), ("0", None), ("513", None), ("off", None), ("yes", None), (" 1", None), + ("", None), + ]; + for (value, want) in rows { + assert_eq!(serve(&[(key, value)]).prefill_ring_prefetch, want, "{value:?}"); + } + let window = |w: &str| serve(&[(key, "on"), ("LELEKA_PREFILL_RING_PREFETCH_WINDOW", w)]).prefill_ring_prefetch; + assert_eq!(window("16"), Some(P::new(P::DEFAULT_TOP_K, 16))); + for invalid in ["0", "65", "x", ""] { + assert_eq!(window(invalid), default, "window {invalid:?} keeps the default"); + } + assert_eq!(serve(&[("LELEKA_PREFILL_RING_PREFETCH_WINDOW", "4")]).prefill_ring_prefetch, None, "no switch: off"); + let detach = |v: &str| serve(&[(key, "on"), ("LELEKA_PREFILL_RING_PREFETCH_DETACH", v)]).prefill_ring_prefetch; + assert_eq!(detach("1"), default.map(|p| p.with_detached_drains(true))); + assert_eq!(detach("on"), default.map(|p| p.with_detached_drains(true))); + for off in ["0", "yes", ""] { + assert_eq!(detach(off), default, "detach {off:?} stays off"); + } +} + +#[test] +fn the_prefill_gdn_tensor_core_scan_is_one_or_on_and_off_by_default() { + assert!(!serve(&[]).prefill_gdn_tc); + for (value, want) in + [("1", true), ("on", true), ("0", false), ("off", false), ("yes", false), ("true", false), ("", false)] + { + assert_eq!(serve(&[("LELEKA_PREFILL_GDN_TC", value)]).prefill_gdn_tc, want, "gdn tc {value:?}"); + } +} diff --git a/deploy/rust-runtime/profiles/rtx5090-32g-file.json b/deploy/rust-runtime/profiles/rtx5090-32g-file.json index 63341252..ce41a750 100644 --- a/deploy/rust-runtime/profiles/rtx5090-32g-file.json +++ b/deploy/rust-runtime/profiles/rtx5090-32g-file.json @@ -13,6 +13,6 @@ "min_vram_total_mib": 30000, "min_ram_total_bytes": 68719476736, "min_ram_available_bytes": 62000000000, - "engine_env": {"LELEKA_ORIGINAL_SERVE_EXPERT_PER_LAYER": "yes", "LELEKA_CHAIN": "all", "LELEKA_ORIGINAL_SERVE_SEED": "off", "LELEKA_SM120_ATTN_DAILY_MTP": "1", "LELEKA_SM120_ATTN_DAILY": "1", "LELEKA_SM120_GU_SWIGLU": "1", "LELEKA_SM120_SIDE_MIXER": "1", "LELEKA_SM120_SIDE_QSA": "1", "LELEKA_SM120_SIDE_SHARED": "1", "LELEKA_SM120_FUSED_QSA_PRELUDE": "1", "LELEKA_DRAFT_FUSED_COMMIT": "1"}, + "engine_env": {"LELEKA_PREFILL_LOAN_TIERS": "1", "LELEKA_DRAFT_CHECK_MERGE": "1", "LELEKA_PREFIX_PARK_FAST": "1", "LELEKA_DECODE_GRAPH_REUSE": "1", "STRATA_PREFILL_STREAM_MIN": "1536", "LELEKA_ORIGINAL_SERVE_EXPERT_PER_LAYER": "yes", "LELEKA_CHAIN": "all", "LELEKA_ORIGINAL_SERVE_SEED": "off", "LELEKA_SM120_ATTN_DAILY_MTP": "1", "LELEKA_SM120_ATTN_DAILY": "1", "LELEKA_SM120_GU_SWIGLU": "1", "LELEKA_SM120_SIDE_MIXER": "1", "LELEKA_SM120_SIDE_QSA": "1", "LELEKA_SM120_SIDE_SHARED": "1", "LELEKA_SM120_FUSED_QSA_PRELUDE": "1", "LELEKA_DRAFT_FUSED_COMMIT": "1"}, "memory": {"prefix_cache_mib": "6144", "prefix_cache_tail": "reply", "prefix_cache_block": 8192, "soft_floor_mib": 4096, "hard_floor_mib": 2048, "reserve_mib": 2048, "lock": "off", "heal": false} } diff --git a/deploy/rust-runtime/profiles/rtx5090-32g-gguf-ple.json b/deploy/rust-runtime/profiles/rtx5090-32g-gguf-ple.json index 44333144..cd0bda13 100644 --- a/deploy/rust-runtime/profiles/rtx5090-32g-gguf-ple.json +++ b/deploy/rust-runtime/profiles/rtx5090-32g-gguf-ple.json @@ -13,6 +13,6 @@ "min_vram_total_mib": 30000, "min_ram_total_bytes": 68719476736, "min_ram_available_bytes": 62000000000, - "engine_env": {"LELEKA_ORIGINAL_SERVE_EXPERT_PER_LAYER": "yes", "LELEKA_CHAIN": "all", "LELEKA_ORIGINAL_SERVE_SEED": "off", "LELEKA_SM120_ATTN_DAILY_MTP": "1", "LELEKA_SM120_ATTN_DAILY": "1", "LELEKA_SM120_GU_SWIGLU": "1", "LELEKA_SM120_SIDE_MIXER": "1", "LELEKA_SM120_SIDE_QSA": "1", "LELEKA_SM120_SIDE_SHARED": "1", "LELEKA_SM120_FUSED_QSA_PRELUDE": "1", "LELEKA_DRAFT_FUSED_COMMIT": "1", "LELEKA_PLE_DIRECT": "0", "LELEKA_ORIGINAL_SERVE_GGUF_PLE": "1"}, + "engine_env": {"LELEKA_PREFILL_LOAN_TIERS": "1", "LELEKA_DRAFT_CHECK_MERGE": "1", "LELEKA_PREFIX_PARK_FAST": "1", "LELEKA_DECODE_GRAPH_REUSE": "1", "STRATA_PREFILL_STREAM_MIN": "1536", "LELEKA_ORIGINAL_SERVE_EXPERT_PER_LAYER": "yes", "LELEKA_CHAIN": "all", "LELEKA_ORIGINAL_SERVE_SEED": "off", "LELEKA_SM120_ATTN_DAILY_MTP": "1", "LELEKA_SM120_ATTN_DAILY": "1", "LELEKA_SM120_GU_SWIGLU": "1", "LELEKA_SM120_SIDE_MIXER": "1", "LELEKA_SM120_SIDE_QSA": "1", "LELEKA_SM120_SIDE_SHARED": "1", "LELEKA_PLE_DIRECT": "0", "LELEKA_ORIGINAL_SERVE_GGUF_PLE": "1", "LELEKA_SM120_FUSED_QSA_PRELUDE": "1", "LELEKA_DRAFT_FUSED_COMMIT": "1"}, "memory": {"prefix_cache_mib": "6144", "prefix_cache_tail": "reply", "prefix_cache_block": 8192, "soft_floor_mib": 4096, "hard_floor_mib": 2048, "reserve_mib": 2048, "lock": "off", "heal": false} } diff --git a/deploy/rust-runtime/profiles/rtx5090-32g.json b/deploy/rust-runtime/profiles/rtx5090-32g.json index 8403060e..aa492647 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). Single copy of every model byte in host RAM: the 50 GB routed-expert bank is the one page-locked RAM copy (from GGUF shard 0), and of the 55 GB level-2 KAR archive only the 16.0 GB the serve path reads (the PLE rows, 2 extents) is copied once into a sealed sparse memfd (memfd_extents ple_only: holes elsewhere, verified against the pinned digest of the extents), read O_DIRECT so no page-cache copy remains. 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 6144 MiB (explicit cap: what `auto` resolves to on this host, 5.7-6.1 GiB; unlike `auto` it cannot grow when RAM is freed) with request-end checkpoints (reply), chain kernels): no speed claim is made in this text (the paired 245k series against vanilla Strata is docs/experiments/baseline-pair-5090.md). 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). Main attention and gate/up SwiGLU sm_120 kernels on (engine_env LELEKA_SM120_ATTN_DAILY=1, LELEKA_SM120_GU_SWIGLU=1: bitwise identical on the teacher-forced gate, decode +1.85 % paired, docs/experiments/codex-compare-speed-gap.md). GDN gates and gate projection on two side streams of the verify graph (engine_env LELEKA_SM120_SIDE_MIXER=1: identical top-16 logprob rows and draft trace on the teacher-forced gate, decode +1.39 % paired, CI +0.46..+2.32 %, docs/experiments/step-ledger.md V3a). QSA indexer/query chains (LELEKA_SM120_SIDE_QSA=1, mixer phase of a QSA layer -14.8 us) and the shared expert (LELEKA_SM120_SIDE_SHARED=1, doorbell to first expert 27.6 -> 10.9 us) on side streams too: identical rows and draft trace, section deltas in step-ledger.md V3b/V4a. QSA layer prelude fused (LELEKA_SM120_FUSED_QSA_PRELUDE=1: three launches per QSA layer to two, identical top-16 logprob rows 2057/2057 and draft trace 1036/1036 on the teacher-forced gate, mixer phase 0.6-2.8 us per layer by window rows, docs/experiments/verify-qsa-fused-prelude.md). Not a formally quality-gated profile.", + "description": "RTX 5090 class server (sm_120, 32 GB VRAM, >= 100 GiB RAM). Single copy of every model byte in host RAM: the 50 GB routed-expert bank is the one page-locked RAM copy (from GGUF shard 0), and of the 55 GB level-2 KAR archive only the 16.0 GB the serve path reads (the PLE rows, 2 extents) is copied once into a sealed sparse memfd (memfd_extents ple_only: holes elsewhere, verified against the pinned digest of the extents), read O_DIRECT so no page-cache copy remains. 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 6144 MiB (explicit cap: what `auto` resolves to on this host, 5.7-6.1 GiB; unlike `auto` it cannot grow when RAM is freed) with request-end checkpoints (reply), chain kernels): no speed claim is made in this text (the paired 245k series against vanilla Strata is docs/experiments/baseline-pair-5090.md). 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). Main attention and gate/up SwiGLU sm_120 kernels on (engine_env LELEKA_SM120_ATTN_DAILY=1, LELEKA_SM120_GU_SWIGLU=1: bitwise identical on the teacher-forced gate, decode +1.85 % paired, docs/experiments/codex-compare-speed-gap.md). GDN gates and gate projection on two side streams of the verify graph (engine_env LELEKA_SM120_SIDE_MIXER=1: identical top-16 logprob rows and draft trace on the teacher-forced gate, decode +1.39 % paired, CI +0.46..+2.32 %, docs/experiments/step-ledger.md V3a). QSA indexer/query chains (LELEKA_SM120_SIDE_QSA=1, mixer phase of a QSA layer -14.8 us) and the shared expert (LELEKA_SM120_SIDE_SHARED=1, doorbell to first expert 27.6 -> 10.9 us) on side streams too: identical rows and draft trace, section deltas in step-ledger.md V3b/V4a. 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, @@ -14,6 +14,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", "LELEKA_SM120_ATTN_DAILY_MTP": "1", "LELEKA_SM120_ATTN_DAILY": "1", "LELEKA_SM120_GU_SWIGLU": "1", "LELEKA_SM120_SIDE_MIXER": "1", "LELEKA_SM120_SIDE_QSA": "1", "LELEKA_SM120_SIDE_SHARED": "1", "LELEKA_SM120_FUSED_QSA_PRELUDE": "1", "LELEKA_DRAFT_FUSED_COMMIT": "1"}, + "engine_env": {"LELEKA_PREFILL_LOAN_TIERS": "1", "LELEKA_DRAFT_CHECK_MERGE": "1", "LELEKA_PREFIX_PARK_FAST": "1", "LELEKA_DECODE_GRAPH_REUSE": "1", "STRATA_PREFILL_STREAM_MIN": "1536", "LELEKA_ORIGINAL_SERVE_EXPERT_PER_LAYER": "yes", "LELEKA_CHAIN": "all", "LELEKA_ORIGINAL_SERVE_SEED": "off", "LELEKA_SM120_ATTN_DAILY_MTP": "1", "LELEKA_SM120_ATTN_DAILY": "1", "LELEKA_SM120_GU_SWIGLU": "1", "LELEKA_SM120_SIDE_MIXER": "1", "LELEKA_SM120_SIDE_QSA": "1", "LELEKA_SM120_SIDE_SHARED": "1", "LELEKA_SM120_FUSED_QSA_PRELUDE": "1", "LELEKA_DRAFT_FUSED_COMMIT": "1"}, "memory": {"prefix_cache_mib": "6144", "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/design/single-copy-ram-2026-11-09.md b/docs/design/single-copy-ram-2026-11-09.md new file mode 100644 index 00000000..223d4ddc --- /dev/null +++ b/docs/design/single-copy-ram-2026-11-09.md @@ -0,0 +1,81 @@ +# One copy of the model in host RAM (design, 2026-11-09, branch `claude/single-copy-ram`) + +Base `claude/hexagonal-finish-14ee3a` (b686f6ab7). Evidence labels as in `memory-single-copy-and-elastic-state.md`: **M** measured (record named), **S** read from source, **E** estimate, **U** not verified. +No GPU job and no server command were run for this page; the server numbers are the owner's 2026-11-09 reading. Nothing here is a performance claim. + +## 1. Finding + +The product already holds one copy. The lab does not. Everything the single-copy work built is merged (`claude/sparse-memfd`, `claude/kar-file-source`, `claude/single-copy`, `-base`, `-win` are all ancestors of `main` +and of the base; `rtx5090-32g` has `memfd_extents: ple_only`, the extents digest is pinned, the checklist rows Q12/A6 record bitwise identity and MemAvailable 8.5 -> 45.1 GiB). What the owner measured on 2026-11-09 is the +**lab holder's full 55.3 GB memfd**, not the sparse memfd of `leleka up`: + +| measured 2026-11-09 (M, owner) | GiB (from GB) | explained by (S/E) | +|---|---:|---| +| Shmem 58.6 GB | 54.6 | full memfd 51.50 + pinned K/V 3.09 + head/MTP pins 0.57 = 55.2 (a sparse memfd would give 14.90 + 3.09 + 0.57 = 18.6, which is the A6 measurement) | +| engine touches 3.9 GB of the memfd | 3.6 | PLE rows only: ~1M distinct rows after ~250k tokens, one 4 KiB page each (`design` A.4) | +| RssAnon 55.1 GB (one region 46.54 GiB + heap 0.95 GiB) | 51.3 | resident expert bank 46.84 GiB (GGUF shard 0) + dense host copy 1.37 + arena/pool/rings ~2 | +| MemAvailable 7-8 GB, Free ~1 GB, page cache ~2.6 GB | | 121 - 54.6 - 51.3 - 2.6 - ~4 (kernel, gateway, Codex, node) | + +Why the holder: `scripts/e2e/decode/single-copy-holder.sh` ran `leleka seal-exec --file KAR --expect-bytes 55295529472 -- python3 single-copy-holder.py` **without `--sparse-ple`**; `single-copy-window.sh` and +`cmp_window.sh` restart the holder with that script, and the older `run_holder2.sh` / `kar_holder2.py` (outside the repository) copy the whole file too. Every holder job (`spd_ab_job.sh`, `cmp_codex_job.sh`, the Codex replays) +runs `leleka up --foreground --kar-fd FD`; the supervisor then pins the extents digest (profile `ple_only`), the engine hashes only the extents inside the full copy, and starts without complaint. The run is bitwise correct and +wastes 36.6 GiB (S: `supervisor/archive.rs` `open_inherited_archive`, `engine .../inherited_kar_archive.rs` `open_sparse`). U until `holder3.out` (`holder3 ready fd=.. bytes=.. allocated=..`) or +`scripts/e2e/decode/ram-inventory.sh` (memfd block: apparent vs allocated) is read on the server: both are read-only. + +## 2. Where the model bytes live (S) + +| copy | built by | file / function | class | GiB | read by | +|---|---|---|---|---:|---| +| resident expert bank (GGUF shard 0, 144 tensors, native IQ3_S/IQ4_NL blocks) | the engine at stack open | `model-format/src/qwen4exp_expert_source_bank/qwen4_exp_artifact.rs` `load_resident_expert_source` -> `load_banks` -> `gguf_resident/verified_gguf_file.rs` `load_resident_tensor` (heap or huge-page buffer; `bulk_read::read_into`, O_DIRECT by default) | anon, page-locked later | 46.84 | VRAM tier fill, PCIe staging, CPU leg, prefill ring | +| sealed KAR memfd, full | the holder (`seal-exec` without `--sparse-ple`, or `kar_holder2.py`) | `deploy/src/sealed/linux.rs` `seal_file_report` (parallel O_DIRECT fill, `sealed/linux/copy.rs`) | shmem | 51.50 | PLE rows only (3.6 GiB touched) | +| sealed KAR memfd, sparse (product) | `leleka up/run` supervisor | `supervisor/archive.rs` `seal_archive` -> `sealed.rs` `seal_extents_report`; extents from `sealed/exec_arguments.rs` `archive_serve_extents` | shmem | 14.90 | PLE rows (`read_rows_chunk`) | +| VRAM expert tier | engine | `qwen_forward/original_serve_residency/open_tier.rs`, copies bank bytes by profile rank (11,280 slots, 1.95 MiB each, 21.5 GiB) | device | | the MMQ kernels decode a block in registers per multiply; no decoded copy is stored (S) | +| page cache of the shards | the load | `memory_governor/page_cache.rs` `drop_file_cache` (twice: after the bank, after the stack open) | file | ~2.6 (M) | nothing | + +So in the product the bytes are not duplicated: the bank holds the experts, the memfd holds PLE rows (a different tensor family, KAR level 2), and the 1223 other records of the archive (never read) are holes. +The VRAM tier is already "compressed, decoded only where multiplied" in the Original's own format (GGUF quant blocks). What the owner asks beyond that, a KAR-coded bank (35.16 GiB instead of 46.84), is a different +and lossy encoding (relative L2 0.33 at level 2, 0.165 at level 3) and is section 4, step 6. + +## 3. Candidates + +| # | candidate | smallest change | freed (host) | quality / identity | risk | status | +|---|---|---|---:|---|---|---| +| C1 | holder seals sparse (`--sparse-ple`), supervisor refuses a `ple_only` profile on a full memfd | 1 script line + `sealed/single_copy.rs` (40 lines) + 12 lines in `supervisor/archive.rs` | **36.6 GiB** shmem (E; A6 measured 55.2 -> 18.6 GiB Shmem) | bitwise: same rows, same pages (Q12: 2057/2057 top-16 rows, 1036/1036 draft lines) | the live holder must be restarted; old jobs with profile `full` need `HOLDER_MEMFD=full` | **this commit** | +| C2 | bank built from the memfd / KAR | new decoder, GGUF-layout kernels, F32 scratch (18.75 MiB per expert) | 11.7 GiB host, +3.7k VRAM slots (E: 21.5 GiB / 1.465 MiB) | lossy (L2); needs the 245k quality gate | high; refused today with the optimized MMQ owners | step 6, experimental | +| C3 | PLE from the file, O_DIRECT, bounded row cache (`kar_source: file`) | exists (`rtx5090-32g-file`) | 14.9 -> cache size (E: ~4 GiB touched at 256k) | bitwise (per-read identity check) | decode 82.7 vs 153-154 tok/s measured with the page-cache form (A6); O_DIRECT cache never measured; model volume is unstable | step 5, owner approval | +| C4 | bank as `mapped` (B1/B2) | exists | ~0 at 256k (whole bank touched per prefill chunk) | bitwise | prefill/decode loss (job 917) | rejected | +| C5 | drop the dense host copy after upload (T12) | engine | 1.37 GiB | bitwise | low | step 3 | +| C6 | park on overwrite (T6/T7) | store | 3.2 GiB at 245k | bitwise restore | medium | step 4 | + +Files of the speed session (`original_serve_residency*`, `cpu_expert_miss`, `original_verify_gpu_plan*`, `original_expert_stager*/cache*`) are not touched by C1. C2, C5 and C3's engine part would touch +`original_serve_residency/open_tier.rs` only to read the compressed form; that is for the owner of that session. + +## 4. Ordered steps and what each measures + +Common record (charter): server `rnr5090`, RTX 5090, driver 595.99, CUDA 13.2, binary sha256, model digests (shards `4c1eb2ce`, `316b46f3`, archive `536d612c`), cache state at start, token counts and distributions. +Series every 5 s by `scripts/e2e/sample_env.sh` + `scripts/e2e/decode/ram-inventory.sh` at READY, at each turn end and every 60 s: RssAnon, RssShmem, VmLck, Shmem, MemAvailable, Free, Cached, +`/proc/pressure/memory` (some/full total), `/proc/vmstat` `allocstall_*`, `pgscan_direct`, `compact_stall`, swap. Report deltas over the run, not boot totals (the 2026-11-09 totals are since boot). + +| step | change | measurement before -> after | gate | +|---|---|---|---| +| 0 | read-only evidence on the server (no restart) | `holder3.out` allocated bytes; `ram-inventory.sh before`; PSI and vmstat counters | memfd allocated ~55.3 GB confirms section 1 | +| 1 | this commit; then restart the holder with `single-copy-holder.sh` (hex-finish owns the queue) | Shmem 58.6 -> ~20 GB; MemAvailable 7-8 -> ~44 GiB (E); RssAnon unchanged; PSI memory some and allocstall per hour -> ~0 (U, the hypothesis of the host stalls); engine log `sealed memfd` line shows 14.9 GiB | identity: replay `out_sha` of every request equal (`scripts/e2e/codex/speed/replay_hash.py`), top-16 logprob rows and draft trace equal on the replay gate; **paired A/B, n >= 10 blocks**, arms F (`HOLDER_MEMFD=full` + `LELEKA_ALLOW_FULL_MEMFD=1`) and S (sparse), interleaved by holder restart, same recorded cells (`VANL/nestng-crm-r2`, `VANL/ttt-r3`) through `spd_ab_job.sh`, `ab_report.py RUN F S --skip 3`; tok/s within run noise (A6: +0.58 %, se 0.91) and host-stall spans (prefill input) not longer | +| 2 | retire the Python holders: `run_holder2.sh` and `kar_holder2.py` (buffered 16 MiB reads leave a second 50 GB copy in the page cache) replaced by `single-copy-holder.sh` everywhere; `baseline-reboot-series.sh` and `kar-file-ab.sh` still name them | `fincore` of the KAR and shards (`ram-inventory.sh` pagecache block) after the holder is READY: ~0 | page cache of model files < 1 GiB | +| 3 | T12: free the dense host copy after upload | RssAnon -1.4 GiB | ids identical, replay `out_sha` equal | +| 4 | T6/T7: park on overwrite | anon -3 GiB at 245k; switch latency +0.4 s at most | restored state bit-equal | +| 5 | C3: PLE from file, O_DIRECT, bounded cache | Shmem -10 GiB (E) | `window.ple`, tok/s, TTFT within noise on the 245k replay, else keep step 1 | +| 6 | C2: KAR-coded expert bank and slots (experimental, never default) | host -11.7 GiB, slots +33 % (E) | the Original's own quality envelope at 245k (separate gate, charter), then paired A/B n >= 10 | + +## 5. What this commit does (step 1, code) + +* `crates/deploy/src/sealed/single_copy.rs`: `single_copy_verdict(form, allocated_bytes, allow_full_copy)`. A `ple_only` profile accepts an inherited memfd that allocates at most the extents (16,000,348,672 B) + 1 GiB; + anything above is refused with the remedy. `LELEKA_ALLOW_FULL_MEMFD=1` is the explicit, logged override; `memfd_extents: full` profiles are unaffected. +* `sealed/linux.rs` `inherited_archive_allocated_bytes(fd)` (`st_blocks * 512`; a stub on non-Linux). +* `supervisor/archive.rs` `check_single_copy`, called from `open_inherited_archive` (the one path of `up --kar-fd` and `run --kar-fd`). +* `scripts/e2e/decode/single-copy-holder.sh`: `--sparse-ple` by default, `HOLDER_MEMFD=full` for the old form. +* Tests: verdict table, override, `st_blocks` of a real memfd (hole = 0, 4 MiB written = 4 MiB). U: the end-to-end run on the server with a real holder. + +## 6. Not verified + +The cause in section 1 is derived from the byte accounting and the scripts; it is not read from the server. The PSI/allocstall improvement is a hypothesis until step 1 is measured. The end state is +RAM = PLE 14.9 + bank 46.84 + K/V 3.09 + other ~4 = ~69 GiB of 121, not "compressed everywhere": that needs steps 5 and 6. diff --git a/docs/experiments/2026-10-28-s6-1-lossy-audit.md b/docs/experiments/2026-10-28-s6-1-lossy-audit.md index 3c4e13be..30dfe338 100644 --- a/docs/experiments/2026-10-28-s6-1-lossy-audit.md +++ b/docs/experiments/2026-10-28-s6-1-lossy-audit.md @@ -1,279 +1,279 @@ -# S6.1 Lossy-default audit of the shipped rtx5090-32g and rtx3080-16g profiles (STRA-250) - -Status: read-only audit, 2026-10-28. Leaf STRA-250 of STRA-245. Branch `claude/stra-250`, base `2457d81d` (the tip of `claude/merge-opt`; every path, line number -and count below was read in that tree, not in the main checkout). Nothing was run on a GPU and no model was loaded: every class is a reading of code, profile files and -recorded documents, with the path and line that carry it. Nothing in the engine, the profiles or `engine/strata` was changed. - -Vanilla defaults belong to STRA-247; this page carries one cross-reference section for them (section 6) and no measurement of vanilla. - -## 1. Classes and scope - -* `lossless`: the default moves bytes, caches, schedules or traces, or a recorded byte comparison shows the output equal; no arithmetic order changes. -* `lossy`: the default changes the output by design (a mode the code itself labels as changing the output). No such mode is ON by default in either shipped profile. -* `unknown-until-q_pair`: the default changes the order of arithmetic or the expert placement (rounding level) and the files read carry no q_pair result for the shipped value - on the shipped machine. The leaf that produces the result is named per row: STRA-267 (S2.5) for the 5090 profile on sm_120, STRA-293 (S3.9) for the laptop profile on sm_86. - The command is `python scripts/quality/q_pair.py LOG_A LOG_B` (exit 0 if every common forced row is identical). - An existing gate that is NOT a q_pair result (q_tail_gate over 30-70k tokens, a 612-row teacher-forced gate on short prompts) is quoted in the row and does not move it out of this class. - -Scope (bounded, round 5 of the STRA-245 tree): (a) every key of both profile files, sections 2 and 3; (b) the admitted sets of `serve_tuning.rs`, section 4; -(c) the `LELEKA_*` / `STRATA_*` names in `original_serve*.rs` (section 5) and in the prefill chunk path files (section 5b); (d) all other names listed by name, section 7. - -## 2. rtx5090-32g profile: one row per key (27 rows; classes: 19 lossless, 0 lossy, 8 unknown-until-q_pair) - -| row | key | shipped value | class | evidence | -| --- | --- | --- | --- | --- | -| K50-01 | `name` | rtx5090-32g | lossless | deploy/rust-runtime/profiles/rtx5090-32g.json:2; label only (crates/deploy/src/profile.rs:238) | -| K50-02 | `description` | prose | lossless | deploy/rust-runtime/profiles/rtx5090-32g.json:3; no engine effect (crates/deploy/src/profile.rs:239); it states `Not a formally quality-gated profile` | -| K50-03 | `select.sm_min` | 120 | lossless | deploy/rust-runtime/profiles/rtx5090-32g.json:4; selector only, `Profile::matches` (crates/deploy/src/profile.rs:226-233, 381-386) | -| K50-04 | `select.sm_max` | 130 | lossless | deploy/rust-runtime/profiles/rtx5090-32g.json:4; selector only (crates/deploy/src/profile.rs:226-233) | -| K50-05 | `select.vram_mib_min` | 30000 | lossless | deploy/rust-runtime/profiles/rtx5090-32g.json:4; selector only (crates/deploy/src/profile.rs:226-233) | -| K50-06 | `select.vram_mib_max` | 1000000 | lossless | deploy/rust-runtime/profiles/rtx5090-32g.json:4; selector only (crates/deploy/src/profile.rs:226-233) | -| K50-07 | `gpu_budget_bytes` | 32212254720 (30 GiB) | unknown-until-q_pair | deploy/rust-runtime/profiles/rtx5090-32g.json:5; `--gpu-budget` (crates/deploy/src/config.rs:176-179); sizes the VRAM expert tier, i.e. which experts compute on the GPU and which on the CPU pool; the tier changes placement only (docs/quality-gate.md section 8: P1-P6, 612 rows, d_top1 p99 0.176-0.235, flips 1.6-2.3 %, short prompts, 5090); no CPU-leg versus GPU-leg bit-identity record was found in the files read; STRA-267 (5090, sm_120); q_pair logs: none | -| K50-08 | `spec_min_p` | 0.0 | unknown-until-q_pair | deploy/rust-runtime/profiles/rtx5090-32g.json:6; `--spec-min-p` (crates/deploy/src/config.rs:218-220); ceiling of the adaptive draft floor, drafts only, verification untouched (docs/adaptive-spec.md:106-111, 122-124) but window shape changes batch rounding: adaptive identical to the fixed-4 pass in 16/30 requests, fixed-3 13/30, fixed-6 13/30, fixed-4 against its own repeats 15/20 (docs/adaptive-spec.md:106-111); STRA-267 (5090, sm_120); q_pair logs: none | -| K50-09 | `expert_profile` | data/expert-profile.bin | unknown-until-q_pair | deploy/rust-runtime/profiles/rtx5090-32g.json:7; starting VRAM placement (`LELEKA_ORIGINAL_SERVE_EXPERT_PROFILE` set by `plan.rs:270-279`; read at crates/leleka-runtime/src/qwen_forward/original_serve_residency.rs:224); placement class as K50-07; STRA-267 (5090, sm_120); q_pair logs: none | -| K50-10 | `context_tokens` | 262144 | lossless | deploy/rust-runtime/profiles/rtx5090-32g.json:8; `--context-tokens` (crates/deploy/src/config.rs:180-181), admitted 1..=262144 (crates/deploy/src/profile.rs:325-327); a ceiling, no arithmetic | -| K50-11 | `prefill_capacity` | 8192 | unknown-until-q_pair | deploy/rust-runtime/profiles/rtx5090-32g.json:9; `--original-prefill-capacity` (crates/deploy/src/config.rs:206-208), admitted set {256,512,1024,2048,3072,4096,6144,8192} (crates/deploy/src/profile.rs:44); chunk size changes the rounding order of the prompt path: 16,000 tokens answered identically at 2048, 4096, 6144 and differently at 8192 on one prompt (docs/prefill-throughput.md:52-57, open: rounding or defect); STRA-267 (5090, sm_120); q_pair logs: none | -| K50-12 | `kar_source` | memfd | lossless | deploy/rust-runtime/profiles/rtx5090-32g.json:10; where the pinned archive bytes live (crates/deploy/src/profile.rs:47-54; digest pinned crates/deploy/src/profile.rs:15-16); same bytes | -| K50-13 | `expert_source` | resident | lossless | deploy/rust-runtime/profiles/rtx5090-32g.json:11; where the routed-expert bytes live (crates/deploy/src/profile.rs:65-73); same bytes | -| K50-14 | `min_driver_major` | 595 | lossless | deploy/rust-runtime/profiles/rtx5090-32g.json:12; preflight gate only (crates/deploy/src/profile.rs:257) | -| K50-15 | `min_vram_total_mib` | 30000 | lossless | deploy/rust-runtime/profiles/rtx5090-32g.json:13; preflight gate only (crates/deploy/src/profile.rs:258) | -| K50-16 | `min_ram_total_bytes` | 107374182400 | lossless | deploy/rust-runtime/profiles/rtx5090-32g.json:14; preflight gate only (crates/deploy/src/profile.rs:263) | -| K50-17 | `min_ram_available_bytes` | 113000000000 | lossless | deploy/rust-runtime/profiles/rtx5090-32g.json:15; preflight gate only (crates/deploy/src/profile.rs:264) | -| K50-18 | `engine_env.LELEKA_ORIGINAL_SERVE_EXPERT_PER_LAYER` | yes | unknown-until-q_pair | deploy/rust-runtime/profiles/rtx5090-32g.json:16; per-layer slot sizing of the VRAM tier (crates/leleka-runtime/src/qwen_forward/original_serve_residency.rs:225-227); placement class as K50-07; STRA-267 (5090, sm_120); q_pair logs: none | -| K50-19 | `engine_env.LELEKA_CHAIN` | all | unknown-until-q_pair | deploy/rust-runtime/profiles/rtx5090-32g.json:16; groups glue, ab, gr, tiny, head, mtp (not qsa) (crates/cuda-driver/src/original_verify_window_chain.rs:62-87); NOT bit-identical at 30-70k context: 5,993 of 64,355 rows identical, d_top1 p99 0.327, max 4.31, argmax flips 697 (1.08 %), control for rounding noise p99 0.394 / flips 1.45 % (docs/chain-kernels.md:70-79); passes the q_tail_gate 1.25x rule only, 5090, 30-70k context, no 256k q_pair; FINDING F1; STRA-267 (5090, sm_120); q_pair logs: none | -| K50-20 | `memory.prefix_cache_mib` | auto | lossless | deploy/rust-runtime/profiles/rtx5090-32g.json:17; cache budget (crates/deploy/src/profile.rs:90-92, 166-168); a hit reproduces the full read bit for bit (docs/prefix-cache.md:34-36, job 922 equality, 14 requests); grid nodes exact by construction (docs/prefix-cache.md:169) | -| K50-21 | `memory.prefix_cache_tail` | reply | unknown-until-q_pair | deploy/rust-runtime/profiles/rtx5090-32g.json:17; request-end checkpoints at the end of the decode; the cells past the prompt are decode-produced, so the state is not what a prefill would produce (docs/prefix-cache.md:165-168); the same doc marks `reply` EXPERIMENTAL and not to be defaulted before the agreement gate (line 168) and also records it as the 5090 default (lines 190-198: d_top1 p99 0.401, flips 1.45 % against a control of p99 0.394 / 1.45 %, ~70k context, q_tail_gate); FINDING F2; STRA-267 (5090, sm_120); q_pair logs: none | -| K50-22 | `memory.prefix_cache_block` | 8192 | unknown-until-q_pair | deploy/rust-runtime/profiles/rtx5090-32g.json:17; tokens per prefix block and chunk-grid step, caps every chunk (crates/deploy/src/profile.rs:97-100, 172-176); grid nodes are exact by construction but the grid sets the chunk cut, same class as K50-11 (8192 differed on one prompt, docs/prefill-throughput.md:52-57); STRA-267 (5090, sm_120); q_pair logs: none | -| K50-23 | `memory.soft_floor_mib` | 4096 | lossless | deploy/rust-runtime/profiles/rtx5090-32g.json:17; memory governor: caches shed below it (crates/deploy/src/profile.rs:104-106, 194-196); sheds reuse, never values | -| K50-24 | `memory.hard_floor_mib` | 2048 | lossless | deploy/rust-runtime/profiles/rtx5090-32g.json:17; new requests refused with 503 below it (crates/deploy/src/profile.rs:107-109, 197-200) | -| K50-25 | `memory.reserve_mib` | 2048 | lossless | deploy/rust-runtime/profiles/rtx5090-32g.json:17; slack above the soft floor (crates/deploy/src/profile.rs:110-112, 201-204) | -| K50-26 | `memory.lock` | try | lossless | deploy/rust-runtime/profiles/rtx5090-32g.json:17; keeps the sealed memfd resident (crates/deploy/src/profile.rs:116-118, 209) | -| K50-27 | `memory.heal` | true | lossless | deploy/rust-runtime/profiles/rtx5090-32g.json:17; pulls swapped memfd pages back (crates/deploy/src/profile.rs:119-121, 213-216) | - -## 3. rtx3080-16g profile: one row per key (27 rows; classes: 22 lossless, 0 lossy, 5 unknown-until-q_pair) - -`engine_env` is `{}` in this file and contributes 0 keys (the AC1 one-liner counts leaves). Absent keys take the engine's defaults, which section 5 classifies: `spec_min_p` absent -= 0.0 (`crates/leleka-runtime/src/backend_original_serve.rs:152`), `LELEKA_CHAIN` absent = off. The deploy layer adds `LELEKA_ORIGINAL_SERVE_EXPERT_SLOTS=auto` and -`LELEKA_ORIGINAL_SERVE_EXPERT_PROFILE` when the profile file validates (`crates/deploy/src/plan.rs:270-279`) and the resource preset adds the CPU worker count and the mapped -working set (`crates/deploy/src/resources.rs:330-337`). - -| row | key | shipped value | class | evidence | -| --- | --- | --- | --- | --- | -| K30-01 | `name` | rtx3080-16g | lossless | deploy/rust-runtime/profiles/rtx3080-16g.json:2; label only (crates/deploy/src/profile.rs:238) | -| K30-02 | `description` | prose | lossless | deploy/rust-runtime/profiles/rtx3080-16g.json:3; no engine effect; it states `Experimental` and `no quality claim` | -| K30-03 | `select.sm_min` | 80 | lossless | deploy/rust-runtime/profiles/rtx3080-16g.json:4; selector only (crates/deploy/src/profile.rs:226-233) | -| K30-04 | `select.sm_max` | 120 | lossless | deploy/rust-runtime/profiles/rtx3080-16g.json:4; selector only (crates/deploy/src/profile.rs:226-233) | -| K30-05 | `select.vram_mib_min` | 14000 | lossless | deploy/rust-runtime/profiles/rtx3080-16g.json:4; selector only (crates/deploy/src/profile.rs:226-233) | -| K30-06 | `select.vram_mib_max` | 24000 | lossless | deploy/rust-runtime/profiles/rtx3080-16g.json:4; selector only (crates/deploy/src/profile.rs:226-233) | -| K30-07 | `gpu_budget_bytes` | 16106127360 (15 GiB) | unknown-until-q_pair | deploy/rust-runtime/profiles/rtx3080-16g.json:5; `--gpu-budget` (crates/deploy/src/config.rs:176-179), lowered by the workstation preset to 13 GiB (docs/laptop-vs-vanilla.md:152); sizes the VRAM expert tier, placement class as K50-07; STRA-293 (laptop, sm_86); q_pair logs: none | -| K30-08 | `context_tokens` | 262144 | lossless | deploy/rust-runtime/profiles/rtx3080-16g.json:6; `--context-tokens` (crates/deploy/src/config.rs:180-181); a ceiling, no arithmetic | -| K30-09 | `prefill_capacity` | 6144 | unknown-until-q_pair | deploy/rust-runtime/profiles/rtx3080-16g.json:7; `--original-prefill-capacity` (crates/deploy/src/config.rs:206-208); `6144 changes the rounding order of the prompt path ... no quality gate yet` (docs/laptop-vs-vanilla.md:79, 152); 16,000 tokens identical at 2048/4096/6144 on one prompt (docs/prefill-throughput.md:52-57); q_pair or R-hash arms 2048 against 6144 `Not run` (docs/laptop-vs-vanilla.md:79); STRA-293 (laptop, sm_86); q_pair logs: none | -| K30-10 | `kar_source` | file | lossless | deploy/rust-runtime/profiles/rtx3080-16g.json:8; where the archive bytes live (crates/deploy/src/profile.rs:47-54); same bytes | -| K30-11 | `expert_source` | mapped | lossless | deploy/rust-runtime/profiles/rtx3080-16g.json:9; where the routed-expert bytes live (crates/deploy/src/profile.rs:65-73); same bytes | -| K30-12 | `min_driver_major` | 595 | lossless | deploy/rust-runtime/profiles/rtx3080-16g.json:10; preflight gate only (crates/deploy/src/profile.rs:257) | -| K30-13 | `min_vram_total_mib` | 14000 | lossless | deploy/rust-runtime/profiles/rtx3080-16g.json:11; preflight gate only (crates/deploy/src/profile.rs:258) | -| K30-14 | `min_vram_free_mib` | 14500 | lossless | deploy/rust-runtime/profiles/rtx3080-16g.json:12; preflight gate only (crates/deploy/src/profile.rs:259-262) | -| K30-15 | `min_ram_total_bytes` | 23622320128 | lossless | deploy/rust-runtime/profiles/rtx3080-16g.json:13; preflight gate only (crates/deploy/src/profile.rs:263) | -| K30-16 | `min_ram_available_bytes` | 10737418240 | lossless | deploy/rust-runtime/profiles/rtx3080-16g.json:14; preflight gate only (crates/deploy/src/profile.rs:264) | -| K30-17 | `wsl_memory_gib` | 32 | lossless | deploy/rust-runtime/profiles/rtx3080-16g.json:15; advice only for `.wslconfig` (crates/deploy/src/profile.rs:265-267) | -| K30-18 | `expert_profile` | data/expert-profile.bin | unknown-until-q_pair | deploy/rust-runtime/profiles/rtx3080-16g.json:16; starting VRAM placement (set as `LELEKA_ORIGINAL_SERVE_EXPERT_PROFILE` by plan.rs:270-279 when the file validates); placement class as K50-07; STRA-293 (laptop, sm_86); q_pair logs: none | -| K30-19 | `expert_profile_sha256` | 8f59b4aa...975baf | lossless | deploy/rust-runtime/profiles/rtx3080-16g.json:17; integrity pin of the profile file (crates/deploy/src/profile.rs:271-272, 345-349) | -| K30-20 | `memory.prefix_cache_mib` | auto | lossless | deploy/rust-runtime/profiles/rtx3080-16g.json:19; cache budget; a hit reproduces the full read bit for bit (docs/prefix-cache.md:34-36); grid nodes exact by construction (docs/prefix-cache.md:169) | -| K30-21 | `memory.prefix_cache_tail` | prompt | unknown-until-q_pair | deploy/rust-runtime/profiles/rtx3080-16g.json:19; one checkpoint at n-1 at the end of the prefill = an extra chunk boundary; differs from a grid-only full read by where the chunks were cut, rounding level, same as any chunk-size change (docs/prefix-cache.md:164, 169-170); docs/laptop-vs-vanilla.md:80 (tail only moves where a checkpoint is taken; run A not checked with q_pair); STRA-293 (laptop, sm_86); q_pair logs: none | -| K30-22 | `memory.prefix_cache_block` | 6144 | unknown-until-q_pair | deploy/rust-runtime/profiles/rtx3080-16g.json:19; grid step caps every chunk (crates/deploy/src/profile.rs:97-100); same class as K30-09 (docs/laptop-vs-vanilla.md:79, 152); STRA-293 (laptop, sm_86); q_pair logs: none | -| K30-23 | `memory.soft_floor_mib` | 4096 | lossless | deploy/rust-runtime/profiles/rtx3080-16g.json:19; memory governor floor (crates/deploy/src/profile.rs:104-106); raised by the preset (docs/laptop-vs-vanilla.md); values untouched | -| K30-24 | `memory.hard_floor_mib` | 2048 | lossless | deploy/rust-runtime/profiles/rtx3080-16g.json:19; refusal floor (crates/deploy/src/profile.rs:107-109) | -| K30-25 | `memory.reserve_mib` | 1024 | lossless | deploy/rust-runtime/profiles/rtx3080-16g.json:19; slack above the soft floor (crates/deploy/src/profile.rs:110-112) | -| K30-26 | `memory.lock` | off | lossless | deploy/rust-runtime/profiles/rtx3080-16g.json:19; no memfd on this profile (crates/deploy/src/profile.rs:116-118) | -| K30-27 | `memory.heal` | false | lossless | deploy/rust-runtime/profiles/rtx3080-16g.json:19; no memfd on this profile (crates/deploy/src/profile.rs:119-121) | - -## 4. Admitted sets of `crates/leleka-runtime/src/serve_tuning.rs` (and the matching profile checks) - -| row | set | where | class | evidence | -| --- | --- | --- | --- | --- | -| A-01 | prefill chunk in {256, 512, 1024, 2048, 3072, 4096, 6144, 8192} | `serve_tuning.rs:14,68-70`; `crates/deploy/src/profile.rs:44,328-334` | unknown-until-q_pair | every member is a different chunk cut, rounding level; the engine default is 2048 (`original_serve_stack.rs:109`); 6144 and 8192 are the shipped values (K30-09, K50-11); STRA-267 (5090, sm_120); STRA-293 (laptop, sm_86); q_pair logs: none | -| A-02 | prefix block a multiple of 256 and <= 8192 (0 = the prefill chunk) and not larger than the chunk | `serve_tuning.rs:122-126,146-152`; `profile.rs:140-144` | unknown-until-q_pair | the block is the chunk-grid step; same class as A-01; STRA-267 (5090, sm_120); STRA-293 (laptop, sm_86); q_pair logs: none | -| A-03 | cpu_workers 1..=15 | `serve_tuning.rs:85-93` (engine pool admits 1..=64 at `original_serve_stack.rs:158`) | unknown-until-q_pair | no record of worker-count independence of the result in the files read; STRA-267 (5090, sm_120); STRA-293 (laptop, sm_86); q_pair logs: none | -| A-04 | context_tokens 1..=262144 | `serve_tuning.rs:58-66` | lossless | a ceiling | -| A-05 | kv_resident 0 or >= 20480, fixed for the life of the process; default 32768 | `serve_tuning.rs:76-84,16` | lossless | resident window of the same int8 cells; streaming of K/V, not a format change | -| A-06 | spec_min_p finite within 0..=1 | `serve_tuning.rs:94-102` | unknown-until-q_pair | see K50-08 / SRV `LELEKA_SPEC_ADAPTIVE`; STRA-267 (5090, sm_120); STRA-293 (laptop, sm_86) | -| A-07 | prefix_cache_mib `auto` / `off` / `0` / MiB; prefix_cache_tail off / prompt / reply; prefix_retention_min | `serve_tuning.rs:107-131` | unknown-until-q_pair | the tail value `reply` / `prompt` is the unknown part (K50-21, K30-21); budget and retention are lossless; STRA-267 (5090, sm_120); STRA-293 (laptop, sm_86) | - -## 5. Names read on the serve path in `original_serve*.rs`: 51 distinct names (38 lossless, 0 lossy, 13 unknown-until-q_pair) - -Command: `grep -rhoE '(LELEKA|STRATA)_[A-Z0-9_]+' crates/leleka-runtime/src --include='original_serve*.rs' | sort -u | wc -l` (files: 16, all under -`crates/leleka-runtime/src/qwen_forward/`, among them `original_serve_residency.rs`). The grep also matches comment mentions and the prefix token `LELEKA_ORIGINAL_SERVE_`; each is a -row. "Unset value" is the value in force when the variable is absent. Column "evidence" quotes the code or document that carries the class. - -| row | name | file:line | unset value | class | evidence | -| --- | --- | --- | --- | --- | --- | -| S-01 | `LELEKA_ADAPT_DECAY` | crates/leleka-runtime/src/qwen_forward/original_serve_residency.rs:443,448 | 0.7 (generate.cpp constant) | unknown-until-q_pair | adaptive-tier count decay, placement; adapt_every 4 / adapt_swaps 96 are ON (crates/leleka-runtime/src/qwen_forward/original_serve_residency.rs:174-175); docs/quality-gate.md section 8 P2/P6 PASS, 612 rows; STRA-267 (5090, sm_120); STRA-293 (laptop, sm_86) | -| S-02 | `LELEKA_ADAPT_MARGIN` | crates/leleka-runtime/src/qwen_forward/original_serve_residency.rs:443,448 | 1.5 | unknown-until-q_pair | adaptive-tier swap margin, placement; as LELEKA_ADAPT_DECAY | -| S-03 | `LELEKA_ADAPT_MIN_COUNT` | crates/leleka-runtime/src/qwen_forward/original_serve_residency.rs:442,448 | 2.0 | unknown-until-q_pair | adaptive-tier swap threshold, placement; as LELEKA_ADAPT_DECAY | -| S-04 | `LELEKA_BRINGUP_TRACE` | crates/leleka-runtime/src/qwen_forward/original_serve_pool.rs:34 | off | lossless | timing trace only (also read in the prefill path, row P-06) | -| S-05 | `LELEKA_CHAIN` | crates/leleka-runtime/src/qwen_forward/original_serve_config.rs:176 (comment; read at crates/cuda-driver/src/original_verify_window_chain.rs:62) | off (no group) | lossless | unset on the laptop profile; the 5090 profile sets `all`, see K50-19 (U, finding F1) | -| S-06 | `LELEKA_CPU_POOL` | crates/leleka-runtime/src/qwen_forward/original_serve_pool.rs:176,190 | Direct path | lossless | same arithmetic as the legacy path, copies skipped (pool.rs:179-181); `crosscheck` mode compares every float bit for bit (pool.rs:184-186); no recorded crosscheck result was read | -| S-07 | `LELEKA_CPU_POOL_FENCE` | crates/leleka-runtime/src/qwen_forward/original_serve_pool.rs:208,447 | one fence per group | lossless | synchronisation granularity only | -| S-08 | `LELEKA_CPU_POOL_LOOKAHEAD` | crates/leleka-runtime/src/qwen_forward/original_serve_pool.rs:210,453 | off (opt-in) | lossless | router lookahead is opt-in; unset = off | -| S-09 | `LELEKA_CPU_POOL_PLAN` | crates/leleka-runtime/src/qwen_forward/original_serve_stack.rs:156,159 | off (15 workers) | lossless | unset = constant 15 workers (stack.rs:112); `on` = pool_plan::default_workers | -| S-10 | `LELEKA_CPU_PREFETCH` | crates/leleka-runtime/src/qwen_forward/original_serve_pool.rs:219,459; crates/leleka-runtime/src/qwen_forward/prefetch_policy.rs:19-34 | Windows: adaptive (cheaper of pass / no pass by moving average); elsewhere: on | lossless | the laptop prefetch policy: `The bytes read and the arithmetic are the same in both modes` (prefetch_policy.rs:8); measured 8.70 -> 10.58 tok/s warm, 6.85 vs 5.22 cold (prefetch_policy.rs:4-6); timing choice, no q_pair needed | -| S-11 | `LELEKA_CPU_PREFETCH_OFF_FILE` | crates/leleka-runtime/src/qwen_forward/original_serve_pool.rs:81,84 | no file = no effect | lossless | A/B bring-up file | -| S-12 | `LELEKA_EXPERT_TIER_GPU` | crates/leleka-runtime/src/qwen_forward/original_serve_residency_gpu.rs:1,116,118 | unset (ignored test) | lossless | gates an #[ignore] test, not production | -| S-13 | `LELEKA_OPEN_CACHE` | crates/leleka-runtime/src/qwen_forward/original_serve_pool.rs:216,457 | off (opt-in) | lossless | unset = off; `not measured on a device yet` (pool.rs:216) | -| S-14 | `LELEKA_ORIGINAL_SERVE_` | crates/leleka-runtime/src/qwen_forward/original_serve_residency.rs:219 | prefix token of a format string | lossless | not a switch: `format!("LELEKA_ORIGINAL_SERVE_{name}")`; its members are the rows LELEKA_ORIGINAL_SERVE_* below plus names listed in section 7 (e.g. _EXPERT_PER_LAYER, _PCIE_FRAC, _PREFILL_BORROW, _CAPACITY, _KV_RESIDENT) | -| S-15 | `LELEKA_ORIGINAL_SERVE_CPU_WORKERS` | crates/leleka-runtime/src/qwen_forward/original_serve_stack.rs:155,158 | 15 (stack.rs:112); preset may set it (crates/deploy/src/resources.rs:335-337) | unknown-until-q_pair | worker count of the CPU expert pool, admitted 1..=64 here and 1..=15 by serve_tuning.rs:86; no record that the result is independent of the worker count was found in the files read; STRA-267 (5090, sm_120); STRA-293 (laptop, sm_86); q_pair logs: none | -| S-16 | `LELEKA_ORIGINAL_SERVE_DUMP_ROUTING` | crates/leleka-runtime/src/qwen_forward/original_serve_residency.rs:703,718 | off | lossless | writes a routing file, no effect on values | -| S-17 | `LELEKA_ORIGINAL_SERVE_EXPERT_PROFILE` | crates/leleka-runtime/src/qwen_forward/original_serve_residency.rs:224 | none; deploy sets it when the profile file validates (plan.rs:270-279) | unknown-until-q_pair | starting placement, K50-09 / K30-18; STRA-267 (5090, sm_120); STRA-293 (laptop, sm_86) | -| S-18 | `LELEKA_ORIGINAL_SERVE_EXPERT_SLOTS` | crates/leleka-runtime/src/qwen_forward/original_serve_residency.rs:214,221 | 0 (tier off); deploy sets `auto` (plan.rs:270-273) | unknown-until-q_pair | VRAM tier size; the shipped runs have the tier ON; placement class as K50-07; STRA-267 (5090, sm_120); STRA-293 (laptop, sm_86) | -| S-19 | `LELEKA_ORIGINAL_SERVE_SEED` | crates/leleka-runtime/src/qwen_forward/original_serve_residency.rs:145,260-269; crates/leleka-runtime/src/qwen_forward/original_serve_seed.rs:1,29-30 | ON, up to 4096 swaps | unknown-until-q_pair | prompt-routing seed, placement only; docs/quality-gate.md section 8: P5 vs P1 p99 0.146 / max 0.447, P6 shipped default p99 0.235 (+7 % over the Original's 0.219), flips 2.3 %, verdict PASS, 612 rows, short prompts; STRA-267 (5090, sm_120); STRA-293 (laptop, sm_86) | -| S-20 | `LELEKA_PCIE_AUTO` | crates/leleka-runtime/src/qwen_forward/original_serve_residency.rs:557,576,616,638 | off (only `lag` enables) | lossless | unset = fixed share; `Only the split changes, never what an expert computes` (residency.rs:561-562) | -| S-21 | `LELEKA_PCIE_LOCKED_ONLY` | crates/leleka-runtime/src/qwen_forward/original_serve_residency.rs:328,434,438,796 | off | lossless | unset = unrestricted split | -| S-22 | `LELEKA_PREFILL_LOAN_TIERS` | crates/leleka-runtime/src/qwen_forward/original_serve_stack.rs:145,219,222,305 | off | lossless | OFF until its identity gate (job p34); unset = full loan | -| S-23 | `LELEKA_PREFIX_RETENTION_S` | crates/leleka-runtime/src/qwen_forward/original_serve_prefix.rs:77,80 | 3600 s | lossless | cache lifetime only; the profile `prefix_retention_min` is absent in both files | -| S-24 | `LELEKA_PREFIX_TRACE` | crates/leleka-runtime/src/qwen_forward/original_serve_stack.rs:1464,1469 | off | lossless | operator text only | -| S-25 | `LELEKA_QSA_CLUSTER` | crates/leleka-runtime/src/qwen_forward/original_serve_verifier.rs:31,272-273 | ON (QSA_CLUSTER_DEFAULT = true; the driver turns it off below sm_90, so off on the sm_86 laptop) | lossless | cluster decode top-k writes the same ids as qsa_topk_ref in 24 model-free cases; end to end q_tail_gate over 1,502 forced rows: d_top1 median/p99/max 0.0000 and 0 argmax flips for all 7 arms (docs/upstream-port-plan.md:42, 142-143) | -| S-26 | `LELEKA_REFILL_DEFER` | crates/leleka-runtime/src/qwen_forward/original_serve_residency.rs:1155,1161; crates/leleka-runtime/src/qwen_forward/original_serve_stack.rs:316 | off (EXPERIMENTAL) | lossless | unset = off | -| S-27 | `LELEKA_ROUTE_TAIL_SKIP` | crates/leleka-runtime/src/qwen_forward/original_serve_residency.rs:52,64,87 | 0 = OFF (`unwrap_or(0)` at line 64) | lossless | ours is off by default; the mode is lossy (`changes the output`, residency.rs:51-55) and would be class lossy if enabled; vanilla's default differs, see section 6 | -| S-28 | `LELEKA_ROUTE_TAIL_SKIP_MAX_CACHED` | crates/leleka-runtime/src/qwen_forward/original_serve_residency.rs:54,80 | 90.0 (percent) | lossless | only consulted when tail skip is on | -| S-29 | `LELEKA_SEED_TRACE` | crates/leleka-runtime/src/qwen_forward/original_serve_stack.rs:314,1253,1260,1266,1296 | off | lossless | trace only | -| S-30 | `LELEKA_SERVE_OVERLAP` | crates/leleka-runtime/src/qwen_forward/original_serve_native.rs:117,121 | ON (draft enqueued behind the commit event, generate.cpp order) | lossless | enqueue order of already-defined work; `off` is the earlier serialized order | -| S-31 | `LELEKA_SERVE_PROFILE` | crates/leleka-runtime/src/qwen_forward/original_serve_profile.rs:1,9,12; crates/leleka-runtime/src/qwen_forward/original_serve_stack.rs:1561 | off | lossless | span timing only | -| S-32 | `LELEKA_SERVE_PUBLISH` | crates/leleka-runtime/src/qwen_forward/original_serve_host.rs:119,122,409 | batched publication | lossless | same twelve index checkpoints, one batch versus one by one | -| S-33 | `LELEKA_SERVE_SWAP_WAIT` | crates/leleka-runtime/src/qwen_forward/original_serve_residency.rs:947,981,984 | ON (wait for adaptive swaps at a round start) | lossless | makes `the resident set no longer depend on when the copies finished` (residency.rs:944-946); timing only | -| S-34 | `LELEKA_SPAN_CACHE` | crates/leleka-runtime/src/qwen_forward/original_serve_residency.rs:528,540 | ON | lossless | caches span lookups; `off` is the A/B control | -| S-35 | `LELEKA_SPEC` | crates/leleka-runtime/src/qwen_forward/original_serve_engine.rs:376,384,390,398,1076 | unset = mode17 (verify window 6, MTP window 4) unless adaptive | unknown-until-q_pair | window width; verified tokens are the verifier's, width changes batch rounding (docs/adaptive-spec.md:106-111); STRA-267 (5090, sm_120); STRA-293 (laptop, sm_86) | -| S-36 | `LELEKA_SPEC_ADAPTIVE` | crates/leleka-runtime/src/qwen_forward/original_serve_engine.rs:354,363,378,389,397-405 | ON (ADAPTIVE_DEFAULT = true, engine.rs:354) | unknown-until-q_pair | adaptive window is the shipped default; exactness argued by verification, measured 16/30 identical against fixed-4 (docs/adaptive-spec.md:106-111); STRA-267 (5090, sm_120); STRA-293 (laptop, sm_86); q_pair logs: none | -| S-37 | `LELEKA_SPEC_ADAPTIVE_MAX_T` | crates/leleka-runtime/src/qwen_forward/original_serve_engine.rs:378,391 | 8 (MAX_T) | unknown-until-q_pair | widest adaptive window; as LELEKA_SPEC_ADAPTIVE | -| S-38 | `LELEKA_SPEC_ARMS` | crates/leleka-runtime/src/qwen_forward/original_serve_engine.rs:410,414; crates/leleka-runtime/src/qwen_forward/original_serve_stack.rs:273,710 | none (empty) | lossless | A/B harness switch, unset = single policy | -| S-39 | `LELEKA_SPEC_MTP_MAX_T` | crates/leleka-runtime/src/qwen_forward/original_serve_engine.rs:377,387 | spec (4) or the adaptive maximum | unknown-until-q_pair | draft chain length; as LELEKA_SPEC_ADAPTIVE | -| S-40 | `LELEKA_SPEC_SUFFIX` | crates/leleka-runtime/src/qwen_forward/original_serve_engine.rs:377,388 | 3 (suffix draft ON, mode17 SUFFIX = 3) | unknown-until-q_pair | prompt-lookup drafting changes the window contents; as LELEKA_SPEC_ADAPTIVE | -| S-41 | `LELEKA_TRACE_LOGPROBS` | crates/leleka-runtime/src/qwen_forward/original_serve_native.rs:110,162 | off | lossless | diagnostic dump | -| S-42 | `LELEKA_TRACE_RESIDUAL` | crates/leleka-runtime/src/qwen_forward/original_serve_native.rs:114,171 | off | lossless | diagnostic dump | -| S-43 | `STRATA_CKPT_REREAD` | crates/leleka-runtime/src/qwen_forward/original_serve_conversation.rs:37,47,59,234; crates/leleka-runtime/src/qwen_forward/original_serve_stack.rs:803,1184 | off (checkpoints are restored) | lossless | a check of the checkpoint (answer must match the restored one token for token), not a default | -| S-44 | `STRATA_MTP_PREFILL_SYNC` | crates/leleka-runtime/src/qwen_forward/original_serve_config.rs:197 | unset (comment; per_group_sync false) | lossless | named in a comment only, not read in ours; synchronisation granularity | -| S-45 | `STRATA_OLD_SAMPLER` | crates/leleka-runtime/src/qwen_forward/original_serve_config.rs:203,208,373-375 | unset = Split top-k path | unknown-until-q_pair | sampler kernel choice mirrors sampler.cu (config.rs:203-205); the q_pair corpus is greedy / teacher-forced and does not exercise sampled requests, so a q_pair result cannot settle it; STRA-267 (5090, sm_120); STRA-293 (laptop, sm_86) | -| S-46 | `STRATA_PREFILL_STREAM_MIN` | crates/leleka-runtime/src/qwen_forward/original_serve_config.rs:277 (comment: 1024); crates/leleka-runtime/src/qwen_forward/cache_original_prompt.rs:12,29 (code: 4096) | 4096 rows (code); the config.rs comment says 1024 (finding F6) | lossless | copy ordering of expert streaming; `identical greedy ids` at chunk 8192, +13..27 % prefill tok/s (cache_original_prompt.rs:16-17); also row P-14 | -| S-47 | `STRATA_ROPE_TABLE` | crates/leleka-runtime/src/qwen_forward/original_serve_config.rs:120 | unset = analytic form | lossless | named in a comment: the table form is `not supported here` | -| S-48 | `STRATA_ROUTE_TAIL_SKIP` | crates/leleka-runtime/src/qwen_forward/original_serve_residency.rs:51,311 | not read in ours (comments) | lossless | upstream name in comments; ours reads LELEKA_ROUTE_TAIL_SKIP | -| S-49 | `STRATA_SAMPLER_ONE_BLOCK` | crates/leleka-runtime/src/qwen_forward/original_serve_config.rs:204,210,372-373 | off | lossless | unset = Split path (see STRATA_OLD_SAMPLER) | -| S-50 | `STRATA_SPEC_COUPLED` | crates/leleka-runtime/src/qwen_forward/original_serve_engine.rs:406,408 | off (coupled draft sampling false) | lossless | unset = off | -| S-51 | `STRATA_VERIFY_PROFILE` | crates/leleka-runtime/src/qwen_forward/original_serve_stack.rs:1116 | unset (comment; read in the driver) | lossless | GPU stage timing report only | - -### 5b. Names in the prefill chunk path files: 14 distinct names (14 lossless, 0 lossy, 0 unknown-until-q_pair) - -The file list is the output of `find crates/leleka-runtime/src -type f -name '*.rs' | grep -E 'prefill|chunk|original_prompt|prompt' | grep -v '/original_serve'` (31 files, none -matches the glob of section 5), relative to `crates/leleka-runtime/src/`: -`backend_original_prompt.rs`, `qwen_forward/cache_original_prompt.rs`, `chunk_modules.rs`, `executor_original_prompt.rs`, `executor_prefill_chunk.rs`, `gdn_chunk_device.rs`, -`gdn_chunk_fused.rs`, `gdn_chunk_numeric_gpu.rs`, `gdn_chunk_producer.rs`, `gdn_prefill_batch.rs`, `gdn_prefill_batch_gpu.rs`, `gdn_prompt_device.rs`, `gr_attention_chunk.rs`, -`gr_batch_chunk.rs`, `moe_group_chunk.rs`, `moe_mmq_chunk.rs`, `moe_prefill_batch.rs`, `moe_prompt_finish.rs`, `mtp_decode_chunk.rs`, `mtp_state_chunk.rs`, `original_mtp_prefill.rs`, -`original_mtp_scalar_prefill.rs`, `original_prompt_embedding.rs`, `prefill_profile.rs`, `prompt_device_rows.rs`, `qsa_prefill_batch.rs`, `qsa_prompt_device.rs`, `qsa_prompt_index.rs`, -`session_chunk.rs`, `session_chunk_verify.rs`, `session_original_prompt.rs` (all except the first one under `qwen_forward/`). Command over those files: -`grep -hoE '(LELEKA|STRATA)_[A-Z0-9_]+' | sort -u | wc -l`. Two names also occur in section 5 (`LELEKA_BRINGUP_TRACE`, `STRATA_PREFILL_STREAM_MIN`). - -| row | name | file:line | unset value | class | evidence | -| --- | --- | --- | --- | --- | --- | -| P-01 | `LELEKA_BRINGUP_TRACE` | crates/leleka-runtime/src/qwen_forward/prefill_profile.rs:1 | off | lossless | per-chunk timing trace (also row S-04) | -| P-02 | `LELEKA_PREFILL_GDN_MIRROR` | crates/leleka-runtime/src/qwen_forward/gdn_chunk_device.rs:11,152 | ON | lossless | reuse of a resident GDN state mirror versus a canonical re-upload of the same values (`always upload the canonical host values (the A/B arm)`) | -| P-03 | `LELEKA_PREFILL_MOE_SPAN_CACHE` | crates/leleka-runtime/src/qwen_forward/cache_original_prompt.rs:44,52 | ON | lossless | span lookup cache, `0` restores the walk | -| P-04 | `LELEKA_PREFILL_PROFILE_SYNC` | crates/leleka-runtime/src/qwen_forward/prefill_profile.rs:6,119,138 | off | lossless | drains the device per span for attribution only | -| P-05 | `LELEKA_PREFILL_QSA_PREFETCH` | crates/leleka-runtime/src/qwen_forward/prompt_device_rows.rs:419 (comment); read at crates/cuda-driver/src/qsa_resident_transport.rs:38,74 | ON (QSA_PREFETCH_DEFAULT = true) | lossless | starts the prior-KV prefix copy on a side stream; ordering of a copy, same bytes | -| P-06 | `LELEKA_PREFILL_STAGED_INPUT` | crates/leleka-runtime/src/qwen_forward/executor_original_prompt.rs:39,42,296 | ON | lossless | KAR inputs staged chunk-wide on the device versus per-token host path (the A/B arm); `0` keeps the host path | -| P-07 | `LELEKA_PREFILL_STREAM` | crates/leleka-runtime/src/qwen_forward/cache_original_prompt.rs:15,23 | ON | lossless | per-chunk expert streaming; `identical greedy ids`, 16,000 tokens at chunk 8192 (cache_original_prompt.rs:16-17) | -| P-08 | `LELEKA_PREFILL_STREAM_SEQ` | crates/leleka-runtime/src/qwen_forward/cache_original_prompt.rs:31 | unset (test harness switch, `-1` = environment) | lossless | in-process A/B override | -| P-09 | `LELEKA_STRA169_RUN_GDN_BATCH_RESOURCES` | crates/leleka-runtime/src/qwen_forward/gdn_prefill_batch_gpu.rs:13 | unset (gates a GPU test) | lossless | test gate | -| P-10 | `LELEKA_STRA169_RUN_GDN_CHUNK_COMPONENT` | crates/leleka-runtime/src/qwen_forward/gdn_chunk_numeric_gpu.rs:404,481 | unset (gates a GPU test) | lossless | test gate | -| P-11 | `LELEKA_TRACE_DRIVER_ERRORS` | crates/leleka-runtime/src/qwen_forward/executor_original_prompt.rs:601 | off | lossless | prints driver errors | -| P-12 | `LELEKA_TRACE_PREFILL_R` | crates/leleka-runtime/src/qwen_forward/executor_original_prompt.rs:437,439 | off | lossless | FNV-1a of the final residual per chunk, `off by default` | -| P-13 | `STRATA_PREFILL_BF16X2` | crates/leleka-runtime/src/qwen_forward/gdn_prefill_batch.rs:29; crates/leleka-runtime/src/qwen_forward/moe_prefill_batch.rs:33 | 0 = HighOnly, the original default | lossless | named in comments: HighOnly is the literal profile; HighPlusLow is `separately profile-bound` and not selected here | -| P-14 | `STRATA_PREFILL_STREAM_MIN` | crates/leleka-runtime/src/qwen_forward/cache_original_prompt.rs:12,29 | 4096 rows | lossless | see row S-46; copy ordering | - -Not covered by the file set above, read in `crates/cuda-driver/src` and named here only so the second wave can find them (not classified here): `LELEKA_PREFILL_GDN_NOSTORE` -(default ON, `prefill_stage.rs:78,84`, identity gate cited in docs/upstream-port-plan.md row 2.4), `LELEKA_PREFILL_GDN_KH` (default off, `prefill_stage.rs:96-103`, sm_120 only), -`LELEKA_PREFILL_FAST_REC` (off, `prefill_stage.rs:61`), `LELEKA_MMQ_STREAMK` / `LELEKA_MMQ_NO_STREAMK` (stream-K policy latched per device, `arch_ptx.rs:27,85`). - -## 6. Vanilla Strata defaults (cross-reference to STRA-247 only; nothing measured or classified here) - -* Route tail skip, vanilla: ON by default on CUDA builds (owner decision 0.1.42), rank 7: `engine/strata/src/program/generate.cpp:10110-10153` (the handoff's `generate.cpp` is - `src/program/generate.cpp`; the skip itself is `src/core/expert_source.cpp:4763-4894`). Conditions that turn the default OFF: every expert resident; at least - `STRATA_TAIL_SKIP_MAX_CACHED` percent (default 90) of the experts cached; NVFP4 experts; `--batch` slots; a peer or helper GPU; an unsupported decode architecture - (`decode_defaults_arch_ok()`). It changes the output (comment: KL ~0.003-0.006). Ours: OFF, `unwrap_or(0)` (row S-27, line 64 below). So `off` is ours only. See STRA-247. -* CPU prefill share, vanilla: ON by default for chunks below 1024 tokens since 0.1.41 (`STRATA_PREFILL_CPU_SHARE` unset behaves as `auto` with `STRATA_PREFILL_CPU_SHARE_MAX=1024`; - CUDA builds, one GPU, no batch slots; layer split, batch slots and HIP stay off), `engine/strata/src/prefill/prefill.cpp:193-221`; mean KL against the share off about 0.004 - (comment, lines 202-205). `STRATA_PREFILL_CPU_SHARE=0` turns it off. Ours: ABSENT (row below). See STRA-247. - -| row | item | ours | evidence | -| --- | --- | --- | --- | -| V-01 | route tail skip | OFF by default (`LELEKA_ROUTE_TAIL_SKIP`, unset = 0, lossy when enabled) | `crates/leleka-runtime/src/qwen_forward/original_serve_residency.rs:64`; command `sed -n '64p' ...` in section 8 | -| V-02 | CPU prefill share | ABSENT: no such switch in `crates/` or `scripts/` | command `grep -rn -i "prefill.*cpu.*share\|PREFILL_CPU_SHARE" crates scripts` printed nothing (section 8) | - -## 7. Everything else: not on the shipped serve path as scoped, not classified (434 names) - -These are the distinct `LELEKA_*` / `STRATA_*` tokens found in `crates/**/*.rs` minus the names of sections 5 and 5b. Command that produced the list: -`grep -rhoE '(LELEKA|STRATA)_[A-Z0-9_]+' crates --include='*.rs' | sort -u` (497 distinct tokens, 441 of them `LELEKA_*`) minus the 63 names of sections 5 and 5b, with -`comm -23`. Caveat: this list is by token, not by reader. Some of these are read on the serve path by files outside the bounded file set (for example `LELEKA_MEMORY_*` and -`LELEKA_MAPPED_WORKING_SET_GIB`, which the profile `memory` rows K50-23..27 and K30-23..27 classify; `LELEKA_CHAIN_*` groups behind K50-19; `LELEKA_SPEC_*` controller constants -in docs/adaptive-spec.md; `LELEKA_ORIGINAL_SERVE_PCIE_FRAC`, `_PREFILL_BORROW`, `_CAPACITY`, `_KV_RESIDENT`; `LELEKA_PREFILL_*` switches in `crates/cuda-driver`). They are -listed so that nothing is silently dropped; none is classified. - -`LELEKA_AB_DATE`, `LELEKA_AB_REPLAY`, `LELEKA_ASSETS`, `LELEKA_BANK_THP`, `LELEKA_CAPTURE_DIR`, `LELEKA_CB_WARMUP`, `LELEKA_CHAIN_`, `LELEKA_CHAIN_AB`, `LELEKA_CHAIN_DOWN`, `LELEKA_CHAIN_GLUE`, `LELEKA_CHAIN_GR`, `LELEKA_CHAIN_HEAD`, `LELEKA_CHAIN_MTP`, `LELEKA_CHAIN_QSA`, `LELEKA_CHAIN_TINY`, `LELEKA_CHAIN_UP8`, `LELEKA_CHUNK_DRAIN`, `LELEKA_CHUNK_DRAIN_FILE`, `LELEKA_CONVERSATION_CACHE`, `LELEKA_CONVERSATION_CACHE_MIB`, `LELEKA_CONVERSATION_CACHE_SLOTS`, `LELEKA_CONVERSATION_CANCEL_PROBES`, `LELEKA_CONVERSATION_EVERY`, `LELEKA_CONVERSATION_MAX_NEW`, `LELEKA_CONVERSATION_SYSTEM_REPEAT`, `LELEKA_CPU_ISA`, `LELEKA_CPU_POOL_PIN_HOST`, `LELEKA_CUDA_CASE`, `LELEKA_CUDA_MOCK_HARNESS`, `LELEKA_CUDA_MOCK_ROOT`, `LELEKA_CUDA_Q5_MOCK_ROOT`, `LELEKA_CUDA_Q6_MOCK_ROOT`, `LELEKA_CUDA_REAL_GPU`, `LELEKA_CUDA_TRACE_CALLBACKS`, `LELEKA_CUDA_TRACE_SYNC`, `LELEKA_DLL_DIRS`, `LELEKA_EXPERIMENTAL_EXPERTS_USED`, `LELEKA_EXPERIMENTAL_FAKE_BITS`, `LELEKA_EXPERIMENTAL_KAR_EXPERT_LAYERS`, `LELEKA_EXPERIMENTAL_KAR_EXPERT_LEVELS`, `LELEKA_EXPERIMENTAL_KAR_LEVELS`, `LELEKA_EXPERIMENTAL_KAR_TENSORS`, `LELEKA_FAMILY_CLOSE_FAILURE`, `LELEKA_FAMILY_EXPECT_FAILURE`, `LELEKA_FAMILY_GPU_ROOT`, `LELEKA_FAMILY_IQ2S_ENABLED`, `LELEKA_FAMILY_IQ3S_ENABLED`, `LELEKA_FAMILY_IQ3XXS_ENABLED`, `LELEKA_FAMILY_IQ4NL_ENABLED`, `LELEKA_FAMILY_IQ4XS_ENABLED`, `LELEKA_FAMILY_MODES`, `LELEKA_FAMILY_N`, `LELEKA_FAMILY_NATIVE`, `LELEKA_FAMILY_PUBLIC_CASE`, `LELEKA_FAMILY_PUBLIC_MODE`, `LELEKA_FAMILY_Q2_ENABLED`, `LELEKA_FAMILY_Q4K_ENABLED`, `LELEKA_FAMILY_Q8_ENABLED`, `LELEKA_FAMILY_QUANTIZER_PTX`, `LELEKA_FAMILY_REAL_GPU`, `LELEKA_FAMILY_ROOT`, `LELEKA_FAMILY_UNIT_ELF`, `LELEKA_FORCE_SMS`, `LELEKA_GATEWAY_TOKEN`, `LELEKA_GPTOSS_GGUF`, `LELEKA_HEAD_EVIDENCE`, `LELEKA_HEAD_NATIVE_ORACLE`, `LELEKA_HEAD_NATIVE_SHA256`, `LELEKA_IGPU_MOE_TILE`, `LELEKA_IGPU_TILE`, `LELEKA_LAPTOP_ARMS`, `LELEKA_LAPTOP_BENCH`, `LELEKA_LAPTOP_CELLS`, `LELEKA_LAPTOP_CPU_WORKERS`, `LELEKA_LAPTOP_EXPERTS`, `LELEKA_LAPTOP_KAR_FILE`, `LELEKA_LAPTOP_MAX_CONTEXT`, `LELEKA_LAPTOP_MAX_NEW`, `LELEKA_LAPTOP_ORDER`, `LELEKA_LAPTOP_PREFIX_BLOCK`, `LELEKA_LAPTOP_PREFIX_MIB`, `LELEKA_LAPTOP_PROMPT_CACHE`, `LELEKA_LAPTOP_PROMPT_IDS`, `LELEKA_LAPTOP_REPEAT`, `LELEKA_LAPTOP_SEQUENCE`, `LELEKA_LAPTOP_SKIP_FAILED`, `LELEKA_LAPTOP_SOAK_S`, `LELEKA_LAPTOP_SPEC_MIN_P`, `LELEKA_MAPPED_WORKING_SET_GIB`, `LELEKA_MARGINS`, `LELEKA_MEMORY_`, `LELEKA_MEMORY_CACHE_SHARE_PERCENT`, `LELEKA_MEMORY_ENFORCE`, `LELEKA_MEMORY_HARD_FLOOR_MIB`, `LELEKA_MEMORY_HEAL`, `LELEKA_MEMORY_HYSTERESIS_MIB`, `LELEKA_MEMORY_LOCK`, `LELEKA_MEMORY_NO_TRIM`, `LELEKA_MEMORY_PSI_FULL_REJECT`, `LELEKA_MEMORY_PSI_GUARD_MIB`, `LELEKA_MEMORY_PSI_SOME_SHED`, `LELEKA_MEMORY_RESERVE_MIB`, `LELEKA_MEMORY_RESIDENCY_S`, `LELEKA_MEMORY_SAMPLE_MS`, `LELEKA_MEMORY_SOFT_FLOOR_MIB`, `LELEKA_MEMORY_SWAPOUT_PAGES_PER_S`, `LELEKA_MEM_ABORT_GIB`, `LELEKA_MEM_BALLAST_MIB`, `LELEKA_MEM_BIG`, `LELEKA_MEM_BIG_EVERY`, `LELEKA_MEM_EXPERTS`, `LELEKA_MEM_FILL_MAX`, `LELEKA_MEM_FILL_TOKENS`, `LELEKA_MEM_HARD_BELOW_MIB`, `LELEKA_MEM_KAR_FILE`, `LELEKA_MEM_LEAK_SAMPLE_S`, `LELEKA_MEM_LEAK_SECS`, `LELEKA_MEM_LEAK_TSV`, `LELEKA_MEM_LEAK_WARMUP_PCT`, `LELEKA_MEM_PREFIX_MIB`, `LELEKA_MEM_PROBE_SECS`, `LELEKA_MEM_READER_FILE`, `LELEKA_MEM_READER_GIB`, `LELEKA_MEM_READER_NEW`, `LELEKA_MEM_READER_REQS`, `LELEKA_MEM_REQUESTS`, `LELEKA_MEM_SCENARIO`, `LELEKA_MEM_SESSIONS`, `LELEKA_MEM_SESSION_CAP`, `LELEKA_MEM_SMOKE`, `LELEKA_MEM_SOFT_BELOW_MIB`, `LELEKA_MEM_TOKENS`, `LELEKA_MEM_WARMUP`, `LELEKA_MMQ_NO_STREAMK`, `LELEKA_MMQ_NO_STREAMK_FILE`, `LELEKA_MMQ_STREAMK`, `LELEKA_MMQ_STREAMK_FILE`, `LELEKA_MODEL_SHA256`, `LELEKA_MTP_RT_BANK_GPU`, `LELEKA_MTP_SCALAR_SHORT_GPU`, `LELEKA_NO_TRIM_FILE`, `LELEKA_NPU_CPU_THREADS`, `LELEKA_NPU_PROFILE`, `LELEKA_OPENVINO_DEVICE`, `LELEKA_OPENVINO_ROOT`, `LELEKA_ORIGINAL_SERVE_ADAPT_EVERY`, `LELEKA_ORIGINAL_SERVE_BUDGET_GIB`, `LELEKA_ORIGINAL_SERVE_CAPACITY`, `LELEKA_ORIGINAL_SERVE_EXPERT_`, `LELEKA_ORIGINAL_SERVE_EXPERT_PER_LAYER`, `LELEKA_ORIGINAL_SERVE_KV_RESIDENT`, `LELEKA_ORIGINAL_SERVE_LONG_ARMS`, `LELEKA_ORIGINAL_SERVE_LONG_CONVERSATION`, `LELEKA_ORIGINAL_SERVE_LONG_FORCE_DIR`, `LELEKA_ORIGINAL_SERVE_LONG_IDS_DIR`, `LELEKA_ORIGINAL_SERVE_LONG_MAX_NEW`, `LELEKA_ORIGINAL_SERVE_LONG_QUESTION`, `LELEKA_ORIGINAL_SERVE_LONG_REPEAT`, `LELEKA_ORIGINAL_SERVE_LONG_SMOKE`, `LELEKA_ORIGINAL_SERVE_LONG_TEXT_FILE`, `LELEKA_ORIGINAL_SERVE_LONG_TOKENS`, `LELEKA_ORIGINAL_SERVE_MAX_CONTEXT`, `LELEKA_ORIGINAL_SERVE_NAN_GUARD`, `LELEKA_ORIGINAL_SERVE_NAN_GUARD_RETRIES`, `LELEKA_ORIGINAL_SERVE_NAN_INJECT`, `LELEKA_ORIGINAL_SERVE_PCIE_FRAC`, `LELEKA_ORIGINAL_SERVE_PER_LAYER_SIZED`, `LELEKA_ORIGINAL_SERVE_PREFILL_BORROW`, `LELEKA_ORIGINAL_SERVE_REPLAY`, `LELEKA_ORIGINAL_SERVE_RESIDENT_BUDGET_GIB`, `LELEKA_ORIGINAL_SERVE_RT_DIR`, `LELEKA_ORIGINAL_SERVE_SMOKE`, `LELEKA_ORIGINAL_SERVE_VRAM_RESERVE_MIB`, `LELEKA_PCIE_DMA_BATCH`, `LELEKA_PCIE_DMA_MANY`, `LELEKA_PCIE_FLAGB`, `LELEKA_PCIE_GRID`, `LELEKA_PCIE_KERNEL`, `LELEKA_PFX_BLOCK`, `LELEKA_PFX_CANCEL`, `LELEKA_PFX_CAPACITY`, `LELEKA_PFX_END`, `LELEKA_PFX_GROW`, `LELEKA_PFX_LAPTOP`, `LELEKA_PFX_MAX_NEW`, `LELEKA_PFX_MIB`, `LELEKA_PFX_MODE`, `LELEKA_PFX_SCENARIO`, `LELEKA_PFX_SESSIONS`, `LELEKA_PFX_SHARED`, `LELEKA_PFX_SMOKE`, `LELEKA_PFX_START`, `LELEKA_PFX_TURNS`, `LELEKA_PFX_VERIFY`, `LELEKA_PLE_`, `LELEKA_PLE_AHEAD`, `LELEKA_PLE_AHEAD_VERIFY`, `LELEKA_PLE_DIRECT`, `LELEKA_PLE_INFLIGHT`, `LELEKA_PLE_PROBE_ARCHIVE`, `LELEKA_PLE_PROBE_DUMP`, `LELEKA_PLE_PROBE_ROWS`, `LELEKA_PLE_READER`, `LELEKA_PLE_ROW_CACHE`, `LELEKA_PLE_SYNC_SUBMIT`, `LELEKA_PREFILL_AHEAD`, `LELEKA_PREFILL_ALIGNED_COPY`, `LELEKA_PREFILL_ALLOC_TRACE`, `LELEKA_PREFILL_CHUNK`, `LELEKA_PREFILL_COPY_STATS`, `LELEKA_PREFILL_DEFER_FREE_MIB`, `LELEKA_PREFILL_DEFER_GUARDS`, `LELEKA_PREFILL_DEPTH`, `LELEKA_PREFILL_DIAG_SKIP_EXPERT_DMA`, `LELEKA_PREFILL_FAST_DEQUANT`, `LELEKA_PREFILL_FAST_REC`, `LELEKA_PREFILL_FUSED_SCANS`, `LELEKA_PREFILL_GDN_KH`, `LELEKA_PREFILL_GDN_NOSTORE`, `LELEKA_PREFILL_GDN_POOL`, `LELEKA_PREFILL_GUARD_GRID`, `LELEKA_PREFILL_ISSUER`, `LELEKA_PREFILL_STAGE_GPU`, `LELEKA_PREFILL_STALL_TRACE`, `LELEKA_PREFILL_STREAM_JITTER`, `LELEKA_PREFILL_TOPUP`, `LELEKA_PREFILL_ZERO_MEMSET`, `LELEKA_PREFIX`, `LELEKA_PRESET`, `LELEKA_PUBLIC_EVALUATION`, `LELEKA_Q5_CASE`, `LELEKA_Q5_EVIDENCE`, `LELEKA_Q5_NATIVE_ORACLE`, `LELEKA_Q5_REAL_INPUT`, `LELEKA_Q5_TRUSTED_PTX`, `LELEKA_Q6_CASE`, `LELEKA_Q6_EVIDENCE`, `LELEKA_Q6_NATIVE_ORACLE`, `LELEKA_Q6_REAL_INPUT`, `LELEKA_Q6_TRUSTED_PTX`, `LELEKA_QSA_LATE`, `LELEKA_QSA_LATE_GPU`, `LELEKA_QSA_LATE_SEQ`, `LELEKA_QSA_LATE_SM86`, `LELEKA_QSA_TOPK`, `LELEKA_REAL_GU_DIR`, `LELEKA_REAL_GU_MANIFEST_SHA`, `LELEKA_REAL_GU_OUTPUT_DIR`, `LELEKA_REPLAY_ARMS`, `LELEKA_REPLAY_CAPACITY`, `LELEKA_REPLAY_COUNT`, `LELEKA_REPLAY_DIR`, `LELEKA_REPLAY_FIRST`, `LELEKA_REPLAY_FORCE`, `LELEKA_REPLAY_MAX_CONTEXT`, `LELEKA_REPLAY_MAX_NEW`, `LELEKA_REPLAY_OUT`, `LELEKA_REPLAY_PREFIX_MIB`, `LELEKA_REPLAY_PREFIX_TAIL`, `LELEKA_REPLAY_REPS`, `LELEKA_REPLAY_SPEC_MIN_P`, `LELEKA_RING_SERIALIZE`, `LELEKA_RING_SERIALIZE_CMD_FILE`, `LELEKA_RING_SERIALIZE_COPY_FILE`, `LELEKA_RING_SERIALIZE_FILE`, `LELEKA_ROUTE`, `LELEKA_RUNTIME_TOKEN`, `LELEKA_RUN_REAL_NATIVE_D4`, `LELEKA_SHADOW_DEVICE`, `LELEKA_SKIP_CPU`, `LELEKA_SLOT_LOG`, `LELEKA_SM86_TRACE`, `LELEKA_SMOKE_ARMS`, `LELEKA_SMOKE_CHAT`, `LELEKA_SMOKE_FORCE_DIR`, `LELEKA_SMOKE_FORCE_PASSES`, `LELEKA_SMOKE_MAX_CONTEXT`, `LELEKA_SMOKE_MAX_NEW`, `LELEKA_SMOKE_MIN_P`, `LELEKA_SMOKE_ORDER`, `LELEKA_SMOKE_PROMPTS`, `LELEKA_SMOKE_PROMPT_CACHE`, `LELEKA_SMOKE_PROMPT_IDS`, `LELEKA_SMOKE_REPEAT`, `LELEKA_SMOKE_SAMPLED`, `LELEKA_SPECULATION_LOG`, `LELEKA_SPEC_BIAS_RATE`, `LELEKA_SPEC_COST_ALPHA`, `LELEKA_SPEC_DECAY`, `LELEKA_SPEC_DRAFT_STEP_MS`, `LELEKA_SPEC_EXPLORE`, `LELEKA_SPEC_MARGIN`, `LELEKA_SPEC_MIN_P_LO`, `LELEKA_SPEC_STATS`, `LELEKA_SPEC_TRACE`, `LELEKA_SPLIT_LOG`, `LELEKA_SSD_KEEPALIVE`, `LELEKA_SSD_KEEPALIVE_MS`, `LELEKA_SSD_KEEPALIVE_WINDOW_S`, `LELEKA_STAGE_PRIORITY`, `LELEKA_STAGE_VERIFY`, `LELEKA_STATE`, `LELEKA_STRA169_`, `LELEKA_STRA169_CANDIDATE_CAPTURE`, `LELEKA_STRA169_CAPTURE_DIR`, `LELEKA_STRA169_EXPERT_PROFILE`, `LELEKA_STRA169_IQ3S_SHARD0`, `LELEKA_STRA169_IQ3S_SHARD1`, `LELEKA_STRA169_KAR_ARCHIVE`, `LELEKA_STRA169_KAR_FD`, `LELEKA_STRA169_KAR_PROVENANCE`, `LELEKA_STRA169_KAR_STAGING`, `LELEKA_STRA169_LAYER0_DIR`, `LELEKA_STRA169_MMQ_REFERENCE_DIR`, `LELEKA_STRA169_MMQ_REFERENCE_MANIFEST_SHA`, `LELEKA_STRA169_MTP_PACK`, `LELEKA_STRA169_MTP_STAGING`, `LELEKA_STRA169_NATIVE_BASELINE`, `LELEKA_STRA169_PAIR_METADATA`, `LELEKA_STRA169_PAIR_METADATA_SHA`, `LELEKA_STRA169_PAIR_OUTPUT`, `LELEKA_STRA169_RUN_COMBINED_BOUNDARIES`, `LELEKA_STRA169_RUN_COMBINED_REUSE`, `LELEKA_STRA169_RUN_FIVE_PUBLIC_CASES`, `LELEKA_STRA169_RUN_FIXED_DRAFT_MOE`, `LELEKA_STRA169_RUN_GDN_BATCH`, `LELEKA_STRA169_RUN_GDN_FUSED_T1`, `LELEKA_STRA169_RUN_GDN_MTP_JOURNAL`, `LELEKA_STRA169_RUN_GDN_PRODUCTS`, `LELEKA_STRA169_RUN_GDN_QK_SLOT`, `LELEKA_STRA169_RUN_GDN_ROW_QUEUE`, `LELEKA_STRA169_RUN_GROUPED_CHUNK_PROOF`, `LELEKA_STRA169_RUN_GROUPED_DOWN`, `LELEKA_STRA169_RUN_GR_DEVICE_GUARD`, `LELEKA_STRA169_RUN_GR_HANDOFF`, `LELEKA_STRA169_RUN_GR_MICROBATCH`, `LELEKA_STRA169_RUN_GR_OUTPUT_WORKSPACE`, `LELEKA_STRA169_RUN_LAYER0_MMQ_DIAGNOSTIC`, `LELEKA_STRA169_RUN_MMQ_NUMERIC`, `LELEKA_STRA169_RUN_MOE_GROUP`, `LELEKA_STRA169_RUN_MOE_PREFILL_BATCH`, `LELEKA_STRA169_RUN_MTP_BATCH_NUMERIC`, `LELEKA_STRA169_RUN_MTP_KV_RING_PROOF`, `LELEKA_STRA169_RUN_NATIVE_RESIDENT_MMQ_MODEL`, `LELEKA_STRA169_RUN_OWNED_ASYNC_COPY`, `LELEKA_STRA169_RUN_PLE_CLOSED_QUEUE`, `LELEKA_STRA169_RUN_PUBLIC_CANDIDATE_ONLY`, `LELEKA_STRA169_RUN_PUBLIC_NATIVE_DOWN_PAIR`, `LELEKA_STRA169_RUN_QSA_ATTENTION_SCRATCH`, `LELEKA_STRA169_RUN_QUEUED_GR`, `LELEKA_STRA169_RUN_RESIDENT_MMQ_MODEL`, `LELEKA_STRA169_RUN_ROUTED_RESIDENT_QUEUE`, `LELEKA_STRA169_RUN_ROUTER_SCRATCH`, `LELEKA_STRA169_RUN_SINGLELOAD_PROOF`, `LELEKA_STRA172_RUN_GROUPED_GU21_GU23`, `LELEKA_STRA172_RUN_GROUPED_GU21_GU23_NC4`, `LELEKA_STRA172_RUN_GR_BATCH_INJECT_WORKSPACE`, `LELEKA_STRA172_RUN_HEAD_GREEDY`, `LELEKA_STRA172_RUN_MMQ_TRIPLET`, `LELEKA_STRA172_RUN_MTP_INPUT_PREFIX`, `LELEKA_STRA172_RUN_OWNED_GATE_UP_UPLOAD`, `LELEKA_STRA172_RUN_QSA_SELECTED_KV`, `LELEKA_STRA172_RUN_ROUTED_COLUMNS_LOAN`, `LELEKA_STRA172_RUN_ROUTED_FINITE_GUARD`, `LELEKA_STRA172_RUN_ROUTED_GROUP_WORKSPACE`, `LELEKA_STRA172_RUN_SHARED_TAIL`, `LELEKA_SUFFIX_RESET`, `LELEKA_SWEEP_CONTEXT`, `LELEKA_SWEEP_KS`, `LELEKA_SWEEP_MAX_NEW`, `LELEKA_SWEEP_REPS`, `LELEKA_S_FP16_ARGS`, `LELEKA_S_GEMV`, `LELEKA_S_GEMV_Q8K`, `LELEKA_S_GEMV_Q8_SPLIT`, `LELEKA_S_GEMV_SPLIT`, `LELEKA_S_Q8_ARGS`, `LELEKA_TOKENIZER_DIR`, `LELEKA_TOKENIZER_REFERENCE`, `LELEKA_TOKENIZER_SEGMENT_CACHE_MIB`, `LELEKA_TOKENIZER_TEXTS`, `LELEKA_TRACE_LADDER`, `LELEKA_TRACE_PLE`, `LELEKA_TRACE_POISON`, `LELEKA_VERIFY_WINDOW_GPU`, `LELEKA_WARM`, `LELEKA_WINDOW_MODULE_CACHE`, `LELEKA_WSL_DISTRO`, `STRATA_ADAPT_CALLBACK_WARMUP`, `STRATA_ARENA_LOCK`, `STRATA_ARENA_PIN_GIB`, `STRATA_COMMIT_SYNC`, `STRATA_CPU_YMM`, `STRATA_DEC_BATCH`, `STRATA_D_FMTS`, `STRATA_FORCE_AVX2`, `STRATA_GU_FMTS`, `STRATA_HC_SPLIT`, `STRATA_IQ_GATHER`, `STRATA_IQ_MT_MIN`, `STRATA_IQ_PREFETCH`, `STRATA_KEYLESS_ROUTING`, `STRATA_KQ256`, `STRATA_KV_MAIN_OFF`, `STRATA_KV_RING_OFF`, `STRATA_KV_ROT`, `STRATA_LOGPOS`, `STRATA_LOGPOS_TOPK`, `STRATA_NAN_GUARD`, `STRATA_NAN_INJECT`, `STRATA_NO_IQ256`, `STRATA_NO_IQ4NL`, `STRATA_NO_IQ512`, `STRATA_OLD_IQ_MMVQ`, `STRATA_PARTIAL_PIN`, `STRATA_PARTIAL_PIN_GIB`, `STRATA_POOL_SPIN_US`, `STRATA_PREFILL_ISSUER`, `STRATA_PREFILL_RING`, `STRATA_PROMPT_ATTN_V1`, `STRATA_Q2`, `STRATA_Q2_BLOB_BYTES`, `STRATA_QSA_CLUSTER`, `STRATA_QSA_WARP`, `STRATA_SCORES_MULTI`, `STRATA_SNAPSHOT_FULL_CAPTURE`, `STRATA_STAGER_RING`, `STRATA_STAGER_THREADS`, `STRATA_TEST_CACHE_FAIL`, `STRATA_TEST_VERIFY_STALL`, `STRATA_VERIFY_DEVICE_PLAN`, `STRATA_WATCHDOG_S`, `STRATA_WINDOW_DOWN`, `STRATA_WINDOW_GU` - -## 8. DISPOSITION of a default found lossy or unknown - -A default found lossy is a finding returned to TECH_LEAD for a second-wave fix leaf (revert to a lossless value, or mark the mode experimental and keep it off); this leaf changes -nothing: no profile, no `serve_tuning.rs`, no code, no `engine/strata`, no sealed PTX. A default classed `unknown-until-q_pair` stays shipped until its leaf (STRA-267 on the 5090, -STRA-293 on the laptop) returns a q_pair result; no default found here is classed `lossy` in the sense of section 1 (no output-changing mode is ON in ours). - -### Findings for the second wave - -* F1. The 5090 profile ships `LELEKA_CHAIN=all` (K50-19). The chain kernels are not bit-identical to the Original's at 30-70k context (5,993 of 64,355 rows identical, 697 argmax flips, - 1.08 %, docs/chain-kernels.md:70-79); the profile text and the doc call them within rounding noise by the q_tail_gate rule. No 256k q_pair exists. Needs STRA-267. -* F2. The 5090 profile ships `memory.prefix_cache_tail = reply` (K50-21). docs/prefix-cache.md:168 says EXPERIMENTAL, off by default, not to be defaulted before the agreement gate; - docs/prefix-cache.md:190-198 records it as the profile default after a ~70k-token q_tail_gate. The two statements in one document disagree; the gate was not run at 256k. -* F3. Chunk and grid defaults are rounding-level changes with no q_pair: 8192 on the 5090 (K50-11, K50-22; 8192 answered differently on one 16,000-token prompt, docs/prefill-throughput.md:52-57, - whether rounding or a defect was left open) and 6144 on the laptop (K30-09, K30-22; docs/laptop-vs-vanilla.md:79). No log pair for 8192/2048 or 6144/2048 is in the repository (section 9). -* F4. Adaptive speculative window and `spec_min_p`, expert placement (seed ON, adaptive tier ON, per-layer slots, expert profile) are gated only by docs/quality-gate.md section 8 - (612 rows, short prompts, 5090) and docs/adaptive-spec.md:106-111; neither machine has a 256k q_pair for them. Needs STRA-267 and STRA-293. -* F5. `LELEKA_ORIGINAL_SERVE_CPU_WORKERS` / `cpu_workers`: no record found that the result is independent of the worker count. -* F6. Documentation mismatch, no class: `STRATA_PREFILL_STREAM_MIN` is 4096 in code (`cache_original_prompt.rs:29`) and 1024 in the `original_serve_config.rs:277` comment. -* F7. Handoff correction: vanilla's tail-skip default is at `engine/strata/src/program/generate.cpp:10110-10153`, not at a top-level `generate.cpp`. -* F8. Nothing lossy is ON by default in ours: route tail skip is off (S-27) and there is no CPU prefill share (V-02). The conditional ON defaults of vanilla (section 6) are STRA-247's. - -## 9. q_pair logs for chunk 8192 and 6144 - -Logs that exist for chunk 8192 and for chunk 6144: none. `git ls-files` lists 0 files ending in `.log`; `artifacts/runs` in the main checkout is not populated; the only comparison of -chunk sizes in the repository is a greedy-id comparison on one 16,000-token prompt (docs/prefill-throughput.md:52-57), which is not a q_pair result. docs/laptop-vs-vanilla.md:79 -states that q_pair or R-hash arms 2048 against 6144 were `Not run`. `scripts/quality/q_pair.py` exists (usage: `q_pair.py LOG_A LOG_B [--pass N] [--control LOG_A2]`, exit 0 if every common forced row is identical). - -## 10. Counts printed side by side - -The command outputs are produced by the verification run recorded with the item; the page-side counts are: - -| item | command output (recorded with the item) | page count | -| --- | --- | --- | -| profile key rows, rtx5090-32g | 27 | 27 | -| profile key rows, rtx3080-16g | 27 | 27 | -| names in `original_serve*.rs` | 51 | 51 | -| names in the prefill chunk path files | 14 | 14 | -| route tail skip line 64 | `unwrap_or(0)` default | S-27 | -| CPU prefill share grep | empty output | V-02 ABSENT | - -## 11. Commands run in the worktree and their output (AC1-AC3, q_pair log search) - -``` -$ python -c "import json,sys;f=lambda d:sum(f(v) if isinstance(v,dict) else 1 for v in d.values());print([f(json.load(open(p))) for p in sys.argv[1:]])" deploy/rust-runtime/profiles/rtx5090-32g.json deploy/rust-runtime/profiles/rtx3080-16g.json -[27, 27] -$ grep -rhoE '(LELEKA|STRATA)_[A-Z0-9_]+' crates/leleka-runtime/src --include='original_serve*.rs' | sort -u | wc -l -51 -$ (the prefill chunk path file list of section 5b, 31 files, 0 of them matching original_serve*) grep -hoE '(LELEKA|STRATA)_[A-Z0-9_]+' | sort -u | wc -l -14 -$ sed -n '64p' crates/leleka-runtime/src/qwen_forward/original_serve_residency.rs - let rank = std::env::var("LELEKA_ROUTE_TAIL_SKIP").ok().and_then(|v| v.trim().parse::().ok()).filter(|r| (1..TOP_K as u32).contains(r)).unwrap_or(0); -$ grep -rn -i "prefill.*cpu.*share\|PREFILL_CPU_SHARE" crates scripts -(empty output, exit status 1) -$ ls *.log 2>/dev/null -(empty: none) -$ grep -rn "q_pair" docs/prefill-throughput.md docs/laptop-vs-vanilla.md | head -docs/laptop-vs-vanilla.md:79, 80, 152 (the three lines quoted in K30-09 and section 9); docs/prefill-throughput.md: no match -``` - -Page-side counts: 27 and 27 profile-key rows, 51 names in section 5, 14 names in section 5b. The row for route tail skip is S-27 (line 64 as read in this worktree). +# S6.1 Lossy-default audit of the shipped rtx5090-32g and rtx3080-16g profiles (STRA-250) + +Status: read-only audit, 2026-10-28. Leaf STRA-250 of STRA-245. Branch `claude/stra-250`, base `2457d81d` (the tip of `claude/merge-opt`; every path, line number +and count below was read in that tree, not in the main checkout). Nothing was run on a GPU and no model was loaded: every class is a reading of code, profile files and +recorded documents, with the path and line that carry it. Nothing in the engine, the profiles or `engine/strata` was changed. + +Vanilla defaults belong to STRA-247; this page carries one cross-reference section for them (section 6) and no measurement of vanilla. + +## 1. Classes and scope + +* `lossless`: the default moves bytes, caches, schedules or traces, or a recorded byte comparison shows the output equal; no arithmetic order changes. +* `lossy`: the default changes the output by design (a mode the code itself labels as changing the output). No such mode is ON by default in either shipped profile. +* `unknown-until-q_pair`: the default changes the order of arithmetic or the expert placement (rounding level) and the files read carry no q_pair result for the shipped value + on the shipped machine. The leaf that produces the result is named per row: STRA-267 (S2.5) for the 5090 profile on sm_120, STRA-293 (S3.9) for the laptop profile on sm_86. + The command is `python scripts/quality/q_pair.py LOG_A LOG_B` (exit 0 if every common forced row is identical). + An existing gate that is NOT a q_pair result (q_tail_gate over 30-70k tokens, a 612-row teacher-forced gate on short prompts) is quoted in the row and does not move it out of this class. + +Scope (bounded, round 5 of the STRA-245 tree): (a) every key of both profile files, sections 2 and 3; (b) the admitted sets of `serve_tuning.rs`, section 4; +(c) the `LELEKA_*` / `STRATA_*` names in `original_serve*.rs` (section 5) and in the prefill chunk path files (section 5b); (d) all other names listed by name, section 7. + +## 2. rtx5090-32g profile: one row per key (27 rows; classes: 19 lossless, 0 lossy, 8 unknown-until-q_pair) + +| row | key | shipped value | class | evidence | +| --- | --- | --- | --- | --- | +| K50-01 | `name` | rtx5090-32g | lossless | deploy/rust-runtime/profiles/rtx5090-32g.json:2; label only (crates/deploy/src/profile.rs:238) | +| K50-02 | `description` | prose | lossless | deploy/rust-runtime/profiles/rtx5090-32g.json:3; no engine effect (crates/deploy/src/profile.rs:239); it states `Not a formally quality-gated profile` | +| K50-03 | `select.sm_min` | 120 | lossless | deploy/rust-runtime/profiles/rtx5090-32g.json:4; selector only, `Profile::matches` (crates/deploy/src/profile.rs:226-233, 381-386) | +| K50-04 | `select.sm_max` | 130 | lossless | deploy/rust-runtime/profiles/rtx5090-32g.json:4; selector only (crates/deploy/src/profile.rs:226-233) | +| K50-05 | `select.vram_mib_min` | 30000 | lossless | deploy/rust-runtime/profiles/rtx5090-32g.json:4; selector only (crates/deploy/src/profile.rs:226-233) | +| K50-06 | `select.vram_mib_max` | 1000000 | lossless | deploy/rust-runtime/profiles/rtx5090-32g.json:4; selector only (crates/deploy/src/profile.rs:226-233) | +| K50-07 | `gpu_budget_bytes` | 32212254720 (30 GiB) | unknown-until-q_pair | deploy/rust-runtime/profiles/rtx5090-32g.json:5; `--gpu-budget` (crates/deploy/src/config.rs:176-179); sizes the VRAM expert tier, i.e. which experts compute on the GPU and which on the CPU pool; the tier changes placement only (docs/quality-gate.md section 8: P1-P6, 612 rows, d_top1 p99 0.176-0.235, flips 1.6-2.3 %, short prompts, 5090); no CPU-leg versus GPU-leg bit-identity record was found in the files read; STRA-267 (5090, sm_120); q_pair logs: none | +| K50-08 | `spec_min_p` | 0.0 | unknown-until-q_pair | deploy/rust-runtime/profiles/rtx5090-32g.json:6; `--spec-min-p` (crates/deploy/src/config.rs:218-220); ceiling of the adaptive draft floor, drafts only, verification untouched (docs/adaptive-spec.md:106-111, 122-124) but window shape changes batch rounding: adaptive identical to the fixed-4 pass in 16/30 requests, fixed-3 13/30, fixed-6 13/30, fixed-4 against its own repeats 15/20 (docs/adaptive-spec.md:106-111); STRA-267 (5090, sm_120); q_pair logs: none | +| K50-09 | `expert_profile` | data/expert-profile.bin | unknown-until-q_pair | deploy/rust-runtime/profiles/rtx5090-32g.json:7; starting VRAM placement (`LELEKA_ORIGINAL_SERVE_EXPERT_PROFILE` set by `plan.rs:270-279`; read at crates/leleka-runtime/src/qwen_forward/original_serve_residency.rs:224); placement class as K50-07; STRA-267 (5090, sm_120); q_pair logs: none | +| K50-10 | `context_tokens` | 262144 | lossless | deploy/rust-runtime/profiles/rtx5090-32g.json:8; `--context-tokens` (crates/deploy/src/config.rs:180-181), admitted 1..=262144 (crates/deploy/src/profile.rs:325-327); a ceiling, no arithmetic | +| K50-11 | `prefill_capacity` | 8192 | unknown-until-q_pair | deploy/rust-runtime/profiles/rtx5090-32g.json:9; `--original-prefill-capacity` (crates/deploy/src/config.rs:206-208), admitted set {256,512,1024,2048,3072,4096,6144,8192} (crates/deploy/src/profile.rs:44); chunk size changes the rounding order of the prompt path: 16,000 tokens answered identically at 2048, 4096, 6144 and differently at 8192 on one prompt (docs/prefill-throughput.md:52-57, open: rounding or defect); STRA-267 (5090, sm_120); q_pair logs: none | +| K50-12 | `kar_source` | memfd | lossless | deploy/rust-runtime/profiles/rtx5090-32g.json:10; where the pinned archive bytes live (crates/deploy/src/profile.rs:47-54; digest pinned crates/deploy/src/profile.rs:15-16); same bytes | +| K50-13 | `expert_source` | resident | lossless | deploy/rust-runtime/profiles/rtx5090-32g.json:11; where the routed-expert bytes live (crates/deploy/src/profile.rs:65-73); same bytes | +| K50-14 | `min_driver_major` | 595 | lossless | deploy/rust-runtime/profiles/rtx5090-32g.json:12; preflight gate only (crates/deploy/src/profile.rs:257) | +| K50-15 | `min_vram_total_mib` | 30000 | lossless | deploy/rust-runtime/profiles/rtx5090-32g.json:13; preflight gate only (crates/deploy/src/profile.rs:258) | +| K50-16 | `min_ram_total_bytes` | 107374182400 | lossless | deploy/rust-runtime/profiles/rtx5090-32g.json:14; preflight gate only (crates/deploy/src/profile.rs:263) | +| K50-17 | `min_ram_available_bytes` | 113000000000 | lossless | deploy/rust-runtime/profiles/rtx5090-32g.json:15; preflight gate only (crates/deploy/src/profile.rs:264) | +| K50-18 | `engine_env.LELEKA_ORIGINAL_SERVE_EXPERT_PER_LAYER` | yes | unknown-until-q_pair | deploy/rust-runtime/profiles/rtx5090-32g.json:16; per-layer slot sizing of the VRAM tier (crates/leleka-runtime/src/qwen_forward/original_serve_residency.rs:225-227); placement class as K50-07; STRA-267 (5090, sm_120); q_pair logs: none | +| K50-19 | `engine_env.LELEKA_CHAIN` | all | unknown-until-q_pair | deploy/rust-runtime/profiles/rtx5090-32g.json:16; groups glue, ab, gr, tiny, head, mtp (not qsa) (crates/cuda-driver/src/original_verify_window_chain.rs:62-87); NOT bit-identical at 30-70k context: 5,993 of 64,355 rows identical, d_top1 p99 0.327, max 4.31, argmax flips 697 (1.08 %), control for rounding noise p99 0.394 / flips 1.45 % (docs/chain-kernels.md:70-79); passes the q_tail_gate 1.25x rule only, 5090, 30-70k context, no 256k q_pair; FINDING F1; STRA-267 (5090, sm_120); q_pair logs: none | +| K50-20 | `memory.prefix_cache_mib` | auto | lossless | deploy/rust-runtime/profiles/rtx5090-32g.json:17; cache budget (crates/deploy/src/profile.rs:90-92, 166-168); a hit reproduces the full read bit for bit (docs/prefix-cache.md:34-36, job 922 equality, 14 requests); grid nodes exact by construction (docs/prefix-cache.md:169) | +| K50-21 | `memory.prefix_cache_tail` | reply | unknown-until-q_pair | deploy/rust-runtime/profiles/rtx5090-32g.json:17; request-end checkpoints at the end of the decode; the cells past the prompt are decode-produced, so the state is not what a prefill would produce (docs/prefix-cache.md:165-168); the same doc marks `reply` EXPERIMENTAL and not to be defaulted before the agreement gate (line 168) and also records it as the 5090 default (lines 190-198: d_top1 p99 0.401, flips 1.45 % against a control of p99 0.394 / 1.45 %, ~70k context, q_tail_gate); FINDING F2; STRA-267 (5090, sm_120); q_pair logs: none | +| K50-22 | `memory.prefix_cache_block` | 8192 | unknown-until-q_pair | deploy/rust-runtime/profiles/rtx5090-32g.json:17; tokens per prefix block and chunk-grid step, caps every chunk (crates/deploy/src/profile.rs:97-100, 172-176); grid nodes are exact by construction but the grid sets the chunk cut, same class as K50-11 (8192 differed on one prompt, docs/prefill-throughput.md:52-57); STRA-267 (5090, sm_120); q_pair logs: none | +| K50-23 | `memory.soft_floor_mib` | 4096 | lossless | deploy/rust-runtime/profiles/rtx5090-32g.json:17; memory governor: caches shed below it (crates/deploy/src/profile.rs:104-106, 194-196); sheds reuse, never values | +| K50-24 | `memory.hard_floor_mib` | 2048 | lossless | deploy/rust-runtime/profiles/rtx5090-32g.json:17; new requests refused with 503 below it (crates/deploy/src/profile.rs:107-109, 197-200) | +| K50-25 | `memory.reserve_mib` | 2048 | lossless | deploy/rust-runtime/profiles/rtx5090-32g.json:17; slack above the soft floor (crates/deploy/src/profile.rs:110-112, 201-204) | +| K50-26 | `memory.lock` | try | lossless | deploy/rust-runtime/profiles/rtx5090-32g.json:17; keeps the sealed memfd resident (crates/deploy/src/profile.rs:116-118, 209) | +| K50-27 | `memory.heal` | true | lossless | deploy/rust-runtime/profiles/rtx5090-32g.json:17; pulls swapped memfd pages back (crates/deploy/src/profile.rs:119-121, 213-216) | + +## 3. rtx3080-16g profile: one row per key (27 rows; classes: 22 lossless, 0 lossy, 5 unknown-until-q_pair) + +`engine_env` is `{}` in this file and contributes 0 keys (the AC1 one-liner counts leaves). Absent keys take the engine's defaults, which section 5 classifies: `spec_min_p` absent += 0.0 (`crates/leleka-runtime/src/backend_original_serve.rs:152`), `LELEKA_CHAIN` absent = off. The deploy layer adds `LELEKA_ORIGINAL_SERVE_EXPERT_SLOTS=auto` and +`LELEKA_ORIGINAL_SERVE_EXPERT_PROFILE` when the profile file validates (`crates/deploy/src/plan.rs:270-279`) and the resource preset adds the CPU worker count and the mapped +working set (`crates/deploy/src/resources.rs:330-337`). + +| row | key | shipped value | class | evidence | +| --- | --- | --- | --- | --- | +| K30-01 | `name` | rtx3080-16g | lossless | deploy/rust-runtime/profiles/rtx3080-16g.json:2; label only (crates/deploy/src/profile.rs:238) | +| K30-02 | `description` | prose | lossless | deploy/rust-runtime/profiles/rtx3080-16g.json:3; no engine effect; it states `Experimental` and `no quality claim` | +| K30-03 | `select.sm_min` | 80 | lossless | deploy/rust-runtime/profiles/rtx3080-16g.json:4; selector only (crates/deploy/src/profile.rs:226-233) | +| K30-04 | `select.sm_max` | 120 | lossless | deploy/rust-runtime/profiles/rtx3080-16g.json:4; selector only (crates/deploy/src/profile.rs:226-233) | +| K30-05 | `select.vram_mib_min` | 14000 | lossless | deploy/rust-runtime/profiles/rtx3080-16g.json:4; selector only (crates/deploy/src/profile.rs:226-233) | +| K30-06 | `select.vram_mib_max` | 24000 | lossless | deploy/rust-runtime/profiles/rtx3080-16g.json:4; selector only (crates/deploy/src/profile.rs:226-233) | +| K30-07 | `gpu_budget_bytes` | 16106127360 (15 GiB) | unknown-until-q_pair | deploy/rust-runtime/profiles/rtx3080-16g.json:5; `--gpu-budget` (crates/deploy/src/config.rs:176-179), lowered by the workstation preset to 13 GiB (docs/laptop-vs-vanilla.md:152); sizes the VRAM expert tier, placement class as K50-07; STRA-293 (laptop, sm_86); q_pair logs: none | +| K30-08 | `context_tokens` | 262144 | lossless | deploy/rust-runtime/profiles/rtx3080-16g.json:6; `--context-tokens` (crates/deploy/src/config.rs:180-181); a ceiling, no arithmetic | +| K30-09 | `prefill_capacity` | 6144 | unknown-until-q_pair | deploy/rust-runtime/profiles/rtx3080-16g.json:7; `--original-prefill-capacity` (crates/deploy/src/config.rs:206-208); `6144 changes the rounding order of the prompt path ... no quality gate yet` (docs/laptop-vs-vanilla.md:79, 152); 16,000 tokens identical at 2048/4096/6144 on one prompt (docs/prefill-throughput.md:52-57); q_pair or R-hash arms 2048 against 6144 `Not run` (docs/laptop-vs-vanilla.md:79); STRA-293 (laptop, sm_86); q_pair logs: none | +| K30-10 | `kar_source` | file | lossless | deploy/rust-runtime/profiles/rtx3080-16g.json:8; where the archive bytes live (crates/deploy/src/profile.rs:47-54); same bytes | +| K30-11 | `expert_source` | mapped | lossless | deploy/rust-runtime/profiles/rtx3080-16g.json:9; where the routed-expert bytes live (crates/deploy/src/profile.rs:65-73); same bytes | +| K30-12 | `min_driver_major` | 595 | lossless | deploy/rust-runtime/profiles/rtx3080-16g.json:10; preflight gate only (crates/deploy/src/profile.rs:257) | +| K30-13 | `min_vram_total_mib` | 14000 | lossless | deploy/rust-runtime/profiles/rtx3080-16g.json:11; preflight gate only (crates/deploy/src/profile.rs:258) | +| K30-14 | `min_vram_free_mib` | 14500 | lossless | deploy/rust-runtime/profiles/rtx3080-16g.json:12; preflight gate only (crates/deploy/src/profile.rs:259-262) | +| K30-15 | `min_ram_total_bytes` | 23622320128 | lossless | deploy/rust-runtime/profiles/rtx3080-16g.json:13; preflight gate only (crates/deploy/src/profile.rs:263) | +| K30-16 | `min_ram_available_bytes` | 10737418240 | lossless | deploy/rust-runtime/profiles/rtx3080-16g.json:14; preflight gate only (crates/deploy/src/profile.rs:264) | +| K30-17 | `wsl_memory_gib` | 32 | lossless | deploy/rust-runtime/profiles/rtx3080-16g.json:15; advice only for `.wslconfig` (crates/deploy/src/profile.rs:265-267) | +| K30-18 | `expert_profile` | data/expert-profile.bin | unknown-until-q_pair | deploy/rust-runtime/profiles/rtx3080-16g.json:16; starting VRAM placement (set as `LELEKA_ORIGINAL_SERVE_EXPERT_PROFILE` by plan.rs:270-279 when the file validates); placement class as K50-07; STRA-293 (laptop, sm_86); q_pair logs: none | +| K30-19 | `expert_profile_sha256` | 8f59b4aa...975baf | lossless | deploy/rust-runtime/profiles/rtx3080-16g.json:17; integrity pin of the profile file (crates/deploy/src/profile.rs:271-272, 345-349) | +| K30-20 | `memory.prefix_cache_mib` | auto | lossless | deploy/rust-runtime/profiles/rtx3080-16g.json:19; cache budget; a hit reproduces the full read bit for bit (docs/prefix-cache.md:34-36); grid nodes exact by construction (docs/prefix-cache.md:169) | +| K30-21 | `memory.prefix_cache_tail` | prompt | unknown-until-q_pair | deploy/rust-runtime/profiles/rtx3080-16g.json:19; one checkpoint at n-1 at the end of the prefill = an extra chunk boundary; differs from a grid-only full read by where the chunks were cut, rounding level, same as any chunk-size change (docs/prefix-cache.md:164, 169-170); docs/laptop-vs-vanilla.md:80 (tail only moves where a checkpoint is taken; run A not checked with q_pair); STRA-293 (laptop, sm_86); q_pair logs: none | +| K30-22 | `memory.prefix_cache_block` | 6144 | unknown-until-q_pair | deploy/rust-runtime/profiles/rtx3080-16g.json:19; grid step caps every chunk (crates/deploy/src/profile.rs:97-100); same class as K30-09 (docs/laptop-vs-vanilla.md:79, 152); STRA-293 (laptop, sm_86); q_pair logs: none | +| K30-23 | `memory.soft_floor_mib` | 4096 | lossless | deploy/rust-runtime/profiles/rtx3080-16g.json:19; memory governor floor (crates/deploy/src/profile.rs:104-106); raised by the preset (docs/laptop-vs-vanilla.md); values untouched | +| K30-24 | `memory.hard_floor_mib` | 2048 | lossless | deploy/rust-runtime/profiles/rtx3080-16g.json:19; refusal floor (crates/deploy/src/profile.rs:107-109) | +| K30-25 | `memory.reserve_mib` | 1024 | lossless | deploy/rust-runtime/profiles/rtx3080-16g.json:19; slack above the soft floor (crates/deploy/src/profile.rs:110-112) | +| K30-26 | `memory.lock` | off | lossless | deploy/rust-runtime/profiles/rtx3080-16g.json:19; no memfd on this profile (crates/deploy/src/profile.rs:116-118) | +| K30-27 | `memory.heal` | false | lossless | deploy/rust-runtime/profiles/rtx3080-16g.json:19; no memfd on this profile (crates/deploy/src/profile.rs:119-121) | + +## 4. Admitted sets of `crates/leleka-runtime/src/serve_tuning.rs` (and the matching profile checks) + +| row | set | where | class | evidence | +| --- | --- | --- | --- | --- | +| A-01 | prefill chunk in {256, 512, 1024, 2048, 3072, 4096, 6144, 8192} | `serve_tuning.rs:14,68-70`; `crates/deploy/src/profile.rs:44,328-334` | unknown-until-q_pair | every member is a different chunk cut, rounding level; the engine default is 2048 (`original_serve_stack.rs:109`); 6144 and 8192 are the shipped values (K30-09, K50-11); STRA-267 (5090, sm_120); STRA-293 (laptop, sm_86); q_pair logs: none | +| A-02 | prefix block a multiple of 256 and <= 8192 (0 = the prefill chunk) and not larger than the chunk | `serve_tuning.rs:122-126,146-152`; `profile.rs:140-144` | unknown-until-q_pair | the block is the chunk-grid step; same class as A-01; STRA-267 (5090, sm_120); STRA-293 (laptop, sm_86); q_pair logs: none | +| A-03 | cpu_workers 1..=15 | `serve_tuning.rs:85-93` (engine pool admits 1..=64 at `original_serve_stack.rs:158`) | unknown-until-q_pair | no record of worker-count independence of the result in the files read; STRA-267 (5090, sm_120); STRA-293 (laptop, sm_86); q_pair logs: none | +| A-04 | context_tokens 1..=262144 | `serve_tuning.rs:58-66` | lossless | a ceiling | +| A-05 | kv_resident 0 or >= 20480, fixed for the life of the process; default 32768 | `serve_tuning.rs:76-84,16` | lossless | resident window of the same int8 cells; streaming of K/V, not a format change | +| A-06 | spec_min_p finite within 0..=1 | `serve_tuning.rs:94-102` | unknown-until-q_pair | see K50-08 / SRV `LELEKA_SPEC_ADAPTIVE`; STRA-267 (5090, sm_120); STRA-293 (laptop, sm_86) | +| A-07 | prefix_cache_mib `auto` / `off` / `0` / MiB; prefix_cache_tail off / prompt / reply; prefix_retention_min | `serve_tuning.rs:107-131` | unknown-until-q_pair | the tail value `reply` / `prompt` is the unknown part (K50-21, K30-21); budget and retention are lossless; STRA-267 (5090, sm_120); STRA-293 (laptop, sm_86) | + +## 5. Names read on the serve path in `original_serve*.rs`: 51 distinct names (38 lossless, 0 lossy, 13 unknown-until-q_pair) + +Command: `grep -rhoE '(LELEKA|STRATA)_[A-Z0-9_]+' crates/leleka-runtime/src --include='original_serve*.rs' | sort -u | wc -l` (files: 16, all under +`crates/leleka-runtime/src/qwen_forward/`, among them `original_serve_residency.rs`). The grep also matches comment mentions and the prefix token `LELEKA_ORIGINAL_SERVE_`; each is a +row. "Unset value" is the value in force when the variable is absent. Column "evidence" quotes the code or document that carries the class. + +| row | name | file:line | unset value | class | evidence | +| --- | --- | --- | --- | --- | --- | +| S-01 | `LELEKA_ADAPT_DECAY` | crates/leleka-runtime/src/qwen_forward/original_serve_residency.rs:443,448 | 0.7 (generate.cpp constant) | unknown-until-q_pair | adaptive-tier count decay, placement; adapt_every 4 / adapt_swaps 96 are ON (crates/leleka-runtime/src/qwen_forward/original_serve_residency.rs:174-175); docs/quality-gate.md section 8 P2/P6 PASS, 612 rows; STRA-267 (5090, sm_120); STRA-293 (laptop, sm_86) | +| S-02 | `LELEKA_ADAPT_MARGIN` | crates/leleka-runtime/src/qwen_forward/original_serve_residency.rs:443,448 | 1.5 | unknown-until-q_pair | adaptive-tier swap margin, placement; as LELEKA_ADAPT_DECAY | +| S-03 | `LELEKA_ADAPT_MIN_COUNT` | crates/leleka-runtime/src/qwen_forward/original_serve_residency.rs:442,448 | 2.0 | unknown-until-q_pair | adaptive-tier swap threshold, placement; as LELEKA_ADAPT_DECAY | +| S-04 | `LELEKA_BRINGUP_TRACE` | crates/leleka-runtime/src/qwen_forward/original_serve_pool.rs:34 | off | lossless | timing trace only (also read in the prefill path, row P-06) | +| S-05 | `LELEKA_CHAIN` | crates/leleka-runtime/src/qwen_forward/original_serve_config.rs:176 (comment; read at crates/cuda-driver/src/original_verify_window_chain.rs:62) | off (no group) | lossless | unset on the laptop profile; the 5090 profile sets `all`, see K50-19 (U, finding F1) | +| S-06 | `LELEKA_CPU_POOL` | crates/leleka-runtime/src/qwen_forward/original_serve_pool.rs:176,190 | Direct path | lossless | same arithmetic as the legacy path, copies skipped (pool.rs:179-181); `crosscheck` mode compares every float bit for bit (pool.rs:184-186); no recorded crosscheck result was read | +| S-07 | `LELEKA_CPU_POOL_FENCE` | crates/leleka-runtime/src/qwen_forward/original_serve_pool.rs:208,447 | one fence per group | lossless | synchronisation granularity only | +| S-08 | `LELEKA_CPU_POOL_LOOKAHEAD` | crates/leleka-runtime/src/qwen_forward/original_serve_pool.rs:210,453 | off (opt-in) | lossless | router lookahead is opt-in; unset = off | +| S-09 | `LELEKA_CPU_POOL_PLAN` | crates/leleka-runtime/src/qwen_forward/original_serve_stack.rs:156,159 | off (15 workers) | lossless | unset = constant 15 workers (stack.rs:112); `on` = pool_plan::default_workers | +| S-10 | `LELEKA_CPU_PREFETCH` | crates/leleka-runtime/src/qwen_forward/original_serve_pool.rs:219,459; crates/leleka-runtime/src/qwen_forward/prefetch_policy.rs:19-34 | Windows: adaptive (cheaper of pass / no pass by moving average); elsewhere: on | lossless | the laptop prefetch policy: `The bytes read and the arithmetic are the same in both modes` (prefetch_policy.rs:8); measured 8.70 -> 10.58 tok/s warm, 6.85 vs 5.22 cold (prefetch_policy.rs:4-6); timing choice, no q_pair needed | +| S-11 | `LELEKA_CPU_PREFETCH_OFF_FILE` | crates/leleka-runtime/src/qwen_forward/original_serve_pool.rs:81,84 | no file = no effect | lossless | A/B bring-up file | +| S-12 | `LELEKA_EXPERT_TIER_GPU` | crates/leleka-runtime/src/qwen_forward/original_serve_residency_gpu.rs:1,116,118 | unset (ignored test) | lossless | gates an #[ignore] test, not production | +| S-13 | `LELEKA_OPEN_CACHE` | crates/leleka-runtime/src/qwen_forward/original_serve_pool.rs:216,457 | off (opt-in) | lossless | unset = off; `not measured on a device yet` (pool.rs:216) | +| S-14 | `LELEKA_ORIGINAL_SERVE_` | crates/leleka-runtime/src/qwen_forward/original_serve_residency.rs:219 | prefix token of a format string | lossless | not a switch: `format!("LELEKA_ORIGINAL_SERVE_{name}")`; its members are the rows LELEKA_ORIGINAL_SERVE_* below plus names listed in section 7 (e.g. _EXPERT_PER_LAYER, _PCIE_FRAC, _PREFILL_BORROW, _CAPACITY, _KV_RESIDENT) | +| S-15 | `LELEKA_ORIGINAL_SERVE_CPU_WORKERS` | crates/leleka-runtime/src/qwen_forward/original_serve_stack.rs:155,158 | 15 (stack.rs:112); preset may set it (crates/deploy/src/resources.rs:335-337) | unknown-until-q_pair | worker count of the CPU expert pool, admitted 1..=64 here and 1..=15 by serve_tuning.rs:86; no record that the result is independent of the worker count was found in the files read; STRA-267 (5090, sm_120); STRA-293 (laptop, sm_86); q_pair logs: none | +| S-16 | `LELEKA_ORIGINAL_SERVE_DUMP_ROUTING` | crates/leleka-runtime/src/qwen_forward/original_serve_residency.rs:703,718 | off | lossless | writes a routing file, no effect on values | +| S-17 | `LELEKA_ORIGINAL_SERVE_EXPERT_PROFILE` | crates/leleka-runtime/src/qwen_forward/original_serve_residency.rs:224 | none; deploy sets it when the profile file validates (plan.rs:270-279) | unknown-until-q_pair | starting placement, K50-09 / K30-18; STRA-267 (5090, sm_120); STRA-293 (laptop, sm_86) | +| S-18 | `LELEKA_ORIGINAL_SERVE_EXPERT_SLOTS` | crates/leleka-runtime/src/qwen_forward/original_serve_residency.rs:214,221 | 0 (tier off); deploy sets `auto` (plan.rs:270-273) | unknown-until-q_pair | VRAM tier size; the shipped runs have the tier ON; placement class as K50-07; STRA-267 (5090, sm_120); STRA-293 (laptop, sm_86) | +| S-19 | `LELEKA_ORIGINAL_SERVE_SEED` | crates/leleka-runtime/src/qwen_forward/original_serve_residency.rs:145,260-269; crates/leleka-runtime/src/qwen_forward/original_serve_seed.rs:1,29-30 | ON, up to 4096 swaps | unknown-until-q_pair | prompt-routing seed, placement only; docs/quality-gate.md section 8: P5 vs P1 p99 0.146 / max 0.447, P6 shipped default p99 0.235 (+7 % over the Original's 0.219), flips 2.3 %, verdict PASS, 612 rows, short prompts; STRA-267 (5090, sm_120); STRA-293 (laptop, sm_86) | +| S-20 | `LELEKA_PCIE_AUTO` | crates/leleka-runtime/src/qwen_forward/original_serve_residency.rs:557,576,616,638 | off (only `lag` enables) | lossless | unset = fixed share; `Only the split changes, never what an expert computes` (residency.rs:561-562) | +| S-21 | `LELEKA_PCIE_LOCKED_ONLY` | crates/leleka-runtime/src/qwen_forward/original_serve_residency.rs:328,434,438,796 | off | lossless | unset = unrestricted split | +| S-22 | `LELEKA_PREFILL_LOAN_TIERS` | crates/leleka-runtime/src/qwen_forward/original_serve_stack.rs:145,219,222,305 | on in the shipped 5090 profiles (engine default off) | lossless | identity PASS (chunk residual hashes equal) and paired A/B n=10: TTFT sum -3.0 s +-0.3; unset = full loan | +| S-23 | `LELEKA_PREFIX_RETENTION_S` | crates/leleka-runtime/src/qwen_forward/original_serve_prefix.rs:77,80 | 3600 s | lossless | cache lifetime only; the profile `prefix_retention_min` is absent in both files | +| S-24 | `LELEKA_PREFIX_TRACE` | crates/leleka-runtime/src/qwen_forward/original_serve_stack.rs:1464,1469 | off | lossless | operator text only | +| S-25 | `LELEKA_QSA_CLUSTER` | crates/leleka-runtime/src/qwen_forward/original_serve_verifier.rs:31,272-273 | ON (QSA_CLUSTER_DEFAULT = true; the driver turns it off below sm_90, so off on the sm_86 laptop) | lossless | cluster decode top-k writes the same ids as qsa_topk_ref in 24 model-free cases; end to end q_tail_gate over 1,502 forced rows: d_top1 median/p99/max 0.0000 and 0 argmax flips for all 7 arms (docs/upstream-port-plan.md:42, 142-143) | +| S-26 | `LELEKA_REFILL_DEFER` | crates/leleka-runtime/src/qwen_forward/original_serve_residency.rs:1155,1161; crates/leleka-runtime/src/qwen_forward/original_serve_stack.rs:316 | off (EXPERIMENTAL) | lossless | unset = off | +| S-27 | `LELEKA_ROUTE_TAIL_SKIP` | crates/leleka-runtime/src/qwen_forward/original_serve_residency.rs:52,64,87 | 0 = OFF (`unwrap_or(0)` at line 64) | lossless | ours is off by default; the mode is lossy (`changes the output`, residency.rs:51-55) and would be class lossy if enabled; vanilla's default differs, see section 6 | +| S-28 | `LELEKA_ROUTE_TAIL_SKIP_MAX_CACHED` | crates/leleka-runtime/src/qwen_forward/original_serve_residency.rs:54,80 | 90.0 (percent) | lossless | only consulted when tail skip is on | +| S-29 | `LELEKA_SEED_TRACE` | crates/leleka-runtime/src/qwen_forward/original_serve_stack.rs:314,1253,1260,1266,1296 | off | lossless | trace only | +| S-30 | `LELEKA_SERVE_OVERLAP` | crates/leleka-runtime/src/qwen_forward/original_serve_native.rs:117,121 | ON (draft enqueued behind the commit event, generate.cpp order) | lossless | enqueue order of already-defined work; `off` is the earlier serialized order | +| S-31 | `LELEKA_SERVE_PROFILE` | crates/leleka-runtime/src/qwen_forward/original_serve_profile.rs:1,9,12; crates/leleka-runtime/src/qwen_forward/original_serve_stack.rs:1561 | off | lossless | span timing only | +| S-32 | `LELEKA_SERVE_PUBLISH` | crates/leleka-runtime/src/qwen_forward/original_serve_host.rs:119,122,409 | batched publication | lossless | same twelve index checkpoints, one batch versus one by one | +| S-33 | `LELEKA_SERVE_SWAP_WAIT` | crates/leleka-runtime/src/qwen_forward/original_serve_residency.rs:947,981,984 | ON (wait for adaptive swaps at a round start) | lossless | makes `the resident set no longer depend on when the copies finished` (residency.rs:944-946); timing only | +| S-34 | `LELEKA_SPAN_CACHE` | crates/leleka-runtime/src/qwen_forward/original_serve_residency.rs:528,540 | ON | lossless | caches span lookups; `off` is the A/B control | +| S-35 | `LELEKA_SPEC` | crates/leleka-runtime/src/qwen_forward/original_serve_engine.rs:376,384,390,398,1076 | unset = mode17 (verify window 6, MTP window 4) unless adaptive | unknown-until-q_pair | window width; verified tokens are the verifier's, width changes batch rounding (docs/adaptive-spec.md:106-111); STRA-267 (5090, sm_120); STRA-293 (laptop, sm_86) | +| S-36 | `LELEKA_SPEC_ADAPTIVE` | crates/leleka-runtime/src/qwen_forward/original_serve_engine.rs:354,363,378,389,397-405 | ON (ADAPTIVE_DEFAULT = true, engine.rs:354) | unknown-until-q_pair | adaptive window is the shipped default; exactness argued by verification, measured 16/30 identical against fixed-4 (docs/adaptive-spec.md:106-111); STRA-267 (5090, sm_120); STRA-293 (laptop, sm_86); q_pair logs: none | +| S-37 | `LELEKA_SPEC_ADAPTIVE_MAX_T` | crates/leleka-runtime/src/qwen_forward/original_serve_engine.rs:378,391 | 8 (MAX_T) | unknown-until-q_pair | widest adaptive window; as LELEKA_SPEC_ADAPTIVE | +| S-38 | `LELEKA_SPEC_ARMS` | crates/leleka-runtime/src/qwen_forward/original_serve_engine.rs:410,414; crates/leleka-runtime/src/qwen_forward/original_serve_stack.rs:273,710 | none (empty) | lossless | A/B harness switch, unset = single policy | +| S-39 | `LELEKA_SPEC_MTP_MAX_T` | crates/leleka-runtime/src/qwen_forward/original_serve_engine.rs:377,387 | spec (4) or the adaptive maximum | unknown-until-q_pair | draft chain length; as LELEKA_SPEC_ADAPTIVE | +| S-40 | `LELEKA_SPEC_SUFFIX` | crates/leleka-runtime/src/qwen_forward/original_serve_engine.rs:377,388 | 3 (suffix draft ON, mode17 SUFFIX = 3) | unknown-until-q_pair | prompt-lookup drafting changes the window contents; as LELEKA_SPEC_ADAPTIVE | +| S-41 | `LELEKA_TRACE_LOGPROBS` | crates/leleka-runtime/src/qwen_forward/original_serve_native.rs:110,162 | off | lossless | diagnostic dump | +| S-42 | `LELEKA_TRACE_RESIDUAL` | crates/leleka-runtime/src/qwen_forward/original_serve_native.rs:114,171 | off | lossless | diagnostic dump | +| S-43 | `STRATA_CKPT_REREAD` | crates/leleka-runtime/src/qwen_forward/original_serve_conversation.rs:37,47,59,234; crates/leleka-runtime/src/qwen_forward/original_serve_stack.rs:803,1184 | off (checkpoints are restored) | lossless | a check of the checkpoint (answer must match the restored one token for token), not a default | +| S-44 | `STRATA_MTP_PREFILL_SYNC` | crates/leleka-runtime/src/qwen_forward/original_serve_config.rs:197 | unset (comment; per_group_sync false) | lossless | named in a comment only, not read in ours; synchronisation granularity | +| S-45 | `STRATA_OLD_SAMPLER` | crates/leleka-runtime/src/qwen_forward/original_serve_config.rs:203,208,373-375 | unset = Split top-k path | unknown-until-q_pair | sampler kernel choice mirrors sampler.cu (config.rs:203-205); the q_pair corpus is greedy / teacher-forced and does not exercise sampled requests, so a q_pair result cannot settle it; STRA-267 (5090, sm_120); STRA-293 (laptop, sm_86) | +| S-46 | `STRATA_PREFILL_STREAM_MIN` | crates/leleka-runtime/src/qwen_forward/original_serve_config.rs:277 (comment: 1024); crates/leleka-runtime/src/qwen_forward/cache_original_prompt.rs:12,29 (code: 4096) | 4096 rows (code); the config.rs comment says 1024 (finding F6) | lossless | copy ordering of expert streaming; `identical greedy ids` at chunk 8192, +13..27 % prefill tok/s (cache_original_prompt.rs:16-17); also row P-14 | +| S-47 | `STRATA_ROPE_TABLE` | crates/leleka-runtime/src/qwen_forward/original_serve_config.rs:120 | unset = analytic form | lossless | named in a comment: the table form is `not supported here` | +| S-48 | `STRATA_ROUTE_TAIL_SKIP` | crates/leleka-runtime/src/qwen_forward/original_serve_residency.rs:51,311 | not read in ours (comments) | lossless | upstream name in comments; ours reads LELEKA_ROUTE_TAIL_SKIP | +| S-49 | `STRATA_SAMPLER_ONE_BLOCK` | crates/leleka-runtime/src/qwen_forward/original_serve_config.rs:204,210,372-373 | off | lossless | unset = Split path (see STRATA_OLD_SAMPLER) | +| S-50 | `STRATA_SPEC_COUPLED` | crates/leleka-runtime/src/qwen_forward/original_serve_engine.rs:406,408 | off (coupled draft sampling false) | lossless | unset = off | +| S-51 | `STRATA_VERIFY_PROFILE` | crates/leleka-runtime/src/qwen_forward/original_serve_stack.rs:1116 | unset (comment; read in the driver) | lossless | GPU stage timing report only | + +### 5b. Names in the prefill chunk path files: 14 distinct names (14 lossless, 0 lossy, 0 unknown-until-q_pair) + +The file list is the output of `find crates/leleka-runtime/src -type f -name '*.rs' | grep -E 'prefill|chunk|original_prompt|prompt' | grep -v '/original_serve'` (31 files, none +matches the glob of section 5), relative to `crates/leleka-runtime/src/`: +`backend_original_prompt.rs`, `qwen_forward/cache_original_prompt.rs`, `chunk_modules.rs`, `executor_original_prompt.rs`, `executor_prefill_chunk.rs`, `gdn_chunk_device.rs`, +`gdn_chunk_fused.rs`, `gdn_chunk_numeric_gpu.rs`, `gdn_chunk_producer.rs`, `gdn_prefill_batch.rs`, `gdn_prefill_batch_gpu.rs`, `gdn_prompt_device.rs`, `gr_attention_chunk.rs`, +`gr_batch_chunk.rs`, `moe_group_chunk.rs`, `moe_mmq_chunk.rs`, `moe_prefill_batch.rs`, `moe_prompt_finish.rs`, `mtp_decode_chunk.rs`, `mtp_state_chunk.rs`, `original_mtp_prefill.rs`, +`original_mtp_scalar_prefill.rs`, `original_prompt_embedding.rs`, `prefill_profile.rs`, `prompt_device_rows.rs`, `qsa_prefill_batch.rs`, `qsa_prompt_device.rs`, `qsa_prompt_index.rs`, +`session_chunk.rs`, `session_chunk_verify.rs`, `session_original_prompt.rs` (all except the first one under `qwen_forward/`). Command over those files: +`grep -hoE '(LELEKA|STRATA)_[A-Z0-9_]+' | sort -u | wc -l`. Two names also occur in section 5 (`LELEKA_BRINGUP_TRACE`, `STRATA_PREFILL_STREAM_MIN`). + +| row | name | file:line | unset value | class | evidence | +| --- | --- | --- | --- | --- | --- | +| P-01 | `LELEKA_BRINGUP_TRACE` | crates/leleka-runtime/src/qwen_forward/prefill_profile.rs:1 | off | lossless | per-chunk timing trace (also row S-04) | +| P-02 | `LELEKA_PREFILL_GDN_MIRROR` | crates/leleka-runtime/src/qwen_forward/gdn_chunk_device.rs:11,152 | ON | lossless | reuse of a resident GDN state mirror versus a canonical re-upload of the same values (`always upload the canonical host values (the A/B arm)`) | +| P-03 | `LELEKA_PREFILL_MOE_SPAN_CACHE` | crates/leleka-runtime/src/qwen_forward/cache_original_prompt.rs:44,52 | ON | lossless | span lookup cache, `0` restores the walk | +| P-04 | `LELEKA_PREFILL_PROFILE_SYNC` | crates/leleka-runtime/src/qwen_forward/prefill_profile.rs:6,119,138 | off | lossless | drains the device per span for attribution only | +| P-05 | `LELEKA_PREFILL_QSA_PREFETCH` | crates/leleka-runtime/src/qwen_forward/prompt_device_rows.rs:419 (comment); read at crates/cuda-driver/src/qsa_resident_transport.rs:38,74 | ON (QSA_PREFETCH_DEFAULT = true) | lossless | starts the prior-KV prefix copy on a side stream; ordering of a copy, same bytes | +| P-06 | `LELEKA_PREFILL_STAGED_INPUT` | crates/leleka-runtime/src/qwen_forward/executor_original_prompt.rs:39,42,296 | ON | lossless | KAR inputs staged chunk-wide on the device versus per-token host path (the A/B arm); `0` keeps the host path | +| P-07 | `LELEKA_PREFILL_STREAM` | crates/leleka-runtime/src/qwen_forward/cache_original_prompt.rs:15,23 | ON | lossless | per-chunk expert streaming; `identical greedy ids`, 16,000 tokens at chunk 8192 (cache_original_prompt.rs:16-17) | +| P-08 | `LELEKA_PREFILL_STREAM_SEQ` | crates/leleka-runtime/src/qwen_forward/cache_original_prompt.rs:31 | unset (test harness switch, `-1` = environment) | lossless | in-process A/B override | +| P-09 | `LELEKA_STRA169_RUN_GDN_BATCH_RESOURCES` | crates/leleka-runtime/src/qwen_forward/gdn_prefill_batch_gpu.rs:13 | unset (gates a GPU test) | lossless | test gate | +| P-10 | `LELEKA_STRA169_RUN_GDN_CHUNK_COMPONENT` | crates/leleka-runtime/src/qwen_forward/gdn_chunk_numeric_gpu.rs:404,481 | unset (gates a GPU test) | lossless | test gate | +| P-11 | `LELEKA_TRACE_DRIVER_ERRORS` | crates/leleka-runtime/src/qwen_forward/executor_original_prompt.rs:601 | off | lossless | prints driver errors | +| P-12 | `LELEKA_TRACE_PREFILL_R` | crates/leleka-runtime/src/qwen_forward/executor_original_prompt.rs:437,439 | off | lossless | FNV-1a of the final residual per chunk, `off by default` | +| P-13 | `STRATA_PREFILL_BF16X2` | crates/leleka-runtime/src/qwen_forward/gdn_prefill_batch.rs:29; crates/leleka-runtime/src/qwen_forward/moe_prefill_batch.rs:33 | 0 = HighOnly, the original default | lossless | named in comments: HighOnly is the literal profile; HighPlusLow is `separately profile-bound` and not selected here | +| P-14 | `STRATA_PREFILL_STREAM_MIN` | crates/leleka-runtime/src/qwen_forward/cache_original_prompt.rs:12,29 | 4096 rows | lossless | see row S-46; copy ordering | + +Not covered by the file set above, read in `crates/cuda-driver/src` and named here only so the second wave can find them (not classified here): `LELEKA_PREFILL_GDN_NOSTORE` +(default ON, `prefill_stage.rs:78,84`, identity gate cited in docs/upstream-port-plan.md row 2.4), `LELEKA_PREFILL_GDN_KH` (default off, `prefill_stage.rs:96-103`, sm_120 only), +`LELEKA_PREFILL_FAST_REC` (off, `prefill_stage.rs:61`), `LELEKA_MMQ_STREAMK` / `LELEKA_MMQ_NO_STREAMK` (stream-K policy latched per device, `arch_ptx.rs:27,85`). + +## 6. Vanilla Strata defaults (cross-reference to STRA-247 only; nothing measured or classified here) + +* Route tail skip, vanilla: ON by default on CUDA builds (owner decision 0.1.42), rank 7: `engine/strata/src/program/generate.cpp:10110-10153` (the handoff's `generate.cpp` is + `src/program/generate.cpp`; the skip itself is `src/core/expert_source.cpp:4763-4894`). Conditions that turn the default OFF: every expert resident; at least + `STRATA_TAIL_SKIP_MAX_CACHED` percent (default 90) of the experts cached; NVFP4 experts; `--batch` slots; a peer or helper GPU; an unsupported decode architecture + (`decode_defaults_arch_ok()`). It changes the output (comment: KL ~0.003-0.006). Ours: OFF, `unwrap_or(0)` (row S-27, line 64 below). So `off` is ours only. See STRA-247. +* CPU prefill share, vanilla: ON by default for chunks below 1024 tokens since 0.1.41 (`STRATA_PREFILL_CPU_SHARE` unset behaves as `auto` with `STRATA_PREFILL_CPU_SHARE_MAX=1024`; + CUDA builds, one GPU, no batch slots; layer split, batch slots and HIP stay off), `engine/strata/src/prefill/prefill.cpp:193-221`; mean KL against the share off about 0.004 + (comment, lines 202-205). `STRATA_PREFILL_CPU_SHARE=0` turns it off. Ours: ABSENT (row below). See STRA-247. + +| row | item | ours | evidence | +| --- | --- | --- | --- | +| V-01 | route tail skip | OFF by default (`LELEKA_ROUTE_TAIL_SKIP`, unset = 0, lossy when enabled) | `crates/leleka-runtime/src/qwen_forward/original_serve_residency.rs:64`; command `sed -n '64p' ...` in section 8 | +| V-02 | CPU prefill share | ABSENT: no such switch in `crates/` or `scripts/` | command `grep -rn -i "prefill.*cpu.*share\|PREFILL_CPU_SHARE" crates scripts` printed nothing (section 8) | + +## 7. Everything else: not on the shipped serve path as scoped, not classified (434 names) + +These are the distinct `LELEKA_*` / `STRATA_*` tokens found in `crates/**/*.rs` minus the names of sections 5 and 5b. Command that produced the list: +`grep -rhoE '(LELEKA|STRATA)_[A-Z0-9_]+' crates --include='*.rs' | sort -u` (497 distinct tokens, 441 of them `LELEKA_*`) minus the 63 names of sections 5 and 5b, with +`comm -23`. Caveat: this list is by token, not by reader. Some of these are read on the serve path by files outside the bounded file set (for example `LELEKA_MEMORY_*` and +`LELEKA_MAPPED_WORKING_SET_GIB`, which the profile `memory` rows K50-23..27 and K30-23..27 classify; `LELEKA_CHAIN_*` groups behind K50-19; `LELEKA_SPEC_*` controller constants +in docs/adaptive-spec.md; `LELEKA_ORIGINAL_SERVE_PCIE_FRAC`, `_PREFILL_BORROW`, `_CAPACITY`, `_KV_RESIDENT`; `LELEKA_PREFILL_*` switches in `crates/cuda-driver`). They are +listed so that nothing is silently dropped; none is classified. + +`LELEKA_AB_DATE`, `LELEKA_AB_REPLAY`, `LELEKA_ASSETS`, `LELEKA_BANK_THP`, `LELEKA_CAPTURE_DIR`, `LELEKA_CB_WARMUP`, `LELEKA_CHAIN_`, `LELEKA_CHAIN_AB`, `LELEKA_CHAIN_DOWN`, `LELEKA_CHAIN_GLUE`, `LELEKA_CHAIN_GR`, `LELEKA_CHAIN_HEAD`, `LELEKA_CHAIN_MTP`, `LELEKA_CHAIN_QSA`, `LELEKA_CHAIN_TINY`, `LELEKA_CHAIN_UP8`, `LELEKA_CHUNK_DRAIN`, `LELEKA_CHUNK_DRAIN_FILE`, `LELEKA_CONVERSATION_CACHE`, `LELEKA_CONVERSATION_CACHE_MIB`, `LELEKA_CONVERSATION_CACHE_SLOTS`, `LELEKA_CONVERSATION_CANCEL_PROBES`, `LELEKA_CONVERSATION_EVERY`, `LELEKA_CONVERSATION_MAX_NEW`, `LELEKA_CONVERSATION_SYSTEM_REPEAT`, `LELEKA_CPU_ISA`, `LELEKA_CPU_POOL_PIN_HOST`, `LELEKA_CUDA_CASE`, `LELEKA_CUDA_MOCK_HARNESS`, `LELEKA_CUDA_MOCK_ROOT`, `LELEKA_CUDA_Q5_MOCK_ROOT`, `LELEKA_CUDA_Q6_MOCK_ROOT`, `LELEKA_CUDA_REAL_GPU`, `LELEKA_CUDA_TRACE_CALLBACKS`, `LELEKA_CUDA_TRACE_SYNC`, `LELEKA_DLL_DIRS`, `LELEKA_EXPERIMENTAL_EXPERTS_USED`, `LELEKA_EXPERIMENTAL_FAKE_BITS`, `LELEKA_EXPERIMENTAL_KAR_EXPERT_LAYERS`, `LELEKA_EXPERIMENTAL_KAR_EXPERT_LEVELS`, `LELEKA_EXPERIMENTAL_KAR_LEVELS`, `LELEKA_EXPERIMENTAL_KAR_TENSORS`, `LELEKA_FAMILY_CLOSE_FAILURE`, `LELEKA_FAMILY_EXPECT_FAILURE`, `LELEKA_FAMILY_GPU_ROOT`, `LELEKA_FAMILY_IQ2S_ENABLED`, `LELEKA_FAMILY_IQ3S_ENABLED`, `LELEKA_FAMILY_IQ3XXS_ENABLED`, `LELEKA_FAMILY_IQ4NL_ENABLED`, `LELEKA_FAMILY_IQ4XS_ENABLED`, `LELEKA_FAMILY_MODES`, `LELEKA_FAMILY_N`, `LELEKA_FAMILY_NATIVE`, `LELEKA_FAMILY_PUBLIC_CASE`, `LELEKA_FAMILY_PUBLIC_MODE`, `LELEKA_FAMILY_Q2_ENABLED`, `LELEKA_FAMILY_Q4K_ENABLED`, `LELEKA_FAMILY_Q8_ENABLED`, `LELEKA_FAMILY_QUANTIZER_PTX`, `LELEKA_FAMILY_REAL_GPU`, `LELEKA_FAMILY_ROOT`, `LELEKA_FAMILY_UNIT_ELF`, `LELEKA_FORCE_SMS`, `LELEKA_GATEWAY_TOKEN`, `LELEKA_GPTOSS_GGUF`, `LELEKA_HEAD_EVIDENCE`, `LELEKA_HEAD_NATIVE_ORACLE`, `LELEKA_HEAD_NATIVE_SHA256`, `LELEKA_IGPU_MOE_TILE`, `LELEKA_IGPU_TILE`, `LELEKA_LAPTOP_ARMS`, `LELEKA_LAPTOP_BENCH`, `LELEKA_LAPTOP_CELLS`, `LELEKA_LAPTOP_CPU_WORKERS`, `LELEKA_LAPTOP_EXPERTS`, `LELEKA_LAPTOP_KAR_FILE`, `LELEKA_LAPTOP_MAX_CONTEXT`, `LELEKA_LAPTOP_MAX_NEW`, `LELEKA_LAPTOP_ORDER`, `LELEKA_LAPTOP_PREFIX_BLOCK`, `LELEKA_LAPTOP_PREFIX_MIB`, `LELEKA_LAPTOP_PROMPT_CACHE`, `LELEKA_LAPTOP_PROMPT_IDS`, `LELEKA_LAPTOP_REPEAT`, `LELEKA_LAPTOP_SEQUENCE`, `LELEKA_LAPTOP_SKIP_FAILED`, `LELEKA_LAPTOP_SOAK_S`, `LELEKA_LAPTOP_SPEC_MIN_P`, `LELEKA_MAPPED_WORKING_SET_GIB`, `LELEKA_MARGINS`, `LELEKA_MEMORY_`, `LELEKA_MEMORY_CACHE_SHARE_PERCENT`, `LELEKA_MEMORY_ENFORCE`, `LELEKA_MEMORY_HARD_FLOOR_MIB`, `LELEKA_MEMORY_HEAL`, `LELEKA_MEMORY_HYSTERESIS_MIB`, `LELEKA_MEMORY_LOCK`, `LELEKA_MEMORY_NO_TRIM`, `LELEKA_MEMORY_PSI_FULL_REJECT`, `LELEKA_MEMORY_PSI_GUARD_MIB`, `LELEKA_MEMORY_PSI_SOME_SHED`, `LELEKA_MEMORY_RESERVE_MIB`, `LELEKA_MEMORY_RESIDENCY_S`, `LELEKA_MEMORY_SAMPLE_MS`, `LELEKA_MEMORY_SOFT_FLOOR_MIB`, `LELEKA_MEMORY_SWAPOUT_PAGES_PER_S`, `LELEKA_MEM_ABORT_GIB`, `LELEKA_MEM_BALLAST_MIB`, `LELEKA_MEM_BIG`, `LELEKA_MEM_BIG_EVERY`, `LELEKA_MEM_EXPERTS`, `LELEKA_MEM_FILL_MAX`, `LELEKA_MEM_FILL_TOKENS`, `LELEKA_MEM_HARD_BELOW_MIB`, `LELEKA_MEM_KAR_FILE`, `LELEKA_MEM_LEAK_SAMPLE_S`, `LELEKA_MEM_LEAK_SECS`, `LELEKA_MEM_LEAK_TSV`, `LELEKA_MEM_LEAK_WARMUP_PCT`, `LELEKA_MEM_PREFIX_MIB`, `LELEKA_MEM_PROBE_SECS`, `LELEKA_MEM_READER_FILE`, `LELEKA_MEM_READER_GIB`, `LELEKA_MEM_READER_NEW`, `LELEKA_MEM_READER_REQS`, `LELEKA_MEM_REQUESTS`, `LELEKA_MEM_SCENARIO`, `LELEKA_MEM_SESSIONS`, `LELEKA_MEM_SESSION_CAP`, `LELEKA_MEM_SMOKE`, `LELEKA_MEM_SOFT_BELOW_MIB`, `LELEKA_MEM_TOKENS`, `LELEKA_MEM_WARMUP`, `LELEKA_MMQ_NO_STREAMK`, `LELEKA_MMQ_NO_STREAMK_FILE`, `LELEKA_MMQ_STREAMK`, `LELEKA_MMQ_STREAMK_FILE`, `LELEKA_MODEL_SHA256`, `LELEKA_MTP_RT_BANK_GPU`, `LELEKA_MTP_SCALAR_SHORT_GPU`, `LELEKA_NO_TRIM_FILE`, `LELEKA_NPU_CPU_THREADS`, `LELEKA_NPU_PROFILE`, `LELEKA_OPENVINO_DEVICE`, `LELEKA_OPENVINO_ROOT`, `LELEKA_ORIGINAL_SERVE_ADAPT_EVERY`, `LELEKA_ORIGINAL_SERVE_BUDGET_GIB`, `LELEKA_ORIGINAL_SERVE_CAPACITY`, `LELEKA_ORIGINAL_SERVE_EXPERT_`, `LELEKA_ORIGINAL_SERVE_EXPERT_PER_LAYER`, `LELEKA_ORIGINAL_SERVE_KV_RESIDENT`, `LELEKA_ORIGINAL_SERVE_LONG_ARMS`, `LELEKA_ORIGINAL_SERVE_LONG_CONVERSATION`, `LELEKA_ORIGINAL_SERVE_LONG_FORCE_DIR`, `LELEKA_ORIGINAL_SERVE_LONG_IDS_DIR`, `LELEKA_ORIGINAL_SERVE_LONG_MAX_NEW`, `LELEKA_ORIGINAL_SERVE_LONG_QUESTION`, `LELEKA_ORIGINAL_SERVE_LONG_REPEAT`, `LELEKA_ORIGINAL_SERVE_LONG_SMOKE`, `LELEKA_ORIGINAL_SERVE_LONG_TEXT_FILE`, `LELEKA_ORIGINAL_SERVE_LONG_TOKENS`, `LELEKA_ORIGINAL_SERVE_MAX_CONTEXT`, `LELEKA_ORIGINAL_SERVE_NAN_GUARD`, `LELEKA_ORIGINAL_SERVE_NAN_GUARD_RETRIES`, `LELEKA_ORIGINAL_SERVE_NAN_INJECT`, `LELEKA_ORIGINAL_SERVE_PCIE_FRAC`, `LELEKA_ORIGINAL_SERVE_PER_LAYER_SIZED`, `LELEKA_ORIGINAL_SERVE_PREFILL_BORROW`, `LELEKA_ORIGINAL_SERVE_REPLAY`, `LELEKA_ORIGINAL_SERVE_RESIDENT_BUDGET_GIB`, `LELEKA_ORIGINAL_SERVE_RT_DIR`, `LELEKA_ORIGINAL_SERVE_SMOKE`, `LELEKA_ORIGINAL_SERVE_VRAM_RESERVE_MIB`, `LELEKA_PCIE_DMA_BATCH`, `LELEKA_PCIE_DMA_MANY`, `LELEKA_PCIE_FLAGB`, `LELEKA_PCIE_GRID`, `LELEKA_PCIE_KERNEL`, `LELEKA_PFX_BLOCK`, `LELEKA_PFX_CANCEL`, `LELEKA_PFX_CAPACITY`, `LELEKA_PFX_END`, `LELEKA_PFX_GROW`, `LELEKA_PFX_LAPTOP`, `LELEKA_PFX_MAX_NEW`, `LELEKA_PFX_MIB`, `LELEKA_PFX_MODE`, `LELEKA_PFX_SCENARIO`, `LELEKA_PFX_SESSIONS`, `LELEKA_PFX_SHARED`, `LELEKA_PFX_SMOKE`, `LELEKA_PFX_START`, `LELEKA_PFX_TURNS`, `LELEKA_PFX_VERIFY`, `LELEKA_PLE_`, `LELEKA_PLE_AHEAD`, `LELEKA_PLE_AHEAD_VERIFY`, `LELEKA_PLE_DIRECT`, `LELEKA_PLE_INFLIGHT`, `LELEKA_PLE_PROBE_ARCHIVE`, `LELEKA_PLE_PROBE_DUMP`, `LELEKA_PLE_PROBE_ROWS`, `LELEKA_PLE_READER`, `LELEKA_PLE_ROW_CACHE`, `LELEKA_PLE_SYNC_SUBMIT`, `LELEKA_PREFILL_AHEAD`, `LELEKA_PREFILL_ALIGNED_COPY`, `LELEKA_PREFILL_ALLOC_TRACE`, `LELEKA_PREFILL_CHUNK`, `LELEKA_PREFILL_COPY_STATS`, `LELEKA_PREFILL_DEFER_FREE_MIB`, `LELEKA_PREFILL_DEFER_GUARDS`, `LELEKA_PREFILL_DEPTH`, `LELEKA_PREFILL_DIAG_SKIP_EXPERT_DMA`, `LELEKA_PREFILL_FAST_DEQUANT`, `LELEKA_PREFILL_FAST_REC`, `LELEKA_PREFILL_FUSED_SCANS`, `LELEKA_PREFILL_GDN_KH`, `LELEKA_PREFILL_GDN_NOSTORE`, `LELEKA_PREFILL_GDN_POOL`, `LELEKA_PREFILL_GUARD_GRID`, `LELEKA_PREFILL_ISSUER`, `LELEKA_PREFILL_STAGE_GPU`, `LELEKA_PREFILL_STALL_TRACE`, `LELEKA_PREFILL_STREAM_JITTER`, `LELEKA_PREFILL_TOPUP`, `LELEKA_PREFILL_ZERO_MEMSET`, `LELEKA_PREFIX`, `LELEKA_PRESET`, `LELEKA_PUBLIC_EVALUATION`, `LELEKA_Q5_CASE`, `LELEKA_Q5_EVIDENCE`, `LELEKA_Q5_NATIVE_ORACLE`, `LELEKA_Q5_REAL_INPUT`, `LELEKA_Q5_TRUSTED_PTX`, `LELEKA_Q6_CASE`, `LELEKA_Q6_EVIDENCE`, `LELEKA_Q6_NATIVE_ORACLE`, `LELEKA_Q6_REAL_INPUT`, `LELEKA_Q6_TRUSTED_PTX`, `LELEKA_QSA_LATE`, `LELEKA_QSA_LATE_GPU`, `LELEKA_QSA_LATE_SEQ`, `LELEKA_QSA_LATE_SM86`, `LELEKA_QSA_TOPK`, `LELEKA_REAL_GU_DIR`, `LELEKA_REAL_GU_MANIFEST_SHA`, `LELEKA_REAL_GU_OUTPUT_DIR`, `LELEKA_REPLAY_ARMS`, `LELEKA_REPLAY_CAPACITY`, `LELEKA_REPLAY_COUNT`, `LELEKA_REPLAY_DIR`, `LELEKA_REPLAY_FIRST`, `LELEKA_REPLAY_FORCE`, `LELEKA_REPLAY_MAX_CONTEXT`, `LELEKA_REPLAY_MAX_NEW`, `LELEKA_REPLAY_OUT`, `LELEKA_REPLAY_PREFIX_MIB`, `LELEKA_REPLAY_PREFIX_TAIL`, `LELEKA_REPLAY_REPS`, `LELEKA_REPLAY_SPEC_MIN_P`, `LELEKA_RING_SERIALIZE`, `LELEKA_RING_SERIALIZE_CMD_FILE`, `LELEKA_RING_SERIALIZE_COPY_FILE`, `LELEKA_RING_SERIALIZE_FILE`, `LELEKA_ROUTE`, `LELEKA_RUNTIME_TOKEN`, `LELEKA_RUN_REAL_NATIVE_D4`, `LELEKA_SHADOW_DEVICE`, `LELEKA_SKIP_CPU`, `LELEKA_SLOT_LOG`, `LELEKA_SM86_TRACE`, `LELEKA_SMOKE_ARMS`, `LELEKA_SMOKE_CHAT`, `LELEKA_SMOKE_FORCE_DIR`, `LELEKA_SMOKE_FORCE_PASSES`, `LELEKA_SMOKE_MAX_CONTEXT`, `LELEKA_SMOKE_MAX_NEW`, `LELEKA_SMOKE_MIN_P`, `LELEKA_SMOKE_ORDER`, `LELEKA_SMOKE_PROMPTS`, `LELEKA_SMOKE_PROMPT_CACHE`, `LELEKA_SMOKE_PROMPT_IDS`, `LELEKA_SMOKE_REPEAT`, `LELEKA_SMOKE_SAMPLED`, `LELEKA_SPECULATION_LOG`, `LELEKA_SPEC_BIAS_RATE`, `LELEKA_SPEC_COST_ALPHA`, `LELEKA_SPEC_DECAY`, `LELEKA_SPEC_DRAFT_STEP_MS`, `LELEKA_SPEC_EXPLORE`, `LELEKA_SPEC_MARGIN`, `LELEKA_SPEC_MIN_P_LO`, `LELEKA_SPEC_STATS`, `LELEKA_SPEC_TRACE`, `LELEKA_SPLIT_LOG`, `LELEKA_SSD_KEEPALIVE`, `LELEKA_SSD_KEEPALIVE_MS`, `LELEKA_SSD_KEEPALIVE_WINDOW_S`, `LELEKA_STAGE_PRIORITY`, `LELEKA_STAGE_VERIFY`, `LELEKA_STATE`, `LELEKA_STRA169_`, `LELEKA_STRA169_CANDIDATE_CAPTURE`, `LELEKA_STRA169_CAPTURE_DIR`, `LELEKA_STRA169_EXPERT_PROFILE`, `LELEKA_STRA169_IQ3S_SHARD0`, `LELEKA_STRA169_IQ3S_SHARD1`, `LELEKA_STRA169_KAR_ARCHIVE`, `LELEKA_STRA169_KAR_FD`, `LELEKA_STRA169_KAR_PROVENANCE`, `LELEKA_STRA169_KAR_STAGING`, `LELEKA_STRA169_LAYER0_DIR`, `LELEKA_STRA169_MMQ_REFERENCE_DIR`, `LELEKA_STRA169_MMQ_REFERENCE_MANIFEST_SHA`, `LELEKA_STRA169_MTP_PACK`, `LELEKA_STRA169_MTP_STAGING`, `LELEKA_STRA169_NATIVE_BASELINE`, `LELEKA_STRA169_PAIR_METADATA`, `LELEKA_STRA169_PAIR_METADATA_SHA`, `LELEKA_STRA169_PAIR_OUTPUT`, `LELEKA_STRA169_RUN_COMBINED_BOUNDARIES`, `LELEKA_STRA169_RUN_COMBINED_REUSE`, `LELEKA_STRA169_RUN_FIVE_PUBLIC_CASES`, `LELEKA_STRA169_RUN_FIXED_DRAFT_MOE`, `LELEKA_STRA169_RUN_GDN_BATCH`, `LELEKA_STRA169_RUN_GDN_FUSED_T1`, `LELEKA_STRA169_RUN_GDN_MTP_JOURNAL`, `LELEKA_STRA169_RUN_GDN_PRODUCTS`, `LELEKA_STRA169_RUN_GDN_QK_SLOT`, `LELEKA_STRA169_RUN_GDN_ROW_QUEUE`, `LELEKA_STRA169_RUN_GROUPED_CHUNK_PROOF`, `LELEKA_STRA169_RUN_GROUPED_DOWN`, `LELEKA_STRA169_RUN_GR_DEVICE_GUARD`, `LELEKA_STRA169_RUN_GR_HANDOFF`, `LELEKA_STRA169_RUN_GR_MICROBATCH`, `LELEKA_STRA169_RUN_GR_OUTPUT_WORKSPACE`, `LELEKA_STRA169_RUN_LAYER0_MMQ_DIAGNOSTIC`, `LELEKA_STRA169_RUN_MMQ_NUMERIC`, `LELEKA_STRA169_RUN_MOE_GROUP`, `LELEKA_STRA169_RUN_MOE_PREFILL_BATCH`, `LELEKA_STRA169_RUN_MTP_BATCH_NUMERIC`, `LELEKA_STRA169_RUN_MTP_KV_RING_PROOF`, `LELEKA_STRA169_RUN_NATIVE_RESIDENT_MMQ_MODEL`, `LELEKA_STRA169_RUN_OWNED_ASYNC_COPY`, `LELEKA_STRA169_RUN_PLE_CLOSED_QUEUE`, `LELEKA_STRA169_RUN_PUBLIC_CANDIDATE_ONLY`, `LELEKA_STRA169_RUN_PUBLIC_NATIVE_DOWN_PAIR`, `LELEKA_STRA169_RUN_QSA_ATTENTION_SCRATCH`, `LELEKA_STRA169_RUN_QUEUED_GR`, `LELEKA_STRA169_RUN_RESIDENT_MMQ_MODEL`, `LELEKA_STRA169_RUN_ROUTED_RESIDENT_QUEUE`, `LELEKA_STRA169_RUN_ROUTER_SCRATCH`, `LELEKA_STRA169_RUN_SINGLELOAD_PROOF`, `LELEKA_STRA172_RUN_GROUPED_GU21_GU23`, `LELEKA_STRA172_RUN_GROUPED_GU21_GU23_NC4`, `LELEKA_STRA172_RUN_GR_BATCH_INJECT_WORKSPACE`, `LELEKA_STRA172_RUN_HEAD_GREEDY`, `LELEKA_STRA172_RUN_MMQ_TRIPLET`, `LELEKA_STRA172_RUN_MTP_INPUT_PREFIX`, `LELEKA_STRA172_RUN_OWNED_GATE_UP_UPLOAD`, `LELEKA_STRA172_RUN_QSA_SELECTED_KV`, `LELEKA_STRA172_RUN_ROUTED_COLUMNS_LOAN`, `LELEKA_STRA172_RUN_ROUTED_FINITE_GUARD`, `LELEKA_STRA172_RUN_ROUTED_GROUP_WORKSPACE`, `LELEKA_STRA172_RUN_SHARED_TAIL`, `LELEKA_SUFFIX_RESET`, `LELEKA_SWEEP_CONTEXT`, `LELEKA_SWEEP_KS`, `LELEKA_SWEEP_MAX_NEW`, `LELEKA_SWEEP_REPS`, `LELEKA_S_FP16_ARGS`, `LELEKA_S_GEMV`, `LELEKA_S_GEMV_Q8K`, `LELEKA_S_GEMV_Q8_SPLIT`, `LELEKA_S_GEMV_SPLIT`, `LELEKA_S_Q8_ARGS`, `LELEKA_TOKENIZER_DIR`, `LELEKA_TOKENIZER_REFERENCE`, `LELEKA_TOKENIZER_SEGMENT_CACHE_MIB`, `LELEKA_TOKENIZER_TEXTS`, `LELEKA_TRACE_LADDER`, `LELEKA_TRACE_PLE`, `LELEKA_TRACE_POISON`, `LELEKA_VERIFY_WINDOW_GPU`, `LELEKA_WARM`, `LELEKA_WINDOW_MODULE_CACHE`, `LELEKA_WSL_DISTRO`, `STRATA_ADAPT_CALLBACK_WARMUP`, `STRATA_ARENA_LOCK`, `STRATA_ARENA_PIN_GIB`, `STRATA_COMMIT_SYNC`, `STRATA_CPU_YMM`, `STRATA_DEC_BATCH`, `STRATA_D_FMTS`, `STRATA_FORCE_AVX2`, `STRATA_GU_FMTS`, `STRATA_HC_SPLIT`, `STRATA_IQ_GATHER`, `STRATA_IQ_MT_MIN`, `STRATA_IQ_PREFETCH`, `STRATA_KEYLESS_ROUTING`, `STRATA_KQ256`, `STRATA_KV_MAIN_OFF`, `STRATA_KV_RING_OFF`, `STRATA_KV_ROT`, `STRATA_LOGPOS`, `STRATA_LOGPOS_TOPK`, `STRATA_NAN_GUARD`, `STRATA_NAN_INJECT`, `STRATA_NO_IQ256`, `STRATA_NO_IQ4NL`, `STRATA_NO_IQ512`, `STRATA_OLD_IQ_MMVQ`, `STRATA_PARTIAL_PIN`, `STRATA_PARTIAL_PIN_GIB`, `STRATA_POOL_SPIN_US`, `STRATA_PREFILL_ISSUER`, `STRATA_PREFILL_RING`, `STRATA_PROMPT_ATTN_V1`, `STRATA_Q2`, `STRATA_Q2_BLOB_BYTES`, `STRATA_QSA_CLUSTER`, `STRATA_QSA_WARP`, `STRATA_SCORES_MULTI`, `STRATA_SNAPSHOT_FULL_CAPTURE`, `STRATA_STAGER_RING`, `STRATA_STAGER_THREADS`, `STRATA_TEST_CACHE_FAIL`, `STRATA_TEST_VERIFY_STALL`, `STRATA_VERIFY_DEVICE_PLAN`, `STRATA_WATCHDOG_S`, `STRATA_WINDOW_DOWN`, `STRATA_WINDOW_GU` + +## 8. DISPOSITION of a default found lossy or unknown + +A default found lossy is a finding returned to TECH_LEAD for a second-wave fix leaf (revert to a lossless value, or mark the mode experimental and keep it off); this leaf changes +nothing: no profile, no `serve_tuning.rs`, no code, no `engine/strata`, no sealed PTX. A default classed `unknown-until-q_pair` stays shipped until its leaf (STRA-267 on the 5090, +STRA-293 on the laptop) returns a q_pair result; no default found here is classed `lossy` in the sense of section 1 (no output-changing mode is ON in ours). + +### Findings for the second wave + +* F1. The 5090 profile ships `LELEKA_CHAIN=all` (K50-19). The chain kernels are not bit-identical to the Original's at 30-70k context (5,993 of 64,355 rows identical, 697 argmax flips, + 1.08 %, docs/chain-kernels.md:70-79); the profile text and the doc call them within rounding noise by the q_tail_gate rule. No 256k q_pair exists. Needs STRA-267. +* F2. The 5090 profile ships `memory.prefix_cache_tail = reply` (K50-21). docs/prefix-cache.md:168 says EXPERIMENTAL, off by default, not to be defaulted before the agreement gate; + docs/prefix-cache.md:190-198 records it as the profile default after a ~70k-token q_tail_gate. The two statements in one document disagree; the gate was not run at 256k. +* F3. Chunk and grid defaults are rounding-level changes with no q_pair: 8192 on the 5090 (K50-11, K50-22; 8192 answered differently on one 16,000-token prompt, docs/prefill-throughput.md:52-57, + whether rounding or a defect was left open) and 6144 on the laptop (K30-09, K30-22; docs/laptop-vs-vanilla.md:79). No log pair for 8192/2048 or 6144/2048 is in the repository (section 9). +* F4. Adaptive speculative window and `spec_min_p`, expert placement (seed ON, adaptive tier ON, per-layer slots, expert profile) are gated only by docs/quality-gate.md section 8 + (612 rows, short prompts, 5090) and docs/adaptive-spec.md:106-111; neither machine has a 256k q_pair for them. Needs STRA-267 and STRA-293. +* F5. `LELEKA_ORIGINAL_SERVE_CPU_WORKERS` / `cpu_workers`: no record found that the result is independent of the worker count. +* F6. Documentation mismatch, no class: `STRATA_PREFILL_STREAM_MIN` is 4096 in code (`cache_original_prompt.rs:29`) and 1024 in the `original_serve_config.rs:277` comment. +* F7. Handoff correction: vanilla's tail-skip default is at `engine/strata/src/program/generate.cpp:10110-10153`, not at a top-level `generate.cpp`. +* F8. Nothing lossy is ON by default in ours: route tail skip is off (S-27) and there is no CPU prefill share (V-02). The conditional ON defaults of vanilla (section 6) are STRA-247's. + +## 9. q_pair logs for chunk 8192 and 6144 + +Logs that exist for chunk 8192 and for chunk 6144: none. `git ls-files` lists 0 files ending in `.log`; `artifacts/runs` in the main checkout is not populated; the only comparison of +chunk sizes in the repository is a greedy-id comparison on one 16,000-token prompt (docs/prefill-throughput.md:52-57), which is not a q_pair result. docs/laptop-vs-vanilla.md:79 +states that q_pair or R-hash arms 2048 against 6144 were `Not run`. `scripts/quality/q_pair.py` exists (usage: `q_pair.py LOG_A LOG_B [--pass N] [--control LOG_A2]`, exit 0 if every common forced row is identical). + +## 10. Counts printed side by side + +The command outputs are produced by the verification run recorded with the item; the page-side counts are: + +| item | command output (recorded with the item) | page count | +| --- | --- | --- | +| profile key rows, rtx5090-32g | 27 | 27 | +| profile key rows, rtx3080-16g | 27 | 27 | +| names in `original_serve*.rs` | 51 | 51 | +| names in the prefill chunk path files | 14 | 14 | +| route tail skip line 64 | `unwrap_or(0)` default | S-27 | +| CPU prefill share grep | empty output | V-02 ABSENT | + +## 11. Commands run in the worktree and their output (AC1-AC3, q_pair log search) + +``` +$ python -c "import json,sys;f=lambda d:sum(f(v) if isinstance(v,dict) else 1 for v in d.values());print([f(json.load(open(p))) for p in sys.argv[1:]])" deploy/rust-runtime/profiles/rtx5090-32g.json deploy/rust-runtime/profiles/rtx3080-16g.json +[27, 27] +$ grep -rhoE '(LELEKA|STRATA)_[A-Z0-9_]+' crates/leleka-runtime/src --include='original_serve*.rs' | sort -u | wc -l +51 +$ (the prefill chunk path file list of section 5b, 31 files, 0 of them matching original_serve*) grep -hoE '(LELEKA|STRATA)_[A-Z0-9_]+' | sort -u | wc -l +14 +$ sed -n '64p' crates/leleka-runtime/src/qwen_forward/original_serve_residency.rs + let rank = std::env::var("LELEKA_ROUTE_TAIL_SKIP").ok().and_then(|v| v.trim().parse::().ok()).filter(|r| (1..TOP_K as u32).contains(r)).unwrap_or(0); +$ grep -rn -i "prefill.*cpu.*share\|PREFILL_CPU_SHARE" crates scripts +(empty output, exit status 1) +$ ls *.log 2>/dev/null +(empty: none) +$ grep -rn "q_pair" docs/prefill-throughput.md docs/laptop-vs-vanilla.md | head +docs/laptop-vs-vanilla.md:79, 80, 152 (the three lines quoted in K30-09 and section 9); docs/prefill-throughput.md: no match +``` + +Page-side counts: 27 and 27 profile-key rows, 51 names in section 5, 14 names in section 5b. The row for route tail skip is S-27 (line 64 as read in this worktree). diff --git a/docs/experiments/decode-graph-reuse.md b/docs/experiments/decode-graph-reuse.md new file mode 100644 index 00000000..99af17b7 --- /dev/null +++ b/docs/experiments/decode-graph-reuse.md @@ -0,0 +1,270 @@ +# Decode graph reuse across requests (ledger row Q7) + +Status: wired behind `LELEKA_DECODE_GRAPH_REUSE` (off by default, typed setting `serve.decode_graph_reuse`), unit tested +host-side and on the lifecycle fake, NOT run on a device. The speed session's driver part (`DeviceRef` handles, `OriginalVerifier:: +park` / `rearm`, `OriginalVerifyCanonicalGdn::reseed`, `docs/experiments/verify-decode-graph-reuse-handles.md`) is merged in; +this side is the policy (`DecodeGraphKey`, `GraphReuse::begin` / `end`, `HeldAssembly`), the QSA owner loan in the journal +(B2), the drafter decision (B3), the shared-expert pin and weights epoch, and the stack wiring (section 4). With the switch off +every path is the one before this change. No speedup claim; the sections to compare are in section 5. + +## 1. Why the graphs are recorded per request + +`decode_phase` (`OriginalServeStack`) calls `assemble_decode` -> `AssembleInputs::assemble` (`original_serve_verifier.rs`) for +every request, and `teardown_decode` -> `disassemble` at its end. `assemble` is: `prepare` (geometry, canonical GDN image +uploaded from the session's priors, QSA gamma), `OriginalVerifyQsaJournal::new` over the twelve QSA owners, then +`capture_verifier`: a new `OriginalVerifier` (new `Physical` arena, mapped allocations, two streams), one aggregate +(`OriginalVerifyWindowResources`) per T = 1..=max_t plus one for the commit graph, and `record_all` (nine graphs at T <= 8 +with the mode17 policy, 54-62 ms capture + 27-30 ms instantiate). `disassemble` closes the verifier (drains, drops every +graph and aggregate), which releases the aggregates' references to the QSA journal so `into_owners` can take the owners back, +and `release_mtp` drops the MTP drafter's programs bound to this verifier's bank. + +The recording is per request because of OWNERSHIP, not because the kernel arguments change: + +1. The QSA owners (twelve index images + mapped K/V journals) belong to the prompt executor. The next request's prefill + writes them (chunks, prefix-cache import, rollback). They can only get there by moving out of the journal + (`Rc::try_unwrap` in `into_owners`), which requires every graph that holds the journal to be gone. +2. The resources borrow the stack: `DecodeResources<'s, 'ctx>` holds `&'s DenseWeightCache`, `&'s MoeWeightCache`, + `&'s OriginalNativeOutput`, `&'s DeviceBuffer` (PLE history and scratch), `&SharedKeys` (a value of the request's own + stage). A value that borrows fields of `OriginalServeStack` cannot be stored in it (self-reference); this is why + `DecodeView` borrows the fields one by one. +3. The shared experts and routers are LRU entries of the MoE cache (`ensure_original_verify_shared`); the prompt path loads + layer by layer and may evict and reload them, so their device addresses are not guaranteed to survive a prefill. +4. The MTP drafter's round programs read the verifier's bank (final R span) and are released with it (`mtp_release_verifier`); + they are re-captured against the next bank (spans `draft.*`, a second cost of the same cause). + +`docs/decode-parity.md` already records this as "Verifier persistence: not done ... needs the executor to use the owners through +the journal". + +## 2. What the captured graphs point at + +Per-request buffers (created by `assemble`, addresses change every request today; data must be re-seeded if the buffer is kept): + +| Resource | Created in | Per request | Can be stable | +| --- | --- | --- | --- | +| Canonical GDN image (36 layers x 128*48*128 + 10240*3 f32, ~118 MB) | `prepare_assembly` (`original_verify_canonical_gdn(states, histories)`) | allocated and uploaded from the session priors | yes: keep the buffer, re-upload (118 MB H2D, stays in the per-request cost) | +| Verifier arena, `prof`, 15 mapped allocations, window modules | `OriginalVerifier::new` | new | yes: sized by `verify_geometry(max_t, max_cells, blobs)`; only the window state is data (`last_t`, `last_position`, `generation`, staged tokens) | +| Head rows per T, embedding rows per T, GDN journal, window aggregates | `aggregate()` | new | yes, part of the kept assembly | +| QSA journal `Rc` | `OriginalVerifyQsaJournal::new` | new Rc around the executor's buffers | the buffers are the executor's (fixed addresses); the Rc must outlive requests | +| Graphs, streams, event | `record_all` | new | the point of the feature | + +Stable resources the graphs also point at (owned across requests today, so reuse needs only a proof that they were not +reallocated): dense weights and gamma, router and shared experts (MoE cache entries, see 1.3), `OriginalNativeOutput`, PLE history +and PLE scratch (stack buffers), RoPE tables, the registered expert banks of the pcie path, the VRAM expert cache slots. + +Context length, window width, expert tier: + +* Context length and positions are DATA (staged into mapped host memory / device flags before each `run`); the arena and + the QSA journals are sized for `max_cells`, fixed by the configuration. A longer context does not change the graphs. +* The window width T is the graph identity (`OriginalGraphKey::VerifyWindow(t)`, t in 1..=8) and `max_t` is the arena + geometry. `verifier_max_t` can only fall during a process (`narrow_window_policy` after a graph OOM); a held assembly + recorded for another `max_t` must be retired. +* The expert tier: `pcie_mode` (0 DMA, 2 copy kernel) and the per-layer role bytes are baked into the graphs + (`set_pcie_mode`, `pcie_role_bytes`); the VRAM cache slot contents are data (published plan), the cache object and the + registered banks are addresses. `decode_pcie_mode` is a function of the configuration and of the cache being present. +* Process-level switches resolved at recording time: `qsa_cluster_requested` (cluster top-k), the sm120 switches + (`from_env`), `WindowPolicy::mode17()`. They are fixed for a process; they are in the key so a change is caught. + +## 3. Key and invalidation (coded: `original_serve_stack/decode_graph_reuse.rs`) + +`DecodeGraphKey { max_t, max_cells, pcie_mode, tier, cluster_topk, weights_epoch, owners_epoch }`. `weights_epoch` and +`owners_epoch` are counters bumped by the owners of the physical buffers whenever one that a window reads or writes in place +is freed, moved or reallocated. `GraphReuse::begin((key, seed), owners, retire)` returns the held assembly only for an equal key, with the owners taken back +at the addresses the graphs bound and `HeldAssembly::rearm(seed)` accepting; otherwise it retires it (`Why::KeyChanged(name) | +OwnersChanged | RearmRefused | NothingHeld | Disabled`) and gives the owners back to record a new one. `end` parks the assembly +of a clean request, lends the owners home and keeps it; a failed or cancelled request keeps nothing; `invalidate` retires it +(broken stack, reconfigure, narrowed window). A reuse that cannot show an equal key is a +re-record. The lifecycle fake (`lifecycle_fake/graphs.rs`, tests `backend/lifecycle_tests/graphs.rs`) bakes the key and the seed +into its graph set and fails the request on a replay for another key or without a re-arm: kept and re-recorded sets give the +same text, a kept set costs no recording, each of the seven key inputs forces a re-record, a refused re-arm and a failed +request do not replay. + +Owners of the epochs: + +* `weights_epoch`: `MoeWeightCache::weights_epoch()` counts every raw entry the cache evicted (`room`, `room_protected`) and + every pin release; `pin_for_window(keys)` / `unpin_window()` make `is_pinned` true for the 192 shared tensors so the prompt + path cannot evict them while a set is held (the existing eviction rule, as for the profile's permanent pool). Not wired + yet: pinning shrinks what a prefill can evict, and a prefill that finds nothing evictable fails with `InputAllocation`, so + it is switched on only together with a held set. The routers and the other dense operands live in the dense cache, which + does not evict after open. +* `owners_epoch`: replaced by the journal's own check (B2): `take_back` compares the window addresses (`window_addresses(layer)` for the twelve + layers: resident pools, table, host copy, resolver, pooled and dead key spans) taken when it lent the owners with those + of the owners that come back; any difference is a refusal and a re-record. + +## 4. The pieces: handles (speed session), owner loan, drafter, stack wiring + +### B1. The held assembly cannot borrow the stack (done by the speed session: `DeviceRef` handles) + +`DecodeResources<'s>` is `OriginalVerifier<'ctx, OriginalVerifyWindowResources<'a, 'ctx>>`; the aggregates hold `&'a +DeviceBuffer<'ctx>` into the dense cache (projections, GR, QSA operands, gamma), the PLE history and scratch, the RoPE tables +and the MoE cache (shared experts, `original_verify_moe`). The prompt path of the next request needs `&mut MoeWeightCache` and +`&mut DeviceBuffer` (`seed_ple_history`), which a live `&'a` forbids, and a value that borrows fields of the stack cannot live in +the stack. No safe restructuring of the stack alone fixes this: an owner above the stack would have to hold the MoE cache +immutably (the prompt path mutates it) or split the shared experts out of it (the prompt path loads them through it). + +Exact change that removes the borrow (files of the speed session's area, or operand types they use): + +* `original_verify_window_moe.rs` (5 sites: `OriginalVerifyMoeLayerWeights`), `original_verify_window_gr.rs` (16: `PleBuffers`, + `HcLayerBuffers`, ...), `original_verify_window_proj*` and `original_verify_window_qsa.rs` (5), `qwen_dispatch/fixed_operands.rs` + (34): replace the `&'a DeviceBuffer<'ctx>` operands with a shared handle `DeviceRef<'ctx>` (an `Rc` to the allocation plus + offset and length, `Clone`, derefs to `&DeviceBuffer` for the existing `qwen_address()` calls). The aggregates then have no + `'a`, `OriginalVerifyWindowResources<'ctx>` and `DecodeResources<'ctx>` can sit in the stack, and the borrow of the caches + ends at `assemble`. +* The caches hand out handles: `DenseWeightCache::original_verify_*` and `MoeWeightCache::raw_shared` clone the `Rc` of the + entry (the entries become `Rc`); an unpinned entry that a held set still references is dropped from the + cache's book on eviction but not freed (the set keeps the allocation alive; `weights_epoch` bumps, so the set is retired + at the next request). +* `seed_ple_history` writes through the shared handle (a `&self` upload of `DeviceBuffer`, device idle). + +### B2. QSA owner loan (coded, driver) + +`OriginalVerifyQsaJournal` (`cuda-driver/src/qsa_verification_commit*`, not a speed-session file) keeps its owners as +`RefCell>` behind the accessors `index`, `index_mut`, `kv`, `kv_mut`, which refuse (`InvalidQwenShape`) while the +owners are out, so a graph run, a window arm or a commit over a lent journal fails instead of touching nothing. + +* `lend(&self) -> Result`: needs the journal valid, not armed, every index idle and published and standing + where its journal does. It records the `OwnerPrint` of each of the twelve layers: the `window_addresses` (resident pools, + table, host copy, resolver, pooled and dead key spans) and the image's tail and block-position addresses, i.e. every + address the captured append and attention commands bind; then moves the 24 owners out (all 24 are borrowed and found full + before the first moves). +* `take_back(&self, owners) -> Result<(), (Error, owners)>`: takes the print of the returning owners, requires all twelve + idle at one position (`check_aligned`) and the print equal to the lent one. Equal: the owners are put back, the journal + stands at their position, disarmed. Anything else (an address moved, a resolver reset, a print that cannot be taken, + called while not lent) fails the loan and the journal for good (`validate_context` then answers `ContextPoisoned`) and + gives the owners back to the caller with the error, so none is lost; the stack retires the assembly. +* The state machine is `cuda-driver/src/owner_loan.rs` (pure; unit tests run without a GPU: round trip, a changed address or + a missing print fails for good, steps out of order change nothing). +* `into_owners` (the retire path) keeps working and refuses a lent journal. +* The stack side: `DecodeResources` implements `HeldAssembly` (`original_serve_verifier/held.rs`): `lend` / `take_back` map + the twelve layers to and from the executor's 48 slots (`place_owners`) and refuse owners that are not at exactly the + assembly's slots; `park` and `rearm` return `false` until the bank has them (below). +* GPU check (orchestrator, with the speed session's `park` / `rearm`): lend, run a prompt over the executor's owners, + `take_back`: accepted when the prompt only appended; `take_back` of owners after a `reset` of the mapped journal (new + resolver) must be refused. + +### B3. MTP drafter bound to the kept bank (coded) + +`GraphReuse::begin` / `invalidate` take a `retire` callback that runs before the retired assembly is dropped; `end` never +calls it when the assembly is kept. The stack passes `|| executor.mtp_release_verifier(binding)` (the current `release_mtp`). +So a kept bank keeps the drafter's cached round programs (no first-draft capture in the next request) and a retired one +releases them before its bank closes. Lifecycle fake: `drafter_releases` is 0 across kept requests and exactly 1 per +retirement (key change, owners moved, refused re-arm, `invalidate`) and per request with the switch off or `park` refused. +Open point for the GPU run: the drafter's tail keeps the last staged window of the previous request; the first request after +a re-arm must clear it (today `set_prompt_len` does; check `OriginalMtpActor` for anything keyed on the previous request). + +### The stack side (wired) + +* `OriginalServeStack::held: GraphReuse>`, enabled by the setting. `DecodeView::assemble` takes the QSA + owners from the executor as before, then `begin_kept`: with the switch off it returns them untouched (`Start::Record`, + the old path); on, it builds the `DecodeGraphKey` (`graph_key`: `verifier_max_t`, `max_cells`, `decode_pcie_mode`, tier + present, `cluster_topk_requested()`, `MoeWeightCache::weights_epoch()`) and the seed (`RearmSeed`: binding and the session's + `OriginalVerifiedBase`) and asks `GraphReuse::begin`. `Reused` skips `AssembleInputs::assemble` and queues the lent-slot + refill that assembly's prepare step would have queued; a refill that cannot be queued lends the owners out again and + retires the set (the failure goes through `resolve_assembled`, which adopts the owners). `Record { owners, why }` + assembles as today over those owners and prints why a kept set was not reused (`decode graphs recorded again: ...`). + `Lost` marks the stack broken. +* `DecodeResources` implements `HeldAssembly` (`original_serve_verifier/held.rs`): `park` = `OriginalVerifier::park`, `rearm` = + `OriginalVerifier::rearm` with the 36 GDN priors (`gdn_layer_priors`) and the PLE history of the session's base, `lend` / + `take_back` = the journal's loan mapped to the executor's 48 slots. Any refusal or error answers `false` / `None` / `Err`, + and the policy retires the set. +* `serve` computes the key before the request runs; `teardown_decode` (`decode_teardown.rs`) keeps the assembly only for a + request that was served without an error, whose host outcome is neither `failed` nor `dirty` (`keepable`), and whose + drafter and pins went through: `mtp_end_request_keep_bank` (the drafter forgets an unfinished draft and the staged window, + keeps its programs), `MoeWeightCache::pin_for_window(shared)`, then `GraphReuse::end` (park, lend, `QsaOwnerHome::adopt`). + Not kept: the old teardown (`release_mtp`, `disassemble`, adopt), or, when the owners were already home, `release_mtp` and + `verifier.close()`. Kept: no `release_mtp`, no `disassemble`, spans `decode.keep` (park + lend + adopt) in their place. +* Retirement always runs `retire_kept` first (`release_mtp` = `mtp_release_verifier`, then `unpin_window`) and drops the + assembly after it, so the bank is never closed under the drafter. It happens in `begin` (changed key, owners at other + addresses, refused re-arm), in `OriginalServeStack::close`, and in `reset_expert_tier`. +* Weights: the assembly holds handles, so an evicted tensor stays alive; the pin only avoids loading it a second time. A freed + entry the window reads, and the release of the pins, move `weights_epoch`, which retires the set at the next request. +* With the switch off `Ending` carries no `Keep`, `GraphReuse::begin` is not called, and `teardown_decode` runs the old body + unchanged. + +### Drafter state keyed on the previous request (checked) + +`OriginalMtpDrafter` holds: `in_flight` (a draft launched and never finished), the tail owner's staged verifier window +(`full.source`), the cached round programs (`graphs`, `graph_metadata`), `direct_window_mode`, `ring_owner`, `policy_key`. +`end_request_keep_bank` clears the first two (after draining the draft stream) and keeps the rest: the programs name the bank's +final-R span (unchanged for a kept bank; `stage_round` refuses a window at another address) and the draft ring +(`ring_owner`, `policy_key` are checked by the drafter on use). The actor's other state (`DraftSettings`, prompt length, max +drafts, the coupled host) is set per request by the stack as before. To confirm on the GPU: the draft trace and the top-16 +logprobs of request 2 equal the fresh-assembly run, and `draft.*` shows no capture at the first draft. + +### Scenarios (the lifecycle fake runs them; the real wiring answers the same way where it can run host-side: `backend/lifecycle_tests/graphs.rs`) + +| Scenario | Expected | +| --- | --- | +| switch off, 3 requests | 3 recordings, 3 drafter releases, set never held | +| switch on, 4 requests, different prompts | text equal to the switch-off run; 1 recording, 3 re-arms, 0 drafter releases; the 3 later requests pay no recording | +| full cycle: request 1 records, `park`, request 2 re-arms | bank generation 1 then 2; a window token of request 1 refused after the re-arm, a window of request 2 accepted; windows, commits and the wait flag count request 2's rounds only (4, not 8); the canonical image holds request 2's seed, not request 1's | +| each key input changed (max_t, max_cells, pcie_mode, tier, cluster top-k, weights epoch, owners epoch) | re-record with `KeyChanged(name)`, 1 drafter release, the new set kept again | +| owners moved by the prefill (`take_back` refused) | re-record with `OwnersChanged`, owners not lost, the new set kept | +| `rearm` refused | the owners are lent out again, the set retired (1 drafter release), re-record `RearmRefused`, next request re-arms | +| `park` refused | not kept, owners home, every request records | +| request failed or cancelled | not kept, owners home, next request records `NothingHeld`; `invalidate` of a kept set releases the drafter once | + +### Part 2: the verify bank's re-arm API (done by the speed session; the text below is the spec it was written from) + +Needed in `crates/cuda-driver` (`original_verify_schedule/*`, `original_verify.rs`, `original_verify_gpu_plan*`): + +```rust +/// Seed of the next request: the session's recurrent priors, in the canonical image's layout. +pub struct OriginalVerifyRearm<'s> { + pub gdn_states: [&'s [f32]; 36], // 128*48*128 f32 each + pub gdn_histories: [&'s [f32]; 36], // 10240*3 f32 each + pub ple_history: &'s [f32], // 9*10240 f32 +} +impl<'ctx, R: OriginalVerifyGraphResources<'ctx> + OriginalNativeHeadGraphResources<'ctx>> OriginalVerifier<'ctx, R> { + /// End of a request: drain both streams, wait a pending commit; keep graphs, bank, streams and event. + pub fn park(&mut self) -> Result<()>; + /// Start of the next request over the same recording. `Err` leaves the verifier unusable (the caller retires it). + pub fn rearm(&mut self, seed: OriginalVerifyRearm<'_>) -> Result<()>; +} +impl OriginalVerifyCanonicalGdn<'_> { + /// Overwrite the image in place (same device address): states and histories, 117.7 MB host to device. + pub fn reseed(&self, states: [&[f32]; 36], histories: [&[f32]; 36]) -> Result<()>; +} +``` + +Preconditions of `rearm`: `park` ran (both streams idle, `commit_pending`, `window_ready` and `active` false, `failed` false, +not released); every captured graph is quiescent; the QSA journal is not armed and not lent. State it resets (everything a +fresh `OriginalVerifier::new` + `record_all` leaves, so the first `run` of the new request sees what the first `run` after a +recording sees): + +* `OriginalVerifier`: `windows = 0`, `commits = 0`, `completed_generation = None`, `completed_ids = [0; 8]`, profile counters; + `split`, `groups`, `resource_keys` as recorded. +* `OriginalVerifyBank`: `last_t = 0`, `last_position = 0`, `last_tokens = [0; 8]`, `last_keep = 0`, `generation` advanced (old + `OriginalVerifyRow` / `OriginalVerifyWindow` values are refused), `released = false`, `pcie_sources` cleared (held until the + previous copy-stream fence); `pcie_mode` / `pcie_roles` unchanged (they are in the key). +* Every device and mapped flag the graphs wait on or raise (`verify_wait_flag_ge_kernel` / `_or_kernel` operands, the group flag + rings and doorbell of `raise_group_flag` / `wait_doorbell`, the `verify_clear_status` words, the ident-hit and tail-snapshot + flags): back to the value they have at the end of `record_all` (zero). The graphs compare against a "want" that counts up + inside a window; it must restart. +* The gpu-plan state in `Physical.mapped[..]` (the published plan, the fetch tables) and `prof`: cleared. +* The canonical GDN image (`reseed`) and the PLE history image (`seed.ple_history`, through the journal's `ple` handle). + +Postcondition for the stack: the first `stage_window` of the new request is accepted at any `position` the QSA owners stand at. +The policy retires and re-records on any `Err` or `false`, so a partial re-arm is safe. + +## 5. Validation (GPU, orchestrator) + +1. Identity: greedy output and top-16 logprob rows over N requests with different prompts and lengths, switch on vs off, + with an eviction of a shared expert in between, a changed `max_t` (graph OOM fallback) and a request that fails in the + middle (each must re-record and match); the draft trace of request 2 equal to the fresh-assembly run. +2. The stderr lines: `decode graph reuse ... on` at open; `decode graphs recorded again: ` for every request that did not + re-arm (expect none after the first in a steady run; `OwnersChanged` means the prefill moved an owner buffer, `RearmRefused` + a driver refusal). +3. Spans, paired A/B on the same workload (cache state recorded): `decode.assemble` (recording) against `decode.reuse` + (take back + re-arm), `decode.disassemble` against `decode.keep` (park + lend + adopt), `record.capture`, + `record.instantiate`, `record.modules` (should be 0 after the first request), the first-draft capture in `draft.*`, + `prefill.*` (the pins and the kept pool must not slow the prefill), end-to-end request time. +4. VRAM at the decode low-water mark (`vram_note "decode end before disassemble"`) and during the prefill: a kept set holds the + graph pool, the bank arena, the mapped staging and the 118 MB canonical image; the loan ladder and the prefill arena + budget see that much less. +5. The GPU tests of the speed session's doc (section 5 of `verify-decode-graph-reuse-handles.md`) and the journal check of + B2 (lend, a prompt over the owners, take_back accepted; a `reset` of the mapped journal between must be refused). + +## 6. Expected size of the win and what stays + +Removes `record_all` (83-85 ms) and the aggregate construction; the canonical image upload and per-request state seeding stay +(about 15-25 ms of the 98-109 ms), `decode.disassemble` (B4, 11.7 ms) becomes a park. The kept pool costs VRAM during prefill. diff --git a/docs/experiments/plan-faster-than-strata.md b/docs/experiments/plan-faster-than-strata.md new file mode 100644 index 00000000..4c85e0ce --- /dev/null +++ b/docs/experiments/plan-faster-than-strata.md @@ -0,0 +1,50 @@ +# План: Leleka стабільно швидше за Strata на агентських задачах + +Власник: оркестратор. Працюємо тільки за цим планом; нова ідея спершу потрапляє сюди, потім у роботу. Реєстр кроків: `docs/experiments/step-ledger.md`. + +## Ціль і мірило + +* Реальні агентські задачі (Codex: `nestng-crm`, `ttt`), довгий контекст 30–245k. +* База vanilla (не перемірювати): VANL 202,1 ток/с і 462 с задачі, VAN 222 ток/с і 434 с (n=3). +* Поточний LEL: 158–160 ток/с декод, 485–555 с задачі. Розрив −21 % декоду. +* Успіх: LEL ≥ VAN за часом задачі й ток/с на обох задачах, accept 56/56, ttt грається. + +## Правила + +1. Лінійно по конвеєру запиту: запит → prefill → decode-раунд. Крок N+1 після закриття кроку N. +2. Закриття кроку = виміряна дільнична дельта (профіль цього кроку) + ідентичність (2057 logprob-рядків, 1036 draft-рядків) + запис у реєстрі. Не відкидати «нижче шуму». +3. Після кожного етапу груповий e2e: повні сесії Codex проти бази, без перемірювання vanilla. +4. Lossy (tail skip тощо) лише з окремим гейтом і словом власника. Дефолти lossy не вмикаємо. +5. Правила коду: доменні DTO, змістовні імена (також для завдань і гілок), функції ≤30 рядків, ≤5 параметрів, файли ≤400, гейти limits/arch на нулі. +6. Черга GPU йде в порядку етапів (prefill перед decode). Імена завдань словами: `<область>-<що>-<крок>`. + +## Етапи і статус + +| Етап | Зміст | Власник | Статус | +|---|---|---|---| +| 0 | Архітектура (гексагональна, розміри, params, імена) | hex-finish | **зроблено**, локально, пуш чекає ssh | +| 1 | Пам'ять: розріджений holder (одна копія) | hex-finish | **зроблено** (+42 ГБ вільно) | +| 2 | Запит: інтейк, resume, prefix import (A1–A3) | hex-finish | вимір ідемпотентний «порожній запит» чекає GPU | +| 3 | Prefill: ladder (Q1–Q5), refill (Q6), паркування prefix (B1–B5), запис графів (Q7) | hex-finish | ladder готовий, профіль чекає A/B; решта в черзі | +| 4 | Decode: чернетка (ланцюг одним проходом, перевірки finite) | hex-finish | S1 закомічено, чекає ідентичність/A/B | +| 5 | Decode: verify-граф (бічні гілки: mixer, QSA, shared) | speed | **зроблено**, дефолт увімкнено (+1,39 % і дільничні дельти) | +| 6 | Decode: ядра mixer-половини (S10 батчований append K/V, GDN K7/K7a), accept на пристрої (0,32→0,08 мс), commit (fused) | speed | у роботі | +| 7 | Груповий e2e: CRM×3 і ttt×3 проти бази | обидва | після етапів 2–6 | +| 8 | Рішення власника: tail skip (+10…12 %, не пройшов гейт CRM) | власник | відкрито | + +## Задачі в LeaseVibe (залежності лінійні) + +Батьківська задача STRA-368. Ланцюг: STRA-369 (пам'ять, зроблено) → STRA-370 (запит A1–A3) → STRA-371 (prefill ladder) → STRA-372 (refill і паркування) → STRA-373 (запис графів) → STRA-374 (чернетка) → STRA-375 (verify бічні гілки, зроблено, чекає груповий A/B) → STRA-376 (verify-ядра і accept на пристрої) → STRA-377 (commit, хост-хвіст) → STRA-378 (груповий e2e). Окремо STRA-379 (рішення власника: tail skip, Playwright, ssh). Статуси на дошці переводить людина (workflow Backlog → Ready for BA), тож актуальний стан у summary задач і в цьому плані. + +## Відкриті блокери і рішення власника + +* ssh-агент ноутбука: пуш на сервер не проходить, усе коміти локально. +* Дозвіл поставити Playwright для браузерної перевірки ttt (поки лише статика 14/14). +* Tail skip: чи ризикувати ради +10 %. +* База порівняння застаріла: upstream Strata на 2026-11-09 це engine 0.1.59 / app 0.2.13.1 (наш пін 0.1.50, 1985 комітів різниці; релізи v0.2.7 .. v0.2.13). Для NVIDIA/Blackwell є зміни: DFlash2 per-device (Blackwell cc 12.0: conf 0.35→0.55, window 6→8), MMQ_KQ дефолтом для cc>=8.0, виправлення передачі completion. Чекає рішення власника: взяти нову базу (одне вимірювання CRM x3 нової ваніли, версія на вибір) і додати в реєстр їхні нові кроки. + +## Ритм оркестратора (кожна перевірка) + +1. Черга GPU (що біжить, що за ним, порядок етапів). +2. Лічильники реєстру (open/fixing/fixed/proved-equal). +3. Блокери і дрейф від плану; нове питання записати сюди, а не розпочинати. diff --git a/docs/experiments/refill-batch-copy.md b/docs/experiments/refill-batch-copy.md new file mode 100644 index 00000000..446a4d7c --- /dev/null +++ b/docs/experiments/refill-batch-copy.md @@ -0,0 +1,102 @@ +# Lent-slot refill with batched copies (`LELEKA_REFILL_BATCH`, EXPERIMENTAL, off by default) + +Date 2026-11-10. Branch: a sub-agent branch on top of `claude/prefill-latency` (cdb0958b6). Status: **code and host-side +tests only; nothing has run on a GPU. No speedup is claimed.** Step ledger row Q6. + +## Problem (M, ledger Q6) + +After every prompt the expert-cache slots the prompt borrowed as scratch (999 to 2,226 slots) are refilled from the +registered host bank: `original_serve_residency::refill_lent` calls `OriginalExpertCache::fill_slot_queued` (or +`_async` under `LELEKA_REFILL_DEFER`) once per slot. Each call enters the context and issues one +`cuMemcpyHtoDAsync_v2` per piece. A slot has three pieces (gate, up, down), or more when `pin_resident` ranges cut a +piece. On the 5090 (driver 595.99.02, CUDA 13.2) the host time to issue the copies is `refill.queue` = 70 ms per +request (about 70 us per slot); `refill.sync` is 23 ms. Both sit on the request's critical path. `LELEKA_REFILL_DEFER` +only moves the wait. + +## Design + +* `LELEKA_REFILL_BATCH=on|1` (`settings::memory::MemorySettings::refill_batch`; the driver reads no environment). + When it is on, `refill_lent` collects every `(slot, spans)` pair that needs a refill, in slot order, and makes one + call: `OriginalExpertCache::fill_slots_queued_batched(bank, fills, RefillBatchOptions { own_stream, + max_copies_per_call: 512 })`. +* The cache checks every slot the way `fill_slot_queued_on` does: owner, state, registered source and capacity. It also + refuses a duplicate slot. It builds the piece list with the per-copy path's own code (`cache_source`, `copy_pieces`, + the `checked_subspan` destinations) and in its order: slot by slot, then gate, up, down. It retains every source + `Rc` in `pending` before anything is queued, enters the context once, and issues the list. +* `refill_batch_copy::plan_batch_calls` (pure) cuts the list into consecutive calls of at most 512 copies. It leaves + out empty copies, which move no byte and which the batch entry refuses. `issue_copies` makes one + `cuMemcpyBatchAsync_v2` per call with one attribute: `srcAccessOrder = STREAM`, no location hints, flags 0. Each + call gets the same destinations, sources and sizes as the per-copy path, so the slot bytes must come out identical. + Only the host cost of issuing them changes. +* **Stream.** The batch entry does not take the legacy default stream. The per-copy refill uses that stream unless the + refill is deferred. As far as I recall, the CUDA documentation says the batch entry refuses the legacy NULL stream; + no header or documentation was available here to confirm it, and it has not been checked on the 5090. So the batch always runs on the cache's own non-blocking `fill_stream`. For a refill that is not + deferred, the cache first records `fill_event` on the legacy default stream and makes `fill_stream` wait for it + (`cuStreamWaitEvent`). The copies therefore still start only after everything queued there before them. `sync_queued` + already waits for both streams, and it stays the fence (`settle_refill`, `lend_prefill_tail`, close). +* **Binding.** `api::AsyncApi` resolves `cuMemcpyBatchAsync_v2` and `cuStreamWaitEvent` as optional symbols + (`api/enabled/batch_copy.rs`). If either is missing, the batch is unavailable and the refill is issued per copy. The + prototype is the CUDA 13 `_v2` form without `failIdx`: dsts, srcs, sizes, count, attrs, attrsIdxs, numAttrs, stream. + `CUmemcpyAttributes` is 24 bytes, and a compile-time assertion checks that size. These are the prototype and layout + that `original_gpu_schedule_ffi` already uses for the verify window's PCIe DMA. The stub for non-CUDA builds answers + `can_batch() == false`. +* **Fallback and errors.** The per-copy path is used when: + * the driver has no batch entry; + * the bank is pageable (the low-RAM file mapping); + * this cache saw a batch call refused before. + If a batch call fails, the warning is printed once (`leleka-serve: WARNING: the driver refused a batched expert + refill ...`) and `batch_refused` is set on the cache. The refused call and every later copy are then issued one + `cuMemcpyHtoDAsync_v2` each on the same stream. A copy the refused call may already have queued is copied again with + the same bytes. An error from a per-copy call, or from the event record or wait, poisons the cache and is returned, + exactly like the per-copy path. + +## Counters (`LELEKA_SERVE_PROFILE=1`) + +| name | meaning | +| --- | --- | +| `refill.batch_calls` | `cuMemcpyBatchAsync_v2` calls the driver accepted (sum per request) | +| `refill.batch_copies` | copies those calls carried | +| `refill.per_copy` | copies issued one call each by the batched path: no entry, pageable bank, or after a refusal | +| `refill.queue`, `refill.spans`, `refill.sync` | unchanged; with the switch on, `refill.queue` is the one batched call | + +## Tests + +* Host (run on the laptop, `cargo test -p leleka-cuda-driver --features cuda-driver --lib refill_batch_copy`): + * calls are cut into consecutive ranges no longer than the cap; + * order, destinations, sources and sizes are preserved; + * a list within the cap gives one call, and an empty list gives none; + * 2,226 slots x 3 pieces give 14 calls of up to 512 copies; + * empty copies are left out but keep their place; + * a cap of 0 or above 4,096 is refused. +* Settings: `LELEKA_REFILL_BATCH` is in `refill_defer_batch_and_locked_only_are_on_or_one`. It is an engine-crate + test, so it runs in WSL/Linux only and was not run here. +* GPU, `#[ignore]`: `refill_batch_copy_gpu_slots_equal_per_copy` (`crates/cuda-driver/src/refill_batch_copy_gpu.rs`) + fills 1,024 slots of 3 role-major pieces from one registered host buffer twice: once per copy, once through + `issue_copies` in calls of 512. It requires every byte to be equal between the two and to the host bytes, with the + gaps left untouched: + `cargo test --release -p leleka-cuda-driver --features cuda-driver,sm120 --lib -- --ignored --nocapture refill_batch_copy_gpu`. + +## What the GPU validation must show (not done) + +1. The ignored GPU test passes on the 5090 (and, separately, on the laptop: on the RTX 3080 under Windows, + `cuMemcpyBatchAsync_v2` from page-locked memory faulted with error 700 in `docs/windows.md`, so the switch must stay + off there unless this test passes). +2. Serve identity: the same requests with `LELEKA_REFILL_BATCH` off and on give identical greedy replies and + logprob rows. `verify_slot` of refilled slots, or a slot read-back after `settle_refill`, matches the bank. +3. `LELEKA_SERVE_PROFILE=1`, 14 or more warm requests per arm on the default set: + * `refill.queue` per request, before and after; + * `refill.sync`; + * `refill.batch_calls` and `refill.batch_copies` (expected: copies / 512 calls, and `refill.per_copy` = 0 on the + registered bank); + * wall time per output token. + A speedup may be claimed only from that paired A/B with the quality result. + +## Risks + +* The prototype and attribute layout come from the existing verify-window binding, not from the headers on this + machine (none are installed here). An ABI mismatch would show as a refused call (fallback) or as wrong bytes; the GPU + test checks for both. +* The first non-deferred batched refill creates `fill_stream` and `fill_event`. The fill stream is non-blocking, so + default-stream work queued after the refill is not ordered after it. Every reader of the lent slots waits in + `sync_queued` first, as with the deferred path. +* Driver faults of the batch entry on some Windows drivers (above): the switch is off by default. diff --git a/docs/experiments/ring-prefetch.md b/docs/experiments/ring-prefetch.md new file mode 100644 index 00000000..8ebfe298 --- /dev/null +++ b/docs/experiments/ring-prefetch.md @@ -0,0 +1,149 @@ +# Prompt copy-ring prefetch (EXPERIMENTAL, off by default) + +Switch: `LELEKA_PREFILL_RING_PREFETCH` (engine settings, `ServeSettings::prefill_ring_prefetch`). Status: implemented +and host-tested only. No GPU run, no identity probe, no A/B yet. No speedup is claimed. + +## Problem + +Chunks below the expert stream's row minimum (0.2-1.5k rows on the 5090 profiles; chunks from 1536 rows already use +the expert stream) go through the per-layer copy ring. Our profiles show that ring is bound by PCIe DMA. Per request, +7,000-12,000 experts that are not resident (14-26 GB, 146-266 per layer, about 2.05 MB each) cross the bus at about +45 GB/s. `ring.finish_statuses`, the wait for the copies and the kernels, takes 230-420 ms of a 530-830 ms +`prefill.read`. Each layer's GDN/QSA/attention stage takes about 7 ms (about 330 ms per request), and PCIe is idle +during it. + +## Design + +1. **History** (`leleka_cuda_model::ring_prefetch::MissHistory`). Every `Ring::new` records the layer's missed set: + the experts that were routed and not resident. The history is per layer, as a 512-bit mask per chunk, and keeps the + last `window` chunks (default 8). Missed sets are per layer because each layer has its own resident set, and the + lent slots change between requests. +2. **Prediction** (`MissHistory::predict`). Experts are ranked by how many recorded chunks missed them, then by the + most recent chunk that missed them, then by id. Experts resident right now (`cache_expert_span`) are skipped. The + top `K` are kept, with `K = min(top_k, ring_slots / 2)`, and `K = 0` for a ring under 32 slots: the literal 8-slot + ring of the 512-row rung is never prefetched into. +3. **Issue** (`OriginalMmqCopySchedule::prefetch_ring_layer`, called from `run_prompt_layer` through + `OriginalMoePromptLayer::prefetch_ring_layer`). This runs right after layer `l`'s ring has closed, which drains both + streams, and before layer `l`'s combine. The predicted experts of layer `l+1` are copied into stage slots + `0..K-1` of the same row lease. Each copy is the same as `stage_one`'s: the aligned supersets or the exact pieces, + with the same destination offsets. The copies run on the schedule's copy stream, and each slot's `copied` event is + recorded. The engine resolves the spans from the span cache, or from a walk of the binding that changes nothing. + Only experts whose bytes already passed the finite admission scan are resolved; others are not prefetched. By default + the drains stay context-wide: the combine's and the next mixer's drains wait for these copies (the PCIe time then + overlaps only the GPU work queued before such a drain). With `LELEKA_PREFILL_RING_PREFETCH_DETACH=1` the copy stream + becomes the `compute_drain` background stream, as under the chunk expert stream: the drains stop waiting for it, + all-zero uploads become memsets and frees are deferred. +4. **Adopt** (`Ring::adopt_prefetch`, in `Ring::init` after `admit_sources`). The next ring takes the set (in the detached + mode this restores the context-wide drains and flushes the deferred frees). The set is used only if it was issued for this + layer, from the same bank (`Rc::ptr_eq`), into the same slot spans, with the same blob size, and with no chunk + stream. Otherwise it is drained and dropped. A routed, non-resident source whose host byte ranges are equal to an + entry's ranges is consumed from that slot (`source.slot`, `dest`, `prefetched`). The slot is marked `reserved` + until that source's gather, and its `copied` event orders the gather. Each entry is consumed at most once + (`match_prefetch`). Entries that were not routed, or that became resident, are wasted: the slot stays free, and a + later stage copy into it is ordered behind the prefetch by the copy stream's FIFO order. +5. **Ring walk.** The slot bookkeeping is the pure `SlotState` / `stage_needed` / `stage_target` of + `leleka_cuda_model::ring_prefetch`, which the driver's `Ring` and the host tests both call. `stage_one` skips prefetched + sources and picks the next slot that is not reserved. Without reservations, that slot is the literal `stage_next`. + `ring_stage_ahead` stops early when the next free slot is not gathered yet (`Ring::stage_room`, always true without reservations). The + reserved slots therefore shrink the lookahead and never cause an overwrite. Since `K <= slots / 2`, a free slot + always exists. + +The same experts reach the same gather, the same kernels and the same group order. Only the time and the order of the +H2D copies change, so the outputs must be bitwise identical. + +**Lifetime and errors.** `end_prompt_stream` is called on every forward exit and on a failed layer. Like +`begin_prompt_stream` and the schedule's `close`, it cancels a set that no ring took: it synchronizes the copy stream, +drops the set and restores the drains. A failure while issuing is not returned to the layer. It is counted as +`ring.prefetch_failed`, the copy stream is synchronized, and fewer experts are prefetched; the ring copies the rest as +usual. A set that was adopted is covered by the ring's own drain, because `submitted` is set. + +## Switch + +| Variable | Values | Default | +|---|---|---| +| `LELEKA_PREFILL_RING_PREFETCH` | `1` / `on` (top K = 150), or a top K in `2..=512` | off | +| `LELEKA_PREFILL_RING_PREFETCH_WINDOW` | recent chunks counted, `1..=64` | 8 | +| `LELEKA_PREFILL_RING_PREFETCH_DETACH` | `1` / `on`: detach the drains from the pending copies (EXPERIMENTAL) | off | + +The driver reads no environment variable for this feature. The policy is passed with +`OriginalMmqCopySchedule::set_ring_prefetch` when the arena owners are attached. + +## Refusal and decision trace (`LELEKA_TRACE_DRIVER_ERRORS` or `LELEKA_BRINGUP_TRACE`) + +The engine passes its driver-error trace switch with `OriginalMmqCopySchedule::set_ring_error_trace`; the driver reads no +environment variable. Every copy-ring refusal still returns `InvalidProjectionShape` but also prints +`RING-REFUSE layer=.. check=.. source=.. stage_next=.. reserved=.. slots=.. sources=.. error=..`. The checks: +`new.validate`, `new.schedule_slots`, `layer.preflight`, `sources.spans`, `stream.layer` / `stream.no_entry` / +`stream.entry_bytes` / `stream.pieces`, `stage.no_source`, `stage.source_already_staged`, `stage.all_slots_reserved`, +`stage.slot_not_gathered`, `gather.no_source`, `gather.no_slot`, `gather.slot_not_live`, +`gather.slot_already_gathered` (followed by `gather.slot` from the caller), `enqueue.closed_full_or_context`. The +prefetch prints `RING-PREFETCH layer=.. issued=..`, `layer=.. hits=.. wasted=..`, `layer=.. dropped=.. issued_for=..`, +`layer=.. cancelled=..` and `layer=.. issue failed: ..`. + +## Counters (`LELEKA_SERVE_PROFILE=1`) + +| Name | Call count | Value | +|---|---|---| +| `ring.prefetch_issued` | experts copied ahead | MB | +| `ring.prefetch_hit` | prefetched experts consumed by the ring | MB | +| `ring.prefetch_wasted` | prefetched experts not consumed (mispredicted, resident by then, or a set dropped) | MB | +| `ring.prefetch_failed` | issue attempts that stopped on an error | 1 each | +| `ring.prefetch_issue` | host span of the issue | ms | +| `ring.copied_mb` | unchanged: copies `stage_one` still made (hits are not counted here) | MB | + +The hit rate is `hit / issued`. The PCIe bytes saved from the ring's critical path equal `hit` MB. The extra bus +traffic equals `wasted` MB. + +## What the GPU validation must show + +1. **Identity.** Run with `LELEKA_TRACE_PREFILL_R=1`, once with the switch off and once with it on, on the same + prompts. Use 0.2-1.5k-row chunks (the 2048-row rung, 384 slots) and also 512-row rung chunks (8 slots, where the + prefetch is a no-op). Every chunk's R hash must be equal. Also check the first-token logprob rows / greedy output. +2. **Counters.** `ring.prefetch_hit / ring.prefetch_issued` should be near the offline 55-57 % at K = 150-200. + `ring.copied_mb` should fall by the hit MB. +3. **Latency.** Run a paired A/B of `prefill.read` and `ring.finish_statuses`, by tail class (chunk rows: <512, + 512-1535, >=1536 as the control, where the prefetch must stay inactive). Measure on the same workload and record the + run metadata the charter requires. Watch `ring.init_sync`: it now waits for prefetch copies that are still in + flight. Run the identity first with `_DETACH` off; only then the detached mode, which also changes the mixer's + drains, memsets and frees while the copies are pending. +4. **Sweeps.** K in {100, 150, 200} and window in {4, 8, 16}. + +## Risks and open points + +- The prefetch competes with the combine's and the next mixer's own H2D uploads on the copy engines. A large K that + outlasts the mixer delays the ring's mandatory copies, which queue on the same stream behind the prefetch. +- `ring.init_sync` (a context synchronize) waits for every prefetch copy, wasted ones included. +- Experts that were routed only once so far (and never finite-scanned) are not prefetched. +- Layer 0 of a chunk is never prefetched, because the prefetch is issued from the previous layer of the same chunk and + row lease. +- Not tested on a GPU: the event ordering, the background-stream switch and the reserved-slot walk are covered only by + review and by the host tests in `crates/cuda-model/src/ring_prefetch/tests.rs`. + +## First GPU run (PET.1, 2026-11-10): failures with the first commit + +With the first commit (`3ba2a0e37`, the background stream always on) 5 of 12 requests failed with +`InvalidProjectionShape`, and 9 of 30 in the earlier run. From reading the code, the host slot bookkeeping holds: the host +tests drive the same functions through the scenarios that were suspected (a prefetched source staged again, a reserved +slot reused, a gather of a slot that was never filled or was already read), and none of them can be reached. The +unreviewed change was the background stream. It is a process-wide switch that changes every drain, memset and free +of the small-chunk mixers and routers while the copies are pending. A drain in that mode skips streams that are not +registered, for example the QSA resident-transfer side stream. This is a suspect, not a proven cause: the error code +alone does not say which check refused. That mode is now opt-in +(`_DETACH`). If the failure persists with it off, the `RING-REFUSE` line names the check. + +## Second GPU run (pkg-s16, 51b36adf7): `stage.slot_not_gathered` on layers 46/47 + +9 of 30 requests failed with the same refusal in both arms (with and without `_DETACH`): +`RING-REFUSE layer=46|47 check=stage.slot_not_gathered source=391..435 stage_next=7..191 reserved=0 slots=384 +sources=410..460`. So the detached drains were not the cause. The cause was the slot search. Without a prefetch, +copies and gathers run in the same order and the lookahead is one slot short of the ring, so the next slot in ring order +always holds the oldest copy, already gathered. With prefetch hits, the copies skip the hit sources, and once the +layer's sources exceed the ring, the wrap reaches a slot that holds an earlier source's copy that is not gathered yet. +The old `stage_room` shortcut (`reserved == 0`, true once every hit was gathered) then let `stage_one` refuse. + +Fix: `stage_target` searches forward, wrapping, for the first slot that is not reserved and is free (never filled, or +already gathered). Without a prefetch it finds `stage_next` itself, as in the literal ring. `stage_room` is now always +"needs no copy, or `stage_target` finds a slot", so the walk waits for a gather instead of refusing. Host tests: 200 +seeds of 460 sources on 384 slots with random prefetch hits among the first 300 sources, plus other sizes. The model +asserts that no stage targets a reserved or unread slot, and that `stage_target` refuses only when no unreserved slot is +free. With the old `stage_target`, both assertions fail. \ No newline at end of file diff --git a/docs/experiments/step-ledger.md b/docs/experiments/step-ledger.md index 5f2967a0..7c993431 100644 --- a/docs/experiments/step-ledger.md +++ b/docs/experiments/step-ledger.md @@ -21,9 +21,9 @@ No per-step figure exists for A1-A3; each is a `not measured` row that needs a s | id | step | LEL | VANL | difference | source | owner | status | | --- | --- | ---: | ---: | ---: | --- | --- | --- | -| A1 | HTTP, gateway and proxy time per request | not measured per step | not measured per step | the sum 'rest' per request is Q10: 22 ms against 32 ms | LOG | hex-finish | open | -| A2 | tokenizer and prompt assembly | not measured | not measured | n/a | none | hex-finish | open | -| A3 | prefix-cache lookup and import (cached tokens per request, import time) | not measured | not measured | n/a (replay logs `cached_tokens`; import time only in `last_import_split`) | none | hex-finish | open | +| A1 | request: HTTP, gateway and proxy time (code `pf_probe.py`) | probe pending (job `prefill-empty-request-probe-leleka`) | none: vanilla is not re-measured (owner 2026-11-09); the vanilla figure comes from its existing logs | the sum 'rest' per request is Q10: 22 ms against 32 ms | LOG | hex-finish | measured (probe job `prefill-empty-request-probe-leleka`, 2 boots x 2): tiny prompt wall 0.540 s = engine spans 503 ms (prefill.read 250, refill 137, assemble 94, disassemble 11, round 10, draft 1) + 37 ms outside the engine; cached long prompt wall 0.157 s = engine 120 ms + 37 ms. The same 37 ms for both (client, HTTP, gateway, SSE close) is A1. Vanilla not re-measured (owner); Q10 'rest' per request in real sessions is LEL 22 ms against VANL 32 ms: no loss shown, proved-equal (LEL ahead) | +| A2 | request: tokenizer and prompt assembly of a long prompt | probe pending (job `prefill-empty-request-probe-leleka`: long cached prompt minus tiny prompt) | not measured | n/a | none | hex-finish | measured: long cached prompt minus tiny prompt outside the engine = 0 ms (37 ms both), so tokenizer and prompt assembly of the 67k-token prompt cost under the probe precision (about 2 ms); proved-equal | +| A3 | request: prefix-cache lookup and import (code `request.resume`, `ctrl.begin_request`, `prefix.*`) | PROFILE `runs/dc1` (60 requests): `request.resume` 2.53 + `ctrl.begin_request` 0.60 + `prefix.import_session` 0.80 + `prefix.draft_resume_at` 1.05 + `prefix.mtp_kv_restore` 0.61 + `prefix.layer_index` 0.38 = 5.97 ms per request | not measured | n/a (replay logs `cached_tokens`; import time only in `last_import_split`) | none | hex-finish | measured, cached repeats of the 67k prompt: request.resume 2.2-2.9 + ctrl.begin_request 0.8 + prefix.import_session 0.6-1.4 + prefix.draft_resume_at 0.8 + prefix.mtp_kv_restore 0.7 + prefix.layer_index 0.4 = 5.5-7.0 ms per request; vanilla's import is inside its prompt time and not separable without the instrumented copy (not built: no evidence that the sums diverge); open at 5.5-7.0 ms | | Q10 | gateway, proxy, serialization ("rest" per request) | 22 ms | 32 ms | -10 ms | LOG | hex-finish | proved-equal (LEL ahead) | ## B. Prefill (chunks, expert ring and copies, refill, QSA, GDN, first token), then the hand-over to decode @@ -31,15 +31,18 @@ No per-step figure exists for A1-A3; each is a `not measured` row that needs a s | id | step | LEL | VANL | difference | source | owner | status | | --- | --- | ---: | ---: | ---: | --- | --- | --- | | Q8 | request time per output token, prefill + decode | 0.59 + 5.63 = 6.22 ms | 0.36 + 4.61 = 4.97 ms | +1.25 ms (decode +1.02, prefill +0.23) | LOG | both | open | -| Q1 | prefill per request at equal uncached tokens | 726 ms | 431 ms | +295 ms | LOG | hex-finish | open | -| Q2 | prefill latency by uncached tokens (< 64, 64-256, 256-1024, 1024-4096, >= 4096), median ms | 430, 530, 722, 1002, 4405 | 268, 292, 435, 715, 2184 | +162, +238, +287, +287, +2221 | LOG | hex-finish | open | -| Q3 | prefill throughput over uncached tokens | 930-1050 tok/s | 1460-1560 tok/s | -35 % | LOG | hex-finish | open | -| Q4 | `prefill.read` fixed part (581 ms + 0.134 ms per token; 485 ms for 239 tokens) | 485-581 ms | whole prefill of that size class 292 ms | +193 and more | PROFILE | hex-finish | open | -| Q5 | `moe.ring` in a small tail (72-80 % of the chunk, 48 layers x 7.4 ms, 355 ms for 238 tokens) | 355 ms | vanilla reads tails of up to 64 tokens through verify windows | +355 ms for the smallest tails | PROFILE `prof-l5` | hex-finish | open | +| Q1 | prefill: time per request at equal uncached tokens (code ladder `LELEKA_PREFILL_LOAN_TIERS`) | 726 ms | 431 ms | +295 ms. Ladder (`LELEKA_PREFILL_LOAN_TIERS=1`) paired on the sparse holder, n=5 blocks: -3.1 s per 30-request session +-0.5; <= 2048 new tokens -151 ms per request (faster in 19 of 19); n=10 (5 + 5 blocks, jobs `ab3` and `prefill-ladder-ab-pairs-6-10`): -3.0 s +-0.3 per 30-request session, median -104 ms per request, <= 2048 new tokens -154 ms (19 of 19 faster), > 2048 tokens -10 ms; identity PASS (chunk residual hashes equal) | LOG | hex-finish | fixed for the ladder part (switch committed in the 5090 profiles); the remaining gap at equal uncached tokens (rows Q2, Q3) stays open | +| Q2 | prefill latency by uncached tokens (< 64, 64-256, 256-1024, 1024-4096, >= 4096), median ms | 430, 530, 722, 1002, 4405 | 268, 292, 435, 715, 2184 | +162, +238, +287, +287, +2221 | LOG | hex-finish | open AFTER THE STREAM THRESHOLD 2026-11-10: VANL means from the VANL engine logs (`read in X ms`, 3 reps): 64-256 tokens 294 ms (n=121), 256-1024 447 (n=72), 1-4k 820 (n=23), > 4k 2062 (n=8); ours `prefill.read` with `STRATA_PREFILL_STREAM_MIN=1536`: 64-256 about 400-620, 256-1024 521, 1000-1536 729, 1536-4096 830, 4k+ 1245-1500: at parity from 1 to 4k tokens and ahead beyond 4.9k, behind by +75..+170 ms below 1k tokens (VANL reads 64-256 tokens in 294 ms = 14 GB / 50 GB/s with the rest of the chunk hidden under the DMA; ours has the DMA at 45 GB/s and about 130 ms of GDN/QSA unoverlapped). Open: ring prefetch (sub-agent, switch off), U6. | +| Q3 | prefill throughput over uncached tokens | 930-1050 tok/s | 1460-1560 tok/s | -35 % | LOG | hex-finish | open see Q2 (2026-11-10): the gap that remains is below 1k tokens, not a throughput gap above it. | +| Q4 | prefill: fixed part of the chunk read (code `prefill.read`, 581 ms + 0.134 ms per token; 485 ms for 239 tokens) | 485-581 ms | whole prefill of that size class 292 ms | +193 and more | PROFILE | hex-finish | open: root cause found (see Q5) RING FINDINGS 2026-11-10 (jobs `prefill-ring-host-spans-profile`, `prefill-ring-copied-megabytes-profile`, pkg-s11/s12, 15 requests): `moe.ring` is DMA-bound, not host-bound. Host spans of the copy ring per request with a 1.4k tail: init 10.5 ms (`init_sync` 0.0), stage 50.7, gather 36.3, enqueue 30.1 (about 130 ms, parallel with the DMA), `finish_statuses` (host waits for the GPU/DMA) 335.8 ms; the wait grows about 200 ms fixed + 0.08 ms per tail token. Experts copied over PCIe per request: 7,002 (14.3 GB) at a 279-token tail, 8,794 (18.4 GB) at 1,243, 11,576 (24.0 GB) at 1,454, 12,762 (26.5 GB) at 2,837; 146-266 per layer, 45-55 % of the routed experts are not resident. GB / 45 GB/s = 319, 410, 459, 590 ms vs ring wall 332, 428, 462, ~590: the ring runs at the PCIe rate. So synchronisation fixes (step A: syncs, cuMemGetInfo, gather by 16) buy nothing. Offline prefetch study (`LELEKA_PREFILL_ROUTE_TRACE`, 30 requests): the experts the layer's last 3-16 chunks missed predict the next chunk's missing set with 60 % precision at 150 experts per layer (86 hits), an upper bound of about -150..-190 ms per request for a prefetch under the GDN/QSA stage; not built (complex, 40 % wasted bandwidth). PREFETCH FIRST GPU RUN 2026-11-10 (pkg-s14, `LELEKA_PREFILL_RING_PREFETCH=1`, sub-agent branch merged, default off): 9 of 30 requests failed with `class=InvalidDimension` and the chunk hashes differ (60 PREFILL-R lines vs 31): the implementation is NOT correct yet; driver error trace job queued (`prefill-ring-prefetch-failure-driver-error-trace`). Remains OFF. | +| Q5 | `moe.ring` in a small tail (72-80 % of the chunk, 48 layers x 7.4 ms, 355 ms for 238 tokens) | 355 ms | vanilla reads tails of up to 64 tokens through verify windows | +355 ms for the smallest tails. Root cause: `prompt_options` (`original_serve_stack_prefill_phase.rs`) sets `force_batched: true`; the planner already emits `PromptPath::Verify` actions for tails <= 64 tokens but the executor's `verify_window` hook (`original_prompt_executor_drop.rs:63`) is not implemented | PROFILE `prof-l5` | hex-finish | fixing (design pending) STREAM THRESHOLD 2026-11-10: vanilla streams every non-resident expert (overlapped with the mixers) from 1024-row chunks (`kStreamAllMinDefault`), ours from 4096 (`STRATA_PREFILL_STREAM_MIN`, `settings/kv.rs`, set when the expert cache was off and only 60 % of the experts were routed). Profile `prefill-expert-stream-from-1024-rows-profile` (shipped / 1024 / 256, 15 requests): prefill.read at tails 2,837 / 2,622 / 2,453 / 1,602 / 1,454 tokens 1129 / 1029 / 1001 / 782 / 799 ms became 876 / 863 / 818 / 702 / 702; no change below 1,300 tokens, worse from 256 rows (279 tokens 465 to 747). Threshold 1536. Job `prefill-expert-stream-from-1536-rows-identity-and-profile` (30 requests): PREFILL-R chunk residual hashes IDENTICAL, 31 of 31 (shipped vs stream), no failures; prefill.read by tail class (mean ms, shipped to stream): < 1000 tokens 530 to 521 (-9), 1000-1536 723 to 729 (+6), 1536-4096 1010 to 830 (-180, -17.8 %), > 4096 1245 to 1280 (+35, noise); over 29 warm requests -45 ms per request (prefill.phase 921 to 877). `STRATA_PREFILL_STREAM_MIN=1536` is set in the three 5090 profiles (not the 3080: tier off there, different trade). Two more levers remain (not done): the prefetch of Q4 and vanilla's CPU share (lossy, off in the reference arm). | | B1 | prefill GDN and QSA stages of a small tail (per stage split) | `prof-l5/Q.1` has moe, moe.ring, gdn, qsa, input per chunk | none for vanilla | n/a | PROFILE | hex-finish | open | | B2 | first token sampling and publication after prefill | not measured | not measured | n/a | none | hex-finish | open | -| Q6 | `prefill.refill` of the lent expert slots (2,226 copy spans) | 137-140 ms per request | none | +138 ms; deferring it into the decode assembly (`LELEKA_REFILL_DEFER`): decode -0.92 % (CI -1.63..-0.21), end-to-end +0.56 % (CI -0.15..+1.27) | PROFILE, A/B `ab-l5v2` | hex-finish | fixing | -| Q7 | `decode.assemble` (graph re-recording per request: `record_all` 83 ms of 98-109 ms, nine graphs, 54-62 capture + 27-30 instantiate) | 98-109 ms per request | none (vanilla keeps its graphs) | +98-109 ms | PROFILE | both | fixing (device part DONE and merged, branch `claude/verify-decode-graph-reuse-handles` tip 0e8472968: `DeviceRef`, `park`/`rearm`/`reseed`, note `docs/experiments/verify-decode-graph-reuse-handles.md`; open: identity on a GPU, hex-finish part (owner loan, `weights_epoch`, drafter binding, enabling); original plan was: device = shared `DeviceRef` handle in the verify-window/qwen_dispatch operand files plus `park`/`rearm`/`reseed` API, branch after the three side-stream merges; hex-finish = owner loan, drafter binding, enabling `LELEKA_DECODE_GRAPH_REUSE` in the stack; spec `docs/experiments/decode-graph-reuse.md` B1 and Part 2 in `claude/prefill-latency` a4a8d597f; section = `decode.assemble` per request) | +| Q6 | `prefill.refill` of the lent expert slots (2,226 copy spans) | 137-140 ms per request | none | +138 ms; deferring it into the decode assembly (`LELEKA_REFILL_DEFER`): decode -0.92 % (CI -1.63..-0.21), end-to-end +0.56 % (CI -0.15..+1.27) | PROFILE, A/B `ab-l5v2` | hex-finish | fixing PROFILE 2026-11-10 (job `prefill-refill-deferred-with-default-set-profile`, default set + stream 1536, YP without / YRP with `LELEKA_REFILL_DEFER`, 14 warm requests each): `prefill.refill` 93.9 vs 70.7 ms and `refill.sync` 23.3 vs 23.3, `refill.queue` 70.0 vs 70.2 ms (the host time to issue the copies stays, now behind the decode assembly); `decode.reuse` 13.0 vs 13.0; wall per output token 5.95 vs 6.01 ms (sums 155.0 vs 154.7 s, 26,047 vs 25,729 tokens): no gain from the deferral on top of Q7 (the host assembly it overlapped with is 13 ms now, not 98). The cost is HOST issue of about 1,000 slots x 3 `cuMemcpyHtoDAsync` = 70 us per slot; plan: one `cuMemcpyBatchAsync_v2` per few hundred copies (driver 595.99 exports it), bitwise (same bytes and order), switch `LELEKA_REFILL_BATCH` off, in progress as a sub-agent branch (host-side tests + ignored GPU test); expected -50..-60 ms per request. `LELEKA_REFILL_DEFER` stays off. BATCH COPY 2026-11-10 (job `prefill-ring-prefetch-and-refill-batch-identity-and-profile`, pkg-s14, `LELEKA_REFILL_BATCH=1`): production refill with the batch: `refill.batch_calls` 6, `batch_copies` 2,997, `per_copy` 0, `refill.queue` 41.7 to 1.0 ms but `refill.sync` 23.8 to 57.0 ms, `prefill.refill` 65.9 to 58.3 ms (-7.6 ms per request): the host issue was already overlapped with the DMA, the refill is bytes-bound (999 slots x 2 MB = 2 GB = 45 ms at 45 GB/s). R hashes of all chunks identical to shipped (31 of 31), 0 failed requests. The isolated GPU test `refill_batch_copy_gpu_slots_equal_per_copy` (Vec registered by cuMemHostRegister, 3,072 pieces) faults with error 719 on the batch arm while the per-copy arm is exact: the known driver bug of the batch entry with page-locked sources (docs/windows.md, 3080), here on driver 595.99 too; the production bank evidently takes another route. Verdict: -7.6 ms is too small to justify a driver entry that faults in some memory kinds; `LELEKA_REFILL_BATCH` stays OFF; Q6 stays bytes-bound (floor = lent slots x 2 MB / 45 GB/s). 2026-11-10 driver check `prefill-raw-batch-copy-page-locked-driver-check` (5090, driver 595.99): `pcie_copy_gpu_raw_batch_page_locked`, `..._raw_batch_mixed`, `pcie_copy_gpu_production_page_locked`, `..._production_pageable` all pass (4/4, ~0.9 s each), so a raw batched copy from page-locked memory works on this driver; the CUDA 719 of the slots-equal GPU test is specific to that test's registered Vec, not to batch copy. Switch stays OFF (gain -7.6 ms, bytes-bound). | +| Q7 | `decode.assemble` (graph re-recording per request: `record_all` 83 ms of 98-109 ms, nine graphs, 54-62 capture + 27-30 instantiate) | 98-109 ms per request | none (vanilla keeps its graphs) | +98-109 ms | PROFILE | both | fixing (code 7570247d9, wired behind `LELEKA_DECODE_GRAPH_REUSE`, identity and section delta pending on the GPU): the speed session's handles, `park`/`rearm`/`reseed` and this side's key, `GraphReuse::begin`/`end`, QSA owner loan, drafter decision, shared-expert pin and stack wiring are merged and tested host-side and on the lifecycle fake; compare `decode.assemble` with `decode.reuse`, `decode.disassemble` with `decode.keep`, `record.*`, the first-draft capture, VRAM at the low-water mark; design and scenarios `docs/experiments/decode-graph-reuse.md` GPU (job `host-decode-graph-reuse-identity-and-profile`, package `pkg-s6` = our wiring + the speed session's handles/re-arm, 4 profiled boots x 30 requests): REUSE WORKS. Per request, shipped (AP.1/AP.2): `decode.assemble` 103.5/104.1 ms (`record_all` 86.5/86.9, capture 34.0, instantiate 22.2) + `decode.disassemble` 14.7/12.3 = 118/116 ms. With `LELEKA_DECODE_GRAPH_REUSE=1` (RGP.1/RGP.2): `decode.assemble` 6.0 + `decode.reuse` 14.0/13.8 + `decode.keep` 0.7/0.6 = 20.7/20.4 ms, `record_all` 5.4 (the one full assembly of the first request averaged over 30), `record.capture` 1.1, `record.instantiate` 1.3: section delta about -97 ms per request (a reused request costs ~18 ms: re-arm with the 118 MB reseed). 29 of 30 requests reused, 1 full assembly, zero `decode graphs recorded again` lines (no retire), all HTTP 200. VRAM low-water unchanged (535 MiB free in both). ms/token (unpaired, free-running): 6.18/6.19 shipped against 6.10/6.12 with reuse. Identity: teacher-forced bitwise job queued (`host-draft-switches-teacher-forced-identity`, P4); free-running hashes cannot decide it BITWISE IDENTITY PASS (job `host-draft-switches-teacher-forced-identity`, test binary `rt-pf9`, night5-long-256k, teacher forced, 5 requests to 243k, 240 forced tokens each): top-16 logprob rows 2057 of 2057 identical in both arms, draft trace 1036 of 1036 lines identical, A/A floor identical (q_tail_gate PASS, d_top1 0.0000, flips 0). FIXED for the section: -97 ms per request (118 to 20.7 ms) and identity; ON by default in the three 5090 profiles (`LELEKA_DECODE_GRAPH_REUSE=1`, test `the_switches_that_passed_the_bitwise_gate_are_on_for_the_5090_profiles_only`); the end-to-end paired A/B of the group is still to come GROUP A/B 2026-11-10 (job `host-draft-switches-group-ab`, n=10 per arm, 30 requests each, free-running): the group arm X = chain pipeline + check merge + park fast (reuse RG is NOT in X; its own paired e2e arm is still to run). Decode ms/token A 6.33, X 6.30, paired -0.03 +-0.08 (no regression, no gain visible); session time A 329 +-19 s, X 340 +-20 s but output lengths differ run to run (free-running), so time per equal-output pair is the fair figure: 66 pairs with output within 2 %, mean X-A -73 ms (se 46), median -5 ms. Section deltas stand (Q7 -97 ms per request); the e2e effect is below the A/B noise (about 3 % of session time), CLOSED on section + bitwise identity; ON in the three 5090 profiles; e2e confirmation by RG paired arm pending. SECTION DELTA 2026-11-10 (job `host-set-profile-paired-section-deltas`, one profiled boot per arm, 15 requests, package pkg-s9; AP shipped, YP = check merge + park fast + graph reuse): `decode.assemble` 97.8 ms median + `decode.disassemble` 12.0 ms (= 109.8 ms per request) became `decode.reuse` 13.1 ms + `decode.keep` 0.63 ms (= 13.8 ms) on 14 of 15 requests; the first request records (assemble 178 ms, `record_all` 162 ms vs 81.6 ms shipped, the one-time cost of building the held set); over all 15: 1,726 ms to 373 ms = -90 ms per request including the cold one (-96 ms on the 14 warm ones). Matches the earlier -97 ms. FIXED: section delta + bitwise identity (teacher-forced 2057/2057 rows); ON in the 5090 profiles. | +| B3 | prefill: prefix-cache parking in the request path (code `prefix.export_kv` 19.0 + `export_index` 2.3 + `park_tail` 14.7 + `park_block` 6.5 + `after_prefill` 9.4 + `after_chunk` 0.7 + `after_decode` 12.5, mean per request) | 65.1 ms | vanilla parks the conversation (checkpoints) inside its own prompt time, not separable | n/a until the instrumented vanilla | PROFILE `runs/dc1` | hex-finish | fixing (code a88a77b25, switches `LELEKA_PREFIX_PARK_FAST=1` and `LELEKA_PREFIX_PARK_ASYNC=1`, both off by default, identity and section delta pending). Reading of the code: the seven listed spans are nested, not additive (`export_kv` and `export_index` sit inside `park_block` and `park_tail`, which sit inside `after_prefill`, `after_chunk` and `after_decode`), so the request-path total is `after_prefill` + `after_chunk` + `after_decode` = 22.6 ms, not 65.1 ms. FAST: one context drain per park instead of 12, K/V pages copied into unzeroed vectors, index rows take the device-read staging as the result (same bytes; compare `prefix.export_kv` and `prefix.export_index`, new `prefix.export_drain`; the sub-spans `export.copy_fast` and `export.index_copy_fast` replace `export.sync`, `export.alloc`, `export.copy`, `export.index_alloc`, `export.index_copy`). ASYNC (with `--prefix-cache-tail reply`): the `after_decode` part (12.5 ms) is taken after the terminal event of the request, before the prefix summary and before the next request, and reported on the line `DBG profile park_deferred` (sum the `request` and `park_deferred` lines for an equal-work comparison); the tail node is in the store before the next request exactly as before. Not deferred: `after_prefill` and `after_chunk` (the last page also holds cells the decode overwrites and the recurrent state the decode advances, so a later park gives other bytes). Not done: pooled buffers (the store retains the vectors) and threaded copies of the 12 layers. GPU run 2026-11-09 (`prefill-prefix-park-identity-and-profile`): FAST kept the prefix reuse and cut the three `after_*` sections by 2.0 ms (23.5 to 21.5; the first-touch page faults of fresh host memory dominate and stay); ASYNC was refused by the runner (the busy mark `active` was still set while the owner ran the deferred step, so the next request got `runtime_capacity`). Fixed in the next commit: the busy mark is released before the deferred step, so a request that arrives meanwhile is admitted and waits in the control queue (test `a_request_arriving_during_the_deferred_tail_is_admitted_and_queued_not_refused`); pass criterion for the rerun: `cached_tokens` equal to shipped for all 30 and no `engine refused` in requests.log. Pre-faulted buffer pool not built: the store keeps every parked vector, so a pool is the store budget held pre-touched (tens of GiB, or sizes that do not match the variable tail) and needs a store free list or a slab type; allocator tuning (`MALLOC_TOP_PAD_`, `MALLOC_TRIM_THRESHOLD_`) can be tried without code BITWISE IDENTITY PASS (job `host-draft-switches-teacher-forced-identity`, test binary `rt-pf9`, night5-long-256k, teacher forced, 5 requests to 243k, 240 forced tokens each): top-16 logprob rows 2057 of 2057 identical in both arms, draft trace 1036 of 1036 lines identical, A/A floor identical (q_tail_gate PASS, d_top1 0.0000, flips 0). FAST: identity PASS and section -2.0 ms per request: ON by default in the three 5090 profiles (`LELEKA_PREFIX_PARK_FAST=1`); ASYNC is not in the default (admission fix queued for the rerun `prefill-prefix-park-async-fix-identity-and-profile`) ASYNC rerun 2026-11-10 (job `prefill-prefix-park-async-fix-identity-and-profile`, after fix 955a72e37): no `engine_refused`/`runtime_capacity` in any of the 8 boots; `cached_tokens` equal to the shipped arm for 30 of 30 requests in every arm (1,202,318 total); `prefix.after_response` 8.7 ms median on the `park_deferred` line, the work leaves the request path (`prefix.export_kv` 17.0 to 7.6 ms median, `park_tail` 13.7-15.2 to 6.3 ms) but `prefix.after_prefill` is 9.6/9.9 ms vs 10.5/11.1 (shipped) and 9.4 (FAST): the request path gains nothing measurable beyond FAST. FAST CLOSED (bitwise identity + section delta, ON in 5090 profiles); ASYNC stays OFF (no delta beyond FAST, adds a deferred step). SECTION DELTA 2026-11-10 (same job): `prefix.after_prefill` + `prefix.after_decode` per request AP 13.30 + 10.01 = 23.3 ms, YP 13.01 + 7.21 = 20.2 ms (-3.1 ms, -13 %; earlier job: -2.0 ms); `prefix.park_tail` 16.8 to 15.3 ms, `prefix.export_drain` 3 context drains per park instead of 12 (counter 0.00/3), `prefix.export_index` 3.50 to 2.89 ms; `prefix.export_kv` 22.6 to 25.3 ms (the copies themselves are the same bytes). FAST FIXED: section delta -2..-3 ms per request + bitwise identity; ON in the 5090 profiles. ASYNC stays OFF. | +| B4 | decode hand-over: tear-down of the request (code `decode.disassemble`) | 11.7 ms per request | none | +11.7 ms | PROFILE `runs/dc1` | hex-finish | open | +| B5 | host: admission of CPU work (code `cpu.admit`, 819 calls per request) | 43.2 ms per request | not measured | n/a | PROFILE `runs/dc1` | hex-finish | open | ## C. Decode round: summary, then draft, verify graph, accept, commit, publication, next round @@ -55,10 +58,10 @@ Round-level totals first (they are the sum of the steps below). | id | step | LEL | VANL | difference | source | owner | status | | --- | --- | ---: | ---: | ---: | --- | --- | --- | -| O9 | draft chain steps and idle between them | 0.27 | not given | +0.27 | ORCH | hex-finish | open | -| O8 | draft finite and q8 guard checks (`mtp_original_finite` 158.8 x 0.87 us, `mtp_original_q8_guard` 28 x 0.87 us per round, 186.8 launches) | 0.162 | none | +0.162 | CUPTI | hex-finish | open | -| K13 | draft chain role total (chain GR kernels, `mtp_*`) | 3.544 | 2.471 | +1.073 (includes the draft head and checks of R3 and O8; VANL books its draft in the shared GR kernels) | CUPTI role table | hex-finish | open | -| O12 | draft finish follows the window width (0.93 ms at T 3.0, 2.5 ms at T 6.2) | window price | | part of the +3.1 ms for +0.65 tokens per round | PROFILE | hex-finish | open | +| O9 | draft: chain steps and the host idle between them (code `LELEKA_DRAFT_CHAIN_PIPELINE`) | 0.272 ms per round (2.38 boundaries x 114 us) | idle inside the draft 0.52 ms on 4.5 streams (draft span at equal steps: 1.83 against 1.85) | +0.27 | ORCH | hex-finish | fixing: S1 `LELEKA_DRAFT_CHAIN_PIPELINE` (code `1ab37e408`, opt-in; all chain steps of a greedy draft with min_p 0 enqueued back to back, one drain, flags read once); package `pkg-s1`, identity and profile pair job `host-draft-chain-one-pass-identity`, paired A/B job `host-draft-chain-one-pass-ab` GPU (job `host-draft-chain-gate-diagnosis`, 8,377 drafts): `mtp.chain_gate.min_p` for ALL of them: the adaptive plan gives every round a positive `min_p` (the chain stops at the first step whose probability is below it), so the pipelined path (greedy, `min_p` 0) never engages in production; `mtp.chain_step` stays 0.480 ms x 2.66 steps per round. Pipelining a chain with an early stop would enqueue steps the sequential path never runs (each ~0.45 ms of GPU) against a gain of ~0.1 ms per boundary, so it is a loss without a device-side stop. S1 stays off, parked; the remaining 0.272 ms per round of host turnaround is open for cheaper per-step sync | +| O8 | draft: finite and q8 guard checks of the MTP ring (code `mtp_original_finite` 158.8 x 0.87 us, `mtp_original_q8_guard` 28 x 0.87 us per round, 186.8 launches) | 0.162 | none | +0.162 | CUPTI | hex-finish | fixing (code 306b39807, switch `LELEKA_DRAFT_CHECK_MERGE`, off by default; identity and section delta pending): S2' launches every run of ADJACENT checks of a draft step program as one `mtp_original_check_batch` (new sealed asset `mtp_original_check_batch.ptx`; each entry keeps its own buffer, count, kind and status word, so the status words are the separate launches' words). Per step 48 check launches, 3 runs (prefix guards after the GR block 5, tail after the MLP GR 5, tail after the shared gate and up 2): 12 launches become 3, 9 fewer per step, 36 per round at 4 steps (expect `mtp_original_finite` 158.8 to about 111 and `mtp_original_q8_guard` 28 unchanged per round (the merged runs hold finite checks only), plus about 12 `mtp_original_check_batch` launches, net 36 fewer; the upper bound of the gain is about 0.05 ms per round, no claim). Not done: moving a check across another command (deferral to the end of the chain): the checked buffers `qcur`, `r`, `xn`, `lo` are overwritten in place between their checks and the program has no write-set table, so it needs one first. Proofs: `cuda-model` `draft_check_batch` (the merged schedule expands to the separate one, and a NaN/Inf at the edges and middle of every buffer after every kernel leaves identical status words in a simulated step), driver tests on the real command lists, GPU test `check_batch_program_gpu` (`--ignored`, job `draft-check-merge-gpu-proof`) GPU: detection test PASS (73 cases: NaN/+Inf/-Inf in every buffer and Q8 scale, 72 raise a flag, 0 differ from the separate launches); step graph 114 -> 105 nodes (-9 per step, `DBG mtp chain-step graph`, job `host-draft-chain-gate-diagnosis` MCP against AP); section: `draft.finish` 1.392 -> 1.300 ms per round (single boot each, not paired: 6390 and 5744 rounds); bitwise identity under teacher forcing queued (`host-draft-switches-teacher-forced-identity`, P2). The free-running replay cannot decide identity: draft traces of DT, MT and XT diverge at the 12th draft and shipped against shipped differs across boots BITWISE IDENTITY PASS (job `host-draft-switches-teacher-forced-identity`, test binary `rt-pf9`, night5-long-256k, teacher forced, 5 requests to 243k, 240 forced tokens each): top-16 logprob rows 2057 of 2057 identical in both arms, draft trace 1036 of 1036 lines identical, A/A floor identical (q_tail_gate PASS, d_top1 0.0000, flips 0). Check merge: identity PASS, step graph 114 to 105 nodes: ON by default in the three 5090 profiles (`LELEKA_DRAFT_CHECK_MERGE=1`); the paired section delta stays to be read from the group A/B (`host-draft-switches-group-ab`) GROUP A/B 2026-11-10: see Q7 row (X arm includes check merge): no regression, ms/token paired -0.03 +-0.08. Identity bitwise PASS (teacher-forced, 1036/1036 draft lines); ON in the three 5090 profiles. The paired `draft.finish` delta was not profiled in that group job (no profile arm): a profiled arm X vs A is the remaining step for the section number. SECTION DELTA 2026-11-10 (same job, per call over 8,697 / 9,518 / 7,771 draft rounds): `draft.finish` AP 1.548 ms, MCP (check merge only) 1.494 ms (-0.054 ms, -3.5 %), YP (the complete set) 1.577 ms (+0.029 ms, +1.9 %); `gpu.mtp_chain_step` 0.458 / 0.452 / 0.453 ms per step and `mtp.chain_step` 0.488 / 0.480 / 0.481 equal in all three. One boot per arm cannot resolve a 2-4 % difference (boot-to-boot spread of this profile is about 3 %), and YP does not reproduce MCP's gain: the section delta is at most -0.054 ms per round (about -30 ms per request at 580 rounds), not resolved. CLOSED on bitwise identity (1036/1036 draft lines) and the graph-node count (114 to 105); no regression found; ON in the 5090 profiles. A resolved per-round number would need 3 or more boots per arm (not scheduled: owner rule 2026-11-10). | +| K13 | draft chain role total (chain GR kernels, `mtp_*`) | 3.544 | 2.471 | +1.073 (includes the draft head and checks of R3 and O8; VANL books its draft in the shared GR kernels) | CUPTI role table | hex-finish | open (O8 `LELEKA_DRAFT_CHECK_MERGE` takes the adjacent checks out of this total once its section delta is measured) | +| O12 | draft: finish follows the window width (0.93 ms at T 3.0, 2.5 ms at T 6.2) | window price | | part of the +3.1 ms for +0.65 tokens per round | PROFILE | hex-finish | open | | O2 | kernels outside big graphs | 630 | 147 | +483 | CUPTI | hex-finish | open | | O3 | graph executions per round | 5.38 | 4.47 | +0.91 | CUPTI | hex-finish | open | @@ -241,3 +244,47 @@ Queue stubs and result directories carry the readable name from 2026-11-09 (`= 8, one SM per value head, shared memory) | not a gap against VANL 0.2.6 (it has no `GDN_TC`); a possible win of about 5 % of prefill | upstream commit message | hex-finish | fixing (code c5a8b7794, switch `LELEKA_PREFILL_GDN_TC`, experimental/lossy; parity, quality gate and section delta pending): sealed asset `gdn_prefill_tc.cu` (prep + scan, 99-KB split plan, two value tiles per head on the 5090), runs of >= 128 tokens on sm_120, scratch = the idle dequantization scratch (no extra VRAM); not bitwise by design, the gate is `docs/quality-gate.md` (first-token KL / q_tail_gate / logprob envelope); checks: ignored GPU test `gdn_tensor_core_scan_stays_within_the_gate_of_the_sequential_recurrence` (1e-4), then the quality gate, then section delta = `gdn` stage per chunk of the prefill profile at 4K/16K/32K; no speedup claimed FIRST GPU RESULTS (2026-11-10): parity PASS (readout 5-7e-8, state 1-4e-7, gate 1e-4, T up to 2048+, both tile plans); synthetic kernel time kh 4.049 ms to tensor-core 1.308 ms at 8192 tokens. Logit gate (job `prefill-gdn-tensor-core-logit-gate`, first run, arm I1 only: both processes failed to open arm I2 with `InputAllocation`/`HostAllocation` on the full holder, so there is NO A/A floor): against the shipped path on `night5-long-256k` (5 requests, 45k-243k prompts, 240 forced tokens each) d_top1 p99 0.2727 (limit 0.22), max 0.7405 (limit 0.43), argmax flips 47 of 1658 common rows = 2.83 % (limit 2.8 %): OUTSIDE the Original envelope, preliminary; TTFT of the five requests 63.97 s to 60.57 s (-3.4 s, -5.3 %, unpaired single run). Rerun with the A/A floor on the sparse holder queued. LOGIT GATE 2026-11-10 (rerun with A/A floor, job `prefill-gdn-tensor-core-logit-gate`): A/A floor identical (arm I2 against I1 inside A: 518/518 draft lines, rows identical, so the difference is real); GDN-TC vs shipped: 1658 common rows, d_top1 median 0.0087, p99 0.2727, max 0.7405, argmax flips 47 (2.83 %), DRAFT VERDICT DIFFERENT; envelope (p99 <= 0.22, max <= 0.43, flips <= 2.8 %) FAILED on p99 and max, flips at the limit. PROFILE (job `prefill-gdn-tensor-core-profile`, 2 boots x 30 requests per arm): `prefill.phase` total 35539/34384 ms shipped vs 33996/34572 ms GDN-TC (-22.6 ms per request, -1.9 %, inside the 3 % boot-to-boot spread), because tails are short (mean ~800 uncached tokens, below the 128-token runs the kernel targets in most chunks). VERDICT: stays experimental and OFF; no A/B, no CRM x3. | +| U2 | prefill: batched PLE post-ops (code `STRATA_PLE_BATCH`; upstream `78316c8df` 2026-11-02 turns it off for an engine built with CUDA 12.8 on cc 12.0: illegal memory access in `native_ple_postops_batch_snap`) | we run the PLE of a prompt chunk batched (`OriginalPromptDevice::apply_ple`, `ple_batch_ffi`, `ple_batch_queue`); our sealed PTX is ISA 9.2 = CUDA 13.2 and the deploy refuses a driver older than 595 (`docs/deploy.md`), the production RTX 5090 host runs driver 595.99 / CUDA 13.2 | upstream: with CUDA 13.0 the batch is ~23 % faster prompts, so only the 12.8 toolchain faults | same hazard does not apply (no 12.8 build exists in our chain); the batch is already on | source read | hex-finish | proved-equal (we have the fast path and not the faulting toolchain); no work | +| U3 | prefill: MMQ row table over-read by the stream-k fixup (code `ids_identity`; upstream `f225844d1` 2026-11-05, class E correctness) | same structure: `ids_identity` is `T*K` entries exactly (`original_prefill_layout.rs:330`, `a.rows("ids_identity", t, K, 4)`), read by the same ggml `mul_mat_q_stream_k_fixup` (`mmq_original_formats_fixup.cu`); upstream needs `T*K + roundup(T, J) + J` entries (J = 8..128). It stays inside the arena today because `bounds_dev`, `grp_gu`, `grp_d` follow it in the same allocation, so the over-read lands in a neighbouring span and the skipped writes never use it | upstream faulted (Xid 31) when the exact table ended a 2 MiB page | latent: not a fault with the current layout, would become one if the order of the `Common` spans changes or `mmq_any` spans end the allocation | source read | hex-finish | fixing: margin `roundup(T, 128) + 128` entries added (`original_prefill_layout/mmq_identity.rs`, unit test of every readable index; always on, class E, no switch); identity (prompt logit digests equal) pending in the batched identity job | +| U4 | verify: flag B stays behind queued copies (upstream `40849df0a` 2026-11-05, P1.1, class E) | `OriginalVerifyGpuPlan::raise_after_staging` (`plan_phases.rs`): a plan with a PCIe source queues the flag behind the staging copies on the copy stream even when the plan is empty (`stage_pcie`, then `raise_after_copies`), the copy-kernel mode and the no-source case raise at once. The upstream hazard (an empty plan raising the one counter early while an earlier layer's or the other token group's uploads are still queued) can only occur in the no-source branch if a window mixes groups with and without a source; not shown to happen | upstream: counter jumped past a layer whose bytes had not landed | unknown; needs the check in the file owned by the speed session | source read | device | proved-equal (speed session, 2026-11-09): flag B is a monotonic ring word; a group with a PCIe source raises it behind the staging copies, one without a source or with the copy kernel raises it from the host at once; groups are never mixed in the product (`pcie_num > 0` is fixed once per round, `decode_parts.rs:209`); pure function `flag_b_route(copy_kernel, has_source)` with a truth table added on their branch, behaviour unchanged | +| U5 | verify: adaptive-copy range covers the whole round (upstream `40849df0a`) | different implementation: adaptive swaps are planned and applied in `original_serve_residency` (`adapt_swaps` cap 96 per round, `swap_tie_order.rs`); no serial/pipelined split with `lo/hi/bi` ranges exists in the Rust port | upstream: a pipelined round that drained early marked only an earlier round's range resident, so other swaps were lost (slot held the new expert, table still named the old one) | analogue not found; the resident marking of a drained round needs a read-through | source read | device | proved-equal (speed session, 2026-11-09): a swap is `Queued` until `complete_swaps` after `wait_swaps`/`poll_swaps` marks it `Filled`, and the slot search requires `Filled`, so a slot is resident only after its copy landed | +| U6 | prefill: expert-major (whole-blob) host bank for the copy ring (vanilla's pack holds one 2 MB blob per expert; ours is role-major, so the ring issues three H2D copies of ~0.7 MB per expert, `copy_exact`/`copy_aligned` in `ring_stage_expert_copies.rs`) | PCIe 44.6 GB/s measured over the copies (`PREFILL-COPY avg_call=696194 dma_gbps=44.6`); a 1.4k-token tail copies 24 GB, the ring wall equals bytes / 45 GB/s | vanilla: Original's own probe 49.9 GB/s with whole blobs | about -10 % of the ring DMA = -30..-45 ms per request at 0.3-1.5k tails (estimate: 0.9x of 460 ms) | PROFILE `prefill-ring-copied-megabytes-profile` (bytes), `docs/upstream-port-plan.md:181` (probe) | hex-finish | DEFERRED by the orchestrator 2026-11-10: it changes the KAR bank layout and the single compressed copy of the model (not a ring-local change); come back after the ring prefetch and Q6. Bitwise by construction (same bytes), needs a KAR format/version decision and a sealed-bank migration | +| U7 | prefill: fused int8 prompt experts (code `STRATA_PF_FUSED`, `moe_fused_iq.cu`; upstream `959e6c34`, `b1e0fdaa`; ON by default for a 5090 in vanilla via `sm120_series.hpp`, confirmed in the VANL engine log: `prompt experts on the fused int8 kernels (STRATA_PF_FUSED=1, #136)`) | absent (our prompt experts run the grouped MMQ kernels behind the copy ring; port-plan rows 3.2/6.2 are todo, size L, needs the GPU-side grouping) | VANL has it ON (and CPU share OFF in that arm); upstream measured prompt +7/+5/+3 % at 4K/20K/98K; KL against MMQ 0.0002, an exact int8 dot with one float add per 32 values (s0-7 row 5, B2) | not measured: at tails of 64-1024 tokens the ring wall equals the PCIe time of the copied bytes (7-13k experts per request, DMA 319-590 ms at 45 GB/s = ring wall 332-590 ms), so a faster expert kernel only moves the kernel tail after the last copy; expected effect at those tails is small (a few ms per layer of MMQ after the final group), and +3..7 % of compute at 4K+ | model-free `prefill_fused_iq_test` against our MMQ layer (row 6.1), then the Original envelope (`q_tail_gate` on `night5-long-256k`, first-token KL) | hex-finish | open, NOT the cause of the 64-1024 tail gap (that gap is the unoverlapped GDN/QSA compute, ~130 ms, and DMA 45 vs 50 GB/s, rows Q4/U6); experimental switch OFF + gate only after the prefetch and Q6, default with the owner's word | + +## M. Host memory: the lab holder's sealed memfd + +| id | step | LEL | VANL | difference | source | owner | status | +| --- | --- | ---: | ---: | ---: | --- | --- | --- | +| M1 | lab holder restart after every holder window: the window scripts (`cmp_codex_job.sh` and the jobs built on it: cmp*, kar-off*, spd-van*, spd-cu*, `pf-mv1`) end with `single-copy-holder.sh`, the FULL seal (55.3 GB resident, `allocated=55295533056`), so the sparse holder of `pf-hs1` (`allocated=16000352256`, 10:28) lasted only until `pf-mv1` ended (10:50); the next window `spd-cuv` (13:31) restarted the full one again | 51.5 GiB resident memfd (profile `ple_only` needs 14.9) | n/a (vanilla holds its own copy) | +36.6 GiB of host RAM held twice; builds with the memfd check refuse to start (`leleka up`: "a second copy of model bytes that nothing reads"); `ab3` (12:13-13:17), `ab4` (22:46-23:43) and `dc-p1` ran on the full holder, both arms of each pair on the same one | `notes.md`, holder3.out, `stat` of the memfd | hex-finish | fixing: guard in `pf_ab_job.sh` (allocated size of the inherited memfd above 20 GiB: sparse restart through `pf_holder_window.sh` and the job queued again, `pf_sparse_requeue.sh`); window scripts of other sessions must end with `pf_holder_sparse.sh` instead of `single-copy-holder.sh` (not done: not our files) | + +## Job names (GPU queue stubs and result directories) + +Naming rule (owner 2026-11-09): `--`, in words; areas `prefill-`, `host-`, `draft-`, `memory-`. Result directories under `/data/leleka-e2e/prefill-latency/runs/` carry the same name. Jobs that already ran keep their old name; the map is old to new. + +| old name | new name (job stub, queue entry and result directory) | what it measures | row | +| --- | --- | --- | --- | +| `pf-ab4` | `prefill-ladder-ab-pairs-6-10` | paired A/B of the prompt loan ladder against shipped, pairs 6-10, sparse holder | Q1 | +| `pr-lel` | `prefill-empty-request-probe-leleka` | empty-request probe on LEL: tiny prompt, cold, cached long prompt | A1, A2, A3 | +| `pr-prof` | `prefill-prefix-park-subspans-profile` | profiled replay with the sub-spans of the prefix-cache export (sync, allocation, copy) | B3 | +| `s1-id1` | `host-draft-chain-one-pass-identity` | identity and host-span pair, draft chain in one pass against sequential | O9 | +| `s1-ab1` | `host-draft-chain-one-pass-ab` | paired A/B n=10, draft chain in one pass (ms per token, task time) | O9 | +| `pr-prof` (then `prefill-prefix-park-subspans-profile`) | `prefill-prefix-park-identity-and-profile` | replaces the sub-span profile job: identity of parking FAST/ASYNC against shipped (A, PF, PA) and the profiled pair (AP, PFP, PAP), package `pkg-s3` (commit `7a549b68e`) | B3, U3 | +| `s1-ab1` (then `host-draft-chain-one-pass-ab`) | `host-draft-switches-group-ab` | the one paired A/B of the group of host/draft switches (chain pipeline + check merge + parking fast) against shipped, n=10, package `pkg-s4` | O9, O8, B3 | +| (new) | `draft-check-merge-gpu-proof` | GPU test `check_batch` (batched guard against separate launches, NaN/Inf in every buffer) | O8 | +| (new) | `host-draft-switches-identity` | replay hashes and draft trace lines equal with X (group), the check merge alone (MT), shipped (DT) | O8, O9, B3 | +| (new) | `prefill-gdn-tensor-core-parity-gpu` | GPU tests: tensor-core GDN scan against the sequential kernel (gate 1e-4) and kernel timing; package `pkg-s5` | U1 | +| (new) | `prefill-gdn-tensor-core-logit-gate` | lossy gate: teacher-forced `night5-long-256k`, 240 tokens by top-16 logprob, shipped against `LELEKA_PREFILL_GDN_TC=1` (A/A floor), Original envelope via `q_tail_gate.py`; test binary `dt/rt-pf7` | U1 | +| (new) | `prefill-gdn-tensor-core-profile` | `gdn` stage per chunk, shipped (AP) against tensor-core scan (GTP), replay of 30 requests | U1 | +| (new) | `host-decode-graph-reuse-identity-and-profile` | Q7: replay hashes and draft trace equal to shipped with `LELEKA_DECODE_GRAPH_REUSE=1`, and the `decode.assemble`/`decode.reuse`/`record.*` spans; package `pkg-s6` (commit `2a1f2eccf`) | Q7 | +| (new) | `prefill-prefix-park-async-fix-identity-and-profile` | rerun of the parking identity (reuse) and sections after the ASYNC admission fix; package `pkg-s8` (commit `4fef1b009`) | B3 | +| (new) | `host-draft-chain-gate-diagnosis` | which condition keeps the pipelined draft chain from engaging (`mtp.chain_gate.*` counters), and the step-graph node count with the check merge; package `pkg-s9` (commit `4b0f87bf0`) | O9, O8 | +| (new) | `host-draft-switches-teacher-forced-identity` | bitwise identity under teacher forcing (night5-long-256k, A/A floor): shipped against check merge, parking fast and decode graph reuse, one process each; test binary `dt/rt-pf9` (commit `2a1f2eccf`) | O8, B3, Q7 | +| `pr-van` | removed | empty-request probe on VANL; vanilla is not re-measured (owner 2026-11-09) | A1-A3 | diff --git a/docs/prefill-throughput.md b/docs/prefill-throughput.md index 3d4efe9f..c5413637 100644 --- a/docs/prefill-throughput.md +++ b/docs/prefill-throughput.md @@ -160,6 +160,21 @@ binary measures old against new. | element-parallel dequantization (GDN, QSA) | `LELEKA_PREFILL_FAST_DEQUANT=0` | one thread per 32 values, ~6 GB/s on the laptop | | GDN chunk starts from the mirror's device state | `LELEKA_PREFILL_GDN_MIRROR=0` | canonical host state converted and uploaded for every layer of every chunk | | two-barrier GDN recurrence (EXPERIMENTAL, off) | `LELEKA_PREFILL_FAST_REC=1` | `gdn_rec_cols_pipe_kernel` | +| chunked tensor-core GDN recurrence (EXPERIMENTAL, LOSSY, off) | `LELEKA_PREFILL_GDN_TC=1` | `leleka_prefill_gdn_rec` / `_kh` for runs of >= 128 tokens; NOT bitwise, see below | + +Tensor-core GDN recurrence (`LELEKA_PREFILL_GDN_TC=1`, EXPERIMENTAL, LOSSY, off by default; ledger row U1). A port of Strata +upstream `gdn_tc.cuh` (`strata-upstream/main` 504b1433): the recurrence of a prompt chunk in WY form, 32-token chunks, every product an +f16x3 `mma.sync` (x = hi + lo, hi.hi + hi.lo + lo.hi, power-of-two scaling per chunk). New sealed asset `gdn_prefill_tc.cu` (group +`gdn-prefill-tc`, kernels `leleka_gdn_tc_prep`, `_scan_t1`, `_scan_t2`; no sm_86 companion, the plan refuses cc < 12). Plan for the +RTX 5090: the 99-KB split plan (97,808 bytes of dynamic shared memory), two value tiles per head (upstream 51567de1a: 96 blocks of +128 threads from 96 SMs; the card has 170) and a prep of `chunks * 16` blocks of 256 threads. The scratch (942,272 bytes a chunk, +60,305,408 for upstream's 64 chunks) is the prompt device's dequantization scratch, idle during the recurrence, so the super-block is +55 chunks (1,760 tokens) and the switch costs no device memory. Dispatch: switch on, cc >= 12, >= 48 SMs, >= 97,808 bytes of +opt-in shared memory, run of >= 128 tokens; anything else runs the sequential kernels unchanged (one stderr line says why). The state +in/out, the readout and the non-finite state witness are those of `leleka_prefill_gdn_rec_kh`. Not bitwise equal (upstream first-token +KL mean 0.0019, max 0.0125): the gate is `docs/quality-gate.md` (first-token KL / q_tail_gate / logprob envelope), never an identity +probe. GPU checks: `gdn_tensor_core_scan_stays_within_the_gate_of_the_sequential_recurrence` (1e-4, upstream's gate) and +`gdn_tensor_core_scan_timing_against_the_kh_recurrence` (synthetic); the end-to-end number is the `gdn` stage of the prefill profile. Input staging: the rows of a chunk (16 per token) are resolved against the cache map on the host, the packets of the misses are read in parallel (`pread`, up to 32 threads), and one kernel decodes all of them straight into the arena's @@ -442,7 +457,7 @@ VRAM taken from the expert tier". **It is not.** 8192-row loan; the lent slots are the last ones, so the rungs nest, and the refill is driven by the per-slot `NeedsRefill` state, so a small loan refills less with no other change. The stack opens with the rungs it can afford (`prompt loan ladder: ...` in the operator log). The arithmetic of a chunk does not depend on the arena capacity (buffers only); the gate is the hash of the final residual R of every chunk with and without the ladder (job p34: 24 requests of 9e3, arms `N = !notiers`, `T = !tiers`, static tier so the arms do identical work) and the paired A/B of TTFT (job p35, arms T N N T). -**Off by default** (`LELEKA_PREFILL_LOAN_TIERS=1`, replay arm flag `!tiers`) until p34 passes; both jobs are queued behind the owner's disk-maintenance job (see the status in the report). +**On in the shipped 5090 profiles** (`LELEKA_PREFILL_LOAN_TIERS=1` in `engine_env`; the engine default stays off, replay arm flag `!tiers`). Identity: the chunk residual hashes (PREFILL-R) of the ladder arm equal the full-loan arm (jobs id1-id4). Paired A/B on the lab holder (it held the FULL sealed memfd in both experiments: every holder window restarts the full seal, see the step ledger row M1), 10 blocks (`ab3` 5 + `prefill-ladder-ab-pairs-6-10` 5, same 30-request replay): session TTFT sum -3.0 s +-0.3 (CI excludes 0), median -104 ms per request, requests with at most 2048 new tokens -154 ms (faster in 19 of 19), above 2048 tokens -10 ms (no loss). Recommended once p34/p35 pass: `prefill_capacity: 8192` in the `rtx5090-32g` profile with the ladder on (cold re-reads at 4.4k tok/s, warm turns unchanged); the grid follows the capacity (`--prefix-cache-block` 0 = the chunk), the trade being the reuse granularity after a fork (up to 8192 tokens re-read instead of 2048: 67.9k vs 67.9k re-prefilled tokens in B2 vs A2, equal on this diff --git a/scripts/e2e/codex/prefill/pf_ab_job.sh b/scripts/e2e/codex/prefill/pf_ab_job.sh new file mode 100755 index 00000000..ddfcc678 --- /dev/null +++ b/scripts/e2e/codex/prefill/pf_ab_job.sh @@ -0,0 +1,143 @@ +#!/usr/bin/env bash +# Prefill fixed-latency A/B driver (docs/prefill-throughput.md, "Prefill fixed latency per request"): a copy of the speed program's spd_ab_job.sh +# (scripts/e2e/codex/speed) that runs against its own package, state and prefix directories, so it never touches the codex-compare release state. +# The SAME recorded Codex prompts are replayed through the packaged stack; a variant is named NAME or NAME.BLOCK (A.1 L.1 L.2 A.2 ...), BLOCK only names the output directory. +# replay_hash.py (next to this file in the server tools dir) records the sha256 of each request's output. +# HOLDER JOB (inherits the sealed KAR memfd). Test tooling, never in serving. +# PF_VARIANTS space separated variant names (default "A L") +# PF_CELLS recorded cells to replay, in order (default VANL/nestng-crm-r2 of the codex-compare run) +# PF_OUT result directory (default $PL/runs/main) +# PF_MAX requests per cell (default all) +# PF_ROOT the task directory (default /data/leleka-e2e/prefill-latency): pkg/bin (binaries under test), state/, prefix/, tools/ +# PF_CLIENT the client script in the tools directory (default replay_hash.py; pf_probe.py = the empty-request probe of ledger rows A1-A3) +# PF_PKG the package directory (default $PF_ROOT/pkg): bin/ and SHA256SUMS; lets a second build run next to the first +# Variants (engine environment of the `leleka up` process): +# A shipped (the prompt loan is the full 8192-row loan for every chunk) +# L the prompt loan ladder: LELEKA_PREFILL_LOAN_TIERS=1 (a chunk of at most 512 / 2048 rows borrows and refills a smaller loan) +# AR as A with LELEKA_TRACE_PREFILL_R=1: one PREFILL-R line (FNV-1a of every bit of the chunk's final residual) per chunk, the identity record +# LR as L with LELEKA_TRACE_PREFILL_R=1 +# P as A with the step profile (LELEKA_SERVE_PROFILE=1: one `DBG profile request` line of host spans per request) +# LP as L with the step profile +# LT as L with the bring-up trace (LELEKA_BRINGUP_TRACE=1: the driver error behind a failed chunk) +# C as A with the draft chain pipeline (LELEKA_DRAFT_CHAIN_PIPELINE=1: the chain steps enqueued back to back, one drain) +# DT as A with LELEKA_TRACE_DRAFT=1 (the draft-round identity lines) MC draft check merge (LELEKA_DRAFT_CHECK_MERGE=1) MT = MC + DT MCP = MC + profile +# RG decode graph reuse across requests (LELEKA_DECODE_GRAPH_REUSE=1) RGP = RG + profile RGT = RG + draft trace +# GT prefill GDN tensor-core scan (LELEKA_PREFILL_GDN_TC=1, EXPERIMENTAL, lossy) GTP = GT + profile GTD = GT + draft trace +# PF/PA parking fast / async (+P: with profile) X = chain pipeline + check merge + parking fast (the group of host/draft switches) XT = X + DT +# CP as C with the step profile AP as A with the step profile (the pair for the host spans of the draft) +set -uo pipefail +PL=${PF_ROOT:-/data/leleka-e2e/prefill-latency} +CMP=/data/leleka-e2e/codex-compare +RUN=${PF_OUT:-$PL/runs/main} +VARS=${PF_VARIANTS:-"A L"} +MAXR=${PF_MAX:-0} +CELLS=${PF_CELLS:-"$CMP/runs/main/VANL/nestng-crm-r2"} +LOCK=/data/leleka-e2e/gpu.lock +G=$HOME/work/gpu-runs +CUBLAS=$HOME/cuda-toolkits/cublas-12.9.1.4/lib +FD=${LELEKA_STRA169_KAR_FD:-} +mkdir -p "$RUN" +exec > >(tee -a "$RUN/job-$(date -u +%H%M%S).log") 2>&1 +log() { echo "[pf $(date -u +%T)] $*"; } +note() { echo "[$(date -u +%FT%TZ)] [DEV prefill-latency] $*" >>/data/leleka-e2e/decode/notes.md; } +readlink "/proc/self/fd/$FD" 2>/dev/null | grep -q '^/memfd:' || { echo "needs the holder's sealed memfd"; exit 3; } +# Guard: the shipped profiles read only the PLE extents (~15 GiB, memfd_extents ple_only). A holder that sealed the whole archive (every holder window ends with the FULL +# single-copy-holder.sh) makes `leleka up` refuse ("a second copy of model bytes") and inflates host memory. Allocated size of the inherited memfd, in GiB: +ALLOC_GIB=$(( $(stat -L -c %b "/proc/self/fd/$FD") / 2097152 )) +log "inherited memfd: $ALLOC_GIB GiB allocated" +if [ "${PF_ALLOW_FULL_MEMFD:-0}" != 1 ] && [ "$ALLOC_GIB" -gt "${PF_MEMFD_MAX_GIB:-20}" ]; then + # newest .running: stale ones of killed jobs exist + JOBF=$(ls -t "$G"/holder2/jobs/*.running 2>/dev/null | head -1); JOBN=$(basename "${JOBF%.running}") + [ -n "$JOBN" ] || { echo "memfd is not sparse and the queue entry of this job is unknown"; exit 3; } + log "memfd is not sparse ($ALLOC_GIB GiB > ${PF_MEMFD_MAX_GIB:-20}): restarting the lab holder sparse and queueing $JOBN again" + touch "$G/holder2/jobs/STOP" + ( eval "exec ${FD}>&-"; setsid nohup bash "$PL/tools/pf_sparse_requeue.sh" "$JOBN" > "$PL/window-requeue-$JOBN.launch" 2>&1 < /dev/null & ) + exit 0 +fi +[ -d "$G/MODEL.lock" ] || { echo "MODEL.lock is not held"; exit 3; } +PKG=${PF_PKG:-$PL/pkg} +AS=$CMP/ours-assets; ST=$PL/state; PFX=$PL/prefix; BIN=$PKG/bin +[ -x "$BIN/leleka" ] && [ -f "$ST/leleka.json" ] || { echo "the prefill-latency package or state is not prepared"; exit 3; } +(cd "$BIN" && sha256sum -c ../SHA256SUMS >/dev/null 2>&1) || { echo "the package binaries do not match $PKG/SHA256SUMS"; exit 3; } +got=0; for _ in $(seq 1 4320); do if mkdir "$LOCK" 2>/dev/null; then echo "prefill-latency $(date -u +%FT%TZ) $RUN" >"$LOCK/owner"; got=1; break; fi; sleep 5; done +[ $got = 1 ] || { echo "GPU lock held by: $(cat $LOCK/owner 2>/dev/null)"; exit 3; } +SUP_PID=; MON_PID= +stop_stack() { if [ -n "$SUP_PID" ] && kill -0 "$SUP_PID" 2>/dev/null; then kill -TERM "$SUP_PID" 2>/dev/null; for _ in $(seq 1 120); do kill -0 "$SUP_PID" 2>/dev/null || break; sleep 2; done; fi; SUP_PID=; } +cleanup() { stop_stack; [ -n "$MON_PID" ] && kill "$MON_PID" 2>/dev/null; pkill -KILL -f "$PFX/bin/" 2>/dev/null; sleep 3; rm -f "$LOCK/owner"; rmdir "$LOCK" 2>/dev/null; note "prefill-latency job ended: $RUN"; } +trap cleanup EXIT +note "prefill-latency job started: variants [$VARS] cells [$CELLS] out $RUN" +[ -z "$(nvidia-smi --query-compute-apps=pid --format=csv,noheader 2>/dev/null)" ] || { echo "something uses the GPU"; exit 3; } +export LD_LIBRARY_PATH=$CUBLAS:$HOME/cuda-toolkits/13.2.2/lib64:${LD_LIBRARY_PATH:-} +COMMON="--assets $AS --state-dir $ST --prefix $PFX --bin-src $BIN --cublas-dir $CUBLAS --trust-archive --kar-fd $FD" +for v in $VARS; do + D=$RUN/$v; mkdir -p "$D"; vb=${v%%.*} + [ -f "$D/replay.jsonl" ] && { log "variant $v already done: skipped"; continue; } + unset LELEKA_PREFILL_LOAN_TIERS LELEKA_TRACE_PREFILL_R LELEKA_SERVE_PROFILE STRATA_VERIFY_PROFILE LELEKA_REFILL_DEFER LELEKA_BRINGUP_TRACE LELEKA_DRAFT_CHAIN_PIPELINE LELEKA_PREFIX_PARK_FAST LELEKA_PREFIX_PARK_ASYNC LELEKA_DRAFT_CHECK_MERGE LELEKA_TRACE_DRAFT LELEKA_PREFILL_GDN_TC LELEKA_DECODE_GRAPH_REUSE LELEKA_PREFILL_DIAG_SKIP_EXPERT_DMA LELEKA_PREFILL_ROUTE_TRACE STRATA_PREFILL_STREAM_MIN LELEKA_PREFILL_RING_PREFETCH LELEKA_PREFILL_RING_PREFETCH_WINDOW LELEKA_PREFILL_RING_PREFETCH_DETACH LELEKA_REFILL_BATCH LELEKA_REFILL_DEFER LELEKA_TRACE_DRIVER_ERRORS + case $vb in + A) ;; + L) export LELEKA_PREFILL_LOAN_TIERS=1;; + AR) export LELEKA_TRACE_PREFILL_R=1;; + LR) export LELEKA_PREFILL_LOAN_TIERS=1 LELEKA_TRACE_PREFILL_R=1;; + P) export LELEKA_SERVE_PROFILE=1;; + LP) export LELEKA_PREFILL_LOAN_TIERS=1 LELEKA_SERVE_PROFILE=1;; + LT) export LELEKA_PREFILL_LOAN_TIERS=1 LELEKA_BRINGUP_TRACE=1;; + C) export LELEKA_DRAFT_CHAIN_PIPELINE=1;; + CP) export LELEKA_DRAFT_CHAIN_PIPELINE=1 LELEKA_SERVE_PROFILE=1;; + AP) export LELEKA_SERVE_PROFILE=1;; + SP1) export STRATA_PREFILL_STREAM_MIN=1024 LELEKA_SERVE_PROFILE=1;; # chunks of 1024+ rows use the expert stream (vanilla default) + SP2) export STRATA_PREFILL_STREAM_MIN=256 LELEKA_SERVE_PROFILE=1;; + SR) export STRATA_PREFILL_STREAM_MIN=1536 LELEKA_TRACE_PREFILL_R=1;; + # the stream threshold of the 5090 profiles is part of the base for the prefetch and refill-batch arms + FR) export STRATA_PREFILL_STREAM_MIN=1536 LELEKA_TRACE_PREFILL_R=1;; + FP) export STRATA_PREFILL_STREAM_MIN=1536 LELEKA_SERVE_PROFILE=1;; + PE) export STRATA_PREFILL_STREAM_MIN=1536 LELEKA_PREFILL_RING_PREFETCH=1 LELEKA_TRACE_PREFILL_R=1 LELEKA_TRACE_DRIVER_ERRORS=1;; + PED) export STRATA_PREFILL_STREAM_MIN=1536 LELEKA_PREFILL_RING_PREFETCH=1 LELEKA_PREFILL_RING_PREFETCH_DETACH=1 LELEKA_TRACE_PREFILL_R=1 LELEKA_TRACE_DRIVER_ERRORS=1;; + PEDP) export STRATA_PREFILL_STREAM_MIN=1536 LELEKA_PREFILL_RING_PREFETCH=1 LELEKA_PREFILL_RING_PREFETCH_DETACH=1 LELEKA_SERVE_PROFILE=1;; + PEP) export STRATA_PREFILL_STREAM_MIN=1536 LELEKA_PREFILL_RING_PREFETCH=1 LELEKA_SERVE_PROFILE=1;; + PET) export STRATA_PREFILL_STREAM_MIN=1536 LELEKA_PREFILL_RING_PREFETCH=1 LELEKA_TRACE_DRIVER_ERRORS=1 LELEKA_SERVE_PROFILE=1;; + RB) export STRATA_PREFILL_STREAM_MIN=1536 LELEKA_REFILL_BATCH=1 LELEKA_TRACE_PREFILL_R=1;; + RBP) export STRATA_PREFILL_STREAM_MIN=1536 LELEKA_REFILL_BATCH=1 LELEKA_SERVE_PROFILE=1;; + SRP) export STRATA_PREFILL_STREAM_MIN=1536 LELEKA_SERVE_PROFILE=1;; + APR) export LELEKA_SERVE_PROFILE=1 LELEKA_PREFILL_ROUTE_TRACE=1;; + RG) export LELEKA_DECODE_GRAPH_REUSE=1;; + RGP) export LELEKA_DECODE_GRAPH_REUSE=1 LELEKA_SERVE_PROFILE=1;; + RGT) export LELEKA_DECODE_GRAPH_REUSE=1 LELEKA_TRACE_DRAFT=1;; + GT) export LELEKA_PREFILL_GDN_TC=1;; + GTP) export LELEKA_PREFILL_GDN_TC=1 LELEKA_SERVE_PROFILE=1;; + GTD) export LELEKA_PREFILL_GDN_TC=1 LELEKA_TRACE_DRAFT=1;; + DT) export LELEKA_TRACE_DRAFT=1;; + MC) export LELEKA_DRAFT_CHECK_MERGE=1;; + MT) export LELEKA_DRAFT_CHECK_MERGE=1 LELEKA_TRACE_DRAFT=1;; + MCP) export LELEKA_DRAFT_CHECK_MERGE=1 LELEKA_SERVE_PROFILE=1;; + X) export LELEKA_DRAFT_CHAIN_PIPELINE=1 LELEKA_DRAFT_CHECK_MERGE=1 LELEKA_PREFIX_PARK_FAST=1;; + XT) export LELEKA_DRAFT_CHAIN_PIPELINE=1 LELEKA_DRAFT_CHECK_MERGE=1 LELEKA_PREFIX_PARK_FAST=1 LELEKA_TRACE_DRAFT=1;; + Y) export LELEKA_DRAFT_CHECK_MERGE=1 LELEKA_PREFIX_PARK_FAST=1 LELEKA_DECODE_GRAPH_REUSE=1;; + YP) export LELEKA_DRAFT_CHECK_MERGE=1 LELEKA_PREFIX_PARK_FAST=1 LELEKA_DECODE_GRAPH_REUSE=1 STRATA_PREFILL_STREAM_MIN=1536 LELEKA_SERVE_PROFILE=1;; + YRP) export LELEKA_DRAFT_CHECK_MERGE=1 LELEKA_PREFIX_PARK_FAST=1 LELEKA_DECODE_GRAPH_REUSE=1 LELEKA_REFILL_DEFER=1 STRATA_PREFILL_STREAM_MIN=1536 LELEKA_SERVE_PROFILE=1;; + DSP) export LELEKA_PREFILL_DIAG_SKIP_EXPERT_DMA=40000 LELEKA_SERVE_PROFILE=1;; # diagnostic, WRONG outputs: how much of moe.ring is bytes + PF) export LELEKA_PREFIX_PARK_FAST=1;; + PA) export LELEKA_PREFIX_PARK_FAST=1 LELEKA_PREFIX_PARK_ASYNC=1;; + PFP) export LELEKA_PREFIX_PARK_FAST=1 LELEKA_SERVE_PROFILE=1;; + PAP) export LELEKA_PREFIX_PARK_FAST=1 LELEKA_PREFIX_PARK_ASYNC=1 LELEKA_SERVE_PROFILE=1;; + *) echo "unknown variant $v"; continue;; + esac + export LELEKA_SPEC_STATS=1 + : >"$ST/logs/engine.log" 2>/dev/null + nvidia-smi --query-gpu=timestamp,temperature.gpu,clocks.sm,clocks.mem,power.draw,utilization.gpu --format=csv -l 10 >"$D/mon.csv" 2>/dev/null & MON_PID=$! + log "variant $v: leleka up --foreground" + t0=$(date +%s) + setsid "$BIN/leleka" up --foreground $COMMON --timeout-s 1800 >"$D/up-foreground.txt" 2>&1 & + SUP_PID=$! + ready=0 + for _ in $(seq 1 700); do "$PFX/bin/leleka" status --state-dir "$ST" >/dev/null 2>&1 && { ready=1; break; }; kill -0 "$SUP_PID" 2>/dev/null || break; sleep 3; done + [ $ready = 1 ] || { log "variant $v NOT READY"; tail -20 "$D/up-foreground.txt" | cut -c1-240; stop_stack; kill "$MON_PID" 2>/dev/null; continue; } + log "ready after $(( $(date +%s) - t0 )) s" + "$PFX/bin/leleka" status --state-dir "$ST" --json >"$D/status.json" 2>&1 + args=(); for c in $CELLS; do args+=(--cell "$c"); done + python3 -I "$PL/tools/${PF_CLIENT:-replay_hash.py}" "${args[@]}" --url http://127.0.0.1:8081 --model qwen-iq3 --key-file "$ST/api-key" --out "$D/replay.jsonl" --max-requests "$MAXR" >"$D/replay.out" 2>&1 + log "replay rc=$? $(wc -l <"$D/replay.jsonl") requests" + cp "$ST/logs/engine.log" "$D/engine.log" 2>/dev/null; cp "$ST/logs/requests.log" "$D/requests.log" 2>/dev/null + stop_stack; kill "$MON_PID" 2>/dev/null; MON_PID= + sleep 5 +done +log "done" diff --git a/scripts/e2e/codex/prefill/pf_codex_job.sh b/scripts/e2e/codex/prefill/pf_codex_job.sh new file mode 100644 index 00000000..ecbf14cf --- /dev/null +++ b/scripts/e2e/codex/prefill/pf_codex_job.sh @@ -0,0 +1,90 @@ +#!/usr/bin/env bash +# Prefill fixed-latency program: one full Codex session block (smoke-mini warm-up, then the requested tasks) of OUR stack from the prefill-latency +# package (pkg/bin, own state and prefix, never the codex-compare release state). A copy of the `ours` arm of compare/cmp_codex_job.sh. +# HOLDER JOB (inherits the sealed KAR memfd). Test tooling, never in serving. +# PF_VAR result variant name, one directory under $PF_RUN (default LEL-A) +# PF_ENV engine environment of the `leleka up` process, space separated NAME=VALUE (default none = shipped) +# LEL-A: none (shipped, the prompt loan is the full 8192-row loan) LEL-L: LELEKA_PREFILL_LOAN_TIERS=1 +# PF_TASKS tasks (default "nestng-crm") PF_REPS repetitions (default "1") PF_WALL cell wall limit s (3000) PF_ROUNDS round cap (150) +# PF_RUN result directory (default $PL/runs/codex) PF_ROOT task directory (default /data/leleka-e2e/prefill-latency) +# Cells: cell.py of the codex-compare study (logging proxy, temperature 0 injected, real Codex CLI, task acceptance), identical to the LEL/VAN/VANL cells. +set -uo pipefail +PL=${PF_ROOT:-/data/leleka-e2e/prefill-latency} +CMP=/data/leleka-e2e/codex-compare +VAR=${PF_VAR:-LEL-A} +TASKS=${PF_TASKS:-nestng-crm}; REPS=${PF_REPS:-1} +RUN=${PF_RUN:-$PL/runs/codex} +WALL=${PF_WALL:-3000}; ROUNDS=${PF_ROUNDS:-150} +TASKS_ROOT=$CMP/tasks; CELLPY=$CMP/delta/cell.py +CODEX=/home/para/work/codex-e2e/bin/codex +LOCK=/data/leleka-e2e/gpu.lock +G=$HOME/work/gpu-runs +CUBLAS=$HOME/cuda-toolkits/cublas-12.9.1.4/lib +NODE_BIN=$(ls -d "$CMP"/toolchain/node-v*-linux-x64/bin 2>/dev/null | tail -1) +NM=$CMP/nm +BLK=$(echo "$REPS" | tr ' ' '+') +mkdir -p "$RUN/$VAR" +exec > >(tee -a "$RUN/job-$VAR-r$BLK.log") 2>&1 +log() { echo "[pfc $VAR $(date -u +%T)] $*"; } +note() { echo "[$(date -u +%FT%TZ)] [DEV prefill-latency] $*" >>/data/leleka-e2e/decode/notes.md; } + +AS=$CMP/ours-assets; ST=$PL/state; PFX=$PL/prefix; BIN=$PL/pkg/bin +FD=${LELEKA_STRA169_KAR_FD:-} +( cd "$CMP" && sha256sum --quiet -c INSTALL.sha256 ) || { echo "installed tools differ from INSTALL.sha256"; exit 3; } +python3 -I "$CMP/delta/taskfile.py" check "$TASKS_ROOT" >"$RUN/tasks-check-$VAR.txt" 2>&1 || { echo "task files differ from their manifest"; exit 3; } +[ -f "$CMP/toolchain/NESTNG_OK" ] && [ -d "$NM/backend/node_modules" ] || { echo "nestng-crm toolchain is not ready"; exit 3; } +[ -x "$CODEX" ] && [ -n "$NODE_BIN" ] && [ -x "$NODE_BIN/node" ] || { echo "no codex or node toolchain"; exit 3; } +[ -x "$BIN/leleka" ] && [ -f "$ST/leleka.json" ] || { echo "the prefill-latency package or state is not prepared"; exit 3; } +(cd "$PL/pkg/bin" && sha256sum -c ../SHA256SUMS >/dev/null 2>&1) || { echo "the package binaries do not match $PL/pkg/SHA256SUMS"; exit 3; } +readlink "/proc/self/fd/$FD" 2>/dev/null | grep -q '^/memfd:' || { echo "needs the holder's sealed memfd"; exit 3; } +[ -d "$G/MODEL.lock" ] || { echo "MODEL.lock is not held"; exit 3; } +got=0; for _ in $(seq 1 4320); do if mkdir "$LOCK" 2>/dev/null; then echo "prefill-codex $VAR $(date -u +%FT%TZ) $RUN" >"$LOCK/owner"; got=1; break; fi; sleep 5; done +[ $got = 1 ] || { echo "GPU lock held by: $(cat $LOCK/owner 2>/dev/null)"; exit 3; } +SUP_PID=; MON_PID=; PSI_PID=; TAIL_PID= +stop_stack() { if [ -n "$SUP_PID" ] && kill -0 "$SUP_PID" 2>/dev/null; then kill -TERM "$SUP_PID" 2>/dev/null; for _ in $(seq 1 120); do kill -0 "$SUP_PID" 2>/dev/null || break; sleep 2; done; fi; SUP_PID=; } +cleanup() { stop_stack; [ -n "$MON_PID" ] && kill "$MON_PID" 2>/dev/null; [ -n "$PSI_PID" ] && kill "$PSI_PID" 2>/dev/null; [ -n "$TAIL_PID" ] && pkill -P "$TAIL_PID" 2>/dev/null; pkill -KILL -f "$PFX/bin/" 2>/dev/null; sleep 3; rm -f "$LOCK/owner"; rmdir "$LOCK" 2>/dev/null; note "prefill codex block $VAR ended: $RUN"; } +trap cleanup EXIT +note "prefill codex block $VAR started: $RUN tasks=[$TASKS] reps=[$REPS] env=[${PF_ENV:-}]" +[ -z "$(nvidia-smi --query-compute-apps=pid --format=csv,noheader 2>/dev/null)" ] || { echo "something uses the GPU"; exit 3; } +if pgrep -u "$USER" -x 'leleka-inference|strata-next|leleka-daemon' >/dev/null; then echo "a stack process exists"; exit 3; fi +for p in 18766 18080 8081 8090; do ss -ltn "sport = :$p" 2>/dev/null | grep -q LISTEN && { echo "port $p in use"; exit 3; }; done +export LD_LIBRARY_PATH=$CUBLAS:$HOME/cuda-toolkits/13.2.2/lib64:${LD_LIBRARY_PATH:-} +export PATH=$NODE_BIN:$PATH NG_CLI_ANALYTICS=false npm_config_cache=/tmp/cmp-npm-cache npm_config_update_notifier=false npm_config_fund=false npm_config_audit=false CI=1 +unset LELEKA_PREFILL_LOAN_TIERS LELEKA_TRACE_PREFILL_R LELEKA_SERVE_PROFILE LELEKA_REFILL_DEFER LELEKA_BRINGUP_TRACE +for kv in ${PF_ENV:-}; do export "$kv"; done +export LELEKA_SPEC_STATS=1 +STK=$RUN/$VAR/stack-r$BLK; mkdir -p "$STK" +{ date -u +%FT%TZ; uname -r; nvidia-smi --query-gpu=name,driver_version,power.limit --format=csv,noheader; free -g | sed -n 2p; cat "$PL/pkg/COMMIT.txt"; env | grep -E '^(LELEKA_|STRATA_)' | grep -v KEY | sort; } | tee "$STK/host.txt" +nvidia-smi --query-gpu=timestamp,temperature.gpu,clocks.sm,clocks.mem,power.draw,utilization.gpu --format=csv -l 10 >"$STK/mon.csv" 2>/dev/null & MON_PID=$! +# Host memory counters (pf_memstat.sh: memstat.csv every 0.25 s, memstat.mem.csv every 15 s): a stall of the host-only spans (`input`, `other`) is matched against them by the request timestamps. +bash "$PL/tools/pf_memstat.sh" "$STK/memstat" & PSI_PID=$! +# The engine log rotates at 16 MiB and the rotated files are overwritten by the next run: keep the profile lines of the whole session (epoch ms first). +( tail -n 0 -F "$ST/logs/engine.log" 2>/dev/null | grep --line-buffered -a -E 'PREFILL-PROFILE|DBG profile request|"ev":"request"' | while IFS= read -r l; do echo "$(date +%s%3N) $l"; done ) >"$STK/prof.log" 2>/dev/null & TAIL_PID=$! +COMMON="--assets $AS --state-dir $ST --prefix $PFX --bin-src $BIN --cublas-dir $CUBLAS --trust-archive --kar-fd $FD" +: >"$ST/logs/engine.log" 2>/dev/null +t0=$(date +%s) +setsid "$BIN/leleka" up --foreground $COMMON --timeout-s 1800 >"$STK/up-foreground.txt" 2>&1 & +SUP_PID=$! +ready=0 +for _ in $(seq 1 700); do "$PFX/bin/leleka" status --state-dir "$ST" >/dev/null 2>&1 && { ready=1; break; }; kill -0 "$SUP_PID" 2>/dev/null || break; sleep 3; done +[ $ready = 1 ] || { log "NOT READY"; tail -20 "$STK/up-foreground.txt" | cut -c1-240; exit 7; } +log "ready after $(( $(date +%s) - t0 )) s" +"$PFX/bin/leleka" status --state-dir "$ST" --json >"$STK/status.json" 2>&1 +KEY=$(cat "$ST/api-key") +for rep in $REPS; do + list="smoke-mini $TASKS" + for task in $list; do + CELL=$RUN/$VAR/$task-r$rep; [ "$task" = smoke-mini ] && CELL=$RUN/$VAR/smoke-mini-r$((100 + rep)) + [ -f "$CELL/cell.json" ] && { log "cell $CELL already done: skipped"; continue; } + link=""; [ "$task" = nestng-crm ] && link="--link-tree backend/node_modules=$NM/backend/node_modules --link-tree frontend/node_modules=$NM/frontend/node_modules" + t1=$(date +%s) + E2E_API_KEY=$KEY CLD_CODEX=$CODEX timeout $((WALL + 900)) python3 -I "$CELLPY" --cell-dir "$CELL" --variant "$VAR" --task "$task" \ + --rep "$([ "$task" = smoke-mini ] && echo $((100 + rep)) || echo $rep)" --tasks-root "$TASKS_ROOT" --upstream http://127.0.0.1:8081 --upstream-model qwen-iq3 \ + --codex-bin "$CODEX" --wall-limit "$WALL" --max-rounds "$ROUNDS" --engine-log "$ST/logs/engine.log" --active-dir "$RUN/active-$VAR" \ + --config-extra 'model_auto_compact_token_limit = 100000000' $link >"$CELL.out" 2>&1 + log "cell $VAR $task r$rep rc=$? $(( $(date +%s) - t1 )) s: $(tail -1 "$CELL.out" | cut -c1-200)" + done +done +cp "$ST/logs/engine.log" "$STK/engine.log" 2>/dev/null; cp "$ST/logs/requests.log" "$STK/requests.log" 2>/dev/null +stop_stack +log "done" diff --git a/scripts/e2e/codex/prefill/pf_gputest_job.sh b/scripts/e2e/codex/prefill/pf_gputest_job.sh new file mode 100644 index 00000000..0379128b --- /dev/null +++ b/scripts/e2e/codex/prefill/pf_gputest_job.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +# GPU-ignored unit tests of the driver crate (`cargo test -p leleka-cuda-driver --features cuda-driver --lib`), run from the release test binary of a package. +# HOLDER JOB (same GPU lock and holder checks as pf_ab_job.sh). Test tooling, never in serving. +# PF_TEST_BIN the test binary (built with `cargo test --release --no-run`; sha256 is recorded in the log) +# PF_TEST_FILTERS space separated test name filters; each runs as `BIN --ignored --test-threads=1 --nocapture FILTER` +# PF_OUT result directory (one .log per filter and a summary.txt) +set -uo pipefail +RUN=${PF_OUT:?} +BIN=${PF_TEST_BIN:?} +FILTERS=${PF_TEST_FILTERS:?} +LOCK=/data/leleka-e2e/gpu.lock +G=$HOME/work/gpu-runs +CUBLAS=$HOME/cuda-toolkits/cublas-12.9.1.4/lib +FD=${LELEKA_STRA169_KAR_FD:-} +mkdir -p "$RUN" +exec > >(tee -a "$RUN/job-$(date -u +%H%M%S).log") 2>&1 +log() { echo "[pf $(date -u +%T)] $*"; } +readlink "/proc/self/fd/$FD" 2>/dev/null | grep -q '^/memfd:' || { echo "needs the holder's sealed memfd"; exit 3; } +[ -d "$G/MODEL.lock" ] || { echo "MODEL.lock is not held"; exit 3; } +[ -x "$BIN" ] || { echo "no test binary $BIN"; exit 3; } +got=0; for _ in $(seq 1 4320); do if mkdir "$LOCK" 2>/dev/null; then echo "prefill-latency $(date -u +%FT%TZ) $RUN" >"$LOCK/owner"; got=1; break; fi; sleep 5; done +[ $got = 1 ] || { echo "GPU lock held by: $(cat $LOCK/owner 2>/dev/null)"; exit 3; } +cleanup() { rm -f "$LOCK/owner"; rmdir "$LOCK" 2>/dev/null; } +trap cleanup EXIT +[ -z "$(nvidia-smi --query-compute-apps=pid --format=csv,noheader 2>/dev/null)" ] || { echo "something uses the GPU"; exit 3; } +export LD_LIBRARY_PATH=$CUBLAS:$HOME/cuda-toolkits/13.2.2/lib64:${LD_LIBRARY_PATH:-} +log "binary $(sha256sum "$BIN" | cut -c1-16) filters [$FILTERS]" +: > "$RUN/summary.txt" +for f in $FILTERS; do + nice -n 5 "$BIN" --ignored --test-threads=1 --nocapture "$f" > "$RUN/$f.log" 2>&1; rc=$? + echo "$f rc=$rc $(grep -a -E '^test result' "$RUN/$f.log" | tail -1)" | tee -a "$RUN/summary.txt" +done +log done diff --git a/scripts/e2e/codex/prefill/pf_holder_sparse.sh b/scripts/e2e/codex/prefill/pf_holder_sparse.sh new file mode 100644 index 00000000..2e9eed76 --- /dev/null +++ b/scripts/e2e/codex/prefill/pf_holder_sparse.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +# The lab holder with the SPARSE seal (`--sparse-ple`: the 14.9 GiB the serve path reads), HOLDER_MEMFD=full for the old full 55.3 GB copy. Same as scripts/e2e/decode/single-copy-holder.sh +# of the repository (claude/single-copy-ram 9c77d603d); the Python queue process stays /data/leleka-e2e/single-copy/tools/single-copy-holder.py. Same MODEL.lock contract. +set -u +BIN=${1:-/data/leleka-e2e/decode/dt/bin-singlecopy} +T=/data/leleka-e2e/single-copy/tools +KAR=/home/para/work/leleka/models/leleka-gates/assets/qwen-iq3-s-l2-v4.kar +JOBS=$HOME/work/gpu-runs/holder2/jobs +until mkdir "$HOME/work/gpu-runs/MODEL.lock" 2>/dev/null; do sleep 20; done +trap 'rmdir "$HOME/work/gpu-runs/MODEL.lock"' EXIT +cd "$HOME/work/gpu-runs/holder2" || exit 1 +rm -f "$JOBS/READY" +exec_start=$(date +%s) +SPARSE=--sparse-ple; [ "${HOLDER_MEMFD:-sparse}" = full ] && SPARSE= +LELEKA_LOAD_THREADS=${LELEKA_LOAD_THREADS:-8} "$BIN/leleka" seal-exec --file "$KAR" --expect-bytes 55295529472 $SPARSE -- python3 "$T/single-copy-holder.py" '{FD}' "$JOBS" +echo "holder3 ended rc=$? after $(( $(date +%s) - exec_start )) s" diff --git a/scripts/e2e/codex/prefill/pf_holder_watchdog.sh b/scripts/e2e/codex/prefill/pf_holder_watchdog.sh new file mode 100644 index 00000000..13495c51 --- /dev/null +++ b/scripts/e2e/codex/prefill/pf_holder_watchdog.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +# Safety net of the lab queue (test tooling, never in serving): the holder (the queue executor, `single-copy-holder.py` under `seal-exec`) must +# answer. Every 60 s: if no holder process runs, no window script is about to start one (jobs/STOP, a *_window.sh process, a running +# pf_holder_sparse.sh) and the condition held for two checks in a row, start the SPARSE holder (`pf_holder_sparse.sh`), wait for jobs/READY, +# and write the alert to decode/notes.md (also when READY does not come in 10 minutes: then the next round tries again). +# Cause of the 2026-11-10 19:20-20:20 idle GPU: a window script ran `nohup HOLDER_MEMFD=sparse bash ...` (the variable is not a command), the holder never came back. +set -u +PL=/data/leleka-e2e/prefill-latency +H=$HOME/work/gpu-runs/holder2 +NOTES=/data/leleka-e2e/decode/notes.md +note() { echo "[$(date -u +%FT%TZ)] [DEV prefill-latency] holder watchdog: $*" >> "$NOTES"; } +holder_up() { pgrep -u "$USER" -f 'kar_holder2?\.py|single-copy-holder\.py|pf_holder_sparse\.sh|leleka seal-exec' >/dev/null; } +window_pending() { [ -e "$H/jobs/STOP" ] || pgrep -u "$USER" -f '_window\.sh' >/dev/null; } +misses=0 +while true; do + if holder_up || window_pending; then misses=0; sleep 60; continue; fi + misses=$((misses + 1)) + if [ "$misses" -lt 2 ]; then sleep 60; continue; fi + note "no holder process and no window pending for two checks: starting the sparse holder (holder3.out = $(tail -c 160 "$H/holder3.out" 2>/dev/null | tr '\n' ' '))" + rm -f "$H/jobs/READY" + ( cd "$H" && HOLDER_MEMFD=sparse setsid nohup bash "$PL/tools/pf_holder_sparse.sh" > "$H/holder3.out" 2>&1 < /dev/null & ) + for _ in $(seq 1 120); do [ -f "$H/jobs/READY" ] && break; sleep 5; done + if [ -f "$H/jobs/READY" ]; then note "holder ready: $(grep -a 'holder3 ready' "$H/holder3.out" | tail -1)"; else note "ALERT holder not ready after 10 min; $(tail -c 200 "$H/holder3.out" | tr '\n' ' ')"; fi + misses=0 +done diff --git a/scripts/e2e/codex/prefill/pf_holder_window.sh b/scripts/e2e/codex/prefill/pf_holder_window.sh new file mode 100644 index 00000000..6c6f37c9 --- /dev/null +++ b/scripts/e2e/codex/prefill/pf_holder_window.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +# Prefill fixed-latency program: restart the lab holder with a SPARSE sealed memfd (docs/design/single-copy-ram-2026-11-09.md, step 1) and record what it frees. +# A holder-free window started DETACHED by a queue stub that has touched jobs/STOP and closed the holder's descriptor. Test tooling, never in serving. pf_holder_window.sh LABEL [full] +# 1. waits until the lab holder has ended and its memfd is gone; 2. records the host memory (before); 3. starts the holder with the sparse seal (the `full` argument: the old full copy); +# 4. waits for jobs/READY and records the host memory (after) and the holder's `ready ... allocated=` line. Records: $PL/runs/holder/LABEL.txt, notes.md. +set -u +LABEL=${1:-holder}; FORM=${2:-sparse} +PL=/data/leleka-e2e/prefill-latency +H=$HOME/work/gpu-runs/holder2 +NOTES=/data/leleka-e2e/decode/notes.md +OUT=$PL/runs/holder; mkdir -p "$OUT" +note() { echo "[$(date -u +%FT%TZ)] [DEV prefill-latency] $*" >> "$NOTES"; } +snap() { echo "== $1 $(date -u +%FT%TZ)"; grep -E '^(MemTotal|MemFree|MemAvailable|Cached|Shmem|AnonPages|Mapped):' /proc/meminfo; head -2 /proc/pressure/memory; grep -E '^(allocstall_normal|allocstall_movable|pgscan_direct|compact_stall|workingset_refault_file) ' /proc/vmstat; } +holder_up() { pgrep -u "$USER" -f 'kar_holder2?\.py|single-copy-holder\.py' >/dev/null; } +note "holder window $LABEL: waiting for the holder to end (jobs/STOP is set), then a $FORM holder" +for _ in $(seq 1 1440); do if ! holder_up && [ ! -d "$HOME/work/gpu-runs/MODEL.lock" ]; then break; fi; sleep 5; done +if holder_up; then note "holder window $LABEL: the holder did not end in 2 h, giving up"; exit 3; fi +sleep 5 +{ snap before; } >"$OUT/$LABEL.txt" 2>&1 +rm -f "$H/jobs/STOP" "$H/jobs/READY" +( cd "$H" && unset CMP_ARM CMP_TASKS CMP_OPTIONAL CMP_REPS CMP_VANILLA_LOSSY CMP_WALL CMP_ROUNDS CMP_RUN CMP_TARBALL PF_VAR PF_ENV PF_REPS PF_TASKS PF_RUN \ + && HOLDER_MEMFD=$FORM setsid nohup bash "$PL/tools/pf_holder_sparse.sh" > "$H/holder3.out" 2>&1 < /dev/null & ) +for _ in $(seq 1 360); do [ -f "$H/jobs/READY" ] && break; sleep 5; done +sleep 20 +{ snap after; echo "== holder3.out"; grep -a "holder3 ready\|sealed memfd" "$H/holder3.out"; } >>"$OUT/$LABEL.txt" 2>&1 +note "holder window $LABEL: $FORM holder started; $(grep -a 'holder3 ready' "$H/holder3.out" | tail -1); Shmem $(awk '/^Shmem:/{printf "%.1f GiB", $2/1048576}' /proc/meminfo), MemAvailable $(awk '/^MemAvailable:/{printf "%.1f GiB", $2/1048576}' /proc/meminfo); record $OUT/$LABEL.txt" diff --git a/scripts/e2e/codex/prefill/pf_memstat.sh b/scripts/e2e/codex/prefill/pf_memstat.sh new file mode 100644 index 00000000..cc3732f2 --- /dev/null +++ b/scripts/e2e/codex/prefill/pf_memstat.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +# Prefill fixed-latency program: host memory sampler, one per session (test tooling, never in serving). pf_memstat.sh OUT_PREFIX +# OUT_PREFIX.csv every 0.25 s: epoch_ms, PSI memory some/full total (us), direct-reclaim stalls (sum of allocstall_*), major faults, direct scans, +# compaction stalls (system wide), then the engine process: pid, major faults, minor faults, then PSI cpu some total (us) and the summed run-queue wait +# (run_delay, ns) of all threads of the engine process, then PSI io some total (us) and the engine's syscr/read_bytes (unset when unreadable) +# OUT_PREFIX.mem.csv every 15 s: epoch_ms, MemAvailable, MemFree, Cached, Shmem, Mapped, Active(file), Inactive(file) (kB), engine RssAnon, RssFile, RssShmem (kB) +# The engine process is the leleka-inference (ours) or the vanilla Strata engine binary, found by name; 0 when none runs. +OUT=${1:?OUT_PREFIX} +engine_pid() { pgrep -u "$USER" -f 'leleka-inference|components/engine/[^ ]*/strata' 2>/dev/null | head -1; } +pid=; n=0 +while :; do + { [ -n "$pid" ] && [ -r "/proc/$pid/stat" ]; } || pid=$(engine_pid) + sys=$(awk '/^allocstall_/{a+=$2} /^pgmajfault /{m=$2} /^pgscan_direct /{d=$2} /^compact_stall /{c=$2} END{print a","m","d","c}' /proc/vmstat) + psi=$(awk '/^some/{split($5,s,"=")} /^full/{split($5,f,"=")} END{print s[2]","f[2]}' /proc/pressure/memory 2>/dev/null) + proc=0,0,0; [ -n "$pid" ] && proc=$(awk -v p="$pid" '{sub(/^[^)]*\) /,""); split($0,a," "); print p","a[10]","a[8]}' "/proc/$pid/stat" 2>/dev/null || echo "$pid,0,0") + cpu=$(awk '/^some/{split($5,s,"=")} END{print s[2]}' /proc/pressure/cpu 2>/dev/null) + rd=0; [ -n "$pid" ] && rd=$(cat /proc/"$pid"/task/*/schedstat 2>/dev/null | awk '{d+=$2} END{print d+0}') + io=$(awk '/^some/{split($5,s,"=")} END{print s[2]}' /proc/pressure/io 2>/dev/null) + rb=0; [ -n "$pid" ] && rb=$(awk '/^(read_bytes|syscr):/{printf "%s%s",(c++?"/":""),$2}' "/proc/$pid/io" 2>/dev/null) + echo "$(date +%s%3N),$psi,$sys,$proc,$cpu,$rd,$io,${rb:-0}" >>"$OUT.csv" + if [ $((n % 60)) = 0 ]; then + mi=$(awk '{v[$1]=$2} END{print v["MemAvailable:"]","v["MemFree:"]","v["Cached:"]","v["Shmem:"]","v["Mapped:"]","v["Active(file):"]","v["Inactive(file):"]}' /proc/meminfo) + rs=0,0,0; [ -n "$pid" ] && rs=$(awk '/^RssAnon:/{a=$2} /^RssFile:/{f=$2} /^RssShmem:/{s=$2} END{print a","f","s}' "/proc/$pid/status" 2>/dev/null) + echo "$(date +%s%3N),$mi,$rs" >>"$OUT.mem.csv" + fi + n=$((n + 1)); sleep 0.25 +done diff --git a/scripts/e2e/codex/prefill/pf_probe.py b/scripts/e2e/codex/prefill/pf_probe.py new file mode 100644 index 00000000..f85c0338 --- /dev/null +++ b/scripts/e2e/codex/prefill/pf_probe.py @@ -0,0 +1,105 @@ +#!/usr/bin/env python3 +"""Prefill fixed-latency program, step-ledger rows A1-A3 and B2: the "empty request" probe (test tooling, stdlib only). + +A stack under test answers requests that do almost no model work, so what is left is the path of a request INTO the engine (HTTP and gateway, tokenizer and +prompt assembly, prefix-cache lookup and import) and the first token: + + tiny a one-line prompt, one output token -> floor of HTTP + gateway + tokenizer + first token + cold request SEQ of a recorded cell as recorded, one output token (the prompt is read, not cached; not a probe of the intake, a reference) + cached the same body again, REPS times, one output token -> intake + tokenizer of a long prompt + prefix-cache lookup/import + first token + tiny again, REPS times + +Same body and same client for every stack (the recorded forward bodies of a codex-compare cell, like replay_hash.py), so the differences are the stacks'. +One JSON line per request: probe, i, wall and first-event seconds, input/cached/output tokens. Usage: + + pf_probe.py --cell DIR --url http://127.0.0.1:8081 --model qwen-iq3 --key-file FILE --out probe.jsonl [--seq 29] [--reps 5] +""" +import argparse +import gzip +import json +import os +import sys +import time +import urllib.error +import urllib.request + + +def send(url, hdr, body, timeout): + data = json.dumps(body).encode() + t0 = time.time() + rec = {"req_bytes": len(data)} + try: + req = urllib.request.Request(url.rstrip("/") + "/v1/responses", data=data, headers=hdr, method="POST") + with urllib.request.urlopen(req, timeout=timeout) as r: + rec["status"] = r.status + first = None + last = b"" + for line in r: + if first is None: + first = time.time() - t0 + if line.startswith(b"data:") and b"response.completed" in line: + last = line + rec["t_first_s"] = round(first or 0, 4) + if last: + u = json.loads(last[5:]).get("response", {}).get("usage", {}) + rec["input_tokens"] = u.get("input_tokens") + rec["output_tokens"] = u.get("output_tokens") + rec["cached_tokens"] = (u.get("input_tokens_details") or {}).get("cached_tokens") + except urllib.error.HTTPError as e: + rec["error"] = "HTTP %d %s" % (e.code, e.read()[:300].decode("utf-8", "replace")) + except Exception as e: # recorded, the probe goes on + rec["error"] = repr(e)[:200] + rec["wall_s"] = round(time.time() - t0, 4) + return rec + + +def main(): + ap = argparse.ArgumentParser() + ap.add_argument("--cell", action="append", required=True) + ap.add_argument("--url", required=True) + ap.add_argument("--model", required=True) + ap.add_argument("--key-file", default="") + ap.add_argument("--out", required=True) + ap.add_argument("--max-requests", type=int, default=0, help="accepted for the replay_hash.py command line; unused") + ap.add_argument("--seq", type=int, default=29, help="1-based number of the recorded request used as the long prompt") + ap.add_argument("--reps", type=int, default=5) + ap.add_argument("--timeout", type=int, default=900) + a = ap.parse_args() + key = open(a.key_file).read().strip() if a.key_file else "" + rounds = os.path.join(a.cell[0], "proxy", "rounds") + names = sorted(n for n in os.listdir(rounds) if n.endswith(".fwd.json.gz")) + body = json.loads(gzip.open(os.path.join(rounds, names[a.seq - 1])).read()) + body["model"] = a.model + body["temperature"] = 0.0 + body["max_output_tokens"] = 1 + # a vanilla session's reasoning blob is refused by Leleka (HTTP 400); its own sessions keep None there + for it in body.get("input") or []: + if isinstance(it, dict) and it.get("type") == "reasoning" and it.get("encrypted_content"): + it["encrypted_content"] = None + sid = body.get("prompt_cache_key") or "" + hdr = {"Content-Type": "application/json", "Accept": "text/event-stream", "session-id": sid, "thread-id": sid, "x-codex-window-id": sid + ":0"} + if key: + hdr["Authorization"] = "Bearer " + key + tiny = { + "model": a.model, + "input": [{"type": "message", "role": "user", "content": [{"type": "input_text", "text": "Say ok."}]}], + "stream": True, + "temperature": 0.0, + "max_output_tokens": 1, + } + plan = [("tiny", tiny)] * 2 + [("cold", body)] + [("cached", body)] * a.reps + [("tiny", tiny)] * a.reps + out = open(a.out, "a", encoding="utf-8") + seen = {} + for label, b in plan: + seen[label] = seen.get(label, 0) + 1 + rec = {"probe": label, "i": seen[label], "seq": a.seq} + rec.update(send(a.url, hdr, b, a.timeout)) + out.write(json.dumps(rec) + "\n") + out.flush() + print(json.dumps(rec), flush=True) + time.sleep(0.5) + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/scripts/e2e/codex/prefill/pf_sparse_requeue.sh b/scripts/e2e/codex/prefill/pf_sparse_requeue.sh new file mode 100644 index 00000000..28af41c2 --- /dev/null +++ b/scripts/e2e/codex/prefill/pf_sparse_requeue.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +# Prefill fixed-latency program: put a job back in the queue behind a SPARSE lab holder. Started DETACHED by pf_ab_job.sh (guard: the inherited sealed memfd is not +# sparse), after the job has touched jobs/STOP and closed the holder's descriptor and exited. Waits for the holder to end, starts the sparse one (pf_holder_window.sh), +# then removes JOB.done so the new holder's queue picks the job again (its name stays in jobs/PRIORITY). pf_sparse_requeue.sh JOBNAME. Test tooling, never in serving. +set -u +JOB=${1:?job name} +PL=/data/leleka-e2e/prefill-latency +J=$HOME/work/gpu-runs/holder2/jobs +NOTES=/data/leleka-e2e/decode/notes.md +echo "[$(date -u +%FT%TZ)] [DEV prefill-latency] $JOB found a non-sparse memfd: sparse holder restart, then $JOB runs again" >> "$NOTES" +bash "$PL/tools/pf_holder_window.sh" "requeue-$JOB" sparse +for _ in $(seq 1 60); do [ -f "$J/READY" ] && break; sleep 5; done +rm -f "$J/$JOB.done" +echo "[$(date -u +%FT%TZ)] [DEV prefill-latency] $JOB queued again behind the sparse holder" >> "$NOTES" diff --git a/scripts/e2e/codex/prefill/pf_van_probe.sh b/scripts/e2e/codex/prefill/pf_van_probe.sh new file mode 100644 index 00000000..9333103f --- /dev/null +++ b/scripts/e2e/codex/prefill/pf_van_probe.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +# Prefill fixed-latency program (step ledger A1-A3): vanilla Strata 0.2.6 answering the empty-request probe (pf_probe.py) instead of the replay; a copy of spd-gap/tools/spd_van_job2.sh without +# the engine-side profile. Holder-free window payload (started by spd_window.sh). Test tooling, never in serving. +set -uo pipefail +SPD=/data/leleka-e2e/spd-gap +PL=/data/leleka-e2e/prefill-latency +CMP=/data/leleka-e2e/codex-compare +A=/home/para/work/leleka/models/leleka-gates/assets +G=$HOME/work/gpu-runs +LOCK=/data/leleka-e2e/gpu.lock +LOSSY=${SPD_LOSSY:-0} +RUN=${SPD_RUN:-$PL/runs/probe/VANL} +CELLS=${SPD_CELLS:-"$CMP/runs/main/VANL/nestng-crm-r2"} +MAXR=${SPD_MAX:-30} +mkdir -p "$RUN" +exec > >(tee -a "$RUN/job.log") 2>&1 +log() { echo "[spd-van $(date -u +%T)] $*"; } +mkdir "$G/MODEL.lock" 2>/dev/null || { echo "MODEL.lock is held (holder still up?)"; exit 3; } +got=0; for _ in $(seq 1 4320); do if mkdir "$LOCK" 2>/dev/null; then echo "spd-gap vanilla $(date -u +%FT%TZ) $RUN" >"$LOCK/owner"; got=1; break; fi; sleep 5; done +[ $got = 1 ] || { echo "GPU lock held by: $(cat $LOCK/owner 2>/dev/null)"; rmdir "$G/MODEL.lock"; exit 3; } +S=$HOME/work/vanilla-strata/control/bin/strata +cleanup() { ( cd "$HOME/work/vanilla-strata/control" && "$S" launch --stop >/dev/null 2>&1 ); sleep 5; rm -f "$LOCK/owner"; rmdir "$LOCK" 2>/dev/null; rmdir "$G/MODEL.lock" 2>/dev/null; } +trap cleanup EXIT +[ -z "$(nvidia-smi --query-compute-apps=pid --format=csv,noheader 2>/dev/null)" ] || { echo "something uses the GPU"; exit 3; } +export XDG_CONFIG_HOME=$RUN/xdg-config XDG_STATE_HOME=$RUN/xdg-state +mkdir -p "$XDG_CONFIG_HOME/strata" "$XDG_STATE_HOME"; cp ~/.config/strata/settings.json "$XDG_CONFIG_HOME/strata/" +if [ "$LOSSY" = 1 ]; then unset STRATA_ROUTE_TAIL_SKIP STRATA_PREFILL_CPU_SHARE; else export STRATA_ROUTE_TAIL_SKIP=0 STRATA_PREFILL_CPU_SHARE=0; fi +export LD_LIBRARY_PATH=$HOME/cuda-toolkits/cublas-12.9.1.4/lib:$HOME/cuda-toolkits/13.2.2/lib64:${LD_LIBRARY_PATH:-} +cd "$HOME/work/vanilla-strata/control" +t0=$(date +%s) +timeout 2400 "$S" launch --model iq3_s --family qwen --model-path "$A/model" --context 256k --kv int8 --vision off --parallel 1 --tune skip --access local --port 8090 --no-api-key --no-tui --yes >"$RUN/launch.out" 2>&1 +log "launch rc=$? ready after $(( $(date +%s) - t0 )) s" +curl -fs http://127.0.0.1:8090/v1/models >"$RUN/models.json" || { log "vanilla did not become ready"; exit 4; } +MODEL=$(python3 -c "import json;print(json.load(open('$RUN/models.json'))['data'][0]['id'])") +args=(); for c in $CELLS; do args+=(--cell "$c"); done +python3 -I "$PL/tools/pf_probe.py" "${args[@]}" --url http://127.0.0.1:8090 --model "$MODEL" --out "$RUN/replay.jsonl" --max-requests "$MAXR" >"$RUN/replay.out" 2>&1 +log "replay rc=$? $(wc -l <"$RUN/replay.jsonl") requests" +cp "$XDG_STATE_HOME/strata/launch/iq3_s-256k.engine.log" "$RUN/engine.log" 2>/dev/null +log "done" diff --git a/scripts/e2e/codex/prefill/pf_van_window.sh b/scripts/e2e/codex/prefill/pf_van_window.sh new file mode 100644 index 00000000..2791c873 --- /dev/null +++ b/scripts/e2e/codex/prefill/pf_van_window.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +# Prefill fixed-latency program: a copy of codex-compare/tools/cmp_window.sh for the vanilla arm (variant VANL) that records the host memory counters of the session +# (pf_memstat.sh: memstat.csv / memstat.mem.csv next to the stack directory) and writes its results under the prefill-latency task directory. pf_van_window.sh LABEL +# A holder-free window started DETACHED by a queue stub that has touched jobs/STOP and closed the holder's descriptor. Test tooling, never in serving. +# 1. waits until the lab holder has ended and its memfd is gone; 2. runs codex-compare/tools/cmp_codex_job.sh (unchanged, CMP_* from the stub); 3. ALWAYS restarts the lab holder. +set -u +LABEL=${1:-window} +C=/data/leleka-e2e/codex-compare +PL=/data/leleka-e2e/prefill-latency +H=$HOME/work/gpu-runs/holder2 +NOTES=/data/leleka-e2e/decode/notes.md +note() { echo "[$(date -u +%FT%TZ)] [DEV prefill-latency] $*" >> "$NOTES"; } +SAMPLER= +restart_holder() { + [ -n "$SAMPLER" ] && kill "$SAMPLER" 2>/dev/null + if pgrep -u "$USER" -f 'kar_holder2?\.py|single-copy-holder\.py' >/dev/null; then echo "a holder is already running"; return; fi + rmdir "$HOME/work/gpu-runs/MODEL.lock" 2>/dev/null + rm -f "$H/jobs/STOP" "$H/jobs/READY" + ( cd "$H" && unset CMP_ARM CMP_TASKS CMP_OPTIONAL CMP_REPS CMP_VANILLA_LOSSY CMP_WALL CMP_ROUNDS CMP_RUN CMP_TARBALL && setsid nohup bash "$PL/tools/pf_holder_sparse.sh" > "$H/holder3.out" 2>&1 < /dev/null & ) + note "window $LABEL over: holder restarted with single-copy-holder.sh (holder3.out); queue open again" +} +trap restart_holder EXIT +note "window $LABEL: waiting for the holder to end (jobs/STOP is set), then cmp_codex_job.sh: arm=${CMP_ARM:-?} reps=[${CMP_REPS:-}] tasks=[${CMP_TASKS:-}] run=${CMP_RUN:-}" +for _ in $(seq 1 1440); do + if ! pgrep -u "$USER" -f 'kar_holder2?\.py|single-copy-holder\.py' >/dev/null && [ ! -d "$HOME/work/gpu-runs/MODEL.lock" ]; then break; fi + sleep 5 +done +if pgrep -u "$USER" -f 'kar_holder2?\.py|single-copy-holder\.py' >/dev/null; then note "window $LABEL: the holder did not end in 2 h, giving up (holder left as it is)"; trap - EXIT; exit 3; fi +sleep 5 +note "window $LABEL: holder gone, MemAvailable $(awk '/^MemAvailable:/{printf "%d GiB", $2/1048576}' /proc/meminfo); starting" +OUTD=${CMP_RUN:-$PL/runs/van}/VANL; mkdir -p "$OUTD" +bash "$PL/tools/pf_memstat.sh" "$OUTD/memstat-r$(echo "${CMP_REPS:-1}" | tr ' ' '+')" & SAMPLER=$! +bash "$C/tools/cmp_codex_job.sh" > "$PL/window-$LABEL.out" 2>&1 +note "window $LABEL: cmp_codex_job.sh ended rc=$?; log $PL/window-$LABEL.out" diff --git a/scripts/e2e/decode/single-copy-holder.sh b/scripts/e2e/decode/single-copy-holder.sh index 55a20aa6..e9ffef87 100644 --- a/scripts/e2e/decode/single-copy-holder.sh +++ b/scripts/e2e/decode/single-copy-holder.sh @@ -1,6 +1,9 @@ #!/usr/bin/env bash # Start the lab holder with the fast, page-cache-free seal (see single-copy-holder.py). Same MODEL.lock contract as run_holder2.sh. # single-copy-holder.sh [BIN_DIR] BIN_DIR holds `leleka` (default /data/leleka-e2e/decode/dt/bin-singlecopy) +# The memfd is SPARSE by default (`--sparse-ple`: only the 14.9 GiB the serve path reads; holes elsewhere), the form of profile rtx5090-32g. A full 55.3 GB memfd is a second +# copy of model bytes next to the resident expert bank (36.6 GiB nobody reads; the 2026-11-09 server measurement, docs/design/single-copy-ram-2026-11-09.md), and `leleka run` +# now refuses it for a ple_only profile. HOLDER_MEMFD=full restores the full copy (jobs whose profile is memfd_extents=full, with LELEKA_ALLOW_FULL_MEMFD=1 where needed). # Run it detached: cd ~/work/gpu-runs/holder2 && rm -f jobs/STOP && setsid nohup bash /data/leleka-e2e/single-copy/tools/single-copy-holder.sh > holder3.out 2>&1 & set -u BIN=${1:-/data/leleka-e2e/decode/dt/bin-singlecopy} @@ -12,5 +15,6 @@ trap 'rmdir "$HOME/work/gpu-runs/MODEL.lock"' EXIT cd "$HOME/work/gpu-runs/holder2" || exit 1 rm -f "$JOBS/READY" exec_start=$(date +%s) -LELEKA_LOAD_THREADS=${LELEKA_LOAD_THREADS:-8} "$BIN/leleka" seal-exec --file "$KAR" --expect-bytes 55295529472 -- python3 "$T/single-copy-holder.py" '{FD}' "$JOBS" +SPARSE=--sparse-ple; [ "${HOLDER_MEMFD:-sparse}" = full ] && SPARSE= +LELEKA_LOAD_THREADS=${LELEKA_LOAD_THREADS:-8} "$BIN/leleka" seal-exec --file "$KAR" --expect-bytes 55295529472 $SPARSE -- python3 "$T/single-copy-holder.py" '{FD}' "$JOBS" echo "holder3 ended rc=$? after $(( $(date +%s) - exec_start )) s" diff --git a/scripts/gpu-bringup/extra-seal-plan.json b/scripts/gpu-bringup/extra-seal-plan.json index f940fbee..7eb39823 100644 --- a/scripts/gpu-bringup/extra-seal-plan.json +++ b/scripts/gpu-bringup/extra-seal-plan.json @@ -955,6 +955,54 @@ "group": "draft-round", "optional": false }, + { + "cu": "crates/cuda-driver/src/mtp_original_check_batch.cu", + "ptx": "crates/cuda-driver/src/mtp_original_check_batch.ptx", + "flags": [ + "-ptx", + "-O3", + "-arch=sm_120", + "-std=c++17", + "--fmad=true", + "--ftz=false" + ], + "policy": "precise (the recipe of scripts/build-original-verify-ptx.sh, which built the single-check kernels this one batches; the predicate is the same abs + setp.ne inf)", + "entries": [ + "mtp_original_check_batch" + ], + "encoding": "include_bytes", + "group": "draft-check-batch", + "optional": false + }, + { + "cu": "crates/cuda-driver/src/gdn_prefill_tc.cu", + "ptx": "crates/cuda-driver/src/gdn_prefill_tc.ptx", + "flags": [ + "-ptx", + "-O3", + "-arch=sm_120", + "-std=c++17", + "--ftz=false", + "--prec-div=true", + "--prec-sqrt=true", + "--fmad=true" + ], + "policy": "precise (the recipe of prefill_stage; EXPERIMENTAL and LOSSY by design, LELEKA_PREFILL_GDN_TC: the prompt GDN recurrence as a chunked scan on f16x3 tensor-core products, a port of Strata upstream gdn_tc.cuh, not bitwise equal to leleka_prefill_gdn_rec_kh; the lossy gate of docs/quality-gate.md decides)", + "entries": [ + "leleka_gdn_tc_prep", + "leleka_gdn_tc_scan_t1", + "leleka_gdn_tc_scan_t2" + ], + "encoding": "concat_include_str", + "rust_fields_to_fill": { + "gdn_prefill_tc.rs": [ + "PIN.source_sha256", + "PIN.ptx_sha256" + ] + }, + "group": "gdn-prefill-tc", + "optional": false + }, { "cu": "crates/cuda-driver/src/original_verify_window_qsa_kv_rows.cu", "ptx": "crates/cuda-driver/src/original_verify_window_qsa_kv_rows.ptx",