diff --git a/crates/cuda-driver/ptx-sm86/MANIFEST.json b/crates/cuda-driver/ptx-sm86/MANIFEST.json index 4d9662bc..8af03f9f 100644 --- a/crates/cuda-driver/ptx-sm86/MANIFEST.json +++ b/crates/cuda-driver/ptx-sm86/MANIFEST.json @@ -2733,6 +2733,27 @@ "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", + "problems": [ + "not built for sm_86 by design (claude/verify-qsa-fused-prelude): LELEKA_SM120_FUSED_QSA_PRELUDE is an opt-in compute capability 12 decode switch (original_verify_window_sm120.rs), so an sm_86 build never loads this module" + ] + }, + { + "name": "original_verify_window_qsa_index_rows.ptx", + "sm120_path": "crates/cuda-driver/src/original_verify_window_qsa_index_rows.ptx", + "problems": [ + "not built for sm_86 by design (claude/verify-qsa-fused-prelude): LELEKA_SM120_FUSED_QSA_PRELUDE is an opt-in compute capability 12 decode switch (original_verify_window_sm120.rs), so an sm_86 build never loads this module" + ] + }, + { + "name": "sm120_gdn_fused.ptx", + "sm120_path": "crates/cuda-driver/src/sm120_gdn_fused.ptx", + "problems": [ + "not built for sm_86 by design (claude/verify-gdn-fused-kernels): LELEKA_SM120_FUSED_GDN and LELEKA_SM120_GDN_AB_UNROLL are compute capability 12.0 decode switches; original_verify_window_sm120.rs enables them only on a 12.x card, so an sm_86 build never loads this module" + ] } ], "portable_no_companion_needed": [ diff --git a/crates/cuda-driver/src/device_buffer.rs b/crates/cuda-driver/src/device_buffer.rs index dd7fb524..1cb80981 100644 --- a/crates/cuda-driver/src/device_buffer.rs +++ b/crates/cuda-driver/src/device_buffer.rs @@ -24,6 +24,12 @@ impl DeviceBuffer<'_> { Ok(staging) } pub fn copy_from(&mut self, input: &[u8]) -> Result<()> { + self.copy_from_shared(input) + } + /// `copy_from` through a shared borrow, for a buffer behind a `DeviceRef` (the PLE history image the held + /// verify graphs read in place): the same staging, copy and synchronisation, so the caller keeps the device idle + /// of other writers to the buffer. + pub fn copy_from_shared(&self, input: &[u8]) -> Result<()> { let mut staging = self.staging(input.len())?; staging.copy_from_slice(input); self.copy_staged(staging, false).map(|_| ()) diff --git a/crates/cuda-driver/src/device_ref.rs b/crates/cuda-driver/src/device_ref.rs new file mode 100644 index 00000000..8d843bd0 --- /dev/null +++ b/crates/cuda-driver/src/device_ref.rs @@ -0,0 +1,102 @@ +//! A shared, cloneable handle to a device allocation (or to a range of one). +//! +//! The verify-window aggregates (`OriginalVerifyWindowResources`, the GDN/QSA journals) used to borrow every weight, +//! scratch and history buffer they read from the cache that owns it (`&'a DeviceBuffer`). A value that borrows +//! fields of its owner cannot be stored next to the owner, so the whole recorded graph set had to be dropped and +//! recorded again for every request. A [`DeviceRef`] replaces the borrow by shared ownership of the allocation: +//! +//! * `Clone` is one reference-count increment. Clones happen when an assembly is built, parked or re-armed, never +//! in the per-step loop; the window code only dereferences (`&*handle`, a pointer read, no count traffic). +//! * It dereferences to the [`DeviceBuffer`] every kernel entry point takes, so `qwen_address()` and the size checks +//! work on the handle unchanged. +//! * The range is the alias' own: a handle made from a [`DeviceSlice`] names `[offset, offset + len)` of a slab (the +//! alias is a non-owning `DeviceBuffer` of exactly that range) and keeps the slab alive; a handle made from a +//! whole `DeviceBuffer` owns it. +//! * The allocation is freed when the last holder drops. An owner that releases its handle while an assembly still +//! holds another keeps the memory alive (`release` reports `Ok` and leaves the free to the last holder). +//! +//! Single-thread affine like the buffers it wraps (`Rc`). +use crate::{DeviceBuffer, DeviceSlice, Result}; +use std::{ops::Deref, rc::Rc}; + +/// What a handle shares: the buffer it names and, for a range of a slab, the slab that keeps the memory alive. +struct Shared<'ctx> { + /// Declared first: a non-owning alias drops (and frees nothing) before the slab it points into. + buffer: DeviceBuffer<'ctx>, + slab: Option>>, +} + +/// A shared handle to a device allocation; see the module comment. +pub struct DeviceRef<'ctx> { + shared: Rc>, +} + +impl<'ctx> DeviceRef<'ctx> { + /// A handle that owns `buffer` (its own allocation). + pub fn from_buffer(buffer: DeviceBuffer<'ctx>) -> Self { + Self { shared: Rc::new(Shared { buffer, slab: None }) } + } + + /// A handle to the buffer of a [`DeviceSlice`] (its own allocation, or its range of a shared slab). + pub fn from_slice(slice: DeviceSlice<'ctx>) -> Self { + let (buffer, slab) = slice.into_parts(); + Self { shared: Rc::new(Shared { buffer, slab }) } + } + + /// Whether both handles name the same allocation range. + pub fn ptr_eq(&self, other: &Self) -> bool { + Rc::ptr_eq(&self.shared, &other.shared) + } + + /// How many handles share this range (the cache's own plus every held assembly's). + pub fn holders(&self) -> usize { + Rc::strong_count(&self.shared) + } + + /// Give this handle up. The sole holder frees the buffer (the last handle of a slab frees the slab) and returns + /// the error of that free; with other holders left, they keep the memory alive and free it when they drop. + pub fn release(self) -> Result<()> { + let Ok(shared) = Rc::try_unwrap(self.shared) else { return Ok(()) }; + let Shared { buffer, slab } = shared; + let freed = buffer.release(); + let Some(slab) = slab else { return freed }; + match Rc::try_unwrap(slab) { + Ok(slab) => crate::combine(freed, slab.release()), + Err(_) => freed, + } + } +} + +impl<'ctx> Clone for DeviceRef<'ctx> { + fn clone(&self) -> Self { + Self { shared: Rc::clone(&self.shared) } + } +} + +impl<'ctx> Deref for DeviceRef<'ctx> { + type Target = DeviceBuffer<'ctx>; + fn deref(&self) -> &DeviceBuffer<'ctx> { + &self.shared.buffer + } +} + +impl std::fmt::Debug for DeviceRef<'_> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "DeviceRef({} bytes, {} holders)", self.shared.buffer.len(), self.holders()) + } +} + +impl<'ctx> From> for DeviceRef<'ctx> { + fn from(buffer: DeviceBuffer<'ctx>) -> Self { + Self::from_buffer(buffer) + } +} + +impl<'ctx> From> for DeviceRef<'ctx> { + fn from(slice: DeviceSlice<'ctx>) -> Self { + Self::from_slice(slice) + } +} + +#[cfg(test)] +mod tests; diff --git a/crates/cuda-driver/src/device_ref/tests.rs b/crates/cuda-driver/src/device_ref/tests.rs new file mode 100644 index 00000000..e66d0dbe --- /dev/null +++ b/crates/cuda-driver/src/device_ref/tests.rs @@ -0,0 +1,84 @@ +//! Device proofs of the shared allocation handle. They need a CUDA device and run only with the enabling variable; +//! on every other host they are compile-checked, never executed (the handle is a thin `Rc` over a `DeviceBuffer`, which +//! cannot exist without a context, so there is nothing to build without a device). +use super::*; +use crate::{Driver, SlabAllocator, SlabPolicy}; + +const ENABLE: &str = "LELEKA_VERIFY_WINDOW_GPU"; + +#[test] +#[ignore = "Root-only: needs a CUDA device"] +fn a_released_owner_leaves_the_memory_to_the_last_holder() { + assert_eq!(std::env::var(ENABLE).ok().as_deref(), Some("yes")); + let driver = Driver::load().expect("driver"); + let device = driver.device(0).expect("device"); + let context = device.create_context(1 << 30).expect("context"); + let before = context.allocated_bytes(); + let owner = DeviceRef::from_buffer(context.allocate(4096).expect("buffer")); + owner.copy_from_shared(&[7u8; 4096]).expect("upload through the shared handle"); + let held = owner.clone(); + assert!(owner.ptr_eq(&held)); + assert_eq!(owner.holders(), 2); + assert_eq!(owner.len(), 4096); + // the owner gives its handle up while the assembly still holds one: nothing is freed + owner.release().expect("release with a holder left"); + assert_eq!(context.allocated_bytes(), before + 4096); + assert_eq!(held.copy_to_owned(4096).expect("read back"), vec![7u8; 4096]); + assert_eq!(held.holders(), 1); + held.release().expect("the last holder frees"); + assert_eq!(context.allocated_bytes(), before); +} + +#[test] +#[ignore = "Root-only: needs a CUDA device"] +fn a_handle_to_a_slab_range_keeps_the_slab_alive_after_the_allocator_released_it() { + assert_eq!(std::env::var(ENABLE).ok().as_deref(), Some("yes")); + let driver = Driver::load().expect("driver"); + let device = driver.device(0).expect("device"); + let context = device.create_context(1 << 30).expect("context"); + let before = context.allocated_bytes(); + let mut slabs = SlabAllocator::new(&context, SlabPolicy::DENSE).expect("slab allocator"); + let first = DeviceRef::from_slice(slabs.allocate(1024).expect("first range")); + let second = DeviceRef::from_slice(slabs.allocate(2048).expect("second range")); + assert!(!first.ptr_eq(&second)); + first.copy_from_shared(&[1u8; 1024]).expect("upload"); + second.copy_from_shared(&[2u8; 2048]).expect("upload"); + let held = second.clone(); + // the cache closes: its handles and the allocator go, one handle of an assembly is left + first.release().expect("release first"); + second.release().expect("release second with a holder left"); + slabs.release().expect("release the allocator"); + assert!(context.allocated_bytes() > before, "the slab is still allocated"); + assert_eq!(held.copy_to_owned(2048).expect("read back"), vec![2u8; 2048]); + held.release().expect("the last holder frees the slab"); + assert_eq!(context.allocated_bytes(), before); +} + +/// The per-step path (a `run`: begin, enqueue, drain, commit) and the recorders read the handles through `Deref` +/// only. This guard keeps `.clone()` out of the modules that read the weight handles of a recorded window, so a +/// reference-count increment cannot slip into the loop unnoticed. The clones live in the assembly (the engine's caches +/// hand the handles out) and in `park` / `rearm`. +#[test] +fn the_window_and_journal_modules_never_clone_a_handle() { + let window_ops = [ + include_str!("../original_verify_window_ops.rs"), + include_str!("../original_verify_window_ops/gdn_stages.rs"), + include_str!("../original_verify_window_ops/original_verify_window_ops_methods.rs"), + include_str!("../original_verify_window_ops/qsa_prelude_ops.rs"), + include_str!("../original_verify_window_ops/side_qsa_branches.rs"), + include_str!("../original_verify_window_ops/side_shared_expert.rs"), + include_str!("../original_verify_window_ops/window_ops_kernels_and_pcie_plan.rs"), + ]; + let journals = [ + include_str!("../original_verify/original_verify_gdn_journal/verify_gdn_fused_step.rs"), + include_str!("../original_verify/original_verify_gdn_journal/verify_gdn_journal_ladder_logits_scan.rs"), + include_str!("../original_verify/original_verify_gdn_journal/verify_gdn_journal_stage_and_commit.rs"), + include_str!("../original_verify/original_verify_gdn_journal/verify_gdn_journal_window_launches.rs"), + include_str!("../qsa_verification_commit/verify_qsa_journal_capture_commit.rs"), + include_str!("../qsa_verification_commit/verify_qsa_journal_index_image.rs"), + ]; + for source in window_ops.iter().chain(journals.iter()) { + let code = source.split("#[cfg(test)]").next().unwrap_or(source); + assert!(!code.contains(".clone()"), "a window or journal module clones: handles are dereferenced there"); + } +} diff --git a/crates/cuda-driver/src/device_slab.rs b/crates/cuda-driver/src/device_slab.rs index bd55163c..6a08dc82 100644 --- a/crates/cuda-driver/src/device_slab.rs +++ b/crates/cuda-driver/src/device_slab.rs @@ -133,6 +133,15 @@ impl<'ctx> DeviceSlice<'ctx> { matches!(self.backing, SliceBacking::Carved { .. }) } + /// The buffer this slice dereferences to and, for a carved range, the slab that keeps it alive + /// (`DeviceRef::from_slice`). + pub(crate) fn into_parts(self) -> (DeviceBuffer<'ctx>, Option>>) { + match self.backing { + SliceBacking::Own(buffer) => (buffer, None), + SliceBacking::Carved { slab, view } => (view, Some(slab)), + } + } + /// Release the buffer. The last slice of a slab frees the slab; an error of that free is returned. pub fn release(self) -> Result<()> { match self.backing { diff --git a/crates/cuda-driver/src/lib.rs b/crates/cuda-driver/src/lib.rs index c2381cac..acf1445b 100644 --- a/crates/cuda-driver/src/lib.rs +++ b/crates/cuda-driver/src/lib.rs @@ -43,6 +43,7 @@ pub use root_exports::*; pub mod compute_drain; mod deferred_status; +mod device_ref; mod device_slab; #[allow(unsafe_code)] mod ffi; 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..d9b2d4a5 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 @@ -5,6 +5,8 @@ use super::*; #[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_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/native_head/native_asset_pin_types.rs b/crates/cuda-driver/src/native_head/native_asset_pin_types.rs index d827b40e..95b09f0d 100644 --- a/crates/cuda-driver/src/native_head/native_asset_pin_types.rs +++ b/crates/cuda-driver/src/native_head/native_asset_pin_types.rs @@ -93,10 +93,13 @@ pub struct OriginalNativeHeadRows<'ctx> { pub(super) mixed: Option>, pub(super) q8: Option>, pub(super) logits: Option>, + /// `t` sampled ids, then one word: the finite verdict of the logits when the graph carries it. pub(super) mapped: Option, pub(super) commands: RefCell>, pub(super) t: usize, pub(super) failed: Cell, + /// `LELEKA_SM120_ACCEPT_ON_DEVICE`: the verify graph of these rows ends with the finite scan (set before capture). + pub(super) verdict_in_graph: Cell, } pub struct NativeHeadFlight<'a, 'ctx> { pub(super) rows: &'a mut OriginalNativeHeadRows<'ctx>, diff --git a/crates/cuda-driver/src/native_head/original_native_head_rows/original_native_head_rows_greedy_submit.rs b/crates/cuda-driver/src/native_head/original_native_head_rows/original_native_head_rows_greedy_submit.rs index fd9c27a8..89e0e2ad 100644 --- a/crates/cuda-driver/src/native_head/original_native_head_rows/original_native_head_rows_greedy_submit.rs +++ b/crates/cuda-driver/src/native_head/original_native_head_rows/original_native_head_rows_greedy_submit.rs @@ -20,6 +20,7 @@ impl<'ctx> OriginalNativeHeadRows<'ctx> { commands: RefCell::new(Vec::new()), t, failed: Cell::new(false), + verdict_in_graph: Cell::new(false), }; if let Err(primary) = owner.allocate_buffers() { return combine(Err(primary), owner.close_inner()); @@ -32,14 +33,36 @@ impl<'ctx> OriginalNativeHeadRows<'ctx> { self.q8 = Some(context.allocate(t * self.head.n / 32 * 36)?); self.logits = Some(context.allocate(t * self.head.vocab * 4)?); let guard = context.enter()?; - let mapped = MappedAllocation::new(t * 4); + // the ids, then the finite verdict word (read only when the graph carries the scan) + let mapped = MappedAllocation::new(t * 4 + 4); let pop = guard.finish(); if pop.is_err() { context.poison(); context.retain_driver(); } self.mapped = Some(combine(mapped, pop)?); - Ok(()) + self.rearm_finite_verdict() + } + /// The verify graph of these rows ends with the finite scan and its store to the verdict word (set before capture). + pub(crate) fn set_finite_verdict_in_graph(&self, on: bool) { + self.verdict_in_graph.set(on); + } + pub(crate) fn finite_verdict_in_graph(&self) -> bool { + self.verdict_in_graph.get() + } + /// Device address of the verdict word, the destination of the graph's store. + pub(crate) fn finite_verdict_address(&self) -> Result { + self.mapped.as_ref().ok_or(Error::ContextPoisoned)?.address(self.t * 4, 4) + } + /// The word the graph stored, after a genuine drain: `Ok` when every logit was finite. + pub(crate) fn read_finite_verdict(&self) -> Result<()> { + let words = self.mapped.as_ref().ok_or(Error::ContextPoisoned)?.read_i32(self.t + 1)?; + crate::original_verify::finite_verdict::decode_verdict(words[self.t]) + } + /// Back to "not written": a window whose graph did not store its verdict reads as an error, not as finite. + fn rearm_finite_verdict(&mut self) -> Result<()> { + let pending = crate::original_verify::finite_verdict::VERDICT_PENDING.to_le_bytes(); + self.mapped.as_mut().ok_or(Error::ContextPoisoned)?.write(self.t * 4, &pending) } pub fn rows(&self) -> usize { self.t @@ -160,6 +183,9 @@ impl<'ctx> OriginalNativeHeadRows<'ctx> { ) -> Result { let NativeHeadSampling { position: pos0, params, history, history_len, enabled: head_sampling, .. } = sampling; self.check_sampling_request(stream, ¶ms, history_len, pos0)?; + if self.finite_verdict_in_graph() { + self.rearm_finite_verdict()?; + } self.commands.borrow_mut().clear(); if head_sampling && sampling_needed(¶ms, history.is_some()) { self.sample_on_stream(stream, sampling)?; diff --git a/crates/cuda-driver/src/original_gpu_verify_bridge.rs b/crates/cuda-driver/src/original_gpu_verify_bridge.rs index d6087c01..973b22f9 100644 --- a/crates/cuda-driver/src/original_gpu_verify_bridge.rs +++ b/crates/cuda-driver/src/original_gpu_verify_bridge.rs @@ -35,14 +35,24 @@ impl<'ctx, R: OriginalVerifyGraphResources<'ctx> + OriginalNativeHeadGraphResour } Ok(()) } + /// The finite check of the whole head output. With `LELEKA_SM120_ACCEPT_ON_DEVICE` the graph recorded the scan + /// and stored its verdict in a mapped word: only that word is read here. Otherwise the literal scan runs after + /// the drain. Either way it raises the same error, before the window is completed and before any commit. fn validate_verifier_logits(&self, stream: &mut OriginalGpuStream<'ctx>) -> Result<()> { let r = self.resources.as_ref().ok_or(Error::ContextPoisoned)?; - let rows = r.native_head_rows()?.completed_logits()?; - let geometry = r.verifier_journal().geometry(); - if rows.len() != r.native_head_rows()?.rows() * geometry.vocabulary * 4 { - return Err(Error::InvalidQwenShape); - } - r.verifier_journal().validate_completed_logits(stream, rows, rows.len() / (geometry.vocabulary * 4)) + let head = r.native_head_rows()?; + crate::original_verify::finite_verdict::post_drain_check( + head.finite_verdict_in_graph(), + || { + let rows = head.completed_logits()?; + let geometry = r.verifier_journal().geometry(); + if rows.len() != head.rows() * geometry.vocabulary * 4 { + return Err(Error::InvalidQwenShape); + } + r.verifier_journal().validate_completed_logits(stream, rows, rows.len() / (geometry.vocabulary * 4)) + }, + || head.read_finite_verdict(), + ) } } @@ -76,6 +86,10 @@ impl<'ctx, R: OriginalVerifyGraphResources<'ctx> + OriginalNativeHeadGraphResour r.verifier_journal().validate_bank(bank)?; r.verifier_qsa().complete_commit(bank) } + /// No launch of this graph is outstanding (`park` waited them all): the precondition of a re-arm. + pub(crate) fn verifier_is_idle(&self) -> bool { + !self.launched + } pub(crate) fn verifier_abandon_after_drain(&mut self) -> Result<()> { let r = self.resources_after_wait()?; r.verifier_qsa().abandon_after_drain(); 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_serve_access.rs b/crates/cuda-driver/src/original_serve_access.rs index 4fa5bb79..f6e56d76 100644 --- a/crates/cuda-driver/src/original_serve_access.rs +++ b/crates/cuda-driver/src/original_serve_access.rs @@ -6,7 +6,7 @@ //! append/copy capability; both refuse while a window is armed (uncommitted). use crate::{Error, OriginalQsaMappedPrefix, OriginalVerifyQsaJournal, Result}; -impl<'ctx> OriginalVerifyQsaJournal<'_, 'ctx> { +impl<'ctx> OriginalVerifyQsaJournal<'ctx> { /// The mapped K/V prefix of one resident QSA layer (`0..12`) after a committed window. pub fn committed_mapped_prefix(&self, layer: usize) -> Result { if layer >= 12 { diff --git a/crates/cuda-driver/src/original_verify.rs b/crates/cuda-driver/src/original_verify.rs index b2bbca86..fd2fcf76 100644 --- a/crates/cuda-driver/src/original_verify.rs +++ b/crates/cuda-driver/src/original_verify.rs @@ -11,6 +11,9 @@ pub(crate) mod chain; mod diag; #[path = "original_verify_window_draft.rs"] pub(crate) mod draft; +pub(crate) mod finite_verdict; +#[path = "original_verify/original_verify_window_gdn_fused.rs"] +pub(crate) mod gdn_fused; #[path = "original_verify_window_gr.rs"] pub(crate) mod gr; #[path = "original_verify_window_kernels.rs"] @@ -42,7 +45,7 @@ pub(crate) mod window_plan; #[path = "original_verify_window_record.rs"] pub(crate) mod window_record; use crate::original_gpu_schedule::{OriginalCapture, OriginalGraphResources, resources}; -use crate::{Context, DeviceBuffer, Error, Result, combine}; +use crate::{Context, DeviceBuffer, DeviceRef, Error, Result, combine}; use abi::{Arg, Command, Module}; pub use diag::{ OriginalVerifyDiag, original_verify_diagnostics, original_verify_live_count, original_verify_release_live, @@ -138,11 +141,9 @@ struct Physical<'ctx> { /// resource aggregate; commands retain the stable ABI through final graph drain. pub struct OriginalVerifyBank<'ctx> { physical: Rc>, - last_t: usize, - last_position: usize, - last_tokens: [i32; 8], + /// The window staged last (`stage`, `stage_commit`); empty after `rearm`. + staged: StagedWindow, generation: u64, - last_keep: usize, released: bool, /// Registered expert banks a window's PCIe DMA reads (`publish_gpu_plan`), held until the copy-stream fence. pcie_sources: Vec>>, @@ -179,37 +180,37 @@ pub enum OriginalVerifyGdnStage { AlphaBeta = 1, Recurrence = 2, } -pub struct OriginalVerifyGdnWeights<'a, 'ctx> { - pub conv: &'a DeviceBuffer<'ctx>, - pub alpha: &'a DeviceBuffer<'ctx>, - pub beta: &'a DeviceBuffer<'ctx>, - pub dt: &'a DeviceBuffer<'ctx>, - pub a: &'a DeviceBuffer<'ctx>, - pub norm: &'a DeviceBuffer<'ctx>, +pub struct OriginalVerifyGdnWeights<'ctx> { + pub conv: DeviceRef<'ctx>, + pub alpha: DeviceRef<'ctx>, + pub beta: DeviceRef<'ctx>, + pub dt: DeviceRef<'ctx>, + pub a: DeviceRef<'ctx>, + pub norm: DeviceRef<'ctx>, } -pub struct OriginalVerifyGdnJournal<'a, 'ctx> { +pub struct OriginalVerifyGdnJournal<'ctx> { physical: Rc>, canonical: Rc>, - weights: [OriginalVerifyGdnWeights<'a, 'ctx>; 36], - ple: Option<&'a DeviceBuffer<'ctx>>, + weights: [OriginalVerifyGdnWeights<'ctx>; 36], + ple: Option>, commands: RefCell>, } /// Only real driver graph aggregates can implement this sealed association. /// Root's all-layer aggregate returns its retained journal; runtime cannot mint it. pub trait OriginalVerifyGraphResources<'ctx>: OriginalGraphResources { - fn verifier_qsa(&self) -> &crate::OriginalVerifyQsaJournal<'_, 'ctx>; - fn verifier_journal(&self) -> &OriginalVerifyGdnJournal<'_, 'ctx>; + fn verifier_qsa(&self) -> &crate::OriginalVerifyQsaJournal<'ctx>; + fn verifier_journal(&self) -> &OriginalVerifyGdnJournal<'ctx>; } /// The concrete all-owner resource aggregate for one captured verification /// graph. It retains the GDN state journal, the twelve QSA index images, and /// the exact native-head output rows as one affine owner. A graph cannot pair /// a journal from one context with a head or QSA checkpoint from another. -pub struct OriginalVerifyResources<'a, 'ctx> { +pub struct OriginalVerifyResources<'ctx> { context: &'ctx Context<'ctx>, - journal: OriginalVerifyGdnJournal<'a, 'ctx>, - qsa: Rc>, + journal: OriginalVerifyGdnJournal<'ctx>, + qsa: Rc>, head: crate::OriginalNativeHeadRows<'ctx>, } #[path = "original_verify_gpu_plan.rs"] @@ -226,6 +227,9 @@ pub use schedule::{ OriginalVerifier, OriginalVerifyCpuRows, OriginalVerifyCpuSink, OriginalVerifyWindowResult, OriginalVerifyWindowTokens, }; +mod original_verify_rearm; +pub use original_verify_rearm::OriginalVerifyRearm; +use original_verify_rearm::StagedWindow; #[path = "original_verify_window_ops.rs"] mod window_ops; pub use gr::{ @@ -252,6 +256,8 @@ use share_window_modules::admission; #[allow(unused_imports)] use share_window_modules::admit; #[allow(unused_imports)] +use share_window_modules::check_canonical_lengths; +#[allow(unused_imports)] use share_window_modules::check_commands; #[allow(unused_imports)] use share_window_modules::command; diff --git a/crates/cuda-driver/src/original_verify/finite_verdict.rs b/crates/cuda-driver/src/original_verify/finite_verdict.rs new file mode 100644 index 00000000..2e609472 --- /dev/null +++ b/crates/cuda-driver/src/original_verify/finite_verdict.rs @@ -0,0 +1,163 @@ +//! `LELEKA_SM120_ACCEPT_ON_DEVICE`: the finite verdict of the verify window's head logits, decided inside the graph. +//! +//! Literal order (switch off): after the window graph drains, the host launches `verify_clear_status` and +//! `verify_scan_logits` over all `T x vocab` logits, synchronises the stream, copies the 4-byte status back with +//! `cuMemcpyDtoH` and synchronises the context. Three blocking waits sit between the end of the graph and the host +//! reading the picked ids. +//! +//! Vanilla records the same check into the window's own stream after the greedy pick (`logits_nonfinite_rows`, +//! `verify.cpp:2380`) and reads the mapped flags after the window's one synchronisation. This module is that order: +//! the same two kernels of the sealed `original_verify.ptx` end the graph, then one store moves the status word into +//! the host-mapped verdict word of the head rows (a plain store, as the greedy kernel stores its ids: no atomics on +//! mapped memory). The post-drain code reads that word and launches and synchronises nothing. The status is the same +//! integer exponent scan, so the verdict and the error it raises are the literal ones; no number of the model changes. + +use super::{Arg, Command, Error, Result}; + +/// The error label of a non-finite logit, the same one the post-drain scan has always raised. +pub(crate) const NON_FINITE_LABEL: &str = "Original Verifier full logits"; + +/// What the verdict word holds before the graph stores into it: neither 0 (finite) nor 1 (non-finite). +pub(crate) const VERDICT_PENDING: i32 = 0x5a5a_5a5a; + +/// The operands of the finite scan: the head logits, their word count and the device status word the scan ORs into. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub(crate) struct ScanOperands { + pub logits: u64, + pub words: u64, + pub status: u64, +} + +/// The two scan kernels of the literal post-drain check: clear the status, then OR a bit for every non-finite logit. +pub(crate) fn scan_commands(scan: ScanOperands) -> Result> { + let ScanOperands { logits, words, status } = scan; + Ok(vec![ + Command::new("verify_clear_status", [1, 1, 1], [32, 1, 1], 0, vec![Arg::Address(status)])?, + Command::new( + "verify_scan_logits", + [words.div_ceil(256).min(65535) as u32, 1, 1], + [256, 1, 1], + 0, + vec![Arg::Address(logits), Arg::U64(words), Arg::Address(status)], + )?, + ]) +} + +/// The tail of the verify graph with the verdict in it: the scan, then the store of the status into the mapped word +/// (`verify_copy_i32_from_mapped_kernel`: `dst[i] = src[i]` for one word). +pub(crate) fn tail_commands(scan: ScanOperands, verdict: u64) -> Result> { + let mut commands = scan_commands(scan)?; + commands.push(Command::new( + "verify_copy_i32_from_mapped_kernel", + [1, 1, 1], + [32, 1, 1], + 0, + vec![Arg::Address(verdict), Arg::Address(scan.status), Arg::I32(1)], + )?); + Ok(commands) +} + +/// The verdict word after the drain: 0 every logit finite, 1 a non-finite one (the literal error), anything else means +/// the graph did not store it. +pub(crate) fn decode_verdict(word: i32) -> Result<()> { + match word { + 0 => Ok(()), + 1 => Err(Error::NonFiniteMmqOutput(NON_FINITE_LABEL)), + _ => Err(Error::InvalidDriverValue("Original Verifier finite verdict was not stored by the graph")), + } +} + +/// The post-drain finite check. With the verdict in the graph only `graph_verdict` runs (a read of mapped memory); +/// otherwise `scan` runs: the launch, the stream synchronisation, the copy back and the context synchronisation. +pub(crate) fn post_drain_check( + verdict_in_graph: bool, + scan: impl FnOnce() -> Result<()>, + graph_verdict: impl FnOnce() -> Result<()>, +) -> Result<()> { + if verdict_in_graph { graph_verdict() } else { scan() } +} + +#[cfg(test)] +mod tests { + use super::*; + use std::cell::Cell; + + const OPERANDS: ScanOperands = ScanOperands { logits: 0x1000, words: 8 * 248_320, status: 0x2000 }; + + fn names(commands: &[Command]) -> Vec<&'static str> { + commands.iter().map(|c| c.name).collect() + } + + #[test] + fn the_literal_scan_is_a_clear_then_a_scan_over_every_logit_word() { + let commands = scan_commands(OPERANDS).unwrap(); + assert_eq!(names(&commands), ["verify_clear_status", "verify_scan_logits"]); + assert_eq!(commands[0].grid, [1, 1, 1]); + assert_eq!(commands[1].grid, [7760, 1, 1]); + assert_eq!(commands[1].block, [256, 1, 1]); + let huge = scan_commands(ScanOperands { words: 1 << 26, ..OPERANDS }).unwrap(); + assert_eq!(huge[1].grid, [65535, 1, 1]); + let small = scan_commands(ScanOperands { words: 300, ..OPERANDS }).unwrap(); + assert_eq!(small[1].grid, [2, 1, 1]); + } + + #[test] + fn the_graph_tail_is_the_two_scan_kernels_and_then_the_store_to_the_mapped_word() { + let tail = tail_commands(OPERANDS, 0x3000).unwrap(); + assert_eq!(names(&tail), ["verify_clear_status", "verify_scan_logits", "verify_copy_i32_from_mapped_kernel"]); + // the scan is the literal one: the same two commands, in the same order, with the same launch shape + let literal = scan_commands(OPERANDS).unwrap(); + for (a, b) in literal.iter().zip(&tail) { + assert_eq!((a.name, a.grid, a.block, a.shared), (b.name, b.grid, b.block, b.shared)); + } + // one word, one block: the store is not an atomic and not a second scan + assert_eq!((tail[2].grid, tail[2].block), ([1, 1, 1], [32, 1, 1])); + } + + #[test] + fn the_verdict_word_reads_finite_non_finite_or_never_stored() { + assert!(decode_verdict(0).is_ok()); + assert_eq!(decode_verdict(1), Err(Error::NonFiniteMmqOutput("Original Verifier full logits"))); + for stale in [VERDICT_PENDING, 2, -1, i32::MAX] { + assert!(matches!(decode_verdict(stale), Err(Error::InvalidDriverValue(_))), "{stale}"); + } + assert!(VERDICT_PENDING != 0 && VERDICT_PENDING != 1); + } + + #[test] + fn with_the_verdict_in_the_graph_the_post_drain_code_launches_copies_and_synchronises_nothing() { + let (scan_calls, read_calls) = (Cell::new(0), Cell::new(0)); + let scan = || { + scan_calls.set(scan_calls.get() + 1); + Ok(()) + }; + let read = || { + read_calls.set(read_calls.get() + 1); + Ok(()) + }; + assert!(post_drain_check(true, scan, read).is_ok()); + assert_eq!((scan_calls.get(), read_calls.get()), (0, 1)); + } + + #[test] + fn with_the_switch_off_the_literal_scan_runs_and_the_verdict_word_is_not_read() { + let (scan_calls, read_calls) = (Cell::new(0), Cell::new(0)); + let scan = || { + scan_calls.set(scan_calls.get() + 1); + Ok(()) + }; + let read = || { + read_calls.set(read_calls.get() + 1); + Ok(()) + }; + assert!(post_drain_check(false, scan, read).is_ok()); + assert_eq!((scan_calls.get(), read_calls.get()), (1, 0)); + } + + #[test] + fn a_non_finite_verdict_is_the_same_error_on_both_paths() { + let literal = Err(Error::NonFiniteMmqOutput(NON_FINITE_LABEL)); + assert_eq!(post_drain_check(false, || literal.clone(), || Ok(())), literal); + assert_eq!(post_drain_check(true, || Ok(()), || decode_verdict(1)), literal); + } +} diff --git a/crates/cuda-driver/src/original_verify/original_verify_gdn_journal.rs b/crates/cuda-driver/src/original_verify/original_verify_gdn_journal.rs index 6ac34daa..0c290f07 100644 --- a/crates/cuda-driver/src/original_verify/original_verify_gdn_journal.rs +++ b/crates/cuda-driver/src/original_verify/original_verify_gdn_journal.rs @@ -6,6 +6,7 @@ use super::*; mod original_verify_window; +mod verify_gdn_fused_step; mod verify_gdn_journal_ladder_logits_scan; mod verify_gdn_journal_stage_and_commit; mod verify_gdn_journal_window_launches; diff --git a/crates/cuda-driver/src/original_verify/original_verify_gdn_journal/verify_gdn_fused_step.rs b/crates/cuda-driver/src/original_verify/original_verify_gdn_journal/verify_gdn_fused_step.rs new file mode 100644 index 00000000..e4edcde5 --- /dev/null +++ b/crates/cuda-driver/src/original_verify/original_verify_gdn_journal/verify_gdn_fused_step.rs @@ -0,0 +1,86 @@ +//! claude/verify-gdn-fused-kernels: the journal side of the fused GDN launch and of the unrolled a/b kernel +//! (`original_verify_window_gdn_fused.rs`, `sm120_gdn_fused.cu`). The operand spans are the ones +//! `capture_layer_stage` binds for the three Original kernels. + +use super::super::gdn_fused::{AbUnrolledStep, FusedGdnBuffers, FusedGdnStep, GateSource, GdnGateOperands, RowSpan}; +use super::verify_gdn_journal_stage_and_commit::StageOperands; +#[allow(unused_imports)] +use super::*; + +impl<'ctx> OriginalVerifyGdnJournal<'ctx> { + /// One launch for the conv, the gates (computed inside unless `gates` says they are joined) and the recurrence of + /// layer `layer` over `rows`. Writes `h`, `gate`, `beta` and `y` of those rows exactly as the three kernels do. + pub(crate) fn capture_fused_recurrence( + &self, + capture: &mut OriginalCapture<'_, 'ctx>, + layer: usize, + rows: std::ops::Range, + gates: GateSource, + ) -> Result<()> { + self.validate_context(self.physical.context)?; + let op = self.stage_operands(layer, rows.start, rows.end)?; + let gate_operands = match gates { + GateSource::InKernel => self.gate_operands(&op)?, + GateSource::Joined => GdnGateOperands::JOINED, + }; + let step = FusedGdnStep { + buffers: self.fused_buffers(&op)?, + gates: gate_operands, + rows: RowSpan { begin: op.begin, end: op.end }, + eps: EPS, + }; + self.submit_launches(capture, vec![step.launch()?]) + } + + /// The alpha/beta gates of layer `layer` over `rows` by the unrolled kernel of `LELEKA_SM120_GDN_AB_UNROLL`. + pub(crate) fn capture_ab_unrolled( + &self, + capture: &mut OriginalCapture<'_, 'ctx>, + layer: usize, + rows: std::ops::Range, + ) -> Result<()> { + self.validate_context(self.physical.context)?; + let op = self.stage_operands(layer, rows.start, rows.end)?; + let first_row = (op.begin * 48 * 4) as u64; + let step = AbUnrolledStep { + gates: self.gate_operands(&op)?, + gate: op.gate + first_row, + beta: op.beta + first_row, + rows: op.end - op.begin, + }; + self.submit_launches(capture, vec![step.launch()?]) + } + + /// The buffers the three Original kernels share, by their arena spans and weights. + fn fused_buffers(&self, op: &StageOperands) -> Result { + let (g, c, w) = (self.physical.layout.geometry, self.physical.context, &self.weights[op.layer]); + Ok(FusedGdnBuffers { + state: self.canonical.span(op.layer, false)?, + hist: self.canonical.span(op.layer, true)?, + qkv: op.qkv, + conv_w: admit(c, &w.conv, 10240 * 4 * 4)?, + h: op.h, + gate: op.gate, + beta: op.beta, + z: self.physical.span("z", 0, g.max_t * 6144 * 4)?, + gamma: admit(c, &w.norm, 128 * 4)?, + y: self.physical.span("y", 0, g.max_t * 6144 * 4)?, + }) + } + + /// The a/b projection operands: the mixed rows of the stage and the layer's alpha/beta weights. + fn gate_operands(&self, op: &StageOperands) -> Result { + let (g, c, w) = (self.physical.layout.geometry, self.physical.context, &self.weights[op.layer]); + let n = op.end - op.begin; + if g.n != 2560 || g.value_heads != 48 { + return Err(Error::InvalidQwenShape); + } + Ok(GdnGateOperands { + x: self.physical.span("mixed", op.begin * g.n * 4, n * g.n * 4)?, + alpha_w: admit(c, &w.alpha, 48 * 2560 * 2)?, + beta_w: admit(c, &w.beta, 48 * 2560 * 2)?, + dt: admit(c, &w.dt, 48 * 4)?, + a: admit(c, &w.a, 48 * 4)?, + }) + } +} diff --git a/crates/cuda-driver/src/original_verify/original_verify_gdn_journal/verify_gdn_journal_ladder_logits_scan.rs b/crates/cuda-driver/src/original_verify/original_verify_gdn_journal/verify_gdn_journal_ladder_logits_scan.rs index 1f96a711..984fd082 100644 --- a/crates/cuda-driver/src/original_verify/original_verify_gdn_journal/verify_gdn_journal_ladder_logits_scan.rs +++ b/crates/cuda-driver/src/original_verify/original_verify_gdn_journal/verify_gdn_journal_ladder_logits_scan.rs @@ -5,7 +5,7 @@ #[allow(unused_imports)] use super::*; -impl<'ctx> OriginalVerifyGdnJournal<'_, 'ctx> { +impl<'ctx> OriginalVerifyGdnJournal<'ctx> { /// Retain the actual PLE history after each chronological row, before its /// subsequent overwrite. Only the actual producer's capture calls this. /// Bring-up diagnostic (LELEKA_TRACE_LADDER): copy rows `[begin,end)` of the residual R into frame `frame` of the @@ -45,7 +45,7 @@ impl<'ctx> OriginalVerifyGdnJournal<'_, 'ctx> { if row >= g.max_t { return Err(Error::InvalidQwenShape); } - let history = self.ple.ok_or(Error::InvalidQwenShape)?; + let history = self.ple.as_ref().ok_or(Error::InvalidQwenShape)?; let words = 9 * 10240; let src = admit(self.physical.context, history, words * 4)?; self.submit( @@ -84,6 +84,15 @@ impl<'ctx> OriginalVerifyGdnJournal<'_, 'ctx> { logits: &DeviceBuffer<'ctx>, rows: usize, ) -> Result<(Vec, crate::ffi::BufferHandle)> { + let (operands, status) = self.logits_scan_operands(logits, rows)?; + Ok((finite_verdict::scan_commands(operands)?, status)) + } + /// The admitted logits, their word count and the status word (retired `hit_count` scratch) of the finite scan. + fn logits_scan_operands( + &self, + logits: &DeviceBuffer<'ctx>, + rows: usize, + ) -> Result<(finite_verdict::ScanOperands, crate::ffi::BufferHandle)> { let g = self.physical.layout.geometry; if !(1..=g.max_t).contains(&rows) { return Err(Error::InvalidQwenShape); @@ -92,16 +101,21 @@ impl<'ctx> OriginalVerifyGdnJournal<'_, 'ctx> { let src = admit(self.physical.context, logits, words.checked_mul(4).ok_or(Error::InvalidSize)?)?; self.check_logits_unaliased(logits)?; let status = self.span("hit_count", 0, 4)?; - let commands = vec![ - command("verify_clear_status", [1, 1, 1], [32, 1, 1], vec![Arg::Address(status.qwen_address())])?, - command( - "verify_scan_logits", - [words.div_ceil(256).min(65535) as u32, 1, 1], - [256, 1, 1], - vec![Arg::Address(src), Arg::U64(words as u64), Arg::Address(status.qwen_address())], - )?, - ]; - Ok((commands, status)) + let operands = finite_verdict::ScanOperands { logits: src, words: words as u64, status: status.qwen_address() }; + Ok((operands, status)) + } + /// `LELEKA_SM120_ACCEPT_ON_DEVICE`: record the same scan as the last nodes of the window graph, followed by the + /// store of its status into the host-mapped verdict word `verdict` (a device address of the head rows' mapped + /// block). The graph then carries the verdict; `validate_completed_logits` is not called for it. + pub(crate) fn capture_finite_verdict( + &self, + capture: &mut OriginalCapture<'_, 'ctx>, + logits: &DeviceBuffer<'ctx>, + (rows, verdict): (usize, u64), + ) -> Result<()> { + self.validate_context(self.physical.context)?; + let (operands, _status) = self.logits_scan_operands(logits, rows)?; + self.submit(capture, finite_verdict::tail_commands(operands, verdict)?) } /// The head output does not overlap the verifier arena. fn check_logits_unaliased(&self, logits: &DeviceBuffer<'ctx>) -> Result<()> { @@ -158,7 +172,7 @@ impl<'ctx> OriginalVerifyGdnJournal<'_, 'ctx> { /// Actual original PLE history image; selected accepted row, never final-image /// metadata relabel. Borrowed destination must survive the graph aggregate. pub fn capture_ple_commit(&self, capture: &mut OriginalCapture<'_, 'ctx>) -> Result<()> { - let history = self.ple.ok_or(Error::InvalidQwenShape)?; + let history = self.ple.as_ref().ok_or(Error::InvalidQwenShape)?; let bytes = 9 * 10240 * 4; let dst = admit(self.physical.context, history, bytes)?; let arena = self.physical.arena.as_ref().ok_or(Error::ContextPoisoned)?; @@ -192,11 +206,11 @@ impl<'ctx> OriginalVerifyGdnJournal<'_, 'ctx> { handle(b)?.checked_subspan(b.len(), s.offset + offset, bytes) } } -impl<'a, 'ctx> OriginalVerifyResources<'a, 'ctx> { +impl<'ctx> OriginalVerifyResources<'ctx> { pub fn new( context: &'ctx Context<'ctx>, - journal: OriginalVerifyGdnJournal<'a, 'ctx>, - qsa: Rc>, + journal: OriginalVerifyGdnJournal<'ctx>, + qsa: Rc>, head: crate::OriginalNativeHeadRows<'ctx>, ) -> Result { journal.validate_context(context)?; @@ -205,8 +219,8 @@ impl<'a, 'ctx> OriginalVerifyResources<'a, 'ctx> { Ok(Self { context, journal, qsa, head }) } } -impl resources::Sealed for OriginalVerifyResources<'_, '_> {} -impl OriginalGraphResources for OriginalVerifyResources<'_, '_> { +impl resources::Sealed for OriginalVerifyResources<'_> {} +impl OriginalGraphResources for OriginalVerifyResources<'_> { fn validate_context(&self, context: &Context<'_>) -> Result<()> { if !std::ptr::eq(self.context, context) { return Err(Error::ContextMismatch); @@ -216,15 +230,15 @@ impl OriginalGraphResources for OriginalVerifyResources<'_, '_> { self.head.validate_context(context) } } -impl<'ctx> OriginalVerifyGraphResources<'ctx> for OriginalVerifyResources<'_, 'ctx> { - fn verifier_qsa(&self) -> &crate::OriginalVerifyQsaJournal<'_, 'ctx> { +impl<'ctx> OriginalVerifyGraphResources<'ctx> for OriginalVerifyResources<'ctx> { + fn verifier_qsa(&self) -> &crate::OriginalVerifyQsaJournal<'ctx> { self.qsa.as_ref() } - fn verifier_journal(&self) -> &OriginalVerifyGdnJournal<'_, 'ctx> { + fn verifier_journal(&self) -> &OriginalVerifyGdnJournal<'ctx> { &self.journal } } -impl<'ctx> crate::OriginalNativeHeadGraphResources<'ctx> for OriginalVerifyResources<'_, 'ctx> { +impl<'ctx> crate::OriginalNativeHeadGraphResources<'ctx> for OriginalVerifyResources<'ctx> { fn native_head_rows(&self) -> Result<&crate::OriginalNativeHeadRows<'ctx>> { Ok(&self.head) } @@ -233,12 +247,12 @@ impl<'ctx> crate::OriginalNativeHeadGraphResources<'ctx> for OriginalVerifyResou } } -impl OriginalVerifyGdnJournal<'_, '_> { +impl OriginalVerifyGdnJournal<'_> { pub(crate) fn has_ple(&self) -> bool { self.ple.is_some() } pub(crate) fn ple_history_address(&self) -> Result> { - self.ple.map(|b| Ok(handle(b)?.qwen_address())).transpose() + self.ple.as_ref().map(|b| Ok(handle(b)?.qwen_address())).transpose() } pub(crate) fn canonical_identity(&self) -> usize { Rc::as_ptr(&self.canonical) as usize diff --git a/crates/cuda-driver/src/original_verify/original_verify_gdn_journal/verify_gdn_journal_stage_and_commit.rs b/crates/cuda-driver/src/original_verify/original_verify_gdn_journal/verify_gdn_journal_stage_and_commit.rs index 3214321b..5424fc9b 100644 --- a/crates/cuda-driver/src/original_verify/original_verify_gdn_journal/verify_gdn_journal_stage_and_commit.rs +++ b/crates/cuda-driver/src/original_verify/original_verify_gdn_journal/verify_gdn_journal_stage_and_commit.rs @@ -3,7 +3,7 @@ #[allow(unused_imports)] use super::*; -impl<'ctx> OriginalVerifyGdnJournal<'_, 'ctx> { +impl<'ctx> OriginalVerifyGdnJournal<'ctx> { /// Exact batch convolution, BF16 MMVF alpha/beta, and recurrence. Canonical /// state/history are READ ONLY; retained qkv/h/gate/beta banks span all36 layers. pub fn capture_layer_stage( @@ -22,7 +22,7 @@ impl<'ctx> OriginalVerifyGdnJournal<'_, 'ctx> { self.submit(capture, single_command(commands.swap_remove(stage as usize))?) } /// The range check and the arena spans one layer stage works on. - fn stage_operands(&self, layer: usize, begin: usize, end: usize) -> Result { + pub(super) fn stage_operands(&self, layer: usize, begin: usize, end: usize) -> Result { let g = self.physical.layout.geometry; if layer >= 36 || begin >= end || end > g.max_t { return Err(Error::InvalidQwenShape); @@ -50,7 +50,7 @@ impl<'ctx> OriginalVerifyGdnJournal<'_, 'ctx> { vec![ Arg::Address(self.canonical.span(op.layer, true)?), Arg::Address(op.qkv), - Arg::Address(admit(self.physical.context, w.conv, 10240 * 4 * 4)?), + Arg::Address(admit(self.physical.context, &w.conv, 10240 * 4 * 4)?), Arg::Address(op.h), Arg::I32(10240), Arg::I32(32), @@ -68,10 +68,10 @@ impl<'ctx> OriginalVerifyGdnJournal<'_, 'ctx> { [256, 1, 1], vec![ Arg::Address(self.physical.span("mixed", op.begin * g.n * 4, n * g.n * 4)?), - Arg::Address(admit(c, w.alpha, 48 * 2560 * 2)?), - Arg::Address(admit(c, w.beta, 48 * 2560 * 2)?), - Arg::Address(admit(c, w.dt, 48 * 4)?), - Arg::Address(admit(c, w.a, 48 * 4)?), + Arg::Address(admit(c, &w.alpha, 48 * 2560 * 2)?), + Arg::Address(admit(c, &w.beta, 48 * 2560 * 2)?), + Arg::Address(admit(c, &w.dt, 48 * 4)?), + Arg::Address(admit(c, &w.a, 48 * 4)?), Arg::Address(op.gate + (op.begin * 48 * 4) as u64), Arg::Address(op.beta + (op.begin * 48 * 4) as u64), Arg::I32(2560), @@ -93,7 +93,7 @@ impl<'ctx> OriginalVerifyGdnJournal<'_, 'ctx> { Arg::Address(op.gate), Arg::Address(op.beta), Arg::Address(self.physical.span("z", 0, g.max_t * 6144 * 4)?), - Arg::Address(admit(self.physical.context, w.norm, 128 * 4)?), + Arg::Address(admit(self.physical.context, &w.norm, 128 * 4)?), Arg::F32(EPS), Arg::Address(self.physical.span("y", 0, g.max_t * 6144 * 4)?), Arg::I32(16), @@ -115,10 +115,10 @@ impl<'ctx> OriginalVerifyGdnJournal<'_, 'ctx> { kernels::LaunchExtent::new([96, 1, 1], [32, 1, 1], 0), vec![ kernels::A::P(x), - kernels::A::P(admit(c, w.alpha, 48 * 2560 * 2)?), - kernels::A::P(admit(c, w.beta, 48 * 2560 * 2)?), - kernels::A::P(admit(c, w.dt, 48 * 4)?), - kernels::A::P(admit(c, w.a, 48 * 4)?), + kernels::A::P(admit(c, &w.alpha, 48 * 2560 * 2)?), + kernels::A::P(admit(c, &w.beta, 48 * 2560 * 2)?), + kernels::A::P(admit(c, &w.dt, 48 * 4)?), + kernels::A::P(admit(c, &w.a, 48 * 4)?), kernels::A::P(op.gate + (op.begin * 48 * 4) as u64), kernels::A::P(op.beta + (op.begin * 48 * 4) as u64), kernels::A::I32(2560), @@ -187,7 +187,7 @@ impl<'ctx> OriginalVerifyGdnJournal<'_, 'ctx> { Arg::Address(op.gate), Arg::Address(op.beta), Arg::Address(self.physical.span("z", 0, g.max_t * 6144 * 4)?), - Arg::Address(admit(self.physical.context, self.weights[op.layer].norm, 128 * 4)?), + Arg::Address(admit(self.physical.context, &self.weights[op.layer].norm, 128 * 4)?), Arg::F32(EPS), Arg::Address(self.physical.span("y_dummy", 0, g.max_t * 6144 * 4)?), Arg::I32(16), @@ -260,14 +260,14 @@ impl FusedSpans { } /// The arena spans and range of one GDN layer stage. -struct StageOperands { - layer: usize, - begin: usize, - end: usize, - qkv: u64, - h: u64, - gate: u64, - beta: u64, +pub(super) struct StageOperands { + pub(super) layer: usize, + pub(super) begin: usize, + pub(super) end: usize, + pub(super) qkv: u64, + pub(super) h: u64, + pub(super) gate: u64, + pub(super) beta: u64, } /// The base spans of the fused commit: layer `i` of every operand is `base + i * stride`. @@ -284,7 +284,7 @@ struct FusedSpans { small: usize, } -impl<'ctx> OriginalVerifyGdnJournal<'_, 'ctx> { +impl<'ctx> OriginalVerifyGdnJournal<'ctx> { /// Whether layer `i`'s per-layer spans are affine in the layer, as the fused commit assumes. fn layer_is_affine(&self, i: usize, sp: &FusedSpans) -> Result { Ok(self.canonical_affine(i, sp)? && self.window_affine(i, sp)?) diff --git a/crates/cuda-driver/src/original_verify/original_verify_gdn_journal/verify_gdn_journal_window_launches.rs b/crates/cuda-driver/src/original_verify/original_verify_gdn_journal/verify_gdn_journal_window_launches.rs index 10ca8f63..78a4cd24 100644 --- a/crates/cuda-driver/src/original_verify/original_verify_gdn_journal/verify_gdn_journal_window_launches.rs +++ b/crates/cuda-driver/src/original_verify/original_verify_gdn_journal/verify_gdn_journal_window_launches.rs @@ -3,11 +3,11 @@ #[allow(unused_imports)] use super::*; -impl<'ctx> OriginalVerifyGdnJournal<'_, 'ctx> { +impl<'ctx> OriginalVerifyGdnJournal<'ctx> { /// The device history image the window rows advance (and the commit graph sets from `hist_snap`): the one buffer /// all aggregates share. pub(crate) fn ple_buffer(&self) -> Option<&DeviceBuffer<'ctx>> { - self.ple + self.ple.as_deref() } pub(crate) fn submit(&self, capture: &mut OriginalCapture<'_, 'ctx>, commands: Vec) -> Result<()> { capture.validate_context(self.physical.context)?; diff --git a/crates/cuda-driver/src/original_verify/original_verify_rearm.rs b/crates/cuda-driver/src/original_verify/original_verify_rearm.rs new file mode 100644 index 00000000..ad4d1852 --- /dev/null +++ b/crates/cuda-driver/src/original_verify/original_verify_rearm.rs @@ -0,0 +1,155 @@ +//! Re-arming a parked Original verifier for the next request (ledger row Q7, `docs/experiments/decode-graph-reuse.md`, +//! `docs/experiments/verify-decode-graph-reuse-handles.md`). +//! +//! A recorded verifier (arena, mapped staging, streams, event, the nine graphs) is bound to buffers whose ADDRESSES +//! the graphs captured, and to nothing else about a request: context length, positions and tokens are data staged +//! before every `run`. Keeping the recording across requests therefore needs the request-bound DATA put back to what +//! a fresh `OriginalVerifier::new` + `record_all` leaves, which is what this module defines: +//! +//! * [`OriginalVerifyRearm`], the seed of the next request: the session's recurrent priors (the canonical GDN image is +//! overwritten in place, same device address) and its PLE history; +//! * [`StagedWindow`], the host's memory of the window staged last, and [`ResetPlan`], the device and mapped memory a +//! fresh bank starts zeroed; both pure, so the tests run without a device; +//! * `OriginalVerifyBank::rearm`, which applies them and advances the bank generation so that every row and window +//! handle of the previous request is refused. +//! +//! The verifier side (`park`, `rearm`, its preconditions and counters) is +//! `original_verify_schedule/verifier_park_rearm.rs`. +use super::*; + +/// The PLE history image: nine rows of `10240` f32 (the commit graph's `hist_snap` row). +const PLE_HISTORY_WORDS: usize = 9 * 10240; + +/// The seed of the next request: the session's recurrent priors in the canonical image's layout, and its PLE history. +#[derive(Clone, Copy)] +pub struct OriginalVerifyRearm<'s> { + /// The 36 recurrent states, `128 * 48 * 128` f32 each. + pub gdn_states: [&'s [f32]; 36], + /// The 36 convolution histories, `10240 * 3` f32 each. + pub gdn_histories: [&'s [f32]; 36], + /// The PLE history image, `9 * 10240` f32. + pub ple_history: &'s [f32], +} + +impl OriginalVerifyRearm<'_> { + /// Every slice has the exact length the images hold; nothing is touched before this passes. + pub(crate) fn check_shapes(&self) -> Result<()> { + if self.ple_history.len() != PLE_HISTORY_WORDS { + return Err(Error::InvalidQwenShape); + } + check_canonical_lengths(&self.gdn_states, &self.gdn_histories) + } + /// The PLE history image as the little-endian bytes the device holds. + pub(crate) fn ple_history_bytes(&self) -> Result> { + let mut bytes = Vec::new(); + bytes.try_reserve_exact(PLE_HISTORY_WORDS * 4).map_err(|_| Error::HostAllocation)?; + for value in self.ple_history { + bytes.extend_from_slice(&value.to_le_bytes()); + } + Ok(bytes) + } +} + +/// What the bank remembers about the window staged last: its width, first position, tokens and kept prefix. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub(super) struct StagedWindow { + pub t: usize, + pub position: usize, + pub tokens: [i32; 8], + pub keep: usize, +} + +impl StagedWindow { + /// No window staged: the state of a fresh bank and of a re-armed one. + pub(super) const EMPTY: Self = Self { t: 0, position: 0, tokens: [0; 8], keep: 0 }; +} + +/// The host-side bookkeeping of a bank that a re-arm resets, as a value: the staged window, the generation that +/// handles of earlier windows are checked against, and whether the GPU waits were released. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub(super) struct Book { + pub staged: StagedWindow, + pub generation: u64, + pub released: bool, +} + +impl Book { + /// The book of the next request: nothing staged, not released, and the generation one further, so that every + /// row and window handle minted for the previous request is refused. + pub(super) fn rearmed(self) -> Result { + let generation = self.generation.checked_add(1).ok_or(Error::InvalidSize)?; + Ok(Self { staged: StagedWindow::EMPTY, generation, released: false }) + } +} + +/// The memory a fresh bank starts zeroed, and so a re-armed one: every mapped staging allocation (the token, step and +/// position words, the commit record, the PLE rows, the doorbell and the three flag words, the CPU rows and output, +/// the published GPU plan), the arena (all journals, tail and history snapshots, plan copy, expert staging, the +/// logits) and, with `STRATA_VERIFY_PROFILE`, the stamp words. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub(super) struct ResetPlan { + pub mapped: usize, + pub arena_bytes: usize, + pub profile_bytes: Option, +} + +impl ResetPlan { + pub(super) fn of(layout: &OriginalVerifyLayout, profile_bytes: Option) -> Self { + Self { mapped: layout.mapped_bytes.len(), arena_bytes: layout.bytes, profile_bytes } + } +} + +impl Physical<'_> { + /// Put the mapped staging, the arena and the profile stamps back to zero, exactly as `initialize` left them. The + /// device is idle (the caller parked both streams); a failed transfer poisons the context as everywhere here. + pub(super) fn reset_to_recorded(&self) -> Result<()> { + self.validate(self.context)?; + let plan = ResetPlan::of(&self.layout, self.prof.as_ref().map(DeviceBuffer::len)); + for cell in self.mapped.iter().take(plan.mapped) { + let mut slot = cell.try_borrow_mut().map_err(|_| Error::InvalidQwenShape)?; + slot.as_mut().ok_or(Error::ContextPoisoned)?.initialize_zero()?; + } + std::sync::atomic::fence(std::sync::atomic::Ordering::SeqCst); + let guard = self.context.enter()?; + let zeroed = self.zero_device(plan); + let sync = self.context.driver.api.synchronize(); + let pop = guard.finish(); + if zeroed.as_ref().err().is_some_and(transport) || sync.is_err() || pop.is_err() { + self.failed.set(true); + poison(self.context) + } + combine(combine(zeroed, sync), pop) + } + /// The arena and, when present, the stamp words, zeroed inside an entered context. + fn zero_device(&self, plan: ResetPlan) -> Result<()> { + let arena = self.arena.as_ref().ok_or(Error::ContextPoisoned)?; + debug_assert_eq!(arena.len(), plan.arena_bytes); + self.context.driver.api.zero(handle(arena)?.qwen_address(), plan.arena_bytes)?; + if let (Some(prof), Some(bytes)) = (self.prof.as_ref(), plan.profile_bytes) { + self.context.driver.api.zero(handle(prof)?.qwen_address(), bytes)?; + } + Ok(()) + } +} + +impl OriginalVerifyBank<'_> { + /// Back to what `new` leaves, for the next request over the same recording. The generation advances FIRST (as + /// `stage` does) so every `OriginalVerifyRow` / `OriginalVerifyWindow` of the previous request is refused before + /// any state changes; then the host memory of the staged window, `released`, the held PCIe sources and the device + /// and mapped memory of [`ResetPlan`] are reset. `pcie_mode` and `pcie_roles` are part of the recording and stay. + /// The device must be idle. Returns the new generation. + pub(crate) fn rearm(&mut self) -> Result { + self.validate_context(self.physical.context)?; + let next = Book { staged: self.staged, generation: self.generation, released: self.released }.rearmed()?; + self.generation = next.generation; + self.physical.generation.set(next.generation); + self.staged = next.staged; + self.released = next.released; + self.release_pcie_sources(); + self.physical.reset_to_recorded()?; + Ok(next.generation) + } +} + +#[cfg(test)] +mod tests; diff --git a/crates/cuda-driver/src/original_verify/original_verify_rearm/tests.rs b/crates/cuda-driver/src/original_verify/original_verify_rearm/tests.rs new file mode 100644 index 00000000..6713fed1 --- /dev/null +++ b/crates/cuda-driver/src/original_verify/original_verify_rearm/tests.rs @@ -0,0 +1,90 @@ +//! Unit tests of the pure half of the re-arm (no device): the seed shapes, the bookkeeping a bank resets and the +//! memory a re-armed bank zeroes. The device half is exercised by the identity job (see +//! `docs/experiments/verify-decode-graph-reuse-handles.md`). +use super::*; + +const STATE_WORDS: usize = 128 * 48 * 128; +const HISTORY_WORDS: usize = 10240 * 3; + +fn seed<'s>(state: &'s [f32], history: &'s [f32], ple: &'s [f32]) -> OriginalVerifyRearm<'s> { + OriginalVerifyRearm { gdn_states: [state; 36], gdn_histories: [history; 36], ple_history: ple } +} + +#[test] +fn a_seed_of_the_exact_shapes_passes_and_every_other_shape_is_refused() { + let (state, history, ple) = + (vec![0.5f32; STATE_WORDS], vec![0.25f32; HISTORY_WORDS], vec![0.0f32; PLE_HISTORY_WORDS]); + assert_eq!(seed(&state, &history, &ple).check_shapes(), Ok(())); + assert_eq!(seed(&state, &history, &ple[1..]).check_shapes(), Err(Error::InvalidQwenShape)); + assert_eq!(seed(&state[1..], &history, &ple).check_shapes(), Err(Error::InvalidQwenShape)); + assert_eq!(seed(&state, &history[1..], &ple).check_shapes(), Err(Error::InvalidQwenShape)); + let mut one_short = seed(&state, &history, &ple); + one_short.gdn_histories[35] = &history[..HISTORY_WORDS - 1]; + assert_eq!(one_short.check_shapes(), Err(Error::InvalidQwenShape)); +} + +#[test] +fn the_ple_history_goes_to_the_device_as_little_endian_f32() { + let (state, history) = (vec![0.0f32; STATE_WORDS], vec![0.0f32; HISTORY_WORDS]); + let mut ple = vec![0.0f32; PLE_HISTORY_WORDS]; + ple[0] = 1.0; + ple[PLE_HISTORY_WORDS - 1] = -2.5; + let bytes = seed(&state, &history, &ple).ple_history_bytes().unwrap(); + assert_eq!(bytes.len(), PLE_HISTORY_WORDS * 4); + assert_eq!(bytes[..4], 1.0f32.to_le_bytes()); + assert_eq!(bytes[bytes.len() - 4..], (-2.5f32).to_le_bytes()); +} + +fn staged_once() -> Book { + Book { + staged: StagedWindow { t: 5, position: 1234, tokens: [9, 8, 7, 6, 5, 0, 0, 0], keep: 3 }, + generation: 41, + released: true, + } +} + +#[test] +fn a_rearmed_book_has_nothing_staged_is_not_released_and_is_one_generation_on() { + let book = staged_once().rearmed().unwrap(); + assert_eq!(book.staged, StagedWindow::EMPTY); + assert_eq!(book.staged, StagedWindow { t: 0, position: 0, tokens: [0; 8], keep: 0 }); + assert!(!book.released); + // a handle minted at generation 41 (a row or window of the previous request) no longer matches + assert_eq!(book.generation, 42); +} + +#[test] +fn every_rearm_advances_the_generation_by_exactly_one_and_the_counter_never_wraps() { + let mut book = staged_once(); + for expected in 42..46 { + book = book.rearmed().unwrap(); + assert_eq!(book.generation, expected); + } + let last = Book { generation: u64::MAX, ..staged_once() }; + assert_eq!(last.rearmed(), Err(Error::InvalidSize)); +} + +#[test] +fn a_re_armed_bank_zeroes_every_mapped_allocation_the_arena_and_the_profile_stamps() { + let layout = OriginalVerifyLayout::new(kernels::test_geometry()).unwrap(); + let plan = ResetPlan::of(&layout, Some(profile_stamp_words(48) * 8)); + // all fifteen mapped allocations: the token/step/position words (0..=2), the commit record (3), the PLE rows (4), + // the sampled ids (5), the CPU activation, id and weight rows (6..=8), the doorbell and the three flag words + // (9..=12), the CPU output (13) and the published GPU plan (14) + assert_eq!(plan.mapped, 15); + assert!(layout.mapped_bytes.iter().all(|&bytes| bytes > 0)); + assert!(layout.mapped_bytes[9..=12].iter().all(|&bytes| bytes == 64)); + assert_eq!(plan.arena_bytes, layout.bytes); + assert_eq!(plan.profile_bytes, Some(profile_stamp_words(48) * 8)); + assert_eq!(ResetPlan::of(&layout, None).profile_bytes, None); +} + +#[test] +fn the_arena_plan_covers_the_spans_the_graphs_read_back_the_first_window() { + let layout = OriginalVerifyLayout::new(kernels::test_geometry()).unwrap(); + // every span, including the snapshots the commit graph restores and the plan copy, lies inside the zeroed bytes + for name in ["tail_snap", "hist_snap", "plan", "staging", "head_logits", "commit", "tok"] { + let span = layout.span(name).unwrap(); + assert!(span.offset + span.bytes <= layout.bytes, "{name} is inside the arena"); + } +} diff --git a/crates/cuda-driver/src/original_verify/original_verify_window_gdn_fused.rs b/crates/cuda-driver/src/original_verify/original_verify_window_gdn_fused.rs new file mode 100644 index 00000000..bc531baa --- /dev/null +++ b/crates/cuda-driver/src/original_verify/original_verify_window_gdn_fused.rs @@ -0,0 +1,273 @@ +//! claude/verify-gdn-fused-kernels: the GDN layers of the verify window as fewer launches (`sm120_gdn_fused.cu`, +//! design note `docs/experiments/verify-gdn-fused-kernels.md`). +//! +//! Two independent opt-in switches (`original_verify_window_sm120.rs`, both off by default), one sealed sm_120-only +//! asset: +//! +//! * `LELEKA_SM120_FUSED_GDN`: a GDN layer's `verify_gdn_conv_l2_multi_kernel` + `verify_gdn_ab_multi_kernel` (or +//! `chain_gdn_ab_multi_kernel`) + `verify_gdn_step_norm_multi_kernel` are recorded as ONE launch, +//! `leleka_verify_gdn_fused_step`, at the place of the recurrence. With the side-stream GDN branch +//! (`LELEKA_SM120_SIDE_MIXER`) only the conv is fused: the gates stay on side stream 0 and are read. +//! * `LELEKA_SM120_GDN_AB_UNROLL`: upstream `STRATA_SMALL_UNR` bit 1 (`gdn_ab_body`), the a/b projection with constant +//! trip counts, as its own kernel (`leleka_gdn_ab_unrolled_t*`) wherever the a/b projection runs as a kernel of its +//! own (no `FUSED_GDN`, or the side-stream branch). +//! +//! Both compute every output word with the operations of the kernels they replace, in the same order. +use super::kernels::{A, AssetSpec, Launch, LaunchExtent}; +use super::sm120::Sm120Switches; +// `ptx` below is read from `../sm120_gdn_fused.ptx` (this file lives one directory below the sealed assets) +use crate::{Error, Result}; + +pub(crate) const E_FUSED_STEP: &str = "leleka_verify_gdn_fused_step"; +/// Unrolled a/b kernels: constant token count for T = 1..=6, the run time count for T = 7 and 8 (upstream's split). +pub(crate) const E_AB_UNROLLED: [&str; 7] = [ + "leleka_gdn_ab_unrolled_t1", + "leleka_gdn_ab_unrolled_t2", + "leleka_gdn_ab_unrolled_t3", + "leleka_gdn_ab_unrolled_t4", + "leleka_gdn_ab_unrolled_t5", + "leleka_gdn_ab_unrolled_t6", + "leleka_gdn_ab_unrolled_t8", +]; +const ENTRIES: [&str; 8] = [ + E_FUSED_STEP, + E_AB_UNROLLED[0], + E_AB_UNROLLED[1], + E_AB_UNROLLED[2], + E_AB_UNROLLED[3], + E_AB_UNROLLED[4], + E_AB_UNROLLED[5], + E_AB_UNROLLED[6], +]; + +/// `sm120_gdn_fused.cu` (nvcc 13.2.86, `--fmad=true --ftz=false`), sealed by `scripts/gpu-bringup/seal_pins.py` +/// (extra-seal-plan.json, group sm120-decode). +pub(crate) static GDN_FUSED: AssetSpec = AssetSpec { + name: "sm120_gdn_fused.ptx", + ptx: concat!(include_str!("../sm120_gdn_fused.ptx"), "\0").as_bytes(), + sha: [ + 157, 163, 62, 130, 23, 193, 228, 218, 162, 210, 111, 151, 57, 135, 73, 120, 233, 194, 6, 235, 95, 48, 249, 65, + 127, 93, 248, 181, 38, 227, 127, 23, + ], + entries: &ENTRIES, + unsealed: "Original verifier asset unsealed: sm120_gdn_fused.ptx (fused GDN layer step, unrolled GDN alpha/beta)", +}; + +/// The window's rows of the verify graph and the width of the a/b projection input. +pub(crate) const MAX_ROWS: usize = 8; +const N_EMBD: i32 = 2560; +const VALUE_HEADS: u32 = 48; + +/// What one `WindowOps` call of a GDN layer records. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub(crate) enum GdnStep { + /// Nothing: another call covers it. + Skip, + /// The Original's kernel of this stage (or the chain kernel when `LELEKA_CHAIN_AB` is on). + Original, + /// The unrolled a/b kernel of `LELEKA_SM120_GDN_AB_UNROLL`. + AbUnrolled, + /// The fused launch (conv, gates and step), with the gates computed inside or read. + Fused(GateSource), +} + +/// Where the fused launch gets gate and beta. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub(crate) enum GateSource { + /// Computed by two warps of every block and written to `gate` / `beta`. + InKernel, + /// Already in `gate` / `beta` (the side-stream branch computed them and joined before the launch). + Joined, +} + +/// The three `WindowOps` calls of a GDN layer, in graph order. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub(crate) struct GdnStages { + pub conv: GdnStep, + pub alpha_beta: GdnStep, + pub recurrence: GdnStep, +} +impl GdnStages { + /// Kernel launches the layer records on the capture stream, without the side-stream branch. + #[cfg(test)] + pub(crate) fn launches(&self) -> usize { + [self.conv, self.alpha_beta, self.recurrence].iter().filter(|s| **s != GdnStep::Skip).count() + } +} + +/// The resolved switches of one window recording. +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] +pub(crate) struct GdnFusedPolicy { + pub fused_step: bool, + pub ab_unroll: bool, +} +impl GdnFusedPolicy { + pub(crate) fn from_switches(s: &Sm120Switches) -> Self { + Self { fused_step: s.fused_gdn, ab_unroll: s.gdn_ab_unroll } + } + /// The asset the window preloads before capture (none when both switches are off). + pub(crate) fn assets(self) -> Vec<&'static AssetSpec> { + if self.fused_step || self.ab_unroll { vec![&GDN_FUSED] } else { Vec::new() } + } + /// The a/b stage as a kernel of its own (a graph without `FUSED_GDN`, and the side-stream branch). + pub(crate) fn separate_ab(self) -> GdnStep { + if self.ab_unroll { GdnStep::AbUnrolled } else { GdnStep::Original } + } + /// What the three calls of a GDN layer record; `side_gdn`: the gates run on side stream 0. + pub(crate) fn stages(self, side_gdn: bool) -> GdnStages { + if self.fused_step { + let gates = if side_gdn { GateSource::Joined } else { GateSource::InKernel }; + return GdnStages { conv: GdnStep::Skip, alpha_beta: GdnStep::Skip, recurrence: GdnStep::Fused(gates) }; + } + let alpha_beta = if side_gdn { GdnStep::Skip } else { self.separate_ab() }; + GdnStages { conv: GdnStep::Original, alpha_beta, recurrence: GdnStep::Original } + } +} + +/// Resolves the switches for the card and loads the asset before capture (module loading is not capturable). A +/// requested switch whose asset is not sealed refuses the recording, so a paired A/B never runs the default path +/// under the name of the switch. +pub(crate) fn prepare(journal: &super::OriginalVerifyGdnJournal<'_>) -> Result { + let major = journal.window_device_attribute(super::gr::ATTR_COMPUTE_CAPABILITY_MAJOR)?; + let minor = journal.window_device_attribute(super::gr::ATTR_COMPUTE_CAPABILITY_MINOR)?; + let policy = GdnFusedPolicy::from_switches(&Sm120Switches::from_env(major, minor)); + journal.ensure_window_assets(&policy.assets())?; + if policy != GdnFusedPolicy::default() { + static SAID: std::sync::Once = std::sync::Once::new(); + SAID.call_once(|| eprintln!("leleka-serve gdn kernels: {policy:?} (compute capability {major}.{minor})")); + } + Ok(policy) +} + +/// Device addresses of the buffers of one GDN layer the fused launch reads and writes. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub(crate) struct FusedGdnBuffers { + /// Canonical recurrence state of the layer (read only: the window never writes it). + pub state: u64, + /// Canonical conv history of the layer (read only). + pub hist: u64, + pub qkv: u64, + pub conv_w: u64, + /// Conv + L2 rows: written for the new tokens (q and k by the blocks of value heads 0..16, v by every block). + pub h: u64, + pub gate: u64, + pub beta: u64, + pub z: u64, + pub gamma: u64, + pub y: u64, +} + +/// The a/b projection operands: the activation row of the first new token (0: gate and beta are already computed). +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub(crate) struct GdnGateOperands { + pub x: u64, + pub alpha_w: u64, + pub beta_w: u64, + pub dt: u64, + pub a: u64, +} +impl GdnGateOperands { + pub(crate) const JOINED: Self = Self { x: 0, alpha_w: 0, beta_w: 0, dt: 0, a: 0 }; +} + +/// The rows a stage works on: the new tokens `begin..end`; the tokens before `begin` are replayed from the buffers. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub(crate) struct RowSpan { + pub begin: usize, + pub end: usize, +} + +/// One launch of `leleka_verify_gdn_fused_step`. +#[derive(Clone, Copy, Debug, PartialEq)] +pub(crate) struct FusedGdnStep { + pub buffers: FusedGdnBuffers, + pub gates: GdnGateOperands, + pub rows: RowSpan, + pub eps: f32, +} +impl FusedGdnStep { + /// The by-value kernel argument `FusedGdnArgs` of `sm120_gdn_fused.cu`, in declaration order. + pub(crate) fn words(&self) -> Vec { + let (b, g) = (&self.buffers, &self.gates); + vec![ + b.state, + b.hist, + b.qkv, + b.conv_w, + b.h, + b.gate, + b.beta, + b.z, + b.gamma, + b.y, + g.x, + g.alpha_w, + g.beta_w, + g.dt, + g.a, + u64::from(self.eps.to_bits()), + self.rows.begin as u64, + self.rows.end as u64, + ] + } + /// 48 blocks (one per value head) of 128 x 4 threads, as the Original's step kernel. + pub(crate) fn launch(&self) -> Result { + if self.rows.begin >= self.rows.end || self.rows.end > MAX_ROWS { + return Err(Error::InvalidQwenShape); + } + Launch::new( + &GDN_FUSED, + E_FUSED_STEP, + LaunchExtent::new([VALUE_HEADS, 1, 1], [128, 4, 1], 0), + vec![A::Words(self.words())], + ) + } +} + +/// One launch of the unrolled a/b projection: the Original's arguments, `rows` tokens. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub(crate) struct AbUnrolledStep { + pub gates: GdnGateOperands, + /// `gate` and `beta` of the first token of the stage. + pub gate: u64, + pub beta: u64, + pub rows: usize, +} +impl AbUnrolledStep { + /// The entry for `rows` tokens: constant count up to 6, the run time count above (upstream's `kVerifyNarrowT`). + pub(crate) fn entry(rows: usize) -> Result<&'static str> { + match rows { + 1..=6 => Ok(E_AB_UNROLLED[rows - 1]), + 7 | 8 => Ok(E_AB_UNROLLED[6]), + _ => Err(Error::InvalidQwenShape), + } + } + /// One warp a row of the 96 (alpha, then beta): 96 blocks of 32 threads, the shape of `chain_gdn_ab_multi_kernel` + /// (what `LELEKA_CHAIN=all` records), so the unrolled loop is the only difference to the shipped kernel. Upstream's + /// own shape, 48 blocks of 64 threads, runs the same kernel. + pub(crate) fn launch(&self) -> Result { + let g = &self.gates; + let args = vec![ + A::P(g.x), + A::P(g.alpha_w), + A::P(g.beta_w), + A::P(g.dt), + A::P(g.a), + A::P(self.gate), + A::P(self.beta), + A::I32(N_EMBD), + A::I32(VALUE_HEADS as i32), + A::I32(self.rows as i32), + ]; + Launch::new( + &GDN_FUSED, + Self::entry(self.rows)?, + LaunchExtent::new([2 * VALUE_HEADS, 1, 1], [32, 1, 1], 0), + args, + ) + } +} + +#[cfg(test)] +#[path = "original_verify_window_gdn_fused/tests.rs"] +mod tests; diff --git a/crates/cuda-driver/src/original_verify/original_verify_window_gdn_fused/tests.rs b/crates/cuda-driver/src/original_verify/original_verify_window_gdn_fused/tests.rs new file mode 100644 index 00000000..e53c8032 --- /dev/null +++ b/crates/cuda-driver/src/original_verify/original_verify_window_gdn_fused/tests.rs @@ -0,0 +1,311 @@ +use super::*; +use crate::original_verify::sm120::{DEFAULT_ON_FUSED_GDN, DEFAULT_ON_GDN_AB_UNROLL}; + +const FUSED_PTX: &str = include_str!("../../sm120_gdn_fused.ptx"); +const FUSED_CU: &str = include_str!("../../sm120_gdn_fused.cu"); +const ORIGINAL_PTX: &str = include_str!("../../original_verify.ptx"); +const CHAIN_PTX: &str = include_str!("../../chain_window.ptx"); + +fn env(pairs: &'static [(&'static str, &'static str)]) -> impl Fn(&str) -> Option { + move |k| pairs.iter().find(|(n, _)| *n == k).map(|(_, v)| v.to_string()) +} +fn policy(major: i32, minor: i32, pairs: &'static [(&'static str, &'static str)]) -> GdnFusedPolicy { + GdnFusedPolicy::from_switches(&Sm120Switches::resolve(major, minor, env(pairs))) +} + +#[test] +fn both_switches_are_off_by_default() { + assert!(!DEFAULT_ON_FUSED_GDN && !DEFAULT_ON_GDN_AB_UNROLL); + assert_eq!(policy(12, 0, &[]), GdnFusedPolicy::default()); + assert_eq!(policy(12, 0, &[("LELEKA_SM120_PERF", "0")]), GdnFusedPolicy::default()); + assert!(policy(12, 0, &[]).assets().is_empty()); +} + +#[test] +fn each_variable_turns_on_its_own_switch_and_nothing_else() { + let fused = policy(12, 0, &[("LELEKA_SM120_FUSED_GDN", "1")]); + assert_eq!(fused, GdnFusedPolicy { fused_step: true, ab_unroll: false }); + let unroll = policy(12, 0, &[("LELEKA_SM120_GDN_AB_UNROLL", "on")]); + assert_eq!(unroll, GdnFusedPolicy { fused_step: false, ab_unroll: true }); + let both = policy(12, 1, &[("LELEKA_SM120_FUSED_GDN", "1"), ("LELEKA_SM120_GDN_AB_UNROLL", "1")]); + assert_eq!(both, GdnFusedPolicy { fused_step: true, ab_unroll: true }); + assert!(!policy(12, 0, &[("LELEKA_SM120_FUSED_GDN", "0")]).fused_step); + for p in [fused, unroll, both] { + assert_eq!(p.assets().len(), 1); + assert!(std::ptr::eq(p.assets()[0], &GDN_FUSED)); + } +} + +#[test] +fn a_card_below_compute_capability_12_never_takes_a_switch() { + let on = &[("LELEKA_SM120_FUSED_GDN", "1"), ("LELEKA_SM120_GDN_AB_UNROLL", "1")]; + assert_eq!(policy(8, 6, on), GdnFusedPolicy::default()); + assert_eq!(policy(9, 0, on), GdnFusedPolicy::default()); +} + +#[test] +fn the_asset_is_sealed_and_exports_every_entry() { + GDN_FUSED.assert_sealed_and_fail_closed(); + assert_eq!(GDN_FUSED.entries.len(), 1 + E_AB_UNROLLED.len()); + assert!(GDN_FUSED.has_entry(E_FUSED_STEP)); +} + +#[test] +fn a_default_layer_records_the_original_three_kernels() { + let off = GdnFusedPolicy::default(); + let stages = off.stages(false); + let original = GdnStep::Original; + assert_eq!(stages, GdnStages { conv: original, alpha_beta: original, recurrence: original }); + assert_eq!(stages.launches(), 3); + // side-stream branch: the gates are another stream's launch, three kernels in all + let side = off.stages(true); + assert_eq!(side.alpha_beta, GdnStep::Skip); + assert_eq!(side.launches() + 1, 3); +} + +#[test] +fn the_fused_switch_records_one_launch_per_layer() { + let on = GdnFusedPolicy { fused_step: true, ab_unroll: false }; + let stages = on.stages(false); + assert_eq!(stages.conv, GdnStep::Skip); + assert_eq!(stages.alpha_beta, GdnStep::Skip); + assert_eq!(stages.recurrence, GdnStep::Fused(GateSource::InKernel)); + assert_eq!(stages.launches(), 1); + // 36 layers: 108 launches against 36 + assert_eq!(36 * GdnFusedPolicy::default().stages(false).launches(), 108); + assert_eq!(36 * stages.launches(), 36); +} + +#[test] +fn with_the_side_branch_only_the_conv_is_fused() { + let on = GdnFusedPolicy { fused_step: true, ab_unroll: false }; + let side = on.stages(true); + assert_eq!(side.recurrence, GdnStep::Fused(GateSource::Joined)); + assert_eq!((side.conv, side.alpha_beta), (GdnStep::Skip, GdnStep::Skip)); + // the fused launch and the gates on side stream 0: two launches against the side branch's three + assert_eq!(side.launches() + 1, 2); + assert_eq!(GdnFusedPolicy::default().stages(true).launches() + 1, 3); +} + +#[test] +fn the_unrolled_gates_replace_only_the_ab_kernel() { + let on = GdnFusedPolicy { fused_step: false, ab_unroll: true }; + let stages = on.stages(false); + assert_eq!(stages.alpha_beta, GdnStep::AbUnrolled); + assert_eq!((stages.conv, stages.recurrence), (GdnStep::Original, GdnStep::Original)); + assert_eq!(stages.launches(), 3); + // the side branch still issues the gates, as the unrolled kernel + assert_eq!(on.stages(true).alpha_beta, GdnStep::Skip); + assert_eq!(on.separate_ab(), GdnStep::AbUnrolled); + assert_eq!(GdnFusedPolicy::default().separate_ab(), GdnStep::Original); + // fused + unroll: the gates are inside the fused launch, the unrolled kernel is only for the side branch + let both = GdnFusedPolicy { fused_step: true, ab_unroll: true }; + assert_eq!(both.stages(false).launches(), 1); + assert_eq!(both.separate_ab(), GdnStep::AbUnrolled); +} + +fn step(begin: usize, end: usize, gates: GdnGateOperands) -> FusedGdnStep { + FusedGdnStep { + buffers: FusedGdnBuffers { + state: 0x100, + hist: 0x200, + qkv: 0x300, + conv_w: 0x400, + h: 0x500, + gate: 0x600, + beta: 0x700, + z: 0x800, + gamma: 0x900, + y: 0xa00, + }, + gates, + rows: RowSpan { begin, end }, + eps: 1e-6, + } +} +#[rustfmt::skip] +const KERNEL_ARGUMENT_MEMBERS: [&str; 18] = [ + "state", "hist", "qkv", "conv_w", "h", "gate", "beta", "z", "gamma", "y", + "ab_x", "ab_alpha_w", "ab_beta_w", "ab_dt", "ab_a", "eps_bits", "t_begin", "t_end", +]; +const GATES: GdnGateOperands = GdnGateOperands { x: 0xb00, alpha_w: 0xc00, beta_w: 0xd00, dt: 0xe00, a: 0xf00 }; + +#[test] +fn the_fused_launch_is_one_block_per_value_head_like_the_originals_step() { + let launch = step(0, 4, GATES).launch().unwrap(); + assert_eq!((launch.grid, launch.block, launch.shared), ([48, 1, 1], [128, 4, 1], 0)); + assert_eq!(launch.entry, E_FUSED_STEP); + assert!(std::ptr::eq(launch.asset, &GDN_FUSED)); + assert_eq!(launch.args.len(), 1); +} + +#[test] +fn the_argument_words_follow_the_struct_of_the_kernel_source() { + let words = step(2, 5, GATES).words(); + assert_eq!( + words, + vec![0x100, 0x200, 0x300, 0x400, 0x500, 0x600, 0x700, 0x800, 0x900, 0xa00, 0xb00, 0xc00, 0xd00, 0xe00, 0xf00] + .into_iter() + .chain([u64::from(1e-6f32.to_bits()), 2, 5]) + .collect::>() + ); + let (_, body) = FUSED_CU.split_once("struct FusedGdnArgs {").expect("struct in the source"); + let body = body.split_once("};").expect("end of the struct").0; + let members: Vec<&str> = body + .lines() + .filter_map(|l| l.trim().strip_prefix("uint64_t ")) + .map(|l| l.split(';').next().unwrap().trim()) + .collect(); + assert_eq!(members, KERNEL_ARGUMENT_MEMBERS); + assert_eq!(members.len(), words.len()); +} + +#[test] +fn the_fused_launch_writes_what_the_three_kernels_write() { + // conv -> h, ab -> gate and beta, step -> y: the fused launch is given exactly these four (state and history are + // read only: the window never writes them), and a joined launch carries no activation row, so it computes no gate + let words = step(0, 3, GATES).words(); + assert_eq!([words[4], words[5], words[6], words[9]], [0x500, 0x600, 0x700, 0xa00]); + assert_ne!(words[10], 0); + let joined = step(0, 3, GdnGateOperands::JOINED).words(); + assert_eq!(joined[10..15], [0; 5]); + assert_eq!(joined[..10], words[..10]); +} + +#[test] +fn the_fused_launch_refuses_empty_and_oversized_row_ranges() { + assert!(step(0, 8, GATES).launch().is_ok()); + assert!(step(7, 8, GATES).launch().is_ok()); + assert_eq!(step(3, 3, GATES).launch().unwrap_err(), Error::InvalidQwenShape); + assert_eq!(step(0, 9, GATES).launch().unwrap_err(), Error::InvalidQwenShape); +} + +#[test] +fn the_unrolled_entry_follows_the_token_count_like_upstream() { + for rows in 1..=6 { + assert_eq!(AbUnrolledStep::entry(rows).unwrap(), format!("leleka_gdn_ab_unrolled_t{rows}")); + } + assert_eq!(AbUnrolledStep::entry(7).unwrap(), "leleka_gdn_ab_unrolled_t8"); + assert_eq!(AbUnrolledStep::entry(8).unwrap(), "leleka_gdn_ab_unrolled_t8"); + assert!(AbUnrolledStep::entry(0).is_err() && AbUnrolledStep::entry(9).is_err()); +} + +#[test] +fn the_unrolled_launch_takes_the_arguments_of_the_original_ab_kernel() { + let unrolled = AbUnrolledStep { gates: GATES, gate: 0x1100, beta: 0x1200, rows: 4 }; + let launch = unrolled.launch().unwrap(); + // verify_gdn_ab_multi_kernel(x, wa, wb, dt, ssm_a, gate, beta, n = 2560, h_v = 48, T) + assert_eq!( + launch.args, + vec![ + A::P(0xb00), + A::P(0xc00), + A::P(0xd00), + A::P(0xe00), + A::P(0xf00), + A::P(0x1100), + A::P(0x1200), + A::I32(2560), + A::I32(48), + A::I32(4) + ] + ); + assert_eq!((launch.grid, launch.block), ([96, 1, 1], [32, 1, 1])); + assert!(AbUnrolledStep { rows: 0, ..unrolled }.launch().is_err()); +} + +// ---- the sealed PTX against the Original's: same operations in the same order (CPU-side, no GPU) ---- + +/// The body of the `.entry` whose name is exactly `name`. +fn entry_body<'t>(ptx: &'t str, name: &str) -> &'t str { + let start = ptx.find(&format!(".entry {name}(")).unwrap_or_else(|| panic!("no entry {name}")); + let end = ptx[start..].find("\n}\n").map_or(ptx.len(), |e| start + e); + &ptx[start..end] +} + +/// Float arithmetic, shuffles and barriers of an entry, in program order (loads, stores, moves and address +/// arithmetic differ between a fused and a split producer). +fn numeric_sequence(body: &str) -> Vec { + let numeric = |op: &str| { + let float = ["add", "sub", "mul", "fma", "div", "rcp", "rsqrt", "ex2"].iter().any(|p| op.starts_with(p)); + (float && op.contains(".f32")) || op.starts_with("shfl.") || op.starts_with("bar.sync") + }; + body.lines() + .map(str::trim) + .map(|l| if l.starts_with('@') { l.split_once(' ').map_or("", |(_, rest)| rest.trim()) } else { l }) + .filter_map(|l| l.split_whitespace().next()) + .map(|op| op.trim_end_matches(';')) + .filter(|op| numeric(op)) + .map(str::to_owned) + .collect() +} + +fn ops(names: &[&str]) -> Vec { + names.iter().map(|s| s.to_string()).collect() +} +fn contains_run(hay: &[String], needle: &[String]) -> bool { + !needle.is_empty() && hay.windows(needle.len()).any(|w| w == needle) +} +fn distinct(seq: &[String]) -> std::collections::BTreeSet<&str> { + seq.iter().map(String::as_str).collect() +} + +#[test] +fn the_fused_conv_is_the_originals_conv_instruction_for_instruction() { + let original = numeric_sequence(entry_body(ORIGINAL_PTX, "verify_gdn_conv_l2_multi_kernel")); + let fused = numeric_sequence(entry_body(FUSED_PTX, E_FUSED_STEP)); + // mul + 3 fma (the four taps), silu by div.rn, y * y, five butterfly adds, the barrier, the L2 sum, rsqrt, scale + assert_eq!(original.len(), 26, "{original:?}"); + assert!(contains_run(&fused, &original), "the conv of the Original is not a run of the fused kernel"); +} + +#[test] +fn the_fused_step_keeps_the_originals_unfused_delta_and_its_output_tail() { + let original = numeric_sequence(entry_body(ORIGINAL_PTX, "verify_gdn_step_norm_multi_kernel")); + let fused = numeric_sequence(entry_body(FUSED_PTX, E_FUSED_STEP)); + // kv_col (three adds), then delta = beta * (v - g * kv): mul, sub, mul and no fma (ptxas contracts a plain + // mul + sub into one FFMA at load time, in the Original and in this kernel alike) + let delta = ops(&["add.f32", "add.f32", "add.f32", "mul.f32", "sub.f32", "mul.f32"]); + assert!(contains_run(&original, &delta) && contains_run(&fused, &delta)); + // oc = sum * rsqrt(128) (evaluated at run time), the five butterfly adds, ss/128 + eps as one fma, rsqrt, three + // multiplies, the sigmoid by rcp.rn + #[rustfmt::skip] + let tail = ops(&[ + "add.f32", "add.f32", "add.f32", "rsqrt.approx.f32", "mul.f32", "mul.f32", + "shfl.sync.bfly.b32", "add.f32", "shfl.sync.bfly.b32", "add.f32", "shfl.sync.bfly.b32", "add.f32", + "shfl.sync.bfly.b32", "add.f32", "shfl.sync.bfly.b32", "add.f32", "bar.sync", + "add.f32", "add.f32", "add.f32", "fma.rn.f32", "rsqrt.approx.f32", "mul.f32", "mul.f32", "mul.f32", + "ex2.approx.f32", "add.f32", "rcp.rn.f32", "mul.f32", + ]); + assert!(contains_run(&original, &tail), "the Original's tail changed"); + assert!(contains_run(&fused, &tail), "the fused output tail differs from the Original's"); +} + +#[test] +fn the_fused_kernel_has_no_flavour_the_original_kernels_do_not_have() { + let mut union: std::collections::BTreeSet = std::collections::BTreeSet::new(); + for name in ["verify_gdn_conv_l2_multi_kernel", "verify_gdn_ab_multi_kernel", "verify_gdn_step_norm_multi_kernel"] { + union.extend(distinct(&numeric_sequence(entry_body(ORIGINAL_PTX, name))).into_iter().map(str::to_owned)); + } + let fused = numeric_sequence(entry_body(FUSED_PTX, E_FUSED_STEP)); + let fused_set: std::collections::BTreeSet = distinct(&fused).into_iter().map(str::to_owned).collect(); + assert_eq!(fused_set, union); + // no explicit-rounding intrinsic, no flush to zero, no approximate division: plain contractible forms only + assert!(fused.iter().all(|op| !op.contains(".ftz") && !op.contains("div.approx") && !op.contains("div.full"))); + assert!(fused.iter().all(|op| !matches!(op.as_str(), "add.rn.f32" | "mul.rn.f32" | "sub.rn.f32"))); +} + +#[test] +fn every_unrolled_ab_kernel_has_the_original_ab_kernels_flavours() { + let original = numeric_sequence(entry_body(ORIGINAL_PTX, "verify_gdn_ab_multi_kernel")); + let chain = numeric_sequence(entry_body(CHAIN_PTX, "chain_gdn_ab_multi_kernel")); + assert_eq!(distinct(&original), distinct(&chain)); + for entry in E_AB_UNROLLED { + let unrolled = numeric_sequence(entry_body(FUSED_PTX, entry)); + assert_eq!(distinct(&unrolled), distinct(&original), "{entry}"); + // the multiply-adds of the dot product: eight per weight word and token, ten passes + let fmas = |seq: &[String]| seq.iter().filter(|op| *op == "fma.rn.f32").count(); + let tokens: usize = entry.rsplit('t').next().unwrap().parse().unwrap(); + assert!(fmas(&unrolled) >= 8 * 10 * tokens, "{entry}: {} fmas", fmas(&unrolled)); + } +} diff --git a/crates/cuda-driver/src/original_verify/share_window_modules.rs b/crates/cuda-driver/src/original_verify/share_window_modules.rs index c0f01676..c0658bea 100644 --- a/crates/cuda-driver/src/original_verify/share_window_modules.rs +++ b/crates/cuda-driver/src/original_verify/share_window_modules.rs @@ -10,6 +10,8 @@ pub(super) use verify_bank_and_canonical_gdn_open::admission; #[allow(unused_imports)] pub(super) use verify_bank_and_canonical_gdn_open::admit; #[allow(unused_imports)] +pub(super) use verify_bank_and_canonical_gdn_open::check_canonical_lengths; +#[allow(unused_imports)] pub(super) use verify_bank_and_canonical_gdn_open::check_commands; #[allow(unused_imports)] pub(super) use verify_bank_and_canonical_gdn_open::command; diff --git a/crates/cuda-driver/src/original_verify/share_window_modules/original_verify_bank.rs b/crates/cuda-driver/src/original_verify/share_window_modules/original_verify_bank.rs index a60b99b5..f36e3c66 100644 --- a/crates/cuda-driver/src/original_verify/share_window_modules/original_verify_bank.rs +++ b/crates/cuda-driver/src/original_verify/share_window_modules/original_verify_bank.rs @@ -15,11 +15,8 @@ impl<'ctx> OriginalVerifyBank<'ctx> { } Ok(Self { physical: Rc::new(owner), - last_t: 0, - last_position: 0, - last_tokens: [0; 8], + staged: StagedWindow::EMPTY, generation: 0, - last_keep: 0, released: false, pcie_sources: Vec::new(), pcie_mode: 0, @@ -28,21 +25,21 @@ impl<'ctx> OriginalVerifyBank<'ctx> { } pub(crate) fn staged_window(&self) -> Result<(u64, usize, usize)> { self.validate_context(self.physical.context)?; - if self.last_t == 0 || self.released { + if self.staged.t == 0 || self.released { return Err(Error::InvalidQwenShape); } - Ok((self.generation, self.last_position, self.last_t)) + Ok((self.generation, self.staged.position, self.staged.t)) } pub(crate) fn staged_keep(&self) -> Result { self.staged_window()?; - if !(1..=self.last_t).contains(&self.last_keep) { + if !(1..=self.staged.t).contains(&self.staged.keep) { return Err(Error::InvalidQwenShape); } - Ok(self.last_keep) + Ok(self.staged.keep) } pub(crate) fn completed_row(&self, row: usize) -> Result> { self.staged_window()?; - if row >= self.last_t { + if row >= self.staged.t { return Err(Error::InvalidQwenShape); } let bytes = self.geometry().hc * self.geometry().n * 4; @@ -51,7 +48,7 @@ impl<'ctx> OriginalVerifyBank<'ctx> { physical: self.physical.clone(), generation: self.generation, row, - position: self.last_position + row, + position: self.staged.position + row, }) } pub fn allocated_bytes(&self) -> usize { @@ -76,16 +73,16 @@ impl<'ctx> OriginalVerifyBank<'ctx> { // A failed partial staging cannot retain old generation authority. self.generation = generation; self.physical.generation.set(generation); - self.last_t = 0; - self.last_keep = 0; + self.staged.t = 0; + self.staged.keep = 0; self.write_staged_rows(tokens, position)?; std::sync::atomic::fence(std::sync::atomic::Ordering::SeqCst); - self.last_t = tokens.len(); - self.last_position = position; - self.last_tokens[..tokens.len()].copy_from_slice(tokens); + self.staged.t = tokens.len(); + self.staged.position = position; + self.staged.tokens[..tokens.len()].copy_from_slice(tokens); self.generation = generation; self.physical.generation.set(generation); - self.last_keep = 0; + self.staged.keep = 0; Ok(generation) } fn check_stage(&self, tokens: &[i32], position: usize) -> Result<()> { @@ -140,7 +137,9 @@ impl<'ctx> OriginalVerifyBank<'ctx> { } pub(crate) fn stage_ple(&mut self, values: &[f32]) -> Result<()> { self.validate_context(self.physical.context)?; - if self.last_t == 0 || values.len() != self.last_t * self.geometry().n || values.iter().any(|x| !x.is_finite()) + if self.staged.t == 0 + || values.len() != self.staged.t * self.geometry().n + || values.iter().any(|x| !x.is_finite()) { return Err(Error::InvalidQwenShape); } @@ -157,7 +156,7 @@ impl<'ctx> OriginalVerifyBank<'ctx> { } pub(crate) fn stage_commit(&mut self, keep: usize) -> Result<()> { self.validate_context(self.physical.context)?; - if !(1..=self.last_t).contains(&keep) { + if !(1..=self.staged.t).contains(&keep) { return Err(Error::InvalidQwenShape); } let m = &self.physical.mapped; @@ -166,11 +165,11 @@ impl<'ctx> OriginalVerifyBank<'ctx> { m.write(0, &(keep as i32).to_le_bytes())?; m.write(4, &(keep as i32 - 1).to_le_bytes())?; for t in 0..self.geometry().max_t { - let p = if t < keep { (self.last_position + t) as i32 } else { -1 }; + let p = if t < keep { (self.staged.position + t) as i32 } else { -1 }; m.write((2 + t) * 4, &p.to_le_bytes())? } std::sync::atomic::fence(std::sync::atomic::Ordering::SeqCst); - self.last_keep = keep; + self.staged.keep = keep; Ok(()) } pub(crate) fn release_gpu_waits(&mut self) -> Result<()> { diff --git a/crates/cuda-driver/src/original_verify/share_window_modules/verify_bank_and_canonical_gdn_open.rs b/crates/cuda-driver/src/original_verify/share_window_modules/verify_bank_and_canonical_gdn_open.rs index 9ce702fd..aeef34eb 100644 --- a/crates/cuda-driver/src/original_verify/share_window_modules/verify_bank_and_canonical_gdn_open.rs +++ b/crates/cuda-driver/src/original_verify/share_window_modules/verify_bank_and_canonical_gdn_open.rs @@ -103,7 +103,7 @@ impl<'ctx> Context<'ctx> { OriginalVerifyBank::new(self, geometry) } } -fn check_canonical_lengths(states: &[&[f32]; 36], histories: &[&[f32]; 36]) -> Result<()> { +pub(in super::super) fn check_canonical_lengths(states: &[&[f32]; 36], histories: &[&[f32]; 36]) -> Result<()> { for i in 0..36 { if states[i].len() != STATE_WORDS || histories[i].len() != HISTORY_WORDS { return Err(Error::InvalidQwenShape); @@ -131,16 +131,23 @@ fn encode_layer(bytes: &mut [u8], state: &[f32], history: &[f32]) -> bool { impl Canonical<'_> { /// One pass per layer converts to little-endian bytes and checks every word finite; a non-finite word refuses the /// intake before the layer is uploaded. - fn upload_layers(&mut self, states: &[&[f32]; 36], histories: &[&[f32]; 36]) -> Result<()> { + fn upload_layers(&self, states: &[&[f32]; 36], histories: &[&[f32]; 36]) -> Result<()> { let mut bytes = zero(LAYER_BYTES)?; for i in 0..36 { if !encode_layer(&mut bytes, states[i], histories[i]) { return Err(Error::NonFiniteMmqOutput("Original canonical GDN intake")); } - self.buffer.as_mut().ok_or(Error::ContextPoisoned)?.copy_from_range(i * LAYER_BYTES, &bytes)?; + self.buffer.as_ref().ok_or(Error::ContextPoisoned)?.copy_from_range_shared(i * LAYER_BYTES, &bytes)?; } Ok(()) } + /// Overwrite the image in place (same device address, so every graph that captured it stays valid) with the next + /// request's priors: the same checks and the same per-layer transfers as the intake of `new`. + pub(in super::super) fn reseed(&self, states: [&[f32]; 36], histories: [&[f32]; 36]) -> Result<()> { + check_canonical_lengths(&states, &histories)?; + self.validate_context(self.context)?; + self.upload_layers(&states, &histories) + } pub fn allocated_bytes(&self) -> usize { self.buffer.as_ref().map_or(0, DeviceBuffer::len) } @@ -222,6 +229,12 @@ impl OriginalVerifyCanonicalGdn<'_> { } self.inner.with_layer(layer, read) } + /// Overwrite the image in place (same device address) with `states` and `histories`, 117.7 MB host to device. The + /// graphs that captured the image are idle: the caller parked the verifier first. A non-finite word refuses the + /// layer that holds it, after the layers before it were written (a partial reseed: the caller retires the set). + pub fn reseed(&self, states: [&[f32]; 36], histories: [&[f32]; 36]) -> Result<()> { + self.inner.reseed(states, histories) + } pub fn close(self) -> Result<()> { match Rc::try_unwrap(self.inner) { Ok(mut owner) => owner.close_inner(), diff --git a/crates/cuda-driver/src/original_verify/share_window_modules/verify_bank_plan_and_window_rows.rs b/crates/cuda-driver/src/original_verify/share_window_modules/verify_bank_plan_and_window_rows.rs index 25d5b028..02552b6d 100644 --- a/crates/cuda-driver/src/original_verify/share_window_modules/verify_bank_plan_and_window_rows.rs +++ b/crates/cuda-driver/src/original_verify/share_window_modules/verify_bank_plan_and_window_rows.rs @@ -78,15 +78,15 @@ impl<'ctx> OriginalVerifyBank<'ctx> { } /// Fixed real layer operands and borrowed source weights remain alive inside /// the graph aggregate. No host-made readiness or arbitrary handles enter. - pub fn gdn_journal<'a>( + pub fn gdn_journal( &self, canonical: &mut OriginalVerifyCanonicalGdn<'ctx>, - weights: [OriginalVerifyGdnWeights<'a, 'ctx>; 36], - ple: Option<&'a DeviceBuffer<'ctx>>, - ) -> Result> { + weights: [OriginalVerifyGdnWeights<'ctx>; 36], + ple: Option>, + ) -> Result> { let (owned, arena) = self.journal_buffers(canonical)?; self.check_journal_weights(&weights, owned, arena)?; - if let Some(history) = ple { + if let Some(history) = &ple { self.check_journal_ple(history, owned, arena)?; } Ok(OriginalVerifyGdnJournal { @@ -114,18 +114,18 @@ impl<'ctx> OriginalVerifyBank<'ctx> { /// Every layer operand fits its size and overlaps neither the canonical buffer nor the arena. fn check_journal_weights( &self, - weights: &[OriginalVerifyGdnWeights<'_, 'ctx>; 36], + weights: &[OriginalVerifyGdnWeights<'ctx>; 36], owned: &DeviceBuffer<'ctx>, arena: &DeviceBuffer<'ctx>, ) -> Result<()> { for w in weights { for (b, n) in [ - (w.conv, 10240 * 4 * 4), - (w.alpha, 48 * 2560 * 2), - (w.beta, 48 * 2560 * 2), - (w.dt, 48 * 4), - (w.a, 48 * 4), - (w.norm, 128 * 4), + (&w.conv, 10240 * 4 * 4), + (&w.alpha, 48 * 2560 * 2), + (&w.beta, 48 * 2560 * 2), + (&w.dt, 48 * 4), + (&w.a, 48 * 4), + (&w.norm, 128 * 4), ] { admit(self.physical.context, b, n)?; if handle(b)?.overlaps(n, handle(owned)?, owned.len()) @@ -220,13 +220,13 @@ impl<'ctx> OriginalVerifyWindow<'ctx> { } } /// The journal resolves arena spans for the pure window plans. -impl kernels::ArenaMap for OriginalVerifyGdnJournal<'_, '_> { +impl kernels::ArenaMap for OriginalVerifyGdnJournal<'_> { fn span(&self, name: &str, offset: usize, bytes: usize) -> Result { self.physical.span(name, offset, bytes) } } -impl resources::Sealed for OriginalVerifyGdnJournal<'_, '_> {} -impl OriginalGraphResources for OriginalVerifyGdnJournal<'_, '_> { +impl resources::Sealed for OriginalVerifyGdnJournal<'_> {} +impl OriginalGraphResources for OriginalVerifyGdnJournal<'_> { fn validate_context(&self, c: &Context<'_>) -> Result<()> { self.physical.validate(c)?; self.canonical.validate_context(c) diff --git a/crates/cuda-driver/src/original_verify_diag.rs b/crates/cuda-driver/src/original_verify_diag.rs index 98fef468..ead5fbe3 100644 --- a/crates/cuda-driver/src/original_verify_diag.rs +++ b/crates/cuda-driver/src/original_verify_diag.rs @@ -129,6 +129,13 @@ impl Registration { pub(super) fn end_window(&self) { self.shared.active.store(false, Ordering::SeqCst); } + /// No window yet: the numbers of a freshly registered verifier (a re-armed one starts the next request there). + pub(super) fn reset_window(&self) { + self.shared.rows.store(0, Ordering::SeqCst); + self.shared.first_position.store(0, Ordering::SeqCst); + self.shared.layer_step.store(0, Ordering::SeqCst); + self.shared.active.store(false, Ordering::SeqCst); + } /// Raised by the owner (or a watchdog); later windows are refused. pub(super) fn is_released(&self) -> bool { self.shared.released.load(Ordering::SeqCst) @@ -269,6 +276,26 @@ mod tests { assert!(String::from_utf8(out).unwrap().contains("(last window, not the current stage)")); } + #[test] + fn a_rearmed_registration_reports_no_window_until_the_next_one_begins() { + let _serial = serial(); + let (cells, w) = words(); + let r = Registration::new(w); + let used = snapshot_after_a_window(&r, &cells); + assert!(used.current && used.rows == 4); + // the mapped words are zeroed by the bank's re-arm; the registry's own numbers by this + for cell in cells.iter() { + cell.store(0, Ordering::SeqCst); + } + r.reset_window(); + let fresh = r.snapshot(); + assert_eq!((fresh.rows, fresh.first_position, fresh.host_layer_step), (0, 0, 0)); + assert_eq!((fresh.gpu_rang, fresh.served, fresh.plan, fresh.copies), (0, 0, 0, 0)); + assert!(!fresh.current && !fresh.released); + r.begin_window(2, 99); + assert_eq!((r.snapshot().rows, r.snapshot().first_position, r.snapshot().host_layer_step), (2, 99, 0)); + } + #[test] fn release_raises_every_flag_past_any_ring_and_waits_for_the_window() { let _serial = serial(); diff --git a/crates/cuda-driver/src/original_verify_gpu_plan/plan_phases.rs b/crates/cuda-driver/src/original_verify_gpu_plan/plan_phases.rs index 2e11db36..f870b7c3 100644 --- a/crates/cuda-driver/src/original_verify_gpu_plan/plan_phases.rs +++ b/crates/cuda-driver/src/original_verify_gpu_plan/plan_phases.rs @@ -219,15 +219,13 @@ impl<'ctx> schedule::OriginalVerifyCpuSink<'_, 'ctx> { (kernel, staging, stride): (bool, u64, usize), ) -> Result<()> { let flag_b = self.flag_b_host_address()?; - if kernel { - if !plan.pcie.is_empty() { + if flag_b_route(kernel, pcie.is_some()) == FlagBRoute::AtOnce { + if kernel && !plan.pcie.is_empty() { self.bank.retain_pcie_source(Rc::clone(pcie.as_ref().ok_or(Error::InvalidQwenShape)?.bank))?; } return self.raise_flag_b(); } - let Some(source) = pcie else { - return self.raise_flag_b(); - }; + let source = pcie.ok_or(Error::InvalidQwenShape)?; if !plan.pcie.is_empty() { // The bank's registered bytes are read by the copy engine after this call returns: the bank // stays retained by the verifier until the window's copy-stream fence. @@ -266,6 +264,24 @@ impl<'ctx> schedule::OriginalVerifyCpuSink<'_, 'ctx> { } } +/// Where a group's flag B is raised from. +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub(super) enum FlagBRoute { + /// From the host at once. + AtOnce, + /// Queued on the copy stream behind the group's staging copies, so it lands only after them. + BehindStagingCopies, +} + +/// The route of flag B for one group. Only a group staged by DMA waits for its copies; the copy kernel and a group +/// without a PCIe source raise at once. Flag B is one monotone ring word shared by the groups of a window, so a window +/// must not mix a staged group with an at-once group: the at-once raise of a later ring value would announce the +/// earlier group's copies as landed. The product never mixes them: whether a PCIe source exists is `pcie_num > 0` of +/// the round (`decode_parts.rs`), the same for every group of every window of that round. +pub(super) const fn flag_b_route(copy_kernel: bool, has_pcie_source: bool) -> FlagBRoute { + if copy_kernel || !has_pcie_source { FlagBRoute::AtOnce } else { FlagBRoute::BehindStagingCopies } +} + /// Enqueues the host-to-device copies of every PCIe expert's spans into its staging slot: one batched call for all /// pieces (`many`), or one per piece. fn stage_pcie<'ctx>( diff --git a/crates/cuda-driver/src/original_verify_gpu_plan/tests.rs b/crates/cuda-driver/src/original_verify_gpu_plan/tests.rs index 77254192..a371517f 100644 --- a/crates/cuda-driver/src/original_verify_gpu_plan/tests.rs +++ b/crates/cuda-driver/src/original_verify_gpu_plan/tests.rs @@ -71,3 +71,12 @@ fn a_corrupt_plan_is_refused_not_repaired() { // more entries than the block holds assert!(encode_plan_block(&layout, PlanEntryShape { cap: 40, k: 10, n_entries: 50 }, &[], &[]).is_err()); } + +#[test] +fn flag_b_waits_for_the_staging_copies_only_for_a_dma_group_with_a_pcie_source() { + use plan_phases::{FlagBRoute::*, flag_b_route}; + assert_eq!(flag_b_route(false, true), BehindStagingCopies, "DMA with a source: behind the copies"); + assert_eq!(flag_b_route(false, false), AtOnce, "no PCIe source: at once"); + assert_eq!(flag_b_route(true, true), AtOnce, "copy kernel: the graph stages, flag B at once"); + assert_eq!(flag_b_route(true, false), AtOnce); +} diff --git a/crates/cuda-driver/src/original_verify_schedule.rs b/crates/cuda-driver/src/original_verify_schedule.rs index c2293961..4f27f3bf 100644 --- a/crates/cuda-driver/src/original_verify_schedule.rs +++ b/crates/cuda-driver/src/original_verify_schedule.rs @@ -80,5 +80,7 @@ mod original_verifier; mod verifier_commit_window_lifecycle; #[path = "original_verify_schedule/verifier_logits_diagnostics_close.rs"] mod verifier_logits_diagnostics_close; +#[path = "original_verify_schedule/verifier_park_rearm.rs"] +mod verifier_park_rearm; #[path = "original_verify_schedule/window_phases.rs"] mod window_phases; diff --git a/crates/cuda-driver/src/original_verify_schedule/commit_sync_forced.rs b/crates/cuda-driver/src/original_verify_schedule/commit_sync_forced.rs index 9d1cd74c..79d22725 100644 --- a/crates/cuda-driver/src/original_verify_schedule/commit_sync_forced.rs +++ b/crates/cuda-driver/src/original_verify_schedule/commit_sync_forced.rs @@ -40,7 +40,7 @@ impl<'ctx, R: OriginalVerifyGraphResources<'ctx> + OriginalNativeHeadGraphResour self.event = Some(context.original_gpu_event(OriginalEventKind::Completion)?); Ok(()) } - fn unopened() -> Self { + pub(super) fn unopened() -> Self { Self { bank: None, compute: None, diff --git a/crates/cuda-driver/src/original_verify_schedule/park_rearm_tests.rs b/crates/cuda-driver/src/original_verify_schedule/park_rearm_tests.rs new file mode 100644 index 00000000..c428f524 --- /dev/null +++ b/crates/cuda-driver/src/original_verify_schedule/park_rearm_tests.rs @@ -0,0 +1,129 @@ +//! Unit tests of `park` and `rearm` on a verifier that holds no device state (`unopened`): the preconditions, the +//! order of refusals and the counters a re-arm restores. What touches the device (the bank, the images) is checked by +//! the identity job of `docs/experiments/verify-decode-graph-reuse-handles.md`. +use super::*; +use crate::original_gpu_schedule::resources; + +/// Resources that are never used: `unopened` verifiers hold no graph. +struct NoResources; +impl resources::Sealed for NoResources {} +impl OriginalGraphResources for NoResources { + fn validate_context(&self, _: &Context<'_>) -> Result<()> { + Err(Error::ContextPoisoned) + } +} +impl<'ctx> OriginalVerifyGraphResources<'ctx> for NoResources { + fn verifier_qsa(&self) -> &crate::OriginalVerifyQsaJournal<'ctx> { + unreachable!("an unopened verifier holds no graph") + } + fn verifier_journal(&self) -> &OriginalVerifyGdnJournal<'ctx> { + unreachable!("an unopened verifier holds no graph") + } +} +impl<'ctx> OriginalNativeHeadGraphResources<'ctx> for NoResources { + fn native_head_rows(&self) -> Result<&crate::OriginalNativeHeadRows<'ctx>> { + Err(Error::ContextPoisoned) + } + fn native_head_rows_mut(&mut self) -> Result<&mut crate::OriginalNativeHeadRows<'ctx>> { + Err(Error::ContextPoisoned) + } +} + +type Bare = OriginalVerifier<'static, NoResources>; +/// A name and the change that makes a verifier unfit to be re-armed. +type Refusal = (&'static str, fn(&mut Bare)); + +const STATE_WORDS: usize = 128 * 48 * 128; +const HISTORY_WORDS: usize = 10240 * 3; + +/// A verifier mid-way through a request: counters up, a completed window remembered. +fn busy() -> Bare { + let mut verifier = Bare::unopened(); + verifier.windows = 7; + verifier.commits = 6; + verifier.completed_generation = Some(12); + verifier.completed_ids = [3; 8]; + verifier +} + +fn counters(v: &Bare) -> (u64, u64, Option, [i32; 8]) { + (v.windows, v.commits, v.completed_generation, v.completed_ids) +} + +fn seeded(use_seed: impl FnOnce(OriginalVerifyRearm<'_>) -> R) -> R { + let (state, history, ple) = (vec![0.0f32; STATE_WORDS], vec![0.0f32; HISTORY_WORDS], vec![0.0f32; 9 * 10240]); + use_seed(OriginalVerifyRearm { gdn_states: [&state; 36], gdn_histories: [&history; 36], ple_history: &ple }) +} + +#[test] +fn the_counters_of_a_fresh_verifier_come_back() { + let mut verifier = busy(); + verifier.profile.add_window(&vec![1u64; profile_stamp_words(48)], 48, |layer| layer % 4 == 3); + assert_eq!(verifier.profile.windows(), 1); + verifier.reset_run_counters(); + let fresh = Bare::unopened(); + assert_eq!(counters(&verifier), counters(&fresh)); + assert_eq!(counters(&verifier), (0, 0, None, [0; 8])); + assert_eq!(verifier.profile.windows(), 0); + assert!(verifier.profile_report().is_empty()); +} + +#[test] +fn a_verifier_that_is_not_parked_or_is_unusable_refuses_to_rearm_and_keeps_its_counters() { + let flags: [Refusal; 5] = [ + ("failed", |v| v.failed = true), + ("released", |v| v.released = true), + ("window outstanding", |v| v.active = true), + ("completed window not settled", |v| v.window_ready = true), + ("commit pending", |v| v.commit_pending = true), + ]; + for (what, set) in flags { + let mut verifier = busy(); + set(&mut verifier); + let failed_before = verifier.failed; + assert_eq!(seeded(|seed| verifier.rearm(seed)), Err(Error::InvalidQwenShape), "{what}"); + assert_eq!(counters(&verifier), counters(&busy()), "{what}: nothing was reset"); + assert_eq!(verifier.failed, failed_before, "{what}: a refused precondition does not fail the verifier"); + // a failed or active verifier is dropped through its abort path, which needs no device here + verifier.failed = true; + } +} + +#[test] +fn a_verifier_without_a_recording_cannot_be_rearmed_and_is_not_marked_failed() { + let mut verifier = busy(); + assert_eq!(seeded(|seed| verifier.rearm(seed)), Err(Error::ContextPoisoned)); + assert!(!verifier.failed); + assert_eq!(counters(&verifier), counters(&busy())); +} + +#[test] +fn a_seed_of_the_wrong_shape_is_refused_before_anything_else() { + let mut verifier = busy(); + let (state, history) = (vec![0.0f32; STATE_WORDS], vec![0.0f32; HISTORY_WORDS]); + let short_ple = vec![0.0f32; 9 * 10240 - 1]; + let seed = OriginalVerifyRearm { gdn_states: [&state; 36], gdn_histories: [&history; 36], ple_history: &short_ple }; + // even a failed verifier answers the shape first: the seed is checked before the state of the verifier + verifier.failed = true; + assert_eq!(verifier.rearm(seed), Err(Error::InvalidQwenShape)); + assert_eq!(counters(&verifier), counters(&busy())); +} + +#[test] +fn park_refuses_a_verifier_with_a_window_outstanding_or_one_that_failed() { + let flags: [fn(&mut Bare); 4] = + [|v| v.failed = true, |v| v.released = true, |v| v.active = true, |v| v.window_ready = true]; + for set in flags { + let mut verifier = Bare::unopened(); + set(&mut verifier); + assert_eq!(verifier.park(), Err(Error::InvalidQwenShape)); + verifier.failed = true; + } +} + +#[test] +fn parking_an_idle_verifier_with_nothing_pending_is_a_no_op() { + let mut verifier = Bare::unopened(); + assert_eq!(verifier.park(), Ok(())); + assert!(!verifier.failed); +} diff --git a/crates/cuda-driver/src/original_verify_schedule/verifier_commit_window_lifecycle.rs b/crates/cuda-driver/src/original_verify_schedule/verifier_commit_window_lifecycle.rs index 178b7aad..78825686 100644 --- a/crates/cuda-driver/src/original_verify_schedule/verifier_commit_window_lifecycle.rs +++ b/crates/cuda-driver/src/original_verify_schedule/verifier_commit_window_lifecycle.rs @@ -90,8 +90,8 @@ impl<'ctx, R: OriginalVerifyGraphResources<'ctx> + OriginalNativeHeadGraphResour Ok(OriginalVerifyWindow { physical: b.physical.clone(), generation: b.generation, - rows: b.last_t, - position: b.last_position, + rows: b.staged.t, + position: b.staged.position, sampled_ids: self.completed_ids, }) } @@ -104,7 +104,7 @@ impl<'ctx, R: OriginalVerifyGraphResources<'ctx> + OriginalNativeHeadGraphResour return Err(Error::InvalidQwenShape); } let b = self.bank()?; - Ok(&b.last_tokens[..b.staged_keep()?]) + Ok(&b.staged.tokens[..b.staged_keep()?]) } pub fn with_committed_gdn( &mut self, @@ -216,7 +216,7 @@ impl<'ctx, R: OriginalVerifyGraphResources<'ctx> + OriginalNativeHeadGraphResour ) -> Result { self.require_completed_window()?; let bank = self.bank()?; - let t = bank.last_t; + let t = bank.staged.t; let vocabulary = bank.geometry().vocabulary; let logits = self .window @@ -227,6 +227,6 @@ impl<'ctx, R: OriginalVerifyGraphResources<'ctx> + OriginalNativeHeadGraphResour if logits.len() != t.checked_mul(vocabulary).and_then(|n| n.checked_mul(4)).ok_or(Error::InvalidSize)? { return Err(Error::InvalidQwenShape); } - read(logits, t, vocabulary, bank.last_position) + read(logits, t, vocabulary, bank.staged.position) } } diff --git a/crates/cuda-driver/src/original_verify_schedule/verifier_logits_diagnostics_close.rs b/crates/cuda-driver/src/original_verify_schedule/verifier_logits_diagnostics_close.rs index 4898803b..867b65fa 100644 --- a/crates/cuda-driver/src/original_verify_schedule/verifier_logits_diagnostics_close.rs +++ b/crates/cuda-driver/src/original_verify_schedule/verifier_logits_diagnostics_close.rs @@ -95,21 +95,21 @@ impl<'ctx, R: OriginalVerifyGraphResources<'ctx> + OriginalNativeHeadGraphResour pub fn window_residual_rows(&self) -> Result<(usize, usize, Vec)> { self.require_completed_window()?; let bank = self.bank()?; - let t = bank.last_t; + let t = bank.staged.t; let g = bank.geometry(); let bytes_len = [t, g.hc, g.n, 4].iter().try_fold(1usize, |n, &x| n.checked_mul(x)).ok_or(Error::InvalidSize)?; let s = bank.physical.layout.span("R")?; let span = arena_span(bank, s.offset, bytes_len)?; let bytes = read_device_bytes(bank.physical.context, span, bytes_len)?; - Ok((t, bank.last_position, decode_f32s(&bytes, bytes_len / 4)?)) + Ok((t, bank.staged.position, decode_f32s(&bytes, bytes_len / 4)?)) } /// Bring-up diagnostic: the `dbg_ladder` frames (96 x rows x hc*n f32, frame = 2*layer + half) of the last /// completed window, `None` when the region was not laid out (LELEKA_TRACE_LADDER unset at bank creation). pub fn window_ladder_rows(&self) -> Result>> { self.require_completed_window()?; let bank = self.bank()?; - let t = bank.last_t; + let t = bank.staged.t; let g = bank.geometry(); let row = g.hc * g.n; let Ok(s) = bank.physical.layout.span("dbg_ladder") else { return Ok(None) }; diff --git a/crates/cuda-driver/src/original_verify_schedule/verifier_park_rearm.rs b/crates/cuda-driver/src/original_verify_schedule/verifier_park_rearm.rs new file mode 100644 index 00000000..3e4b90c1 --- /dev/null +++ b/crates/cuda-driver/src/original_verify_schedule/verifier_park_rearm.rs @@ -0,0 +1,112 @@ +//! Park and re-arm of a recorded verifier (ledger row Q7, `docs/experiments/verify-decode-graph-reuse-handles.md`). +//! +//! `park` ends a request without closing anything: both streams drained, a pending commit waited, every graph +//! quiescent; the graphs, the bank, the streams and the event stay. `rearm` starts the next request over the same +//! recording: it puts back everything a fresh `OriginalVerifier::new` + `record_all` leaves (the counters here, the +//! bank, its flags and mapped staging in `original_verify_rearm.rs`) and overwrites the canonical GDN image and the PLE +//! history with the next request's priors. Any error leaves the verifier failed, so the caller retires the set and +//! records a new one; a partial re-arm is safe for that reason. + +#[allow(unused_imports)] +use super::*; + +impl<'ctx, R: OriginalVerifyGraphResources<'ctx> + OriginalNativeHeadGraphResources<'ctx>> OriginalVerifier<'ctx, R> { + /// End of a request: wait a pending commit, drain both streams and retire every graph's launch. The recorded + /// graphs, the bank, the streams and the event stay; nothing is closed. A verifier that failed, was released or + /// still has a window outstanding (`active`, or completed but neither committed nor discarded) is refused. An error + /// of the waits leaves the verifier failed. + pub fn park(&mut self) -> Result<()> { + if self.failed || self.released || self.active || self.window_ready { + return Err(Error::InvalidQwenShape); + } + let parked = self.wait_commit().and_then(|()| self.drain_streams()).and_then(|()| self.quiesce_graphs()); + if parked.is_err() { + self.failed = true; + } + parked + } + + /// Start of the next request over the same recording: the preconditions (parked, nothing outstanding, the QSA + /// journal quiet), then the bank, the images and the counters. `Err` leaves the verifier unusable when it came + /// after the first change (the caller retires it); a refused precondition or seed changes nothing. + pub fn rearm(&mut self, seed: OriginalVerifyRearm<'_>) -> Result<()> { + seed.check_shapes()?; + self.require_rearmable()?; + let applied = self.apply_rearm(&seed); + if applied.is_err() { + self.failed = true; + } + applied + } + + fn drain_streams(&mut self) -> Result<()> { + for stream in [self.compute.as_ref(), self.copy.as_ref()].into_iter().flatten() { + stream.synchronize()?; + } + if let Some(bank) = self.bank.as_mut() { + bank.release_pcie_sources(); + } + Ok(()) + } + + /// Every window graph and the commit graph have no launch outstanding. + fn quiesce_graphs(&mut self) -> Result<()> { + for graph in self.window.iter_mut().filter_map(Option::as_mut).chain(self.commit.as_mut()) { + graph.resources_after_wait()?; + } + Ok(()) + } + + /// Parked and quiet: nothing in flight or outstanding, not failed or released, the graphs idle, the QSA journal + /// not armed. + fn require_rearmable(&mut self) -> Result<()> { + if self.is_unusable() || self.active || self.window_ready || self.commit_pending { + return Err(Error::InvalidQwenShape); + } + if self.bank.is_none() || self.commit.is_none() { + return Err(Error::ContextPoisoned); + } + if self.window.iter().flatten().chain(self.commit.iter()).any(|g| !g.verifier_is_idle()) { + return Err(Error::InvalidQwenShape); + } + self.commit.as_mut().ok_or(Error::ContextPoisoned)?.resources_after_wait()?.verifier_qsa().require_idle() + } + + /// Failed, or released here or by the watchdog (a released verifier ran a window the GPU never finished). + fn is_unusable(&self) -> bool { + self.failed || self.released || self.registration.as_ref().is_some_and(diag::Registration::is_released) + } + + fn apply_rearm(&mut self, seed: &OriginalVerifyRearm<'_>) -> Result<()> { + self.bank.as_mut().ok_or(Error::ContextPoisoned)?.rearm()?; + self.reseed_images(seed)?; + self.reset_run_counters(); + if let Some(registration) = &self.registration { + registration.reset_window(); + } + Ok(()) + } + + /// The canonical GDN image and the PLE history are overwritten in place: every aggregate shares them, so the + /// commit graph's journal reaches both. + fn reseed_images(&mut self, seed: &OriginalVerifyRearm<'_>) -> Result<()> { + let resources = self.commit.as_mut().ok_or(Error::ContextPoisoned)?.resources_after_wait()?; + let journal = resources.verifier_journal(); + journal.canonical.reseed(seed.gdn_states, seed.gdn_histories)?; + let history = journal.ple_buffer().ok_or(Error::InvalidQwenShape)?; + history.copy_from_shared(&seed.ple_history_bytes()?) + } + + /// The counters and completed-window memory of a verifier that has run nothing. + pub(super) fn reset_run_counters(&mut self) { + self.windows = 0; + self.commits = 0; + self.completed_generation = None; + self.completed_ids = [0; 8]; + self.profile = OriginalVerifyProfile::default(); + } +} + +#[cfg(test)] +#[path = "park_rearm_tests.rs"] +mod tests; diff --git a/crates/cuda-driver/src/original_verify_window_gr.rs b/crates/cuda-driver/src/original_verify_window_gr.rs index ff2dd0c7..a9be585f 100644 --- a/crates/cuda-driver/src/original_verify_window_gr.rs +++ b/crates/cuda-driver/src/original_verify_window_gr.rs @@ -31,7 +31,7 @@ use super::proj::{ use super::window_record::{HcHalf, Rows}; use super::{OriginalVerifyGdnJournal, admit, handle}; use crate::native_head::native_head_row_bytes; -use crate::{Context, DeviceBuffer, Error, NativeHeadDispatch, Result}; +use crate::{Context, DeviceBuffer, DeviceRef, Error, NativeHeadDispatch, Result}; // ------------------------------------------------------------------------------------------------ // Geometry of the artifact (`fused_gr.cu` is compiled for exactly these) @@ -275,49 +275,49 @@ pub(crate) struct HcReadPlan { /// The four buffers of one hc half: `norm` F32 `[hc*N]`, `down` BF16 `[hc_lr][hc*N]`, `up` BF16 /// `[hc*N][hc_lr]`, `inject` BF16 `[hc][hc*N]`. -pub struct HcHalfBuffers<'a, 'ctx> { - pub norm: &'a DeviceBuffer<'ctx>, - pub down: &'a DeviceBuffer<'ctx>, - pub up: &'a DeviceBuffer<'ctx>, - pub inject: &'a DeviceBuffer<'ctx>, +pub struct HcHalfBuffers<'ctx> { + pub norm: DeviceRef<'ctx>, + pub down: DeviceRef<'ctx>, + pub up: DeviceRef<'ctx>, + pub inject: DeviceRef<'ctx>, } -pub struct HcLayerBuffers<'a, 'ctx> { - pub attention: HcHalfBuffers<'a, 'ctx>, - pub ffn: HcHalfBuffers<'a, 'ctx>, +pub struct HcLayerBuffers<'ctx> { + pub attention: HcHalfBuffers<'ctx>, + pub ffn: HcHalfBuffers<'ctx>, } /// `output_hc_norm.weight` / `output_hc_down.weight` / `output_hc_up.weight` (no injection). -pub struct HcOutputBuffers<'a, 'ctx> { - pub norm: &'a DeviceBuffer<'ctx>, - pub down: &'a DeviceBuffer<'ctx>, - pub up: &'a DeviceBuffer<'ctx>, +pub struct HcOutputBuffers<'ctx> { + pub norm: DeviceRef<'ctx>, + pub down: DeviceRef<'ctx>, + pub up: DeviceRef<'ctx>, } -pub enum PleKeyBuffer<'a, 'ctx> { +pub enum PleKeyBuffer<'ctx> { /// BF16 `[hc_dim][n_embd]` (`PLE_KEY_BF16_BYTES`). - Bf16(&'a DeviceBuffer<'ctx>), + Bf16(DeviceRef<'ctx>), /// A native GGUF key of ggml type `ty` (42, 18, 23, 8): `hc_dim` rows of `n_embd`. - Native { ty: u32, data: &'a DeviceBuffer<'ctx> }, + Native { ty: u32, data: DeviceRef<'ctx> }, } /// The PLE weights and state of the layer-1 block. `history` must be the SAME buffer the verify /// journal snapshots (`ss.ple.hist`). -pub struct PleBuffers<'a, 'ctx> { - pub key: PleKeyBuffer<'a, 'ctx>, - pub value: &'a DeviceBuffer<'ctx>, - pub norm_key: &'a DeviceBuffer<'ctx>, - pub norm_query: &'a DeviceBuffer<'ctx>, - pub norm_conv: &'a DeviceBuffer<'ctx>, - pub conv1d: &'a DeviceBuffer<'ctx>, +pub struct PleBuffers<'ctx> { + pub key: PleKeyBuffer<'ctx>, + pub value: DeviceRef<'ctx>, + pub norm_key: DeviceRef<'ctx>, + pub norm_query: DeviceRef<'ctx>, + pub norm_conv: DeviceRef<'ctx>, + pub conv1d: DeviceRef<'ctx>, /// At least `PLE_SCRATCH_BYTES` (`ss.ple.scratch`). - pub scratch: &'a DeviceBuffer<'ctx>, - pub history: &'a DeviceBuffer<'ctx>, + pub scratch: DeviceRef<'ctx>, + pub history: DeviceRef<'ctx>, } /// The weights of the GR family for the 48 layers, the final mixer and (optionally) the PLE block, /// validated for context and exact byte sizes. -pub struct OriginalVerifyGrBinding<'a, 'ctx> { +pub struct OriginalVerifyGrBinding<'ctx> { context: &'ctx Context<'ctx>, - layers: Vec>, - output: HcOutputBuffers<'a, 'ctx>, - ple: Option>, + layers: Vec>, + output: HcOutputBuffers<'ctx>, + ple: Option>, } #[cfg(test)] diff --git a/crates/cuda-driver/src/original_verify_window_gr/assets.rs b/crates/cuda-driver/src/original_verify_window_gr/assets.rs index c280f7a5..6a14dc35 100644 --- a/crates/cuda-driver/src/original_verify_window_gr/assets.rs +++ b/crates/cuda-driver/src/original_verify_window_gr/assets.rs @@ -54,11 +54,7 @@ impl GrConfig { } /// `from_device` with the attributes read from the verifier's device. - pub(crate) fn query( - journal: &OriginalVerifyGdnJournal<'_, '_>, - variant: GrVariant, - native_mmvf: bool, - ) -> Result { + pub(crate) fn query(journal: &OriginalVerifyGdnJournal<'_>, variant: GrVariant, native_mmvf: bool) -> Result { Ok(Self::from_device( variant, native_mmvf, diff --git a/crates/cuda-driver/src/original_verify_window_gr/plan_ple_row.rs b/crates/cuda-driver/src/original_verify_window_gr/plan_ple_row.rs index a32fa889..6487d1bf 100644 --- a/crates/cuda-driver/src/original_verify_window_gr/plan_ple_row.rs +++ b/crates/cuda-driver/src/original_verify_window_gr/plan_ple_row.rs @@ -145,12 +145,12 @@ pub(crate) fn plan_ple_layer1( check_rows(window.geo, rows)?; (rows.begin..rows.end).map(|t| Ok((t, plan_ple_row(window, ple, a, t)?))).collect() } -impl<'a, 'ctx> OriginalVerifyGrBinding<'a, 'ctx> { +impl<'ctx> OriginalVerifyGrBinding<'ctx> { pub fn new( context: &'ctx Context<'ctx>, - layers: Vec>, - output: HcOutputBuffers<'a, 'ctx>, - ple: Option>, + layers: Vec>, + output: HcOutputBuffers<'ctx>, + ple: Option>, ) -> Result { if layers.len() != LAYERS { return Err(Error::InvalidQwenShape); @@ -167,7 +167,7 @@ impl<'a, 'ctx> OriginalVerifyGrBinding<'a, 'ctx> { } Ok(binding) } - pub(super) fn half(&self, layer: usize, half: HcHalf) -> Result<&HcHalfBuffers<'a, 'ctx>> { + pub(super) fn half(&self, layer: usize, half: HcHalf) -> Result<&HcHalfBuffers<'ctx>> { let l = self.layers.get(layer).ok_or(Error::InvalidQwenShape)?; Ok(match half { HcHalf::Attention => &l.attention, @@ -179,24 +179,24 @@ impl<'a, 'ctx> OriginalVerifyGrBinding<'a, 'ctx> { let h = self.half(layer, half)?; let c = self.context; Ok(HcAddrs { - norm: admit(c, h.norm, HC_NORM_BYTES)?, - down: admit(c, h.down, HC_DOWN_BYTES)?, - up: admit(c, h.up, HC_UP_BYTES)?, - inject: admit(c, h.inject, HC_INJECT_BYTES)?, + norm: admit(c, &h.norm, HC_NORM_BYTES)?, + down: admit(c, &h.down, HC_DOWN_BYTES)?, + up: admit(c, &h.up, HC_UP_BYTES)?, + inject: admit(c, &h.inject, HC_INJECT_BYTES)?, }) } pub(crate) fn head_addrs(&self) -> Result { let c = self.context; Ok(HeadAddrs { - norm: admit(c, self.output.norm, HC_NORM_BYTES)?, - down: admit(c, self.output.down, HC_DOWN_BYTES)?, - up: admit(c, self.output.up, HC_UP_BYTES)?, + norm: admit(c, &self.output.norm, HC_NORM_BYTES)?, + down: admit(c, &self.output.down, HC_DOWN_BYTES)?, + up: admit(c, &self.output.up, HC_UP_BYTES)?, }) } pub fn has_ple(&self) -> bool { self.ple.is_some() } - fn ple_key_addr(&self, key: &PleKeyBuffer<'a, 'ctx>) -> Result { + fn ple_key_addr(&self, key: &PleKeyBuffer<'ctx>) -> Result { let c = self.context; Ok(match key { PleKeyBuffer::Bf16(b) => PleKey::Bf16(admit(c, b, PLE_KEY_BF16_BYTES)?), @@ -209,7 +209,7 @@ impl<'a, 'ctx> OriginalVerifyGrBinding<'a, 'ctx> { } }) } - fn ple_scratch_addr(&self, scratch: &'a DeviceBuffer<'ctx>) -> Result { + fn ple_scratch_addr(&self, scratch: &DeviceBuffer<'ctx>) -> Result { if !std::ptr::eq(self.context, scratch.context) { return Err(Error::ContextMismatch); } @@ -224,16 +224,16 @@ impl<'a, 'ctx> OriginalVerifyGrBinding<'a, 'ctx> { let p = self.ple.as_ref().ok_or(Error::InvalidQwenShape)?; let c = self.context; let key = self.ple_key_addr(&p.key)?; - let scratch = self.ple_scratch_addr(p.scratch)?; + let scratch = self.ple_scratch_addr(&p.scratch)?; Ok(PleAddrs { key, - value: admit(c, p.value, PLE_VALUE_BYTES)?, - norm_key: admit(c, p.norm_key, PLE_NORM_BYTES)?, - norm_query: admit(c, p.norm_query, PLE_NORM_BYTES)?, - norm_conv: admit(c, p.norm_conv, PLE_NORM_BYTES)?, - conv1d: admit(c, p.conv1d, PLE_CONV_BYTES)?, + value: admit(c, &p.value, PLE_VALUE_BYTES)?, + norm_key: admit(c, &p.norm_key, PLE_NORM_BYTES)?, + norm_query: admit(c, &p.norm_query, PLE_NORM_BYTES)?, + norm_conv: admit(c, &p.norm_conv, PLE_NORM_BYTES)?, + conv1d: admit(c, &p.conv1d, PLE_CONV_BYTES)?, scratch, - history: admit(c, p.history, PLE_HISTORY_BYTES)?, + history: admit(c, &p.history, PLE_HISTORY_BYTES)?, }) } } diff --git a/crates/cuda-driver/src/original_verify_window_moe.rs b/crates/cuda-driver/src/original_verify_window_moe.rs index 8defb2f1..38bd890e 100644 --- a/crates/cuda-driver/src/original_verify_window_moe.rs +++ b/crates/cuda-driver/src/original_verify_window_moe.rs @@ -38,7 +38,7 @@ use super::window_plan::{PlanLayout, WINDOW_LAYERS}; use super::window_record::{ExpertTier, Rows}; use super::{OriginalVerifyGeometry, admit, handle}; use crate::native_head::native_head_row_bytes; -use crate::{Context, DeviceBuffer, Error, NativeHeadDispatch, Result}; +use crate::{Context, DeviceBuffer, DeviceRef, Error, NativeHeadDispatch, Result}; macro_rules! unavailable { ($producer:literal, $why:literal) => { @@ -323,21 +323,21 @@ pub(crate) struct MoeLayerAddrs { } /// One layer's MoE weights as the runtime hands them over. -pub struct OriginalVerifyMoeLayerWeights<'a, 'ctx> { - pub router: &'a DeviceBuffer<'ctx>, - pub gate_inp_shexp: &'a DeviceBuffer<'ctx>, - pub gate_shexp: &'a DeviceBuffer<'ctx>, +pub struct OriginalVerifyMoeLayerWeights<'ctx> { + pub router: DeviceRef<'ctx>, + pub gate_inp_shexp: DeviceRef<'ctx>, + pub gate_shexp: DeviceRef<'ctx>, pub gate_shexp_type: u32, - pub up_shexp: &'a DeviceBuffer<'ctx>, + pub up_shexp: DeviceRef<'ctx>, pub up_shexp_type: u32, - pub down_shexp: &'a DeviceBuffer<'ctx>, + pub down_shexp: DeviceRef<'ctx>, pub down_shexp_type: u32, } /// The router and shared-expert weights of all 48 layers plus the routed experts' formats. Construction /// validates context equality and the exact byte size of every tensor; the accessors yield addresses. -pub struct OriginalVerifyMoeBinding<'a, 'ctx> { - layers: Vec>, +pub struct OriginalVerifyMoeBinding<'ctx> { + layers: Vec>, formats: OriginalVerifyExpertFormats, n_embd: usize, n_ff: usize, diff --git a/crates/cuda-driver/src/original_verify_window_moe/pcie_fast_kernel.rs b/crates/cuda-driver/src/original_verify_window_moe/pcie_fast_kernel.rs index 55eae8bc..c2d497a2 100644 --- a/crates/cuda-driver/src/original_verify_window_moe/pcie_fast_kernel.rs +++ b/crates/cuda-driver/src/original_verify_window_moe/pcie_fast_kernel.rs @@ -146,11 +146,11 @@ impl OriginalVerifyExpertFormats { Ok(self.blob(layer)?.bytes) } } -impl<'a, 'ctx> OriginalVerifyMoeBinding<'a, 'ctx> { +impl<'ctx> OriginalVerifyMoeBinding<'ctx> { pub fn new( context: &Context<'_>, geometry: &OriginalVerifyGeometry, - layers: Vec>, + layers: Vec>, formats: OriginalVerifyExpertFormats, ) -> Result { let (n_embd, n_ff, experts) = (geometry.n, geometry.ff, geometry.experts); @@ -165,7 +165,7 @@ impl<'a, 'ctx> OriginalVerifyMoeBinding<'a, 'ctx> { } pub fn validate_context(&self, context: &Context<'_>) -> Result<()> { for l in &self.layers { - for b in [l.router, l.gate_inp_shexp, l.gate_shexp, l.up_shexp, l.down_shexp] { + for b in [&l.router, &l.gate_inp_shexp, &l.gate_shexp, &l.up_shexp, &l.down_shexp] { if !std::ptr::eq(context, b.context) { return Err(Error::ContextMismatch); } @@ -181,11 +181,11 @@ impl<'a, 'ctx> OriginalVerifyMoeBinding<'a, 'ctx> { let l = self.layers.get(layer).ok_or(Error::InvalidQwenShape)?; let (n, f) = (self.n_embd, self.n_ff); Ok(MoeLayerAddrs { - router: exact_address(l.router, self.experts * n * 2)?, - gate_inp_shexp: exact_address(l.gate_inp_shexp, n * 2)?, - gate_shexp: shexp_address(l.gate_shexp, l.gate_shexp_type, (f, n))?, - up_shexp: shexp_address(l.up_shexp, l.up_shexp_type, (f, n))?, - down_shexp: shexp_address(l.down_shexp, l.down_shexp_type, (n, f))?, + router: exact_address(&l.router, self.experts * n * 2)?, + gate_inp_shexp: exact_address(&l.gate_inp_shexp, n * 2)?, + gate_shexp: shexp_address(&l.gate_shexp, l.gate_shexp_type, (f, n))?, + up_shexp: shexp_address(&l.up_shexp, l.up_shexp_type, (f, n))?, + down_shexp: shexp_address(&l.down_shexp, l.down_shexp_type, (n, f))?, }) } } @@ -206,15 +206,15 @@ fn shexp_address(b: &DeviceBuffer<'_>, ty: u32, (rows, k): (usize, usize)) -> Re /// The `new` admission of one layer's router and shared-expert buffers. fn admit_layer( context: &Context<'_>, - layer: &OriginalVerifyMoeLayerWeights<'_, '_>, + layer: &OriginalVerifyMoeLayerWeights<'_>, (n_embd, n_ff): (usize, usize), router_bytes: usize, ) -> Result<()> { - admit(context, layer.router, router_bytes)?; - admit(context, layer.gate_inp_shexp, n_embd * 2)?; - admit(context, layer.gate_shexp, n_ff * native_head_row_bytes(layer.gate_shexp_type, n_embd)?)?; - admit(context, layer.up_shexp, n_ff * native_head_row_bytes(layer.up_shexp_type, n_embd)?)?; - admit(context, layer.down_shexp, n_embd * native_head_row_bytes(layer.down_shexp_type, n_ff)?)?; + admit(context, &layer.router, router_bytes)?; + admit(context, &layer.gate_inp_shexp, n_embd * 2)?; + admit(context, &layer.gate_shexp, n_ff * native_head_row_bytes(layer.gate_shexp_type, n_embd)?)?; + admit(context, &layer.up_shexp, n_ff * native_head_row_bytes(layer.up_shexp_type, n_embd)?)?; + admit(context, &layer.down_shexp, n_embd * native_head_row_bytes(layer.down_shexp_type, n_ff)?)?; Ok(()) } diff --git a/crates/cuda-driver/src/original_verify_window_ops.rs b/crates/cuda-driver/src/original_verify_window_ops.rs index 12cb9f73..5319501b 100644 --- a/crates/cuda-driver/src/original_verify_window_ops.rs +++ b/crates/cuda-driver/src/original_verify_window_ops.rs @@ -53,19 +53,19 @@ pub struct OriginalVerifyExpertLayout { /// twelve QSA images and the head rows (`OriginalVerifyResources`), plus the /// graph-referenced embedding rows and the expert blob layout, and the weight /// bindings of every producer family. A graph cannot pair owners of different contexts. -pub struct OriginalVerifyWindowResources<'a, 'ctx> { - base: OriginalVerifyResources<'a, 'ctx>, +pub struct OriginalVerifyWindowResources<'ctx> { + base: OriginalVerifyResources<'ctx>, embed: OriginalNativeEmbedRows<'ctx>, experts: OriginalVerifyExpertLayout, rows: usize, /// Native MMVQ projection matrices of the 36 GDN and 12 QSA layers (attached by the model adapter). - proj: Option>, + proj: Option>, /// hc weights of the 48 layers, the final mixer and the optional PLE block. - gr: Option>, + gr: Option>, /// QSA norms and indexer projections of the 12 QSA layers. - qsa: Option>, + qsa: Option>, /// Router, shared experts and routed expert formats of the 48 layers. - moe: Option>, + moe: Option>, /// The per-card fused-GR decisions, read once by `prepare`. gr_cfg: Option, } @@ -82,12 +82,14 @@ macro_rules! unattached { } /// The recorder's producer set over one graph's capture stream and resources. -pub(crate) struct OriginalVerifyWindowOps<'c, 's, 'a, 'ctx> { +pub(crate) struct OriginalVerifyWindowOps<'c, 's, 'ctx> { capture: &'c mut OriginalCapture<'s, 'ctx>, - resources: &'c mut OriginalVerifyWindowResources<'a, 'ctx>, + resources: &'c mut OriginalVerifyWindowResources<'ctx>, t: usize, groups: usize, policy: WindowPolicy, + /// The GDN kernel switches (`original_verify_window_gdn_fused.rs`). + gdn: gdn_fused::GdnFusedPolicy, } #[cfg(test)] @@ -102,10 +104,14 @@ pub(super) use all_window_assets::all_window_assets; use all_window_assets::unsealed_keys; #[allow(unused_imports)] pub use all_window_assets::unsealed_window_assets; +#[path = "original_verify_window_ops/gdn_stages.rs"] +mod gdn_stages; #[path = "original_verify_window_ops/original_verifier.rs"] mod original_verifier; #[path = "original_verify_window_ops/original_verify_window_ops_methods.rs"] mod original_verify_window_ops_methods; +#[path = "original_verify_window_ops/qsa_prelude_ops.rs"] +mod qsa_prelude_ops; #[path = "original_verify_window_ops/side_qsa_branches.rs"] mod side_qsa_branches; #[path = "original_verify_window_ops/side_shared_expert.rs"] diff --git a/crates/cuda-driver/src/original_verify_window_ops/all_window_assets.rs b/crates/cuda-driver/src/original_verify_window_ops/all_window_assets.rs index 58c8f2ab..4d242a6a 100644 --- a/crates/cuda-driver/src/original_verify_window_ops/all_window_assets.rs +++ b/crates/cuda-driver/src/original_verify_window_ops/all_window_assets.rs @@ -75,10 +75,10 @@ impl OriginalVerifyExpertLayout { .ok_or(Error::InvalidQwenShape) } } -impl<'a, 'ctx> OriginalVerifyWindowResources<'a, 'ctx> { +impl<'ctx> OriginalVerifyWindowResources<'ctx> { pub fn new( context: &'ctx Context<'ctx>, - base: OriginalVerifyResources<'a, 'ctx>, + base: OriginalVerifyResources<'ctx>, embed: OriginalNativeEmbedRows<'ctx>, experts: OriginalVerifyExpertLayout, rows: usize, @@ -94,7 +94,7 @@ impl<'a, 'ctx> OriginalVerifyWindowResources<'a, 'ctx> { self.rows } /// Attach the GDN/QSA native projection matrices (`quantize_q8_1` + `mmvq` producers). - pub fn with_projections(mut self, proj: OriginalVerifyProjBinding<'a, 'ctx>) -> Result { + pub fn with_projections(mut self, proj: OriginalVerifyProjBinding<'ctx>) -> Result { let context = self.base.journal.context(); let geometry = self.base.journal.geometry(); for i in 0..36 { @@ -109,7 +109,7 @@ impl<'a, 'ctx> OriginalVerifyWindowResources<'a, 'ctx> { /// Attach the hyper-connection weights (`hc_read`, `final_write`, `head`, and `ple_layer1` with PLE). /// The PLE binding must match the journal: present exactly when the window carries a PLE history, and /// the SAME history buffer the journal snapshots. - pub fn with_gr(mut self, gr: OriginalVerifyGrBinding<'a, 'ctx>) -> Result { + pub fn with_gr(mut self, gr: OriginalVerifyGrBinding<'ctx>) -> Result { let journal = &self.base.journal; if gr.has_ple() != journal.has_ple() { return Err(Error::InvalidQwenShape); @@ -121,7 +121,7 @@ impl<'a, 'ctx> OriginalVerifyWindowResources<'a, 'ctx> { Ok(self) } /// Attach the QSA layer weights (norms, indexer projections). - pub fn with_qsa(mut self, qsa: OriginalVerifyQsaBinding<'a, 'ctx>) -> Result { + pub fn with_qsa(mut self, qsa: OriginalVerifyQsaBinding<'ctx>) -> Result { qsa.validate_context(self.base.journal.context())?; for q in 0..12 { OriginalVerifyQsaKvBinding::from_journal(&self.base.qsa, q)?.validate(&self.base.journal.geometry())?; @@ -131,7 +131,7 @@ impl<'a, 'ctx> OriginalVerifyWindowResources<'a, 'ctx> { } /// Attach the router / shared-expert weights and the routed experts' formats. The formats' blob sizes must /// equal the expert layout this graph stages PCIe blobs with. - pub fn with_moe(mut self, moe: OriginalVerifyMoeBinding<'a, 'ctx>) -> Result { + pub fn with_moe(mut self, moe: OriginalVerifyMoeBinding<'ctx>) -> Result { moe.validate_context(self.base.journal.context())?; for layer in 0..WINDOW_LAYERS { if moe.formats().blob_bytes(layer)? != self.experts.blob_bytes(layer)? { @@ -155,6 +155,7 @@ impl<'a, 'ctx> OriginalVerifyWindowResources<'a, 'ctx> { assets.extend(qsa::assets()); assets.extend(qsa::cluster_assets(&policy.qsa)); assets.extend(qsa::daily_assets(&policy.qsa)); + assets.extend(qsa::fused_prelude::assets(policy.qsa.fused_prelude)); } if self.moe.is_some() { assets.extend(moe::assets()); @@ -185,7 +186,7 @@ impl<'a, 'ctx> OriginalVerifyWindowResources<'a, 'ctx> { Ok(()) } } -impl WindowWeights for OriginalVerifyWindowResources<'_, '_> { +impl WindowWeights for OriginalVerifyWindowResources<'_> { fn gdn_projections(&self, gdn: usize) -> Result { let p = self.proj.as_ref().ok_or(unattached!("mmvq", "projection weights"))?; p.gdn_addrs(self.base.journal.context(), &self.base.journal.geometry(), gdn) @@ -211,7 +212,7 @@ impl WindowWeights for OriginalVerifyWindowResources<'_, '_> { Ok(QsaLayerAddrs { weights: b.addrs(q)?, kv }) } fn rope(&self) -> Result { - QsaRope::from_rope(&self.base.qsa.rope()) + QsaRope::from_rope(self.base.qsa.rope()) } fn moe(&self, layer: usize) -> Result { self.moe.as_ref().ok_or(unattached!("router", "router / shared-expert weights"))?.addrs(layer) @@ -220,22 +221,22 @@ impl WindowWeights for OriginalVerifyWindowResources<'_, '_> { Ok(self.moe.as_ref().ok_or(unattached!("expert_groups", "routed expert formats"))?.formats()) } } -impl resources::Sealed for OriginalVerifyWindowResources<'_, '_> {} -impl OriginalGraphResources for OriginalVerifyWindowResources<'_, '_> { +impl resources::Sealed for OriginalVerifyWindowResources<'_> {} +impl OriginalGraphResources for OriginalVerifyWindowResources<'_> { fn validate_context(&self, context: &Context<'_>) -> Result<()> { self.base.validate_context(context)?; self.embed.validate_context(context) } } -impl<'ctx> OriginalVerifyGraphResources<'ctx> for OriginalVerifyWindowResources<'_, 'ctx> { - fn verifier_qsa(&self) -> &crate::OriginalVerifyQsaJournal<'_, 'ctx> { +impl<'ctx> OriginalVerifyGraphResources<'ctx> for OriginalVerifyWindowResources<'ctx> { + fn verifier_qsa(&self) -> &crate::OriginalVerifyQsaJournal<'ctx> { self.base.verifier_qsa() } - fn verifier_journal(&self) -> &OriginalVerifyGdnJournal<'_, 'ctx> { + fn verifier_journal(&self) -> &OriginalVerifyGdnJournal<'ctx> { self.base.verifier_journal() } } -impl<'ctx> OriginalNativeHeadGraphResources<'ctx> for OriginalVerifyWindowResources<'_, 'ctx> { +impl<'ctx> OriginalNativeHeadGraphResources<'ctx> for OriginalVerifyWindowResources<'ctx> { fn native_head_rows(&self) -> Result<&crate::OriginalNativeHeadRows<'ctx>> { self.base.native_head_rows() } diff --git a/crates/cuda-driver/src/original_verify_window_ops/gdn_stages.rs b/crates/cuda-driver/src/original_verify_window_ops/gdn_stages.rs new file mode 100644 index 00000000..4a92b51d --- /dev/null +++ b/crates/cuda-driver/src/original_verify_window_ops/gdn_stages.rs @@ -0,0 +1,57 @@ +//! claude/verify-gdn-fused-kernels: what the three GDN `WindowOps` calls of a layer record +//! (`GdnFusedPolicy::stages`, `original_verify_window_gdn_fused.rs`). With both switches off every call records the +//! Original's kernel as before. + +use super::gdn_fused::{GdnStages, GdnStep}; +#[allow(unused_imports)] +use super::*; + +impl OriginalVerifyWindowOps<'_, '_, '_> { + fn gdn_stages(&self) -> GdnStages { + self.gdn.stages(self.side_gdn()) + } + + /// The Original's kernel (or the chain kernel) of one GDN stage. + fn gdn_original_stage(&mut self, stage: OriginalVerifyGdnStage, layer: usize, rows: Rows) -> Result<()> { + self.resources.base.journal.capture_layer_stage(stage, self.capture, layer, rows.begin..rows.end) + } + + /// The a/b gates as a kernel of their own: the Original's, or the unrolled one of `GDN_AB_UNROLL`. Used by the + /// ordinary call and by the side-stream branch. + pub(super) fn gdn_alpha_beta_kernel(&mut self, layer: usize, rows: Rows) -> Result<()> { + match self.gdn.separate_ab() { + GdnStep::AbUnrolled => { + self.resources.base.journal.capture_ab_unrolled(self.capture, layer, rows.begin..rows.end) + } + _ => self.gdn_original_stage(OriginalVerifyGdnStage::AlphaBeta, layer, rows), + } + } + + pub(super) fn gdn_conv_stage(&mut self, layer: usize, rows: Rows) -> Result<()> { + match self.gdn_stages().conv { + GdnStep::Skip => Ok(()), // the fused launch convolves + _ => self.gdn_original_stage(OriginalVerifyGdnStage::Conv, layer, rows), + } + } + + pub(super) fn gdn_alpha_beta_stage(&mut self, layer: usize, rows: Rows) -> Result<()> { + match self.gdn_stages().alpha_beta { + GdnStep::Skip => Ok(()), // issued on side stream 0 by `issue_gdn_side`, or computed by the fused launch + _ => self.gdn_alpha_beta_kernel(layer, rows), + } + } + + pub(super) fn gdn_recurrence_stage(&mut self, layer: usize, rows: Rows) -> Result<()> { + if self.side_gdn() { + // the recurrence reads the gates and the gate projection: the capture stream joins both branches + self.capture.side_join(0)?; + self.capture.side_join(1)?; + } + match self.gdn_stages().recurrence { + GdnStep::Fused(gates) => { + self.resources.base.journal.capture_fused_recurrence(self.capture, layer, rows.begin..rows.end, gates) + } + _ => self.gdn_original_stage(OriginalVerifyGdnStage::Recurrence, layer, rows), + } + } +} diff --git a/crates/cuda-driver/src/original_verify_window_ops/original_verifier.rs b/crates/cuda-driver/src/original_verify_window_ops/original_verifier.rs index 3875dce3..b074e63d 100644 --- a/crates/cuda-driver/src/original_verify_window_ops/original_verifier.rs +++ b/crates/cuda-driver/src/original_verify_window_ops/original_verifier.rs @@ -3,13 +3,13 @@ #[allow(unused_imports)] use super::*; -impl<'a, 'ctx> OriginalVerifier<'ctx, OriginalVerifyWindowResources<'a, 'ctx>> { +impl<'ctx> OriginalVerifier<'ctx, OriginalVerifyWindowResources<'ctx>> { /// Record the T-token window graph for `t` (split windows use two groups). /// `resources` is this graph's own aggregate (its head rows hold `t` rows). pub fn record_literal_window( &mut self, t: usize, - resources: OriginalVerifyWindowResources<'a, 'ctx>, + resources: OriginalVerifyWindowResources<'ctx>, policy: WindowPolicy, ) -> Result<()> { policy.validate_selected()?; @@ -25,11 +25,12 @@ impl<'a, 'ctx> OriginalVerifier<'ctx, OriginalVerifyWindowResources<'a, 'ctx>> { // Sealed modules load before capture begins (cuModuleLoadData is not a capturable call). let mut resources = resources; resources.prepare(&policy)?; + let gdn = gdn_fused::prepare(resources.verifier_journal())?; // SIDE_MIXER: this recording's capture creates the two side streams (a split window just leaves them unused) crate::original_gpu_schedule::set_side_streams_wanted(policy.side.any()); let recorded = self.record_window(t, resources, |capture, resources, groups| { // The recorder re-validates the shape; the groups come from `set_split`. - let mut ops = OriginalVerifyWindowOps { capture, resources, t, groups, policy }; + let mut ops = OriginalVerifyWindowOps { capture, resources, t, groups, policy, gdn }; record_window(&mut ops, &policy, t, groups, ple) }); crate::original_gpu_schedule::set_side_streams_wanted(false); @@ -42,8 +43,8 @@ impl<'a, 'ctx> OriginalVerifier<'ctx, OriginalVerifyWindowResources<'a, 'ctx>> { pub fn record_all( &mut self, policy: WindowPolicy, - mut window: impl FnMut(usize) -> Result>, - commit: OriginalVerifyWindowResources<'a, 'ctx>, + mut window: impl FnMut(usize) -> Result>, + commit: OriginalVerifyWindowResources<'ctx>, ) -> Result<()> { policy.validate_selected()?; let max_t = self.bank()?.geometry().max_t; @@ -57,7 +58,7 @@ impl<'a, 'ctx> OriginalVerifier<'ctx, OriginalVerifyWindowResources<'a, 'ctx>> { } /// The cluster top-k needs sm_90+ and a sealed module; anything else keeps the Original's qsa_topk_ref. -fn resolve_cluster_topk(resources: &OriginalVerifyWindowResources<'_, '_>, policy: &mut WindowPolicy) -> Result<()> { +fn resolve_cluster_topk(resources: &OriginalVerifyWindowResources<'_>, policy: &mut WindowPolicy) -> Result<()> { if policy.qsa.cluster_topk { let cc = resources.verifier_journal().window_device_attribute(gr::ATTR_COMPUTE_CAPABILITY_MAJOR)?; policy.qsa.cluster_topk = cc >= 9 && qsa::CLUSTER.sealed().is_ok(); @@ -74,13 +75,17 @@ fn resolve_cluster_topk(resources: &OriginalVerifyWindowResources<'_, '_>, polic /// The sm_120 decode switches (original_verify_window_sm120.rs): resolved from the card and the environment, once per /// recording. -fn resolve_sm120_switches(resources: &OriginalVerifyWindowResources<'_, '_>, policy: &mut WindowPolicy) -> Result<()> { +fn resolve_sm120_switches(resources: &OriginalVerifyWindowResources<'_>, policy: &mut WindowPolicy) -> Result<()> { let major = resources.verifier_journal().window_device_attribute(gr::ATTR_COMPUTE_CAPABILITY_MAJOR)?; let minor = resources.verifier_journal().window_device_attribute(gr::ATTR_COMPUTE_CAPABILITY_MINOR)?; let want = sm120::Sm120Switches::from_env(major, minor); policy.qsa.attn_daily = (policy.qsa.attn_daily || want.attn_daily) && sm120::ATTN_DAILY.sealed().is_ok(); policy.gu_swiglu = (policy.gu_swiglu || want.gu_swiglu) && sm120::GU_SWIGLU.sealed().is_ok(); policy.side = policy.side.union(want.side_branches()); + // ACCEPT_ON_DEVICE: marks the head rows of THIS graph (each T has its own); `OriginalVerifyWindowOps::head` records + // the finite scan after the pick and the post-drain check reads its verdict word instead of scanning + resources.base.head.set_finite_verdict_in_graph(want.accept_on_device); + policy.qsa.fused_prelude = qsa::fused_prelude::resolve(policy.qsa.fused_prelude || want.fused_qsa_prelude); static SAID: std::sync::Once = std::sync::Once::new(); SAID.call_once(|| { eprintln!( @@ -94,7 +99,7 @@ fn resolve_sm120_switches(resources: &OriginalVerifyWindowResources<'_, '_>, pol /// The per-layer gate/up/down role bytes of the experts for the copy-kernel pcie mode 2, else none. fn pcie_role_bytes( - resources: &OriginalVerifyWindowResources<'_, '_>, + resources: &OriginalVerifyWindowResources<'_>, pcie_mode: u8, ) -> Result> { if pcie_mode != 2 { diff --git a/crates/cuda-driver/src/original_verify_window_ops/original_verify_window_ops_methods.rs b/crates/cuda-driver/src/original_verify_window_ops/original_verify_window_ops_methods.rs index 44cac3c4..3d2e6946 100644 --- a/crates/cuda-driver/src/original_verify_window_ops/original_verify_window_ops_methods.rs +++ b/crates/cuda-driver/src/original_verify_window_ops/original_verify_window_ops_methods.rs @@ -3,7 +3,7 @@ #[allow(unused_imports)] use super::*; -impl<'a, 'ctx> OriginalVerifyWindowOps<'_, '_, 'a, 'ctx> { +impl<'ctx> OriginalVerifyWindowOps<'_, '_, 'ctx> { /// SIDE_MIXER (upstream `STRATA_SIDE_MIXER=2`, GDN part): the GDN gates and the gate projection run on side /// streams of the window's graph. Not in a split window (two row groups), as upstream. pub(super) fn side_gdn(&self) -> bool { @@ -16,12 +16,7 @@ impl<'a, 'ctx> OriginalVerifyWindowOps<'_, '_, 'a, 'ctx> { pub(super) fn issue_gdn_side(&mut self, layer: usize, rows: Rows) -> Result<()> { let g = gdn_index(layer).ok_or(Error::InvalidQwenShape)?; self.capture.side_fork(0)?; - self.resources.base.journal.capture_layer_stage( - OriginalVerifyGdnStage::AlphaBeta, - self.capture, - g, - rows.begin..rows.end, - )?; + self.gdn_alpha_beta_kernel(g, rows)?; self.capture.side_end(0)?; self.capture.side_fork(1)?; self.plan_launch(|p| p.mmvq(layer, Projection::GdnGate, rows))?; @@ -66,7 +61,7 @@ impl<'a, 'ctx> OriginalVerifyWindowOps<'_, '_, 'a, 'ctx> { pub(super) fn plan_group_offset(&self, group: usize) -> usize { group * self.plan().device_stride() * 4 } - pub(super) fn journal(&self) -> &OriginalVerifyGdnJournal<'a, 'ctx> { + pub(super) fn journal(&self) -> &OriginalVerifyGdnJournal<'ctx> { &self.resources.base.journal } pub(super) fn submit(&mut self, commands: Vec) -> Result<()> { diff --git a/crates/cuda-driver/src/original_verify_window_ops/qsa_prelude_ops.rs b/crates/cuda-driver/src/original_verify_window_ops/qsa_prelude_ops.rs new file mode 100644 index 00000000..4d583153 --- /dev/null +++ b/crates/cuda-driver/src/original_verify_window_ops/qsa_prelude_ops.rs @@ -0,0 +1,26 @@ +//! `LELEKA_SM120_FUSED_QSA_PRELUDE`, indexer half: the tail snapshot and the row appends of a QSA layer index image +//! as the one launch `leleka_verify_qsa_index_rows` (`qsa/fused_prelude.rs`). The K/V half is a planner plan +//! (`QsaWindow::kv_rows`) and needs no journal. +//! +//! The launch sits where `capture_append_rows` of the journal sits (after the K/V append in the in-line order, +//! inside the indexer chain on the side stream with `SIDE_QSA`), and the snapshot that precedes the first row in the +//! literal order is its first step, so the order the side branches rely on is unchanged. + +#[allow(unused_imports)] +use super::*; +use qsa::fused_prelude::IndexImage; + +impl<'ctx> OriginalVerifyWindowOps<'_, '_, 'ctx> { + /// The index image of QSA layer `q` when this window fuses the indexer rows: the switch is on and the retained + /// RoPE is the analytic variant (the table variant keeps the per-row launches). + pub(super) fn fused_index_image(&self, q: usize) -> Result> { + if !self.policy.qsa.fused_prelude { + return Ok(None); + } + self.resources.base.qsa.index_image(&self.resources.base.journal, q) + } + /// Record the snapshot (first row group) and the append of `rows` as one launch on the current stream. + pub(super) fn issue_index_rows(&mut self, q: usize, rows: Rows, image: IndexImage) -> Result<()> { + self.plan_launch(|p| p.qsa_index_rows(q, rows, &image)) + } +} diff --git a/crates/cuda-driver/src/original_verify_window_ops/side_qsa_branches.rs b/crates/cuda-driver/src/original_verify_window_ops/side_qsa_branches.rs index c9671c44..52b1ad71 100644 --- a/crates/cuda-driver/src/original_verify_window_ops/side_qsa_branches.rs +++ b/crates/cuda-driver/src/original_verify_window_ops/side_qsa_branches.rs @@ -21,7 +21,7 @@ pub(super) struct QsaSideLayer { pub(super) batched: bool, } -impl<'a, 'ctx> OriginalVerifyWindowOps<'_, '_, 'a, 'ctx> { +impl<'ctx> OriginalVerifyWindowOps<'_, '_, 'ctx> { /// The QSA layers run their indexer and query chains on side streams (not in a split window, as upstream). pub(super) fn side_qsa(&self) -> bool { self.policy.side.qsa && self.groups == 1 && self.capture.has_side() @@ -39,9 +39,13 @@ impl<'a, 'ctx> OriginalVerifyWindowOps<'_, '_, 'a, 'ctx> { fn issue_indexer_chain(&mut self, layer: QsaSideLayer) -> Result<()> { let QsaSideLayer { q, rows, batched } = layer; self.plan_launch(|p| p.qsa_index_k(q, rows, batched))?; - let base = &self.resources.base; - base.qsa.capture_tail_snapshot(&base.journal, self.capture, q)?; - base.qsa.capture_append_rows(&base.journal, self.capture, q, rows.begin..rows.end)?; + if let Some(image) = self.fused_index_image(q)? { + self.issue_index_rows(q, rows, image)?; + } else { + let base = &self.resources.base; + base.qsa.capture_tail_snapshot(&base.journal, self.capture, q)?; + base.qsa.capture_append_rows(&base.journal, self.capture, q, rows.begin..rows.end)?; + } self.plan_launch(|p| p.qsa_index_q_path(q, rows, batched))?; self.plan_launch(|p| p.qsa_block_scores_topk(q, rows)) } diff --git a/crates/cuda-driver/src/original_verify_window_ops/side_shared_expert.rs b/crates/cuda-driver/src/original_verify_window_ops/side_shared_expert.rs index 018aba57..6ea53239 100644 --- a/crates/cuda-driver/src/original_verify_window_ops/side_shared_expert.rs +++ b/crates/cuda-driver/src/original_verify_window_ops/side_shared_expert.rs @@ -11,7 +11,7 @@ #[allow(unused_imports)] use super::*; -impl<'a, 'ctx> OriginalVerifyWindowOps<'_, '_, 'a, 'ctx> { +impl<'ctx> OriginalVerifyWindowOps<'_, '_, 'ctx> { /// The shared expert runs on side stream 0 (not in a split window, as the other side branches). pub(super) fn side_shared(&self) -> bool { self.policy.side.shared_expert && self.groups == 1 && self.capture.has_side() diff --git a/crates/cuda-driver/src/original_verify_window_ops/window_ops_kernels_and_pcie_plan.rs b/crates/cuda-driver/src/original_verify_window_ops/window_ops_kernels_and_pcie_plan.rs index 98cb5dcc..1718dace 100644 --- a/crates/cuda-driver/src/original_verify_window_ops/window_ops_kernels_and_pcie_plan.rs +++ b/crates/cuda-driver/src/original_verify_window_ops/window_ops_kernels_and_pcie_plan.rs @@ -5,7 +5,7 @@ use super::side_qsa_branches::QsaSideLayer; #[allow(unused_imports)] use super::*; -impl WindowOps for OriginalVerifyWindowOps<'_, '_, '_, '_> { +impl WindowOps for OriginalVerifyWindowOps<'_, '_, '_> { fn embed(&mut self) -> Result<()> { self.embed_stage_tokens()?; self.resources.embed.capture(self.capture)?; @@ -51,36 +51,13 @@ impl WindowOps for OriginalVerifyWindowOps<'_, '_, '_, '_> { self.plan_launch(|p| p.mmvq(layer, projection, rows)) } fn gdn_conv(&mut self, layer: usize, rows: Rows) -> Result<()> { - self.resources.base.journal.capture_layer_stage( - OriginalVerifyGdnStage::Conv, - self.capture, - layer, - rows.begin..rows.end, - ) + self.gdn_conv_stage(layer, rows) } fn gdn_alpha_beta(&mut self, layer: usize, rows: Rows) -> Result<()> { - if self.side_gdn() { - return Ok(()); // issued on side stream 0 by `issue_gdn_side` - } - self.resources.base.journal.capture_layer_stage( - OriginalVerifyGdnStage::AlphaBeta, - self.capture, - layer, - rows.begin..rows.end, - ) + self.gdn_alpha_beta_stage(layer, rows) } fn gdn_recurrence(&mut self, layer: usize, rows: Rows) -> Result<()> { - if self.side_gdn() { - // the recurrence reads the gates and the gate projection: the capture stream joins both branches - self.capture.side_join(0)?; - self.capture.side_join(1)?; - } - self.resources.base.journal.capture_layer_stage( - OriginalVerifyGdnStage::Recurrence, - self.capture, - layer, - rows.begin..rows.end, - ) + self.gdn_recurrence_stage(layer, rows) } fn qsa_index_k(&mut self, q: usize, rows: Rows, batched: bool) -> Result<()> { if self.side_qsa() { @@ -97,6 +74,9 @@ impl WindowOps for OriginalVerifyWindowOps<'_, '_, '_, '_> { if self.side_qsa() { return Ok(()); // issued on side stream 0 by `issue_qsa_side` } + if self.fused_index_image(layer)?.is_some() { + return Ok(()); // the snapshot is the first step of the fused indexer launch of `qsa_indexer_append` + } let base = &self.resources.base; base.qsa.capture_tail_snapshot(&base.journal, self.capture, layer) } @@ -107,6 +87,9 @@ impl WindowOps for OriginalVerifyWindowOps<'_, '_, '_, '_> { if self.side_qsa() { return Ok(()); // issued on side stream 0 by `issue_qsa_side` } + if let Some(image) = self.fused_index_image(layer)? { + return self.issue_index_rows(layer, rows, image); + } let base = &self.resources.base; base.qsa.capture_append_rows(&base.journal, self.capture, layer, rows.begin..rows.end) } @@ -241,11 +224,26 @@ impl WindowOps for OriginalVerifyWindowOps<'_, '_, '_, '_> { // quantize ALL T, native MMVQ ALL T, greedy argmax (`capture_head_greedy`). let mixed = handle(self.resources.base.head.mixed_mut()?)?.qwen_address(); self.plan_launch(|p| p.head_mix(mixed, rows))?; - self.resources.base.head.capture_head_greedy(self.capture) + self.resources.base.head.capture_head_greedy(self.capture)?; + self.capture_finite_verdict() } } -impl OriginalVerifyWindowOps<'_, '_, '_, '_> { +impl OriginalVerifyWindowOps<'_, '_, '_> { + /// `LELEKA_SM120_ACCEPT_ON_DEVICE`: after the greedy pick, the finite scan of the logits and the store of its + /// verdict into the head rows' mapped word, as the last nodes of the graph (vanilla's order, `verify.cpp:2380`). + /// Recorded only when `resolve_sm120_switches` marked the head rows of this graph; the literal graph records + /// nothing here and the scan then runs after the drain. Nothing before the pick changes. + fn capture_finite_verdict(&mut self) -> Result<()> { + let head = &self.resources.base.head; + if !head.finite_verdict_in_graph() { + return Ok(()); + } + let (rows, verdict) = (head.rows(), head.finite_verdict_address()?); + let logits = head.completed_logits()?; + self.resources.verifier_journal().capture_finite_verdict(self.capture, logits, (rows, verdict)) + } + /// Device block and mapped source of this group's GPU plan words. fn plan_copy_addresses(&self, rows: Rows) -> Result<(u64, u64)> { let layout = self.plan(); diff --git a/crates/cuda-driver/src/original_verify_window_planner.rs b/crates/cuda-driver/src/original_verify_window_planner.rs index f0a7e6b7..aed6406e 100644 --- a/crates/cuda-driver/src/original_verify_window_planner.rs +++ b/crates/cuda-driver/src/original_verify_window_planner.rs @@ -10,7 +10,7 @@ use super::gr::{self, GrConfig, HcAddrs, HeadAddrs, PleAddrs, PleConfig}; use super::kernels::{ArenaMap, Launch}; use super::moe::{self, MoeKnobs, MoeLayerAddrs, OriginalVerifyExpertFormats}; use super::proj::{self, GdnProjectionAddrs, QsaProjectionAddrs}; -use super::qsa::{QsaLayerAddrs, QsaRope, QsaWindow}; +use super::qsa::{QsaLayerAddrs, QsaRope, QsaWindow, fused_prelude::IndexImage}; use super::window_plan::{gdn_index, qsa_index}; use super::window_record::{ExpertTier, HcHalf, Projection, QuantSource, Rows, WindowPolicy}; use crate::{Error, Result}; @@ -135,6 +135,10 @@ impl<'p> Planner<'p> { pub(crate) fn qsa_kv_append(&self, q: usize, rows: Rows) -> Result> { self.qsa_window()?.kv_append(q, &self.weights.qsa(q)?, rows) } + /// `LELEKA_SM120_FUSED_QSA_PRELUDE`: the layer's tail snapshot and indexer append rows as one launch. + pub(crate) fn qsa_index_rows(&self, q: usize, rows: Rows, image: &IndexImage) -> Result> { + Ok(vec![self.qsa_window()?.index_rows(q, image, rows)?]) + } pub(crate) fn qsa_q_path(&self, q: usize, rows: Rows, batched: bool) -> Result> { self.qsa_window()?.q_path(q, &self.weights.qsa(q)?, rows, batched) } diff --git a/crates/cuda-driver/src/original_verify_window_planner/tests.rs b/crates/cuda-driver/src/original_verify_window_planner/tests.rs index 78d983ff..f6277e07 100644 --- a/crates/cuda-driver/src/original_verify_window_planner/tests.rs +++ b/crates/cuda-driver/src/original_verify_window_planner/tests.rs @@ -4,6 +4,7 @@ use super::super::kernels::{LayoutMap, test_geometry}; use super::super::moe::MoeLayerAddrs; use super::super::proj::NativeWeight; use super::super::qsa::{OriginalVerifyQsaKvBinding, QsaWeightAddrs, RopeCorrectionRange}; +use super::super::qsa::fused_prelude::{IndexImage, IndexRope}; use super::super::window_plan::WINDOW_LAYERS; use super::super::window_record::{WindowOps, record_window}; use super::*; @@ -50,6 +51,21 @@ fn fake_qsa_kv(b: u64) -> OriginalVerifyQsaKvBinding { } } +/// The retained index image of QSA layer `q` (distinct addresses, analytic RoPE). +fn fake_index_image(q: usize) -> IndexImage { + let b = 0x70_0000_0000u64 + q as u64 * 0x1000_0000; + let rope = IndexRope { + theta_scale: 0.75, + freq_scale: 1.0, + corr_low: 0.0, + corr_high: 0.0, + ext_factor: 0.0, + magnitude: 1.0, + }; + let (tail, dead, pooled, block_pos, gamma) = (b, b + 0x1000, b + 0x2000, b + 0x3000, b + 0x4000); + IndexImage { tail, dead, pooled, block_pos, gamma, positions: 0, rope } +} + impl WindowWeights for Fake { fn gdn_projections(&self, g: usize) -> Result { let b = 0x10_0000_0000u64 + g as u64 * 0x1000_0000; @@ -201,13 +217,20 @@ impl WindowOps for PlanOps<'_> { self.plan("k_norm_rope", x) } fn qsa_tail_snapshot(&mut self, q: usize) -> Result<()> { + if self.planner.policy.qsa.fused_prelude { + return Ok(()); // the first step of the fused indexer launch + } self.mark(format!("tail q{q}")) } fn qsa_kv_append(&mut self, q: usize, r: Rows) -> Result<()> { let x = self.planner.qsa_kv_append(q, r); self.plan("kv_append", x) } - fn qsa_indexer_append(&mut self, q: usize, _: Rows) -> Result<()> { + fn qsa_indexer_append(&mut self, q: usize, r: Rows) -> Result<()> { + if self.planner.policy.qsa.fused_prelude { + let x = self.planner.qsa_index_rows(q, r, &fake_index_image(q)); + return self.plan("index_rows", x); + } self.mark(format!("indexer_append q{q}")) } fn qsa_q_path(&mut self, q: usize, r: Rows, b: bool) -> Result<()> { @@ -318,3 +341,5 @@ fn names(log: &[String]) -> Vec<&str> { #[path = "tests/every_window_size_and_group.rs"] mod every_window_size_and_group; +#[path = "tests/fused_qsa_prelude.rs"] +mod fused_qsa_prelude; diff --git a/crates/cuda-driver/src/original_verify_window_planner/tests/fused_qsa_prelude.rs b/crates/cuda-driver/src/original_verify_window_planner/tests/fused_qsa_prelude.rs new file mode 100644 index 00000000..3fac403d --- /dev/null +++ b/crates/cuda-driver/src/original_verify_window_planner/tests/fused_qsa_prelude.rs @@ -0,0 +1,145 @@ +//! `LELEKA_SM120_FUSED_QSA_PRELUDE` through the recorder: the launch sequence with the switch on has fewer +//! launches, and the two fused launches bind exactly the cells the replaced launches write. + +use super::super::super::kernels::A; +use super::super::super::window_plan::qsa_layer; +#[allow(unused_imports)] +use super::*; + +fn policy_with(fused: bool) -> WindowPolicy { + let mut policy = WindowPolicy::mode17(); + policy.qsa.fused_prelude = fused; + policy +} +fn record_with(fused: bool, t: usize, groups: usize) -> Vec { + let (m, fake) = geometry_and_fake(false); + let policy = policy_with(fused); + let planner = Planner::new(&m, test_geometry(), policy, sm120(), &fake); + let mut ops = PlanOps { planner, log: Vec::new(), t }; + record_window(&mut ops, &policy, t, groups, false).unwrap(); + ops.log +} +fn prelude(log: &[String], q: usize) -> Vec<&str> { + let l = qsa_layer(q); + names(section(log, &format!("stamp {l}.8"), &format!("stamp {l}.9"))) +} +fn words(l: &Launch) -> &[u64] { + match l.args.as_slice() { + [A::Words(w)] => w, + other => panic!("one by-value struct expected, got {other:?}"), + } +} +fn address(a: &A) -> u64 { + match a { + A::P(p) => *p, + other => panic!("address expected, got {other:?}"), + } +} + +#[test] +fn the_default_window_keeps_one_launch_per_row_and_the_snapshot() { + let log = record_with(false, 4, 1); + assert_eq!(log, record(4, 1, false)); + assert_eq!(prelude(&log, 0).iter().filter(|s| **s == "mtp_original_append").count(), 4); + assert!(prelude(&log, 0).contains(&"tail q0") && prelude(&log, 0).contains(&"indexer_append q0")); + assert!(!log.iter().any(|s| s.starts_with("leleka_verify_qsa_"))); +} + +#[test] +fn the_switch_replaces_the_prelude_of_every_layer_by_two_launches() { + for t in [1usize, 2, 4, 8] { + let on = record_with(true, t, 1); + let off = record_with(false, t, 1); + for q in 0..12 { + let kernels: Vec<&str> = + prelude(&on, q).into_iter().filter(|s| s.starts_with("leleka_verify_qsa_")).collect(); + assert_eq!(kernels, ["leleka_verify_qsa_kv_rows", "leleka_verify_qsa_index_rows"], "t={t} q={q}"); + let replaced = prelude(&off, q).into_iter().filter(|s| *s == "mtp_original_append").count() + 1 + t; + assert_eq!(replaced, 2 * t + 1, "snapshot + t K/V appends + t indexer appends"); + } + assert_eq!(on.iter().filter(|s| s.starts_with("leleka_verify_qsa_")).count(), 24); + let literal = |s: &String| s == "mtp_original_append" || s.starts_with("tail q"); + assert!(!on.iter().any(literal) && !on.iter().any(|s| s.starts_with("indexer_append"))); + } +} + +/// The recorded entries that belong to the prelude, whichever way it is recorded. +fn is_prelude_entry(s: &str) -> bool { + s.starts_with("leleka_verify_qsa_") + || s == "mtp_original_append" + || s.starts_with("tail q") + || s.starts_with("indexer_append") + || s.contains("index_rows") + || s.contains("kv_append") +} + +#[test] +fn the_switch_changes_nothing_outside_the_prelude() { + for t in [1usize, 2, 4, 8] { + let strip = |l: Vec| l.into_iter().filter(|s| !is_prelude_entry(s)).collect::>(); + assert_eq!(strip(record_with(true, t, 1)), strip(record_with(false, t, 1)), "t={t}"); + } +} + +#[test] +fn a_split_window_snapshots_once_per_layer_and_appends_every_row_once() { + let on = record_with(true, 5, 2); + assert_eq!(on.iter().filter(|s| *s == "leleka_verify_qsa_index_rows").count(), 24); + assert_eq!(on.iter().filter(|s| *s == "leleka_verify_qsa_kv_rows").count(), 24); + assert!(!on.iter().any(|s| s.starts_with("tail q"))); +} + +fn planners(fused: bool) -> (LayoutMap, Fake, WindowPolicy) { + let (m, fake) = geometry_and_fake(false); + (m, fake, policy_with(fused)) +} + +#[test] +fn the_fused_kv_launch_binds_the_cells_of_the_per_row_launches() { + let (m, fake, off) = planners(false); + let (_, _, on) = planners(true); + let per_row = Planner::new(&m, test_geometry(), off, sm120(), &fake); + let fused = Planner::new(&m, test_geometry(), on, sm120(), &fake); + let row_bytes = 2 * 256 * 4; + for rows in + [Rows { begin: 0, end: 4, group: 0 }, Rows { begin: 2, end: 5, group: 1 }, Rows { begin: 7, end: 8, group: 1 }] + { + let literal = per_row.qsa_kv_append(1, rows).unwrap(); + let one = fused.qsa_kv_append(1, rows).unwrap(); + assert_eq!((literal.len(), one.len()), (rows.len(), 1)); + let w = words(&one[0]); + assert_eq!(one[0].grid, [(rows.len() * 2 * 2) as u32, 1, 1]); + for (j, l) in literal.iter().enumerate() { + let a: Vec = l.args.iter().take(8).map(address).collect(); + assert_eq!(a[..5], w[..5], "resident pools and page table"); + assert_eq!(a[5], w[9] + 16 * j as u64, "step row {j}"); + assert_eq!(a[6], w[10] + (row_bytes * j) as u64, "K row {j}"); + assert_eq!(a[7], w[11] + (row_bytes * j) as u64, "V row {j}"); + let host: Vec = l.args[11..].iter().map(address).collect(); + assert_eq!(host, w[5..9]); + } + assert_eq!(w[14] >> 32, rows.len() as u64); + } +} + +#[test] +fn the_fused_index_launch_binds_the_rows_the_journal_appends_one_by_one() { + let (m, fake, on) = planners(true); + let planner = Planner::new(&m, test_geometry(), on, sm120(), &fake); + for (q, rows) in [(0, Rows { begin: 0, end: 4, group: 0 }), (11, Rows { begin: 3, end: 8, group: 1 })] { + let image = fake_index_image(q); + let one = planner.qsa_index_rows(q, rows, &image).unwrap(); + assert_eq!(one.len(), 1); + let w = words(&one[0]); + for (j, row) in (rows.begin..rows.end).enumerate() { + // `append_command`: raw = idx_raw_L + (layer * max_t + row) * 512, step = step + row * 16 + let raw = m.span("idx_raw_L", (q * 8 + row) * 512, 512).unwrap(); + let step = m.span("step", row * 16, 4).unwrap(); + assert_eq!((w[0] + 512 * j as u64, w[1] + 16 * j as u64), (raw, step), "row {row}"); + } + assert_eq!(&w[2..8], &[image.tail, image.dead, image.pooled, image.block_pos, image.gamma, 0]); + // the snapshot (verify_copy_from_mapped_kernel into tail_snap + layer * 1536) only before the first group + let snapshot = if rows.group == 0 { m.span("tail_snap", q * 1536, 1536).unwrap() } else { 0 }; + assert_eq!((w[8], w[9], w[10]), (snapshot, rows.len() as u64, 4096)); + } +} diff --git a/crates/cuda-driver/src/original_verify_window_proj.rs b/crates/cuda-driver/src/original_verify_window_proj.rs index 76eda1d0..51d4ef43 100644 --- a/crates/cuda-driver/src/original_verify_window_proj.rs +++ b/crates/cuda-driver/src/original_verify_window_proj.rs @@ -15,7 +15,7 @@ use super::kernels::{A, ArenaMap, AssetSpec, Launch, LaunchExtent}; use super::window_plan::{gdn_index, qsa_index}; use super::window_record::{Projection, QuantSource, Rows}; use crate::native_head::native_head_row_bytes; -use crate::{Context, DeviceBuffer}; +use crate::{Context, DeviceRef}; use crate::{Error, NativeHeadDispatch, Result}; #[path = "mtp_original_full_head_dispatch.rs"] diff --git a/crates/cuda-driver/src/original_verify_window_proj/admit_matrix.rs b/crates/cuda-driver/src/original_verify_window_proj/admit_matrix.rs index 3b9f4459..47a9ad29 100644 --- a/crates/cuda-driver/src/original_verify_window_proj/admit_matrix.rs +++ b/crates/cuda-driver/src/original_verify_window_proj/admit_matrix.rs @@ -5,19 +5,19 @@ use super::*; pub(super) fn admit_matrix( context: &Context<'_>, - m: &OriginalVerifyNativeMatrix<'_, '_>, + m: &OriginalVerifyNativeMatrix<'_>, n_in: usize, n_out: usize, ) -> Result { let bytes = native_matrix_bytes(m.kind, n_in, n_out)?; - Ok(NativeWeight { ty: m.kind, data: super::super::admit(context, m.buffer, bytes)? }) + Ok(NativeWeight { ty: m.kind, data: super::super::admit(context, &m.buffer, bytes)? }) } -impl<'a, 'ctx> OriginalVerifyProjBinding<'a, 'ctx> { +impl<'ctx> OriginalVerifyProjBinding<'ctx> { pub fn new( context: &'ctx Context<'ctx>, geometry: &OriginalVerifyGeometry, - gdn: Vec>, - qsa: Vec>, + gdn: Vec>, + qsa: Vec>, ) -> Result { if gdn.len() != 36 || qsa.len() != 12 { return Err(Error::InvalidQwenShape); diff --git a/crates/cuda-driver/src/original_verify_window_proj/head_iq_entries_types.rs b/crates/cuda-driver/src/original_verify_window_proj/head_iq_entries_types.rs index a1c9a0ef..97f0fd5d 100644 --- a/crates/cuda-driver/src/original_verify_window_proj/head_iq_entries_types.rs +++ b/crates/cuda-driver/src/original_verify_window_proj/head_iq_entries_types.rs @@ -151,22 +151,22 @@ pub(crate) struct NativeWeight { } /// One native projection weight with its buffer, as the runtime hands it over. -pub struct OriginalVerifyNativeMatrix<'a, 'ctx> { +pub struct OriginalVerifyNativeMatrix<'ctx> { pub kind: u32, - pub buffer: &'a DeviceBuffer<'ctx>, + pub buffer: DeviceRef<'ctx>, } /// `attn_qkv.weight`, `attn_gate.weight`, `ssm_out.weight` of one GDN layer. -pub struct OriginalVerifyGdnProjections<'a, 'ctx> { - pub qkv: OriginalVerifyNativeMatrix<'a, 'ctx>, - pub gate: OriginalVerifyNativeMatrix<'a, 'ctx>, - pub out: OriginalVerifyNativeMatrix<'a, 'ctx>, +pub struct OriginalVerifyGdnProjections<'ctx> { + pub qkv: OriginalVerifyNativeMatrix<'ctx>, + pub gate: OriginalVerifyNativeMatrix<'ctx>, + pub out: OriginalVerifyNativeMatrix<'ctx>, } /// `attn_k.weight`, `attn_v.weight`, `attn_q.weight`, `attn_output.weight` of one QSA layer. -pub struct OriginalVerifyQsaProjections<'a, 'ctx> { - pub k: OriginalVerifyNativeMatrix<'a, 'ctx>, - pub v: OriginalVerifyNativeMatrix<'a, 'ctx>, - pub q: OriginalVerifyNativeMatrix<'a, 'ctx>, - pub out: OriginalVerifyNativeMatrix<'a, 'ctx>, +pub struct OriginalVerifyQsaProjections<'ctx> { + pub k: OriginalVerifyNativeMatrix<'ctx>, + pub v: OriginalVerifyNativeMatrix<'ctx>, + pub q: OriginalVerifyNativeMatrix<'ctx>, + pub out: OriginalVerifyNativeMatrix<'ctx>, } /// Addresses of a GDN layer's projections. #[derive(Clone, Copy, Debug, PartialEq, Eq)] @@ -186,7 +186,7 @@ pub(crate) struct QsaProjectionAddrs { /// The 36 GDN and 12 QSA layers' native projection matrices (the Original `native_of(...)` weights). /// Sizes are exact: `n_out` rows of `native_head_row_bytes(kind, n_in)`. -pub struct OriginalVerifyProjBinding<'a, 'ctx> { - pub(super) gdn: Vec>, - pub(super) qsa: Vec>, +pub struct OriginalVerifyProjBinding<'ctx> { + pub(super) gdn: Vec>, + pub(super) qsa: Vec>, } diff --git a/crates/cuda-driver/src/original_verify_window_qsa.rs b/crates/cuda-driver/src/original_verify_window_qsa.rs index 434d8ad4..e4ad99fd 100644 --- a/crates/cuda-driver/src/original_verify_window_qsa.rs +++ b/crates/cuda-driver/src/original_verify_window_qsa.rs @@ -28,7 +28,7 @@ use super::proj::{self, Bf16GemvExtents, StridedRows, plan_bf16_gemv}; use super::window_record::Rows; use super::{OriginalVerifyGeometry, admit, handle}; use crate::qsa_index_ffi::{RopeAbi, rope_abi}; -use crate::{Context, DeviceBuffer, Error, Result}; +use crate::{Context, DeviceRef, Error, Result}; /// `EPS` of verify.cpp (RMS epsilon of every QSA norm). const EPS: f32 = 1e-6; @@ -181,6 +181,10 @@ pub struct OriginalVerifyQsaPolicy { /// merge as the Original's chunk and merge kernels. Off in `mode17()`; `record_literal_window` resolves it from the /// card and `LELEKA_SM120_ATTN_DAILY`. pub attn_daily: bool, + /// `LELEKA_SM120_FUSED_QSA_PRELUDE` (`fused_prelude.rs`): the K/V rows and the indexer rows + /// (with the tail snapshot) of a layer as one launch each, bitwise the same cells. Off in `mode17()`; + /// `record_literal_window` resolves it from the card, the environment and the seal of its two modules. + pub fused_prelude: bool, } /// The resolved `rope_scaling()` constants of the window (`OriginalVerifyRope` without its tables). @@ -232,17 +236,17 @@ pub struct OriginalVerifyQsaKvBinding { } /// The weights of one QSA layer that the window producers read directly. -pub struct OriginalVerifyQsaLayerWeights<'a, 'ctx> { +pub struct OriginalVerifyQsaLayerWeights<'ctx> { /// `attn_q_norm.weight`, F32 `[head_dim]`. - pub attn_q_norm: &'a DeviceBuffer<'ctx>, + pub attn_q_norm: DeviceRef<'ctx>, /// `attn_k_norm.weight`, F32 `[head_dim]`. - pub attn_k_norm: &'a DeviceBuffer<'ctx>, + pub attn_k_norm: DeviceRef<'ctx>, /// `indexer.q_norm.weight`, F32 `[index_dim]`. - pub index_q_norm: &'a DeviceBuffer<'ctx>, + pub index_q_norm: DeviceRef<'ctx>, /// `indexer.k_proj.weight`, BF16 `[index_dim][n_embd]`. - pub index_k_proj: &'a DeviceBuffer<'ctx>, + pub index_k_proj: DeviceRef<'ctx>, /// `indexer.q_proj.weight`, BF16 `[index_heads * index_dim][n_embd]`. - pub index_q_proj: &'a DeviceBuffer<'ctx>, + pub index_q_proj: DeviceRef<'ctx>, } /// Device addresses of one layer's weights, after byte-exact admission. #[derive(Clone, Copy, Debug, PartialEq, Eq)] @@ -255,10 +259,10 @@ pub struct QsaWeightAddrs { } /// The 12 QSA layers' direct weight operands. The index key norm gamma and the index images live in /// `OriginalVerifyQsaJournal`; the K/V and quantized projections are `proj`/mmvq operands. -pub struct OriginalVerifyQsaBinding<'a, 'ctx> { +pub struct OriginalVerifyQsaBinding<'ctx> { context: &'ctx Context<'ctx>, geometry: OriginalVerifyGeometry, - layers: [OriginalVerifyQsaLayerWeights<'a, 'ctx>; 12], + layers: [OriginalVerifyQsaLayerWeights<'ctx>; 12], } /// Everything one window's QSA plans need: arena, geometry, policy and RoPE constants. @@ -302,5 +306,7 @@ use assets::max_blocks; use assets::scratch_floats; #[allow(unused_imports)] pub(crate) use assets::shared_attributes; +#[path = "original_verify_window_qsa/fused_prelude.rs"] +pub(crate) mod fused_prelude; #[path = "original_verify_window_qsa/qsa_window.rs"] mod qsa_window; diff --git a/crates/cuda-driver/src/original_verify_window_qsa/assets.rs b/crates/cuda-driver/src/original_verify_window_qsa/assets.rs index c751c44b..17c674e1 100644 --- a/crates/cuda-driver/src/original_verify_window_qsa/assets.rs +++ b/crates/cuda-driver/src/original_verify_window_qsa/assets.rs @@ -48,6 +48,7 @@ impl OriginalVerifyQsaPolicy { scores_multi: true, cluster_topk: false, attn_daily: false, + fused_prelude: false, } } /// Refuse every variant that has no genuine sealed owner, with its reason. @@ -99,7 +100,7 @@ impl QsaRope { Ok(Self { theta_scale, freq_scale, corr_low, corr_high, ext_factor, mscale }) } /// From the journal's resolved Original constants. Table variants have no sealed kernel here. - pub fn from_rope(rope: &crate::OriginalVerifyRope<'_, '_>) -> Result { + pub fn from_rope(rope: &crate::OriginalVerifyRope<'_>) -> Result { if rope.positions.is_some() { return Err(refuse!("an M-RoPE position table needs the mtab variant of native_rope (no sealed kernel)")); } @@ -120,7 +121,7 @@ impl QsaRope { } impl OriginalVerifyQsaKvBinding { /// Read the fixed addresses of QSA layer `layer` from the retained journal (nothing is changed). - pub(crate) fn from_journal(qsa: &crate::OriginalVerifyQsaJournal<'_, '_>, layer: usize) -> Result { + pub(crate) fn from_journal(qsa: &crate::OriginalVerifyQsaJournal<'_>, layer: usize) -> Result { let a = qsa.window_addresses(layer)?; Ok(Self { resident: a.resident, @@ -162,11 +163,11 @@ impl OriginalVerifyQsaKvBinding { Ok(()) } } -impl<'a, 'ctx> OriginalVerifyQsaBinding<'a, 'ctx> { +impl<'ctx> OriginalVerifyQsaBinding<'ctx> { pub fn new( context: &'ctx Context<'ctx>, geometry: OriginalVerifyGeometry, - layers: [OriginalVerifyQsaLayerWeights<'a, 'ctx>; 12], + layers: [OriginalVerifyQsaLayerWeights<'ctx>; 12], ) -> Result { geometry.validate()?; let this = Self { context, geometry, layers }; @@ -184,7 +185,7 @@ impl<'a, 'ctx> OriginalVerifyQsaBinding<'a, 'ctx> { let sizes = Self::sizes(&self.geometry); let mut spans = Vec::with_capacity(60); for w in &self.layers { - let bufs = [w.attn_q_norm, w.attn_k_norm, w.index_q_norm, w.index_k_proj, w.index_q_proj]; + let bufs = [&w.attn_q_norm, &w.attn_k_norm, &w.index_q_norm, &w.index_k_proj, &w.index_q_proj]; for (b, bytes) in bufs.into_iter().zip(sizes) { admit(context, b, bytes)?; spans.push((handle(b)?, bytes)); @@ -202,11 +203,11 @@ impl<'a, 'ctx> OriginalVerifyQsaBinding<'a, 'ctx> { let w = self.layers.get(q).ok_or(Error::InvalidQwenShape)?; let s = Self::sizes(&self.geometry); Ok(QsaWeightAddrs { - q_norm: admit(self.context, w.attn_q_norm, s[0])?, - k_norm: admit(self.context, w.attn_k_norm, s[1])?, - index_q_norm: admit(self.context, w.index_q_norm, s[2])?, - index_k_proj: admit(self.context, w.index_k_proj, s[3])?, - index_q_proj: admit(self.context, w.index_q_proj, s[4])?, + q_norm: admit(self.context, &w.attn_q_norm, s[0])?, + k_norm: admit(self.context, &w.attn_k_norm, s[1])?, + index_q_norm: admit(self.context, &w.index_q_norm, s[2])?, + index_k_proj: admit(self.context, &w.index_k_proj, s[3])?, + index_q_proj: admit(self.context, &w.index_q_proj, s[4])?, }) } } diff --git a/crates/cuda-driver/src/original_verify_window_qsa/fused_prelude.rs b/crates/cuda-driver/src/original_verify_window_qsa/fused_prelude.rs new file mode 100644 index 00000000..fd7b79c9 --- /dev/null +++ b/crates/cuda-driver/src/original_verify_window_qsa/fused_prelude.rs @@ -0,0 +1,206 @@ +//! verify-qsa-fused-prelude: the K/V and indexer appends of a QSA layer of the verify window as two launches +//! (`LELEKA_SM120_FUSED_QSA_PRELUDE`, off by default; docs/experiments/verify-qsa-fused-prelude.md). +//! +//! The literal window records, per QSA layer and window row, `mtp_original_append` (K/V into the INT8 pools) and +//! `verify_qsa_append_analytic` (the indexer key), plus one tail snapshot copy before the first row: `2 n + 1` +//! launches. +//! With the switch on: +//! +//! * `leleka_verify_qsa_kv_rows` (`original_verify_window_qsa_kv_rows.cu`, precise math) is the n `mtp_original_append` +//! launches with the rows along the grid (rows are independent: every row writes its own cell); +//! * `leleka_verify_qsa_index_rows` (`original_verify_window_qsa_index_rows.cu`, fast math like the Original indexer) +//! is the tail snapshot and the n `verify_qsa_append_analytic` launches as one chain in one CTA (row r + 1 reads what +//! row r wrote). +//! +//! The two stay separate launches because they differ in math mode and because the QSA side streams +//! (`SIDE_QSA`) run the indexer chain beside the K/V chain: each launch sits where the launches it replaces sit. +//! The plans are pure (addresses in, one `Launch` out); the kernel arguments are by-value structs of u64 words. +use super::super::kernels::{A, AssetSpec, Launch, LaunchExtent}; +use super::OriginalVerifyQsaKvBinding; +use crate::{Error, Result}; + +pub(crate) const E_KV_ROWS: &str = "leleka_verify_qsa_kv_rows"; +pub(crate) const E_INDEX_ROWS: &str = "leleka_verify_qsa_index_rows"; + +/// `original_verify_window_qsa_kv_rows.cu`, precise math (the recipe of `mtp_original_kv.ptx`), nvcc 13.2.86, sealed +/// with `scripts/gpu-bringup` (extra-seal-plan.json, group verify-qsa-prelude). `resolve` keeps the switch inert while +/// a pin does not match its bytes. +pub(crate) static KV_ROWS: AssetSpec = AssetSpec { + name: "original_verify_window_qsa_kv_rows.ptx", + ptx: concat!(include_str!("../original_verify_window_qsa_kv_rows.ptx"), "\0").as_bytes(), + sha: [ + 217, 24, 52, 136, 189, 9, 207, 86, 34, 6, 137, 55, 116, 152, 82, 81, 123, 82, 109, 46, 201, 207, 91, 113, 81, + 42, 29, 254, 208, 161, 219, 133, + ], + entries: &[E_KV_ROWS], + unsealed: "Original verifier asset unsealed: original_verify_window_qsa_kv_rows.ptx (fused K/V append rows)", +}; + +/// `original_verify_window_qsa_index_rows.cu`, fast math like `original_verify_qsa.ptx`; nvcc 13.2.86, sealed as +/// `KV_ROWS`. +pub(crate) static INDEX_ROWS: AssetSpec = AssetSpec { + name: "original_verify_window_qsa_index_rows.ptx", + ptx: concat!(include_str!("../original_verify_window_qsa_index_rows.ptx"), "\0").as_bytes(), + sha: [ + 113, 219, 156, 79, 31, 64, 14, 200, 110, 124, 241, 140, 177, 124, 53, 4, 138, 238, 50, 70, 215, 152, 40, 219, + 112, 252, 43, 86, 45, 44, 213, 125, + ], + entries: &[E_INDEX_ROWS], + unsealed: "Original verifier asset unsealed: original_verify_window_qsa_index_rows.ptx (fused indexer append rows)", +}; + +/// `kStepCount` of the step rows: the words between two window rows of the "step" span. +const STEP_WORDS: usize = 4; +/// Threads of both kernels (`THREADS` of the .cu files). +const THREADS: u32 = 256; +/// The key width of the indexer image (`D` of the .cu file) and the INT8 scale group (`KV_GROUP`). +const INDEX_DIM: usize = 128; +const KV_GROUP: usize = 64; + +/// The modules a window needs when the switch is on. +pub(crate) fn assets(on: bool) -> Vec<&'static AssetSpec> { + if on { vec![&KV_ROWS, &INDEX_ROWS] } else { Vec::new() } +} + +/// Both modules are sealed (their pins match their bytes). +pub(crate) fn sealed() -> bool { + KV_ROWS.sealed().is_ok() && INDEX_ROWS.sealed().is_ok() +} + +/// The switch as the window records it: requested, and the sealed modules exist. An unsealed module keeps the literal +/// launches (fail closed), and says so once. +pub(crate) fn resolve(requested: bool) -> bool { + let on = requested && sealed(); + static SAID: std::sync::Once = std::sync::Once::new(); + if requested && !on { + SAID.call_once(|| eprintln!("leleka-serve fused QSA prelude: refused (PTX not sealed), per-row launches kept")); + } + on +} + +fn pack(low: u32, high: u32) -> u64 { + u64::from(low) | (u64::from(high) << 32) +} +fn pack_i32(low: usize, high: usize) -> Result { + let int = |v: usize| i32::try_from(v).map(|v| v as u32).map_err(|_| Error::InvalidQwenShape); + Ok(pack(int(low)?, int(high)?)) +} +fn pack_f32(low: f32, high: f32) -> u64 { + pack(low.to_bits(), high.to_bits()) +} + +/// Where the K/V rows of one launch live: the first step row, the first K and V rows, and how many rows. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub(crate) struct KvRowsOperands { + pub step: u64, + pub kcur: u64, + pub vcur: u64, + pub rows: usize, +} + +/// The cache shape the K/V rows append into. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub(crate) struct KvRowsShape { + pub kv_heads: usize, + pub head_dim: usize, + pub page_size: usize, +} + +/// `rows` x `mtp_original_append` as one launch: grid (rows * 2 * kv_heads), 256 threads. +pub(crate) fn plan_kv_rows(kv: &OriginalVerifyQsaKvBinding, ops: KvRowsOperands, shape: KvRowsShape) -> Result { + let KvRowsShape { kv_heads, head_dim, page_size } = shape; + if ops.rows == 0 || kv_heads == 0 || head_dim == 0 || head_dim % KV_GROUP != 0 || page_size == 0 { + return Err(Error::InvalidQwenShape); + } + let [k_q, v_q, k_scale, v_scale] = kv.resident; + let [host_k_q, host_v_q, host_k_scale, host_v_scale] = kv.host; + let words = vec![ + k_q, + v_q, + k_scale, + v_scale, + kv.table, + host_k_q, + host_v_q, + host_k_scale, + host_v_scale, + ops.step, + ops.kcur, + ops.vcur, + pack_i32(kv_heads, head_dim)?, + pack_i32(page_size, STEP_WORDS)?, + pack_i32(kv_heads * head_dim, ops.rows)?, + ]; + let blocks = u32::try_from(ops.rows * 2 * kv_heads).map_err(|_| Error::InvalidQwenShape)?; + Launch::new(&KV_ROWS, E_KV_ROWS, LaunchExtent::new([blocks, 1, 1], [THREADS, 1, 1], 0), vec![A::Words(words)]) +} + +/// The RoPE constants of the indexer keys (`OriginalVerifyRope`, analytic variant). +#[derive(Clone, Copy, Debug, PartialEq)] +pub(crate) struct IndexRope { + pub theta_scale: f32, + pub freq_scale: f32, + pub corr_low: f32, + pub corr_high: f32, + pub ext_factor: f32, + pub magnitude: f32, +} + +/// The fixed addresses of one layer's retained index image and its key norm (what `append_plan` binds for every row): +/// `positions` is 0 without a retained position table. +#[derive(Clone, Copy, Debug, PartialEq)] +pub(crate) struct IndexImage { + pub tail: u64, + pub dead: u64, + pub pooled: u64, + pub block_pos: u64, + pub gamma: u64, + pub positions: u64, + pub rope: IndexRope, +} + +/// The window rows of one indexer launch: the raw key rows, the step rows, the snapshot destination (0: no snapshot, +/// every row group but the first) and the cell limit. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub(crate) struct IndexRowsOperands { + pub raw: u64, + pub step: u64, + pub snapshot: u64, + pub rows: usize, + pub max_cells: usize, +} + +/// The tail snapshot and `rows` x `verify_qsa_append_analytic` as one launch: one CTA of 256 threads. +pub(crate) fn plan_index_rows(image: &IndexImage, ops: IndexRowsOperands) -> Result { + if ops.rows == 0 || ops.max_cells == 0 { + return Err(Error::InvalidQwenShape); + } + let r = &image.rope; + let words = vec![ + ops.raw, + ops.step, + image.tail, + image.dead, + image.pooled, + image.block_pos, + image.gamma, + image.positions, + ops.snapshot, + ops.rows as u64, + ops.max_cells as u64, + pack_f32(1e-6, r.theta_scale), + pack_f32(r.freq_scale, r.corr_low), + pack_f32(r.corr_high, r.ext_factor), + pack_f32(r.magnitude, 0.0), + ]; + Launch::new(&INDEX_ROWS, E_INDEX_ROWS, LaunchExtent::new([1, 1, 1], [THREADS, 1, 1], 0), vec![A::Words(words)]) +} + +/// The indexer key width the kernel is written for. +pub(crate) fn index_dim_supported(index_dim: usize) -> bool { + index_dim == INDEX_DIM +} + +#[cfg(test)] +#[path = "fused_prelude/tests.rs"] +mod tests; diff --git a/crates/cuda-driver/src/original_verify_window_qsa/fused_prelude/tests.rs b/crates/cuda-driver/src/original_verify_window_qsa/fused_prelude/tests.rs new file mode 100644 index 00000000..d7b4ac55 --- /dev/null +++ b/crates/cuda-driver/src/original_verify_window_qsa/fused_prelude/tests.rs @@ -0,0 +1,112 @@ +//! Unit tests of the fused QSA prelude plans (the recorded window sequence is tested in the planner tests). + +use super::*; + +fn binding() -> OriginalVerifyQsaKvBinding { + OriginalVerifyQsaKvBinding { + resident: [0x10, 0x20, 0x30, 0x40], + table: 0x50, + host: [0x60, 0x70, 0x80, 0x90], + resolver: [0; 7], + slots: 8192, + pooled: 0xa0, + pooled_bytes: 1026 * 512, + dead: 0xb0, + dead_bytes: 512, + } +} +fn words(l: &Launch) -> &[u64] { + match l.args.as_slice() { + [A::Words(w)] => w, + other => panic!("one by-value struct expected, got {other:?}"), + } +} +fn image() -> IndexImage { + IndexImage { + tail: 0x1000, + dead: 0x2000, + pooled: 0x3000, + block_pos: 0x4000, + gamma: 0x5000, + positions: 0, + rope: IndexRope { + theta_scale: 0.75, + freq_scale: 1.0, + corr_low: 2.0, + corr_high: 3.0, + ext_factor: 0.5, + magnitude: 1.25, + }, + } +} + +#[test] +fn the_kv_rows_launch_is_one_cta_per_row_kind_and_head_with_the_literal_pools() { + let ops = KvRowsOperands { step: 0x100, kcur: 0x200, vcur: 0x300, rows: 5 }; + let l = plan_kv_rows(&binding(), ops, KvRowsShape { kv_heads: 2, head_dim: 256, page_size: 4 }).unwrap(); + assert_eq!((l.entry, l.grid, l.block, l.shared, l.cluster), (E_KV_ROWS, [20, 1, 1], [256, 1, 1], 0, 0)); + let w = words(&l); + assert_eq!(w.len(), 15, "KvRowsArgs of the .cu: 12 addresses and 6 i32"); + assert_eq!(&w[..9], &[0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80, 0x90]); + assert_eq!(&w[9..12], &[0x100, 0x200, 0x300]); + // kv_heads, head_dim | page_size, step_stride | cur_stride, rows + assert_eq!(&w[12..], &[2 | 256 << 32, 4 | 4 << 32, 512 | 5 << 32]); +} + +#[test] +fn the_index_rows_launch_is_one_cta_and_carries_the_literal_append_operands() { + let ops = IndexRowsOperands { raw: 0x10, step: 0x20, snapshot: 0x30, rows: 3, max_cells: 4096 }; + let l = plan_index_rows(&image(), ops).unwrap(); + assert_eq!((l.entry, l.grid, l.block, l.shared, l.cluster), (E_INDEX_ROWS, [1, 1, 1], [256, 1, 1], 0, 0)); + let w = words(&l); + assert_eq!(w.len(), 15, "IndexRowsArgs of the .cu: 11 words and 8 floats"); + assert_eq!(&w[..11], &[0x10, 0x20, 0x1000, 0x2000, 0x3000, 0x4000, 0x5000, 0, 0x30, 3, 4096]); + let f = |x: f32| u64::from(x.to_bits()); + assert_eq!(w[11], f(1e-6) | f(0.75) << 32); + assert_eq!(&w[12..], &[f(1.0) | f(2.0) << 32, f(3.0) | f(0.5) << 32, f(1.25)]); +} + +#[test] +fn degenerate_shapes_are_refused() { + let shape = KvRowsShape { kv_heads: 2, head_dim: 256, page_size: 4 }; + let ok = KvRowsOperands { step: 1, kcur: 2, vcur: 3, rows: 1 }; + assert!(plan_kv_rows(&binding(), ok, shape).is_ok()); + assert!(plan_kv_rows(&binding(), KvRowsOperands { rows: 0, ..ok }, shape).is_err()); + assert!(plan_kv_rows(&binding(), ok, KvRowsShape { head_dim: 100, ..shape }).is_err()); + assert!(plan_kv_rows(&binding(), ok, KvRowsShape { kv_heads: 0, ..shape }).is_err()); + let rows = IndexRowsOperands { raw: 1, step: 2, snapshot: 0, rows: 1, max_cells: 8 }; + assert!(plan_index_rows(&image(), rows).is_ok()); + assert!(plan_index_rows(&image(), IndexRowsOperands { rows: 0, ..rows }).is_err()); + assert!(plan_index_rows(&image(), IndexRowsOperands { max_cells: 0, ..rows }).is_err()); + assert!(index_dim_supported(128) && !index_dim_supported(64)); +} + +#[test] +fn the_cuda_sources_declare_the_entries_and_the_argument_structs_the_plans_fill() { + let kv = include_str!("../../original_verify_window_qsa_kv_rows.cu"); + let index = include_str!("../../original_verify_window_qsa_index_rows.cu"); + assert!(kv.contains(&format!("__launch_bounds__(THREADS) {E_KV_ROWS}(KvRowsArgs a)"))); + assert!(index.contains(&format!("__launch_bounds__(THREADS) {E_INDEX_ROWS}(IndexRowsArgs a)"))); + assert!(kv.contains("constexpr int THREADS = 256;") && index.contains("THREADS = 256;")); + assert!(index.contains("D = 128") && kv.contains("KV_GROUP = 64")); + // the precise recipe has no fast math; the indexer recipe is the one of the Original indexer + assert!(kv.contains("--ftz=false") && index.contains("--use_fast_math")); +} + +#[test] +fn the_modules_load_only_with_the_switch_and_a_missing_seal_fails_closed() { + assert!(assets(false).is_empty()); + let on = assets(true); + assert!(on.iter().any(|a| std::ptr::eq(*a, &KV_ROWS)) && on.iter().any(|a| std::ptr::eq(*a, &INDEX_ROWS))); + assert!(!resolve(false)); + for spec in [&KV_ROWS, &INDEX_ROWS] { + if spec.sealed().is_ok() { + spec.assert_sealed_and_fail_closed(); + } else { + // no PTX was built yet: refused by the asset's own text, and the switch stays off + assert_eq!(spec.sealed(), Err(Error::InvalidDriverValue(spec.unsealed))); + assert!(!sealed() && !resolve(true)); + } + } + assert_eq!(resolve(true), sealed()); +} diff --git a/crates/cuda-driver/src/original_verify_window_qsa/qsa_window.rs b/crates/cuda-driver/src/original_verify_window_qsa/qsa_window.rs index 2659c4af..0105fa24 100644 --- a/crates/cuda-driver/src/original_verify_window_qsa/qsa_window.rs +++ b/crates/cuda-driver/src/original_verify_window_qsa/qsa_window.rs @@ -3,6 +3,8 @@ #[allow(unused_imports)] use super::*; +#[path = "qsa_window/qsa_window_prelude_rows.rs"] +mod qsa_window_prelude_rows; #[path = "qsa_window/qsa_window_query_key_paths.rs"] mod qsa_window_query_key_paths; #[path = "qsa_window/qsa_window_select_and_attend.rs"] diff --git a/crates/cuda-driver/src/original_verify_window_qsa/qsa_window/qsa_window_prelude_rows.rs b/crates/cuda-driver/src/original_verify_window_qsa/qsa_window/qsa_window_prelude_rows.rs new file mode 100644 index 00000000..95108730 --- /dev/null +++ b/crates/cuda-driver/src/original_verify_window_qsa/qsa_window/qsa_window_prelude_rows.rs @@ -0,0 +1,46 @@ +//! `LELEKA_SM120_FUSED_QSA_PRELUDE`: the K/V rows and the indexer rows of a QSA layer as one launch each +//! (`original_verify_window_qsa/fused_prelude.rs`). Same operands as the per-row plans of `qsa_kv_append` and of the +//! journal's indexer append, taken from the same arena spans. + +#[allow(unused_imports)] +use super::*; +use crate::original_verify::qsa::fused_prelude::{ + self, IndexImage, IndexRowsOperands, KvRowsOperands, KvRowsShape, plan_index_rows, plan_kv_rows, +}; + +impl<'a> QsaWindow<'a> { + /// `qsa_kv_append` of all `rows` as one launch: the same step rows and K/V rows as the per-row launches. + pub fn kv_rows(&self, q: usize, w: &QsaLayerAddrs, rows: Rows) -> Result { + let s = self.rows(q, rows, None)?; + let g = &self.g; + let row_bytes = g.kv_heads * g.head_dim * 4; + w.kv.validate(g)?; + let ops = KvRowsOperands { + step: self.span("step", s.tb * 16, s.n * 16)?, + kcur: self.span("kcur", s.tb * row_bytes, s.n * row_bytes)?, + vcur: self.span("vcur", s.tb * row_bytes, s.n * row_bytes)?, + rows: s.n, + }; + let shape = KvRowsShape { kv_heads: g.kv_heads, head_dim: g.head_dim, page_size: PAGE_SIZE as usize }; + plan_kv_rows(&w.kv, ops, shape) + } + + /// The journal's tail snapshot (first row group only) and indexer append of `rows` as one launch. + pub fn index_rows(&self, q: usize, image: &IndexImage, rows: Rows) -> Result { + let s = self.rows(q, rows, None)?; + let g = &self.g; + let key_bytes = g.index_dim * 4; + let tail_bytes = (g.index_block - 1) * key_bytes; + if !fused_prelude::index_dim_supported(g.index_dim) { + return Err(Error::InvalidQwenShape); + } + let ops = IndexRowsOperands { + raw: self.span("idx_raw_L", (q * g.max_t + s.tb) * key_bytes, s.n * key_bytes)?, + step: self.span("step", s.tb * 16, s.n * 16)?, + snapshot: if rows.group == 0 { self.span("tail_snap", q * tail_bytes, tail_bytes)? } else { 0 }, + rows: s.n, + max_cells: g.max_cells, + }; + plan_index_rows(image, ops) + } +} diff --git a/crates/cuda-driver/src/original_verify_window_qsa/qsa_window/qsa_window_query_key_paths.rs b/crates/cuda-driver/src/original_verify_window_qsa/qsa_window/qsa_window_query_key_paths.rs index d1d530ef..a39a6f94 100644 --- a/crates/cuda-driver/src/original_verify_window_qsa/qsa_window/qsa_window_query_key_paths.rs +++ b/crates/cuda-driver/src/original_verify_window_qsa/qsa_window/qsa_window_query_key_paths.rs @@ -133,6 +133,9 @@ impl<'a> QsaWindow<'a> { /// `qsa_kv_append`: one `kv_append_q8_step` per row into the resident pool (if the page is resident) /// and the host copy. pub fn kv_append(&self, q: usize, w: &QsaLayerAddrs, rows: Rows) -> Result> { + if self.policy.fused_prelude { + return Ok(vec![self.kv_rows(q, w, rows)?]); + } let s = self.rows(q, rows, None)?; let g = &self.g; let (nkv, hd) = (g.kv_heads, g.head_dim); diff --git a/crates/cuda-driver/src/original_verify_window_qsa_index_rows.cu b/crates/cuda-driver/src/original_verify_window_qsa_index_rows.cu new file mode 100644 index 00000000..1f9c7d81 --- /dev/null +++ b/crates/cuda-driver/src/original_verify_window_qsa_index_rows.cu @@ -0,0 +1,152 @@ +// verify-qsa-fused-prelude: the indexer half of the QSA prelude of the verify window graph, ONE launch per layer +// (docs/experiments/verify-qsa-fused-prelude.md). +// +// The window graph records, per QSA layer, `verify_copy_from_mapped_kernel` (the tail snapshot, first row group only) +// and then one `verify_qsa_append_analytic` launch per window row (original_verify_qsa.cu, TAB = false): 1 + n +// launches of one CTA each. Row r + 1 reads what row r wrote (the tail slots, `dead`, the pooled keys), so the rows are +// a chain; this kernel is that chain in one CTA of the same 256 threads: the snapshot copy, then the body of +// `verify_qsa_append_analytic` once per row, in row order. Every row is a verbatim copy of that body (same operations, +// same order, same shuffle reduction), so every output word is computed as the replaced launches compute it. +// +// Barriers: the snapshot reads the tail before any row writes it (one barrier). A row that only stores into the tail +// (pos % 4 != 3, pos != 0) touches no shared memory and only its own tail column, so it needs none; a row that closes +// a block ends with a barrier because the next row rewrites `values` and `partials`. +// +// Only the analytic RoPE variant is fused (the table variant, `verify_qsa_append_table`, is not: the Rust side records +// the per-row launches when the retained angle tables are present). +// +// Compile: nvcc --ptx -O3 -arch=sm_120 -std=c++17 --fmad=true --use_fast_math. This is the recipe of +// original_verify_qsa.cu and draft_commit_qsa.cu: the Original builds native_qsa_indexer with --use_fast_math, so powf, +// cosf and sinf are __powf / cos.approx / sin.approx and the keys are not those of a precise build. +// +// PTX built with nvcc 13.2.86 (server rnr5090, compile only) and sealed with scripts/gpu-bringup (extra-seal-plan.json, +// group verify-qsa-prelude, SHA-256 pin in original_verify_window_qsa/fused_prelude.rs). +#include +#include +#include +#include +#include + +constexpr int D = 128, R = 4, ROT = 64, THREADS = 256; + +// by-value kernel parameter: u64 words, then the floats two per word (see original_verify_window_qsa/fused_prelude.rs) +struct IndexRowsArgs { + uint64_t raw; // float [rows][128]: the indexer key rows of this layer, from the first row of the launch + uint64_t step; // int32 [rows][4]: the step rows; word 0 of a row is the position of the new cell + uint64_t tail; // float [3 * 128] + uint64_t dead; // float [128] + uint64_t pooled; // float [blocks * 128] + uint64_t block_pos; // int32 [1] + uint64_t gamma; // float [128] + uint64_t mtab; // int32 [positions][3] (mrope), or 0 + uint64_t snapshot; // float [3 * 128] destination of the tail snapshot, or 0: no snapshot + uint64_t rows; + uint64_t max_cells; + float epsilon, theta_scale, freq_scale, corr_low; + float corr_high, ext_factor, mscale, pad; +}; + +__device__ float warp_sum(float x) { +#pragma unroll + for (int offset = 16; offset; offset >>= 1) x += __shfl_xor_sync(0xffffffffu, x, offset); + return x; +} +__device__ __forceinline__ int mrope_pos(const int32_t* tab, int pos, int pair) { + return tab ? __ldg(tab + (size_t) pos * 3 + pair % 3) : pos; +} +__host__ __device__ inline float rope_yarn_ramp(float low, float high, int pair) { + const float y = ((float) pair - low) / (high - low > 0.001f ? high - low : 0.001f); + const float clamped = y < 0.0f ? 0.0f : (y > 1.0f ? 1.0f : y); + return 1.0f - clamped; +} +__host__ __device__ inline void rope_scaled_angle(float theta_extrap, float freq_scale, float corr_low, float corr_high, + float ext_factor, float mscale_in, int pair, float& cos_out, + float& sin_out) { + float theta = freq_scale * theta_extrap; + float mscale = mscale_in; + if (ext_factor != 0.0f) { + const float ramp_mix = rope_yarn_ramp(corr_low, corr_high, pair) * ext_factor; + theta = theta * (1.0f - ramp_mix) + theta_extrap * ramp_mix; + mscale *= 1.0f + 0.1f * logf(1.0f / freq_scale); + } + cos_out = cosf(theta) * mscale; + sin_out = sinf(theta) * mscale; +} + +// The rotated key of a completed block, written to pooled[b] (and the spare to pooled[b + 1]); the tail of +// verify_qsa_append_analytic after the block norm. `values` holds the norm output of all 128 lanes. +__device__ __forceinline__ void store_block(const IndexRowsArgs& a, const float* values, int pos, int d) { + const int32_t* mtab = reinterpret_cast(a.mtab); + float* pooled = reinterpret_cast(a.pooled); + float* dead = reinterpret_cast(a.dead); + const int b = pos / R; + const int rope_pos = pos == 0 ? 0 : R * b; // pos_base is 0 in the verify window + float y = values[d]; + if (d < ROT) { + const int pair = d % (ROT / 2); + float c, s; + const float theta_extrap = (pos == 0 ? 0 : mrope_pos(mtab, rope_pos, pair)) * powf(a.theta_scale, float(pair)); + rope_scaled_angle(theta_extrap, a.freq_scale, a.corr_low, a.corr_high, a.ext_factor, a.mscale, pair, c, s); + const float av = values[pair], z = values[pair + ROT / 2]; + y = d < ROT / 2 ? av * c - z * s : av * s + z * c; + } + pooled[std::size_t(b) * D + d] = y; + if (pos == 0) dead[d] = y; + else pooled[std::size_t(b + 1) * D + d] = dead[d]; + if (d == 0 && pos != 0) *reinterpret_cast(a.block_pos) = rope_pos; +} + +// One row: verify_qsa_append_analytic for the row at `raw` / `pos`. Block uniform control flow; a row that does not +// close a block returns before any barrier. +__device__ __forceinline__ void append_row(const IndexRowsArgs& a, const float* raw, int pos, float* values, + float* partials) { + float* tail = reinterpret_cast(a.tail); + const float* gamma = reinterpret_cast(a.gamma); + const int d = threadIdx.x; + const int slot = pos % R; + float incoming = 0.0f; + if (d < D) { + // SET_ROWS stores F16; GET_ROWS expands those exact values to F32. + incoming = __half2float(__float2half_rn(raw[d])); + if (slot < R - 1) tail[slot * D + d] = incoming; + } + if (pos != 0 && slot != R - 1) return; + float mean = 0.0f; + if (d < D) { + float sum = pos == 0 ? incoming : tail[d]; +#pragma unroll + for (int j = 1; j < R; ++j) sum = __fadd_rn(sum, pos == 0 || j == R - 1 ? incoming : tail[j * D + d]); + mean = __fmaf_rn(0.25f, sum, 0.0f); // SCALE includes a zero bias. + } + float square_sum = 0.0f; + if (d < D) square_sum += mean * mean; + square_sum = warp_sum(square_sum); + const int lane = d % 32; + if (lane == 0) partials[d / 32] = square_sum; + __syncthreads(); + square_sum = lane < THREADS / 32 ? partials[lane] : 0.0f; + square_sum = warp_sum(square_sum); + const float scale = rsqrtf(square_sum / D + a.epsilon); + if (d < D) values[d] = scale * mean * gamma[d]; + __syncthreads(); + if (d < D) store_block(a, values, pos, d); + __syncthreads(); // values / partials are rewritten by the next row +} + +// grid (1), block (256): the snapshot, then the rows in order +extern "C" __global__ void __launch_bounds__(THREADS) leleka_verify_qsa_index_rows(IndexRowsArgs a) { + __shared__ float values[D]; + __shared__ float partials[32]; + if (a.snapshot != 0) { + // verify_copy_from_mapped_kernel: 96 float4 (tail_snap <- the tail image) + if (threadIdx.x < 96) { + reinterpret_cast(a.snapshot)[threadIdx.x] = reinterpret_cast(a.tail)[threadIdx.x]; + } + __syncthreads(); // every read of the tail precedes the first row write + } + for (int row = 0; row < (int) a.rows; ++row) { + const int pos = reinterpret_cast(a.step)[row * 4]; + if (pos < 0 || pos >= (int) a.max_cells) continue; // block uniform, as the early return of the Original + append_row(a, reinterpret_cast(a.raw) + (std::size_t) row * D, pos, values, partials); + } +} diff --git a/crates/cuda-driver/src/original_verify_window_qsa_index_rows.ptx b/crates/cuda-driver/src/original_verify_window_qsa_index_rows.ptx new file mode 100644 index 00000000..0838d450 --- /dev/null +++ b/crates/cuda-driver/src/original_verify_window_qsa_index_rows.ptx @@ -0,0 +1,294 @@ +// +// 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_verify_qsa_index_rows +// _ZZ28leleka_verify_qsa_index_rowsE6values has been demoted +// _ZZ28leleka_verify_qsa_index_rowsE8partials has been demoted + +.visible .entry leleka_verify_qsa_index_rows( + .param .align 8 .b8 leleka_verify_qsa_index_rows_param_0[120] +) +.maxntid 256 +{ + .reg .pred %p<40>; + .reg .b16 %rs<7>; + .reg .b32 %r<111>; + .reg .b64 %rd<43>; + // demoted variable + .shared .align 4 .b8 _ZZ28leleka_verify_qsa_index_rowsE6values[512]; + // demoted variable + .shared .align 4 .b8 _ZZ28leleka_verify_qsa_index_rowsE8partials[128]; + ld.param.v2.b32 {%r1, %r31}, [leleka_verify_qsa_index_rows_param_0+112]; + ld.param.v2.b32 {%r29, %r30}, [leleka_verify_qsa_index_rows_param_0+104]; + ld.param.v2.b32 {%r27, %r28}, [leleka_verify_qsa_index_rows_param_0+96]; + ld.param.v2.b32 {%r25, %r26}, [leleka_verify_qsa_index_rows_param_0+88]; + ld.param.b64 %rd10, [leleka_verify_qsa_index_rows_param_0+80]; + ld.param.b64 %rd9, [leleka_verify_qsa_index_rows_param_0+72]; + ld.param.b64 %rd7, [leleka_verify_qsa_index_rows_param_0+56]; + ld.param.b64 %rd6, [leleka_verify_qsa_index_rows_param_0+48]; + ld.param.b64 %rd18, [leleka_verify_qsa_index_rows_param_0+40]; + ld.param.b64 %rd5, [leleka_verify_qsa_index_rows_param_0+32]; + ld.param.b64 %rd4, [leleka_verify_qsa_index_rows_param_0+24]; + ld.param.b64 %rd3, [leleka_verify_qsa_index_rows_param_0+16]; + ld.param.b64 %rd2, [leleka_verify_qsa_index_rows_param_0+8]; + ld.param.b64 %rd1, [leleka_verify_qsa_index_rows_param_0]; + ld.param.b64 %rd8, [leleka_verify_qsa_index_rows_param_0+64]; + setp.eq.b64 %p1, %rd8, 0; + @%p1 bra $L__BB0_4; + mov.u32 %r2, %tid.x; + setp.gt.u32 %p2, %r2, 95; + @%p2 bra $L__BB0_3; + cvta.to.global.u64 %rd19, %rd8; + mul.wide.u32 %rd20, %r2, 16; + add.s64 %rd21, %rd19, %rd20; + cvta.to.global.u64 %rd22, %rd3; + add.s64 %rd23, %rd22, %rd20; + ld.global.v2.b64 {%rd24, %rd25}, [%rd23]; + st.global.v2.b64 [%rd21], {%rd24, %rd25}; +$L__BB0_3: + bar.sync 0; +$L__BB0_4: + cvt.u32.u64 %r3, %rd9; + setp.lt.s32 %p3, %r3, 1; + @%p3 bra $L__BB0_42; + cvta.to.global.u64 %rd41, %rd2; + cvt.u32.u64 %r4, %rd10; + cvta.to.global.u64 %rd26, %rd1; + cvta.to.global.u64 %rd27, %rd3; + cvta.to.global.u64 %rd28, %rd6; + mov.u32 %r32, %tid.x; + cvt.u64.u32 %rd11, %r32; + mul.wide.u32 %rd29, %r32, 4; + add.s64 %rd42, %rd26, %rd29; + add.s64 %rd12, %rd27, %rd29; + and.b32 %r5, %r32, 31; + shr.u32 %r33, %r32, 3; + mov.b32 %r34, _ZZ28leleka_verify_qsa_index_rowsE8partials; + add.s32 %r6, %r34, %r33; + shl.b32 %r35, %r32, 2; + and.b32 %r36, %r35, 124; + add.s32 %r7, %r34, %r36; + add.s64 %rd13, %rd28, %rd29; + mov.b32 %r37, _ZZ28leleka_verify_qsa_index_rowsE6values; + add.s32 %r8, %r37, %r35; + cvta.to.global.u64 %rd14, %rd5; + cvta.to.global.u64 %rd30, %rd4; + cvt.u16.u32 %rs1, %r5; + mul.lo.s16 %rs2, %rs1, 86; + shr.u16 %rs3, %rs2, 8; + mul.lo.s16 %rs4, %rs3, 3; + sub.s16 %rs5, %rs1, %rs4; + cvt.u32.u16 %r38, %rs5; + and.b32 %r39, %r38, 255; + mul.wide.u32 %rd31, %r39, 4; + add.s64 %rd15, %rd7, %rd31; + cvt.rn.f32.u32 %r9, %r5; + sub.ftz.f32 %r10, %r9, %r28; + sub.ftz.f32 %r40, %r29, %r28; + max.ftz.f32 %r11, %r40, 0f3A83126F; + rcp.approx.ftz.f32 %r12, %r27; + add.s32 %r13, %r37, %r36; + add.s64 %rd16, %rd30, %rd29; + neg.s32 %r100, %r3; + lg2.approx.ftz.f32 %r77, %r26; + mul.ftz.f32 %r78, %r77, %r9; + ex2.approx.ftz.f32 %r79, %r78; + div.approx.ftz.f32 %r80, %r10, %r11; + lg2.approx.ftz.f32 %r88, %r12; + mul.ftz.f32 %r89, %r88, 0f3F317218; + fma.rn.ftz.f32 %r90, %r89, 0f3DCCCCCD, 0f3F800000; + mul.ftz.f32 %r20, %r1, %r90; +$L__BB0_6: + ld.global.b32 %r14, [%rd41]; + setp.lt.s32 %p4, %r14, 0; + setp.ge.s32 %p5, %r14, %r4; + or.pred %p6, %p4, %p5; + @%p6 bra $L__BB0_41; + cvt.u32.u64 %r41, %rd11; + setp.gt.u32 %p7, %r41, 127; + and.b32 %r15, %r14, 3; + mov.b32 %r101, 0f00000000; + @%p7 bra $L__BB0_10; + ld.global.b32 %r42, [%rd42]; + // begin inline asm + { cvt.rn.f16.f32 %rs6, %r42;} + + // end inline asm + // begin inline asm + { cvt.f32.f16 %r101, %rs6;} + + // end inline asm + setp.eq.b32 %p8, %r15, 3; + @%p8 bra $L__BB0_10; + mul.wide.u32 %rd32, %r15, 128; + shl.b64 %rd33, %rd32, 2; + add.s64 %rd34, %rd12, %rd33; + st.global.b32 [%rd34], %r101; +$L__BB0_10: + setp.ne.b32 %p9, %r14, 0; + setp.ne.b32 %p10, %r15, 3; + and.pred %p11, %p9, %p10; + @%p11 bra $L__BB0_41; + cvt.u32.u64 %r43, %rd11; + setp.gt.u32 %p12, %r43, 127; + mov.b32 %r104, 0f00000000; + @%p12 bra $L__BB0_18; + setp.eq.b32 %p13, %r14, 0; + mov.b32 %r102, %r101; + @%p13 bra $L__BB0_14; + ld.global.b32 %r102, [%rd12]; +$L__BB0_14: + @%p9 bra $L__BB0_16; + add.rn.ftz.f32 %r48, %r102, %r101; + add.rn.ftz.f32 %r49, %r48, %r101; + add.rn.ftz.f32 %r103, %r49, %r101; + bra.uni $L__BB0_17; +$L__BB0_16: + ld.global.b32 %r44, [%rd12+512]; + add.rn.ftz.f32 %r45, %r102, %r44; + ld.global.b32 %r46, [%rd12+1024]; + add.rn.ftz.f32 %r47, %r45, %r46; + add.rn.ftz.f32 %r103, %r47, %r101; +$L__BB0_17: + fma.rn.ftz.f32 %r104, %r103, 0f3E800000, 0f00000000; +$L__BB0_18: + setp.ne.b32 %p14, %r5, 0; + setp.lt.u32 %p15, %r43, 128; + fma.rn.ftz.f32 %r50, %r104, %r104, 0f00000000; + selp.f32 %r51, %r50, 0f00000000, %p15; + shfl.sync.bfly.b32 %r52|%p16, %r51, 16, 31, -1; + add.ftz.f32 %r53, %r51, %r52; + shfl.sync.bfly.b32 %r54|%p17, %r53, 8, 31, -1; + add.ftz.f32 %r55, %r53, %r54; + shfl.sync.bfly.b32 %r56|%p18, %r55, 4, 31, -1; + add.ftz.f32 %r57, %r55, %r56; + shfl.sync.bfly.b32 %r58|%p19, %r57, 2, 31, -1; + add.ftz.f32 %r59, %r57, %r58; + shfl.sync.bfly.b32 %r60|%p20, %r59, 1, 31, -1; + add.ftz.f32 %r16, %r59, %r60; + @%p14 bra $L__BB0_20; + st.shared.b32 [%r6], %r16; +$L__BB0_20: + setp.gt.u32 %p21, %r5, 7; + bar.sync 0; + mov.b32 %r105, 0f00000000; + @%p21 bra $L__BB0_22; + ld.shared.b32 %r105, [%r7]; +$L__BB0_22: + shfl.sync.bfly.b32 %r61|%p22, %r105, 16, 31, -1; + add.ftz.f32 %r62, %r105, %r61; + shfl.sync.bfly.b32 %r63|%p23, %r62, 8, 31, -1; + add.ftz.f32 %r64, %r62, %r63; + shfl.sync.bfly.b32 %r65|%p24, %r64, 4, 31, -1; + add.ftz.f32 %r66, %r64, %r65; + shfl.sync.bfly.b32 %r67|%p25, %r66, 2, 31, -1; + add.ftz.f32 %r68, %r66, %r67; + shfl.sync.bfly.b32 %r69|%p26, %r68, 1, 31, -1; + add.ftz.f32 %r70, %r68, %r69; + mov.b32 %r71, 0f43000000; + div.approx.ftz.f32 %r17, %r70, %r71; + @%p12 bra $L__BB0_24; + add.ftz.f32 %r72, %r25, %r17; + rsqrt.approx.ftz.f32 %r73, %r72; + mul.ftz.f32 %r74, %r104, %r73; + ld.global.b32 %r75, [%rd13]; + mul.ftz.f32 %r76, %r74, %r75; + st.shared.b32 [%r8], %r76; +$L__BB0_24: + setp.gt.u32 %p27, %r43, 127; + bar.sync 0; + @%p27 bra $L__BB0_40; + setp.gt.u32 %p28, %r43, 63; + and.b32 %r18, %r14, 2147483644; + ld.shared.b32 %r110, [%r8]; + @%p28 bra $L__BB0_35; + setp.eq.b32 %p29, %r14, 0; + mov.b32 %r107, 0f00000000; + @%p29 bra $L__BB0_30; + setp.eq.b64 %p30, %rd7, 0; + mov.b32 %r106, %r18; + @%p30 bra $L__BB0_29; + mul.wide.u32 %rd36, %r18, 12; + add.s64 %rd35, %rd15, %rd36; + // begin inline asm + ld.global.nc.s32 %r106, [%rd35]; + // end inline asm +$L__BB0_29: + cvt.rn.f32.s32 %r107, %r106; +$L__BB0_30: + setp.eq.ftz.f32 %p31, %r30, 0f00000000; + mul.ftz.f32 %r19, %r107, %r79; + mul.ftz.f32 %r108, %r27, %r19; + mov.b32 %r109, %r1; + @%p31 bra $L__BB0_32; + setp.lt.ftz.f32 %p32, %r80, 0f00000000; + setp.gt.ftz.f32 %p33, %r80, 0f3F800000; + selp.f32 %r81, 0f3F800000, %r80, %p33; + mov.b32 %r82, 0f3F800000; + sub.ftz.f32 %r83, %r82, %r81; + selp.f32 %r84, 0f3F800000, %r83, %p32; + mul.ftz.f32 %r85, %r30, %r84; + sub.ftz.f32 %r86, %r82, %r85; + mul.ftz.f32 %r87, %r108, %r86; + fma.rn.ftz.f32 %r108, %r19, %r85, %r87; + mov.b32 %r109, %r20; +$L__BB0_32: + cvt.u32.u64 %r91, %rd11; + setp.gt.u32 %p34, %r91, 31; + cos.approx.ftz.f32 %r92, %r108; + mul.ftz.f32 %r21, %r109, %r92; + sin.approx.ftz.f32 %r93, %r108; + mul.ftz.f32 %r22, %r109, %r93; + ld.shared.b32 %r23, [%r13]; + ld.shared.b32 %r24, [%r13+128]; + @%p34 bra $L__BB0_34; + mul.ftz.f32 %r95, %r21, %r23; + mul.ftz.f32 %r96, %r22, %r24; + sub.ftz.f32 %r110, %r95, %r96; + bra.uni $L__BB0_35; +$L__BB0_34: + mul.ftz.f32 %r94, %r21, %r24; + fma.rn.ftz.f32 %r110, %r23, %r22, %r94; +$L__BB0_35: + shr.u32 %r97, %r14, 2; + mul.wide.u32 %rd37, %r97, 128; + add.s64 %rd38, %rd37, %rd11; + shl.b64 %rd39, %rd38, 2; + add.s64 %rd17, %rd14, %rd39; + st.global.b32 [%rd17], %r110; + setp.ne.b32 %p35, %r14, 0; + @%p35 bra $L__BB0_37; + st.global.b32 [%rd16], %r110; + bra.uni $L__BB0_38; +$L__BB0_37: + ld.global.b32 %r98, [%rd16]; + st.global.b32 [%rd17+512], %r98; +$L__BB0_38: + cvt.u32.u64 %r99, %rd11; + setp.eq.b32 %p36, %r14, 0; + setp.ne.b32 %p37, %r99, 0; + or.pred %p38, %p37, %p36; + @%p38 bra $L__BB0_40; + cvta.to.global.u64 %rd40, %rd18; + st.global.b32 [%rd40], %r18; +$L__BB0_40: + bar.sync 0; +$L__BB0_41: + add.s64 %rd42, %rd42, 512; + add.s32 %r100, %r100, 1; + setp.ne.b32 %p39, %r100, 0; + add.s64 %rd41, %rd41, 16; + @%p39 bra $L__BB0_6; +$L__BB0_42: + ret; + +} diff --git a/crates/cuda-driver/src/original_verify_window_qsa_kv_rows.cu b/crates/cuda-driver/src/original_verify_window_qsa_kv_rows.cu new file mode 100644 index 00000000..aa4e02d2 --- /dev/null +++ b/crates/cuda-driver/src/original_verify_window_qsa_kv_rows.cu @@ -0,0 +1,95 @@ +// verify-qsa-fused-prelude: the K/V half of the QSA prelude of the verify window graph, ONE launch per layer +// (docs/experiments/verify-qsa-fused-prelude.md). +// +// The window graph records, per QSA layer and window row, one `mtp_original_append` launch (mtp_original_kv.cu, the +// literal Original `kv_append_q8_kernel`): grid (kv_heads, head_dim / 64, 2), 64 threads, one 64-value group of K +// (z = 0) or V (z = 1) of one head. Rows do not depend on each other (every row writes its own cell of the pools: its +// own codes and its own scales), so the n launches are one launch with the rows along the grid. This is the Original +// own multi-token form (`kv_append_q8_kernel`, S26 STRATA_LFUSE: token j reads step + j * step_stride and its +// K/V rows at kcur / vcur + j * cur_stride). +// +// One CTA of 256 threads is one (row, K or V, head): its four 64-thread quarters are four consecutive 64-value groups, +// so the group of 64 values, the two-warp maximum (a shuffle reduction in each warp, then the maximum of the two warp +// values; fmaxf is exact, so any association gives the same bits), the f16 scale, the code and the stores are the +// operations of the Original kernel on the same 64 values. head_dim / 64 may be any count: a CTA loops over the groups +// four at a time. +// +// Compile: PRECISE math, nvcc --ptx -O3 -arch=sm_120 -std=c++17 --fmad=true --ftz=false, like mtp_original_kv.cu (the +// Original builds kv_q8.cu with default flags): `amax / 127.0f` and `x / sf` are IEEE divisions. +// +// PTX built with nvcc 13.2.86 (server rnr5090, compile only) and sealed with scripts/gpu-bringup (extra-seal-plan.json, +// group verify-qsa-prelude, SHA-256 pin in original_verify_window_qsa/fused_prelude.rs). +#include "strata/kernels/f16_bits.hpp" +#include "strata/kernels/kv_stream.hpp" +#include + +using namespace strata::kernels; + +constexpr int KV_GROUP = 64; +constexpr int THREADS = 256; +constexpr int QUARTERS = THREADS / KV_GROUP; + +// by-value kernel parameter: 12 addresses, then six 32-bit integers (three words) +struct KvRowsArgs { + uint64_t k_q, v_q, k_scale, v_scale; // resident pools (k_q is never null here: the keyless arm is refused) + uint64_t table; // int32 page table + uint64_t host_k_q, host_v_q, host_k_scale, host_v_scale; // host copy (identity layout), each may be 0 + uint64_t step; // int32 [rows][step_stride]: word kStepPos is the position + uint64_t kcur, vcur; // float [rows][cur_stride]: the K and V rows of the window + int32_t kv_heads, head_dim, page_size, step_stride; + int32_t cur_stride, rows; +}; + +// One group of 64 values of one head of K or V of one row: the body of kv_append_q8_kernel. +__device__ __forceinline__ void append_group(const KvRowsArgs& a, long long pos, bool is_v, int h, int g, + float x, float amax) { + const int t = threadIdx.x & (KV_GROUP - 1); + const int groups = a.head_dim / KV_GROUP; + const uint16_t sbits = f16_from_f32(amax / 127.0f); + const float sf = f32_from_f16(sbits); // quantize against the STORED scale + int q = 0; + if (sf > 0.0f) { + q = __float2int_rn(x / sf); + q = q < -127 ? -127 : (q > 127 ? 127 : q); + } + // KV streaming: the host copy (identity layout) always, the VRAM page only if the block is resident + const long long page = (long long) reinterpret_cast(a.table)[pos / a.page_size]; + if (page >= 0) { + const long long row = (page * a.kv_heads + h) * a.page_size + (pos % a.page_size); + int8_t* codes = reinterpret_cast(is_v ? a.v_q : a.k_q); + uint16_t* scales = reinterpret_cast(is_v ? a.v_scale : a.k_scale); + codes[row * a.head_dim + g * KV_GROUP + t] = (int8_t) q; + if (t == 0) scales[row * groups + g] = sbits; + } + const uint64_t host_codes = is_v ? a.host_v_q : a.host_k_q; + if (host_codes != 0) { + const long long row = ((pos / a.page_size) * a.kv_heads + h) * a.page_size + (pos % a.page_size); + reinterpret_cast(host_codes)[row * a.head_dim + g * KV_GROUP + t] = (int8_t) q; + if (t == 0) reinterpret_cast(is_v ? a.host_v_scale : a.host_k_scale)[row * groups + g] = sbits; + } +} + +// grid (rows * 2 * kv_heads), block (256): block b = ((row * 2 + is_v) * kv_heads + head) +extern "C" __global__ void __launch_bounds__(THREADS) leleka_verify_qsa_kv_rows(KvRowsArgs a) { + __shared__ float warp_max[THREADS / 32]; + const int h = blockIdx.x % a.kv_heads; + const bool is_v = ((blockIdx.x / a.kv_heads) & 1) != 0; + const int j = blockIdx.x / (2 * a.kv_heads); + const long long pos = (long long) __ldg(reinterpret_cast(a.step) + (size_t) j * a.step_stride + kStepPos); + const float* cur = reinterpret_cast(is_v ? a.vcur : a.kcur) + (size_t) j * a.cur_stride; + const int quarter = threadIdx.x / KV_GROUP, t = threadIdx.x % KV_GROUP; + const int groups = a.head_dim / KV_GROUP; + for (int g0 = 0; g0 < groups; g0 += QUARTERS) { + const int g = g0 + quarter; + const bool live = g < groups; + const float x = live ? cur[h * a.head_dim + g * KV_GROUP + t] : 0.0f; + // max |x| over the 64 values: two warps, then combine through shared memory in a fixed order + float m = fabsf(x); + for (int o = 16; o > 0; o >>= 1) m = fmaxf(m, __shfl_xor_sync(0xffffffffu, m, o)); + if ((threadIdx.x & 31) == 0) warp_max[threadIdx.x >> 5] = m; + __syncthreads(); + const float amax = fmaxf(warp_max[2 * quarter], warp_max[2 * quarter + 1]); + if (live) append_group(a, pos, is_v, h, g, x, amax); + __syncthreads(); // warp_max is reused by the next group quartet + } +} diff --git a/crates/cuda-driver/src/original_verify_window_qsa_kv_rows.ptx b/crates/cuda-driver/src/original_verify_window_qsa_kv_rows.ptx new file mode 100644 index 00000000..6336d089 --- /dev/null +++ b/crates/cuda-driver/src/original_verify_window_qsa_kv_rows.ptx @@ -0,0 +1,341 @@ +// +// 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_verify_qsa_kv_rows +// _ZZ25leleka_verify_qsa_kv_rowsE8warp_max has been demoted + +.visible .entry leleka_verify_qsa_kv_rows( + .param .align 8 .b8 leleka_verify_qsa_kv_rows_param_0[120] +) +.maxntid 256 +{ + .reg .pred %p<39>; + .reg .b16 %rs<14>; + .reg .b32 %r<119>; + .reg .b64 %rd<66>; + // demoted variable + .shared .align 4 .b8 _ZZ25leleka_verify_qsa_kv_rowsE8warp_max[32]; + ld.param.b64 %rd25, [leleka_verify_qsa_kv_rows_param_0+64]; + ld.param.b64 %rd24, [leleka_verify_qsa_kv_rows_param_0+56]; + ld.param.b64 %rd23, [leleka_verify_qsa_kv_rows_param_0+48]; + ld.param.b64 %rd22, [leleka_verify_qsa_kv_rows_param_0+40]; + ld.param.b64 %rd21, [leleka_verify_qsa_kv_rows_param_0+32]; + ld.param.b64 %rd20, [leleka_verify_qsa_kv_rows_param_0+24]; + ld.param.b64 %rd19, [leleka_verify_qsa_kv_rows_param_0+16]; + ld.param.b64 %rd18, [leleka_verify_qsa_kv_rows_param_0+8]; + ld.param.b64 %rd17, [leleka_verify_qsa_kv_rows_param_0]; + ld.param.v2.b32 {%r29, %r30}, [leleka_verify_qsa_kv_rows_param_0+112]; + ld.param.b64 %rd28, [leleka_verify_qsa_kv_rows_param_0+88]; + ld.param.b64 %rd27, [leleka_verify_qsa_kv_rows_param_0+80]; + ld.param.b64 %rd26, [leleka_verify_qsa_kv_rows_param_0+72]; + ld.param.v2.b32 {%r27, %r28}, [leleka_verify_qsa_kv_rows_param_0+104]; + ld.param.v2.b32 {%r25, %r26}, [leleka_verify_qsa_kv_rows_param_0+96]; + mov.u32 %r32, %ctaid.x; + div.u32 %r33, %r32, %r25; + mul.lo.s32 %r34, %r33, %r25; + sub.s32 %r1, %r32, %r34; + shl.b32 %r35, %r25, 1; + div.u32 %r36, %r32, %r35; + cvt.u64.u32 %rd30, %r36; + cvt.s64.s32 %rd31, %r28; + mul.lo.s64 %rd32, %rd30, %rd31; + shl.b64 %rd33, %rd32, 2; + add.s64 %rd29, %rd26, %rd33; + // begin inline asm + ld.global.nc.s32 %r31, [%rd29]; + // end inline asm + cvt.s64.s32 %rd1, %r31; + and.b32 %r2, %r33, 1; + setp.eq.b32 %p1, %r2, 0; + selp.b64 %rd2, %rd27, %rd28, %p1; + cvt.s64.s32 %rd34, %r29; + mul.lo.s64 %rd3, %rd30, %rd34; + mov.u32 %r3, %tid.x; + shr.u32 %r4, %r3, 6; + and.b32 %r5, %r3, 63; + shr.s32 %r37, %r26, 31; + shr.u32 %r38, %r37, 26; + add.s32 %r39, %r26, %r38; + shr.s32 %r6, %r39, 6; + setp.lt.s32 %p2, %r26, 64; + @%p2 bra $L__BB0_48; + mad.lo.s32 %r7, %r1, %r26, %r5; + and.b32 %r8, %r3, 31; + shr.u32 %r40, %r3, 3; + mov.b32 %r41, _ZZ25leleka_verify_qsa_kv_rowsE8warp_max; + add.s32 %r9, %r41, %r40; + shl.b32 %r42, %r4, 3; + add.s32 %r10, %r41, %r42; + cvt.s64.s32 %rd4, %r27; + cvt.s64.s32 %rd5, %r25; + cvt.u64.u32 %rd6, %r1; + selp.b64 %rd7, %rd17, %rd18, %p1; + selp.b64 %rd8, %rd19, %rd20, %p1; + cvt.u64.u32 %rd9, %r26; + cvt.u64.u32 %rd10, %r6; + selp.b64 %rd11, %rd22, %rd23, %p1; + selp.b64 %rd12, %rd24, %rd25, %p1; + mov.b32 %r112, 0; +$L__BB0_2: + add.s32 %r11, %r112, %r4; + setp.ge.s32 %p3, %r11, %r6; + mov.b32 %r113, 0f00000000; + @%p3 bra $L__BB0_4; + shl.b32 %r43, %r11, 6; + add.s32 %r44, %r7, %r43; + cvt.s64.s32 %rd35, %r44; + add.s64 %rd36, %rd3, %rd35; + shl.b64 %rd37, %rd36, 2; + add.s64 %rd38, %rd2, %rd37; + ld.b32 %r113, [%rd38]; +$L__BB0_4: + setp.ne.b32 %p4, %r8, 0; + abs.f32 %r45, %r113; + shfl.sync.bfly.b32 %r46|%p5, %r45, 16, 31, -1; + max.f32 %r47, %r45, %r46; + shfl.sync.bfly.b32 %r48|%p6, %r47, 8, 31, -1; + max.f32 %r49, %r47, %r48; + shfl.sync.bfly.b32 %r50|%p7, %r49, 4, 31, -1; + max.f32 %r51, %r49, %r50; + shfl.sync.bfly.b32 %r52|%p8, %r51, 2, 31, -1; + max.f32 %r53, %r51, %r52; + shfl.sync.bfly.b32 %r54|%p9, %r53, 1, 31, -1; + max.f32 %r12, %r53, %r54; + @%p4 bra $L__BB0_6; + st.shared.b32 [%r9], %r12; +$L__BB0_6: + bar.sync 0; + @%p3 bra $L__BB0_47; + ld.shared.b32 %r55, [%r10]; + ld.shared.b32 %r56, [%r10+4]; + max.f32 %r57, %r55, %r56; + div.rn.f32 %r13, %r57, 0f42FE0000; + shr.u32 %r58, %r13, 16; + and.b32 %r14, %r58, 32768; + shr.u32 %r59, %r13, 23; + and.b32 %r15, %r59, 255; + and.b32 %r16, %r13, 8388607; + setp.ne.b32 %p10, %r15, 255; + @%p10 bra $L__BB0_9; + setp.eq.b32 %p21, %r16, 0; + selp.b32 %r76, 0, 512, %p21; + or.b32 %r77, %r76, %r14; + cvt.u16.u32 %rs6, %r77; + or.b16 %rs12, %rs6, 31744; + bra.uni $L__BB0_18; +$L__BB0_9: + setp.lt.u32 %p11, %r15, 143; + @%p11 bra $L__BB0_11; + cvt.u16.u32 %rs5, %r14; + or.b16 %rs12, %rs5, 31744; + bra.uni $L__BB0_18; +$L__BB0_11: + setp.gt.u32 %p12, %r15, 112; + @%p12 bra $L__BB0_17; + setp.gt.u32 %p16, %r15, 101; + @%p16 bra $L__BB0_14; + cvt.u16.u32 %rs12, %r14; + bra.uni $L__BB0_18; +$L__BB0_14: + or.b32 %r67, %r16, 8388608; + sub.s32 %r68, 126, %r15; + shr.u32 %r17, %r67, %r68; + mov.b32 %r69, -1; + shl.b32 %r70, %r69, %r68; + not.b32 %r71, %r70; + and.b32 %r18, %r67, %r71; + sub.s32 %r72, 125, %r15; + mov.b32 %r114, 1; + shl.b32 %r19, %r114, %r72; + setp.gt.u32 %p17, %r18, %r19; + @%p17 bra $L__BB0_16; + setp.eq.b32 %p18, %r18, %r19; + and.b32 %r73, %r17, 1; + setp.ne.b32 %p19, %r73, 0; + and.pred %p20, %p18, %p19; + selp.b32 %r114, 1, 0, %p20; +$L__BB0_16: + add.s32 %r74, %r114, %r17; + add.s32 %r75, %r74, %r14; + cvt.u16.u32 %rs12, %r75; + bra.uni $L__BB0_18; +$L__BB0_17: + shl.b32 %r60, %r15, 10; + shr.u32 %r61, %r16, 13; + or.b32 %r62, %r60, %r61; + add.s32 %r63, %r62, 16384; + or.b32 %r64, %r63, %r14; + cvt.u16.u32 %rs3, %r64; + and.b32 %r65, %r13, 8191; + setp.gt.u32 %p13, %r65, 4096; + and.b32 %r66, %r13, 16383; + setp.eq.b32 %p14, %r66, 12288; + or.pred %p15, %p13, %p14; + selp.b16 %rs4, 1, 0, %p15; + add.s16 %rs12, %rs3, %rs4; +$L__BB0_18: + cvt.u32.u16 %r78, %rs12; + shl.b32 %r79, %r78, 16; + and.b32 %r118, %r79, -2147483648; + shr.u16 %rs7, %rs12, 10; + and.b16 %rs1, %rs7, 31; + and.b16 %rs2, %rs12, 1023; + cvt.u32.u16 %r20, %rs2; + setp.eq.b16 %p22, %rs1, 31; + @%p22 bra $L__BB0_28; + setp.ne.b16 %p23, %rs1, 0; + @%p23 bra $L__BB0_29; + setp.eq.b16 %p24, %rs2, 0; + @%p24 bra $L__BB0_30; + clz.b32 %r82, %r20; + xor.b32 %r83, %r82, 31; + sub.s32 %r84, 9, %r83; + sub.s32 %r21, 10, %r83; + shl.b32 %r22, %r20, %r84; + and.b32 %r23, %r21, 3; + setp.gt.u32 %p25, %r83, 6; + mov.b32 %r116, 0; + @%p25 bra $L__BB0_25; + cvt.u16.u32 %rs8, %r21; + shr.u16 %rs9, %rs8, 2; + and.b16 %rs10, %rs9, 3; + mul.wide.u16 %r116, %rs10, 4; + neg.s32 %r115, %r116; +$L__BB0_23: + add.s32 %r115, %r115, 4; + setp.ne.b32 %p26, %r115, 0; + @%p26 bra $L__BB0_23; + setp.eq.b32 %p27, %r23, 0; + mov.b32 %r117, %r116; + @%p27 bra $L__BB0_27; +$L__BB0_25: + add.s32 %r117, %r116, 1; + setp.eq.b32 %p28, %r23, 1; + @%p28 bra $L__BB0_27; + setp.eq.b32 %p29, %r23, 2; + selp.b32 %r85, 2, 3, %p29; + add.s32 %r117, %r116, %r85; +$L__BB0_27: + shl.b32 %r86, %r117, 23; + shl.b32 %r87, %r22, 14; + and.b32 %r88, %r87, 8372224; + sub.s32 %r89, %r88, %r86; + add.s32 %r90, %r89, 947912704; + or.b32 %r118, %r90, %r118; + bra.uni $L__BB0_30; +$L__BB0_28: + shl.b32 %r80, %r20, 13; + add.s32 %r81, %r118, %r80; + add.s32 %r118, %r81, 2139095040; + bra.uni $L__BB0_30; +$L__BB0_29: + add.s16 %rs11, %rs1, 112; + cvt.u32.u16 %r91, %rs11; + shl.b32 %r92, %r91, 23; + shl.b32 %r93, %r20, 13; + or.b32 %r94, %r92, %r93; + add.s32 %r118, %r94, %r118; +$L__BB0_30: + setp.leu.f32 %p30, %r118, 0f00000000; + mov.b16 %rs13, 0; + @%p30 bra $L__BB0_32; + div.rn.f32 %r95, %r113, %r118; + cvt.rni.s32.f32 %r96, %r95; + max.s32 %r97, %r96, -127; + min.s32 %r98, %r97, 127; + cvt.u16.u32 %rs13, %r98; +$L__BB0_32: + or.b64 %rd39, %rd1, %rd4; + and.b64 %rd40, %rd39, -4294967296; + setp.ne.b64 %p31, %rd40, 0; + @%p31 bra $L__BB0_34; + cvt.u32.u64 %r99, %rd4; + cvt.u32.u64 %r100, %rd1; + div.u32 %r101, %r100, %r99; + cvt.u64.u32 %rd63, %r101; + bra.uni $L__BB0_35; +$L__BB0_34: + div.s64 %rd63, %rd1, %rd4; +$L__BB0_35: + cvta.to.global.u64 %rd41, %rd21; + shl.b64 %rd42, %rd63, 2; + add.s64 %rd43, %rd41, %rd42; + ld.global.b32 %r24, [%rd43]; + setp.lt.s32 %p32, %r24, 0; + @%p32 bra $L__BB0_41; + cvt.u64.u32 %rd44, %r24; + mad.lo.s64 %rd13, %rd44, %rd5, %rd6; + or.b64 %rd45, %rd1, %rd4; + and.b64 %rd46, %rd45, -4294967296; + setp.ne.b64 %p33, %rd46, 0; + @%p33 bra $L__BB0_38; + cvt.u32.u64 %r102, %rd4; + cvt.u32.u64 %r103, %rd1; + rem.u32 %r104, %r103, %r102; + cvt.u64.u32 %rd64, %r104; + bra.uni $L__BB0_39; +$L__BB0_38: + rem.s64 %rd64, %rd1, %rd4; +$L__BB0_39: + setp.ne.b32 %p34, %r5, 0; + mad.lo.s64 %rd14, %rd13, %rd4, %rd64; + shl.b32 %r105, %r11, 6; + or.b32 %r106, %r105, %r5; + cvt.u64.u32 %rd47, %r106; + mad.lo.s64 %rd48, %rd14, %rd9, %rd47; + add.s64 %rd49, %rd7, %rd48; + st.b8 [%rd49], %rs13; + @%p34 bra $L__BB0_41; + cvt.u64.u32 %rd50, %r11; + mad.lo.s64 %rd51, %rd14, %rd10, %rd50; + shl.b64 %rd52, %rd51, 1; + add.s64 %rd53, %rd8, %rd52; + st.b16 [%rd53], %rs12; +$L__BB0_41: + setp.eq.b64 %p35, %rd11, 0; + @%p35 bra $L__BB0_47; + mad.lo.s64 %rd15, %rd63, %rd5, %rd6; + or.b64 %rd54, %rd1, %rd4; + and.b64 %rd55, %rd54, -4294967296; + setp.ne.b64 %p36, %rd55, 0; + @%p36 bra $L__BB0_44; + cvt.u32.u64 %r107, %rd4; + cvt.u32.u64 %r108, %rd1; + rem.u32 %r109, %r108, %r107; + cvt.u64.u32 %rd65, %r109; + bra.uni $L__BB0_45; +$L__BB0_44: + rem.s64 %rd65, %rd1, %rd4; +$L__BB0_45: + setp.ne.b32 %p37, %r5, 0; + mad.lo.s64 %rd16, %rd15, %rd4, %rd65; + shl.b32 %r110, %r11, 6; + or.b32 %r111, %r110, %r5; + cvt.u64.u32 %rd56, %r111; + mad.lo.s64 %rd57, %rd16, %rd9, %rd56; + add.s64 %rd58, %rd11, %rd57; + st.b8 [%rd58], %rs13; + @%p37 bra $L__BB0_47; + cvt.u64.u32 %rd59, %r11; + mad.lo.s64 %rd60, %rd16, %rd10, %rd59; + shl.b64 %rd61, %rd60, 1; + add.s64 %rd62, %rd12, %rd61; + st.b16 [%rd62], %rs12; +$L__BB0_47: + bar.sync 0; + add.s32 %r112, %r112, 4; + setp.lt.s32 %p38, %r112, %r6; + @%p38 bra $L__BB0_2; +$L__BB0_48: + ret; + +} diff --git a/crates/cuda-driver/src/original_verify_window_sm120.rs b/crates/cuda-driver/src/original_verify_window_sm120.rs index 67a40806..6a335bf0 100644 --- a/crates/cuda-driver/src/original_verify_window_sm120.rs +++ b/crates/cuda-driver/src/original_verify_window_sm120.rs @@ -78,6 +78,14 @@ pub(crate) const DEFAULT_ON_GU_SWIGLU: bool = false; pub(crate) const DEFAULT_ON_SIDE_MIXER: bool = false; pub(crate) const DEFAULT_ON_SIDE_QSA: bool = false; pub(crate) const DEFAULT_ON_SIDE_SHARED: bool = false; +/// ACCEPT_ON_DEVICE: the finite verdict of the head logits is decided in the verify graph and read from a mapped word +/// (vanilla's `logits_nonfinite_rows` flags), not by a scan launched, synchronised and copied back after the drain. +pub(crate) const DEFAULT_ON_ACCEPT_ON_DEVICE: bool = false; +/// The QSA prelude (K/V rows and indexer rows of a layer as one launch each, qsa/fused_prelude.rs). +pub(crate) const DEFAULT_ON_FUSED_QSA_PRELUDE: bool = false; +// claude/verify-gdn-fused-kernels (original_verify_window_gdn_fused.rs): both off until a paired A/B and identity +pub(crate) const DEFAULT_ON_FUSED_GDN: bool = false; +pub(crate) const DEFAULT_ON_GDN_AB_UNROLL: bool = false; /// Which parts of the verify graph run on the two side streams: the GDN gates and gate projection, the QSA indexer and /// query chains (upstream `STRATA_SIDE_MIXER=2`), and the shared expert beside the routed experts (upstream's shared @@ -113,6 +121,15 @@ pub struct Sm120Switches { pub side_qsa: bool, /// The shared expert on a side stream, beside the routed experts. pub side_shared: bool, + /// `LELEKA_SM120_ACCEPT_ON_DEVICE`: the finite verdict of the head logits in the verify graph. + pub accept_on_device: bool, + /// `LELEKA_SM120_FUSED_QSA_PRELUDE`: the K/V rows and the indexer rows of a QSA layer as one launch each. + pub fused_qsa_prelude: bool, + // ---- claude/verify-gdn-fused-kernels + /// `LELEKA_SM120_FUSED_GDN`: a GDN layer's conv, a/b gates and step as one launch (`sm120_gdn_fused.cu`). + pub fused_gdn: bool, + /// `LELEKA_SM120_GDN_AB_UNROLL`: upstream `STRATA_SMALL_UNR` bit 1, the unrolled a/b projection kernel. + pub gdn_ab_unroll: bool, } fn one(get: &impl Fn(&str) -> Option, var: &str, default: bool) -> bool { @@ -155,6 +172,10 @@ impl Sm120Switches { side_mixer: switch("LELEKA_SM120_SIDE_MIXER", DEFAULT_ON_SIDE_MIXER), side_qsa: switch("LELEKA_SM120_SIDE_QSA", DEFAULT_ON_SIDE_QSA), side_shared: switch("LELEKA_SM120_SIDE_SHARED", DEFAULT_ON_SIDE_SHARED), + accept_on_device: switch("LELEKA_SM120_ACCEPT_ON_DEVICE", DEFAULT_ON_ACCEPT_ON_DEVICE), + fused_qsa_prelude: switch("LELEKA_SM120_FUSED_QSA_PRELUDE", DEFAULT_ON_FUSED_QSA_PRELUDE), + fused_gdn: switch("LELEKA_SM120_FUSED_GDN", DEFAULT_ON_FUSED_GDN), + gdn_ab_unroll: switch("LELEKA_SM120_GDN_AB_UNROLL", DEFAULT_ON_GDN_AB_UNROLL), } } /// The side-stream parts these switches ask for. @@ -169,6 +190,10 @@ impl Sm120Switches { side_mixer: overridden(&OVERRIDE_SIDE_MIXER, s.side_mixer), side_qsa: s.side_qsa, side_shared: s.side_shared, + accept_on_device: s.accept_on_device, + fused_qsa_prelude: s.fused_qsa_prelude, + fused_gdn: s.fused_gdn, + gdn_ab_unroll: s.gdn_ab_unroll, } } } @@ -249,6 +274,36 @@ mod tests { assert_eq!(both.union(gdn), SideBranches { gdn: true, qsa: true, shared_expert: true }); } + #[test] + fn accept_on_device_is_off_by_default_and_follows_its_own_variable() { + const VAR: &str = "LELEKA_SM120_ACCEPT_ON_DEVICE"; + let accept = |major, minor, e| Sm120Switches::resolve(major, minor, e).accept_on_device; + assert!(!DEFAULT_ON_ACCEPT_ON_DEVICE); + assert!(!accept(12, 0, env(&[]))); + assert!(accept(12, 0, env(&[(VAR, "1")]))); + assert!(accept(12, 0, env(&[(VAR, "on")]))); + assert!(!accept(12, 0, env(&[(VAR, "0")]))); + // the master switch only turns the default set off; an explicit variable still wins, as for the others + assert!(accept(12, 0, env(&[("LELEKA_SM120_PERF", "0"), (VAR, "1")]))); + // the kernels are in the common PTX, but the switch follows the rule of the others: below 12.x never taken + assert!(!accept(8, 6, env(&[(VAR, "1")]))); + // it is not a side-stream part + assert!(!Sm120Switches::resolve(12, 0, env(&[(VAR, "1")])).side_branches().any()); + } + + #[test] + fn fused_qsa_prelude_is_off_by_default_and_follows_its_own_variable() { + let on = |maj, min, e| Sm120Switches::resolve(maj, min, e).fused_qsa_prelude; + assert_eq!(on(12, 0, env(&[])), DEFAULT_ON_FUSED_QSA_PRELUDE); + assert!(!DEFAULT_ON_FUSED_QSA_PRELUDE && !on(12, 0, env(&[]))); + assert!(on(12, 0, env(&[("LELEKA_SM120_FUSED_QSA_PRELUDE", "1")]))); + assert!(!on(8, 6, env(&[("LELEKA_SM120_FUSED_QSA_PRELUDE", "1")]))); + assert!(!on(12, 0, env(&[("LELEKA_SM120_FUSED_QSA_PRELUDE", "0")]))); + // no other switch follows it + let all = Sm120Switches::resolve(12, 0, env(&[("LELEKA_SM120_FUSED_QSA_PRELUDE", "1")])); + assert_eq!(Sm120Switches { fused_qsa_prelude: false, ..all }, Sm120Switches::default()); + } + #[test] fn the_gu_swiglu_asset_is_sealed_and_exports_every_entry() { GU_SWIGLU.assert_sealed_and_fail_closed(); diff --git a/crates/cuda-driver/src/qsa_verification_commit.rs b/crates/cuda-driver/src/qsa_verification_commit.rs index c5eee2d6..49030478 100644 --- a/crates/cuda-driver/src/qsa_verification_commit.rs +++ b/crates/cuda-driver/src/qsa_verification_commit.rs @@ -9,16 +9,16 @@ 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. -#[derive(Clone, Copy)] -pub struct OriginalVerifyRope<'a, 'ctx> { +#[derive(Clone)] +pub struct OriginalVerifyRope<'ctx> { pub theta_scale: f32, pub freq_scale: f32, pub corr_low: f32, pub corr_high: f32, pub ext_factor: f32, pub magnitude: f32, - pub positions: Option<&'a DeviceBuffer<'ctx>>, - pub angles: Option<(&'a DeviceBuffer<'ctx>, &'a DeviceBuffer<'ctx>, usize)>, + pub positions: Option>, + 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)] @@ -44,14 +44,14 @@ struct Live { /// The verifier retains both Original QSA state owners. The index image alone /// is insufficient: upstream `verify.cpp` appends the real K/V projections /// before the indexer and resolves attention from that same K/V prefix. -pub struct OriginalVerifyQsaJournal<'a, 'ctx> { +pub struct OriginalVerifyQsaJournal<'ctx> { context: &'ctx Context<'ctx>, /// The owners; `None` while they are out on loan (`lend` / `take_back`). indices: [RefCell>>; 12], mapped: [RefCell>>; 12], loan: RefCell>, - gamma: [&'a DeviceBuffer<'ctx>; 12], - rope: OriginalVerifyRope<'a, 'ctx>, + gamma: [DeviceRef<'ctx>; 12], + rope: OriginalVerifyRope<'ctx>, live: RefCell, failed: Cell, /// `set_window_snapshots`: the index state (12 x `WINDOW_STATE_BYTES`) and the PLE history image at the start of @@ -74,5 +74,9 @@ 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"] +mod verify_qsa_journal_index_image; #[path = "qsa_verification_commit/verify_qsa_journal_publish_discard.rs"] mod verify_qsa_journal_publish_discard; +#[path = "qsa_verification_commit/verify_qsa_journal_rearm.rs"] +mod verify_qsa_journal_rearm; 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 820793b0..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 @@ -42,10 +42,10 @@ fn image_clear(buffer: &DeviceBuffer<'_>, index: &OriginalQsaResidentIndex<'_>) /// Every norm weight is a whole buffer that overlaps no index image. fn check_gamma<'ctx>( context: &'ctx Context<'ctx>, - gamma: &[&DeviceBuffer<'ctx>; 12], + gamma: &[DeviceRef<'ctx>; 12], indices: &Indices<'ctx>, ) -> Result<()> { - for g in gamma.iter().copied() { + for g in gamma.iter() { whole(context, g, 512)?; for i in indices { image_clear(g, i)?; @@ -54,14 +54,14 @@ fn check_gamma<'ctx>( Ok(()) } /// The retained RoPE tables must not overlap any index image. -fn check_rope_clear(rope: &OriginalVerifyRope<'_, '_>, indices: &Indices<'_>) -> Result<()> { +fn check_rope_clear(rope: &OriginalVerifyRope<'_>, indices: &Indices<'_>) -> Result<()> { for b in indices.iter().flat_map(|i| i.image.iter().flatten()) { - if let Some(p) = rope.positions { + if let Some(p) = &rope.positions { if overlaps(p, b)? { return Err(Error::OutputAliasesInput); } } - if let Some((cos, sin, _)) = rope.angles { + if let Some((cos, sin, _)) = &rope.angles { if overlaps(cos, b)? || overlaps(sin, b)? { return Err(Error::OutputAliasesInput); } @@ -85,13 +85,13 @@ pub(super) fn check_aligned<'ctx>( } Ok(()) } -impl<'a, 'ctx> OriginalVerifyQsaJournal<'a, 'ctx> { +impl<'ctx> OriginalVerifyQsaJournal<'ctx> { pub fn new( context: &'ctx Context<'ctx>, indices: [OriginalQsaResidentIndex<'ctx>; 12], mapped: [OriginalQsaMappedJournal<'ctx>; 12], - gamma: [&'a DeviceBuffer<'ctx>; 12], - rope: OriginalVerifyRope<'a, 'ctx>, + gamma: [DeviceRef<'ctx>; 12], + rope: OriginalVerifyRope<'ctx>, ) -> Result> { let end = indices[0].next_position(); check_aligned(context, &indices, &mapped, end)?; @@ -151,7 +151,7 @@ impl<'a, 'ctx> OriginalVerifyQsaJournal<'a, 'ctx> { i.image[2].as_ref().ok_or(Error::ContextPoisoned)?, i.image[3].as_ref().ok_or(Error::ContextPoisoned)?, ], - self.gamma[layer], + &self.gamma[layer], ) } pub(crate) fn with_committed_index( @@ -203,8 +203,8 @@ impl<'a, 'ctx> OriginalVerifyQsaJournal<'a, 'ctx> { consume(&mut m) } /// The resolved Original RoPE constants and optional retained tables (read only). - pub(crate) fn rope(&self) -> OriginalVerifyRope<'a, 'ctx> { - self.rope + pub(crate) fn rope(&self) -> &OriginalVerifyRope<'ctx> { + &self.rope } /// Fixed device addresses the captured window kernels of one QSA layer bind: the streamed INT8 KV /// (resident pools, page table, host copy, resolver) and the index image's pooled keys and spare key. @@ -272,7 +272,7 @@ impl<'a, 'ctx> OriginalVerifyQsaJournal<'a, 'ctx> { /// full provisional window and is restored by the accepted-prefix graph. pub fn capture_tail_snapshot( &self, - journal: &OriginalVerifyGdnJournal<'_, 'ctx>, + journal: &OriginalVerifyGdnJournal<'ctx>, capture: &mut OriginalCapture<'_, 'ctx>, layer: usize, ) -> Result<()> { diff --git a/crates/cuda-driver/src/qsa_verification_commit/original_verify_rope.rs b/crates/cuda-driver/src/qsa_verification_commit/original_verify_rope.rs index 18dffea8..599f1cba 100644 --- a/crates/cuda-driver/src/qsa_verification_commit/original_verify_rope.rs +++ b/crates/cuda-driver/src/qsa_verification_commit/original_verify_rope.rs @@ -3,14 +3,14 @@ #[allow(unused_imports)] use super::*; -impl OriginalVerifyRope<'_, '_> { +impl OriginalVerifyRope<'_> { pub(super) fn validate(&self, c: &Context<'_>, capacity: usize) -> Result<()> { self.validate_scalars()?; - if let Some(p) = self.positions { + if let Some(p) = &self.positions { whole(c, p, capacity * 3 * 4)?; } - if let Some((cos, sin, n)) = self.angles { - validate_angles(c, (cos, sin), n)?; + if let Some((cos, sin, n)) = &self.angles { + validate_angles(c, (cos, sin), *n)?; } Ok(()) } @@ -28,7 +28,7 @@ impl OriginalVerifyRope<'_, '_> { } } /// The `n` retained cos and sin rows are whole, exactly sized and disjoint. -fn validate_angles(c: &Context<'_>, (cos, sin): (&DeviceBuffer<'_>, &DeviceBuffer<'_>), n: usize) -> Result<()> { +fn validate_angles(c: &Context<'_>, (cos, sin): (&DeviceRef<'_>, &DeviceRef<'_>), n: usize) -> Result<()> { if n == 0 || n > i32::MAX as usize { return Err(Error::InvalidSize); } 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 5a31f1ed..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 @@ -4,12 +4,12 @@ use super::original_verify_qsa_journal::{check_armed_window, image_addresses}; #[allow(unused_imports)] use super::*; -impl<'a, 'ctx> OriginalVerifyQsaJournal<'a, 'ctx> { +impl<'ctx> OriginalVerifyQsaJournal<'ctx> { /// EXACT Original commit: restore prewindow tail, append all maxT raw rows /// using accepted positions or -1. No batched-prompt rounding substitution. pub fn capture_commit_layer( &self, - journal: &OriginalVerifyGdnJournal<'_, 'ctx>, + journal: &OriginalVerifyGdnJournal<'ctx>, capture: &mut OriginalCapture<'_, 'ctx>, layer: usize, ) -> Result<()> { @@ -42,7 +42,7 @@ impl<'a, 'ctx> OriginalVerifyQsaJournal<'a, 'ctx> { /// and records nothing. pub(crate) fn capture_commit_fused( &self, - journal: &OriginalVerifyGdnJournal<'_, 'ctx>, + journal: &OriginalVerifyGdnJournal<'ctx>, capture: &mut OriginalCapture<'_, 'ctx>, ) -> Result { self.validate_context(journal.context())?; @@ -77,14 +77,14 @@ impl<'a, 'ctx> OriginalVerifyQsaJournal<'a, 'ctx> { layers[1][layer] = dead; layers[2][layer] = pooled; layers[3][layer] = block_pos; - layers[4][layer] = whole(self.context, self.gamma[layer], 512)?; + layers[4][layer] = whole(self.context, &self.gamma[layer], 512)?; } Ok(layers) } /// The launch words: the layer tables, the journal addresses, the positions, the sizes and the packed RoPE /// constants. fn fused_words(&self, layers: &[[u64; 12]; 5], io: [u64; 3], (t, max_cells): (usize, usize)) -> Result> { - let r = self.rope; + let r = &self.rope; let positions = self.positions_address()?; let pack = |a: f32, b: f32| (a.to_bits() as u64) | ((b.to_bits() as u64) << 32); let mut words: Vec = Vec::with_capacity(5 * 12 + 7 + 4); @@ -105,6 +105,7 @@ impl<'a, 'ctx> OriginalVerifyQsaJournal<'a, 'ctx> { Ok(self .rope .positions + .as_ref() .map(|b| whole(self.context, b, crate::serving_context::geometry().cells() * 12)) .transpose()? .unwrap_or(0)) @@ -113,7 +114,7 @@ impl<'a, 'ctx> OriginalVerifyQsaJournal<'a, 'ctx> { /// Caller records the tail snapshot before the first group's append. pub fn capture_append_rows( &self, - journal: &OriginalVerifyGdnJournal<'_, 'ctx>, + journal: &OriginalVerifyGdnJournal<'ctx>, capture: &mut OriginalCapture<'_, 'ctx>, layer: usize, rows: std::ops::Range, @@ -123,7 +124,7 @@ impl<'a, 'ctx> OriginalVerifyQsaJournal<'a, 'ctx> { /// Records the row appends of `target` (`commit`: the steps come from the accepted-position words). pub(super) fn capture_append( &self, - journal: &OriginalVerifyGdnJournal<'_, 'ctx>, + journal: &OriginalVerifyGdnJournal<'ctx>, capture: &mut OriginalCapture<'_, 'ctx>, target: LayerRows, commit: bool, @@ -135,14 +136,14 @@ impl<'a, 'ctx> OriginalVerifyQsaJournal<'a, 'ctx> { return Err(Error::InvalidQwenShape); } let i = self.index(layer)?; - let gamma = whole(self.context, self.gamma[layer], 512)?; + 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) } /// One append command per row of the layer. fn append_commands( &self, - journal: &OriginalVerifyGdnJournal<'_, 'ctx>, + journal: &OriginalVerifyGdnJournal<'ctx>, i: &OriginalQsaResidentIndex<'ctx>, (layer_rows, rows): (usize, std::ops::Range), (commit, gamma): (bool, u64), @@ -157,12 +158,12 @@ impl<'a, 'ctx> OriginalVerifyQsaJournal<'a, 'ctx> { } /// The kernel variant (analytic or table RoPE) and the fixed addresses of every row append of a layer. fn append_plan(&self, gamma: u64, is_commit: bool) -> Result { - let (name, cos, sin, max_pos) = match self.rope.angles { + let (name, cos, sin, max_pos) = match &self.rope.angles { Some((c, s, n)) => ( "verify_qsa_append_table", - whole(self.context, c, n * 128)?, - whole(self.context, s, n * 128)?, - n as i32, + whole(self.context, c, *n * 128)?, + whole(self.context, s, *n * 128)?, + *n as i32, ), None => ("verify_qsa_append_analytic", 0, 0, 0), }; @@ -172,7 +173,7 @@ impl<'a, 'ctx> OriginalVerifyQsaJournal<'a, 'ctx> { fn append_command( &self, plan: &AppendPlan, - journal: &OriginalVerifyGdnJournal<'_, 'ctx>, + journal: &OriginalVerifyGdnJournal<'ctx>, i: &OriginalQsaResidentIndex<'ctx>, (raw_row, row): (usize, usize), ) -> Result { @@ -188,7 +189,7 @@ impl<'a, 'ctx> OriginalVerifyQsaJournal<'a, 'ctx> { Command::new(plan.name, [1, 1, 1], [256, 1, 1], 0, self.append_args(plan, &addresses, max_cells)) } fn append_args(&self, plan: &AppendPlan, a: &AppendAddresses, max_cells: i32) -> Vec { - let r = self.rope; + let r = &self.rope; vec![ Arg::Address(a.raw), Arg::Address(a.step), @@ -266,7 +267,7 @@ impl<'a, 'ctx> OriginalVerifyQsaJournal<'a, 'ctx> { } /// The journal addresses of the fused commit: the raw index rows, the tail snapshots and the commit table. Their /// layer and row strides are affine, so the far ends are checked against the first. -fn fused_io(journal: &OriginalVerifyGdnJournal<'_, '_>, t: usize) -> Result<[u64; 3]> { +fn fused_io(journal: &OriginalVerifyGdnJournal<'_>, t: usize) -> Result<[u64; 3]> { let raw = journal.address("idx_raw_L", 0, 512)?; let snap = journal.address("tail_snap", 0, 1536)?; let commit = journal.address("commit", 0, (t + 2) * 4)?; 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 new file mode 100644 index 00000000..7e804081 --- /dev/null +++ b/crates/cuda-driver/src/qsa_verification_commit/verify_qsa_journal_index_image.rs @@ -0,0 +1,47 @@ +//! The retained index image of a layer as the fused indexer launch binds it (`LELEKA_SM120_FUSED_QSA_PRELUDE`). + +use super::original_verify_qsa_journal::image_addresses; +#[allow(unused_imports)] +use super::*; +use crate::original_verify::qsa::fused_prelude::{IndexImage, IndexRope}; + +impl<'ctx> OriginalVerifyQsaJournal<'ctx> { + /// The addresses and RoPE constants every row append of `layer` binds (`append_plan` / `append_args`), or `None` + /// with retained angle tables: only the analytic variant (`verify_qsa_append_analytic`) is fused. + pub(crate) fn index_image( + &self, + journal: &OriginalVerifyGdnJournal<'ctx>, + layer: usize, + ) -> Result> { + self.validate_context(journal.context())?; + if layer >= 12 { + return Err(Error::InvalidQwenShape); + } + if self.rope.angles.is_some() { + return Ok(None); + } + 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 + .rope + .positions + .as_ref() + .map(|b| whole(self.context, b, crate::serving_context::geometry().cells() * 12)) + .transpose()? + .unwrap_or(0); + Ok(Some(IndexImage { tail, dead, pooled, block_pos, gamma, positions, rope: index_rope(&self.rope) })) + } +} + +/// The analytic RoPE constants every row append binds. +fn index_rope(r: &OriginalVerifyRope<'_>) -> IndexRope { + IndexRope { + theta_scale: r.theta_scale, + freq_scale: r.freq_scale, + corr_low: r.corr_low, + corr_high: r.corr_high, + ext_factor: r.ext_factor, + magnitude: r.magnitude, + } +} 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 index a922f1fe..7869463d 100644 --- 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 @@ -44,7 +44,7 @@ pub(super) fn print_of(index: &OriginalQsaResidentIndex<'_>, kv: &OriginalQsaMap } /// The accessors every use of the owners goes through: an error while the owners are out. -impl<'a, 'ctx> OriginalVerifyQsaJournal<'a, 'ctx> { +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)?; @@ -89,15 +89,7 @@ impl<'a, 'ctx> OriginalVerifyQsaJournal<'a, 'ctx> { /// 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.validate_context(self.context)?; - let (position, armed) = { - let live = self.live.try_borrow().map_err(|_| Error::InvalidQwenShape)?; - (live.position, live.armed) - }; - if armed { - return Err(Error::InvalidQwenShape); - } - self.check_idle_at(position)?; + 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)?; 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 7f2edf9a..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 @@ -4,7 +4,7 @@ use super::original_verify_qsa_journal::check_armed_window; #[allow(unused_imports)] use super::*; -impl<'a, 'ctx> OriginalVerifyQsaJournal<'a, 'ctx> { +impl<'ctx> OriginalVerifyQsaJournal<'ctx> { // Called only by the closed graph bridge after its actual commit receipt. pub(crate) fn complete_commit(&self, bank: &OriginalVerifyBank<'ctx>) -> Result<()> { self.validate_context(self.context)?; 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 new file mode 100644 index 00000000..8155a6b7 --- /dev/null +++ b/crates/cuda-driver/src/qsa_verification_commit/verify_qsa_journal_rearm.rs @@ -0,0 +1,19 @@ +//! The re-arm precondition of the journal (ledger row Q7): between two requests the verifier may keep its recorded +//! graphs only if the QSA journal they hold is quiet. + +#[allow(unused_imports)] +use super::*; + +impl OriginalVerifyQsaJournal<'_> { + /// The journal is valid, no window is armed, and all twelve indices and mapped journals are idle, published and + /// standing at one position. The owners themselves are not touched; a prompt that ran over them in between has + /// only appended (the stack compares their addresses before it keeps the graphs). + pub(crate) fn require_idle(&self) -> Result<()> { + self.validate_context(self.context)?; + if self.live.try_borrow().map_err(|_| Error::InvalidQwenShape)?.armed { + return Err(Error::InvalidQwenShape); + } + let end = self.index(0)?.next_position(); + self.check_idle_at(end) + } +} diff --git a/crates/cuda-driver/src/root_exports.rs b/crates/cuda-driver/src/root_exports.rs index 19225915..4f7be59d 100644 --- a/crates/cuda-driver/src/root_exports.rs +++ b/crates/cuda-driver/src/root_exports.rs @@ -3,6 +3,7 @@ #[allow(unused_imports)] use super::*; +pub use device_ref::DeviceRef; 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}; @@ -226,8 +227,8 @@ pub use original_verify::{ MAX_PCIE_FETCHES as ORIGINAL_VERIFY_MAX_PCIE_FETCHES, OriginalVerifier, OriginalVerifyBank, OriginalVerifyCanonicalGdn, OriginalVerifyCpuRows, OriginalVerifyCpuSink, OriginalVerifyGdnJournal, OriginalVerifyGdnStage, OriginalVerifyGdnWeights, OriginalVerifyGeometry, OriginalVerifyGpuPlan, - OriginalVerifyGraphResources, OriginalVerifyLayout, OriginalVerifyPcieSource, OriginalVerifyResources, - OriginalVerifyRow, OriginalVerifySpan, OriginalVerifyWindow, OriginalVerifyWindowResult, + OriginalVerifyGraphResources, OriginalVerifyLayout, OriginalVerifyPcieSource, OriginalVerifyRearm, + OriginalVerifyResources, OriginalVerifyRow, OriginalVerifySpan, OriginalVerifyWindow, OriginalVerifyWindowResult, OriginalVerifyWindowTokens, }; // Live verifier release/diagnostic owner, profile report and completed-logit readout. diff --git a/crates/cuda-driver/src/sm120_gdn_fused.cu b/crates/cuda-driver/src/sm120_gdn_fused.cu new file mode 100644 index 00000000..e2b1c949 --- /dev/null +++ b/crates/cuda-driver/src/sm120_gdn_fused.cu @@ -0,0 +1,310 @@ +// verify window, GDN layers (docs/experiments/verify-gdn-fused-kernels.md). Two switches, one asset, sm_120 only. +// +// LELEKA_SM120_FUSED_GDN: the three kernels of a GDN layer of the Original-literal verify window +// verify_gdn_conv_l2_multi_kernel (grid 80 x T) -> verify_gdn_ab_multi_kernel / chain_gdn_ab_multi_kernel -> verify_gdn_step_norm_multi_kernel (48 blocks of 128 x 4) +// as ONE launch of the Original's step loop (`leleka_verify_gdn_fused_step`, 48 blocks of 128 x 4, one block per value head): +// * the conv prologue: the block convolves its head's q, k and v channels (three chunks of 128) for the NEW tokens [t_begin, t_end) into shared memory. The blocks of heads < 16 write q and k to `h` +// (one writer per q/k chunk), every block writes its v chunk, because the commit graph (draft_commit.cu) and a later split-window group read `h`; +// * the gates: with ab_x != 0 two warps (alpha row `head`, beta row `head`) compute gate and beta of the new tokens and write them to `gate` / `beta`; with ab_x == 0 (SIDE_MIXER: they came from +// side stream 0 and the stream joined before this launch) they are read; +// * the tokens before t_begin (a split window's earlier group) are read from h / gate / beta, as the Original reads them; +// * the step loop: the Original's loop with its loads redirected to shared memory. A replayed token (t < t_begin) needs the state update only: its o dot product and the output path +// never feed the state and are not computed (as draft_commit.cu). +// Every output word is computed by the same operations in the same order as by the kernels above. The arithmetic is written with the SAME plain C++ expressions as original_verify.cu +// and NOT with __fmul_rn / __fadd_rn intrinsics: ptxas contracts a plain `mul.f32` feeding an `add.f32` / `sub.f32` into one FFMA (checked with ptxas 13.2 on a two instruction kernel), +// the `.rn` forms it never contracts, so the loader's JIT of original_verify.ptx fuses `v - g * kv` (the sealed PTX has a plain mul.f32 + sub.f32) and an intrinsic version would not. +// The same expression shape gives the same PTX, hence the same contraction decisions (the PTX of every phase is compared with the sealed one by a unit test). +// +// LELEKA_SM120_GDN_AB_UNROLL: upstream STRATA_SMALL_UNR bit 1 (08b20b104, gdn_ab_body): the same a/b projection with the weight/activation loop at constant trip counts (ten passes of 32 lanes, a +// constant number of tokens for T <= 6), as its own entries `leleka_gdn_ab_unrolled_t*`. One warp a row (96 rows: alpha 0..47, beta 48..95), any block of 1 or 2 warps: the host launches +// 96 blocks of 32 threads (the shape of chain_gdn_ab_multi_kernel, which `LELEKA_CHAIN=all` records) or upstream's 48 blocks of 64. +// +// Compile: nvcc --ptx -O3 -arch=sm_120 -std=c++17 --fmad=true --ftz=false (the recipe of original_verify.cu / draft_commit.cu, which are not on the fast-math list). +#include +#include +#include + +constexpr int S = 128, RG = 4, RPG = S / RG; +constexpr int H_K = 16, H_V = 48, C_QKV = 10240, QK = S * H_K, VALUE_DIM = S * H_V; +constexpr int MAX_N = 8; // window rows (max_t) +constexpr int N_EMBD = 2560, AB_CHUNKS = N_EMBD / 8 / 32; // ten passes of 32 lanes over a weight row of 320 uint4 + +// by-value kernel argument: u64 words (the host side is FusedGdnStep::words in original_verify_window_gdn_fused.rs) +struct FusedGdnArgs { + uint64_t state; // canonical state of the layer, f32 [128][48][128] (read only: the window never writes it) + uint64_t hist; // canonical conv history of the layer, f32 [10240][3] (read only) + uint64_t qkv; // qkv rows of the layer, f32 [max_t][10240] + uint64_t conv_w; // conv weights, f32 [10240][4] + uint64_t h; // conv + L2 rows of the layer, f32 [max_t][10240] (written for the new tokens) + uint64_t gate; // f32 [max_t][48] + uint64_t beta; // f32 [max_t][48] + uint64_t z; // gate projection rows, f32 [max_t][6144] + uint64_t gamma; // norm weights, f32 [128] + uint64_t y; // output rows, f32 [max_t][6144] + uint64_t ab_x; // activation row of token t_begin, f32 [m][2560]; 0: gate and beta are already in `gate` / `beta` + uint64_t ab_alpha_w; // bf16 [48][2560] + uint64_t ab_beta_w; // bf16 [48][2560] + uint64_t ab_dt; // f32 [48] + uint64_t ab_a; // f32 [48] + uint64_t eps_bits; // the f32 epsilon, bits in the low word + uint64_t t_begin; // first new token + uint64_t t_end; // window rows so far (<= 8) +}; + +struct FusedShared { + float q[MAX_N][S], k[MAX_N][S], v[MAX_N][S]; // conv + L2 output (new tokens) or h rows (replayed tokens) + float red_kv[2][RG][S]; // double buffered by token parity: a replayed token has one barrier + float red_o[RG][S]; + float l2[2][RG][S / 32]; // per conv group, double buffered by iteration + float wsum[S / 32]; + float gate[MAX_N], beta[MAX_N]; +}; + +// ---- the conv of verify_gdn_conv_l2_multi_kernel for channel c of token t (the Original's expression) ---- +__device__ __forceinline__ float conv_silu(const FusedGdnArgs& a, int c, int t) { + const float* hist = reinterpret_cast(a.hist); + const float* qkv = reinterpret_cast(a.qkv); + const float* w = reinterpret_cast(a.conv_w); + float win[3]; +#pragma unroll + for (int j = 0; j < 3; ++j) { + const int src = t + j; // index into [hist(3) | x...] + win[j] = src < 3 ? hist[c * 3 + src] : qkv[(size_t) (src - 3) * C_QKV + c]; + } + const float v0 = win[0], v1 = win[1], v2 = win[2], x = qkv[(size_t) t * C_QKV + c]; + float sum = v0 * w[c * 4] + v1 * w[c * 4 + 1] + v2 * w[c * 4 + 2] + x * w[c * 4 + 3]; + return sum / (1.0f + __expf(-sum)); +} + +// ---- one conv task: (kind 0 q, 1 k, 2 v) x (new token). The barrier count is the same for every thread of the block. ---- +__device__ __forceinline__ void conv_new_tokens(const FusedGdnArgs& a, FusedShared& sh, int head) { + const int col = threadIdx.x, rg = threadIdx.y, lane = col & 31, warp = col >> 5; + const int tb = (int) a.t_begin, tasks = 3 * ((int) a.t_end - tb), qh = head % H_K; + const float eps = __uint_as_float((uint32_t) a.eps_bits); + float* h = reinterpret_cast(a.h); + for (int it = 0; it * RG < tasks; ++it) { + const int task = it * RG + rg, kind = task % 3, t = tb + task / 3; + const bool valid = task < tasks, l2 = valid && kind < 2; + const int c = (kind == 0 ? qh : (kind == 1 ? H_K + qh : 2 * H_K + head)) * S + col; + float y = valid ? conv_silu(a, c, t) : 0.0f; + float sq = y * y; // the partials of a v task or an idle task are never read + for (int o = 16; o > 0; o >>= 1) sq += __shfl_xor_sync(0xffffffffu, sq, o); + if (lane == 0) sh.l2[it & 1][rg][warp] = sq; + __syncthreads(); + if (l2) { + const float ss = sh.l2[it & 1][rg][0] + sh.l2[it & 1][rg][1] + sh.l2[it & 1][rg][2] + sh.l2[it & 1][rg][3]; + y *= rsqrtf(ss + eps); + } + if (!valid) continue; + (kind == 0 ? sh.q : (kind == 1 ? sh.k : sh.v))[t][col] = y; + if (kind == 2 || head < H_K) h[(size_t) t * C_QKV + c] = y; + } + __syncthreads(); +} + +// ---- the tokens before t_begin come from h / gate / beta, as the Original reads them ---- +__device__ __forceinline__ void load_replayed_tokens(const FusedGdnArgs& a, FusedShared& sh, int head) { + const int tid = threadIdx.y * S + threadIdx.x, qh = head % H_K; + const float* h = reinterpret_cast(a.h); + for (int t = 0; t < (int) a.t_begin; ++t) { + if (tid < S) { + sh.k[t][tid] = h[(size_t) t * C_QKV + QK + qh * S + tid]; + sh.v[t][tid] = h[(size_t) t * C_QKV + 2 * QK + head * S + tid]; + } + } +} +__device__ __forceinline__ void load_gate_rows(const FusedGdnArgs& a, FusedShared& sh, int head) { + const int tid = threadIdx.y * S + threadIdx.x; + const int last = a.ab_x != 0 ? (int) a.t_begin : (int) a.t_end; // the rows from t_begin on are written by the ab warps + if (tid < last) { + sh.gate[tid] = reinterpret_cast(a.gate)[(size_t) tid * H_V + head]; + sh.beta[tid] = reinterpret_cast(a.beta)[(size_t) tid * H_V + head]; + } +} + +// ---- the alpha / beta projection of one row (verify_gdn_ab_multi_kernel / chain_gdn_ab_multi_kernel arithmetic) ---- +struct AbRow { uint4 w[AB_CHUNKS]; }; +__device__ __forceinline__ AbRow ab_load_row(const uint16_t* wa, const uint16_t* wb, int head, bool is_beta, int lane) { + const uint4* w4 = reinterpret_cast((is_beta ? wb : wa) + (size_t) head * N_EMBD); + AbRow row; +#pragma unroll + for (int q = 0; q < AB_CHUNKS; ++q) row.w[q] = __ldg(w4 + lane + 32 * q); + return row; +} +// per-lane partial dot products: chunk ascending, token independent (the Original's order) +__device__ __forceinline__ void ab_partials(const AbRow& row, const float* x, int lane, int m, float (&acc)[MAX_N]) { +#pragma unroll + for (int t = 0; t < MAX_N; ++t) acc[t] = 0.0f; +#pragma unroll + for (int q = 0; q < AB_CHUNKS; ++q) { + const int j = lane + 32 * q; +#pragma unroll + for (int t = 0; t < MAX_N; ++t) { + if (t >= m) break; + const float* xt = x + (size_t) t * N_EMBD; + const float4 xa = *reinterpret_cast(xt + j * 8); + const float4 xb = *reinterpret_cast(xt + j * 8 + 4); + float v = acc[t]; + v = fmaf(__uint_as_float(row.w[q].x << 16), xa.x, v); v = fmaf(__uint_as_float(row.w[q].x & 0xffff0000u), xa.y, v); + v = fmaf(__uint_as_float(row.w[q].y << 16), xa.z, v); v = fmaf(__uint_as_float(row.w[q].y & 0xffff0000u), xa.w, v); + v = fmaf(__uint_as_float(row.w[q].z << 16), xb.x, v); v = fmaf(__uint_as_float(row.w[q].z & 0xffff0000u), xb.y, v); + v = fmaf(__uint_as_float(row.w[q].w << 16), xb.z, v); v = fmaf(__uint_as_float(row.w[q].w & 0xffff0000u), xb.w, v); + acc[t] = v; + } + } +} +// the gate (alpha row) or beta (beta row) of a reduced dot product +__device__ __forceinline__ float ab_value(float a, bool is_beta, float dt, float ssm_a) { + if (is_beta) return 1.0f / (1.0f + __expf(-a)); + const float v = a + dt; + const float sp = v > 20.0f ? v : log1pf(__expf(v)); + return sp * ssm_a; +} + +__device__ __forceinline__ void ab_new_tokens(const FusedGdnArgs& a, FusedShared& sh, int head, const AbRow& row) { + const int lane = threadIdx.x & 31, tb = (int) a.t_begin, m = (int) a.t_end - tb; + const bool is_beta = (threadIdx.x >> 5) == 1; + float acc[MAX_N]; + ab_partials(row, reinterpret_cast(a.ab_x), lane, m, acc); +#pragma unroll + for (int t = 0; t < MAX_N; ++t) { + if (t >= m) break; + float sum = acc[t]; + for (int o = 16; o > 0; o >>= 1) sum += __shfl_xor_sync(0xffffffffu, sum, o); + if (lane != 0) continue; + const float v = ab_value(sum, is_beta, reinterpret_cast(a.ab_dt)[head], reinterpret_cast(a.ab_a)[head]); + (is_beta ? sh.beta : sh.gate)[tb + t] = v; + (is_beta ? reinterpret_cast(a.beta) : reinterpret_cast(a.gate))[(size_t) (tb + t) * H_V + head] = v; + } +} + +// ---- the Original's step loop (verify_gdn_step_norm_multi_kernel) over shared memory ---- +__device__ __forceinline__ void output_token(const FusedGdnArgs& a, FusedShared& sh, int head, int t, float o) { + const int col = threadIdx.x, rg = threadIdx.y, tid = rg * S + col; + const float eps = __uint_as_float((uint32_t) a.eps_bits); + sh.red_o[rg][col] = o; + __syncthreads(); + float oc = 0.0f, sq_part = 0.0f; + if (rg == 0) { + oc = (sh.red_o[0][col] + sh.red_o[1][col] + sh.red_o[2][col] + sh.red_o[3][col]) * rsqrtf((float) S); + sq_part = oc * oc; + for (int o2 = 16; o2 > 0; o2 >>= 1) sq_part += __shfl_xor_sync(0xffffffffu, sq_part, o2); + if ((tid & 31) == 0) sh.wsum[tid >> 5] = sq_part; + } + __syncthreads(); + if (rg != 0) return; + const float ss = sh.wsum[0] + sh.wsum[1] + sh.wsum[2] + sh.wsum[3]; + const float scale = rsqrtf(ss / (float) S + eps); + const float zz = reinterpret_cast(a.z)[(size_t) t * VALUE_DIM + head * S + col]; + reinterpret_cast(a.y)[(size_t) t * VALUE_DIM + head * S + col] = + oc * scale * reinterpret_cast(a.gamma)[col] * (1.0f / (1.0f + __expf(-zz))); +} + +__device__ __forceinline__ void recurrence(const FusedGdnArgs& a, FusedShared& sh, int head) { + const int col = threadIdx.x, rg = threadIdx.y, n = (int) a.t_end, tb = (int) a.t_begin; + const float* state = reinterpret_cast(a.state) + ((size_t) (rg * RPG) * H_V + head) * S + col; + float s[RPG]; +#pragma unroll + for (int r = 0; r < RPG; ++r) s[r] = state[(size_t) r * H_V * S]; + for (int t = 0; t < n; ++t) { + const float g = __expf(sh.gate[t]); + float kv = 0.0f; +#pragma unroll + for (int r = 0; r < RPG; ++r) kv = fmaf(s[r], sh.k[t][rg * RPG + r], kv); + sh.red_kv[t & 1][rg][col] = kv; + __syncthreads(); + const float kv_col = sh.red_kv[t & 1][0][col] + sh.red_kv[t & 1][1][col] + sh.red_kv[t & 1][2][col] + sh.red_kv[t & 1][3][col]; + const float delta = (sh.v[t][col] - g * kv_col) * sh.beta[t]; + if (t < tb) { // a replayed token: its state update is needed, its output is not +#pragma unroll + for (int r = 0; r < RPG; ++r) s[r] = fmaf(g, s[r], sh.k[t][rg * RPG + r] * delta); + continue; + } + float o = 0.0f; +#pragma unroll + for (int r = 0; r < RPG; ++r) { + s[r] = fmaf(g, s[r], sh.k[t][rg * RPG + r] * delta); + o = fmaf(s[r], sh.q[t][rg * RPG + r], o); + } + output_token(a, sh, head, t, o); + } +} + +// grid (48), block (128, 4): one block per value head +extern "C" __global__ void __launch_bounds__(S * RG) leleka_verify_gdn_fused_step(FusedGdnArgs a) { + __shared__ FusedShared sh; + const int head = blockIdx.x, warp = (threadIdx.y * S + threadIdx.x) >> 5; + AbRow row; + if (a.ab_x != 0 && warp < 2) { // the weight loads are in flight while the whole block convolves + row = ab_load_row(reinterpret_cast(a.ab_alpha_w), reinterpret_cast(a.ab_beta_w), head, warp == 1, + threadIdx.x & 31); + } + load_replayed_tokens(a, sh, head); + load_gate_rows(a, sh, head); + conv_new_tokens(a, sh, head); + if (a.ab_x != 0 && warp < 2) ab_new_tokens(a, sh, head, row); + __syncthreads(); + recurrence(a, sh, head); +} + +// ------------------------------------------------------------------------------------------------------------------ +// LELEKA_SM120_GDN_AB_UNROLL: upstream gdn_ab_body (STRATA_SMALL_UNR bit 1) on the Original's arguments. +// ------------------------------------------------------------------------------------------------------------------ +template +__device__ __forceinline__ void ab_unrolled_body(const float* __restrict__ x, const uint16_t* __restrict__ wa, const uint16_t* __restrict__ wb, + const float* __restrict__ dt, const float* __restrict__ ssm_a, float* __restrict__ gate, + float* __restrict__ beta, int h_v, int T) { + const int row = blockIdx.x * (blockDim.x >> 5) + (threadIdx.x >> 5), lane = threadIdx.x & 31; + if (row >= 2 * h_v) return; + const bool is_beta = row >= h_v; + const int r = is_beta ? row - h_v : row; + const uint4* w4 = reinterpret_cast((is_beta ? wb : wa) + (size_t) r * N_EMBD); + float acc[MAX_T]; +#pragma unroll + for (int t = 0; t < MAX_T; ++t) acc[t] = 0.0f; +#pragma unroll + for (int jj = 0; jj < AB_CHUNKS; ++jj) { // the ten passes, j = lane + 32 jj, all < 320 + const int j = lane + 32 * jj; + const uint4 wv = __ldg(w4 + j); +#pragma unroll + for (int t = 0; t < MAX_T; ++t) { + if (!EXACT_T && t >= T) break; + const float* xt = x + (size_t) t * N_EMBD; + const float4 xa = __ldg(reinterpret_cast(xt + j * 8)); + const float4 xb = __ldg(reinterpret_cast(xt + j * 8 + 4)); + float v = acc[t]; + v = fmaf(__uint_as_float(wv.x << 16), xa.x, v); v = fmaf(__uint_as_float(wv.x & 0xffff0000u), xa.y, v); + v = fmaf(__uint_as_float(wv.y << 16), xa.z, v); v = fmaf(__uint_as_float(wv.y & 0xffff0000u), xa.w, v); + v = fmaf(__uint_as_float(wv.z << 16), xb.x, v); v = fmaf(__uint_as_float(wv.z & 0xffff0000u), xb.y, v); + v = fmaf(__uint_as_float(wv.w << 16), xb.z, v); v = fmaf(__uint_as_float(wv.w & 0xffff0000u), xb.w, v); + acc[t] = v; + } + } +#pragma unroll + for (int t = 0; t < MAX_T; ++t) { + if (!EXACT_T && t >= T) break; + float sum = acc[t]; +#pragma unroll + for (int o = 16; o > 0; o >>= 1) sum += __shfl_xor_sync(0xffffffffu, sum, o); + if (lane != 0) continue; + const float v = ab_value(sum, is_beta, dt[r], ssm_a[r]); + (is_beta ? beta : gate)[(size_t) t * h_v + r] = v; + } +} + +// the Original's argument list (x, wa, wb, dt, ssm_a, gate, beta, n, h_v, T); 2 h_v rows, one warp each +#define LELEKA_AB_UNROLLED(NAME, MAX_T, EXACT_T) \ + extern "C" __global__ void __launch_bounds__(64) NAME(const float* __restrict__ x, const uint16_t* __restrict__ wa, \ + const uint16_t* __restrict__ wb, const float* __restrict__ dt, \ + const float* __restrict__ ssm_a, float* __restrict__ gate, \ + float* __restrict__ beta, int n, int h_v, int T) { \ + (void) n; /* n == 2560: the host refuses any other width */ \ + ab_unrolled_body(x, wa, wb, dt, ssm_a, gate, beta, h_v, T); \ + } +LELEKA_AB_UNROLLED(leleka_gdn_ab_unrolled_t1, 1, true) +LELEKA_AB_UNROLLED(leleka_gdn_ab_unrolled_t2, 2, true) +LELEKA_AB_UNROLLED(leleka_gdn_ab_unrolled_t3, 3, true) +LELEKA_AB_UNROLLED(leleka_gdn_ab_unrolled_t4, 4, true) +LELEKA_AB_UNROLLED(leleka_gdn_ab_unrolled_t5, 5, true) +LELEKA_AB_UNROLLED(leleka_gdn_ab_unrolled_t6, 6, true) +LELEKA_AB_UNROLLED(leleka_gdn_ab_unrolled_t8, 8, false) // T = 7 and 8: upstream's kVerifyNarrowT loop, the token count a run time argument diff --git a/crates/cuda-driver/src/sm120_gdn_fused.ptx b/crates/cuda-driver/src/sm120_gdn_fused.ptx new file mode 100644 index 00000000..f84d559a --- /dev/null +++ b/crates/cuda-driver/src/sm120_gdn_fused.ptx @@ -0,0 +1,10827 @@ +// +// 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_verify_gdn_fused_step +// _ZZ28leleka_verify_gdn_fused_stepE2sh has been demoted + +.visible .entry leleka_verify_gdn_fused_step( + .param .align 8 .b8 leleka_verify_gdn_fused_step_param_0[144] +) +.maxntid 512 +{ + .reg .pred %p<211>; + .reg .b32 %r<2371>; + .reg .b64 %rd<276>; + // demoted variable + .shared .align 4 .b8 _ZZ28leleka_verify_gdn_fused_stepE2sh[18640]; + mov.b64 %rd1, leleka_verify_gdn_fused_step_param_0; + mov.u32 %r1, %ctaid.x; + mov.u32 %r2294, %tid.y; + shl.b32 %r139, %r2294, 7; + mov.u32 %r2, %tid.x; + add.s32 %r140, %r139, %r2; + ld.param.b64 %rd9, [leleka_verify_gdn_fused_step_param_0+80]; + setp.ne.b64 %p3, %rd9, 0; + setp.lt.u32 %p4, %r140, 64; + and.pred %p1, %p3, %p4; + not.pred %p5, %p1; + @%p5 bra $L__BB0_2; + ld.param.b64 %rd20, [%rd1+88]; + ld.param.b64 %rd21, [%rd1+96]; + setp.lt.u32 %p6, %r2, 32; + selp.b64 %rd22, %rd20, %rd21, %p6; + mul.wide.u32 %rd23, %r1, 5120; + add.s64 %rd24, %rd22, %rd23; + shl.b32 %r141, %r2, 4; + cvt.u64.u32 %rd25, %r141; + and.b64 %rd26, %rd25, 496; + add.s64 %rd10, %rd24, %rd26; + // begin inline asm + ld.global.nc.v4.u32 {%r2286,%r2285,%r2284,%r2283}, [%rd10]; + // end inline asm + add.s64 %rd11, %rd10, 512; + // begin inline asm + ld.global.nc.v4.u32 {%r2282,%r2281,%r2280,%r2279}, [%rd11]; + // end inline asm + add.s64 %rd12, %rd10, 1024; + // begin inline asm + ld.global.nc.v4.u32 {%r2278,%r2277,%r2276,%r2275}, [%rd12]; + // end inline asm + add.s64 %rd13, %rd10, 1536; + // begin inline asm + ld.global.nc.v4.u32 {%r2274,%r2273,%r2272,%r2271}, [%rd13]; + // end inline asm + add.s64 %rd14, %rd10, 2048; + // begin inline asm + ld.global.nc.v4.u32 {%r2270,%r2269,%r2268,%r2267}, [%rd14]; + // end inline asm + add.s64 %rd15, %rd10, 2560; + // begin inline asm + ld.global.nc.v4.u32 {%r2266,%r2265,%r2264,%r2263}, [%rd15]; + // end inline asm + add.s64 %rd16, %rd10, 3072; + // begin inline asm + ld.global.nc.v4.u32 {%r2262,%r2261,%r2260,%r2259}, [%rd16]; + // end inline asm + add.s64 %rd17, %rd10, 3584; + // begin inline asm + ld.global.nc.v4.u32 {%r2258,%r2257,%r2256,%r2255}, [%rd17]; + // end inline asm + add.s64 %rd18, %rd10, 4096; + // begin inline asm + ld.global.nc.v4.u32 {%r2254,%r2253,%r2252,%r2251}, [%rd18]; + // end inline asm + add.s64 %rd19, %rd10, 4608; + // begin inline asm + ld.global.nc.v4.u32 {%r2250,%r2249,%r2248,%r2247}, [%rd19]; + // end inline asm +$L__BB0_2: + ld.param.b32 %r3, [%rd1+128]; + setp.lt.s32 %p7, %r3, 1; + @%p7 bra $L__BB0_13; + setp.lt.s32 %p8, %r3, 4; + mov.b32 %r2289, 0; + @%p8 bra $L__BB0_9; + shr.u32 %r142, %r3, 2; + and.b32 %r4, %r142, 536870911; + and.b32 %r143, %r3, 2147483644; + neg.s32 %r2288, %r143; + and.b32 %r144, %r1, 15; + mul.wide.u32 %rd27, %r144, 512; + cvt.u64.u32 %rd28, %r140; + mul.wide.u32 %rd29, %r140, 4; + add.s64 %rd30, %rd27, %rd29; + ld.param.b64 %rd31, [%rd1+32]; + cvta.to.global.u64 %rd32, %rd31; + add.s64 %rd33, %rd30, %rd32; + add.s64 %rd271, %rd33, 90112; + shl.b32 %r145, %r1, 7; + cvt.u64.u32 %rd34, %r145; + add.s64 %rd35, %rd34, %rd28; + shl.b64 %rd36, %rd35, 2; + add.s64 %rd37, %rd36, %rd32; + add.s64 %rd270, %rd37, 98304; + shl.b32 %r146, %r2294, 9; + shl.b32 %r147, %r2, 2; + add.s32 %r148, %r146, %r147; + mov.b32 %r149, _ZZ28leleka_verify_gdn_fused_stepE2sh; + add.s32 %r150, %r148, %r149; + add.s32 %r2287, %r150, 5120; +$L__BB0_5: + setp.gt.u32 %p9, %r140, 127; + @%p9 bra $L__BB0_7; + ld.global.b32 %r151, [%rd271+-81920]; + st.shared.b32 [%r2287+-1024], %r151; + ld.global.b32 %r152, [%rd270+-81920]; + st.shared.b32 [%r2287+3072], %r152; + ld.global.b32 %r153, [%rd271+-40960]; + st.shared.b32 [%r2287+-512], %r153; + ld.global.b32 %r154, [%rd270+-40960]; + st.shared.b32 [%r2287+3584], %r154; + ld.global.b32 %r155, [%rd271]; + st.shared.b32 [%r2287], %r155; + ld.global.b32 %r156, [%rd270]; + st.shared.b32 [%r2287+4096], %r156; + ld.global.b32 %r157, [%rd271+40960]; + st.shared.b32 [%r2287+512], %r157; + ld.global.b32 %r158, [%rd270+40960]; + st.shared.b32 [%r2287+4608], %r158; +$L__BB0_7: + add.s32 %r2288, %r2288, 4; + add.s64 %rd271, %rd271, 163840; + add.s64 %rd270, %rd270, 163840; + add.s32 %r2287, %r2287, 2048; + setp.ne.b32 %p10, %r2288, 0; + @%p10 bra $L__BB0_5; + and.b32 %r159, %r3, 3; + setp.eq.b32 %p11, %r159, 0; + shl.b32 %r2289, %r4, 2; + @%p11 bra $L__BB0_13; +$L__BB0_9: + and.b32 %r160, %r3, 3; + neg.s32 %r2291, %r160; + shl.b32 %r161, %r2294, 9; + shl.b32 %r162, %r2289, 9; + add.s32 %r163, %r161, %r162; + shl.b32 %r164, %r2, 2; + add.s32 %r165, %r163, %r164; + mov.b32 %r166, _ZZ28leleka_verify_gdn_fused_stepE2sh; + add.s32 %r167, %r165, %r166; + add.s32 %r2290, %r167, 8192; + mul.wide.u32 %rd38, %r2289, 10240; + shl.b32 %r168, %r1, 7; + cvt.u64.u32 %rd39, %r168; + add.s64 %rd40, %rd38, %rd39; + cvt.u64.u32 %rd41, %r140; + add.s64 %rd42, %rd40, %rd41; + shl.b64 %rd43, %rd42, 2; + ld.param.b64 %rd44, [%rd1+32]; + cvta.to.global.u64 %rd45, %rd44; + add.s64 %rd46, %rd43, %rd45; + add.s64 %rd273, %rd46, 16384; + and.b32 %r169, %r1, 15; + mul.wide.u32 %rd47, %r169, 128; + or.b64 %rd48, %rd38, %rd47; + add.s64 %rd49, %rd48, %rd41; + shl.b64 %rd50, %rd49, 2; + add.s64 %rd51, %rd50, %rd45; + add.s64 %rd272, %rd51, 8192; +$L__BB0_10: + .pragma "nounroll"; + setp.gt.u32 %p12, %r140, 127; + @%p12 bra $L__BB0_12; + ld.global.b32 %r170, [%rd272]; + st.shared.b32 [%r2290+-4096], %r170; + ld.global.b32 %r171, [%rd273]; + st.shared.b32 [%r2290], %r171; +$L__BB0_12: + add.s32 %r2291, %r2291, 1; + setp.ne.b32 %p13, %r2291, 0; + add.s32 %r2290, %r2290, 512; + add.s64 %rd273, %rd273, 40960; + add.s64 %rd272, %rd272, 40960; + @%p13 bra $L__BB0_10; +$L__BB0_13: + ld.param.b64 %rd52, [%rd1+80]; + setp.eq.b64 %p14, %rd52, 0; + ld.param.b64 %rd2, [%rd1+136]; + ld.param.b64 %rd53, [%rd1+128]; + selp.b64 %rd54, %rd2, %rd53, %p14; + cvt.u32.u64 %r172, %rd54; + setp.ge.s32 %p15, %r140, %r172; + @%p15 bra $L__BB0_15; + shl.b32 %r173, %r140, 2; + mov.b32 %r174, _ZZ28leleka_verify_gdn_fused_stepE2sh; + add.s32 %r175, %r174, %r173; + ld.param.b64 %rd55, [%rd1+40]; + cvta.to.global.u64 %rd56, %rd55; + mad.lo.s32 %r176, %r140, 48, %r1; + mul.wide.u32 %rd57, %r176, 4; + add.s64 %rd58, %rd56, %rd57; + ld.global.b32 %r177, [%rd58]; + st.shared.b32 [%r175+18576], %r177; + ld.param.b64 %rd59, [%rd1+48]; + cvta.to.global.u64 %rd60, %rd59; + add.s64 %rd61, %rd60, %rd57; + ld.global.b32 %r178, [%rd61]; + st.shared.b32 [%r175+18608], %r178; +$L__BB0_15: + cvt.u32.u64 %r179, %rd2; + sub.s32 %r5, %r179, %r3; + ld.param.b32 %r6, [%rd1+120]; + setp.lt.s32 %p16, %r5, 1; + @%p16 bra $L__BB0_40; + mul.lo.s32 %r180, %r5, 3; + max.s32 %r181, %r180, 4; + add.s32 %r182, %r181, -1; + shr.u32 %r183, %r182, 2; + add.s32 %r2295, %r2294, -1; + neg.s32 %r2293, %r183; + mov.b32 %r2292, -1; +$L__BB0_17: + mov.u32 %r185, %ctaid.x; + and.b32 %r2296, %r185, 15; + mul.hi.u32 %r186, %r2294, -1431655765; + shr.u32 %r187, %r186, 1; + add.s32 %r2292, %r2292, 1; + add.s32 %r188, %r2295, 1; + mad.lo.s32 %r7, %r187, -3, %r2295; + add.s32 %r184, %r7, 1; + mul.hi.u32 %r189, %r188, -1431655765; + shr.u32 %r190, %r189, 1; + add.s32 %r8, %r190, %r3; + ld.param.b32 %r191, [%rd1+136]; + sub.s32 %r9, %r191, %r3; + mul.lo.s32 %r192, %r9, 3; + setp.lt.s32 %p17, %r188, %r192; + setp.lt.u32 %p18, %r184, 2; + and.pred %p2, %p17, %p18; + setp.eq.b32 %p19, %r184, 0; + @%p19 bra $L__BB0_21; + setp.ne.b32 %p20, %r184, 1; + @%p20 bra $L__BB0_20; + mov.u32 %r193, %ctaid.x; + and.b32 %r194, %r193, 15; + or.b32 %r2296, %r194, 16; + bra.uni $L__BB0_21; +$L__BB0_20: + mov.u32 %r195, %ctaid.x; + add.s32 %r2296, %r195, 32; +$L__BB0_21: + add.s32 %r196, %r2295, 1; + setp.ge.s32 %p21, %r196, %r192; + shl.b32 %r197, %r2296, 7; + mov.u32 %r198, %tid.x; + add.s32 %r10, %r197, %r198; + mov.b32 %r2300, 0f00000000; + @%p21 bra $L__BB0_32; + setp.gt.s32 %p22, %r8, 2; + @%p22 bra $L__BB0_24; + mad.lo.s32 %r200, %r10, 3, %r8; + ld.param.b64 %rd69, [%rd1+8]; + cvta.to.global.u64 %rd70, %rd69; + mul.wide.s32 %rd71, %r200, 4; + add.s64 %rd72, %rd70, %rd71; + ld.global.b32 %r2297, [%rd72]; + bra.uni $L__BB0_25; +$L__BB0_24: + add.s32 %r199, %r8, -3; + mul.wide.u32 %rd62, %r199, 10240; + cvt.u64.u32 %rd63, %r10; + add.s64 %rd64, %rd62, %rd63; + ld.param.b64 %rd65, [%rd1+16]; + cvta.to.global.u64 %rd66, %rd65; + shl.b64 %rd67, %rd64, 2; + add.s64 %rd68, %rd66, %rd67; + ld.global.b32 %r2297, [%rd68]; +$L__BB0_25: + setp.lt.s32 %p23, %r8, 2; + @%p23 bra $L__BB0_27; + add.s32 %r201, %r8, -2; + mul.wide.u32 %rd73, %r201, 10240; + cvt.u64.u32 %rd74, %r10; + add.s64 %rd75, %rd73, %rd74; + ld.param.b64 %rd76, [%rd1+16]; + cvta.to.global.u64 %rd77, %rd76; + shl.b64 %rd78, %rd75, 2; + add.s64 %rd79, %rd77, %rd78; + ld.global.b32 %r2298, [%rd79]; + bra.uni $L__BB0_28; +$L__BB0_27: + mul.wide.s32 %rd80, %r10, 3; + cvt.s64.s32 %rd81, %r8; + add.s64 %rd82, %rd81, %rd80; + ld.param.b64 %rd83, [%rd1+8]; + cvta.to.global.u64 %rd84, %rd83; + shl.b64 %rd85, %rd82, 2; + add.s64 %rd86, %rd84, %rd85; + ld.global.b32 %r2298, [%rd86+4]; +$L__BB0_28: + setp.lt.s32 %p24, %r8, 1; + @%p24 bra $L__BB0_30; + add.s32 %r202, %r8, -1; + mul.wide.u32 %rd87, %r202, 10240; + cvt.u64.u32 %rd88, %r10; + add.s64 %rd89, %rd87, %rd88; + ld.param.b64 %rd90, [%rd1+16]; + cvta.to.global.u64 %rd91, %rd90; + shl.b64 %rd92, %rd89, 2; + add.s64 %rd93, %rd91, %rd92; + ld.global.b32 %r2299, [%rd93]; + bra.uni $L__BB0_31; +$L__BB0_30: + mul.wide.s32 %rd94, %r10, 3; + cvt.s64.s32 %rd95, %r8; + add.s64 %rd96, %rd95, %rd94; + ld.param.b64 %rd97, [%rd1+8]; + cvta.to.global.u64 %rd98, %rd97; + shl.b64 %rd99, %rd96, 2; + add.s64 %rd100, %rd98, %rd99; + ld.global.b32 %r2299, [%rd100+8]; +$L__BB0_31: + mul.wide.s32 %rd101, %r8, 10240; + cvt.u64.u32 %rd102, %r10; + add.s64 %rd103, %rd101, %rd102; + ld.param.b64 %rd104, [%rd1+16]; + cvta.to.global.u64 %rd105, %rd104; + shl.b64 %rd106, %rd103, 2; + add.s64 %rd107, %rd105, %rd106; + ld.global.b32 %r203, [%rd107]; + shl.b32 %r204, %r10, 2; + ld.param.b64 %rd108, [%rd1+24]; + cvta.to.global.u64 %rd109, %rd108; + mul.wide.u32 %rd110, %r204, 4; + add.s64 %rd111, %rd109, %rd110; + ld.global.b32 %r205, [%rd111]; + ld.global.b32 %r206, [%rd111+4]; + mul.f32 %r207, %r2298, %r206; + fma.rn.f32 %r208, %r2297, %r205, %r207; + ld.global.b32 %r209, [%rd111+8]; + fma.rn.f32 %r210, %r2299, %r209, %r208; + ld.global.b32 %r211, [%rd111+12]; + fma.rn.f32 %r212, %r203, %r211, %r210; + mul.f32 %r213, %r212, 0fBFB8AA3B; + ex2.approx.f32 %r214, %r213; + add.f32 %r215, %r214, 0f3F800000; + div.rn.f32 %r2300, %r212, %r215; +$L__BB0_32: + mov.u32 %r11, %tid.x; + and.b32 %r216, %r11, 31; + setp.ne.b32 %p25, %r216, 0; + mul.f32 %r217, %r2300, %r2300; + shfl.sync.bfly.b32 %r218|%p26, %r217, 16, 31, -1; + add.f32 %r219, %r217, %r218; + shfl.sync.bfly.b32 %r220|%p27, %r219, 8, 31, -1; + add.f32 %r221, %r219, %r220; + shfl.sync.bfly.b32 %r222|%p28, %r221, 4, 31, -1; + add.f32 %r223, %r221, %r222; + shfl.sync.bfly.b32 %r224|%p29, %r223, 2, 31, -1; + add.f32 %r225, %r223, %r224; + shfl.sync.bfly.b32 %r226|%p30, %r225, 1, 31, -1; + add.f32 %r12, %r225, %r226; + @%p25 bra $L__BB0_34; + mov.u32 %r227, %tid.y; + shl.b32 %r228, %r227, 4; + mov.b32 %r229, _ZZ28leleka_verify_gdn_fused_stepE2sh; + add.s32 %r230, %r229, %r228; + shr.u32 %r231, %r11, 3; + and.b32 %r232, %r231, 124; + add.s32 %r233, %r230, %r232; + shl.b32 %r234, %r2292, 6; + and.b32 %r235, %r234, 64; + add.s32 %r236, %r233, %r235; + st.shared.b32 [%r236+18432], %r12; +$L__BB0_34: + bar.sync 0; + not.pred %p31, %p2; + @%p31 bra $L__BB0_36; + mov.u32 %r237, %tid.y; + shl.b32 %r238, %r237, 4; + mov.b32 %r239, _ZZ28leleka_verify_gdn_fused_stepE2sh; + add.s32 %r240, %r239, %r238; + shl.b32 %r241, %r2292, 6; + and.b32 %r242, %r241, 64; + add.s32 %r243, %r240, %r242; + ld.shared.b32 %r244, [%r243+18432]; + ld.shared.b32 %r245, [%r243+18436]; + add.f32 %r246, %r244, %r245; + ld.shared.b32 %r247, [%r243+18440]; + add.f32 %r248, %r246, %r247; + ld.shared.b32 %r249, [%r243+18444]; + add.f32 %r250, %r248, %r249; + add.f32 %r251, %r250, %r6; + rsqrt.approx.f32 %r252, %r251; + mul.f32 %r2300, %r2300, %r252; +$L__BB0_36: + ld.param.b32 %r253, [%rd1+136]; + sub.s32 %r254, %r253, %r3; + mul.lo.s32 %r255, %r254, 3; + add.s32 %r256, %r2295, 1; + setp.ge.s32 %p32, %r256, %r255; + @%p32 bra $L__BB0_39; + mov.u32 %r257, %ctaid.x; + setp.gt.u32 %p33, %r257, 15; + setp.eq.b32 %p34, %r7, 0; + selp.b32 %r258, 4096, 8192, %p34; + mov.b32 %r259, _ZZ28leleka_verify_gdn_fused_stepE2sh; + add.s32 %r260, %r259, %r258; + setp.eq.b32 %p35, %r7, -1; + selp.b32 %r261, %r259, %r260, %p35; + shl.b32 %r262, %r8, 9; + add.s32 %r263, %r261, %r262; + mov.u32 %r264, %tid.x; + shl.b32 %r265, %r264, 2; + add.s32 %r266, %r263, %r265; + st.shared.b32 [%r266], %r2300; + setp.ne.b32 %p36, %r7, 1; + and.pred %p37, %p36, %p33; + @%p37 bra $L__BB0_39; + mul.wide.s32 %rd112, %r8, 10240; + cvt.u64.u32 %rd113, %r10; + add.s64 %rd114, %rd112, %rd113; + ld.param.b64 %rd115, [%rd1+32]; + cvta.to.global.u64 %rd116, %rd115; + shl.b64 %rd117, %rd114, 2; + add.s64 %rd118, %rd116, %rd117; + st.global.b32 [%rd118], %r2300; +$L__BB0_39: + add.s32 %r2295, %r2295, 4; + add.s32 %r2294, %r2294, 4; + add.s32 %r2293, %r2293, 1; + setp.ne.b32 %p38, %r2293, 1; + @%p38 bra $L__BB0_17; +$L__BB0_40: + bar.sync 0; + @%p5 bra $L__BB0_194; + ld.param.b32 %r267, [%rd1+136]; + sub.s32 %r268, %r267, %r3; + setp.lt.s32 %p39, %r268, 1; + mov.b32 %r2301, 0f00000000; + mov.b32 %r2241, 0f00000000; + mov.b32 %r2242, 0f00000000; + mov.b32 %r2243, 0f00000000; + mov.b32 %r2244, 0f00000000; + mov.b32 %r2245, 0f00000000; + mov.b32 %r2246, 0f00000000; + mov.b32 %r2302, %r2301; + mov.b32 %r2303, %r2301; + mov.b32 %r2304, %r2301; + mov.b32 %r2305, %r2301; + mov.b32 %r2306, %r2301; + mov.b32 %r2307, %r2301; + mov.b32 %r2308, %r2301; + @%p39 bra $L__BB0_115; + shl.b32 %r13, %r2286, 16; + and.b32 %r14, %r2286, -65536; + shl.b32 %r15, %r2285, 16; + and.b32 %r16, %r2285, -65536; + shl.b32 %r17, %r2284, 16; + and.b32 %r18, %r2284, -65536; + shl.b32 %r19, %r2283, 16; + and.b32 %r20, %r2283, -65536; + mov.u32 %r269, %tid.x; + shl.b32 %r270, %r269, 3; + and.b32 %r271, %r270, 248; + ld.param.b64 %rd119, [%rd1+80]; + cvta.to.global.u64 %rd120, %rd119; + mul.wide.u32 %rd121, %r271, 4; + add.s64 %rd122, %rd120, %rd121; + ld.global.v4.b32 {%r272, %r273, %r274, %r275}, [%rd122]; + ld.global.v4.b32 {%r276, %r277, %r278, %r279}, [%rd122+16]; + fma.rn.f32 %r280, %r13, %r272, 0f00000000; + fma.rn.f32 %r281, %r14, %r273, %r280; + fma.rn.f32 %r282, %r15, %r274, %r281; + fma.rn.f32 %r283, %r16, %r275, %r282; + fma.rn.f32 %r284, %r17, %r276, %r283; + fma.rn.f32 %r285, %r18, %r277, %r284; + fma.rn.f32 %r286, %r19, %r278, %r285; + fma.rn.f32 %r21, %r20, %r279, %r286; + ld.param.b32 %r287, [%rd1+136]; + sub.s32 %r288, %r287, %r3; + setp.eq.b32 %p40, %r288, 1; + mov.b32 %r2302, 0f00000000; + mov.b32 %r2303, %r2241; + mov.b32 %r2304, %r2242; + mov.b32 %r2305, %r2243; + mov.b32 %r2306, %r2244; + mov.b32 %r2307, %r2245; + mov.b32 %r2308, %r2246; + @%p40 bra $L__BB0_50; + ld.param.b64 %rd123, [%rd1+80]; + cvta.to.global.u64 %rd124, %rd123; + mov.u32 %r289, %tid.x; + shl.b32 %r290, %r289, 3; + and.b32 %r291, %r290, 248; + mul.wide.u32 %rd125, %r291, 4; + add.s64 %rd126, %rd124, %rd125; + ld.global.v4.b32 {%r292, %r293, %r294, %r295}, [%rd126+10240]; + ld.global.v4.b32 {%r296, %r297, %r298, %r299}, [%rd126+10256]; + fma.rn.f32 %r300, %r13, %r292, 0f00000000; + fma.rn.f32 %r301, %r14, %r293, %r300; + fma.rn.f32 %r302, %r15, %r294, %r301; + fma.rn.f32 %r303, %r16, %r295, %r302; + fma.rn.f32 %r304, %r17, %r296, %r303; + fma.rn.f32 %r305, %r18, %r297, %r304; + fma.rn.f32 %r306, %r19, %r298, %r305; + fma.rn.f32 %r2302, %r20, %r299, %r306; + ld.param.b32 %r307, [%rd1+136]; + sub.s32 %r308, %r307, %r3; + setp.lt.u32 %p41, %r308, 3; + mov.b32 %r2303, %r2241; + mov.b32 %r2304, %r2242; + mov.b32 %r2305, %r2243; + mov.b32 %r2306, %r2244; + mov.b32 %r2307, %r2245; + mov.b32 %r2308, %r2246; + @%p41 bra $L__BB0_50; + ld.param.b64 %rd127, [%rd1+80]; + cvta.to.global.u64 %rd128, %rd127; + mov.u32 %r309, %tid.x; + shl.b32 %r310, %r309, 3; + and.b32 %r311, %r310, 248; + mul.wide.u32 %rd129, %r311, 4; + add.s64 %rd130, %rd128, %rd129; + ld.global.v4.b32 {%r312, %r313, %r314, %r315}, [%rd130+20480]; + ld.global.v4.b32 {%r316, %r317, %r318, %r319}, [%rd130+20496]; + fma.rn.f32 %r320, %r13, %r312, 0f00000000; + fma.rn.f32 %r321, %r14, %r313, %r320; + fma.rn.f32 %r322, %r15, %r314, %r321; + fma.rn.f32 %r323, %r16, %r315, %r322; + fma.rn.f32 %r324, %r17, %r316, %r323; + fma.rn.f32 %r325, %r18, %r317, %r324; + fma.rn.f32 %r326, %r19, %r318, %r325; + fma.rn.f32 %r2303, %r20, %r319, %r326; + ld.param.b32 %r327, [%rd1+136]; + sub.s32 %r328, %r327, %r3; + setp.eq.b32 %p42, %r328, 3; + mov.b32 %r2304, %r2242; + mov.b32 %r2305, %r2243; + mov.b32 %r2306, %r2244; + mov.b32 %r2307, %r2245; + mov.b32 %r2308, %r2246; + @%p42 bra $L__BB0_50; + ld.param.b64 %rd131, [%rd1+80]; + cvta.to.global.u64 %rd132, %rd131; + mov.u32 %r329, %tid.x; + shl.b32 %r330, %r329, 3; + and.b32 %r331, %r330, 248; + mul.wide.u32 %rd133, %r331, 4; + add.s64 %rd134, %rd132, %rd133; + ld.global.v4.b32 {%r332, %r333, %r334, %r335}, [%rd134+30720]; + ld.global.v4.b32 {%r336, %r337, %r338, %r339}, [%rd134+30736]; + fma.rn.f32 %r340, %r13, %r332, 0f00000000; + fma.rn.f32 %r341, %r14, %r333, %r340; + fma.rn.f32 %r342, %r15, %r334, %r341; + fma.rn.f32 %r343, %r16, %r335, %r342; + fma.rn.f32 %r344, %r17, %r336, %r343; + fma.rn.f32 %r345, %r18, %r337, %r344; + fma.rn.f32 %r346, %r19, %r338, %r345; + fma.rn.f32 %r2304, %r20, %r339, %r346; + ld.param.b32 %r347, [%rd1+136]; + sub.s32 %r348, %r347, %r3; + setp.lt.u32 %p43, %r348, 5; + mov.b32 %r2305, %r2243; + mov.b32 %r2306, %r2244; + mov.b32 %r2307, %r2245; + mov.b32 %r2308, %r2246; + @%p43 bra $L__BB0_50; + ld.param.b64 %rd135, [%rd1+80]; + cvta.to.global.u64 %rd136, %rd135; + mov.u32 %r349, %tid.x; + shl.b32 %r350, %r349, 3; + and.b32 %r351, %r350, 248; + mul.wide.u32 %rd137, %r351, 4; + add.s64 %rd138, %rd136, %rd137; + ld.global.v4.b32 {%r352, %r353, %r354, %r355}, [%rd138+40960]; + ld.global.v4.b32 {%r356, %r357, %r358, %r359}, [%rd138+40976]; + fma.rn.f32 %r360, %r13, %r352, 0f00000000; + fma.rn.f32 %r361, %r14, %r353, %r360; + fma.rn.f32 %r362, %r15, %r354, %r361; + fma.rn.f32 %r363, %r16, %r355, %r362; + fma.rn.f32 %r364, %r17, %r356, %r363; + fma.rn.f32 %r365, %r18, %r357, %r364; + fma.rn.f32 %r366, %r19, %r358, %r365; + fma.rn.f32 %r2305, %r20, %r359, %r366; + ld.param.b32 %r367, [%rd1+136]; + sub.s32 %r368, %r367, %r3; + setp.eq.b32 %p44, %r368, 5; + mov.b32 %r2306, %r2244; + mov.b32 %r2307, %r2245; + mov.b32 %r2308, %r2246; + @%p44 bra $L__BB0_50; + ld.param.b64 %rd139, [%rd1+80]; + cvta.to.global.u64 %rd140, %rd139; + mov.u32 %r369, %tid.x; + shl.b32 %r370, %r369, 3; + and.b32 %r371, %r370, 248; + mul.wide.u32 %rd141, %r371, 4; + add.s64 %rd142, %rd140, %rd141; + ld.global.v4.b32 {%r372, %r373, %r374, %r375}, [%rd142+51200]; + ld.global.v4.b32 {%r376, %r377, %r378, %r379}, [%rd142+51216]; + fma.rn.f32 %r380, %r13, %r372, 0f00000000; + fma.rn.f32 %r381, %r14, %r373, %r380; + fma.rn.f32 %r382, %r15, %r374, %r381; + fma.rn.f32 %r383, %r16, %r375, %r382; + fma.rn.f32 %r384, %r17, %r376, %r383; + fma.rn.f32 %r385, %r18, %r377, %r384; + fma.rn.f32 %r386, %r19, %r378, %r385; + fma.rn.f32 %r2306, %r20, %r379, %r386; + ld.param.b32 %r387, [%rd1+136]; + sub.s32 %r388, %r387, %r3; + setp.lt.u32 %p45, %r388, 7; + mov.b32 %r2307, %r2245; + mov.b32 %r2308, %r2246; + @%p45 bra $L__BB0_50; + ld.param.b64 %rd143, [%rd1+80]; + cvta.to.global.u64 %rd144, %rd143; + mov.u32 %r389, %tid.x; + shl.b32 %r390, %r389, 3; + and.b32 %r391, %r390, 248; + mul.wide.u32 %rd145, %r391, 4; + add.s64 %rd146, %rd144, %rd145; + ld.global.v4.b32 {%r392, %r393, %r394, %r395}, [%rd146+61440]; + ld.global.v4.b32 {%r396, %r397, %r398, %r399}, [%rd146+61456]; + fma.rn.f32 %r400, %r13, %r392, 0f00000000; + fma.rn.f32 %r401, %r14, %r393, %r400; + fma.rn.f32 %r402, %r15, %r394, %r401; + fma.rn.f32 %r403, %r16, %r395, %r402; + fma.rn.f32 %r404, %r17, %r396, %r403; + fma.rn.f32 %r405, %r18, %r397, %r404; + fma.rn.f32 %r406, %r19, %r398, %r405; + fma.rn.f32 %r2307, %r20, %r399, %r406; + ld.param.b32 %r407, [%rd1+136]; + sub.s32 %r408, %r407, %r3; + setp.eq.b32 %p46, %r408, 7; + mov.b32 %r2308, %r2246; + @%p46 bra $L__BB0_50; + ld.param.b64 %rd147, [%rd1+80]; + cvta.to.global.u64 %rd148, %rd147; + mov.u32 %r409, %tid.x; + shl.b32 %r410, %r409, 3; + and.b32 %r411, %r410, 248; + mul.wide.u32 %rd149, %r411, 4; + add.s64 %rd150, %rd148, %rd149; + ld.global.v4.b32 {%r412, %r413, %r414, %r415}, [%rd150+71680]; + ld.global.v4.b32 {%r416, %r417, %r418, %r419}, [%rd150+71696]; + fma.rn.f32 %r420, %r13, %r412, 0f00000000; + fma.rn.f32 %r421, %r14, %r413, %r420; + fma.rn.f32 %r422, %r15, %r414, %r421; + fma.rn.f32 %r423, %r16, %r415, %r422; + fma.rn.f32 %r424, %r17, %r416, %r423; + fma.rn.f32 %r425, %r18, %r417, %r424; + fma.rn.f32 %r426, %r19, %r418, %r425; + fma.rn.f32 %r2308, %r20, %r419, %r426; +$L__BB0_50: + ld.param.b32 %r427, [%rd1+136]; + sub.s32 %r428, %r427, %r3; + setp.eq.b32 %p47, %r428, 1; + shl.b32 %r26, %r2282, 16; + and.b32 %r27, %r2282, -65536; + shl.b32 %r28, %r2281, 16; + and.b32 %r29, %r2281, -65536; + shl.b32 %r30, %r2280, 16; + and.b32 %r31, %r2280, -65536; + shl.b32 %r32, %r2279, 16; + and.b32 %r33, %r2279, -65536; + ld.param.b64 %rd151, [%rd1+80]; + cvta.to.global.u64 %rd152, %rd151; + mov.u32 %r429, %tid.x; + shl.b32 %r430, %r429, 3; + and.b32 %r431, %r430, 248; + mul.wide.u32 %rd153, %r431, 4; + add.s64 %rd154, %rd152, %rd153; + ld.global.v4.b32 {%r432, %r433, %r434, %r435}, [%rd154+1024]; + ld.global.v4.b32 {%r436, %r437, %r438, %r439}, [%rd154+1040]; + fma.rn.f32 %r440, %r26, %r432, %r21; + fma.rn.f32 %r441, %r27, %r433, %r440; + fma.rn.f32 %r442, %r28, %r434, %r441; + fma.rn.f32 %r443, %r29, %r435, %r442; + fma.rn.f32 %r444, %r30, %r436, %r443; + fma.rn.f32 %r445, %r31, %r437, %r444; + fma.rn.f32 %r446, %r32, %r438, %r445; + fma.rn.f32 %r34, %r33, %r439, %r446; + @%p47 bra $L__BB0_58; + ld.param.b64 %rd155, [%rd1+80]; + cvta.to.global.u64 %rd156, %rd155; + mov.u32 %r447, %tid.x; + shl.b32 %r448, %r447, 3; + and.b32 %r449, %r448, 248; + mul.wide.u32 %rd157, %r449, 4; + add.s64 %rd158, %rd156, %rd157; + ld.global.v4.b32 {%r450, %r451, %r452, %r453}, [%rd158+11264]; + ld.global.v4.b32 {%r454, %r455, %r456, %r457}, [%rd158+11280]; + fma.rn.f32 %r458, %r26, %r450, %r2302; + fma.rn.f32 %r459, %r27, %r451, %r458; + fma.rn.f32 %r460, %r28, %r452, %r459; + fma.rn.f32 %r461, %r29, %r453, %r460; + fma.rn.f32 %r462, %r30, %r454, %r461; + fma.rn.f32 %r463, %r31, %r455, %r462; + fma.rn.f32 %r464, %r32, %r456, %r463; + fma.rn.f32 %r2302, %r33, %r457, %r464; + ld.param.b32 %r465, [%rd1+136]; + sub.s32 %r466, %r465, %r3; + setp.lt.u32 %p48, %r466, 3; + @%p48 bra $L__BB0_58; + ld.param.b64 %rd159, [%rd1+80]; + cvta.to.global.u64 %rd160, %rd159; + mov.u32 %r467, %tid.x; + shl.b32 %r468, %r467, 3; + and.b32 %r469, %r468, 248; + mul.wide.u32 %rd161, %r469, 4; + add.s64 %rd162, %rd160, %rd161; + ld.global.v4.b32 {%r470, %r471, %r472, %r473}, [%rd162+21504]; + ld.global.v4.b32 {%r474, %r475, %r476, %r477}, [%rd162+21520]; + fma.rn.f32 %r478, %r26, %r470, %r2303; + fma.rn.f32 %r479, %r27, %r471, %r478; + fma.rn.f32 %r480, %r28, %r472, %r479; + fma.rn.f32 %r481, %r29, %r473, %r480; + fma.rn.f32 %r482, %r30, %r474, %r481; + fma.rn.f32 %r483, %r31, %r475, %r482; + fma.rn.f32 %r484, %r32, %r476, %r483; + fma.rn.f32 %r2303, %r33, %r477, %r484; + ld.param.b32 %r485, [%rd1+136]; + sub.s32 %r486, %r485, %r3; + setp.eq.b32 %p49, %r486, 3; + @%p49 bra $L__BB0_58; + ld.param.b64 %rd163, [%rd1+80]; + cvta.to.global.u64 %rd164, %rd163; + mov.u32 %r487, %tid.x; + shl.b32 %r488, %r487, 3; + and.b32 %r489, %r488, 248; + mul.wide.u32 %rd165, %r489, 4; + add.s64 %rd166, %rd164, %rd165; + ld.global.v4.b32 {%r490, %r491, %r492, %r493}, [%rd166+31744]; + ld.global.v4.b32 {%r494, %r495, %r496, %r497}, [%rd166+31760]; + fma.rn.f32 %r498, %r26, %r490, %r2304; + fma.rn.f32 %r499, %r27, %r491, %r498; + fma.rn.f32 %r500, %r28, %r492, %r499; + fma.rn.f32 %r501, %r29, %r493, %r500; + fma.rn.f32 %r502, %r30, %r494, %r501; + fma.rn.f32 %r503, %r31, %r495, %r502; + fma.rn.f32 %r504, %r32, %r496, %r503; + fma.rn.f32 %r2304, %r33, %r497, %r504; + ld.param.b32 %r505, [%rd1+136]; + sub.s32 %r506, %r505, %r3; + setp.lt.u32 %p50, %r506, 5; + @%p50 bra $L__BB0_58; + ld.param.b64 %rd167, [%rd1+80]; + cvta.to.global.u64 %rd168, %rd167; + mov.u32 %r507, %tid.x; + shl.b32 %r508, %r507, 3; + and.b32 %r509, %r508, 248; + mul.wide.u32 %rd169, %r509, 4; + add.s64 %rd170, %rd168, %rd169; + ld.global.v4.b32 {%r510, %r511, %r512, %r513}, [%rd170+41984]; + ld.global.v4.b32 {%r514, %r515, %r516, %r517}, [%rd170+42000]; + fma.rn.f32 %r518, %r26, %r510, %r2305; + fma.rn.f32 %r519, %r27, %r511, %r518; + fma.rn.f32 %r520, %r28, %r512, %r519; + fma.rn.f32 %r521, %r29, %r513, %r520; + fma.rn.f32 %r522, %r30, %r514, %r521; + fma.rn.f32 %r523, %r31, %r515, %r522; + fma.rn.f32 %r524, %r32, %r516, %r523; + fma.rn.f32 %r2305, %r33, %r517, %r524; + ld.param.b32 %r525, [%rd1+136]; + sub.s32 %r526, %r525, %r3; + setp.eq.b32 %p51, %r526, 5; + @%p51 bra $L__BB0_58; + ld.param.b64 %rd171, [%rd1+80]; + cvta.to.global.u64 %rd172, %rd171; + mov.u32 %r527, %tid.x; + shl.b32 %r528, %r527, 3; + and.b32 %r529, %r528, 248; + mul.wide.u32 %rd173, %r529, 4; + add.s64 %rd174, %rd172, %rd173; + ld.global.v4.b32 {%r530, %r531, %r532, %r533}, [%rd174+52224]; + ld.global.v4.b32 {%r534, %r535, %r536, %r537}, [%rd174+52240]; + fma.rn.f32 %r538, %r26, %r530, %r2306; + fma.rn.f32 %r539, %r27, %r531, %r538; + fma.rn.f32 %r540, %r28, %r532, %r539; + fma.rn.f32 %r541, %r29, %r533, %r540; + fma.rn.f32 %r542, %r30, %r534, %r541; + fma.rn.f32 %r543, %r31, %r535, %r542; + fma.rn.f32 %r544, %r32, %r536, %r543; + fma.rn.f32 %r2306, %r33, %r537, %r544; + ld.param.b32 %r545, [%rd1+136]; + sub.s32 %r546, %r545, %r3; + setp.lt.u32 %p52, %r546, 7; + @%p52 bra $L__BB0_58; + ld.param.b64 %rd175, [%rd1+80]; + cvta.to.global.u64 %rd176, %rd175; + mov.u32 %r547, %tid.x; + shl.b32 %r548, %r547, 3; + and.b32 %r549, %r548, 248; + mul.wide.u32 %rd177, %r549, 4; + add.s64 %rd178, %rd176, %rd177; + ld.global.v4.b32 {%r550, %r551, %r552, %r553}, [%rd178+62464]; + ld.global.v4.b32 {%r554, %r555, %r556, %r557}, [%rd178+62480]; + fma.rn.f32 %r558, %r26, %r550, %r2307; + fma.rn.f32 %r559, %r27, %r551, %r558; + fma.rn.f32 %r560, %r28, %r552, %r559; + fma.rn.f32 %r561, %r29, %r553, %r560; + fma.rn.f32 %r562, %r30, %r554, %r561; + fma.rn.f32 %r563, %r31, %r555, %r562; + fma.rn.f32 %r564, %r32, %r556, %r563; + fma.rn.f32 %r2307, %r33, %r557, %r564; + ld.param.b32 %r565, [%rd1+136]; + sub.s32 %r566, %r565, %r3; + setp.eq.b32 %p53, %r566, 7; + @%p53 bra $L__BB0_58; + ld.param.b64 %rd179, [%rd1+80]; + cvta.to.global.u64 %rd180, %rd179; + mov.u32 %r567, %tid.x; + shl.b32 %r568, %r567, 3; + and.b32 %r569, %r568, 248; + mul.wide.u32 %rd181, %r569, 4; + add.s64 %rd182, %rd180, %rd181; + ld.global.v4.b32 {%r570, %r571, %r572, %r573}, [%rd182+72704]; + ld.global.v4.b32 {%r574, %r575, %r576, %r577}, [%rd182+72720]; + fma.rn.f32 %r578, %r26, %r570, %r2308; + fma.rn.f32 %r579, %r27, %r571, %r578; + fma.rn.f32 %r580, %r28, %r572, %r579; + fma.rn.f32 %r581, %r29, %r573, %r580; + fma.rn.f32 %r582, %r30, %r574, %r581; + fma.rn.f32 %r583, %r31, %r575, %r582; + fma.rn.f32 %r584, %r32, %r576, %r583; + fma.rn.f32 %r2308, %r33, %r577, %r584; +$L__BB0_58: + ld.param.b32 %r585, [%rd1+136]; + sub.s32 %r586, %r585, %r3; + setp.eq.b32 %p54, %r586, 1; + shl.b32 %r35, %r2278, 16; + and.b32 %r36, %r2278, -65536; + shl.b32 %r37, %r2277, 16; + and.b32 %r38, %r2277, -65536; + shl.b32 %r39, %r2276, 16; + and.b32 %r40, %r2276, -65536; + shl.b32 %r41, %r2275, 16; + and.b32 %r42, %r2275, -65536; + ld.param.b64 %rd183, [%rd1+80]; + cvta.to.global.u64 %rd184, %rd183; + mov.u32 %r587, %tid.x; + shl.b32 %r588, %r587, 3; + and.b32 %r589, %r588, 248; + mul.wide.u32 %rd185, %r589, 4; + add.s64 %rd186, %rd184, %rd185; + ld.global.v4.b32 {%r590, %r591, %r592, %r593}, [%rd186+2048]; + ld.global.v4.b32 {%r594, %r595, %r596, %r597}, [%rd186+2064]; + fma.rn.f32 %r598, %r35, %r590, %r34; + fma.rn.f32 %r599, %r36, %r591, %r598; + fma.rn.f32 %r600, %r37, %r592, %r599; + fma.rn.f32 %r601, %r38, %r593, %r600; + fma.rn.f32 %r602, %r39, %r594, %r601; + fma.rn.f32 %r603, %r40, %r595, %r602; + fma.rn.f32 %r604, %r41, %r596, %r603; + fma.rn.f32 %r43, %r42, %r597, %r604; + @%p54 bra $L__BB0_66; + ld.param.b64 %rd187, [%rd1+80]; + cvta.to.global.u64 %rd188, %rd187; + mov.u32 %r605, %tid.x; + shl.b32 %r606, %r605, 3; + and.b32 %r607, %r606, 248; + mul.wide.u32 %rd189, %r607, 4; + add.s64 %rd190, %rd188, %rd189; + ld.global.v4.b32 {%r608, %r609, %r610, %r611}, [%rd190+12288]; + ld.global.v4.b32 {%r612, %r613, %r614, %r615}, [%rd190+12304]; + fma.rn.f32 %r616, %r35, %r608, %r2302; + fma.rn.f32 %r617, %r36, %r609, %r616; + fma.rn.f32 %r618, %r37, %r610, %r617; + fma.rn.f32 %r619, %r38, %r611, %r618; + fma.rn.f32 %r620, %r39, %r612, %r619; + fma.rn.f32 %r621, %r40, %r613, %r620; + fma.rn.f32 %r622, %r41, %r614, %r621; + fma.rn.f32 %r2302, %r42, %r615, %r622; + ld.param.b32 %r623, [%rd1+136]; + sub.s32 %r624, %r623, %r3; + setp.lt.u32 %p55, %r624, 3; + @%p55 bra $L__BB0_66; + ld.param.b64 %rd191, [%rd1+80]; + cvta.to.global.u64 %rd192, %rd191; + mov.u32 %r625, %tid.x; + shl.b32 %r626, %r625, 3; + and.b32 %r627, %r626, 248; + mul.wide.u32 %rd193, %r627, 4; + add.s64 %rd194, %rd192, %rd193; + ld.global.v4.b32 {%r628, %r629, %r630, %r631}, [%rd194+22528]; + ld.global.v4.b32 {%r632, %r633, %r634, %r635}, [%rd194+22544]; + fma.rn.f32 %r636, %r35, %r628, %r2303; + fma.rn.f32 %r637, %r36, %r629, %r636; + fma.rn.f32 %r638, %r37, %r630, %r637; + fma.rn.f32 %r639, %r38, %r631, %r638; + fma.rn.f32 %r640, %r39, %r632, %r639; + fma.rn.f32 %r641, %r40, %r633, %r640; + fma.rn.f32 %r642, %r41, %r634, %r641; + fma.rn.f32 %r2303, %r42, %r635, %r642; + ld.param.b32 %r643, [%rd1+136]; + sub.s32 %r644, %r643, %r3; + setp.eq.b32 %p56, %r644, 3; + @%p56 bra $L__BB0_66; + ld.param.b64 %rd195, [%rd1+80]; + cvta.to.global.u64 %rd196, %rd195; + mov.u32 %r645, %tid.x; + shl.b32 %r646, %r645, 3; + and.b32 %r647, %r646, 248; + mul.wide.u32 %rd197, %r647, 4; + add.s64 %rd198, %rd196, %rd197; + ld.global.v4.b32 {%r648, %r649, %r650, %r651}, [%rd198+32768]; + ld.global.v4.b32 {%r652, %r653, %r654, %r655}, [%rd198+32784]; + fma.rn.f32 %r656, %r35, %r648, %r2304; + fma.rn.f32 %r657, %r36, %r649, %r656; + fma.rn.f32 %r658, %r37, %r650, %r657; + fma.rn.f32 %r659, %r38, %r651, %r658; + fma.rn.f32 %r660, %r39, %r652, %r659; + fma.rn.f32 %r661, %r40, %r653, %r660; + fma.rn.f32 %r662, %r41, %r654, %r661; + fma.rn.f32 %r2304, %r42, %r655, %r662; + ld.param.b32 %r663, [%rd1+136]; + sub.s32 %r664, %r663, %r3; + setp.lt.u32 %p57, %r664, 5; + @%p57 bra $L__BB0_66; + ld.param.b64 %rd199, [%rd1+80]; + cvta.to.global.u64 %rd200, %rd199; + mov.u32 %r665, %tid.x; + shl.b32 %r666, %r665, 3; + and.b32 %r667, %r666, 248; + mul.wide.u32 %rd201, %r667, 4; + add.s64 %rd202, %rd200, %rd201; + ld.global.v4.b32 {%r668, %r669, %r670, %r671}, [%rd202+43008]; + ld.global.v4.b32 {%r672, %r673, %r674, %r675}, [%rd202+43024]; + fma.rn.f32 %r676, %r35, %r668, %r2305; + fma.rn.f32 %r677, %r36, %r669, %r676; + fma.rn.f32 %r678, %r37, %r670, %r677; + fma.rn.f32 %r679, %r38, %r671, %r678; + fma.rn.f32 %r680, %r39, %r672, %r679; + fma.rn.f32 %r681, %r40, %r673, %r680; + fma.rn.f32 %r682, %r41, %r674, %r681; + fma.rn.f32 %r2305, %r42, %r675, %r682; + ld.param.b32 %r683, [%rd1+136]; + sub.s32 %r684, %r683, %r3; + setp.eq.b32 %p58, %r684, 5; + @%p58 bra $L__BB0_66; + ld.param.b64 %rd203, [%rd1+80]; + cvta.to.global.u64 %rd204, %rd203; + mov.u32 %r685, %tid.x; + shl.b32 %r686, %r685, 3; + and.b32 %r687, %r686, 248; + mul.wide.u32 %rd205, %r687, 4; + add.s64 %rd206, %rd204, %rd205; + ld.global.v4.b32 {%r688, %r689, %r690, %r691}, [%rd206+53248]; + ld.global.v4.b32 {%r692, %r693, %r694, %r695}, [%rd206+53264]; + fma.rn.f32 %r696, %r35, %r688, %r2306; + fma.rn.f32 %r697, %r36, %r689, %r696; + fma.rn.f32 %r698, %r37, %r690, %r697; + fma.rn.f32 %r699, %r38, %r691, %r698; + fma.rn.f32 %r700, %r39, %r692, %r699; + fma.rn.f32 %r701, %r40, %r693, %r700; + fma.rn.f32 %r702, %r41, %r694, %r701; + fma.rn.f32 %r2306, %r42, %r695, %r702; + ld.param.b32 %r703, [%rd1+136]; + sub.s32 %r704, %r703, %r3; + setp.lt.u32 %p59, %r704, 7; + @%p59 bra $L__BB0_66; + ld.param.b64 %rd207, [%rd1+80]; + cvta.to.global.u64 %rd208, %rd207; + mov.u32 %r705, %tid.x; + shl.b32 %r706, %r705, 3; + and.b32 %r707, %r706, 248; + mul.wide.u32 %rd209, %r707, 4; + add.s64 %rd210, %rd208, %rd209; + ld.global.v4.b32 {%r708, %r709, %r710, %r711}, [%rd210+63488]; + ld.global.v4.b32 {%r712, %r713, %r714, %r715}, [%rd210+63504]; + fma.rn.f32 %r716, %r35, %r708, %r2307; + fma.rn.f32 %r717, %r36, %r709, %r716; + fma.rn.f32 %r718, %r37, %r710, %r717; + fma.rn.f32 %r719, %r38, %r711, %r718; + fma.rn.f32 %r720, %r39, %r712, %r719; + fma.rn.f32 %r721, %r40, %r713, %r720; + fma.rn.f32 %r722, %r41, %r714, %r721; + fma.rn.f32 %r2307, %r42, %r715, %r722; + ld.param.b32 %r723, [%rd1+136]; + sub.s32 %r724, %r723, %r3; + setp.eq.b32 %p60, %r724, 7; + @%p60 bra $L__BB0_66; + ld.param.b64 %rd211, [%rd1+80]; + cvta.to.global.u64 %rd212, %rd211; + mov.u32 %r725, %tid.x; + shl.b32 %r726, %r725, 3; + and.b32 %r727, %r726, 248; + mul.wide.u32 %rd213, %r727, 4; + add.s64 %rd214, %rd212, %rd213; + ld.global.v4.b32 {%r728, %r729, %r730, %r731}, [%rd214+73728]; + ld.global.v4.b32 {%r732, %r733, %r734, %r735}, [%rd214+73744]; + fma.rn.f32 %r736, %r35, %r728, %r2308; + fma.rn.f32 %r737, %r36, %r729, %r736; + fma.rn.f32 %r738, %r37, %r730, %r737; + fma.rn.f32 %r739, %r38, %r731, %r738; + fma.rn.f32 %r740, %r39, %r732, %r739; + fma.rn.f32 %r741, %r40, %r733, %r740; + fma.rn.f32 %r742, %r41, %r734, %r741; + fma.rn.f32 %r2308, %r42, %r735, %r742; +$L__BB0_66: + ld.param.b32 %r743, [%rd1+136]; + sub.s32 %r44, %r743, %r3; + setp.eq.b32 %p61, %r44, 1; + shl.b32 %r45, %r2274, 16; + and.b32 %r46, %r2274, -65536; + shl.b32 %r47, %r2273, 16; + and.b32 %r48, %r2273, -65536; + shl.b32 %r49, %r2272, 16; + and.b32 %r50, %r2272, -65536; + shl.b32 %r51, %r2271, 16; + and.b32 %r52, %r2271, -65536; + ld.param.b64 %rd215, [%rd1+80]; + cvta.to.global.u64 %rd216, %rd215; + mov.u32 %r744, %tid.x; + shl.b32 %r745, %r744, 3; + and.b32 %r746, %r745, 248; + mul.wide.u32 %rd217, %r746, 4; + add.s64 %rd7, %rd216, %rd217; + ld.global.v4.b32 {%r747, %r748, %r749, %r750}, [%rd7+3072]; + ld.global.v4.b32 {%r751, %r752, %r753, %r754}, [%rd7+3088]; + fma.rn.f32 %r755, %r45, %r747, %r43; + fma.rn.f32 %r756, %r46, %r748, %r755; + fma.rn.f32 %r757, %r47, %r749, %r756; + fma.rn.f32 %r758, %r48, %r750, %r757; + fma.rn.f32 %r759, %r49, %r751, %r758; + fma.rn.f32 %r760, %r50, %r752, %r759; + fma.rn.f32 %r761, %r51, %r753, %r760; + fma.rn.f32 %r53, %r52, %r754, %r761; + @%p61 bra $L__BB0_74; + ld.global.v4.b32 {%r762, %r763, %r764, %r765}, [%rd7+13312]; + ld.global.v4.b32 {%r766, %r767, %r768, %r769}, [%rd7+13328]; + fma.rn.f32 %r770, %r45, %r762, %r2302; + fma.rn.f32 %r771, %r46, %r763, %r770; + fma.rn.f32 %r772, %r47, %r764, %r771; + fma.rn.f32 %r773, %r48, %r765, %r772; + fma.rn.f32 %r774, %r49, %r766, %r773; + fma.rn.f32 %r775, %r50, %r767, %r774; + fma.rn.f32 %r776, %r51, %r768, %r775; + fma.rn.f32 %r2302, %r52, %r769, %r776; + setp.lt.u32 %p62, %r44, 3; + @%p62 bra $L__BB0_74; + ld.global.v4.b32 {%r777, %r778, %r779, %r780}, [%rd7+23552]; + ld.global.v4.b32 {%r781, %r782, %r783, %r784}, [%rd7+23568]; + fma.rn.f32 %r785, %r45, %r777, %r2303; + fma.rn.f32 %r786, %r46, %r778, %r785; + fma.rn.f32 %r787, %r47, %r779, %r786; + fma.rn.f32 %r788, %r48, %r780, %r787; + fma.rn.f32 %r789, %r49, %r781, %r788; + fma.rn.f32 %r790, %r50, %r782, %r789; + fma.rn.f32 %r791, %r51, %r783, %r790; + fma.rn.f32 %r2303, %r52, %r784, %r791; + setp.eq.b32 %p63, %r44, 3; + @%p63 bra $L__BB0_74; + ld.global.v4.b32 {%r792, %r793, %r794, %r795}, [%rd7+33792]; + ld.global.v4.b32 {%r796, %r797, %r798, %r799}, [%rd7+33808]; + fma.rn.f32 %r800, %r45, %r792, %r2304; + fma.rn.f32 %r801, %r46, %r793, %r800; + fma.rn.f32 %r802, %r47, %r794, %r801; + fma.rn.f32 %r803, %r48, %r795, %r802; + fma.rn.f32 %r804, %r49, %r796, %r803; + fma.rn.f32 %r805, %r50, %r797, %r804; + fma.rn.f32 %r806, %r51, %r798, %r805; + fma.rn.f32 %r2304, %r52, %r799, %r806; + setp.lt.u32 %p64, %r44, 5; + @%p64 bra $L__BB0_74; + ld.global.v4.b32 {%r807, %r808, %r809, %r810}, [%rd7+44032]; + ld.global.v4.b32 {%r811, %r812, %r813, %r814}, [%rd7+44048]; + fma.rn.f32 %r815, %r45, %r807, %r2305; + fma.rn.f32 %r816, %r46, %r808, %r815; + fma.rn.f32 %r817, %r47, %r809, %r816; + fma.rn.f32 %r818, %r48, %r810, %r817; + fma.rn.f32 %r819, %r49, %r811, %r818; + fma.rn.f32 %r820, %r50, %r812, %r819; + fma.rn.f32 %r821, %r51, %r813, %r820; + fma.rn.f32 %r2305, %r52, %r814, %r821; + setp.eq.b32 %p65, %r44, 5; + @%p65 bra $L__BB0_74; + ld.global.v4.b32 {%r822, %r823, %r824, %r825}, [%rd7+54272]; + ld.global.v4.b32 {%r826, %r827, %r828, %r829}, [%rd7+54288]; + fma.rn.f32 %r830, %r45, %r822, %r2306; + fma.rn.f32 %r831, %r46, %r823, %r830; + fma.rn.f32 %r832, %r47, %r824, %r831; + fma.rn.f32 %r833, %r48, %r825, %r832; + fma.rn.f32 %r834, %r49, %r826, %r833; + fma.rn.f32 %r835, %r50, %r827, %r834; + fma.rn.f32 %r836, %r51, %r828, %r835; + fma.rn.f32 %r2306, %r52, %r829, %r836; + setp.lt.u32 %p66, %r44, 7; + @%p66 bra $L__BB0_74; + ld.global.v4.b32 {%r837, %r838, %r839, %r840}, [%rd7+64512]; + ld.global.v4.b32 {%r841, %r842, %r843, %r844}, [%rd7+64528]; + fma.rn.f32 %r845, %r45, %r837, %r2307; + fma.rn.f32 %r846, %r46, %r838, %r845; + fma.rn.f32 %r847, %r47, %r839, %r846; + fma.rn.f32 %r848, %r48, %r840, %r847; + fma.rn.f32 %r849, %r49, %r841, %r848; + fma.rn.f32 %r850, %r50, %r842, %r849; + fma.rn.f32 %r851, %r51, %r843, %r850; + fma.rn.f32 %r2307, %r52, %r844, %r851; + setp.eq.b32 %p67, %r44, 7; + @%p67 bra $L__BB0_74; + ld.global.v4.b32 {%r852, %r853, %r854, %r855}, [%rd7+74752]; + ld.global.v4.b32 {%r856, %r857, %r858, %r859}, [%rd7+74768]; + fma.rn.f32 %r860, %r45, %r852, %r2308; + fma.rn.f32 %r861, %r46, %r853, %r860; + fma.rn.f32 %r862, %r47, %r854, %r861; + fma.rn.f32 %r863, %r48, %r855, %r862; + fma.rn.f32 %r864, %r49, %r856, %r863; + fma.rn.f32 %r865, %r50, %r857, %r864; + fma.rn.f32 %r866, %r51, %r858, %r865; + fma.rn.f32 %r2308, %r52, %r859, %r866; +$L__BB0_74: + shl.b32 %r54, %r2270, 16; + and.b32 %r55, %r2270, -65536; + shl.b32 %r56, %r2269, 16; + and.b32 %r57, %r2269, -65536; + shl.b32 %r58, %r2268, 16; + and.b32 %r59, %r2268, -65536; + shl.b32 %r60, %r2267, 16; + and.b32 %r61, %r2267, -65536; + ld.global.v4.b32 {%r867, %r868, %r869, %r870}, [%rd7+4096]; + ld.global.v4.b32 {%r871, %r872, %r873, %r874}, [%rd7+4112]; + fma.rn.f32 %r875, %r54, %r867, %r53; + fma.rn.f32 %r876, %r55, %r868, %r875; + fma.rn.f32 %r877, %r56, %r869, %r876; + fma.rn.f32 %r878, %r57, %r870, %r877; + fma.rn.f32 %r879, %r58, %r871, %r878; + fma.rn.f32 %r880, %r59, %r872, %r879; + fma.rn.f32 %r881, %r60, %r873, %r880; + fma.rn.f32 %r62, %r61, %r874, %r881; + @%p61 bra $L__BB0_82; + ld.global.v4.b32 {%r882, %r883, %r884, %r885}, [%rd7+14336]; + ld.global.v4.b32 {%r886, %r887, %r888, %r889}, [%rd7+14352]; + fma.rn.f32 %r890, %r54, %r882, %r2302; + fma.rn.f32 %r891, %r55, %r883, %r890; + fma.rn.f32 %r892, %r56, %r884, %r891; + fma.rn.f32 %r893, %r57, %r885, %r892; + fma.rn.f32 %r894, %r58, %r886, %r893; + fma.rn.f32 %r895, %r59, %r887, %r894; + fma.rn.f32 %r896, %r60, %r888, %r895; + fma.rn.f32 %r2302, %r61, %r889, %r896; + setp.lt.u32 %p68, %r44, 3; + @%p68 bra $L__BB0_82; + ld.global.v4.b32 {%r897, %r898, %r899, %r900}, [%rd7+24576]; + ld.global.v4.b32 {%r901, %r902, %r903, %r904}, [%rd7+24592]; + fma.rn.f32 %r905, %r54, %r897, %r2303; + fma.rn.f32 %r906, %r55, %r898, %r905; + fma.rn.f32 %r907, %r56, %r899, %r906; + fma.rn.f32 %r908, %r57, %r900, %r907; + fma.rn.f32 %r909, %r58, %r901, %r908; + fma.rn.f32 %r910, %r59, %r902, %r909; + fma.rn.f32 %r911, %r60, %r903, %r910; + fma.rn.f32 %r2303, %r61, %r904, %r911; + setp.eq.b32 %p69, %r44, 3; + @%p69 bra $L__BB0_82; + ld.global.v4.b32 {%r912, %r913, %r914, %r915}, [%rd7+34816]; + ld.global.v4.b32 {%r916, %r917, %r918, %r919}, [%rd7+34832]; + fma.rn.f32 %r920, %r54, %r912, %r2304; + fma.rn.f32 %r921, %r55, %r913, %r920; + fma.rn.f32 %r922, %r56, %r914, %r921; + fma.rn.f32 %r923, %r57, %r915, %r922; + fma.rn.f32 %r924, %r58, %r916, %r923; + fma.rn.f32 %r925, %r59, %r917, %r924; + fma.rn.f32 %r926, %r60, %r918, %r925; + fma.rn.f32 %r2304, %r61, %r919, %r926; + setp.lt.u32 %p70, %r44, 5; + @%p70 bra $L__BB0_82; + ld.global.v4.b32 {%r927, %r928, %r929, %r930}, [%rd7+45056]; + ld.global.v4.b32 {%r931, %r932, %r933, %r934}, [%rd7+45072]; + fma.rn.f32 %r935, %r54, %r927, %r2305; + fma.rn.f32 %r936, %r55, %r928, %r935; + fma.rn.f32 %r937, %r56, %r929, %r936; + fma.rn.f32 %r938, %r57, %r930, %r937; + fma.rn.f32 %r939, %r58, %r931, %r938; + fma.rn.f32 %r940, %r59, %r932, %r939; + fma.rn.f32 %r941, %r60, %r933, %r940; + fma.rn.f32 %r2305, %r61, %r934, %r941; + setp.eq.b32 %p71, %r44, 5; + @%p71 bra $L__BB0_82; + ld.global.v4.b32 {%r942, %r943, %r944, %r945}, [%rd7+55296]; + ld.global.v4.b32 {%r946, %r947, %r948, %r949}, [%rd7+55312]; + fma.rn.f32 %r950, %r54, %r942, %r2306; + fma.rn.f32 %r951, %r55, %r943, %r950; + fma.rn.f32 %r952, %r56, %r944, %r951; + fma.rn.f32 %r953, %r57, %r945, %r952; + fma.rn.f32 %r954, %r58, %r946, %r953; + fma.rn.f32 %r955, %r59, %r947, %r954; + fma.rn.f32 %r956, %r60, %r948, %r955; + fma.rn.f32 %r2306, %r61, %r949, %r956; + setp.lt.u32 %p72, %r44, 7; + @%p72 bra $L__BB0_82; + ld.global.v4.b32 {%r957, %r958, %r959, %r960}, [%rd7+65536]; + ld.global.v4.b32 {%r961, %r962, %r963, %r964}, [%rd7+65552]; + fma.rn.f32 %r965, %r54, %r957, %r2307; + fma.rn.f32 %r966, %r55, %r958, %r965; + fma.rn.f32 %r967, %r56, %r959, %r966; + fma.rn.f32 %r968, %r57, %r960, %r967; + fma.rn.f32 %r969, %r58, %r961, %r968; + fma.rn.f32 %r970, %r59, %r962, %r969; + fma.rn.f32 %r971, %r60, %r963, %r970; + fma.rn.f32 %r2307, %r61, %r964, %r971; + setp.eq.b32 %p73, %r44, 7; + @%p73 bra $L__BB0_82; + ld.global.v4.b32 {%r972, %r973, %r974, %r975}, [%rd7+75776]; + ld.global.v4.b32 {%r976, %r977, %r978, %r979}, [%rd7+75792]; + fma.rn.f32 %r980, %r54, %r972, %r2308; + fma.rn.f32 %r981, %r55, %r973, %r980; + fma.rn.f32 %r982, %r56, %r974, %r981; + fma.rn.f32 %r983, %r57, %r975, %r982; + fma.rn.f32 %r984, %r58, %r976, %r983; + fma.rn.f32 %r985, %r59, %r977, %r984; + fma.rn.f32 %r986, %r60, %r978, %r985; + fma.rn.f32 %r2308, %r61, %r979, %r986; +$L__BB0_82: + shl.b32 %r63, %r2266, 16; + and.b32 %r64, %r2266, -65536; + shl.b32 %r65, %r2265, 16; + and.b32 %r66, %r2265, -65536; + shl.b32 %r67, %r2264, 16; + and.b32 %r68, %r2264, -65536; + shl.b32 %r69, %r2263, 16; + and.b32 %r70, %r2263, -65536; + ld.global.v4.b32 {%r987, %r988, %r989, %r990}, [%rd7+5120]; + ld.global.v4.b32 {%r991, %r992, %r993, %r994}, [%rd7+5136]; + fma.rn.f32 %r995, %r63, %r987, %r62; + fma.rn.f32 %r996, %r64, %r988, %r995; + fma.rn.f32 %r997, %r65, %r989, %r996; + fma.rn.f32 %r998, %r66, %r990, %r997; + fma.rn.f32 %r999, %r67, %r991, %r998; + fma.rn.f32 %r1000, %r68, %r992, %r999; + fma.rn.f32 %r1001, %r69, %r993, %r1000; + fma.rn.f32 %r71, %r70, %r994, %r1001; + @%p61 bra $L__BB0_90; + ld.global.v4.b32 {%r1002, %r1003, %r1004, %r1005}, [%rd7+15360]; + ld.global.v4.b32 {%r1006, %r1007, %r1008, %r1009}, [%rd7+15376]; + fma.rn.f32 %r1010, %r63, %r1002, %r2302; + fma.rn.f32 %r1011, %r64, %r1003, %r1010; + fma.rn.f32 %r1012, %r65, %r1004, %r1011; + fma.rn.f32 %r1013, %r66, %r1005, %r1012; + fma.rn.f32 %r1014, %r67, %r1006, %r1013; + fma.rn.f32 %r1015, %r68, %r1007, %r1014; + fma.rn.f32 %r1016, %r69, %r1008, %r1015; + fma.rn.f32 %r2302, %r70, %r1009, %r1016; + setp.lt.u32 %p74, %r44, 3; + @%p74 bra $L__BB0_90; + ld.global.v4.b32 {%r1017, %r1018, %r1019, %r1020}, [%rd7+25600]; + ld.global.v4.b32 {%r1021, %r1022, %r1023, %r1024}, [%rd7+25616]; + fma.rn.f32 %r1025, %r63, %r1017, %r2303; + fma.rn.f32 %r1026, %r64, %r1018, %r1025; + fma.rn.f32 %r1027, %r65, %r1019, %r1026; + fma.rn.f32 %r1028, %r66, %r1020, %r1027; + fma.rn.f32 %r1029, %r67, %r1021, %r1028; + fma.rn.f32 %r1030, %r68, %r1022, %r1029; + fma.rn.f32 %r1031, %r69, %r1023, %r1030; + fma.rn.f32 %r2303, %r70, %r1024, %r1031; + setp.eq.b32 %p75, %r44, 3; + @%p75 bra $L__BB0_90; + ld.global.v4.b32 {%r1032, %r1033, %r1034, %r1035}, [%rd7+35840]; + ld.global.v4.b32 {%r1036, %r1037, %r1038, %r1039}, [%rd7+35856]; + fma.rn.f32 %r1040, %r63, %r1032, %r2304; + fma.rn.f32 %r1041, %r64, %r1033, %r1040; + fma.rn.f32 %r1042, %r65, %r1034, %r1041; + fma.rn.f32 %r1043, %r66, %r1035, %r1042; + fma.rn.f32 %r1044, %r67, %r1036, %r1043; + fma.rn.f32 %r1045, %r68, %r1037, %r1044; + fma.rn.f32 %r1046, %r69, %r1038, %r1045; + fma.rn.f32 %r2304, %r70, %r1039, %r1046; + setp.lt.u32 %p76, %r44, 5; + @%p76 bra $L__BB0_90; + ld.global.v4.b32 {%r1047, %r1048, %r1049, %r1050}, [%rd7+46080]; + ld.global.v4.b32 {%r1051, %r1052, %r1053, %r1054}, [%rd7+46096]; + fma.rn.f32 %r1055, %r63, %r1047, %r2305; + fma.rn.f32 %r1056, %r64, %r1048, %r1055; + fma.rn.f32 %r1057, %r65, %r1049, %r1056; + fma.rn.f32 %r1058, %r66, %r1050, %r1057; + fma.rn.f32 %r1059, %r67, %r1051, %r1058; + fma.rn.f32 %r1060, %r68, %r1052, %r1059; + fma.rn.f32 %r1061, %r69, %r1053, %r1060; + fma.rn.f32 %r2305, %r70, %r1054, %r1061; + setp.eq.b32 %p77, %r44, 5; + @%p77 bra $L__BB0_90; + ld.global.v4.b32 {%r1062, %r1063, %r1064, %r1065}, [%rd7+56320]; + ld.global.v4.b32 {%r1066, %r1067, %r1068, %r1069}, [%rd7+56336]; + fma.rn.f32 %r1070, %r63, %r1062, %r2306; + fma.rn.f32 %r1071, %r64, %r1063, %r1070; + fma.rn.f32 %r1072, %r65, %r1064, %r1071; + fma.rn.f32 %r1073, %r66, %r1065, %r1072; + fma.rn.f32 %r1074, %r67, %r1066, %r1073; + fma.rn.f32 %r1075, %r68, %r1067, %r1074; + fma.rn.f32 %r1076, %r69, %r1068, %r1075; + fma.rn.f32 %r2306, %r70, %r1069, %r1076; + setp.lt.u32 %p78, %r44, 7; + @%p78 bra $L__BB0_90; + ld.global.v4.b32 {%r1077, %r1078, %r1079, %r1080}, [%rd7+66560]; + ld.global.v4.b32 {%r1081, %r1082, %r1083, %r1084}, [%rd7+66576]; + fma.rn.f32 %r1085, %r63, %r1077, %r2307; + fma.rn.f32 %r1086, %r64, %r1078, %r1085; + fma.rn.f32 %r1087, %r65, %r1079, %r1086; + fma.rn.f32 %r1088, %r66, %r1080, %r1087; + fma.rn.f32 %r1089, %r67, %r1081, %r1088; + fma.rn.f32 %r1090, %r68, %r1082, %r1089; + fma.rn.f32 %r1091, %r69, %r1083, %r1090; + fma.rn.f32 %r2307, %r70, %r1084, %r1091; + setp.eq.b32 %p79, %r44, 7; + @%p79 bra $L__BB0_90; + ld.global.v4.b32 {%r1092, %r1093, %r1094, %r1095}, [%rd7+76800]; + ld.global.v4.b32 {%r1096, %r1097, %r1098, %r1099}, [%rd7+76816]; + fma.rn.f32 %r1100, %r63, %r1092, %r2308; + fma.rn.f32 %r1101, %r64, %r1093, %r1100; + fma.rn.f32 %r1102, %r65, %r1094, %r1101; + fma.rn.f32 %r1103, %r66, %r1095, %r1102; + fma.rn.f32 %r1104, %r67, %r1096, %r1103; + fma.rn.f32 %r1105, %r68, %r1097, %r1104; + fma.rn.f32 %r1106, %r69, %r1098, %r1105; + fma.rn.f32 %r2308, %r70, %r1099, %r1106; +$L__BB0_90: + shl.b32 %r72, %r2262, 16; + and.b32 %r73, %r2262, -65536; + shl.b32 %r74, %r2261, 16; + and.b32 %r75, %r2261, -65536; + shl.b32 %r76, %r2260, 16; + and.b32 %r77, %r2260, -65536; + shl.b32 %r78, %r2259, 16; + and.b32 %r79, %r2259, -65536; + ld.global.v4.b32 {%r1107, %r1108, %r1109, %r1110}, [%rd7+6144]; + ld.global.v4.b32 {%r1111, %r1112, %r1113, %r1114}, [%rd7+6160]; + fma.rn.f32 %r1115, %r72, %r1107, %r71; + fma.rn.f32 %r1116, %r73, %r1108, %r1115; + fma.rn.f32 %r1117, %r74, %r1109, %r1116; + fma.rn.f32 %r1118, %r75, %r1110, %r1117; + fma.rn.f32 %r1119, %r76, %r1111, %r1118; + fma.rn.f32 %r1120, %r77, %r1112, %r1119; + fma.rn.f32 %r1121, %r78, %r1113, %r1120; + fma.rn.f32 %r80, %r79, %r1114, %r1121; + @%p61 bra $L__BB0_98; + ld.global.v4.b32 {%r1122, %r1123, %r1124, %r1125}, [%rd7+16384]; + ld.global.v4.b32 {%r1126, %r1127, %r1128, %r1129}, [%rd7+16400]; + fma.rn.f32 %r1130, %r72, %r1122, %r2302; + fma.rn.f32 %r1131, %r73, %r1123, %r1130; + fma.rn.f32 %r1132, %r74, %r1124, %r1131; + fma.rn.f32 %r1133, %r75, %r1125, %r1132; + fma.rn.f32 %r1134, %r76, %r1126, %r1133; + fma.rn.f32 %r1135, %r77, %r1127, %r1134; + fma.rn.f32 %r1136, %r78, %r1128, %r1135; + fma.rn.f32 %r2302, %r79, %r1129, %r1136; + setp.lt.u32 %p80, %r44, 3; + @%p80 bra $L__BB0_98; + ld.global.v4.b32 {%r1137, %r1138, %r1139, %r1140}, [%rd7+26624]; + ld.global.v4.b32 {%r1141, %r1142, %r1143, %r1144}, [%rd7+26640]; + fma.rn.f32 %r1145, %r72, %r1137, %r2303; + fma.rn.f32 %r1146, %r73, %r1138, %r1145; + fma.rn.f32 %r1147, %r74, %r1139, %r1146; + fma.rn.f32 %r1148, %r75, %r1140, %r1147; + fma.rn.f32 %r1149, %r76, %r1141, %r1148; + fma.rn.f32 %r1150, %r77, %r1142, %r1149; + fma.rn.f32 %r1151, %r78, %r1143, %r1150; + fma.rn.f32 %r2303, %r79, %r1144, %r1151; + setp.eq.b32 %p81, %r44, 3; + @%p81 bra $L__BB0_98; + ld.global.v4.b32 {%r1152, %r1153, %r1154, %r1155}, [%rd7+36864]; + ld.global.v4.b32 {%r1156, %r1157, %r1158, %r1159}, [%rd7+36880]; + fma.rn.f32 %r1160, %r72, %r1152, %r2304; + fma.rn.f32 %r1161, %r73, %r1153, %r1160; + fma.rn.f32 %r1162, %r74, %r1154, %r1161; + fma.rn.f32 %r1163, %r75, %r1155, %r1162; + fma.rn.f32 %r1164, %r76, %r1156, %r1163; + fma.rn.f32 %r1165, %r77, %r1157, %r1164; + fma.rn.f32 %r1166, %r78, %r1158, %r1165; + fma.rn.f32 %r2304, %r79, %r1159, %r1166; + setp.lt.u32 %p82, %r44, 5; + @%p82 bra $L__BB0_98; + ld.global.v4.b32 {%r1167, %r1168, %r1169, %r1170}, [%rd7+47104]; + ld.global.v4.b32 {%r1171, %r1172, %r1173, %r1174}, [%rd7+47120]; + fma.rn.f32 %r1175, %r72, %r1167, %r2305; + fma.rn.f32 %r1176, %r73, %r1168, %r1175; + fma.rn.f32 %r1177, %r74, %r1169, %r1176; + fma.rn.f32 %r1178, %r75, %r1170, %r1177; + fma.rn.f32 %r1179, %r76, %r1171, %r1178; + fma.rn.f32 %r1180, %r77, %r1172, %r1179; + fma.rn.f32 %r1181, %r78, %r1173, %r1180; + fma.rn.f32 %r2305, %r79, %r1174, %r1181; + setp.eq.b32 %p83, %r44, 5; + @%p83 bra $L__BB0_98; + ld.global.v4.b32 {%r1182, %r1183, %r1184, %r1185}, [%rd7+57344]; + ld.global.v4.b32 {%r1186, %r1187, %r1188, %r1189}, [%rd7+57360]; + fma.rn.f32 %r1190, %r72, %r1182, %r2306; + fma.rn.f32 %r1191, %r73, %r1183, %r1190; + fma.rn.f32 %r1192, %r74, %r1184, %r1191; + fma.rn.f32 %r1193, %r75, %r1185, %r1192; + fma.rn.f32 %r1194, %r76, %r1186, %r1193; + fma.rn.f32 %r1195, %r77, %r1187, %r1194; + fma.rn.f32 %r1196, %r78, %r1188, %r1195; + fma.rn.f32 %r2306, %r79, %r1189, %r1196; + setp.lt.u32 %p84, %r44, 7; + @%p84 bra $L__BB0_98; + ld.global.v4.b32 {%r1197, %r1198, %r1199, %r1200}, [%rd7+67584]; + ld.global.v4.b32 {%r1201, %r1202, %r1203, %r1204}, [%rd7+67600]; + fma.rn.f32 %r1205, %r72, %r1197, %r2307; + fma.rn.f32 %r1206, %r73, %r1198, %r1205; + fma.rn.f32 %r1207, %r74, %r1199, %r1206; + fma.rn.f32 %r1208, %r75, %r1200, %r1207; + fma.rn.f32 %r1209, %r76, %r1201, %r1208; + fma.rn.f32 %r1210, %r77, %r1202, %r1209; + fma.rn.f32 %r1211, %r78, %r1203, %r1210; + fma.rn.f32 %r2307, %r79, %r1204, %r1211; + setp.eq.b32 %p85, %r44, 7; + @%p85 bra $L__BB0_98; + ld.global.v4.b32 {%r1212, %r1213, %r1214, %r1215}, [%rd7+77824]; + ld.global.v4.b32 {%r1216, %r1217, %r1218, %r1219}, [%rd7+77840]; + fma.rn.f32 %r1220, %r72, %r1212, %r2308; + fma.rn.f32 %r1221, %r73, %r1213, %r1220; + fma.rn.f32 %r1222, %r74, %r1214, %r1221; + fma.rn.f32 %r1223, %r75, %r1215, %r1222; + fma.rn.f32 %r1224, %r76, %r1216, %r1223; + fma.rn.f32 %r1225, %r77, %r1217, %r1224; + fma.rn.f32 %r1226, %r78, %r1218, %r1225; + fma.rn.f32 %r2308, %r79, %r1219, %r1226; +$L__BB0_98: + shl.b32 %r81, %r2258, 16; + and.b32 %r82, %r2258, -65536; + shl.b32 %r83, %r2257, 16; + and.b32 %r84, %r2257, -65536; + shl.b32 %r85, %r2256, 16; + and.b32 %r86, %r2256, -65536; + shl.b32 %r87, %r2255, 16; + and.b32 %r88, %r2255, -65536; + ld.global.v4.b32 {%r1227, %r1228, %r1229, %r1230}, [%rd7+7168]; + ld.global.v4.b32 {%r1231, %r1232, %r1233, %r1234}, [%rd7+7184]; + fma.rn.f32 %r1235, %r81, %r1227, %r80; + fma.rn.f32 %r1236, %r82, %r1228, %r1235; + fma.rn.f32 %r1237, %r83, %r1229, %r1236; + fma.rn.f32 %r1238, %r84, %r1230, %r1237; + fma.rn.f32 %r1239, %r85, %r1231, %r1238; + fma.rn.f32 %r1240, %r86, %r1232, %r1239; + fma.rn.f32 %r1241, %r87, %r1233, %r1240; + fma.rn.f32 %r89, %r88, %r1234, %r1241; + @%p61 bra $L__BB0_106; + ld.global.v4.b32 {%r1242, %r1243, %r1244, %r1245}, [%rd7+17408]; + ld.global.v4.b32 {%r1246, %r1247, %r1248, %r1249}, [%rd7+17424]; + fma.rn.f32 %r1250, %r81, %r1242, %r2302; + fma.rn.f32 %r1251, %r82, %r1243, %r1250; + fma.rn.f32 %r1252, %r83, %r1244, %r1251; + fma.rn.f32 %r1253, %r84, %r1245, %r1252; + fma.rn.f32 %r1254, %r85, %r1246, %r1253; + fma.rn.f32 %r1255, %r86, %r1247, %r1254; + fma.rn.f32 %r1256, %r87, %r1248, %r1255; + fma.rn.f32 %r2302, %r88, %r1249, %r1256; + setp.lt.u32 %p86, %r44, 3; + @%p86 bra $L__BB0_106; + ld.global.v4.b32 {%r1257, %r1258, %r1259, %r1260}, [%rd7+27648]; + ld.global.v4.b32 {%r1261, %r1262, %r1263, %r1264}, [%rd7+27664]; + fma.rn.f32 %r1265, %r81, %r1257, %r2303; + fma.rn.f32 %r1266, %r82, %r1258, %r1265; + fma.rn.f32 %r1267, %r83, %r1259, %r1266; + fma.rn.f32 %r1268, %r84, %r1260, %r1267; + fma.rn.f32 %r1269, %r85, %r1261, %r1268; + fma.rn.f32 %r1270, %r86, %r1262, %r1269; + fma.rn.f32 %r1271, %r87, %r1263, %r1270; + fma.rn.f32 %r2303, %r88, %r1264, %r1271; + setp.eq.b32 %p87, %r44, 3; + @%p87 bra $L__BB0_106; + ld.global.v4.b32 {%r1272, %r1273, %r1274, %r1275}, [%rd7+37888]; + ld.global.v4.b32 {%r1276, %r1277, %r1278, %r1279}, [%rd7+37904]; + fma.rn.f32 %r1280, %r81, %r1272, %r2304; + fma.rn.f32 %r1281, %r82, %r1273, %r1280; + fma.rn.f32 %r1282, %r83, %r1274, %r1281; + fma.rn.f32 %r1283, %r84, %r1275, %r1282; + fma.rn.f32 %r1284, %r85, %r1276, %r1283; + fma.rn.f32 %r1285, %r86, %r1277, %r1284; + fma.rn.f32 %r1286, %r87, %r1278, %r1285; + fma.rn.f32 %r2304, %r88, %r1279, %r1286; + setp.lt.u32 %p88, %r44, 5; + @%p88 bra $L__BB0_106; + ld.global.v4.b32 {%r1287, %r1288, %r1289, %r1290}, [%rd7+48128]; + ld.global.v4.b32 {%r1291, %r1292, %r1293, %r1294}, [%rd7+48144]; + fma.rn.f32 %r1295, %r81, %r1287, %r2305; + fma.rn.f32 %r1296, %r82, %r1288, %r1295; + fma.rn.f32 %r1297, %r83, %r1289, %r1296; + fma.rn.f32 %r1298, %r84, %r1290, %r1297; + fma.rn.f32 %r1299, %r85, %r1291, %r1298; + fma.rn.f32 %r1300, %r86, %r1292, %r1299; + fma.rn.f32 %r1301, %r87, %r1293, %r1300; + fma.rn.f32 %r2305, %r88, %r1294, %r1301; + setp.eq.b32 %p89, %r44, 5; + @%p89 bra $L__BB0_106; + ld.global.v4.b32 {%r1302, %r1303, %r1304, %r1305}, [%rd7+58368]; + ld.global.v4.b32 {%r1306, %r1307, %r1308, %r1309}, [%rd7+58384]; + fma.rn.f32 %r1310, %r81, %r1302, %r2306; + fma.rn.f32 %r1311, %r82, %r1303, %r1310; + fma.rn.f32 %r1312, %r83, %r1304, %r1311; + fma.rn.f32 %r1313, %r84, %r1305, %r1312; + fma.rn.f32 %r1314, %r85, %r1306, %r1313; + fma.rn.f32 %r1315, %r86, %r1307, %r1314; + fma.rn.f32 %r1316, %r87, %r1308, %r1315; + fma.rn.f32 %r2306, %r88, %r1309, %r1316; + setp.lt.u32 %p90, %r44, 7; + @%p90 bra $L__BB0_106; + ld.global.v4.b32 {%r1317, %r1318, %r1319, %r1320}, [%rd7+68608]; + ld.global.v4.b32 {%r1321, %r1322, %r1323, %r1324}, [%rd7+68624]; + fma.rn.f32 %r1325, %r81, %r1317, %r2307; + fma.rn.f32 %r1326, %r82, %r1318, %r1325; + fma.rn.f32 %r1327, %r83, %r1319, %r1326; + fma.rn.f32 %r1328, %r84, %r1320, %r1327; + fma.rn.f32 %r1329, %r85, %r1321, %r1328; + fma.rn.f32 %r1330, %r86, %r1322, %r1329; + fma.rn.f32 %r1331, %r87, %r1323, %r1330; + fma.rn.f32 %r2307, %r88, %r1324, %r1331; + setp.eq.b32 %p91, %r44, 7; + @%p91 bra $L__BB0_106; + ld.global.v4.b32 {%r1332, %r1333, %r1334, %r1335}, [%rd7+78848]; + ld.global.v4.b32 {%r1336, %r1337, %r1338, %r1339}, [%rd7+78864]; + fma.rn.f32 %r1340, %r81, %r1332, %r2308; + fma.rn.f32 %r1341, %r82, %r1333, %r1340; + fma.rn.f32 %r1342, %r83, %r1334, %r1341; + fma.rn.f32 %r1343, %r84, %r1335, %r1342; + fma.rn.f32 %r1344, %r85, %r1336, %r1343; + fma.rn.f32 %r1345, %r86, %r1337, %r1344; + fma.rn.f32 %r1346, %r87, %r1338, %r1345; + fma.rn.f32 %r2308, %r88, %r1339, %r1346; +$L__BB0_106: + shl.b32 %r90, %r2254, 16; + and.b32 %r91, %r2254, -65536; + shl.b32 %r92, %r2253, 16; + and.b32 %r93, %r2253, -65536; + shl.b32 %r94, %r2252, 16; + and.b32 %r95, %r2252, -65536; + shl.b32 %r96, %r2251, 16; + and.b32 %r97, %r2251, -65536; + ld.global.v4.b32 {%r1347, %r1348, %r1349, %r1350}, [%rd7+8192]; + ld.global.v4.b32 {%r1351, %r1352, %r1353, %r1354}, [%rd7+8208]; + fma.rn.f32 %r1355, %r90, %r1347, %r89; + fma.rn.f32 %r1356, %r91, %r1348, %r1355; + fma.rn.f32 %r1357, %r92, %r1349, %r1356; + fma.rn.f32 %r1358, %r93, %r1350, %r1357; + fma.rn.f32 %r1359, %r94, %r1351, %r1358; + fma.rn.f32 %r1360, %r95, %r1352, %r1359; + fma.rn.f32 %r1361, %r96, %r1353, %r1360; + fma.rn.f32 %r98, %r97, %r1354, %r1361; + @%p61 bra $L__BB0_114; + ld.global.v4.b32 {%r1362, %r1363, %r1364, %r1365}, [%rd7+18432]; + ld.global.v4.b32 {%r1366, %r1367, %r1368, %r1369}, [%rd7+18448]; + fma.rn.f32 %r1370, %r90, %r1362, %r2302; + fma.rn.f32 %r1371, %r91, %r1363, %r1370; + fma.rn.f32 %r1372, %r92, %r1364, %r1371; + fma.rn.f32 %r1373, %r93, %r1365, %r1372; + fma.rn.f32 %r1374, %r94, %r1366, %r1373; + fma.rn.f32 %r1375, %r95, %r1367, %r1374; + fma.rn.f32 %r1376, %r96, %r1368, %r1375; + fma.rn.f32 %r2302, %r97, %r1369, %r1376; + setp.lt.u32 %p92, %r44, 3; + @%p92 bra $L__BB0_114; + ld.global.v4.b32 {%r1377, %r1378, %r1379, %r1380}, [%rd7+28672]; + ld.global.v4.b32 {%r1381, %r1382, %r1383, %r1384}, [%rd7+28688]; + fma.rn.f32 %r1385, %r90, %r1377, %r2303; + fma.rn.f32 %r1386, %r91, %r1378, %r1385; + fma.rn.f32 %r1387, %r92, %r1379, %r1386; + fma.rn.f32 %r1388, %r93, %r1380, %r1387; + fma.rn.f32 %r1389, %r94, %r1381, %r1388; + fma.rn.f32 %r1390, %r95, %r1382, %r1389; + fma.rn.f32 %r1391, %r96, %r1383, %r1390; + fma.rn.f32 %r2303, %r97, %r1384, %r1391; + setp.eq.b32 %p93, %r44, 3; + @%p93 bra $L__BB0_114; + ld.global.v4.b32 {%r1392, %r1393, %r1394, %r1395}, [%rd7+38912]; + ld.global.v4.b32 {%r1396, %r1397, %r1398, %r1399}, [%rd7+38928]; + fma.rn.f32 %r1400, %r90, %r1392, %r2304; + fma.rn.f32 %r1401, %r91, %r1393, %r1400; + fma.rn.f32 %r1402, %r92, %r1394, %r1401; + fma.rn.f32 %r1403, %r93, %r1395, %r1402; + fma.rn.f32 %r1404, %r94, %r1396, %r1403; + fma.rn.f32 %r1405, %r95, %r1397, %r1404; + fma.rn.f32 %r1406, %r96, %r1398, %r1405; + fma.rn.f32 %r2304, %r97, %r1399, %r1406; + setp.lt.u32 %p94, %r44, 5; + @%p94 bra $L__BB0_114; + ld.global.v4.b32 {%r1407, %r1408, %r1409, %r1410}, [%rd7+49152]; + ld.global.v4.b32 {%r1411, %r1412, %r1413, %r1414}, [%rd7+49168]; + fma.rn.f32 %r1415, %r90, %r1407, %r2305; + fma.rn.f32 %r1416, %r91, %r1408, %r1415; + fma.rn.f32 %r1417, %r92, %r1409, %r1416; + fma.rn.f32 %r1418, %r93, %r1410, %r1417; + fma.rn.f32 %r1419, %r94, %r1411, %r1418; + fma.rn.f32 %r1420, %r95, %r1412, %r1419; + fma.rn.f32 %r1421, %r96, %r1413, %r1420; + fma.rn.f32 %r2305, %r97, %r1414, %r1421; + setp.eq.b32 %p95, %r44, 5; + @%p95 bra $L__BB0_114; + ld.global.v4.b32 {%r1422, %r1423, %r1424, %r1425}, [%rd7+59392]; + ld.global.v4.b32 {%r1426, %r1427, %r1428, %r1429}, [%rd7+59408]; + fma.rn.f32 %r1430, %r90, %r1422, %r2306; + fma.rn.f32 %r1431, %r91, %r1423, %r1430; + fma.rn.f32 %r1432, %r92, %r1424, %r1431; + fma.rn.f32 %r1433, %r93, %r1425, %r1432; + fma.rn.f32 %r1434, %r94, %r1426, %r1433; + fma.rn.f32 %r1435, %r95, %r1427, %r1434; + fma.rn.f32 %r1436, %r96, %r1428, %r1435; + fma.rn.f32 %r2306, %r97, %r1429, %r1436; + setp.lt.u32 %p96, %r44, 7; + @%p96 bra $L__BB0_114; + ld.global.v4.b32 {%r1437, %r1438, %r1439, %r1440}, [%rd7+69632]; + ld.global.v4.b32 {%r1441, %r1442, %r1443, %r1444}, [%rd7+69648]; + fma.rn.f32 %r1445, %r90, %r1437, %r2307; + fma.rn.f32 %r1446, %r91, %r1438, %r1445; + fma.rn.f32 %r1447, %r92, %r1439, %r1446; + fma.rn.f32 %r1448, %r93, %r1440, %r1447; + fma.rn.f32 %r1449, %r94, %r1441, %r1448; + fma.rn.f32 %r1450, %r95, %r1442, %r1449; + fma.rn.f32 %r1451, %r96, %r1443, %r1450; + fma.rn.f32 %r2307, %r97, %r1444, %r1451; + setp.eq.b32 %p97, %r44, 7; + @%p97 bra $L__BB0_114; + ld.global.v4.b32 {%r1452, %r1453, %r1454, %r1455}, [%rd7+79872]; + ld.global.v4.b32 {%r1456, %r1457, %r1458, %r1459}, [%rd7+79888]; + fma.rn.f32 %r1460, %r90, %r1452, %r2308; + fma.rn.f32 %r1461, %r91, %r1453, %r1460; + fma.rn.f32 %r1462, %r92, %r1454, %r1461; + fma.rn.f32 %r1463, %r93, %r1455, %r1462; + fma.rn.f32 %r1464, %r94, %r1456, %r1463; + fma.rn.f32 %r1465, %r95, %r1457, %r1464; + fma.rn.f32 %r1466, %r96, %r1458, %r1465; + fma.rn.f32 %r2308, %r97, %r1459, %r1466; +$L__BB0_114: + shl.b32 %r99, %r2250, 16; + and.b32 %r100, %r2250, -65536; + shl.b32 %r101, %r2249, 16; + and.b32 %r102, %r2249, -65536; + shl.b32 %r103, %r2248, 16; + and.b32 %r104, %r2248, -65536; + shl.b32 %r105, %r2247, 16; + and.b32 %r106, %r2247, -65536; + ld.global.v4.b32 {%r1467, %r1468, %r1469, %r1470}, [%rd7+9216]; + ld.global.v4.b32 {%r1471, %r1472, %r1473, %r1474}, [%rd7+9232]; + fma.rn.f32 %r1475, %r99, %r1467, %r98; + fma.rn.f32 %r1476, %r100, %r1468, %r1475; + fma.rn.f32 %r1477, %r101, %r1469, %r1476; + fma.rn.f32 %r1478, %r102, %r1470, %r1477; + fma.rn.f32 %r1479, %r103, %r1471, %r1478; + fma.rn.f32 %r1480, %r104, %r1472, %r1479; + fma.rn.f32 %r1481, %r105, %r1473, %r1480; + fma.rn.f32 %r2301, %r106, %r1474, %r1481; + @%p61 bra $L__BB0_115; + bra.uni $L__BB0_119; +$L__BB0_115: + ld.param.b32 %r1587, [%rd1+136]; + sub.s32 %r22, %r1587, %r3; + setp.lt.s32 %p104, %r22, 1; + @%p104 bra $L__BB0_194; + mov.u32 %r1588, %tid.x; + and.b32 %r23, %r1588, 32; + setp.eq.b32 %p105, %r23, 0; + and.b32 %r24, %r1588, 31; + setp.eq.b32 %p106, %r24, 0; + ld.param.b64 %rd218, [%rd1+104]; + cvta.to.global.u64 %rd219, %rd218; + mov.u32 %r1589, %ctaid.x; + cvt.u64.u32 %rd3, %r1589; + mul.wide.u32 %rd220, %r1589, 4; + add.s64 %rd4, %rd219, %rd220; + ld.param.b64 %rd221, [%rd1+112]; + cvta.to.global.u64 %rd222, %rd221; + add.s64 %rd5, %rd222, %rd220; + ld.param.b64 %rd223, [%rd1+48]; + ld.param.b64 %rd224, [%rd1+40]; + selp.b64 %rd6, %rd224, %rd223, %p105; + shfl.sync.bfly.b32 %r1590|%p107, %r2301, 16, 31, -1; + add.f32 %r1591, %r2301, %r1590; + shfl.sync.bfly.b32 %r1592|%p108, %r1591, 8, 31, -1; + add.f32 %r1593, %r1591, %r1592; + shfl.sync.bfly.b32 %r1594|%p109, %r1593, 4, 31, -1; + add.f32 %r1595, %r1593, %r1594; + shfl.sync.bfly.b32 %r1596|%p110, %r1595, 2, 31, -1; + add.f32 %r1597, %r1595, %r1596; + shfl.sync.bfly.b32 %r1598|%p111, %r1597, 1, 31, -1; + add.f32 %r25, %r1597, %r1598; + @%p106 bra $L__BB0_117; + bra.uni $L__BB0_131; +$L__BB0_117: + setp.eq.b32 %p112, %r23, 0; + @%p112 bra $L__BB0_126; + mul.f32 %r1599, %r25, 0fBFB8AA3B; + ex2.approx.f32 %r1600, %r1599; + add.f32 %r1601, %r1600, 0f3F800000; + rcp.rn.f32 %r2311, %r1601; + mov.b32 %r2310, 18608; + bra.uni $L__BB0_130; +$L__BB0_119: + ld.global.v4.b32 {%r1482, %r1483, %r1484, %r1485}, [%rd7+19456]; + ld.global.v4.b32 {%r1486, %r1487, %r1488, %r1489}, [%rd7+19472]; + fma.rn.f32 %r1490, %r99, %r1482, %r2302; + fma.rn.f32 %r1491, %r100, %r1483, %r1490; + fma.rn.f32 %r1492, %r101, %r1484, %r1491; + fma.rn.f32 %r1493, %r102, %r1485, %r1492; + fma.rn.f32 %r1494, %r103, %r1486, %r1493; + fma.rn.f32 %r1495, %r104, %r1487, %r1494; + fma.rn.f32 %r1496, %r105, %r1488, %r1495; + fma.rn.f32 %r2302, %r106, %r1489, %r1496; + setp.lt.u32 %p98, %r44, 3; + @%p98 bra $L__BB0_115; + ld.global.v4.b32 {%r1497, %r1498, %r1499, %r1500}, [%rd7+29696]; + ld.global.v4.b32 {%r1501, %r1502, %r1503, %r1504}, [%rd7+29712]; + fma.rn.f32 %r1505, %r99, %r1497, %r2303; + fma.rn.f32 %r1506, %r100, %r1498, %r1505; + fma.rn.f32 %r1507, %r101, %r1499, %r1506; + fma.rn.f32 %r1508, %r102, %r1500, %r1507; + fma.rn.f32 %r1509, %r103, %r1501, %r1508; + fma.rn.f32 %r1510, %r104, %r1502, %r1509; + fma.rn.f32 %r1511, %r105, %r1503, %r1510; + fma.rn.f32 %r2303, %r106, %r1504, %r1511; + setp.eq.b32 %p99, %r44, 3; + @%p99 bra $L__BB0_115; + ld.global.v4.b32 {%r1512, %r1513, %r1514, %r1515}, [%rd7+39936]; + ld.global.v4.b32 {%r1516, %r1517, %r1518, %r1519}, [%rd7+39952]; + fma.rn.f32 %r1520, %r99, %r1512, %r2304; + fma.rn.f32 %r1521, %r100, %r1513, %r1520; + fma.rn.f32 %r1522, %r101, %r1514, %r1521; + fma.rn.f32 %r1523, %r102, %r1515, %r1522; + fma.rn.f32 %r1524, %r103, %r1516, %r1523; + fma.rn.f32 %r1525, %r104, %r1517, %r1524; + fma.rn.f32 %r1526, %r105, %r1518, %r1525; + fma.rn.f32 %r2304, %r106, %r1519, %r1526; + setp.lt.u32 %p100, %r44, 5; + @%p100 bra $L__BB0_115; + ld.global.v4.b32 {%r1527, %r1528, %r1529, %r1530}, [%rd7+50176]; + ld.global.v4.b32 {%r1531, %r1532, %r1533, %r1534}, [%rd7+50192]; + fma.rn.f32 %r1535, %r99, %r1527, %r2305; + fma.rn.f32 %r1536, %r100, %r1528, %r1535; + fma.rn.f32 %r1537, %r101, %r1529, %r1536; + fma.rn.f32 %r1538, %r102, %r1530, %r1537; + fma.rn.f32 %r1539, %r103, %r1531, %r1538; + fma.rn.f32 %r1540, %r104, %r1532, %r1539; + fma.rn.f32 %r1541, %r105, %r1533, %r1540; + fma.rn.f32 %r2305, %r106, %r1534, %r1541; + setp.eq.b32 %p101, %r44, 5; + @%p101 bra $L__BB0_115; + ld.global.v4.b32 {%r1542, %r1543, %r1544, %r1545}, [%rd7+60416]; + ld.global.v4.b32 {%r1546, %r1547, %r1548, %r1549}, [%rd7+60432]; + fma.rn.f32 %r1550, %r99, %r1542, %r2306; + fma.rn.f32 %r1551, %r100, %r1543, %r1550; + fma.rn.f32 %r1552, %r101, %r1544, %r1551; + fma.rn.f32 %r1553, %r102, %r1545, %r1552; + fma.rn.f32 %r1554, %r103, %r1546, %r1553; + fma.rn.f32 %r1555, %r104, %r1547, %r1554; + fma.rn.f32 %r1556, %r105, %r1548, %r1555; + fma.rn.f32 %r2306, %r106, %r1549, %r1556; + setp.lt.u32 %p102, %r44, 7; + @%p102 bra $L__BB0_115; + ld.global.v4.b32 {%r1557, %r1558, %r1559, %r1560}, [%rd7+70656]; + ld.global.v4.b32 {%r1561, %r1562, %r1563, %r1564}, [%rd7+70672]; + fma.rn.f32 %r1565, %r99, %r1557, %r2307; + fma.rn.f32 %r1566, %r100, %r1558, %r1565; + fma.rn.f32 %r1567, %r101, %r1559, %r1566; + fma.rn.f32 %r1568, %r102, %r1560, %r1567; + fma.rn.f32 %r1569, %r103, %r1561, %r1568; + fma.rn.f32 %r1570, %r104, %r1562, %r1569; + fma.rn.f32 %r1571, %r105, %r1563, %r1570; + fma.rn.f32 %r2307, %r106, %r1564, %r1571; + setp.eq.b32 %p103, %r44, 7; + @%p103 bra $L__BB0_115; + ld.global.v4.b32 {%r1572, %r1573, %r1574, %r1575}, [%rd7+80896]; + ld.global.v4.b32 {%r1576, %r1577, %r1578, %r1579}, [%rd7+80912]; + fma.rn.f32 %r1580, %r99, %r1572, %r2308; + fma.rn.f32 %r1581, %r100, %r1573, %r1580; + fma.rn.f32 %r1582, %r101, %r1574, %r1581; + fma.rn.f32 %r1583, %r102, %r1575, %r1582; + fma.rn.f32 %r1584, %r103, %r1576, %r1583; + fma.rn.f32 %r1585, %r104, %r1577, %r1584; + fma.rn.f32 %r1586, %r105, %r1578, %r1585; + fma.rn.f32 %r2308, %r106, %r1579, %r1586; + bra.uni $L__BB0_115; +$L__BB0_126: + ld.global.b32 %r107, [%rd5]; + ld.global.b32 %r1602, [%rd4]; + add.f32 %r2309, %r25, %r1602; + setp.gt.f32 %p113, %r2309, 0f41A00000; + @%p113 bra $L__BB0_129; + mul.f32 %r1603, %r2309, 0f3FB8AA3B; + ex2.approx.f32 %r108, %r1603; + mov.b32 %r1604, 0f3F800000; + add.rz.f32 %r1605, %r108, %r1604; + add.s32 %r1606, %r1605, -1061158912; + and.b32 %r1607, %r1606, -8388608; + sub.s32 %r1608, %r108, %r1607; + sub.s32 %r1609, 1082130432, %r1607; + fma.rn.f32 %r1610, %r1609, 0f3E800000, 0fBF800000; + add.f32 %r1611, %r1610, %r1608; + cvt.rn.f32.s32 %r1612, %r1607; + mul.f32 %r1613, %r1612, 0f34000000; + fma.rn.f32 %r1614, %r1611, 0fBD39BF78, 0f3DD80012; + fma.rn.f32 %r1615, %r1614, %r1611, 0fBE0778E0; + fma.rn.f32 %r1616, %r1615, %r1611, 0f3E146475; + fma.rn.f32 %r1617, %r1616, %r1611, 0fBE2A68DD; + fma.rn.f32 %r1618, %r1617, %r1611, 0f3E4CAF9E; + fma.rn.f32 %r1619, %r1618, %r1611, 0fBE800042; + fma.rn.f32 %r1620, %r1619, %r1611, 0f3EAAAAE6; + fma.rn.f32 %r1621, %r1620, %r1611, 0fBF000000; + mul.f32 %r1622, %r1611, %r1621; + fma.rn.f32 %r1623, %r1622, %r1611, %r1611; + fma.rn.f32 %r2309, %r1613, 0f3F317218, %r1623; + setp.lt.u32 %p114, %r108, 2139095040; + @%p114 bra $L__BB0_129; + setp.gt.s32 %p115, %r108, -1082130432; + fma.rn.f32 %r1624, %r108, 0f7F800000, 0f7F800000; + selp.f32 %r1625, %r1624, %r2309, %p115; + setp.eq.f32 %p116, %r108, 0f00000000; + selp.f32 %r2309, 0f80000000, %r1625, %p116; +$L__BB0_129: + mul.f32 %r2311, %r107, %r2309; + mov.b32 %r2310, 18576; +$L__BB0_130: + mov.b32 %r1626, _ZZ28leleka_verify_gdn_fused_stepE2sh; + add.s32 %r1627, %r1626, %r2310; + shl.b32 %r1628, %r3, 2; + add.s32 %r1629, %r1627, %r1628; + st.shared.b32 [%r1629], %r2311; + ld.param.s32 %rd225, [%rd1+128]; + mad.lo.s64 %rd226, %rd225, 48, %rd3; + shl.b64 %rd227, %rd226, 2; + add.s64 %rd228, %rd6, %rd227; + st.b32 [%rd228], %r2311; +$L__BB0_131: + setp.eq.b32 %p117, %r22, 1; + @%p117 bra $L__BB0_194; + setp.ne.b32 %p118, %r24, 0; + shfl.sync.bfly.b32 %r1630|%p119, %r2302, 16, 31, -1; + add.f32 %r1631, %r2302, %r1630; + shfl.sync.bfly.b32 %r1632|%p120, %r1631, 8, 31, -1; + add.f32 %r1633, %r1631, %r1632; + shfl.sync.bfly.b32 %r1634|%p121, %r1633, 4, 31, -1; + add.f32 %r1635, %r1633, %r1634; + shfl.sync.bfly.b32 %r1636|%p122, %r1635, 2, 31, -1; + add.f32 %r1637, %r1635, %r1636; + shfl.sync.bfly.b32 %r1638|%p123, %r1637, 1, 31, -1; + add.f32 %r109, %r1637, %r1638; + @%p118 bra $L__BB0_140; + setp.eq.b32 %p124, %r23, 0; + @%p124 bra $L__BB0_135; + mul.f32 %r1639, %r109, 0fBFB8AA3B; + ex2.approx.f32 %r1640, %r1639; + add.f32 %r1641, %r1640, 0f3F800000; + rcp.rn.f32 %r2314, %r1641; + mov.b32 %r2313, 18608; + bra.uni $L__BB0_139; +$L__BB0_135: + ld.global.b32 %r110, [%rd5]; + ld.global.b32 %r1642, [%rd4]; + add.f32 %r2312, %r109, %r1642; + setp.gt.f32 %p125, %r2312, 0f41A00000; + @%p125 bra $L__BB0_138; + mul.f32 %r1643, %r2312, 0f3FB8AA3B; + ex2.approx.f32 %r111, %r1643; + mov.b32 %r1644, 0f3F800000; + add.rz.f32 %r1645, %r111, %r1644; + add.s32 %r1646, %r1645, -1061158912; + and.b32 %r1647, %r1646, -8388608; + sub.s32 %r1648, %r111, %r1647; + sub.s32 %r1649, 1082130432, %r1647; + fma.rn.f32 %r1650, %r1649, 0f3E800000, 0fBF800000; + add.f32 %r1651, %r1650, %r1648; + cvt.rn.f32.s32 %r1652, %r1647; + mul.f32 %r1653, %r1652, 0f34000000; + fma.rn.f32 %r1654, %r1651, 0fBD39BF78, 0f3DD80012; + fma.rn.f32 %r1655, %r1654, %r1651, 0fBE0778E0; + fma.rn.f32 %r1656, %r1655, %r1651, 0f3E146475; + fma.rn.f32 %r1657, %r1656, %r1651, 0fBE2A68DD; + fma.rn.f32 %r1658, %r1657, %r1651, 0f3E4CAF9E; + fma.rn.f32 %r1659, %r1658, %r1651, 0fBE800042; + fma.rn.f32 %r1660, %r1659, %r1651, 0f3EAAAAE6; + fma.rn.f32 %r1661, %r1660, %r1651, 0fBF000000; + mul.f32 %r1662, %r1651, %r1661; + fma.rn.f32 %r1663, %r1662, %r1651, %r1651; + fma.rn.f32 %r2312, %r1653, 0f3F317218, %r1663; + setp.lt.u32 %p126, %r111, 2139095040; + @%p126 bra $L__BB0_138; + setp.gt.s32 %p127, %r111, -1082130432; + fma.rn.f32 %r1664, %r111, 0f7F800000, 0f7F800000; + selp.f32 %r1665, %r1664, %r2312, %p127; + setp.eq.f32 %p128, %r111, 0f00000000; + selp.f32 %r2312, 0f80000000, %r1665, %p128; +$L__BB0_138: + mul.f32 %r2314, %r110, %r2312; + mov.b32 %r2313, 18576; +$L__BB0_139: + mov.b32 %r1666, _ZZ28leleka_verify_gdn_fused_stepE2sh; + add.s32 %r1667, %r1666, %r2313; + add.s32 %r1668, %r3, 1; + shl.b32 %r1669, %r3, 2; + add.s32 %r1670, %r1667, %r1669; + st.shared.b32 [%r1670+4], %r2314; + mul.wide.s32 %rd229, %r1668, 48; + add.s64 %rd230, %rd229, %rd3; + shl.b64 %rd231, %rd230, 2; + add.s64 %rd232, %rd6, %rd231; + st.b32 [%rd232], %r2314; +$L__BB0_140: + setp.lt.u32 %p129, %r22, 3; + @%p129 bra $L__BB0_194; + setp.ne.b32 %p130, %r24, 0; + shfl.sync.bfly.b32 %r1671|%p131, %r2303, 16, 31, -1; + add.f32 %r1672, %r2303, %r1671; + shfl.sync.bfly.b32 %r1673|%p132, %r1672, 8, 31, -1; + add.f32 %r1674, %r1672, %r1673; + shfl.sync.bfly.b32 %r1675|%p133, %r1674, 4, 31, -1; + add.f32 %r1676, %r1674, %r1675; + shfl.sync.bfly.b32 %r1677|%p134, %r1676, 2, 31, -1; + add.f32 %r1678, %r1676, %r1677; + shfl.sync.bfly.b32 %r1679|%p135, %r1678, 1, 31, -1; + add.f32 %r112, %r1678, %r1679; + @%p130 bra $L__BB0_149; + setp.eq.b32 %p136, %r23, 0; + @%p136 bra $L__BB0_144; + mul.f32 %r1680, %r112, 0fBFB8AA3B; + ex2.approx.f32 %r1681, %r1680; + add.f32 %r1682, %r1681, 0f3F800000; + rcp.rn.f32 %r2317, %r1682; + mov.b32 %r2316, 18608; + bra.uni $L__BB0_148; +$L__BB0_144: + ld.global.b32 %r113, [%rd5]; + ld.global.b32 %r1683, [%rd4]; + add.f32 %r2315, %r112, %r1683; + setp.gt.f32 %p137, %r2315, 0f41A00000; + @%p137 bra $L__BB0_147; + mul.f32 %r1684, %r2315, 0f3FB8AA3B; + ex2.approx.f32 %r114, %r1684; + mov.b32 %r1685, 0f3F800000; + add.rz.f32 %r1686, %r114, %r1685; + add.s32 %r1687, %r1686, -1061158912; + and.b32 %r1688, %r1687, -8388608; + sub.s32 %r1689, %r114, %r1688; + sub.s32 %r1690, 1082130432, %r1688; + fma.rn.f32 %r1691, %r1690, 0f3E800000, 0fBF800000; + add.f32 %r1692, %r1691, %r1689; + cvt.rn.f32.s32 %r1693, %r1688; + mul.f32 %r1694, %r1693, 0f34000000; + fma.rn.f32 %r1695, %r1692, 0fBD39BF78, 0f3DD80012; + fma.rn.f32 %r1696, %r1695, %r1692, 0fBE0778E0; + fma.rn.f32 %r1697, %r1696, %r1692, 0f3E146475; + fma.rn.f32 %r1698, %r1697, %r1692, 0fBE2A68DD; + fma.rn.f32 %r1699, %r1698, %r1692, 0f3E4CAF9E; + fma.rn.f32 %r1700, %r1699, %r1692, 0fBE800042; + fma.rn.f32 %r1701, %r1700, %r1692, 0f3EAAAAE6; + fma.rn.f32 %r1702, %r1701, %r1692, 0fBF000000; + mul.f32 %r1703, %r1692, %r1702; + fma.rn.f32 %r1704, %r1703, %r1692, %r1692; + fma.rn.f32 %r2315, %r1694, 0f3F317218, %r1704; + setp.lt.u32 %p138, %r114, 2139095040; + @%p138 bra $L__BB0_147; + setp.gt.s32 %p139, %r114, -1082130432; + fma.rn.f32 %r1705, %r114, 0f7F800000, 0f7F800000; + selp.f32 %r1706, %r1705, %r2315, %p139; + setp.eq.f32 %p140, %r114, 0f00000000; + selp.f32 %r2315, 0f80000000, %r1706, %p140; +$L__BB0_147: + mul.f32 %r2317, %r113, %r2315; + mov.b32 %r2316, 18576; +$L__BB0_148: + mov.b32 %r1707, _ZZ28leleka_verify_gdn_fused_stepE2sh; + add.s32 %r1708, %r1707, %r2316; + add.s32 %r1709, %r3, 2; + shl.b32 %r1710, %r3, 2; + add.s32 %r1711, %r1708, %r1710; + st.shared.b32 [%r1711+8], %r2317; + mul.wide.s32 %rd233, %r1709, 48; + add.s64 %rd234, %rd233, %rd3; + shl.b64 %rd235, %rd234, 2; + add.s64 %rd236, %rd6, %rd235; + st.b32 [%rd236], %r2317; +$L__BB0_149: + setp.eq.b32 %p141, %r22, 3; + @%p141 bra $L__BB0_194; + setp.ne.b32 %p142, %r24, 0; + shfl.sync.bfly.b32 %r1712|%p143, %r2304, 16, 31, -1; + add.f32 %r1713, %r2304, %r1712; + shfl.sync.bfly.b32 %r1714|%p144, %r1713, 8, 31, -1; + add.f32 %r1715, %r1713, %r1714; + shfl.sync.bfly.b32 %r1716|%p145, %r1715, 4, 31, -1; + add.f32 %r1717, %r1715, %r1716; + shfl.sync.bfly.b32 %r1718|%p146, %r1717, 2, 31, -1; + add.f32 %r1719, %r1717, %r1718; + shfl.sync.bfly.b32 %r1720|%p147, %r1719, 1, 31, -1; + add.f32 %r115, %r1719, %r1720; + @%p142 bra $L__BB0_158; + setp.eq.b32 %p148, %r23, 0; + @%p148 bra $L__BB0_153; + mul.f32 %r1721, %r115, 0fBFB8AA3B; + ex2.approx.f32 %r1722, %r1721; + add.f32 %r1723, %r1722, 0f3F800000; + rcp.rn.f32 %r2320, %r1723; + mov.b32 %r2319, 18608; + bra.uni $L__BB0_157; +$L__BB0_153: + ld.global.b32 %r116, [%rd5]; + ld.global.b32 %r1724, [%rd4]; + add.f32 %r2318, %r115, %r1724; + setp.gt.f32 %p149, %r2318, 0f41A00000; + @%p149 bra $L__BB0_156; + mul.f32 %r1725, %r2318, 0f3FB8AA3B; + ex2.approx.f32 %r117, %r1725; + mov.b32 %r1726, 0f3F800000; + add.rz.f32 %r1727, %r117, %r1726; + add.s32 %r1728, %r1727, -1061158912; + and.b32 %r1729, %r1728, -8388608; + sub.s32 %r1730, %r117, %r1729; + sub.s32 %r1731, 1082130432, %r1729; + fma.rn.f32 %r1732, %r1731, 0f3E800000, 0fBF800000; + add.f32 %r1733, %r1732, %r1730; + cvt.rn.f32.s32 %r1734, %r1729; + mul.f32 %r1735, %r1734, 0f34000000; + fma.rn.f32 %r1736, %r1733, 0fBD39BF78, 0f3DD80012; + fma.rn.f32 %r1737, %r1736, %r1733, 0fBE0778E0; + fma.rn.f32 %r1738, %r1737, %r1733, 0f3E146475; + fma.rn.f32 %r1739, %r1738, %r1733, 0fBE2A68DD; + fma.rn.f32 %r1740, %r1739, %r1733, 0f3E4CAF9E; + fma.rn.f32 %r1741, %r1740, %r1733, 0fBE800042; + fma.rn.f32 %r1742, %r1741, %r1733, 0f3EAAAAE6; + fma.rn.f32 %r1743, %r1742, %r1733, 0fBF000000; + mul.f32 %r1744, %r1733, %r1743; + fma.rn.f32 %r1745, %r1744, %r1733, %r1733; + fma.rn.f32 %r2318, %r1735, 0f3F317218, %r1745; + setp.lt.u32 %p150, %r117, 2139095040; + @%p150 bra $L__BB0_156; + setp.gt.s32 %p151, %r117, -1082130432; + fma.rn.f32 %r1746, %r117, 0f7F800000, 0f7F800000; + selp.f32 %r1747, %r1746, %r2318, %p151; + setp.eq.f32 %p152, %r117, 0f00000000; + selp.f32 %r2318, 0f80000000, %r1747, %p152; +$L__BB0_156: + mul.f32 %r2320, %r116, %r2318; + mov.b32 %r2319, 18576; +$L__BB0_157: + mov.b32 %r1748, _ZZ28leleka_verify_gdn_fused_stepE2sh; + add.s32 %r1749, %r1748, %r2319; + add.s32 %r1750, %r3, 3; + shl.b32 %r1751, %r3, 2; + add.s32 %r1752, %r1749, %r1751; + st.shared.b32 [%r1752+12], %r2320; + mul.wide.s32 %rd237, %r1750, 48; + add.s64 %rd238, %rd237, %rd3; + shl.b64 %rd239, %rd238, 2; + add.s64 %rd240, %rd6, %rd239; + st.b32 [%rd240], %r2320; +$L__BB0_158: + setp.lt.u32 %p153, %r22, 5; + @%p153 bra $L__BB0_194; + setp.ne.b32 %p154, %r24, 0; + shfl.sync.bfly.b32 %r1753|%p155, %r2305, 16, 31, -1; + add.f32 %r1754, %r2305, %r1753; + shfl.sync.bfly.b32 %r1755|%p156, %r1754, 8, 31, -1; + add.f32 %r1756, %r1754, %r1755; + shfl.sync.bfly.b32 %r1757|%p157, %r1756, 4, 31, -1; + add.f32 %r1758, %r1756, %r1757; + shfl.sync.bfly.b32 %r1759|%p158, %r1758, 2, 31, -1; + add.f32 %r1760, %r1758, %r1759; + shfl.sync.bfly.b32 %r1761|%p159, %r1760, 1, 31, -1; + add.f32 %r118, %r1760, %r1761; + @%p154 bra $L__BB0_167; + setp.eq.b32 %p160, %r23, 0; + @%p160 bra $L__BB0_162; + mul.f32 %r1762, %r118, 0fBFB8AA3B; + ex2.approx.f32 %r1763, %r1762; + add.f32 %r1764, %r1763, 0f3F800000; + rcp.rn.f32 %r2323, %r1764; + mov.b32 %r2322, 18608; + bra.uni $L__BB0_166; +$L__BB0_162: + ld.global.b32 %r119, [%rd5]; + ld.global.b32 %r1765, [%rd4]; + add.f32 %r2321, %r118, %r1765; + setp.gt.f32 %p161, %r2321, 0f41A00000; + @%p161 bra $L__BB0_165; + mul.f32 %r1766, %r2321, 0f3FB8AA3B; + ex2.approx.f32 %r120, %r1766; + mov.b32 %r1767, 0f3F800000; + add.rz.f32 %r1768, %r120, %r1767; + add.s32 %r1769, %r1768, -1061158912; + and.b32 %r1770, %r1769, -8388608; + sub.s32 %r1771, %r120, %r1770; + sub.s32 %r1772, 1082130432, %r1770; + fma.rn.f32 %r1773, %r1772, 0f3E800000, 0fBF800000; + add.f32 %r1774, %r1773, %r1771; + cvt.rn.f32.s32 %r1775, %r1770; + mul.f32 %r1776, %r1775, 0f34000000; + fma.rn.f32 %r1777, %r1774, 0fBD39BF78, 0f3DD80012; + fma.rn.f32 %r1778, %r1777, %r1774, 0fBE0778E0; + fma.rn.f32 %r1779, %r1778, %r1774, 0f3E146475; + fma.rn.f32 %r1780, %r1779, %r1774, 0fBE2A68DD; + fma.rn.f32 %r1781, %r1780, %r1774, 0f3E4CAF9E; + fma.rn.f32 %r1782, %r1781, %r1774, 0fBE800042; + fma.rn.f32 %r1783, %r1782, %r1774, 0f3EAAAAE6; + fma.rn.f32 %r1784, %r1783, %r1774, 0fBF000000; + mul.f32 %r1785, %r1774, %r1784; + fma.rn.f32 %r1786, %r1785, %r1774, %r1774; + fma.rn.f32 %r2321, %r1776, 0f3F317218, %r1786; + setp.lt.u32 %p162, %r120, 2139095040; + @%p162 bra $L__BB0_165; + setp.gt.s32 %p163, %r120, -1082130432; + fma.rn.f32 %r1787, %r120, 0f7F800000, 0f7F800000; + selp.f32 %r1788, %r1787, %r2321, %p163; + setp.eq.f32 %p164, %r120, 0f00000000; + selp.f32 %r2321, 0f80000000, %r1788, %p164; +$L__BB0_165: + mul.f32 %r2323, %r119, %r2321; + mov.b32 %r2322, 18576; +$L__BB0_166: + mov.b32 %r1789, _ZZ28leleka_verify_gdn_fused_stepE2sh; + add.s32 %r1790, %r1789, %r2322; + add.s32 %r1791, %r3, 4; + shl.b32 %r1792, %r3, 2; + add.s32 %r1793, %r1790, %r1792; + st.shared.b32 [%r1793+16], %r2323; + mul.wide.s32 %rd241, %r1791, 48; + add.s64 %rd242, %rd241, %rd3; + shl.b64 %rd243, %rd242, 2; + add.s64 %rd244, %rd6, %rd243; + st.b32 [%rd244], %r2323; +$L__BB0_167: + setp.eq.b32 %p165, %r22, 5; + @%p165 bra $L__BB0_194; + setp.ne.b32 %p166, %r24, 0; + shfl.sync.bfly.b32 %r1794|%p167, %r2306, 16, 31, -1; + add.f32 %r1795, %r2306, %r1794; + shfl.sync.bfly.b32 %r1796|%p168, %r1795, 8, 31, -1; + add.f32 %r1797, %r1795, %r1796; + shfl.sync.bfly.b32 %r1798|%p169, %r1797, 4, 31, -1; + add.f32 %r1799, %r1797, %r1798; + shfl.sync.bfly.b32 %r1800|%p170, %r1799, 2, 31, -1; + add.f32 %r1801, %r1799, %r1800; + shfl.sync.bfly.b32 %r1802|%p171, %r1801, 1, 31, -1; + add.f32 %r121, %r1801, %r1802; + @%p166 bra $L__BB0_176; + setp.eq.b32 %p172, %r23, 0; + @%p172 bra $L__BB0_171; + mul.f32 %r1803, %r121, 0fBFB8AA3B; + ex2.approx.f32 %r1804, %r1803; + add.f32 %r1805, %r1804, 0f3F800000; + rcp.rn.f32 %r2326, %r1805; + mov.b32 %r2325, 18608; + bra.uni $L__BB0_175; +$L__BB0_171: + ld.global.b32 %r122, [%rd5]; + ld.global.b32 %r1806, [%rd4]; + add.f32 %r2324, %r121, %r1806; + setp.gt.f32 %p173, %r2324, 0f41A00000; + @%p173 bra $L__BB0_174; + mul.f32 %r1807, %r2324, 0f3FB8AA3B; + ex2.approx.f32 %r123, %r1807; + mov.b32 %r1808, 0f3F800000; + add.rz.f32 %r1809, %r123, %r1808; + add.s32 %r1810, %r1809, -1061158912; + and.b32 %r1811, %r1810, -8388608; + sub.s32 %r1812, %r123, %r1811; + sub.s32 %r1813, 1082130432, %r1811; + fma.rn.f32 %r1814, %r1813, 0f3E800000, 0fBF800000; + add.f32 %r1815, %r1814, %r1812; + cvt.rn.f32.s32 %r1816, %r1811; + mul.f32 %r1817, %r1816, 0f34000000; + fma.rn.f32 %r1818, %r1815, 0fBD39BF78, 0f3DD80012; + fma.rn.f32 %r1819, %r1818, %r1815, 0fBE0778E0; + fma.rn.f32 %r1820, %r1819, %r1815, 0f3E146475; + fma.rn.f32 %r1821, %r1820, %r1815, 0fBE2A68DD; + fma.rn.f32 %r1822, %r1821, %r1815, 0f3E4CAF9E; + fma.rn.f32 %r1823, %r1822, %r1815, 0fBE800042; + fma.rn.f32 %r1824, %r1823, %r1815, 0f3EAAAAE6; + fma.rn.f32 %r1825, %r1824, %r1815, 0fBF000000; + mul.f32 %r1826, %r1815, %r1825; + fma.rn.f32 %r1827, %r1826, %r1815, %r1815; + fma.rn.f32 %r2324, %r1817, 0f3F317218, %r1827; + setp.lt.u32 %p174, %r123, 2139095040; + @%p174 bra $L__BB0_174; + setp.gt.s32 %p175, %r123, -1082130432; + fma.rn.f32 %r1828, %r123, 0f7F800000, 0f7F800000; + selp.f32 %r1829, %r1828, %r2324, %p175; + setp.eq.f32 %p176, %r123, 0f00000000; + selp.f32 %r2324, 0f80000000, %r1829, %p176; +$L__BB0_174: + mul.f32 %r2326, %r122, %r2324; + mov.b32 %r2325, 18576; +$L__BB0_175: + mov.b32 %r1830, _ZZ28leleka_verify_gdn_fused_stepE2sh; + add.s32 %r1831, %r1830, %r2325; + add.s32 %r1832, %r3, 5; + shl.b32 %r1833, %r3, 2; + add.s32 %r1834, %r1831, %r1833; + st.shared.b32 [%r1834+20], %r2326; + mul.wide.s32 %rd245, %r1832, 48; + add.s64 %rd246, %rd245, %rd3; + shl.b64 %rd247, %rd246, 2; + add.s64 %rd248, %rd6, %rd247; + st.b32 [%rd248], %r2326; +$L__BB0_176: + setp.lt.u32 %p177, %r22, 7; + @%p177 bra $L__BB0_194; + setp.ne.b32 %p178, %r24, 0; + shfl.sync.bfly.b32 %r1835|%p179, %r2307, 16, 31, -1; + add.f32 %r1836, %r2307, %r1835; + shfl.sync.bfly.b32 %r1837|%p180, %r1836, 8, 31, -1; + add.f32 %r1838, %r1836, %r1837; + shfl.sync.bfly.b32 %r1839|%p181, %r1838, 4, 31, -1; + add.f32 %r1840, %r1838, %r1839; + shfl.sync.bfly.b32 %r1841|%p182, %r1840, 2, 31, -1; + add.f32 %r1842, %r1840, %r1841; + shfl.sync.bfly.b32 %r1843|%p183, %r1842, 1, 31, -1; + add.f32 %r124, %r1842, %r1843; + @%p178 bra $L__BB0_185; + setp.eq.b32 %p184, %r23, 0; + @%p184 bra $L__BB0_180; + mul.f32 %r1844, %r124, 0fBFB8AA3B; + ex2.approx.f32 %r1845, %r1844; + add.f32 %r1846, %r1845, 0f3F800000; + rcp.rn.f32 %r2329, %r1846; + mov.b32 %r2328, 18608; + bra.uni $L__BB0_184; +$L__BB0_180: + ld.global.b32 %r125, [%rd5]; + ld.global.b32 %r1847, [%rd4]; + add.f32 %r2327, %r124, %r1847; + setp.gt.f32 %p185, %r2327, 0f41A00000; + @%p185 bra $L__BB0_183; + mul.f32 %r1848, %r2327, 0f3FB8AA3B; + ex2.approx.f32 %r126, %r1848; + mov.b32 %r1849, 0f3F800000; + add.rz.f32 %r1850, %r126, %r1849; + add.s32 %r1851, %r1850, -1061158912; + and.b32 %r1852, %r1851, -8388608; + sub.s32 %r1853, %r126, %r1852; + sub.s32 %r1854, 1082130432, %r1852; + fma.rn.f32 %r1855, %r1854, 0f3E800000, 0fBF800000; + add.f32 %r1856, %r1855, %r1853; + cvt.rn.f32.s32 %r1857, %r1852; + mul.f32 %r1858, %r1857, 0f34000000; + fma.rn.f32 %r1859, %r1856, 0fBD39BF78, 0f3DD80012; + fma.rn.f32 %r1860, %r1859, %r1856, 0fBE0778E0; + fma.rn.f32 %r1861, %r1860, %r1856, 0f3E146475; + fma.rn.f32 %r1862, %r1861, %r1856, 0fBE2A68DD; + fma.rn.f32 %r1863, %r1862, %r1856, 0f3E4CAF9E; + fma.rn.f32 %r1864, %r1863, %r1856, 0fBE800042; + fma.rn.f32 %r1865, %r1864, %r1856, 0f3EAAAAE6; + fma.rn.f32 %r1866, %r1865, %r1856, 0fBF000000; + mul.f32 %r1867, %r1856, %r1866; + fma.rn.f32 %r1868, %r1867, %r1856, %r1856; + fma.rn.f32 %r2327, %r1858, 0f3F317218, %r1868; + setp.lt.u32 %p186, %r126, 2139095040; + @%p186 bra $L__BB0_183; + setp.gt.s32 %p187, %r126, -1082130432; + fma.rn.f32 %r1869, %r126, 0f7F800000, 0f7F800000; + selp.f32 %r1870, %r1869, %r2327, %p187; + setp.eq.f32 %p188, %r126, 0f00000000; + selp.f32 %r2327, 0f80000000, %r1870, %p188; +$L__BB0_183: + mul.f32 %r2329, %r125, %r2327; + mov.b32 %r2328, 18576; +$L__BB0_184: + mov.b32 %r1871, _ZZ28leleka_verify_gdn_fused_stepE2sh; + add.s32 %r1872, %r1871, %r2328; + add.s32 %r1873, %r3, 6; + shl.b32 %r1874, %r3, 2; + add.s32 %r1875, %r1872, %r1874; + st.shared.b32 [%r1875+24], %r2329; + mul.wide.s32 %rd249, %r1873, 48; + add.s64 %rd250, %rd249, %rd3; + shl.b64 %rd251, %rd250, 2; + add.s64 %rd252, %rd6, %rd251; + st.b32 [%rd252], %r2329; +$L__BB0_185: + setp.eq.b32 %p189, %r22, 7; + @%p189 bra $L__BB0_194; + setp.ne.b32 %p190, %r24, 0; + shfl.sync.bfly.b32 %r1876|%p191, %r2308, 16, 31, -1; + add.f32 %r1877, %r2308, %r1876; + shfl.sync.bfly.b32 %r1878|%p192, %r1877, 8, 31, -1; + add.f32 %r1879, %r1877, %r1878; + shfl.sync.bfly.b32 %r1880|%p193, %r1879, 4, 31, -1; + add.f32 %r1881, %r1879, %r1880; + shfl.sync.bfly.b32 %r1882|%p194, %r1881, 2, 31, -1; + add.f32 %r1883, %r1881, %r1882; + shfl.sync.bfly.b32 %r1884|%p195, %r1883, 1, 31, -1; + add.f32 %r127, %r1883, %r1884; + @%p190 bra $L__BB0_194; + setp.eq.b32 %p196, %r23, 0; + ld.global.b32 %r128, [%rd5]; + @%p196 bra $L__BB0_189; + mul.f32 %r1885, %r127, 0fBFB8AA3B; + ex2.approx.f32 %r1886, %r1885; + add.f32 %r1887, %r1886, 0f3F800000; + rcp.rn.f32 %r2332, %r1887; + mov.b32 %r2331, 18608; + bra.uni $L__BB0_193; +$L__BB0_189: + ld.global.b32 %r1888, [%rd4]; + add.f32 %r2330, %r127, %r1888; + setp.gt.f32 %p197, %r2330, 0f41A00000; + @%p197 bra $L__BB0_192; + mul.f32 %r1889, %r2330, 0f3FB8AA3B; + ex2.approx.f32 %r129, %r1889; + mov.b32 %r1890, 0f3F800000; + add.rz.f32 %r1891, %r129, %r1890; + add.s32 %r1892, %r1891, -1061158912; + and.b32 %r1893, %r1892, -8388608; + sub.s32 %r1894, %r129, %r1893; + sub.s32 %r1895, 1082130432, %r1893; + fma.rn.f32 %r1896, %r1895, 0f3E800000, 0fBF800000; + add.f32 %r1897, %r1896, %r1894; + cvt.rn.f32.s32 %r1898, %r1893; + mul.f32 %r1899, %r1898, 0f34000000; + fma.rn.f32 %r1900, %r1897, 0fBD39BF78, 0f3DD80012; + fma.rn.f32 %r1901, %r1900, %r1897, 0fBE0778E0; + fma.rn.f32 %r1902, %r1901, %r1897, 0f3E146475; + fma.rn.f32 %r1903, %r1902, %r1897, 0fBE2A68DD; + fma.rn.f32 %r1904, %r1903, %r1897, 0f3E4CAF9E; + fma.rn.f32 %r1905, %r1904, %r1897, 0fBE800042; + fma.rn.f32 %r1906, %r1905, %r1897, 0f3EAAAAE6; + fma.rn.f32 %r1907, %r1906, %r1897, 0fBF000000; + mul.f32 %r1908, %r1897, %r1907; + fma.rn.f32 %r1909, %r1908, %r1897, %r1897; + fma.rn.f32 %r2330, %r1899, 0f3F317218, %r1909; + setp.lt.u32 %p198, %r129, 2139095040; + @%p198 bra $L__BB0_192; + setp.gt.s32 %p199, %r129, -1082130432; + fma.rn.f32 %r1910, %r129, 0f7F800000, 0f7F800000; + selp.f32 %r1911, %r1910, %r2330, %p199; + setp.eq.f32 %p200, %r129, 0f00000000; + selp.f32 %r2330, 0f80000000, %r1911, %p200; +$L__BB0_192: + mul.f32 %r2332, %r128, %r2330; + mov.b32 %r2331, 18576; +$L__BB0_193: + mov.b32 %r1912, _ZZ28leleka_verify_gdn_fused_stepE2sh; + add.s32 %r1913, %r1912, %r2331; + add.s32 %r1914, %r3, 7; + shl.b32 %r1915, %r3, 2; + add.s32 %r1916, %r1913, %r1915; + st.shared.b32 [%r1916+28], %r2332; + mul.wide.s32 %rd253, %r1914, 48; + add.s64 %rd254, %rd253, %rd3; + shl.b64 %rd255, %rd254, 2; + add.s64 %rd256, %rd6, %rd255; + st.b32 [%rd256], %r2332; +$L__BB0_194: + bar.sync 0; + ld.param.b32 %r130, [%rd1+136]; + setp.lt.s32 %p201, %r130, 1; + @%p201 bra $L__BB0_204; + ld.param.b64 %rd257, [%rd1]; + mov.u32 %r131, %tid.x; + mov.u32 %r132, %tid.y; + mov.u32 %r1917, %ctaid.x; + mad.lo.s32 %r1918, %r132, 1536, %r1917; + mul.wide.u32 %rd258, %r1918, 512; + cvta.to.global.u64 %rd259, %rd257; + add.s64 %rd260, %rd259, %rd258; + mul.wide.u32 %rd261, %r131, 4; + add.s64 %rd262, %rd260, %rd261; + ld.global.b32 %r2368, [%rd262+761856]; + ld.global.b32 %r2367, [%rd262+737280]; + ld.global.b32 %r2366, [%rd262+712704]; + ld.global.b32 %r2365, [%rd262+688128]; + ld.global.b32 %r2364, [%rd262+663552]; + ld.global.b32 %r2363, [%rd262+638976]; + ld.global.b32 %r2362, [%rd262+614400]; + ld.global.b32 %r2361, [%rd262+589824]; + ld.global.b32 %r2360, [%rd262+565248]; + ld.global.b32 %r2359, [%rd262+540672]; + ld.global.b32 %r2358, [%rd262+516096]; + ld.global.b32 %r2357, [%rd262+491520]; + ld.global.b32 %r2356, [%rd262+466944]; + ld.global.b32 %r2355, [%rd262+442368]; + ld.global.b32 %r2354, [%rd262+417792]; + ld.global.b32 %r2353, [%rd262+393216]; + ld.global.b32 %r2352, [%rd262+368640]; + ld.global.b32 %r2351, [%rd262+344064]; + ld.global.b32 %r2350, [%rd262+319488]; + ld.global.b32 %r2349, [%rd262+294912]; + ld.global.b32 %r2348, [%rd262+270336]; + ld.global.b32 %r2347, [%rd262+245760]; + ld.global.b32 %r2346, [%rd262+221184]; + ld.global.b32 %r2345, [%rd262+196608]; + ld.global.b32 %r2344, [%rd262+172032]; + ld.global.b32 %r2343, [%rd262+147456]; + ld.global.b32 %r2342, [%rd262+122880]; + ld.global.b32 %r2341, [%rd262+98304]; + ld.global.b32 %r2340, [%rd262+73728]; + ld.global.b32 %r2339, [%rd262+49152]; + ld.global.b32 %r2338, [%rd262+24576]; + ld.global.b32 %r2337, [%rd262]; + shl.b32 %r1919, %r131, 2; + mov.b32 %r2335, _ZZ28leleka_verify_gdn_fused_stepE2sh; + add.s32 %r133, %r2335, %r1919; + shl.b32 %r1920, %r132, 9; + add.s32 %r134, %r133, %r1920; + shr.u32 %r1921, %r131, 3; + add.s32 %r135, %r2335, %r1921; + ld.param.b64 %rd263, [%rd1+56]; + cvta.to.global.u64 %rd264, %rd263; + shl.b32 %r1922, %r1917, 7; + add.s32 %r1923, %r1922, %r131; + ld.param.b64 %rd265, [%rd1+64]; + cvta.to.global.u64 %rd266, %rd265; + add.s64 %rd8, %rd266, %rd261; + ld.param.b64 %rd267, [%rd1+72]; + cvta.to.global.u64 %rd268, %rd267; + neg.s32 %r2336, %r130; + mul.wide.u32 %rd269, %r1923, 4; + add.s64 %rd275, %rd264, %rd269; + add.s64 %rd274, %rd268, %rd269; + add.s32 %r2334, %r133, 8192; + shl.b32 %r1924, %r132, 7; + add.s32 %r1925, %r1924, %r2335; + add.s32 %r2333, %r1925, 4096; + mov.b32 %r2369, 0; +$L__BB0_196: + ld.shared.b32 %r1926, [%r2335+18576]; + mul.f32 %r1927, %r1926, 0f3FB8AA3B; + ex2.approx.f32 %r136, %r1927; + ld.shared.b32 %r1928, [%r2333]; + fma.rn.f32 %r1929, %r2337, %r1928, 0f00000000; + ld.shared.b32 %r1930, [%r2333+4]; + fma.rn.f32 %r1931, %r2338, %r1930, %r1929; + ld.shared.b32 %r1932, [%r2333+8]; + fma.rn.f32 %r1933, %r2339, %r1932, %r1931; + ld.shared.b32 %r1934, [%r2333+12]; + fma.rn.f32 %r1935, %r2340, %r1934, %r1933; + ld.shared.b32 %r1936, [%r2333+16]; + fma.rn.f32 %r1937, %r2341, %r1936, %r1935; + ld.shared.b32 %r1938, [%r2333+20]; + fma.rn.f32 %r1939, %r2342, %r1938, %r1937; + ld.shared.b32 %r1940, [%r2333+24]; + fma.rn.f32 %r1941, %r2343, %r1940, %r1939; + ld.shared.b32 %r1942, [%r2333+28]; + fma.rn.f32 %r1943, %r2344, %r1942, %r1941; + ld.shared.b32 %r1944, [%r2333+32]; + fma.rn.f32 %r1945, %r2345, %r1944, %r1943; + ld.shared.b32 %r1946, [%r2333+36]; + fma.rn.f32 %r1947, %r2346, %r1946, %r1945; + ld.shared.b32 %r1948, [%r2333+40]; + fma.rn.f32 %r1949, %r2347, %r1948, %r1947; + ld.shared.b32 %r1950, [%r2333+44]; + fma.rn.f32 %r1951, %r2348, %r1950, %r1949; + ld.shared.b32 %r1952, [%r2333+48]; + fma.rn.f32 %r1953, %r2349, %r1952, %r1951; + ld.shared.b32 %r1954, [%r2333+52]; + fma.rn.f32 %r1955, %r2350, %r1954, %r1953; + ld.shared.b32 %r1956, [%r2333+56]; + fma.rn.f32 %r1957, %r2351, %r1956, %r1955; + ld.shared.b32 %r1958, [%r2333+60]; + fma.rn.f32 %r1959, %r2352, %r1958, %r1957; + ld.shared.b32 %r1960, [%r2333+64]; + fma.rn.f32 %r1961, %r2353, %r1960, %r1959; + ld.shared.b32 %r1962, [%r2333+68]; + fma.rn.f32 %r1963, %r2354, %r1962, %r1961; + ld.shared.b32 %r1964, [%r2333+72]; + fma.rn.f32 %r1965, %r2355, %r1964, %r1963; + ld.shared.b32 %r1966, [%r2333+76]; + fma.rn.f32 %r1967, %r2356, %r1966, %r1965; + ld.shared.b32 %r1968, [%r2333+80]; + fma.rn.f32 %r1969, %r2357, %r1968, %r1967; + ld.shared.b32 %r1970, [%r2333+84]; + fma.rn.f32 %r1971, %r2358, %r1970, %r1969; + ld.shared.b32 %r1972, [%r2333+88]; + fma.rn.f32 %r1973, %r2359, %r1972, %r1971; + ld.shared.b32 %r1974, [%r2333+92]; + fma.rn.f32 %r1975, %r2360, %r1974, %r1973; + ld.shared.b32 %r1976, [%r2333+96]; + fma.rn.f32 %r1977, %r2361, %r1976, %r1975; + ld.shared.b32 %r1978, [%r2333+100]; + fma.rn.f32 %r1979, %r2362, %r1978, %r1977; + ld.shared.b32 %r1980, [%r2333+104]; + fma.rn.f32 %r1981, %r2363, %r1980, %r1979; + ld.shared.b32 %r1982, [%r2333+108]; + fma.rn.f32 %r1983, %r2364, %r1982, %r1981; + ld.shared.b32 %r1984, [%r2333+112]; + fma.rn.f32 %r1985, %r2365, %r1984, %r1983; + ld.shared.b32 %r1986, [%r2333+116]; + fma.rn.f32 %r1987, %r2366, %r1986, %r1985; + ld.shared.b32 %r1988, [%r2333+120]; + fma.rn.f32 %r1989, %r2367, %r1988, %r1987; + ld.shared.b32 %r1990, [%r2333+124]; + fma.rn.f32 %r1991, %r2368, %r1990, %r1989; + shl.b32 %r1992, %r2369, 11; + and.b32 %r1993, %r1992, 2048; + mov.b32 %r1994, _ZZ28leleka_verify_gdn_fused_stepE2sh; + add.s32 %r1995, %r1994, %r1993; + shl.b32 %r1996, %r132, 9; + shl.b32 %r1997, %r131, 2; + add.s32 %r1998, %r1995, %r1997; + add.s32 %r1999, %r1998, %r1996; + st.shared.b32 [%r1999+12288], %r1991; + bar.sync 0; + ld.shared.b32 %r2000, [%r1998+12288]; + ld.shared.b32 %r2001, [%r1998+12800]; + add.f32 %r2002, %r2000, %r2001; + ld.shared.b32 %r2003, [%r1998+13312]; + add.f32 %r2004, %r2002, %r2003; + ld.shared.b32 %r2005, [%r1998+13824]; + add.f32 %r2006, %r2004, %r2005; + ld.shared.b32 %r2007, [%r2334]; + mul.f32 %r2008, %r136, %r2006; + sub.f32 %r2009, %r2007, %r2008; + ld.shared.b32 %r2010, [%r2335+18608]; + mul.f32 %r137, %r2010, %r2009; + setp.ge.s32 %p202, %r2369, %r3; + @%p202 bra $L__BB0_198; + ld.shared.b32 %r2177, [%r2333]; + mul.f32 %r2178, %r137, %r2177; + fma.rn.f32 %r2337, %r136, %r2337, %r2178; + ld.shared.b32 %r2179, [%r2333+4]; + mul.f32 %r2180, %r137, %r2179; + fma.rn.f32 %r2338, %r136, %r2338, %r2180; + ld.shared.b32 %r2181, [%r2333+8]; + mul.f32 %r2182, %r137, %r2181; + fma.rn.f32 %r2339, %r136, %r2339, %r2182; + ld.shared.b32 %r2183, [%r2333+12]; + mul.f32 %r2184, %r137, %r2183; + fma.rn.f32 %r2340, %r136, %r2340, %r2184; + ld.shared.b32 %r2185, [%r2333+16]; + mul.f32 %r2186, %r137, %r2185; + fma.rn.f32 %r2341, %r136, %r2341, %r2186; + ld.shared.b32 %r2187, [%r2333+20]; + mul.f32 %r2188, %r137, %r2187; + fma.rn.f32 %r2342, %r136, %r2342, %r2188; + ld.shared.b32 %r2189, [%r2333+24]; + mul.f32 %r2190, %r137, %r2189; + fma.rn.f32 %r2343, %r136, %r2343, %r2190; + ld.shared.b32 %r2191, [%r2333+28]; + mul.f32 %r2192, %r137, %r2191; + fma.rn.f32 %r2344, %r136, %r2344, %r2192; + ld.shared.b32 %r2193, [%r2333+32]; + mul.f32 %r2194, %r137, %r2193; + fma.rn.f32 %r2345, %r136, %r2345, %r2194; + ld.shared.b32 %r2195, [%r2333+36]; + mul.f32 %r2196, %r137, %r2195; + fma.rn.f32 %r2346, %r136, %r2346, %r2196; + ld.shared.b32 %r2197, [%r2333+40]; + mul.f32 %r2198, %r137, %r2197; + fma.rn.f32 %r2347, %r136, %r2347, %r2198; + ld.shared.b32 %r2199, [%r2333+44]; + mul.f32 %r2200, %r137, %r2199; + fma.rn.f32 %r2348, %r136, %r2348, %r2200; + ld.shared.b32 %r2201, [%r2333+48]; + mul.f32 %r2202, %r137, %r2201; + fma.rn.f32 %r2349, %r136, %r2349, %r2202; + ld.shared.b32 %r2203, [%r2333+52]; + mul.f32 %r2204, %r137, %r2203; + fma.rn.f32 %r2350, %r136, %r2350, %r2204; + ld.shared.b32 %r2205, [%r2333+56]; + mul.f32 %r2206, %r137, %r2205; + fma.rn.f32 %r2351, %r136, %r2351, %r2206; + ld.shared.b32 %r2207, [%r2333+60]; + mul.f32 %r2208, %r137, %r2207; + fma.rn.f32 %r2352, %r136, %r2352, %r2208; + ld.shared.b32 %r2209, [%r2333+64]; + mul.f32 %r2210, %r137, %r2209; + fma.rn.f32 %r2353, %r136, %r2353, %r2210; + ld.shared.b32 %r2211, [%r2333+68]; + mul.f32 %r2212, %r137, %r2211; + fma.rn.f32 %r2354, %r136, %r2354, %r2212; + ld.shared.b32 %r2213, [%r2333+72]; + mul.f32 %r2214, %r137, %r2213; + fma.rn.f32 %r2355, %r136, %r2355, %r2214; + ld.shared.b32 %r2215, [%r2333+76]; + mul.f32 %r2216, %r137, %r2215; + fma.rn.f32 %r2356, %r136, %r2356, %r2216; + ld.shared.b32 %r2217, [%r2333+80]; + mul.f32 %r2218, %r137, %r2217; + fma.rn.f32 %r2357, %r136, %r2357, %r2218; + ld.shared.b32 %r2219, [%r2333+84]; + mul.f32 %r2220, %r137, %r2219; + fma.rn.f32 %r2358, %r136, %r2358, %r2220; + ld.shared.b32 %r2221, [%r2333+88]; + mul.f32 %r2222, %r137, %r2221; + fma.rn.f32 %r2359, %r136, %r2359, %r2222; + ld.shared.b32 %r2223, [%r2333+92]; + mul.f32 %r2224, %r137, %r2223; + fma.rn.f32 %r2360, %r136, %r2360, %r2224; + ld.shared.b32 %r2225, [%r2333+96]; + mul.f32 %r2226, %r137, %r2225; + fma.rn.f32 %r2361, %r136, %r2361, %r2226; + ld.shared.b32 %r2227, [%r2333+100]; + mul.f32 %r2228, %r137, %r2227; + fma.rn.f32 %r2362, %r136, %r2362, %r2228; + ld.shared.b32 %r2229, [%r2333+104]; + mul.f32 %r2230, %r137, %r2229; + fma.rn.f32 %r2363, %r136, %r2363, %r2230; + ld.shared.b32 %r2231, [%r2333+108]; + mul.f32 %r2232, %r137, %r2231; + fma.rn.f32 %r2364, %r136, %r2364, %r2232; + ld.shared.b32 %r2233, [%r2333+112]; + mul.f32 %r2234, %r137, %r2233; + fma.rn.f32 %r2365, %r136, %r2365, %r2234; + ld.shared.b32 %r2235, [%r2333+116]; + mul.f32 %r2236, %r137, %r2235; + fma.rn.f32 %r2366, %r136, %r2366, %r2236; + ld.shared.b32 %r2237, [%r2333+120]; + mul.f32 %r2238, %r137, %r2237; + fma.rn.f32 %r2367, %r136, %r2367, %r2238; + ld.shared.b32 %r2239, [%r2333+124]; + mul.f32 %r2240, %r137, %r2239; + fma.rn.f32 %r2368, %r136, %r2368, %r2240; + bra.uni $L__BB0_203; +$L__BB0_198: + setp.ne.b32 %p203, %r132, 0; + ld.shared.b32 %r2011, [%r2333]; + mul.f32 %r2012, %r137, %r2011; + fma.rn.f32 %r2337, %r136, %r2337, %r2012; + ld.shared.b32 %r2013, [%r2333+-4096]; + fma.rn.f32 %r2014, %r2337, %r2013, 0f00000000; + ld.shared.b32 %r2015, [%r2333+4]; + mul.f32 %r2016, %r137, %r2015; + fma.rn.f32 %r2338, %r136, %r2338, %r2016; + ld.shared.b32 %r2017, [%r2333+-4092]; + fma.rn.f32 %r2018, %r2338, %r2017, %r2014; + ld.shared.b32 %r2019, [%r2333+8]; + mul.f32 %r2020, %r137, %r2019; + fma.rn.f32 %r2339, %r136, %r2339, %r2020; + ld.shared.b32 %r2021, [%r2333+-4088]; + fma.rn.f32 %r2022, %r2339, %r2021, %r2018; + ld.shared.b32 %r2023, [%r2333+12]; + mul.f32 %r2024, %r137, %r2023; + fma.rn.f32 %r2340, %r136, %r2340, %r2024; + ld.shared.b32 %r2025, [%r2333+-4084]; + fma.rn.f32 %r2026, %r2340, %r2025, %r2022; + ld.shared.b32 %r2027, [%r2333+16]; + mul.f32 %r2028, %r137, %r2027; + fma.rn.f32 %r2341, %r136, %r2341, %r2028; + ld.shared.b32 %r2029, [%r2333+-4080]; + fma.rn.f32 %r2030, %r2341, %r2029, %r2026; + ld.shared.b32 %r2031, [%r2333+20]; + mul.f32 %r2032, %r137, %r2031; + fma.rn.f32 %r2342, %r136, %r2342, %r2032; + ld.shared.b32 %r2033, [%r2333+-4076]; + fma.rn.f32 %r2034, %r2342, %r2033, %r2030; + ld.shared.b32 %r2035, [%r2333+24]; + mul.f32 %r2036, %r137, %r2035; + fma.rn.f32 %r2343, %r136, %r2343, %r2036; + ld.shared.b32 %r2037, [%r2333+-4072]; + fma.rn.f32 %r2038, %r2343, %r2037, %r2034; + ld.shared.b32 %r2039, [%r2333+28]; + mul.f32 %r2040, %r137, %r2039; + fma.rn.f32 %r2344, %r136, %r2344, %r2040; + ld.shared.b32 %r2041, [%r2333+-4068]; + fma.rn.f32 %r2042, %r2344, %r2041, %r2038; + ld.shared.b32 %r2043, [%r2333+32]; + mul.f32 %r2044, %r137, %r2043; + fma.rn.f32 %r2345, %r136, %r2345, %r2044; + ld.shared.b32 %r2045, [%r2333+-4064]; + fma.rn.f32 %r2046, %r2345, %r2045, %r2042; + ld.shared.b32 %r2047, [%r2333+36]; + mul.f32 %r2048, %r137, %r2047; + fma.rn.f32 %r2346, %r136, %r2346, %r2048; + ld.shared.b32 %r2049, [%r2333+-4060]; + fma.rn.f32 %r2050, %r2346, %r2049, %r2046; + ld.shared.b32 %r2051, [%r2333+40]; + mul.f32 %r2052, %r137, %r2051; + fma.rn.f32 %r2347, %r136, %r2347, %r2052; + ld.shared.b32 %r2053, [%r2333+-4056]; + fma.rn.f32 %r2054, %r2347, %r2053, %r2050; + ld.shared.b32 %r2055, [%r2333+44]; + mul.f32 %r2056, %r137, %r2055; + fma.rn.f32 %r2348, %r136, %r2348, %r2056; + ld.shared.b32 %r2057, [%r2333+-4052]; + fma.rn.f32 %r2058, %r2348, %r2057, %r2054; + ld.shared.b32 %r2059, [%r2333+48]; + mul.f32 %r2060, %r137, %r2059; + fma.rn.f32 %r2349, %r136, %r2349, %r2060; + ld.shared.b32 %r2061, [%r2333+-4048]; + fma.rn.f32 %r2062, %r2349, %r2061, %r2058; + ld.shared.b32 %r2063, [%r2333+52]; + mul.f32 %r2064, %r137, %r2063; + fma.rn.f32 %r2350, %r136, %r2350, %r2064; + ld.shared.b32 %r2065, [%r2333+-4044]; + fma.rn.f32 %r2066, %r2350, %r2065, %r2062; + ld.shared.b32 %r2067, [%r2333+56]; + mul.f32 %r2068, %r137, %r2067; + fma.rn.f32 %r2351, %r136, %r2351, %r2068; + ld.shared.b32 %r2069, [%r2333+-4040]; + fma.rn.f32 %r2070, %r2351, %r2069, %r2066; + ld.shared.b32 %r2071, [%r2333+60]; + mul.f32 %r2072, %r137, %r2071; + fma.rn.f32 %r2352, %r136, %r2352, %r2072; + ld.shared.b32 %r2073, [%r2333+-4036]; + fma.rn.f32 %r2074, %r2352, %r2073, %r2070; + ld.shared.b32 %r2075, [%r2333+64]; + mul.f32 %r2076, %r137, %r2075; + fma.rn.f32 %r2353, %r136, %r2353, %r2076; + ld.shared.b32 %r2077, [%r2333+-4032]; + fma.rn.f32 %r2078, %r2353, %r2077, %r2074; + ld.shared.b32 %r2079, [%r2333+68]; + mul.f32 %r2080, %r137, %r2079; + fma.rn.f32 %r2354, %r136, %r2354, %r2080; + ld.shared.b32 %r2081, [%r2333+-4028]; + fma.rn.f32 %r2082, %r2354, %r2081, %r2078; + ld.shared.b32 %r2083, [%r2333+72]; + mul.f32 %r2084, %r137, %r2083; + fma.rn.f32 %r2355, %r136, %r2355, %r2084; + ld.shared.b32 %r2085, [%r2333+-4024]; + fma.rn.f32 %r2086, %r2355, %r2085, %r2082; + ld.shared.b32 %r2087, [%r2333+76]; + mul.f32 %r2088, %r137, %r2087; + fma.rn.f32 %r2356, %r136, %r2356, %r2088; + ld.shared.b32 %r2089, [%r2333+-4020]; + fma.rn.f32 %r2090, %r2356, %r2089, %r2086; + ld.shared.b32 %r2091, [%r2333+80]; + mul.f32 %r2092, %r137, %r2091; + fma.rn.f32 %r2357, %r136, %r2357, %r2092; + ld.shared.b32 %r2093, [%r2333+-4016]; + fma.rn.f32 %r2094, %r2357, %r2093, %r2090; + ld.shared.b32 %r2095, [%r2333+84]; + mul.f32 %r2096, %r137, %r2095; + fma.rn.f32 %r2358, %r136, %r2358, %r2096; + ld.shared.b32 %r2097, [%r2333+-4012]; + fma.rn.f32 %r2098, %r2358, %r2097, %r2094; + ld.shared.b32 %r2099, [%r2333+88]; + mul.f32 %r2100, %r137, %r2099; + fma.rn.f32 %r2359, %r136, %r2359, %r2100; + ld.shared.b32 %r2101, [%r2333+-4008]; + fma.rn.f32 %r2102, %r2359, %r2101, %r2098; + ld.shared.b32 %r2103, [%r2333+92]; + mul.f32 %r2104, %r137, %r2103; + fma.rn.f32 %r2360, %r136, %r2360, %r2104; + ld.shared.b32 %r2105, [%r2333+-4004]; + fma.rn.f32 %r2106, %r2360, %r2105, %r2102; + ld.shared.b32 %r2107, [%r2333+96]; + mul.f32 %r2108, %r137, %r2107; + fma.rn.f32 %r2361, %r136, %r2361, %r2108; + ld.shared.b32 %r2109, [%r2333+-4000]; + fma.rn.f32 %r2110, %r2361, %r2109, %r2106; + ld.shared.b32 %r2111, [%r2333+100]; + mul.f32 %r2112, %r137, %r2111; + fma.rn.f32 %r2362, %r136, %r2362, %r2112; + ld.shared.b32 %r2113, [%r2333+-3996]; + fma.rn.f32 %r2114, %r2362, %r2113, %r2110; + ld.shared.b32 %r2115, [%r2333+104]; + mul.f32 %r2116, %r137, %r2115; + fma.rn.f32 %r2363, %r136, %r2363, %r2116; + ld.shared.b32 %r2117, [%r2333+-3992]; + fma.rn.f32 %r2118, %r2363, %r2117, %r2114; + ld.shared.b32 %r2119, [%r2333+108]; + mul.f32 %r2120, %r137, %r2119; + fma.rn.f32 %r2364, %r136, %r2364, %r2120; + ld.shared.b32 %r2121, [%r2333+-3988]; + fma.rn.f32 %r2122, %r2364, %r2121, %r2118; + ld.shared.b32 %r2123, [%r2333+112]; + mul.f32 %r2124, %r137, %r2123; + fma.rn.f32 %r2365, %r136, %r2365, %r2124; + ld.shared.b32 %r2125, [%r2333+-3984]; + fma.rn.f32 %r2126, %r2365, %r2125, %r2122; + ld.shared.b32 %r2127, [%r2333+116]; + mul.f32 %r2128, %r137, %r2127; + fma.rn.f32 %r2366, %r136, %r2366, %r2128; + ld.shared.b32 %r2129, [%r2333+-3980]; + fma.rn.f32 %r2130, %r2366, %r2129, %r2126; + ld.shared.b32 %r2131, [%r2333+120]; + mul.f32 %r2132, %r137, %r2131; + fma.rn.f32 %r2367, %r136, %r2367, %r2132; + ld.shared.b32 %r2133, [%r2333+-3976]; + fma.rn.f32 %r2134, %r2367, %r2133, %r2130; + ld.shared.b32 %r2135, [%r2333+124]; + mul.f32 %r2136, %r137, %r2135; + fma.rn.f32 %r2368, %r136, %r2368, %r2136; + ld.shared.b32 %r2137, [%r2333+-3972]; + fma.rn.f32 %r2138, %r2368, %r2137, %r2134; + st.shared.b32 [%r134+16384], %r2138; + bar.sync 0; + mov.b32 %r2370, 0f00000000; + @%p203 bra $L__BB0_201; + and.b32 %r2139, %r131, 31; + setp.ne.b32 %p204, %r2139, 0; + ld.shared.b32 %r2140, [%r133+16384]; + ld.shared.b32 %r2141, [%r133+16896]; + add.f32 %r2142, %r2140, %r2141; + ld.shared.b32 %r2143, [%r133+17408]; + add.f32 %r2144, %r2142, %r2143; + ld.shared.b32 %r2145, [%r133+17920]; + add.f32 %r2146, %r2144, %r2145; + mov.b32 %r2147, 0f43000000; + rsqrt.approx.f32 %r2148, %r2147; + mul.f32 %r2370, %r2146, %r2148; + mul.f32 %r2149, %r2370, %r2370; + shfl.sync.bfly.b32 %r2150|%p205, %r2149, 16, 31, -1; + add.f32 %r2151, %r2149, %r2150; + shfl.sync.bfly.b32 %r2152|%p206, %r2151, 8, 31, -1; + add.f32 %r2153, %r2151, %r2152; + shfl.sync.bfly.b32 %r2154|%p207, %r2153, 4, 31, -1; + add.f32 %r2155, %r2153, %r2154; + shfl.sync.bfly.b32 %r2156|%p208, %r2155, 2, 31, -1; + add.f32 %r2157, %r2155, %r2156; + shfl.sync.bfly.b32 %r2158|%p209, %r2157, 1, 31, -1; + add.f32 %r138, %r2157, %r2158; + @%p204 bra $L__BB0_201; + st.shared.b32 [%r135+18560], %r138; +$L__BB0_201: + bar.sync 0; + @%p203 bra $L__BB0_203; + ld.shared.b32 %r2159, [_ZZ28leleka_verify_gdn_fused_stepE2sh+18560]; + ld.shared.b32 %r2160, [_ZZ28leleka_verify_gdn_fused_stepE2sh+18564]; + add.f32 %r2161, %r2159, %r2160; + ld.shared.b32 %r2162, [_ZZ28leleka_verify_gdn_fused_stepE2sh+18568]; + add.f32 %r2163, %r2161, %r2162; + ld.shared.b32 %r2164, [_ZZ28leleka_verify_gdn_fused_stepE2sh+18572]; + add.f32 %r2165, %r2163, %r2164; + fma.rn.f32 %r2166, %r2165, 0f3C000000, %r6; + rsqrt.approx.f32 %r2167, %r2166; + ld.global.b32 %r2168, [%rd275]; + mul.f32 %r2169, %r2370, %r2167; + ld.global.b32 %r2170, [%rd8]; + mul.f32 %r2171, %r2169, %r2170; + mul.f32 %r2172, %r2168, 0fBFB8AA3B; + ex2.approx.f32 %r2173, %r2172; + add.f32 %r2174, %r2173, 0f3F800000; + rcp.rn.f32 %r2175, %r2174; + mul.f32 %r2176, %r2171, %r2175; + st.global.b32 [%rd274], %r2176; +$L__BB0_203: + add.s32 %r2369, %r2369, 1; + add.s32 %r2336, %r2336, 1; + setp.ne.b32 %p210, %r2336, 0; + add.s64 %rd275, %rd275, 24576; + add.s64 %rd274, %rd274, 24576; + add.s32 %r2335, %r2335, 4; + add.s32 %r2334, %r2334, 512; + add.s32 %r2333, %r2333, 512; + @%p210 bra $L__BB0_196; +$L__BB0_204: + ret; + +} + // .globl leleka_gdn_ab_unrolled_t1 +.visible .entry leleka_gdn_ab_unrolled_t1( + .param .u64 .ptr .align 1 leleka_gdn_ab_unrolled_t1_param_0, + .param .u64 .ptr .align 1 leleka_gdn_ab_unrolled_t1_param_1, + .param .u64 .ptr .align 1 leleka_gdn_ab_unrolled_t1_param_2, + .param .u64 .ptr .align 1 leleka_gdn_ab_unrolled_t1_param_3, + .param .u64 .ptr .align 1 leleka_gdn_ab_unrolled_t1_param_4, + .param .u64 .ptr .align 1 leleka_gdn_ab_unrolled_t1_param_5, + .param .u64 .ptr .align 1 leleka_gdn_ab_unrolled_t1_param_6, + .param .u32 leleka_gdn_ab_unrolled_t1_param_7, + .param .u32 leleka_gdn_ab_unrolled_t1_param_8, + .param .u32 leleka_gdn_ab_unrolled_t1_param_9 +) +.maxntid 64 +{ + .reg .pred %p<14>; + .reg .b32 %r<336>; + .reg .b64 %rd<51>; + + ld.param.b64 %rd2, [leleka_gdn_ab_unrolled_t1_param_0]; + ld.param.b64 %rd3, [leleka_gdn_ab_unrolled_t1_param_1]; + ld.param.b64 %rd4, [leleka_gdn_ab_unrolled_t1_param_2]; + ld.param.b64 %rd5, [leleka_gdn_ab_unrolled_t1_param_3]; + ld.param.b64 %rd6, [leleka_gdn_ab_unrolled_t1_param_4]; + ld.param.b64 %rd50, [leleka_gdn_ab_unrolled_t1_param_5]; + ld.param.b64 %rd7, [leleka_gdn_ab_unrolled_t1_param_6]; + ld.param.b32 %r7, [leleka_gdn_ab_unrolled_t1_param_8]; + mov.u32 %r8, %ctaid.x; + mov.u32 %r9, %ntid.x; + shr.u32 %r10, %r9, 5; + mov.u32 %r1, %tid.x; + shr.u32 %r11, %r1, 5; + mad.lo.s32 %r2, %r10, %r8, %r11; + shl.b32 %r12, %r7, 1; + setp.ge.s32 %p1, %r2, %r12; + @%p1 bra $L__BB1_9; + and.b32 %r133, %r1, 31; + setp.lt.s32 %p2, %r2, %r7; + selp.b32 %r134, 0, %r7, %p2; + sub.s32 %r3, %r2, %r134; + selp.b64 %rd38, %rd3, %rd4, %p2; + mul.wide.s32 %rd39, %r3, 5120; + add.s64 %rd40, %rd38, %rd39; + shl.b32 %r135, %r1, 4; + cvt.u64.u32 %rd41, %r135; + and.b64 %rd42, %rd41, 496; + add.s64 %rd8, %rd40, %rd42; + // begin inline asm + ld.global.nc.v4.u32 {%r13,%r14,%r15,%r16}, [%rd8]; + // end inline asm + shl.b32 %r136, %r1, 3; + and.b32 %r137, %r136, 248; + mul.wide.u32 %rd43, %r137, 4; + add.s64 %rd9, %rd2, %rd43; + // begin inline asm + ld.global.nc.v4.f32 {%r17,%r18,%r19,%r20}, [%rd9]; + // end inline asm + add.s64 %rd10, %rd9, 16; + // begin inline asm + ld.global.nc.v4.f32 {%r21,%r22,%r23,%r24}, [%rd10]; + // end inline asm + shl.b32 %r138, %r13, 16; + fma.rn.f32 %r139, %r138, %r17, 0f00000000; + and.b32 %r140, %r13, -65536; + fma.rn.f32 %r141, %r140, %r18, %r139; + shl.b32 %r142, %r14, 16; + fma.rn.f32 %r143, %r142, %r19, %r141; + and.b32 %r144, %r14, -65536; + fma.rn.f32 %r145, %r144, %r20, %r143; + shl.b32 %r146, %r15, 16; + fma.rn.f32 %r147, %r146, %r21, %r145; + and.b32 %r148, %r15, -65536; + fma.rn.f32 %r149, %r148, %r22, %r147; + shl.b32 %r150, %r16, 16; + fma.rn.f32 %r151, %r150, %r23, %r149; + and.b32 %r152, %r16, -65536; + fma.rn.f32 %r153, %r152, %r24, %r151; + add.s64 %rd11, %rd8, 512; + // begin inline asm + ld.global.nc.v4.u32 {%r25,%r26,%r27,%r28}, [%rd11]; + // end inline asm + add.s64 %rd12, %rd9, 1024; + // begin inline asm + ld.global.nc.v4.f32 {%r29,%r30,%r31,%r32}, [%rd12]; + // end inline asm + add.s64 %rd13, %rd9, 1040; + // begin inline asm + ld.global.nc.v4.f32 {%r33,%r34,%r35,%r36}, [%rd13]; + // end inline asm + shl.b32 %r154, %r25, 16; + fma.rn.f32 %r155, %r154, %r29, %r153; + and.b32 %r156, %r25, -65536; + fma.rn.f32 %r157, %r156, %r30, %r155; + shl.b32 %r158, %r26, 16; + fma.rn.f32 %r159, %r158, %r31, %r157; + and.b32 %r160, %r26, -65536; + fma.rn.f32 %r161, %r160, %r32, %r159; + shl.b32 %r162, %r27, 16; + fma.rn.f32 %r163, %r162, %r33, %r161; + and.b32 %r164, %r27, -65536; + fma.rn.f32 %r165, %r164, %r34, %r163; + shl.b32 %r166, %r28, 16; + fma.rn.f32 %r167, %r166, %r35, %r165; + and.b32 %r168, %r28, -65536; + fma.rn.f32 %r169, %r168, %r36, %r167; + add.s64 %rd14, %rd8, 1024; + // begin inline asm + ld.global.nc.v4.u32 {%r37,%r38,%r39,%r40}, [%rd14]; + // end inline asm + add.s64 %rd15, %rd9, 2048; + // begin inline asm + ld.global.nc.v4.f32 {%r41,%r42,%r43,%r44}, [%rd15]; + // end inline asm + add.s64 %rd16, %rd9, 2064; + // begin inline asm + ld.global.nc.v4.f32 {%r45,%r46,%r47,%r48}, [%rd16]; + // end inline asm + shl.b32 %r170, %r37, 16; + fma.rn.f32 %r171, %r170, %r41, %r169; + and.b32 %r172, %r37, -65536; + fma.rn.f32 %r173, %r172, %r42, %r171; + shl.b32 %r174, %r38, 16; + fma.rn.f32 %r175, %r174, %r43, %r173; + and.b32 %r176, %r38, -65536; + fma.rn.f32 %r177, %r176, %r44, %r175; + shl.b32 %r178, %r39, 16; + fma.rn.f32 %r179, %r178, %r45, %r177; + and.b32 %r180, %r39, -65536; + fma.rn.f32 %r181, %r180, %r46, %r179; + shl.b32 %r182, %r40, 16; + fma.rn.f32 %r183, %r182, %r47, %r181; + and.b32 %r184, %r40, -65536; + fma.rn.f32 %r185, %r184, %r48, %r183; + add.s64 %rd17, %rd8, 1536; + // begin inline asm + ld.global.nc.v4.u32 {%r49,%r50,%r51,%r52}, [%rd17]; + // end inline asm + add.s64 %rd18, %rd9, 3072; + // begin inline asm + ld.global.nc.v4.f32 {%r53,%r54,%r55,%r56}, [%rd18]; + // end inline asm + add.s64 %rd19, %rd9, 3088; + // begin inline asm + ld.global.nc.v4.f32 {%r57,%r58,%r59,%r60}, [%rd19]; + // end inline asm + shl.b32 %r186, %r49, 16; + fma.rn.f32 %r187, %r186, %r53, %r185; + and.b32 %r188, %r49, -65536; + fma.rn.f32 %r189, %r188, %r54, %r187; + shl.b32 %r190, %r50, 16; + fma.rn.f32 %r191, %r190, %r55, %r189; + and.b32 %r192, %r50, -65536; + fma.rn.f32 %r193, %r192, %r56, %r191; + shl.b32 %r194, %r51, 16; + fma.rn.f32 %r195, %r194, %r57, %r193; + and.b32 %r196, %r51, -65536; + fma.rn.f32 %r197, %r196, %r58, %r195; + shl.b32 %r198, %r52, 16; + fma.rn.f32 %r199, %r198, %r59, %r197; + and.b32 %r200, %r52, -65536; + fma.rn.f32 %r201, %r200, %r60, %r199; + add.s64 %rd20, %rd8, 2048; + // begin inline asm + ld.global.nc.v4.u32 {%r61,%r62,%r63,%r64}, [%rd20]; + // end inline asm + add.s64 %rd21, %rd9, 4096; + // begin inline asm + ld.global.nc.v4.f32 {%r65,%r66,%r67,%r68}, [%rd21]; + // end inline asm + add.s64 %rd22, %rd9, 4112; + // begin inline asm + ld.global.nc.v4.f32 {%r69,%r70,%r71,%r72}, [%rd22]; + // end inline asm + shl.b32 %r202, %r61, 16; + fma.rn.f32 %r203, %r202, %r65, %r201; + and.b32 %r204, %r61, -65536; + fma.rn.f32 %r205, %r204, %r66, %r203; + shl.b32 %r206, %r62, 16; + fma.rn.f32 %r207, %r206, %r67, %r205; + and.b32 %r208, %r62, -65536; + fma.rn.f32 %r209, %r208, %r68, %r207; + shl.b32 %r210, %r63, 16; + fma.rn.f32 %r211, %r210, %r69, %r209; + and.b32 %r212, %r63, -65536; + fma.rn.f32 %r213, %r212, %r70, %r211; + shl.b32 %r214, %r64, 16; + fma.rn.f32 %r215, %r214, %r71, %r213; + and.b32 %r216, %r64, -65536; + fma.rn.f32 %r217, %r216, %r72, %r215; + add.s64 %rd23, %rd8, 2560; + // begin inline asm + ld.global.nc.v4.u32 {%r73,%r74,%r75,%r76}, [%rd23]; + // end inline asm + add.s64 %rd24, %rd9, 5120; + // begin inline asm + ld.global.nc.v4.f32 {%r77,%r78,%r79,%r80}, [%rd24]; + // end inline asm + add.s64 %rd25, %rd9, 5136; + // begin inline asm + ld.global.nc.v4.f32 {%r81,%r82,%r83,%r84}, [%rd25]; + // end inline asm + shl.b32 %r218, %r73, 16; + fma.rn.f32 %r219, %r218, %r77, %r217; + and.b32 %r220, %r73, -65536; + fma.rn.f32 %r221, %r220, %r78, %r219; + shl.b32 %r222, %r74, 16; + fma.rn.f32 %r223, %r222, %r79, %r221; + and.b32 %r224, %r74, -65536; + fma.rn.f32 %r225, %r224, %r80, %r223; + shl.b32 %r226, %r75, 16; + fma.rn.f32 %r227, %r226, %r81, %r225; + and.b32 %r228, %r75, -65536; + fma.rn.f32 %r229, %r228, %r82, %r227; + shl.b32 %r230, %r76, 16; + fma.rn.f32 %r231, %r230, %r83, %r229; + and.b32 %r232, %r76, -65536; + fma.rn.f32 %r233, %r232, %r84, %r231; + add.s64 %rd26, %rd8, 3072; + // begin inline asm + ld.global.nc.v4.u32 {%r85,%r86,%r87,%r88}, [%rd26]; + // end inline asm + add.s64 %rd27, %rd9, 6144; + // begin inline asm + ld.global.nc.v4.f32 {%r89,%r90,%r91,%r92}, [%rd27]; + // end inline asm + add.s64 %rd28, %rd9, 6160; + // begin inline asm + ld.global.nc.v4.f32 {%r93,%r94,%r95,%r96}, [%rd28]; + // end inline asm + shl.b32 %r234, %r85, 16; + fma.rn.f32 %r235, %r234, %r89, %r233; + and.b32 %r236, %r85, -65536; + fma.rn.f32 %r237, %r236, %r90, %r235; + shl.b32 %r238, %r86, 16; + fma.rn.f32 %r239, %r238, %r91, %r237; + and.b32 %r240, %r86, -65536; + fma.rn.f32 %r241, %r240, %r92, %r239; + shl.b32 %r242, %r87, 16; + fma.rn.f32 %r243, %r242, %r93, %r241; + and.b32 %r244, %r87, -65536; + fma.rn.f32 %r245, %r244, %r94, %r243; + shl.b32 %r246, %r88, 16; + fma.rn.f32 %r247, %r246, %r95, %r245; + and.b32 %r248, %r88, -65536; + fma.rn.f32 %r249, %r248, %r96, %r247; + add.s64 %rd29, %rd8, 3584; + // begin inline asm + ld.global.nc.v4.u32 {%r97,%r98,%r99,%r100}, [%rd29]; + // end inline asm + add.s64 %rd30, %rd9, 7168; + // begin inline asm + ld.global.nc.v4.f32 {%r101,%r102,%r103,%r104}, [%rd30]; + // end inline asm + add.s64 %rd31, %rd9, 7184; + // begin inline asm + ld.global.nc.v4.f32 {%r105,%r106,%r107,%r108}, [%rd31]; + // end inline asm + shl.b32 %r250, %r97, 16; + fma.rn.f32 %r251, %r250, %r101, %r249; + and.b32 %r252, %r97, -65536; + fma.rn.f32 %r253, %r252, %r102, %r251; + shl.b32 %r254, %r98, 16; + fma.rn.f32 %r255, %r254, %r103, %r253; + and.b32 %r256, %r98, -65536; + fma.rn.f32 %r257, %r256, %r104, %r255; + shl.b32 %r258, %r99, 16; + fma.rn.f32 %r259, %r258, %r105, %r257; + and.b32 %r260, %r99, -65536; + fma.rn.f32 %r261, %r260, %r106, %r259; + shl.b32 %r262, %r100, 16; + fma.rn.f32 %r263, %r262, %r107, %r261; + and.b32 %r264, %r100, -65536; + fma.rn.f32 %r265, %r264, %r108, %r263; + add.s64 %rd32, %rd8, 4096; + // begin inline asm + ld.global.nc.v4.u32 {%r109,%r110,%r111,%r112}, [%rd32]; + // end inline asm + add.s64 %rd33, %rd9, 8192; + // begin inline asm + ld.global.nc.v4.f32 {%r113,%r114,%r115,%r116}, [%rd33]; + // end inline asm + add.s64 %rd34, %rd9, 8208; + // begin inline asm + ld.global.nc.v4.f32 {%r117,%r118,%r119,%r120}, [%rd34]; + // end inline asm + shl.b32 %r266, %r109, 16; + fma.rn.f32 %r267, %r266, %r113, %r265; + and.b32 %r268, %r109, -65536; + fma.rn.f32 %r269, %r268, %r114, %r267; + shl.b32 %r270, %r110, 16; + fma.rn.f32 %r271, %r270, %r115, %r269; + and.b32 %r272, %r110, -65536; + fma.rn.f32 %r273, %r272, %r116, %r271; + shl.b32 %r274, %r111, 16; + fma.rn.f32 %r275, %r274, %r117, %r273; + and.b32 %r276, %r111, -65536; + fma.rn.f32 %r277, %r276, %r118, %r275; + shl.b32 %r278, %r112, 16; + fma.rn.f32 %r279, %r278, %r119, %r277; + and.b32 %r280, %r112, -65536; + fma.rn.f32 %r281, %r280, %r120, %r279; + add.s64 %rd35, %rd8, 4608; + // begin inline asm + ld.global.nc.v4.u32 {%r121,%r122,%r123,%r124}, [%rd35]; + // end inline asm + add.s64 %rd36, %rd9, 9216; + // begin inline asm + ld.global.nc.v4.f32 {%r125,%r126,%r127,%r128}, [%rd36]; + // end inline asm + add.s64 %rd37, %rd9, 9232; + // begin inline asm + ld.global.nc.v4.f32 {%r129,%r130,%r131,%r132}, [%rd37]; + // end inline asm + shl.b32 %r282, %r121, 16; + fma.rn.f32 %r283, %r282, %r125, %r281; + and.b32 %r284, %r121, -65536; + fma.rn.f32 %r285, %r284, %r126, %r283; + shl.b32 %r286, %r122, 16; + fma.rn.f32 %r287, %r286, %r127, %r285; + and.b32 %r288, %r122, -65536; + fma.rn.f32 %r289, %r288, %r128, %r287; + shl.b32 %r290, %r123, 16; + fma.rn.f32 %r291, %r290, %r129, %r289; + and.b32 %r292, %r123, -65536; + fma.rn.f32 %r293, %r292, %r130, %r291; + shl.b32 %r294, %r124, 16; + fma.rn.f32 %r295, %r294, %r131, %r293; + and.b32 %r296, %r124, -65536; + fma.rn.f32 %r297, %r296, %r132, %r295; + shfl.sync.bfly.b32 %r298|%p3, %r297, 16, 31, -1; + add.f32 %r299, %r297, %r298; + shfl.sync.bfly.b32 %r300|%p4, %r299, 8, 31, -1; + add.f32 %r301, %r299, %r300; + shfl.sync.bfly.b32 %r302|%p5, %r301, 4, 31, -1; + add.f32 %r303, %r301, %r302; + shfl.sync.bfly.b32 %r304|%p6, %r303, 2, 31, -1; + add.f32 %r305, %r303, %r304; + shfl.sync.bfly.b32 %r306|%p7, %r305, 1, 31, -1; + add.f32 %r4, %r305, %r306; + setp.ne.b32 %p8, %r133, 0; + @%p8 bra $L__BB1_9; + setp.lt.s32 %p9, %r2, %r7; + cvta.to.global.u64 %rd44, %rd5; + mul.wide.s32 %rd45, %r3, 4; + add.s64 %rd1, %rd44, %rd45; + cvta.to.global.u64 %rd46, %rd6; + add.s64 %rd47, %rd46, %rd45; + ld.global.nc.b32 %r5, [%rd47]; + @%p9 bra $L__BB1_4; + mul.f32 %r307, %r4, 0fBFB8AA3B; + ex2.approx.f32 %r308, %r307; + add.f32 %r309, %r308, 0f3F800000; + rcp.rn.f32 %r335, %r309; + mov.b64 %rd50, %rd7; + bra.uni $L__BB1_8; +$L__BB1_4: + ld.global.nc.b32 %r310, [%rd1]; + add.f32 %r334, %r4, %r310; + setp.gt.f32 %p10, %r334, 0f41A00000; + @%p10 bra $L__BB1_7; + mul.f32 %r311, %r334, 0f3FB8AA3B; + ex2.approx.f32 %r6, %r311; + mov.b32 %r312, 0f3F800000; + add.rz.f32 %r313, %r6, %r312; + add.s32 %r314, %r313, -1061158912; + and.b32 %r315, %r314, -8388608; + sub.s32 %r316, %r6, %r315; + sub.s32 %r317, 1082130432, %r315; + fma.rn.f32 %r318, %r317, 0f3E800000, 0fBF800000; + add.f32 %r319, %r318, %r316; + cvt.rn.f32.s32 %r320, %r315; + mul.f32 %r321, %r320, 0f34000000; + fma.rn.f32 %r322, %r319, 0fBD39BF78, 0f3DD80012; + fma.rn.f32 %r323, %r322, %r319, 0fBE0778E0; + fma.rn.f32 %r324, %r323, %r319, 0f3E146475; + fma.rn.f32 %r325, %r324, %r319, 0fBE2A68DD; + fma.rn.f32 %r326, %r325, %r319, 0f3E4CAF9E; + fma.rn.f32 %r327, %r326, %r319, 0fBE800042; + fma.rn.f32 %r328, %r327, %r319, 0f3EAAAAE6; + fma.rn.f32 %r329, %r328, %r319, 0fBF000000; + mul.f32 %r330, %r319, %r329; + fma.rn.f32 %r331, %r330, %r319, %r319; + fma.rn.f32 %r334, %r321, 0f3F317218, %r331; + setp.lt.u32 %p11, %r6, 2139095040; + @%p11 bra $L__BB1_7; + setp.gt.s32 %p12, %r6, -1082130432; + fma.rn.f32 %r332, %r6, 0f7F800000, 0f7F800000; + selp.f32 %r333, %r332, %r334, %p12; + setp.eq.f32 %p13, %r6, 0f00000000; + selp.f32 %r334, 0f80000000, %r333, %p13; +$L__BB1_7: + mul.f32 %r335, %r5, %r334; +$L__BB1_8: + cvta.to.global.u64 %rd48, %rd50; + add.s64 %rd49, %rd48, %rd45; + st.global.b32 [%rd49], %r335; +$L__BB1_9: + ret; + +} + // .globl leleka_gdn_ab_unrolled_t2 +.visible .entry leleka_gdn_ab_unrolled_t2( + .param .u64 .ptr .align 1 leleka_gdn_ab_unrolled_t2_param_0, + .param .u64 .ptr .align 1 leleka_gdn_ab_unrolled_t2_param_1, + .param .u64 .ptr .align 1 leleka_gdn_ab_unrolled_t2_param_2, + .param .u64 .ptr .align 1 leleka_gdn_ab_unrolled_t2_param_3, + .param .u64 .ptr .align 1 leleka_gdn_ab_unrolled_t2_param_4, + .param .u64 .ptr .align 1 leleka_gdn_ab_unrolled_t2_param_5, + .param .u64 .ptr .align 1 leleka_gdn_ab_unrolled_t2_param_6, + .param .u32 leleka_gdn_ab_unrolled_t2_param_7, + .param .u32 leleka_gdn_ab_unrolled_t2_param_8, + .param .u32 leleka_gdn_ab_unrolled_t2_param_9 +) +.maxntid 64 +{ + .reg .pred %p<25>; + .reg .b32 %r<537>; + .reg .b64 %rd<79>; + + ld.param.b64 %rd4, [leleka_gdn_ab_unrolled_t2_param_3]; + ld.param.b64 %rd78, [leleka_gdn_ab_unrolled_t2_param_5]; + ld.param.b64 %rd5, [leleka_gdn_ab_unrolled_t2_param_6]; + ld.param.b32 %r10, [leleka_gdn_ab_unrolled_t2_param_8]; + mov.u32 %r11, %ctaid.x; + mov.u32 %r12, %ntid.x; + shr.u32 %r13, %r12, 5; + mov.u32 %r1, %tid.x; + shr.u32 %r14, %r1, 5; + mad.lo.s32 %r2, %r13, %r11, %r14; + shl.b32 %r15, %r10, 1; + setp.ge.s32 %p1, %r2, %r15; + @%p1 bra $L__BB2_17; + ld.param.b64 %rd76, [leleka_gdn_ab_unrolled_t2_param_4]; + ld.param.b64 %rd75, [leleka_gdn_ab_unrolled_t2_param_2]; + ld.param.b64 %rd74, [leleka_gdn_ab_unrolled_t2_param_1]; + ld.param.b64 %rd73, [leleka_gdn_ab_unrolled_t2_param_0]; + and.b32 %r3, %r1, 31; + cvta.to.global.u64 %rd56, %rd4; + cvta.to.global.u64 %rd57, %rd76; + setp.lt.s32 %p2, %r2, %r10; + selp.b32 %r216, 0, %r10, %p2; + sub.s32 %r217, %r2, %r216; + selp.b64 %rd58, %rd74, %rd75, %p2; + cvt.s64.s32 %rd1, %r217; + mul.wide.s32 %rd59, %r217, 5120; + add.s64 %rd60, %rd58, %rd59; + shl.b32 %r218, %r1, 4; + cvt.u64.u32 %rd61, %r218; + and.b64 %rd62, %rd61, 496; + add.s64 %rd6, %rd60, %rd62; + // begin inline asm + ld.global.nc.v4.u32 {%r16,%r17,%r18,%r19}, [%rd6]; + // end inline asm + and.b32 %r219, %r19, -65536; + shl.b32 %r220, %r19, 16; + and.b32 %r221, %r18, -65536; + shl.b32 %r222, %r18, 16; + and.b32 %r223, %r17, -65536; + shl.b32 %r224, %r17, 16; + and.b32 %r225, %r16, -65536; + shl.b32 %r226, %r16, 16; + shl.b32 %r227, %r1, 3; + and.b32 %r228, %r227, 248; + mul.wide.u32 %rd63, %r228, 4; + add.s64 %rd7, %rd73, %rd63; + // begin inline asm + ld.global.nc.v4.f32 {%r20,%r21,%r22,%r23}, [%rd7]; + // end inline asm + add.s64 %rd8, %rd7, 16; + // begin inline asm + ld.global.nc.v4.f32 {%r24,%r25,%r26,%r27}, [%rd8]; + // end inline asm + fma.rn.f32 %r229, %r226, %r20, 0f00000000; + fma.rn.f32 %r230, %r225, %r21, %r229; + fma.rn.f32 %r231, %r224, %r22, %r230; + fma.rn.f32 %r232, %r223, %r23, %r231; + fma.rn.f32 %r233, %r222, %r24, %r232; + fma.rn.f32 %r234, %r221, %r25, %r233; + fma.rn.f32 %r235, %r220, %r26, %r234; + fma.rn.f32 %r236, %r219, %r27, %r235; + add.s64 %rd9, %rd7, 10240; + // begin inline asm + ld.global.nc.v4.f32 {%r28,%r29,%r30,%r31}, [%rd9]; + // end inline asm + add.s64 %rd10, %rd7, 10256; + // begin inline asm + ld.global.nc.v4.f32 {%r32,%r33,%r34,%r35}, [%rd10]; + // end inline asm + fma.rn.f32 %r237, %r226, %r28, 0f00000000; + fma.rn.f32 %r238, %r225, %r29, %r237; + fma.rn.f32 %r239, %r224, %r30, %r238; + fma.rn.f32 %r240, %r223, %r31, %r239; + fma.rn.f32 %r241, %r222, %r32, %r240; + fma.rn.f32 %r242, %r221, %r33, %r241; + fma.rn.f32 %r243, %r220, %r34, %r242; + fma.rn.f32 %r244, %r219, %r35, %r243; + add.s64 %rd11, %rd6, 512; + // begin inline asm + ld.global.nc.v4.u32 {%r36,%r37,%r38,%r39}, [%rd11]; + // end inline asm + and.b32 %r245, %r39, -65536; + shl.b32 %r246, %r39, 16; + and.b32 %r247, %r38, -65536; + shl.b32 %r248, %r38, 16; + and.b32 %r249, %r37, -65536; + shl.b32 %r250, %r37, 16; + and.b32 %r251, %r36, -65536; + shl.b32 %r252, %r36, 16; + add.s64 %rd12, %rd7, 1024; + // begin inline asm + ld.global.nc.v4.f32 {%r40,%r41,%r42,%r43}, [%rd12]; + // end inline asm + add.s64 %rd13, %rd7, 1040; + // begin inline asm + ld.global.nc.v4.f32 {%r44,%r45,%r46,%r47}, [%rd13]; + // end inline asm + fma.rn.f32 %r253, %r252, %r40, %r236; + fma.rn.f32 %r254, %r251, %r41, %r253; + fma.rn.f32 %r255, %r250, %r42, %r254; + fma.rn.f32 %r256, %r249, %r43, %r255; + fma.rn.f32 %r257, %r248, %r44, %r256; + fma.rn.f32 %r258, %r247, %r45, %r257; + fma.rn.f32 %r259, %r246, %r46, %r258; + fma.rn.f32 %r260, %r245, %r47, %r259; + add.s64 %rd14, %rd7, 11264; + // begin inline asm + ld.global.nc.v4.f32 {%r48,%r49,%r50,%r51}, [%rd14]; + // end inline asm + add.s64 %rd15, %rd7, 11280; + // begin inline asm + ld.global.nc.v4.f32 {%r52,%r53,%r54,%r55}, [%rd15]; + // end inline asm + fma.rn.f32 %r261, %r252, %r48, %r244; + fma.rn.f32 %r262, %r251, %r49, %r261; + fma.rn.f32 %r263, %r250, %r50, %r262; + fma.rn.f32 %r264, %r249, %r51, %r263; + fma.rn.f32 %r265, %r248, %r52, %r264; + fma.rn.f32 %r266, %r247, %r53, %r265; + fma.rn.f32 %r267, %r246, %r54, %r266; + fma.rn.f32 %r268, %r245, %r55, %r267; + add.s64 %rd16, %rd6, 1024; + // begin inline asm + ld.global.nc.v4.u32 {%r56,%r57,%r58,%r59}, [%rd16]; + // end inline asm + and.b32 %r269, %r59, -65536; + shl.b32 %r270, %r59, 16; + and.b32 %r271, %r58, -65536; + shl.b32 %r272, %r58, 16; + and.b32 %r273, %r57, -65536; + shl.b32 %r274, %r57, 16; + and.b32 %r275, %r56, -65536; + shl.b32 %r276, %r56, 16; + add.s64 %rd17, %rd7, 2048; + // begin inline asm + ld.global.nc.v4.f32 {%r60,%r61,%r62,%r63}, [%rd17]; + // end inline asm + add.s64 %rd18, %rd7, 2064; + // begin inline asm + ld.global.nc.v4.f32 {%r64,%r65,%r66,%r67}, [%rd18]; + // end inline asm + fma.rn.f32 %r277, %r276, %r60, %r260; + fma.rn.f32 %r278, %r275, %r61, %r277; + fma.rn.f32 %r279, %r274, %r62, %r278; + fma.rn.f32 %r280, %r273, %r63, %r279; + fma.rn.f32 %r281, %r272, %r64, %r280; + fma.rn.f32 %r282, %r271, %r65, %r281; + fma.rn.f32 %r283, %r270, %r66, %r282; + fma.rn.f32 %r284, %r269, %r67, %r283; + add.s64 %rd19, %rd7, 12288; + // begin inline asm + ld.global.nc.v4.f32 {%r68,%r69,%r70,%r71}, [%rd19]; + // end inline asm + add.s64 %rd20, %rd7, 12304; + // begin inline asm + ld.global.nc.v4.f32 {%r72,%r73,%r74,%r75}, [%rd20]; + // end inline asm + fma.rn.f32 %r285, %r276, %r68, %r268; + fma.rn.f32 %r286, %r275, %r69, %r285; + fma.rn.f32 %r287, %r274, %r70, %r286; + fma.rn.f32 %r288, %r273, %r71, %r287; + fma.rn.f32 %r289, %r272, %r72, %r288; + fma.rn.f32 %r290, %r271, %r73, %r289; + fma.rn.f32 %r291, %r270, %r74, %r290; + fma.rn.f32 %r292, %r269, %r75, %r291; + add.s64 %rd21, %rd6, 1536; + // begin inline asm + ld.global.nc.v4.u32 {%r76,%r77,%r78,%r79}, [%rd21]; + // end inline asm + and.b32 %r293, %r79, -65536; + shl.b32 %r294, %r79, 16; + and.b32 %r295, %r78, -65536; + shl.b32 %r296, %r78, 16; + and.b32 %r297, %r77, -65536; + shl.b32 %r298, %r77, 16; + and.b32 %r299, %r76, -65536; + shl.b32 %r300, %r76, 16; + add.s64 %rd22, %rd7, 3072; + // begin inline asm + ld.global.nc.v4.f32 {%r80,%r81,%r82,%r83}, [%rd22]; + // end inline asm + add.s64 %rd23, %rd7, 3088; + // begin inline asm + ld.global.nc.v4.f32 {%r84,%r85,%r86,%r87}, [%rd23]; + // end inline asm + fma.rn.f32 %r301, %r300, %r80, %r284; + fma.rn.f32 %r302, %r299, %r81, %r301; + fma.rn.f32 %r303, %r298, %r82, %r302; + fma.rn.f32 %r304, %r297, %r83, %r303; + fma.rn.f32 %r305, %r296, %r84, %r304; + fma.rn.f32 %r306, %r295, %r85, %r305; + fma.rn.f32 %r307, %r294, %r86, %r306; + fma.rn.f32 %r308, %r293, %r87, %r307; + add.s64 %rd24, %rd7, 13312; + // begin inline asm + ld.global.nc.v4.f32 {%r88,%r89,%r90,%r91}, [%rd24]; + // end inline asm + add.s64 %rd25, %rd7, 13328; + // begin inline asm + ld.global.nc.v4.f32 {%r92,%r93,%r94,%r95}, [%rd25]; + // end inline asm + fma.rn.f32 %r309, %r300, %r88, %r292; + fma.rn.f32 %r310, %r299, %r89, %r309; + fma.rn.f32 %r311, %r298, %r90, %r310; + fma.rn.f32 %r312, %r297, %r91, %r311; + fma.rn.f32 %r313, %r296, %r92, %r312; + fma.rn.f32 %r314, %r295, %r93, %r313; + fma.rn.f32 %r315, %r294, %r94, %r314; + fma.rn.f32 %r316, %r293, %r95, %r315; + add.s64 %rd26, %rd6, 2048; + // begin inline asm + ld.global.nc.v4.u32 {%r96,%r97,%r98,%r99}, [%rd26]; + // end inline asm + and.b32 %r317, %r99, -65536; + shl.b32 %r318, %r99, 16; + and.b32 %r319, %r98, -65536; + shl.b32 %r320, %r98, 16; + and.b32 %r321, %r97, -65536; + shl.b32 %r322, %r97, 16; + and.b32 %r323, %r96, -65536; + shl.b32 %r324, %r96, 16; + add.s64 %rd27, %rd7, 4096; + // begin inline asm + ld.global.nc.v4.f32 {%r100,%r101,%r102,%r103}, [%rd27]; + // end inline asm + add.s64 %rd28, %rd7, 4112; + // begin inline asm + ld.global.nc.v4.f32 {%r104,%r105,%r106,%r107}, [%rd28]; + // end inline asm + fma.rn.f32 %r325, %r324, %r100, %r308; + fma.rn.f32 %r326, %r323, %r101, %r325; + fma.rn.f32 %r327, %r322, %r102, %r326; + fma.rn.f32 %r328, %r321, %r103, %r327; + fma.rn.f32 %r329, %r320, %r104, %r328; + fma.rn.f32 %r330, %r319, %r105, %r329; + fma.rn.f32 %r331, %r318, %r106, %r330; + fma.rn.f32 %r332, %r317, %r107, %r331; + add.s64 %rd29, %rd7, 14336; + // begin inline asm + ld.global.nc.v4.f32 {%r108,%r109,%r110,%r111}, [%rd29]; + // end inline asm + add.s64 %rd30, %rd7, 14352; + // begin inline asm + ld.global.nc.v4.f32 {%r112,%r113,%r114,%r115}, [%rd30]; + // end inline asm + fma.rn.f32 %r333, %r324, %r108, %r316; + fma.rn.f32 %r334, %r323, %r109, %r333; + fma.rn.f32 %r335, %r322, %r110, %r334; + fma.rn.f32 %r336, %r321, %r111, %r335; + fma.rn.f32 %r337, %r320, %r112, %r336; + fma.rn.f32 %r338, %r319, %r113, %r337; + fma.rn.f32 %r339, %r318, %r114, %r338; + fma.rn.f32 %r340, %r317, %r115, %r339; + add.s64 %rd31, %rd6, 2560; + // begin inline asm + ld.global.nc.v4.u32 {%r116,%r117,%r118,%r119}, [%rd31]; + // end inline asm + and.b32 %r341, %r119, -65536; + shl.b32 %r342, %r119, 16; + and.b32 %r343, %r118, -65536; + shl.b32 %r344, %r118, 16; + and.b32 %r345, %r117, -65536; + shl.b32 %r346, %r117, 16; + and.b32 %r347, %r116, -65536; + shl.b32 %r348, %r116, 16; + add.s64 %rd32, %rd7, 5120; + // begin inline asm + ld.global.nc.v4.f32 {%r120,%r121,%r122,%r123}, [%rd32]; + // end inline asm + add.s64 %rd33, %rd7, 5136; + // begin inline asm + ld.global.nc.v4.f32 {%r124,%r125,%r126,%r127}, [%rd33]; + // end inline asm + fma.rn.f32 %r349, %r348, %r120, %r332; + fma.rn.f32 %r350, %r347, %r121, %r349; + fma.rn.f32 %r351, %r346, %r122, %r350; + fma.rn.f32 %r352, %r345, %r123, %r351; + fma.rn.f32 %r353, %r344, %r124, %r352; + fma.rn.f32 %r354, %r343, %r125, %r353; + fma.rn.f32 %r355, %r342, %r126, %r354; + fma.rn.f32 %r356, %r341, %r127, %r355; + add.s64 %rd34, %rd7, 15360; + // begin inline asm + ld.global.nc.v4.f32 {%r128,%r129,%r130,%r131}, [%rd34]; + // end inline asm + add.s64 %rd35, %rd7, 15376; + // begin inline asm + ld.global.nc.v4.f32 {%r132,%r133,%r134,%r135}, [%rd35]; + // end inline asm + fma.rn.f32 %r357, %r348, %r128, %r340; + fma.rn.f32 %r358, %r347, %r129, %r357; + fma.rn.f32 %r359, %r346, %r130, %r358; + fma.rn.f32 %r360, %r345, %r131, %r359; + fma.rn.f32 %r361, %r344, %r132, %r360; + fma.rn.f32 %r362, %r343, %r133, %r361; + fma.rn.f32 %r363, %r342, %r134, %r362; + fma.rn.f32 %r364, %r341, %r135, %r363; + add.s64 %rd36, %rd6, 3072; + // begin inline asm + ld.global.nc.v4.u32 {%r136,%r137,%r138,%r139}, [%rd36]; + // end inline asm + and.b32 %r365, %r139, -65536; + shl.b32 %r366, %r139, 16; + and.b32 %r367, %r138, -65536; + shl.b32 %r368, %r138, 16; + and.b32 %r369, %r137, -65536; + shl.b32 %r370, %r137, 16; + and.b32 %r371, %r136, -65536; + shl.b32 %r372, %r136, 16; + add.s64 %rd37, %rd7, 6144; + // begin inline asm + ld.global.nc.v4.f32 {%r140,%r141,%r142,%r143}, [%rd37]; + // end inline asm + add.s64 %rd38, %rd7, 6160; + // begin inline asm + ld.global.nc.v4.f32 {%r144,%r145,%r146,%r147}, [%rd38]; + // end inline asm + fma.rn.f32 %r373, %r372, %r140, %r356; + fma.rn.f32 %r374, %r371, %r141, %r373; + fma.rn.f32 %r375, %r370, %r142, %r374; + fma.rn.f32 %r376, %r369, %r143, %r375; + fma.rn.f32 %r377, %r368, %r144, %r376; + fma.rn.f32 %r378, %r367, %r145, %r377; + fma.rn.f32 %r379, %r366, %r146, %r378; + fma.rn.f32 %r380, %r365, %r147, %r379; + add.s64 %rd39, %rd7, 16384; + // begin inline asm + ld.global.nc.v4.f32 {%r148,%r149,%r150,%r151}, [%rd39]; + // end inline asm + add.s64 %rd40, %rd7, 16400; + // begin inline asm + ld.global.nc.v4.f32 {%r152,%r153,%r154,%r155}, [%rd40]; + // end inline asm + fma.rn.f32 %r381, %r372, %r148, %r364; + fma.rn.f32 %r382, %r371, %r149, %r381; + fma.rn.f32 %r383, %r370, %r150, %r382; + fma.rn.f32 %r384, %r369, %r151, %r383; + fma.rn.f32 %r385, %r368, %r152, %r384; + fma.rn.f32 %r386, %r367, %r153, %r385; + fma.rn.f32 %r387, %r366, %r154, %r386; + fma.rn.f32 %r388, %r365, %r155, %r387; + add.s64 %rd41, %rd6, 3584; + // begin inline asm + ld.global.nc.v4.u32 {%r156,%r157,%r158,%r159}, [%rd41]; + // end inline asm + and.b32 %r389, %r159, -65536; + shl.b32 %r390, %r159, 16; + and.b32 %r391, %r158, -65536; + shl.b32 %r392, %r158, 16; + and.b32 %r393, %r157, -65536; + shl.b32 %r394, %r157, 16; + and.b32 %r395, %r156, -65536; + shl.b32 %r396, %r156, 16; + add.s64 %rd42, %rd7, 7168; + // begin inline asm + ld.global.nc.v4.f32 {%r160,%r161,%r162,%r163}, [%rd42]; + // end inline asm + add.s64 %rd43, %rd7, 7184; + // begin inline asm + ld.global.nc.v4.f32 {%r164,%r165,%r166,%r167}, [%rd43]; + // end inline asm + fma.rn.f32 %r397, %r396, %r160, %r380; + fma.rn.f32 %r398, %r395, %r161, %r397; + fma.rn.f32 %r399, %r394, %r162, %r398; + fma.rn.f32 %r400, %r393, %r163, %r399; + fma.rn.f32 %r401, %r392, %r164, %r400; + fma.rn.f32 %r402, %r391, %r165, %r401; + fma.rn.f32 %r403, %r390, %r166, %r402; + fma.rn.f32 %r404, %r389, %r167, %r403; + add.s64 %rd44, %rd7, 17408; + // begin inline asm + ld.global.nc.v4.f32 {%r168,%r169,%r170,%r171}, [%rd44]; + // end inline asm + add.s64 %rd45, %rd7, 17424; + // begin inline asm + ld.global.nc.v4.f32 {%r172,%r173,%r174,%r175}, [%rd45]; + // end inline asm + fma.rn.f32 %r405, %r396, %r168, %r388; + fma.rn.f32 %r406, %r395, %r169, %r405; + fma.rn.f32 %r407, %r394, %r170, %r406; + fma.rn.f32 %r408, %r393, %r171, %r407; + fma.rn.f32 %r409, %r392, %r172, %r408; + fma.rn.f32 %r410, %r391, %r173, %r409; + fma.rn.f32 %r411, %r390, %r174, %r410; + fma.rn.f32 %r412, %r389, %r175, %r411; + add.s64 %rd46, %rd6, 4096; + // begin inline asm + ld.global.nc.v4.u32 {%r176,%r177,%r178,%r179}, [%rd46]; + // end inline asm + and.b32 %r413, %r179, -65536; + shl.b32 %r414, %r179, 16; + and.b32 %r415, %r178, -65536; + shl.b32 %r416, %r178, 16; + and.b32 %r417, %r177, -65536; + shl.b32 %r418, %r177, 16; + and.b32 %r419, %r176, -65536; + shl.b32 %r420, %r176, 16; + add.s64 %rd47, %rd7, 8192; + // begin inline asm + ld.global.nc.v4.f32 {%r180,%r181,%r182,%r183}, [%rd47]; + // end inline asm + add.s64 %rd48, %rd7, 8208; + // begin inline asm + ld.global.nc.v4.f32 {%r184,%r185,%r186,%r187}, [%rd48]; + // end inline asm + fma.rn.f32 %r421, %r420, %r180, %r404; + fma.rn.f32 %r422, %r419, %r181, %r421; + fma.rn.f32 %r423, %r418, %r182, %r422; + fma.rn.f32 %r424, %r417, %r183, %r423; + fma.rn.f32 %r425, %r416, %r184, %r424; + fma.rn.f32 %r426, %r415, %r185, %r425; + fma.rn.f32 %r427, %r414, %r186, %r426; + fma.rn.f32 %r428, %r413, %r187, %r427; + add.s64 %rd49, %rd7, 18432; + // begin inline asm + ld.global.nc.v4.f32 {%r188,%r189,%r190,%r191}, [%rd49]; + // end inline asm + add.s64 %rd50, %rd7, 18448; + // begin inline asm + ld.global.nc.v4.f32 {%r192,%r193,%r194,%r195}, [%rd50]; + // end inline asm + fma.rn.f32 %r429, %r420, %r188, %r412; + fma.rn.f32 %r430, %r419, %r189, %r429; + fma.rn.f32 %r431, %r418, %r190, %r430; + fma.rn.f32 %r432, %r417, %r191, %r431; + fma.rn.f32 %r433, %r416, %r192, %r432; + fma.rn.f32 %r434, %r415, %r193, %r433; + fma.rn.f32 %r435, %r414, %r194, %r434; + fma.rn.f32 %r436, %r413, %r195, %r435; + add.s64 %rd51, %rd6, 4608; + // begin inline asm + ld.global.nc.v4.u32 {%r196,%r197,%r198,%r199}, [%rd51]; + // end inline asm + and.b32 %r437, %r199, -65536; + shl.b32 %r438, %r199, 16; + and.b32 %r439, %r198, -65536; + shl.b32 %r440, %r198, 16; + and.b32 %r441, %r197, -65536; + shl.b32 %r442, %r197, 16; + and.b32 %r443, %r196, -65536; + shl.b32 %r444, %r196, 16; + add.s64 %rd52, %rd7, 9216; + // begin inline asm + ld.global.nc.v4.f32 {%r200,%r201,%r202,%r203}, [%rd52]; + // end inline asm + add.s64 %rd53, %rd7, 9232; + // begin inline asm + ld.global.nc.v4.f32 {%r204,%r205,%r206,%r207}, [%rd53]; + // end inline asm + fma.rn.f32 %r445, %r444, %r200, %r428; + fma.rn.f32 %r446, %r443, %r201, %r445; + fma.rn.f32 %r447, %r442, %r202, %r446; + fma.rn.f32 %r448, %r441, %r203, %r447; + fma.rn.f32 %r449, %r440, %r204, %r448; + fma.rn.f32 %r450, %r439, %r205, %r449; + fma.rn.f32 %r451, %r438, %r206, %r450; + fma.rn.f32 %r452, %r437, %r207, %r451; + add.s64 %rd54, %rd7, 19456; + // begin inline asm + ld.global.nc.v4.f32 {%r208,%r209,%r210,%r211}, [%rd54]; + // end inline asm + add.s64 %rd55, %rd7, 19472; + // begin inline asm + ld.global.nc.v4.f32 {%r212,%r213,%r214,%r215}, [%rd55]; + // end inline asm + fma.rn.f32 %r453, %r444, %r208, %r436; + fma.rn.f32 %r454, %r443, %r209, %r453; + fma.rn.f32 %r455, %r442, %r210, %r454; + fma.rn.f32 %r456, %r441, %r211, %r455; + fma.rn.f32 %r457, %r440, %r212, %r456; + fma.rn.f32 %r458, %r439, %r213, %r457; + fma.rn.f32 %r459, %r438, %r214, %r458; + fma.rn.f32 %r4, %r437, %r215, %r459; + setp.ne.b32 %p3, %r3, 0; + mul.wide.s32 %rd64, %r217, 4; + add.s64 %rd2, %rd56, %rd64; + add.s64 %rd3, %rd57, %rd64; + shfl.sync.bfly.b32 %r460|%p4, %r452, 16, 31, -1; + add.f32 %r461, %r452, %r460; + shfl.sync.bfly.b32 %r462|%p5, %r461, 8, 31, -1; + add.f32 %r463, %r461, %r462; + shfl.sync.bfly.b32 %r464|%p6, %r463, 4, 31, -1; + add.f32 %r465, %r463, %r464; + shfl.sync.bfly.b32 %r466|%p7, %r465, 2, 31, -1; + add.f32 %r467, %r465, %r466; + shfl.sync.bfly.b32 %r468|%p8, %r467, 1, 31, -1; + add.f32 %r5, %r467, %r468; + @%p3 bra $L__BB2_9; + setp.lt.s32 %p9, %r2, %r10; + @%p9 bra $L__BB2_4; + mul.f32 %r469, %r5, 0fBFB8AA3B; + ex2.approx.f32 %r470, %r469; + add.f32 %r471, %r470, 0f3F800000; + rcp.rn.f32 %r534, %r471; + mov.b64 %rd77, %rd5; + bra.uni $L__BB2_8; +$L__BB2_4: + ld.global.nc.b32 %r472, [%rd2]; + add.f32 %r533, %r5, %r472; + setp.gt.f32 %p10, %r533, 0f41A00000; + @%p10 bra $L__BB2_7; + mul.f32 %r473, %r533, 0f3FB8AA3B; + ex2.approx.f32 %r6, %r473; + mov.b32 %r474, 0f3F800000; + add.rz.f32 %r475, %r6, %r474; + add.s32 %r476, %r475, -1061158912; + and.b32 %r477, %r476, -8388608; + sub.s32 %r478, %r6, %r477; + sub.s32 %r479, 1082130432, %r477; + fma.rn.f32 %r480, %r479, 0f3E800000, 0fBF800000; + add.f32 %r481, %r480, %r478; + cvt.rn.f32.s32 %r482, %r477; + mul.f32 %r483, %r482, 0f34000000; + fma.rn.f32 %r484, %r481, 0fBD39BF78, 0f3DD80012; + fma.rn.f32 %r485, %r484, %r481, 0fBE0778E0; + fma.rn.f32 %r486, %r485, %r481, 0f3E146475; + fma.rn.f32 %r487, %r486, %r481, 0fBE2A68DD; + fma.rn.f32 %r488, %r487, %r481, 0f3E4CAF9E; + fma.rn.f32 %r489, %r488, %r481, 0fBE800042; + fma.rn.f32 %r490, %r489, %r481, 0f3EAAAAE6; + fma.rn.f32 %r491, %r490, %r481, 0fBF000000; + mul.f32 %r492, %r481, %r491; + fma.rn.f32 %r493, %r492, %r481, %r481; + fma.rn.f32 %r533, %r483, 0f3F317218, %r493; + setp.lt.u32 %p11, %r6, 2139095040; + @%p11 bra $L__BB2_7; + setp.gt.s32 %p12, %r6, -1082130432; + fma.rn.f32 %r494, %r6, 0f7F800000, 0f7F800000; + selp.f32 %r495, %r494, %r533, %p12; + setp.eq.f32 %p13, %r6, 0f00000000; + selp.f32 %r533, 0f80000000, %r495, %p13; +$L__BB2_7: + ld.global.nc.b32 %r496, [%rd3]; + mul.f32 %r534, %r496, %r533; + mov.b64 %rd77, %rd78; +$L__BB2_8: + cvta.to.global.u64 %rd65, %rd77; + shl.b64 %rd66, %rd1, 2; + add.s64 %rd67, %rd65, %rd66; + st.global.b32 [%rd67], %r534; +$L__BB2_9: + setp.ne.b32 %p14, %r3, 0; + shfl.sync.bfly.b32 %r497|%p15, %r4, 16, 31, -1; + add.f32 %r498, %r4, %r497; + shfl.sync.bfly.b32 %r499|%p16, %r498, 8, 31, -1; + add.f32 %r500, %r498, %r499; + shfl.sync.bfly.b32 %r501|%p17, %r500, 4, 31, -1; + add.f32 %r502, %r500, %r501; + shfl.sync.bfly.b32 %r503|%p18, %r502, 2, 31, -1; + add.f32 %r504, %r502, %r503; + shfl.sync.bfly.b32 %r505|%p19, %r504, 1, 31, -1; + add.f32 %r7, %r504, %r505; + @%p14 bra $L__BB2_17; + setp.lt.s32 %p20, %r2, %r10; + ld.global.nc.b32 %r8, [%rd3]; + @%p20 bra $L__BB2_12; + mul.f32 %r506, %r7, 0fBFB8AA3B; + ex2.approx.f32 %r507, %r506; + add.f32 %r508, %r507, 0f3F800000; + rcp.rn.f32 %r536, %r508; + mov.b64 %rd78, %rd5; + bra.uni $L__BB2_16; +$L__BB2_12: + ld.global.nc.b32 %r509, [%rd2]; + add.f32 %r535, %r7, %r509; + setp.gt.f32 %p21, %r535, 0f41A00000; + @%p21 bra $L__BB2_15; + mul.f32 %r510, %r535, 0f3FB8AA3B; + ex2.approx.f32 %r9, %r510; + mov.b32 %r511, 0f3F800000; + add.rz.f32 %r512, %r9, %r511; + add.s32 %r513, %r512, -1061158912; + and.b32 %r514, %r513, -8388608; + sub.s32 %r515, %r9, %r514; + sub.s32 %r516, 1082130432, %r514; + fma.rn.f32 %r517, %r516, 0f3E800000, 0fBF800000; + add.f32 %r518, %r517, %r515; + cvt.rn.f32.s32 %r519, %r514; + mul.f32 %r520, %r519, 0f34000000; + fma.rn.f32 %r521, %r518, 0fBD39BF78, 0f3DD80012; + fma.rn.f32 %r522, %r521, %r518, 0fBE0778E0; + fma.rn.f32 %r523, %r522, %r518, 0f3E146475; + fma.rn.f32 %r524, %r523, %r518, 0fBE2A68DD; + fma.rn.f32 %r525, %r524, %r518, 0f3E4CAF9E; + fma.rn.f32 %r526, %r525, %r518, 0fBE800042; + fma.rn.f32 %r527, %r526, %r518, 0f3EAAAAE6; + fma.rn.f32 %r528, %r527, %r518, 0fBF000000; + mul.f32 %r529, %r518, %r528; + fma.rn.f32 %r530, %r529, %r518, %r518; + fma.rn.f32 %r535, %r520, 0f3F317218, %r530; + setp.lt.u32 %p22, %r9, 2139095040; + @%p22 bra $L__BB2_15; + setp.gt.s32 %p23, %r9, -1082130432; + fma.rn.f32 %r531, %r9, 0f7F800000, 0f7F800000; + selp.f32 %r532, %r531, %r535, %p23; + setp.eq.f32 %p24, %r9, 0f00000000; + selp.f32 %r535, 0f80000000, %r532, %p24; +$L__BB2_15: + mul.f32 %r536, %r8, %r535; +$L__BB2_16: + cvta.to.global.u64 %rd68, %rd78; + cvt.s64.s32 %rd69, %r10; + add.s64 %rd70, %rd69, %rd1; + shl.b64 %rd71, %rd70, 2; + add.s64 %rd72, %rd68, %rd71; + st.global.b32 [%rd72], %r536; +$L__BB2_17: + ret; + +} + // .globl leleka_gdn_ab_unrolled_t3 +.visible .entry leleka_gdn_ab_unrolled_t3( + .param .u64 .ptr .align 1 leleka_gdn_ab_unrolled_t3_param_0, + .param .u64 .ptr .align 1 leleka_gdn_ab_unrolled_t3_param_1, + .param .u64 .ptr .align 1 leleka_gdn_ab_unrolled_t3_param_2, + .param .u64 .ptr .align 1 leleka_gdn_ab_unrolled_t3_param_3, + .param .u64 .ptr .align 1 leleka_gdn_ab_unrolled_t3_param_4, + .param .u64 .ptr .align 1 leleka_gdn_ab_unrolled_t3_param_5, + .param .u64 .ptr .align 1 leleka_gdn_ab_unrolled_t3_param_6, + .param .u32 leleka_gdn_ab_unrolled_t3_param_7, + .param .u32 leleka_gdn_ab_unrolled_t3_param_8, + .param .u32 leleka_gdn_ab_unrolled_t3_param_9 +) +.maxntid 64 +{ + .reg .pred %p<36>; + .reg .b32 %r<738>; + .reg .b64 %rd<105>; + + ld.param.b64 %rd104, [leleka_gdn_ab_unrolled_t3_param_5]; + ld.param.b64 %rd5, [leleka_gdn_ab_unrolled_t3_param_6]; + ld.param.b32 %r13, [leleka_gdn_ab_unrolled_t3_param_8]; + mov.u32 %r14, %ctaid.x; + mov.u32 %r15, %ntid.x; + shr.u32 %r16, %r15, 5; + mov.u32 %r1, %tid.x; + shr.u32 %r17, %r1, 5; + mad.lo.s32 %r2, %r16, %r14, %r17; + shl.b32 %r18, %r13, 1; + setp.ge.s32 %p1, %r2, %r18; + @%p1 bra $L__BB3_25; + ld.param.b64 %rd101, [leleka_gdn_ab_unrolled_t3_param_4]; + ld.param.b64 %rd100, [leleka_gdn_ab_unrolled_t3_param_3]; + ld.param.b64 %rd99, [leleka_gdn_ab_unrolled_t3_param_2]; + ld.param.b64 %rd98, [leleka_gdn_ab_unrolled_t3_param_1]; + ld.param.b64 %rd97, [leleka_gdn_ab_unrolled_t3_param_0]; + and.b32 %r3, %r1, 31; + cvta.to.global.u64 %rd76, %rd100; + cvta.to.global.u64 %rd77, %rd101; + setp.lt.s32 %p2, %r2, %r13; + selp.b32 %r299, 0, %r13, %p2; + sub.s32 %r300, %r2, %r299; + selp.b64 %rd78, %rd98, %rd99, %p2; + cvt.s64.s32 %rd1, %r300; + mul.wide.s32 %rd79, %r300, 5120; + add.s64 %rd80, %rd78, %rd79; + shl.b32 %r301, %r1, 4; + cvt.u64.u32 %rd81, %r301; + and.b64 %rd82, %rd81, 496; + add.s64 %rd6, %rd80, %rd82; + // begin inline asm + ld.global.nc.v4.u32 {%r19,%r20,%r21,%r22}, [%rd6]; + // end inline asm + and.b32 %r302, %r22, -65536; + shl.b32 %r303, %r22, 16; + and.b32 %r304, %r21, -65536; + shl.b32 %r305, %r21, 16; + and.b32 %r306, %r20, -65536; + shl.b32 %r307, %r20, 16; + and.b32 %r308, %r19, -65536; + shl.b32 %r309, %r19, 16; + shl.b32 %r310, %r1, 3; + and.b32 %r311, %r310, 248; + mul.wide.u32 %rd83, %r311, 4; + add.s64 %rd7, %rd97, %rd83; + // begin inline asm + ld.global.nc.v4.f32 {%r23,%r24,%r25,%r26}, [%rd7]; + // end inline asm + add.s64 %rd8, %rd7, 16; + // begin inline asm + ld.global.nc.v4.f32 {%r27,%r28,%r29,%r30}, [%rd8]; + // end inline asm + fma.rn.f32 %r312, %r309, %r23, 0f00000000; + fma.rn.f32 %r313, %r308, %r24, %r312; + fma.rn.f32 %r314, %r307, %r25, %r313; + fma.rn.f32 %r315, %r306, %r26, %r314; + fma.rn.f32 %r316, %r305, %r27, %r315; + fma.rn.f32 %r317, %r304, %r28, %r316; + fma.rn.f32 %r318, %r303, %r29, %r317; + fma.rn.f32 %r319, %r302, %r30, %r318; + add.s64 %rd9, %rd7, 10240; + // begin inline asm + ld.global.nc.v4.f32 {%r31,%r32,%r33,%r34}, [%rd9]; + // end inline asm + add.s64 %rd10, %rd7, 10256; + // begin inline asm + ld.global.nc.v4.f32 {%r35,%r36,%r37,%r38}, [%rd10]; + // end inline asm + fma.rn.f32 %r320, %r309, %r31, 0f00000000; + fma.rn.f32 %r321, %r308, %r32, %r320; + fma.rn.f32 %r322, %r307, %r33, %r321; + fma.rn.f32 %r323, %r306, %r34, %r322; + fma.rn.f32 %r324, %r305, %r35, %r323; + fma.rn.f32 %r325, %r304, %r36, %r324; + fma.rn.f32 %r326, %r303, %r37, %r325; + fma.rn.f32 %r327, %r302, %r38, %r326; + add.s64 %rd11, %rd7, 20480; + // begin inline asm + ld.global.nc.v4.f32 {%r39,%r40,%r41,%r42}, [%rd11]; + // end inline asm + add.s64 %rd12, %rd7, 20496; + // begin inline asm + ld.global.nc.v4.f32 {%r43,%r44,%r45,%r46}, [%rd12]; + // end inline asm + fma.rn.f32 %r328, %r309, %r39, 0f00000000; + fma.rn.f32 %r329, %r308, %r40, %r328; + fma.rn.f32 %r330, %r307, %r41, %r329; + fma.rn.f32 %r331, %r306, %r42, %r330; + fma.rn.f32 %r332, %r305, %r43, %r331; + fma.rn.f32 %r333, %r304, %r44, %r332; + fma.rn.f32 %r334, %r303, %r45, %r333; + fma.rn.f32 %r335, %r302, %r46, %r334; + add.s64 %rd13, %rd6, 512; + // begin inline asm + ld.global.nc.v4.u32 {%r47,%r48,%r49,%r50}, [%rd13]; + // end inline asm + and.b32 %r336, %r50, -65536; + shl.b32 %r337, %r50, 16; + and.b32 %r338, %r49, -65536; + shl.b32 %r339, %r49, 16; + and.b32 %r340, %r48, -65536; + shl.b32 %r341, %r48, 16; + and.b32 %r342, %r47, -65536; + shl.b32 %r343, %r47, 16; + add.s64 %rd14, %rd7, 1024; + // begin inline asm + ld.global.nc.v4.f32 {%r51,%r52,%r53,%r54}, [%rd14]; + // end inline asm + add.s64 %rd15, %rd7, 1040; + // begin inline asm + ld.global.nc.v4.f32 {%r55,%r56,%r57,%r58}, [%rd15]; + // end inline asm + fma.rn.f32 %r344, %r343, %r51, %r319; + fma.rn.f32 %r345, %r342, %r52, %r344; + fma.rn.f32 %r346, %r341, %r53, %r345; + fma.rn.f32 %r347, %r340, %r54, %r346; + fma.rn.f32 %r348, %r339, %r55, %r347; + fma.rn.f32 %r349, %r338, %r56, %r348; + fma.rn.f32 %r350, %r337, %r57, %r349; + fma.rn.f32 %r351, %r336, %r58, %r350; + add.s64 %rd16, %rd7, 11264; + // begin inline asm + ld.global.nc.v4.f32 {%r59,%r60,%r61,%r62}, [%rd16]; + // end inline asm + add.s64 %rd17, %rd7, 11280; + // begin inline asm + ld.global.nc.v4.f32 {%r63,%r64,%r65,%r66}, [%rd17]; + // end inline asm + fma.rn.f32 %r352, %r343, %r59, %r327; + fma.rn.f32 %r353, %r342, %r60, %r352; + fma.rn.f32 %r354, %r341, %r61, %r353; + fma.rn.f32 %r355, %r340, %r62, %r354; + fma.rn.f32 %r356, %r339, %r63, %r355; + fma.rn.f32 %r357, %r338, %r64, %r356; + fma.rn.f32 %r358, %r337, %r65, %r357; + fma.rn.f32 %r359, %r336, %r66, %r358; + add.s64 %rd18, %rd7, 21504; + // begin inline asm + ld.global.nc.v4.f32 {%r67,%r68,%r69,%r70}, [%rd18]; + // end inline asm + add.s64 %rd19, %rd7, 21520; + // begin inline asm + ld.global.nc.v4.f32 {%r71,%r72,%r73,%r74}, [%rd19]; + // end inline asm + fma.rn.f32 %r360, %r343, %r67, %r335; + fma.rn.f32 %r361, %r342, %r68, %r360; + fma.rn.f32 %r362, %r341, %r69, %r361; + fma.rn.f32 %r363, %r340, %r70, %r362; + fma.rn.f32 %r364, %r339, %r71, %r363; + fma.rn.f32 %r365, %r338, %r72, %r364; + fma.rn.f32 %r366, %r337, %r73, %r365; + fma.rn.f32 %r367, %r336, %r74, %r366; + add.s64 %rd20, %rd6, 1024; + // begin inline asm + ld.global.nc.v4.u32 {%r75,%r76,%r77,%r78}, [%rd20]; + // end inline asm + and.b32 %r368, %r78, -65536; + shl.b32 %r369, %r78, 16; + and.b32 %r370, %r77, -65536; + shl.b32 %r371, %r77, 16; + and.b32 %r372, %r76, -65536; + shl.b32 %r373, %r76, 16; + and.b32 %r374, %r75, -65536; + shl.b32 %r375, %r75, 16; + add.s64 %rd21, %rd7, 2048; + // begin inline asm + ld.global.nc.v4.f32 {%r79,%r80,%r81,%r82}, [%rd21]; + // end inline asm + add.s64 %rd22, %rd7, 2064; + // begin inline asm + ld.global.nc.v4.f32 {%r83,%r84,%r85,%r86}, [%rd22]; + // end inline asm + fma.rn.f32 %r376, %r375, %r79, %r351; + fma.rn.f32 %r377, %r374, %r80, %r376; + fma.rn.f32 %r378, %r373, %r81, %r377; + fma.rn.f32 %r379, %r372, %r82, %r378; + fma.rn.f32 %r380, %r371, %r83, %r379; + fma.rn.f32 %r381, %r370, %r84, %r380; + fma.rn.f32 %r382, %r369, %r85, %r381; + fma.rn.f32 %r383, %r368, %r86, %r382; + add.s64 %rd23, %rd7, 12288; + // begin inline asm + ld.global.nc.v4.f32 {%r87,%r88,%r89,%r90}, [%rd23]; + // end inline asm + add.s64 %rd24, %rd7, 12304; + // begin inline asm + ld.global.nc.v4.f32 {%r91,%r92,%r93,%r94}, [%rd24]; + // end inline asm + fma.rn.f32 %r384, %r375, %r87, %r359; + fma.rn.f32 %r385, %r374, %r88, %r384; + fma.rn.f32 %r386, %r373, %r89, %r385; + fma.rn.f32 %r387, %r372, %r90, %r386; + fma.rn.f32 %r388, %r371, %r91, %r387; + fma.rn.f32 %r389, %r370, %r92, %r388; + fma.rn.f32 %r390, %r369, %r93, %r389; + fma.rn.f32 %r391, %r368, %r94, %r390; + add.s64 %rd25, %rd7, 22528; + // begin inline asm + ld.global.nc.v4.f32 {%r95,%r96,%r97,%r98}, [%rd25]; + // end inline asm + add.s64 %rd26, %rd7, 22544; + // begin inline asm + ld.global.nc.v4.f32 {%r99,%r100,%r101,%r102}, [%rd26]; + // end inline asm + fma.rn.f32 %r392, %r375, %r95, %r367; + fma.rn.f32 %r393, %r374, %r96, %r392; + fma.rn.f32 %r394, %r373, %r97, %r393; + fma.rn.f32 %r395, %r372, %r98, %r394; + fma.rn.f32 %r396, %r371, %r99, %r395; + fma.rn.f32 %r397, %r370, %r100, %r396; + fma.rn.f32 %r398, %r369, %r101, %r397; + fma.rn.f32 %r399, %r368, %r102, %r398; + add.s64 %rd27, %rd6, 1536; + // begin inline asm + ld.global.nc.v4.u32 {%r103,%r104,%r105,%r106}, [%rd27]; + // end inline asm + and.b32 %r400, %r106, -65536; + shl.b32 %r401, %r106, 16; + and.b32 %r402, %r105, -65536; + shl.b32 %r403, %r105, 16; + and.b32 %r404, %r104, -65536; + shl.b32 %r405, %r104, 16; + and.b32 %r406, %r103, -65536; + shl.b32 %r407, %r103, 16; + add.s64 %rd28, %rd7, 3072; + // begin inline asm + ld.global.nc.v4.f32 {%r107,%r108,%r109,%r110}, [%rd28]; + // end inline asm + add.s64 %rd29, %rd7, 3088; + // begin inline asm + ld.global.nc.v4.f32 {%r111,%r112,%r113,%r114}, [%rd29]; + // end inline asm + fma.rn.f32 %r408, %r407, %r107, %r383; + fma.rn.f32 %r409, %r406, %r108, %r408; + fma.rn.f32 %r410, %r405, %r109, %r409; + fma.rn.f32 %r411, %r404, %r110, %r410; + fma.rn.f32 %r412, %r403, %r111, %r411; + fma.rn.f32 %r413, %r402, %r112, %r412; + fma.rn.f32 %r414, %r401, %r113, %r413; + fma.rn.f32 %r415, %r400, %r114, %r414; + add.s64 %rd30, %rd7, 13312; + // begin inline asm + ld.global.nc.v4.f32 {%r115,%r116,%r117,%r118}, [%rd30]; + // end inline asm + add.s64 %rd31, %rd7, 13328; + // begin inline asm + ld.global.nc.v4.f32 {%r119,%r120,%r121,%r122}, [%rd31]; + // end inline asm + fma.rn.f32 %r416, %r407, %r115, %r391; + fma.rn.f32 %r417, %r406, %r116, %r416; + fma.rn.f32 %r418, %r405, %r117, %r417; + fma.rn.f32 %r419, %r404, %r118, %r418; + fma.rn.f32 %r420, %r403, %r119, %r419; + fma.rn.f32 %r421, %r402, %r120, %r420; + fma.rn.f32 %r422, %r401, %r121, %r421; + fma.rn.f32 %r423, %r400, %r122, %r422; + add.s64 %rd32, %rd7, 23552; + // begin inline asm + ld.global.nc.v4.f32 {%r123,%r124,%r125,%r126}, [%rd32]; + // end inline asm + add.s64 %rd33, %rd7, 23568; + // begin inline asm + ld.global.nc.v4.f32 {%r127,%r128,%r129,%r130}, [%rd33]; + // end inline asm + fma.rn.f32 %r424, %r407, %r123, %r399; + fma.rn.f32 %r425, %r406, %r124, %r424; + fma.rn.f32 %r426, %r405, %r125, %r425; + fma.rn.f32 %r427, %r404, %r126, %r426; + fma.rn.f32 %r428, %r403, %r127, %r427; + fma.rn.f32 %r429, %r402, %r128, %r428; + fma.rn.f32 %r430, %r401, %r129, %r429; + fma.rn.f32 %r431, %r400, %r130, %r430; + add.s64 %rd34, %rd6, 2048; + // begin inline asm + ld.global.nc.v4.u32 {%r131,%r132,%r133,%r134}, [%rd34]; + // end inline asm + and.b32 %r432, %r134, -65536; + shl.b32 %r433, %r134, 16; + and.b32 %r434, %r133, -65536; + shl.b32 %r435, %r133, 16; + and.b32 %r436, %r132, -65536; + shl.b32 %r437, %r132, 16; + and.b32 %r438, %r131, -65536; + shl.b32 %r439, %r131, 16; + add.s64 %rd35, %rd7, 4096; + // begin inline asm + ld.global.nc.v4.f32 {%r135,%r136,%r137,%r138}, [%rd35]; + // end inline asm + add.s64 %rd36, %rd7, 4112; + // begin inline asm + ld.global.nc.v4.f32 {%r139,%r140,%r141,%r142}, [%rd36]; + // end inline asm + fma.rn.f32 %r440, %r439, %r135, %r415; + fma.rn.f32 %r441, %r438, %r136, %r440; + fma.rn.f32 %r442, %r437, %r137, %r441; + fma.rn.f32 %r443, %r436, %r138, %r442; + fma.rn.f32 %r444, %r435, %r139, %r443; + fma.rn.f32 %r445, %r434, %r140, %r444; + fma.rn.f32 %r446, %r433, %r141, %r445; + fma.rn.f32 %r447, %r432, %r142, %r446; + add.s64 %rd37, %rd7, 14336; + // begin inline asm + ld.global.nc.v4.f32 {%r143,%r144,%r145,%r146}, [%rd37]; + // end inline asm + add.s64 %rd38, %rd7, 14352; + // begin inline asm + ld.global.nc.v4.f32 {%r147,%r148,%r149,%r150}, [%rd38]; + // end inline asm + fma.rn.f32 %r448, %r439, %r143, %r423; + fma.rn.f32 %r449, %r438, %r144, %r448; + fma.rn.f32 %r450, %r437, %r145, %r449; + fma.rn.f32 %r451, %r436, %r146, %r450; + fma.rn.f32 %r452, %r435, %r147, %r451; + fma.rn.f32 %r453, %r434, %r148, %r452; + fma.rn.f32 %r454, %r433, %r149, %r453; + fma.rn.f32 %r455, %r432, %r150, %r454; + add.s64 %rd39, %rd7, 24576; + // begin inline asm + ld.global.nc.v4.f32 {%r151,%r152,%r153,%r154}, [%rd39]; + // end inline asm + add.s64 %rd40, %rd7, 24592; + // begin inline asm + ld.global.nc.v4.f32 {%r155,%r156,%r157,%r158}, [%rd40]; + // end inline asm + fma.rn.f32 %r456, %r439, %r151, %r431; + fma.rn.f32 %r457, %r438, %r152, %r456; + fma.rn.f32 %r458, %r437, %r153, %r457; + fma.rn.f32 %r459, %r436, %r154, %r458; + fma.rn.f32 %r460, %r435, %r155, %r459; + fma.rn.f32 %r461, %r434, %r156, %r460; + fma.rn.f32 %r462, %r433, %r157, %r461; + fma.rn.f32 %r463, %r432, %r158, %r462; + add.s64 %rd41, %rd6, 2560; + // begin inline asm + ld.global.nc.v4.u32 {%r159,%r160,%r161,%r162}, [%rd41]; + // end inline asm + and.b32 %r464, %r162, -65536; + shl.b32 %r465, %r162, 16; + and.b32 %r466, %r161, -65536; + shl.b32 %r467, %r161, 16; + and.b32 %r468, %r160, -65536; + shl.b32 %r469, %r160, 16; + and.b32 %r470, %r159, -65536; + shl.b32 %r471, %r159, 16; + add.s64 %rd42, %rd7, 5120; + // begin inline asm + ld.global.nc.v4.f32 {%r163,%r164,%r165,%r166}, [%rd42]; + // end inline asm + add.s64 %rd43, %rd7, 5136; + // begin inline asm + ld.global.nc.v4.f32 {%r167,%r168,%r169,%r170}, [%rd43]; + // end inline asm + fma.rn.f32 %r472, %r471, %r163, %r447; + fma.rn.f32 %r473, %r470, %r164, %r472; + fma.rn.f32 %r474, %r469, %r165, %r473; + fma.rn.f32 %r475, %r468, %r166, %r474; + fma.rn.f32 %r476, %r467, %r167, %r475; + fma.rn.f32 %r477, %r466, %r168, %r476; + fma.rn.f32 %r478, %r465, %r169, %r477; + fma.rn.f32 %r479, %r464, %r170, %r478; + add.s64 %rd44, %rd7, 15360; + // begin inline asm + ld.global.nc.v4.f32 {%r171,%r172,%r173,%r174}, [%rd44]; + // end inline asm + add.s64 %rd45, %rd7, 15376; + // begin inline asm + ld.global.nc.v4.f32 {%r175,%r176,%r177,%r178}, [%rd45]; + // end inline asm + fma.rn.f32 %r480, %r471, %r171, %r455; + fma.rn.f32 %r481, %r470, %r172, %r480; + fma.rn.f32 %r482, %r469, %r173, %r481; + fma.rn.f32 %r483, %r468, %r174, %r482; + fma.rn.f32 %r484, %r467, %r175, %r483; + fma.rn.f32 %r485, %r466, %r176, %r484; + fma.rn.f32 %r486, %r465, %r177, %r485; + fma.rn.f32 %r487, %r464, %r178, %r486; + add.s64 %rd46, %rd7, 25600; + // begin inline asm + ld.global.nc.v4.f32 {%r179,%r180,%r181,%r182}, [%rd46]; + // end inline asm + add.s64 %rd47, %rd7, 25616; + // begin inline asm + ld.global.nc.v4.f32 {%r183,%r184,%r185,%r186}, [%rd47]; + // end inline asm + fma.rn.f32 %r488, %r471, %r179, %r463; + fma.rn.f32 %r489, %r470, %r180, %r488; + fma.rn.f32 %r490, %r469, %r181, %r489; + fma.rn.f32 %r491, %r468, %r182, %r490; + fma.rn.f32 %r492, %r467, %r183, %r491; + fma.rn.f32 %r493, %r466, %r184, %r492; + fma.rn.f32 %r494, %r465, %r185, %r493; + fma.rn.f32 %r495, %r464, %r186, %r494; + add.s64 %rd48, %rd6, 3072; + // begin inline asm + ld.global.nc.v4.u32 {%r187,%r188,%r189,%r190}, [%rd48]; + // end inline asm + and.b32 %r496, %r190, -65536; + shl.b32 %r497, %r190, 16; + and.b32 %r498, %r189, -65536; + shl.b32 %r499, %r189, 16; + and.b32 %r500, %r188, -65536; + shl.b32 %r501, %r188, 16; + and.b32 %r502, %r187, -65536; + shl.b32 %r503, %r187, 16; + add.s64 %rd49, %rd7, 6144; + // begin inline asm + ld.global.nc.v4.f32 {%r191,%r192,%r193,%r194}, [%rd49]; + // end inline asm + add.s64 %rd50, %rd7, 6160; + // begin inline asm + ld.global.nc.v4.f32 {%r195,%r196,%r197,%r198}, [%rd50]; + // end inline asm + fma.rn.f32 %r504, %r503, %r191, %r479; + fma.rn.f32 %r505, %r502, %r192, %r504; + fma.rn.f32 %r506, %r501, %r193, %r505; + fma.rn.f32 %r507, %r500, %r194, %r506; + fma.rn.f32 %r508, %r499, %r195, %r507; + fma.rn.f32 %r509, %r498, %r196, %r508; + fma.rn.f32 %r510, %r497, %r197, %r509; + fma.rn.f32 %r511, %r496, %r198, %r510; + add.s64 %rd51, %rd7, 16384; + // begin inline asm + ld.global.nc.v4.f32 {%r199,%r200,%r201,%r202}, [%rd51]; + // end inline asm + add.s64 %rd52, %rd7, 16400; + // begin inline asm + ld.global.nc.v4.f32 {%r203,%r204,%r205,%r206}, [%rd52]; + // end inline asm + fma.rn.f32 %r512, %r503, %r199, %r487; + fma.rn.f32 %r513, %r502, %r200, %r512; + fma.rn.f32 %r514, %r501, %r201, %r513; + fma.rn.f32 %r515, %r500, %r202, %r514; + fma.rn.f32 %r516, %r499, %r203, %r515; + fma.rn.f32 %r517, %r498, %r204, %r516; + fma.rn.f32 %r518, %r497, %r205, %r517; + fma.rn.f32 %r519, %r496, %r206, %r518; + add.s64 %rd53, %rd7, 26624; + // begin inline asm + ld.global.nc.v4.f32 {%r207,%r208,%r209,%r210}, [%rd53]; + // end inline asm + add.s64 %rd54, %rd7, 26640; + // begin inline asm + ld.global.nc.v4.f32 {%r211,%r212,%r213,%r214}, [%rd54]; + // end inline asm + fma.rn.f32 %r520, %r503, %r207, %r495; + fma.rn.f32 %r521, %r502, %r208, %r520; + fma.rn.f32 %r522, %r501, %r209, %r521; + fma.rn.f32 %r523, %r500, %r210, %r522; + fma.rn.f32 %r524, %r499, %r211, %r523; + fma.rn.f32 %r525, %r498, %r212, %r524; + fma.rn.f32 %r526, %r497, %r213, %r525; + fma.rn.f32 %r527, %r496, %r214, %r526; + add.s64 %rd55, %rd6, 3584; + // begin inline asm + ld.global.nc.v4.u32 {%r215,%r216,%r217,%r218}, [%rd55]; + // end inline asm + and.b32 %r528, %r218, -65536; + shl.b32 %r529, %r218, 16; + and.b32 %r530, %r217, -65536; + shl.b32 %r531, %r217, 16; + and.b32 %r532, %r216, -65536; + shl.b32 %r533, %r216, 16; + and.b32 %r534, %r215, -65536; + shl.b32 %r535, %r215, 16; + add.s64 %rd56, %rd7, 7168; + // begin inline asm + ld.global.nc.v4.f32 {%r219,%r220,%r221,%r222}, [%rd56]; + // end inline asm + add.s64 %rd57, %rd7, 7184; + // begin inline asm + ld.global.nc.v4.f32 {%r223,%r224,%r225,%r226}, [%rd57]; + // end inline asm + fma.rn.f32 %r536, %r535, %r219, %r511; + fma.rn.f32 %r537, %r534, %r220, %r536; + fma.rn.f32 %r538, %r533, %r221, %r537; + fma.rn.f32 %r539, %r532, %r222, %r538; + fma.rn.f32 %r540, %r531, %r223, %r539; + fma.rn.f32 %r541, %r530, %r224, %r540; + fma.rn.f32 %r542, %r529, %r225, %r541; + fma.rn.f32 %r543, %r528, %r226, %r542; + add.s64 %rd58, %rd7, 17408; + // begin inline asm + ld.global.nc.v4.f32 {%r227,%r228,%r229,%r230}, [%rd58]; + // end inline asm + add.s64 %rd59, %rd7, 17424; + // begin inline asm + ld.global.nc.v4.f32 {%r231,%r232,%r233,%r234}, [%rd59]; + // end inline asm + fma.rn.f32 %r544, %r535, %r227, %r519; + fma.rn.f32 %r545, %r534, %r228, %r544; + fma.rn.f32 %r546, %r533, %r229, %r545; + fma.rn.f32 %r547, %r532, %r230, %r546; + fma.rn.f32 %r548, %r531, %r231, %r547; + fma.rn.f32 %r549, %r530, %r232, %r548; + fma.rn.f32 %r550, %r529, %r233, %r549; + fma.rn.f32 %r551, %r528, %r234, %r550; + add.s64 %rd60, %rd7, 27648; + // begin inline asm + ld.global.nc.v4.f32 {%r235,%r236,%r237,%r238}, [%rd60]; + // end inline asm + add.s64 %rd61, %rd7, 27664; + // begin inline asm + ld.global.nc.v4.f32 {%r239,%r240,%r241,%r242}, [%rd61]; + // end inline asm + fma.rn.f32 %r552, %r535, %r235, %r527; + fma.rn.f32 %r553, %r534, %r236, %r552; + fma.rn.f32 %r554, %r533, %r237, %r553; + fma.rn.f32 %r555, %r532, %r238, %r554; + fma.rn.f32 %r556, %r531, %r239, %r555; + fma.rn.f32 %r557, %r530, %r240, %r556; + fma.rn.f32 %r558, %r529, %r241, %r557; + fma.rn.f32 %r559, %r528, %r242, %r558; + add.s64 %rd62, %rd6, 4096; + // begin inline asm + ld.global.nc.v4.u32 {%r243,%r244,%r245,%r246}, [%rd62]; + // end inline asm + and.b32 %r560, %r246, -65536; + shl.b32 %r561, %r246, 16; + and.b32 %r562, %r245, -65536; + shl.b32 %r563, %r245, 16; + and.b32 %r564, %r244, -65536; + shl.b32 %r565, %r244, 16; + and.b32 %r566, %r243, -65536; + shl.b32 %r567, %r243, 16; + add.s64 %rd63, %rd7, 8192; + // begin inline asm + ld.global.nc.v4.f32 {%r247,%r248,%r249,%r250}, [%rd63]; + // end inline asm + add.s64 %rd64, %rd7, 8208; + // begin inline asm + ld.global.nc.v4.f32 {%r251,%r252,%r253,%r254}, [%rd64]; + // end inline asm + fma.rn.f32 %r568, %r567, %r247, %r543; + fma.rn.f32 %r569, %r566, %r248, %r568; + fma.rn.f32 %r570, %r565, %r249, %r569; + fma.rn.f32 %r571, %r564, %r250, %r570; + fma.rn.f32 %r572, %r563, %r251, %r571; + fma.rn.f32 %r573, %r562, %r252, %r572; + fma.rn.f32 %r574, %r561, %r253, %r573; + fma.rn.f32 %r575, %r560, %r254, %r574; + add.s64 %rd65, %rd7, 18432; + // begin inline asm + ld.global.nc.v4.f32 {%r255,%r256,%r257,%r258}, [%rd65]; + // end inline asm + add.s64 %rd66, %rd7, 18448; + // begin inline asm + ld.global.nc.v4.f32 {%r259,%r260,%r261,%r262}, [%rd66]; + // end inline asm + fma.rn.f32 %r576, %r567, %r255, %r551; + fma.rn.f32 %r577, %r566, %r256, %r576; + fma.rn.f32 %r578, %r565, %r257, %r577; + fma.rn.f32 %r579, %r564, %r258, %r578; + fma.rn.f32 %r580, %r563, %r259, %r579; + fma.rn.f32 %r581, %r562, %r260, %r580; + fma.rn.f32 %r582, %r561, %r261, %r581; + fma.rn.f32 %r583, %r560, %r262, %r582; + add.s64 %rd67, %rd7, 28672; + // begin inline asm + ld.global.nc.v4.f32 {%r263,%r264,%r265,%r266}, [%rd67]; + // end inline asm + add.s64 %rd68, %rd7, 28688; + // begin inline asm + ld.global.nc.v4.f32 {%r267,%r268,%r269,%r270}, [%rd68]; + // end inline asm + fma.rn.f32 %r584, %r567, %r263, %r559; + fma.rn.f32 %r585, %r566, %r264, %r584; + fma.rn.f32 %r586, %r565, %r265, %r585; + fma.rn.f32 %r587, %r564, %r266, %r586; + fma.rn.f32 %r588, %r563, %r267, %r587; + fma.rn.f32 %r589, %r562, %r268, %r588; + fma.rn.f32 %r590, %r561, %r269, %r589; + fma.rn.f32 %r591, %r560, %r270, %r590; + add.s64 %rd69, %rd6, 4608; + // begin inline asm + ld.global.nc.v4.u32 {%r271,%r272,%r273,%r274}, [%rd69]; + // end inline asm + and.b32 %r592, %r274, -65536; + shl.b32 %r593, %r274, 16; + and.b32 %r594, %r273, -65536; + shl.b32 %r595, %r273, 16; + and.b32 %r596, %r272, -65536; + shl.b32 %r597, %r272, 16; + and.b32 %r598, %r271, -65536; + shl.b32 %r599, %r271, 16; + add.s64 %rd70, %rd7, 9216; + // begin inline asm + ld.global.nc.v4.f32 {%r275,%r276,%r277,%r278}, [%rd70]; + // end inline asm + add.s64 %rd71, %rd7, 9232; + // begin inline asm + ld.global.nc.v4.f32 {%r279,%r280,%r281,%r282}, [%rd71]; + // end inline asm + fma.rn.f32 %r600, %r599, %r275, %r575; + fma.rn.f32 %r601, %r598, %r276, %r600; + fma.rn.f32 %r602, %r597, %r277, %r601; + fma.rn.f32 %r603, %r596, %r278, %r602; + fma.rn.f32 %r604, %r595, %r279, %r603; + fma.rn.f32 %r605, %r594, %r280, %r604; + fma.rn.f32 %r606, %r593, %r281, %r605; + fma.rn.f32 %r607, %r592, %r282, %r606; + add.s64 %rd72, %rd7, 19456; + // begin inline asm + ld.global.nc.v4.f32 {%r283,%r284,%r285,%r286}, [%rd72]; + // end inline asm + add.s64 %rd73, %rd7, 19472; + // begin inline asm + ld.global.nc.v4.f32 {%r287,%r288,%r289,%r290}, [%rd73]; + // end inline asm + fma.rn.f32 %r608, %r599, %r283, %r583; + fma.rn.f32 %r609, %r598, %r284, %r608; + fma.rn.f32 %r610, %r597, %r285, %r609; + fma.rn.f32 %r611, %r596, %r286, %r610; + fma.rn.f32 %r612, %r595, %r287, %r611; + fma.rn.f32 %r613, %r594, %r288, %r612; + fma.rn.f32 %r614, %r593, %r289, %r613; + fma.rn.f32 %r4, %r592, %r290, %r614; + add.s64 %rd74, %rd7, 29696; + // begin inline asm + ld.global.nc.v4.f32 {%r291,%r292,%r293,%r294}, [%rd74]; + // end inline asm + add.s64 %rd75, %rd7, 29712; + // begin inline asm + ld.global.nc.v4.f32 {%r295,%r296,%r297,%r298}, [%rd75]; + // end inline asm + fma.rn.f32 %r615, %r599, %r291, %r591; + fma.rn.f32 %r616, %r598, %r292, %r615; + fma.rn.f32 %r617, %r597, %r293, %r616; + fma.rn.f32 %r618, %r596, %r294, %r617; + fma.rn.f32 %r619, %r595, %r295, %r618; + fma.rn.f32 %r620, %r594, %r296, %r619; + fma.rn.f32 %r621, %r593, %r297, %r620; + fma.rn.f32 %r5, %r592, %r298, %r621; + setp.ne.b32 %p3, %r3, 0; + mul.wide.s32 %rd84, %r300, 4; + add.s64 %rd2, %rd76, %rd84; + add.s64 %rd3, %rd77, %rd84; + cvt.s64.s32 %rd4, %r13; + shfl.sync.bfly.b32 %r622|%p4, %r607, 16, 31, -1; + add.f32 %r623, %r607, %r622; + shfl.sync.bfly.b32 %r624|%p5, %r623, 8, 31, -1; + add.f32 %r625, %r623, %r624; + shfl.sync.bfly.b32 %r626|%p6, %r625, 4, 31, -1; + add.f32 %r627, %r625, %r626; + shfl.sync.bfly.b32 %r628|%p7, %r627, 2, 31, -1; + add.f32 %r629, %r627, %r628; + shfl.sync.bfly.b32 %r630|%p8, %r629, 1, 31, -1; + add.f32 %r6, %r629, %r630; + @%p3 bra $L__BB3_9; + setp.lt.s32 %p9, %r2, %r13; + @%p9 bra $L__BB3_4; + mul.f32 %r631, %r6, 0fBFB8AA3B; + ex2.approx.f32 %r632, %r631; + add.f32 %r633, %r632, 0f3F800000; + rcp.rn.f32 %r733, %r633; + mov.b64 %rd102, %rd5; + bra.uni $L__BB3_8; +$L__BB3_4: + ld.global.nc.b32 %r634, [%rd2]; + add.f32 %r732, %r6, %r634; + setp.gt.f32 %p10, %r732, 0f41A00000; + @%p10 bra $L__BB3_7; + mul.f32 %r635, %r732, 0f3FB8AA3B; + ex2.approx.f32 %r7, %r635; + mov.b32 %r636, 0f3F800000; + add.rz.f32 %r637, %r7, %r636; + add.s32 %r638, %r637, -1061158912; + and.b32 %r639, %r638, -8388608; + sub.s32 %r640, %r7, %r639; + sub.s32 %r641, 1082130432, %r639; + fma.rn.f32 %r642, %r641, 0f3E800000, 0fBF800000; + add.f32 %r643, %r642, %r640; + cvt.rn.f32.s32 %r644, %r639; + mul.f32 %r645, %r644, 0f34000000; + fma.rn.f32 %r646, %r643, 0fBD39BF78, 0f3DD80012; + fma.rn.f32 %r647, %r646, %r643, 0fBE0778E0; + fma.rn.f32 %r648, %r647, %r643, 0f3E146475; + fma.rn.f32 %r649, %r648, %r643, 0fBE2A68DD; + fma.rn.f32 %r650, %r649, %r643, 0f3E4CAF9E; + fma.rn.f32 %r651, %r650, %r643, 0fBE800042; + fma.rn.f32 %r652, %r651, %r643, 0f3EAAAAE6; + fma.rn.f32 %r653, %r652, %r643, 0fBF000000; + mul.f32 %r654, %r643, %r653; + fma.rn.f32 %r655, %r654, %r643, %r643; + fma.rn.f32 %r732, %r645, 0f3F317218, %r655; + setp.lt.u32 %p11, %r7, 2139095040; + @%p11 bra $L__BB3_7; + setp.gt.s32 %p12, %r7, -1082130432; + fma.rn.f32 %r656, %r7, 0f7F800000, 0f7F800000; + selp.f32 %r657, %r656, %r732, %p12; + setp.eq.f32 %p13, %r7, 0f00000000; + selp.f32 %r732, 0f80000000, %r657, %p13; +$L__BB3_7: + ld.global.nc.b32 %r658, [%rd3]; + mul.f32 %r733, %r658, %r732; + mov.b64 %rd102, %rd104; +$L__BB3_8: + cvta.to.global.u64 %rd85, %rd102; + shl.b64 %rd86, %rd1, 2; + add.s64 %rd87, %rd85, %rd86; + st.global.b32 [%rd87], %r733; +$L__BB3_9: + setp.ne.b32 %p14, %r3, 0; + shfl.sync.bfly.b32 %r659|%p15, %r4, 16, 31, -1; + add.f32 %r660, %r4, %r659; + shfl.sync.bfly.b32 %r661|%p16, %r660, 8, 31, -1; + add.f32 %r662, %r660, %r661; + shfl.sync.bfly.b32 %r663|%p17, %r662, 4, 31, -1; + add.f32 %r664, %r662, %r663; + shfl.sync.bfly.b32 %r665|%p18, %r664, 2, 31, -1; + add.f32 %r666, %r664, %r665; + shfl.sync.bfly.b32 %r667|%p19, %r666, 1, 31, -1; + add.f32 %r8, %r666, %r667; + @%p14 bra $L__BB3_17; + setp.lt.s32 %p20, %r2, %r13; + @%p20 bra $L__BB3_12; + mul.f32 %r668, %r8, 0fBFB8AA3B; + ex2.approx.f32 %r669, %r668; + add.f32 %r670, %r669, 0f3F800000; + rcp.rn.f32 %r735, %r670; + mov.b64 %rd103, %rd5; + bra.uni $L__BB3_16; +$L__BB3_12: + ld.global.nc.b32 %r671, [%rd2]; + add.f32 %r734, %r8, %r671; + setp.gt.f32 %p21, %r734, 0f41A00000; + @%p21 bra $L__BB3_15; + mul.f32 %r672, %r734, 0f3FB8AA3B; + ex2.approx.f32 %r9, %r672; + mov.b32 %r673, 0f3F800000; + add.rz.f32 %r674, %r9, %r673; + add.s32 %r675, %r674, -1061158912; + and.b32 %r676, %r675, -8388608; + sub.s32 %r677, %r9, %r676; + sub.s32 %r678, 1082130432, %r676; + fma.rn.f32 %r679, %r678, 0f3E800000, 0fBF800000; + add.f32 %r680, %r679, %r677; + cvt.rn.f32.s32 %r681, %r676; + mul.f32 %r682, %r681, 0f34000000; + fma.rn.f32 %r683, %r680, 0fBD39BF78, 0f3DD80012; + fma.rn.f32 %r684, %r683, %r680, 0fBE0778E0; + fma.rn.f32 %r685, %r684, %r680, 0f3E146475; + fma.rn.f32 %r686, %r685, %r680, 0fBE2A68DD; + fma.rn.f32 %r687, %r686, %r680, 0f3E4CAF9E; + fma.rn.f32 %r688, %r687, %r680, 0fBE800042; + fma.rn.f32 %r689, %r688, %r680, 0f3EAAAAE6; + fma.rn.f32 %r690, %r689, %r680, 0fBF000000; + mul.f32 %r691, %r680, %r690; + fma.rn.f32 %r692, %r691, %r680, %r680; + fma.rn.f32 %r734, %r682, 0f3F317218, %r692; + setp.lt.u32 %p22, %r9, 2139095040; + @%p22 bra $L__BB3_15; + setp.gt.s32 %p23, %r9, -1082130432; + fma.rn.f32 %r693, %r9, 0f7F800000, 0f7F800000; + selp.f32 %r694, %r693, %r734, %p23; + setp.eq.f32 %p24, %r9, 0f00000000; + selp.f32 %r734, 0f80000000, %r694, %p24; +$L__BB3_15: + ld.global.nc.b32 %r695, [%rd3]; + mul.f32 %r735, %r695, %r734; + mov.b64 %rd103, %rd104; +$L__BB3_16: + cvta.to.global.u64 %rd88, %rd103; + add.s64 %rd89, %rd4, %rd1; + shl.b64 %rd90, %rd89, 2; + add.s64 %rd91, %rd88, %rd90; + st.global.b32 [%rd91], %r735; +$L__BB3_17: + setp.ne.b32 %p25, %r3, 0; + shfl.sync.bfly.b32 %r696|%p26, %r5, 16, 31, -1; + add.f32 %r697, %r5, %r696; + shfl.sync.bfly.b32 %r698|%p27, %r697, 8, 31, -1; + add.f32 %r699, %r697, %r698; + shfl.sync.bfly.b32 %r700|%p28, %r699, 4, 31, -1; + add.f32 %r701, %r699, %r700; + shfl.sync.bfly.b32 %r702|%p29, %r701, 2, 31, -1; + add.f32 %r703, %r701, %r702; + shfl.sync.bfly.b32 %r704|%p30, %r703, 1, 31, -1; + add.f32 %r10, %r703, %r704; + @%p25 bra $L__BB3_25; + setp.lt.s32 %p31, %r2, %r13; + ld.global.nc.b32 %r11, [%rd3]; + @%p31 bra $L__BB3_20; + mul.f32 %r705, %r10, 0fBFB8AA3B; + ex2.approx.f32 %r706, %r705; + add.f32 %r707, %r706, 0f3F800000; + rcp.rn.f32 %r737, %r707; + mov.b64 %rd104, %rd5; + bra.uni $L__BB3_24; +$L__BB3_20: + ld.global.nc.b32 %r708, [%rd2]; + add.f32 %r736, %r10, %r708; + setp.gt.f32 %p32, %r736, 0f41A00000; + @%p32 bra $L__BB3_23; + mul.f32 %r709, %r736, 0f3FB8AA3B; + ex2.approx.f32 %r12, %r709; + mov.b32 %r710, 0f3F800000; + add.rz.f32 %r711, %r12, %r710; + add.s32 %r712, %r711, -1061158912; + and.b32 %r713, %r712, -8388608; + sub.s32 %r714, %r12, %r713; + sub.s32 %r715, 1082130432, %r713; + fma.rn.f32 %r716, %r715, 0f3E800000, 0fBF800000; + add.f32 %r717, %r716, %r714; + cvt.rn.f32.s32 %r718, %r713; + mul.f32 %r719, %r718, 0f34000000; + fma.rn.f32 %r720, %r717, 0fBD39BF78, 0f3DD80012; + fma.rn.f32 %r721, %r720, %r717, 0fBE0778E0; + fma.rn.f32 %r722, %r721, %r717, 0f3E146475; + fma.rn.f32 %r723, %r722, %r717, 0fBE2A68DD; + fma.rn.f32 %r724, %r723, %r717, 0f3E4CAF9E; + fma.rn.f32 %r725, %r724, %r717, 0fBE800042; + fma.rn.f32 %r726, %r725, %r717, 0f3EAAAAE6; + fma.rn.f32 %r727, %r726, %r717, 0fBF000000; + mul.f32 %r728, %r717, %r727; + fma.rn.f32 %r729, %r728, %r717, %r717; + fma.rn.f32 %r736, %r719, 0f3F317218, %r729; + setp.lt.u32 %p33, %r12, 2139095040; + @%p33 bra $L__BB3_23; + setp.gt.s32 %p34, %r12, -1082130432; + fma.rn.f32 %r730, %r12, 0f7F800000, 0f7F800000; + selp.f32 %r731, %r730, %r736, %p34; + setp.eq.f32 %p35, %r12, 0f00000000; + selp.f32 %r736, 0f80000000, %r731, %p35; +$L__BB3_23: + mul.f32 %r737, %r11, %r736; +$L__BB3_24: + cvta.to.global.u64 %rd92, %rd104; + shl.b64 %rd93, %rd4, 1; + add.s64 %rd94, %rd93, %rd1; + shl.b64 %rd95, %rd94, 2; + add.s64 %rd96, %rd92, %rd95; + st.global.b32 [%rd96], %r737; +$L__BB3_25: + ret; + +} + // .globl leleka_gdn_ab_unrolled_t4 +.visible .entry leleka_gdn_ab_unrolled_t4( + .param .u64 .ptr .align 1 leleka_gdn_ab_unrolled_t4_param_0, + .param .u64 .ptr .align 1 leleka_gdn_ab_unrolled_t4_param_1, + .param .u64 .ptr .align 1 leleka_gdn_ab_unrolled_t4_param_2, + .param .u64 .ptr .align 1 leleka_gdn_ab_unrolled_t4_param_3, + .param .u64 .ptr .align 1 leleka_gdn_ab_unrolled_t4_param_4, + .param .u64 .ptr .align 1 leleka_gdn_ab_unrolled_t4_param_5, + .param .u64 .ptr .align 1 leleka_gdn_ab_unrolled_t4_param_6, + .param .u32 leleka_gdn_ab_unrolled_t4_param_7, + .param .u32 leleka_gdn_ab_unrolled_t4_param_8, + .param .u32 leleka_gdn_ab_unrolled_t4_param_9 +) +.maxntid 64 +{ + .reg .pred %p<47>; + .reg .b32 %r<939>; + .reg .b64 %rd<130>; + + ld.param.b64 %rd5, [leleka_gdn_ab_unrolled_t4_param_1]; + ld.param.b64 %rd6, [leleka_gdn_ab_unrolled_t4_param_2]; + ld.param.b64 %rd7, [leleka_gdn_ab_unrolled_t4_param_3]; + ld.param.b64 %rd8, [leleka_gdn_ab_unrolled_t4_param_4]; + ld.param.b64 %rd129, [leleka_gdn_ab_unrolled_t4_param_5]; + ld.param.b64 %rd9, [leleka_gdn_ab_unrolled_t4_param_6]; + ld.param.b32 %r16, [leleka_gdn_ab_unrolled_t4_param_8]; + mov.u32 %r17, %ctaid.x; + mov.u32 %r18, %ntid.x; + shr.u32 %r19, %r18, 5; + mov.u32 %r1, %tid.x; + shr.u32 %r20, %r1, 5; + mad.lo.s32 %r2, %r19, %r17, %r20; + shl.b32 %r21, %r16, 1; + setp.ge.s32 %p1, %r2, %r21; + @%p1 bra $L__BB4_33; + ld.param.b64 %rd125, [leleka_gdn_ab_unrolled_t4_param_0]; + and.b32 %r3, %r1, 31; + cvta.to.global.u64 %rd100, %rd7; + cvta.to.global.u64 %rd101, %rd8; + setp.lt.s32 %p2, %r2, %r16; + selp.b32 %r382, 0, %r16, %p2; + sub.s32 %r383, %r2, %r382; + selp.b64 %rd102, %rd5, %rd6, %p2; + cvt.s64.s32 %rd1, %r383; + mul.wide.s32 %rd103, %r383, 5120; + add.s64 %rd104, %rd102, %rd103; + shl.b32 %r384, %r1, 4; + cvt.u64.u32 %rd105, %r384; + and.b64 %rd106, %rd105, 496; + add.s64 %rd10, %rd104, %rd106; + // begin inline asm + ld.global.nc.v4.u32 {%r22,%r23,%r24,%r25}, [%rd10]; + // end inline asm + and.b32 %r385, %r25, -65536; + shl.b32 %r386, %r25, 16; + and.b32 %r387, %r24, -65536; + shl.b32 %r388, %r24, 16; + and.b32 %r389, %r23, -65536; + shl.b32 %r390, %r23, 16; + and.b32 %r391, %r22, -65536; + shl.b32 %r392, %r22, 16; + shl.b32 %r393, %r1, 3; + and.b32 %r394, %r393, 248; + mul.wide.u32 %rd107, %r394, 4; + add.s64 %rd11, %rd125, %rd107; + // begin inline asm + ld.global.nc.v4.f32 {%r26,%r27,%r28,%r29}, [%rd11]; + // end inline asm + add.s64 %rd12, %rd11, 16; + // begin inline asm + ld.global.nc.v4.f32 {%r30,%r31,%r32,%r33}, [%rd12]; + // end inline asm + fma.rn.f32 %r395, %r392, %r26, 0f00000000; + fma.rn.f32 %r396, %r391, %r27, %r395; + fma.rn.f32 %r397, %r390, %r28, %r396; + fma.rn.f32 %r398, %r389, %r29, %r397; + fma.rn.f32 %r399, %r388, %r30, %r398; + fma.rn.f32 %r400, %r387, %r31, %r399; + fma.rn.f32 %r401, %r386, %r32, %r400; + fma.rn.f32 %r402, %r385, %r33, %r401; + add.s64 %rd13, %rd11, 10240; + // begin inline asm + ld.global.nc.v4.f32 {%r34,%r35,%r36,%r37}, [%rd13]; + // end inline asm + add.s64 %rd14, %rd11, 10256; + // begin inline asm + ld.global.nc.v4.f32 {%r38,%r39,%r40,%r41}, [%rd14]; + // end inline asm + fma.rn.f32 %r403, %r392, %r34, 0f00000000; + fma.rn.f32 %r404, %r391, %r35, %r403; + fma.rn.f32 %r405, %r390, %r36, %r404; + fma.rn.f32 %r406, %r389, %r37, %r405; + fma.rn.f32 %r407, %r388, %r38, %r406; + fma.rn.f32 %r408, %r387, %r39, %r407; + fma.rn.f32 %r409, %r386, %r40, %r408; + fma.rn.f32 %r410, %r385, %r41, %r409; + add.s64 %rd15, %rd11, 20480; + // begin inline asm + ld.global.nc.v4.f32 {%r42,%r43,%r44,%r45}, [%rd15]; + // end inline asm + add.s64 %rd16, %rd11, 20496; + // begin inline asm + ld.global.nc.v4.f32 {%r46,%r47,%r48,%r49}, [%rd16]; + // end inline asm + fma.rn.f32 %r411, %r392, %r42, 0f00000000; + fma.rn.f32 %r412, %r391, %r43, %r411; + fma.rn.f32 %r413, %r390, %r44, %r412; + fma.rn.f32 %r414, %r389, %r45, %r413; + fma.rn.f32 %r415, %r388, %r46, %r414; + fma.rn.f32 %r416, %r387, %r47, %r415; + fma.rn.f32 %r417, %r386, %r48, %r416; + fma.rn.f32 %r418, %r385, %r49, %r417; + add.s64 %rd17, %rd11, 30720; + // begin inline asm + ld.global.nc.v4.f32 {%r50,%r51,%r52,%r53}, [%rd17]; + // end inline asm + add.s64 %rd18, %rd11, 30736; + // begin inline asm + ld.global.nc.v4.f32 {%r54,%r55,%r56,%r57}, [%rd18]; + // end inline asm + fma.rn.f32 %r419, %r392, %r50, 0f00000000; + fma.rn.f32 %r420, %r391, %r51, %r419; + fma.rn.f32 %r421, %r390, %r52, %r420; + fma.rn.f32 %r422, %r389, %r53, %r421; + fma.rn.f32 %r423, %r388, %r54, %r422; + fma.rn.f32 %r424, %r387, %r55, %r423; + fma.rn.f32 %r425, %r386, %r56, %r424; + fma.rn.f32 %r426, %r385, %r57, %r425; + add.s64 %rd19, %rd10, 512; + // begin inline asm + ld.global.nc.v4.u32 {%r58,%r59,%r60,%r61}, [%rd19]; + // end inline asm + and.b32 %r427, %r61, -65536; + shl.b32 %r428, %r61, 16; + and.b32 %r429, %r60, -65536; + shl.b32 %r430, %r60, 16; + and.b32 %r431, %r59, -65536; + shl.b32 %r432, %r59, 16; + and.b32 %r433, %r58, -65536; + shl.b32 %r434, %r58, 16; + add.s64 %rd20, %rd11, 1024; + // begin inline asm + ld.global.nc.v4.f32 {%r62,%r63,%r64,%r65}, [%rd20]; + // end inline asm + add.s64 %rd21, %rd11, 1040; + // begin inline asm + ld.global.nc.v4.f32 {%r66,%r67,%r68,%r69}, [%rd21]; + // end inline asm + fma.rn.f32 %r435, %r434, %r62, %r402; + fma.rn.f32 %r436, %r433, %r63, %r435; + fma.rn.f32 %r437, %r432, %r64, %r436; + fma.rn.f32 %r438, %r431, %r65, %r437; + fma.rn.f32 %r439, %r430, %r66, %r438; + fma.rn.f32 %r440, %r429, %r67, %r439; + fma.rn.f32 %r441, %r428, %r68, %r440; + fma.rn.f32 %r442, %r427, %r69, %r441; + add.s64 %rd22, %rd11, 11264; + // begin inline asm + ld.global.nc.v4.f32 {%r70,%r71,%r72,%r73}, [%rd22]; + // end inline asm + add.s64 %rd23, %rd11, 11280; + // begin inline asm + ld.global.nc.v4.f32 {%r74,%r75,%r76,%r77}, [%rd23]; + // end inline asm + fma.rn.f32 %r443, %r434, %r70, %r410; + fma.rn.f32 %r444, %r433, %r71, %r443; + fma.rn.f32 %r445, %r432, %r72, %r444; + fma.rn.f32 %r446, %r431, %r73, %r445; + fma.rn.f32 %r447, %r430, %r74, %r446; + fma.rn.f32 %r448, %r429, %r75, %r447; + fma.rn.f32 %r449, %r428, %r76, %r448; + fma.rn.f32 %r450, %r427, %r77, %r449; + add.s64 %rd24, %rd11, 21504; + // begin inline asm + ld.global.nc.v4.f32 {%r78,%r79,%r80,%r81}, [%rd24]; + // end inline asm + add.s64 %rd25, %rd11, 21520; + // begin inline asm + ld.global.nc.v4.f32 {%r82,%r83,%r84,%r85}, [%rd25]; + // end inline asm + fma.rn.f32 %r451, %r434, %r78, %r418; + fma.rn.f32 %r452, %r433, %r79, %r451; + fma.rn.f32 %r453, %r432, %r80, %r452; + fma.rn.f32 %r454, %r431, %r81, %r453; + fma.rn.f32 %r455, %r430, %r82, %r454; + fma.rn.f32 %r456, %r429, %r83, %r455; + fma.rn.f32 %r457, %r428, %r84, %r456; + fma.rn.f32 %r458, %r427, %r85, %r457; + add.s64 %rd26, %rd11, 31744; + // begin inline asm + ld.global.nc.v4.f32 {%r86,%r87,%r88,%r89}, [%rd26]; + // end inline asm + add.s64 %rd27, %rd11, 31760; + // begin inline asm + ld.global.nc.v4.f32 {%r90,%r91,%r92,%r93}, [%rd27]; + // end inline asm + fma.rn.f32 %r459, %r434, %r86, %r426; + fma.rn.f32 %r460, %r433, %r87, %r459; + fma.rn.f32 %r461, %r432, %r88, %r460; + fma.rn.f32 %r462, %r431, %r89, %r461; + fma.rn.f32 %r463, %r430, %r90, %r462; + fma.rn.f32 %r464, %r429, %r91, %r463; + fma.rn.f32 %r465, %r428, %r92, %r464; + fma.rn.f32 %r466, %r427, %r93, %r465; + add.s64 %rd28, %rd10, 1024; + // begin inline asm + ld.global.nc.v4.u32 {%r94,%r95,%r96,%r97}, [%rd28]; + // end inline asm + and.b32 %r467, %r97, -65536; + shl.b32 %r468, %r97, 16; + and.b32 %r469, %r96, -65536; + shl.b32 %r470, %r96, 16; + and.b32 %r471, %r95, -65536; + shl.b32 %r472, %r95, 16; + and.b32 %r473, %r94, -65536; + shl.b32 %r474, %r94, 16; + add.s64 %rd29, %rd11, 2048; + // begin inline asm + ld.global.nc.v4.f32 {%r98,%r99,%r100,%r101}, [%rd29]; + // end inline asm + add.s64 %rd30, %rd11, 2064; + // begin inline asm + ld.global.nc.v4.f32 {%r102,%r103,%r104,%r105}, [%rd30]; + // end inline asm + fma.rn.f32 %r475, %r474, %r98, %r442; + fma.rn.f32 %r476, %r473, %r99, %r475; + fma.rn.f32 %r477, %r472, %r100, %r476; + fma.rn.f32 %r478, %r471, %r101, %r477; + fma.rn.f32 %r479, %r470, %r102, %r478; + fma.rn.f32 %r480, %r469, %r103, %r479; + fma.rn.f32 %r481, %r468, %r104, %r480; + fma.rn.f32 %r482, %r467, %r105, %r481; + add.s64 %rd31, %rd11, 12288; + // begin inline asm + ld.global.nc.v4.f32 {%r106,%r107,%r108,%r109}, [%rd31]; + // end inline asm + add.s64 %rd32, %rd11, 12304; + // begin inline asm + ld.global.nc.v4.f32 {%r110,%r111,%r112,%r113}, [%rd32]; + // end inline asm + fma.rn.f32 %r483, %r474, %r106, %r450; + fma.rn.f32 %r484, %r473, %r107, %r483; + fma.rn.f32 %r485, %r472, %r108, %r484; + fma.rn.f32 %r486, %r471, %r109, %r485; + fma.rn.f32 %r487, %r470, %r110, %r486; + fma.rn.f32 %r488, %r469, %r111, %r487; + fma.rn.f32 %r489, %r468, %r112, %r488; + fma.rn.f32 %r490, %r467, %r113, %r489; + add.s64 %rd33, %rd11, 22528; + // begin inline asm + ld.global.nc.v4.f32 {%r114,%r115,%r116,%r117}, [%rd33]; + // end inline asm + add.s64 %rd34, %rd11, 22544; + // begin inline asm + ld.global.nc.v4.f32 {%r118,%r119,%r120,%r121}, [%rd34]; + // end inline asm + fma.rn.f32 %r491, %r474, %r114, %r458; + fma.rn.f32 %r492, %r473, %r115, %r491; + fma.rn.f32 %r493, %r472, %r116, %r492; + fma.rn.f32 %r494, %r471, %r117, %r493; + fma.rn.f32 %r495, %r470, %r118, %r494; + fma.rn.f32 %r496, %r469, %r119, %r495; + fma.rn.f32 %r497, %r468, %r120, %r496; + fma.rn.f32 %r498, %r467, %r121, %r497; + add.s64 %rd35, %rd11, 32768; + // begin inline asm + ld.global.nc.v4.f32 {%r122,%r123,%r124,%r125}, [%rd35]; + // end inline asm + add.s64 %rd36, %rd11, 32784; + // begin inline asm + ld.global.nc.v4.f32 {%r126,%r127,%r128,%r129}, [%rd36]; + // end inline asm + fma.rn.f32 %r499, %r474, %r122, %r466; + fma.rn.f32 %r500, %r473, %r123, %r499; + fma.rn.f32 %r501, %r472, %r124, %r500; + fma.rn.f32 %r502, %r471, %r125, %r501; + fma.rn.f32 %r503, %r470, %r126, %r502; + fma.rn.f32 %r504, %r469, %r127, %r503; + fma.rn.f32 %r505, %r468, %r128, %r504; + fma.rn.f32 %r506, %r467, %r129, %r505; + add.s64 %rd37, %rd10, 1536; + // begin inline asm + ld.global.nc.v4.u32 {%r130,%r131,%r132,%r133}, [%rd37]; + // end inline asm + and.b32 %r507, %r133, -65536; + shl.b32 %r508, %r133, 16; + and.b32 %r509, %r132, -65536; + shl.b32 %r510, %r132, 16; + and.b32 %r511, %r131, -65536; + shl.b32 %r512, %r131, 16; + and.b32 %r513, %r130, -65536; + shl.b32 %r514, %r130, 16; + add.s64 %rd38, %rd11, 3072; + // begin inline asm + ld.global.nc.v4.f32 {%r134,%r135,%r136,%r137}, [%rd38]; + // end inline asm + add.s64 %rd39, %rd11, 3088; + // begin inline asm + ld.global.nc.v4.f32 {%r138,%r139,%r140,%r141}, [%rd39]; + // end inline asm + fma.rn.f32 %r515, %r514, %r134, %r482; + fma.rn.f32 %r516, %r513, %r135, %r515; + fma.rn.f32 %r517, %r512, %r136, %r516; + fma.rn.f32 %r518, %r511, %r137, %r517; + fma.rn.f32 %r519, %r510, %r138, %r518; + fma.rn.f32 %r520, %r509, %r139, %r519; + fma.rn.f32 %r521, %r508, %r140, %r520; + fma.rn.f32 %r522, %r507, %r141, %r521; + add.s64 %rd40, %rd11, 13312; + // begin inline asm + ld.global.nc.v4.f32 {%r142,%r143,%r144,%r145}, [%rd40]; + // end inline asm + add.s64 %rd41, %rd11, 13328; + // begin inline asm + ld.global.nc.v4.f32 {%r146,%r147,%r148,%r149}, [%rd41]; + // end inline asm + fma.rn.f32 %r523, %r514, %r142, %r490; + fma.rn.f32 %r524, %r513, %r143, %r523; + fma.rn.f32 %r525, %r512, %r144, %r524; + fma.rn.f32 %r526, %r511, %r145, %r525; + fma.rn.f32 %r527, %r510, %r146, %r526; + fma.rn.f32 %r528, %r509, %r147, %r527; + fma.rn.f32 %r529, %r508, %r148, %r528; + fma.rn.f32 %r530, %r507, %r149, %r529; + add.s64 %rd42, %rd11, 23552; + // begin inline asm + ld.global.nc.v4.f32 {%r150,%r151,%r152,%r153}, [%rd42]; + // end inline asm + add.s64 %rd43, %rd11, 23568; + // begin inline asm + ld.global.nc.v4.f32 {%r154,%r155,%r156,%r157}, [%rd43]; + // end inline asm + fma.rn.f32 %r531, %r514, %r150, %r498; + fma.rn.f32 %r532, %r513, %r151, %r531; + fma.rn.f32 %r533, %r512, %r152, %r532; + fma.rn.f32 %r534, %r511, %r153, %r533; + fma.rn.f32 %r535, %r510, %r154, %r534; + fma.rn.f32 %r536, %r509, %r155, %r535; + fma.rn.f32 %r537, %r508, %r156, %r536; + fma.rn.f32 %r538, %r507, %r157, %r537; + add.s64 %rd44, %rd11, 33792; + // begin inline asm + ld.global.nc.v4.f32 {%r158,%r159,%r160,%r161}, [%rd44]; + // end inline asm + add.s64 %rd45, %rd11, 33808; + // begin inline asm + ld.global.nc.v4.f32 {%r162,%r163,%r164,%r165}, [%rd45]; + // end inline asm + fma.rn.f32 %r539, %r514, %r158, %r506; + fma.rn.f32 %r540, %r513, %r159, %r539; + fma.rn.f32 %r541, %r512, %r160, %r540; + fma.rn.f32 %r542, %r511, %r161, %r541; + fma.rn.f32 %r543, %r510, %r162, %r542; + fma.rn.f32 %r544, %r509, %r163, %r543; + fma.rn.f32 %r545, %r508, %r164, %r544; + fma.rn.f32 %r546, %r507, %r165, %r545; + add.s64 %rd46, %rd10, 2048; + // begin inline asm + ld.global.nc.v4.u32 {%r166,%r167,%r168,%r169}, [%rd46]; + // end inline asm + and.b32 %r547, %r169, -65536; + shl.b32 %r548, %r169, 16; + and.b32 %r549, %r168, -65536; + shl.b32 %r550, %r168, 16; + and.b32 %r551, %r167, -65536; + shl.b32 %r552, %r167, 16; + and.b32 %r553, %r166, -65536; + shl.b32 %r554, %r166, 16; + add.s64 %rd47, %rd11, 4096; + // begin inline asm + ld.global.nc.v4.f32 {%r170,%r171,%r172,%r173}, [%rd47]; + // end inline asm + add.s64 %rd48, %rd11, 4112; + // begin inline asm + ld.global.nc.v4.f32 {%r174,%r175,%r176,%r177}, [%rd48]; + // end inline asm + fma.rn.f32 %r555, %r554, %r170, %r522; + fma.rn.f32 %r556, %r553, %r171, %r555; + fma.rn.f32 %r557, %r552, %r172, %r556; + fma.rn.f32 %r558, %r551, %r173, %r557; + fma.rn.f32 %r559, %r550, %r174, %r558; + fma.rn.f32 %r560, %r549, %r175, %r559; + fma.rn.f32 %r561, %r548, %r176, %r560; + fma.rn.f32 %r562, %r547, %r177, %r561; + add.s64 %rd49, %rd11, 14336; + // begin inline asm + ld.global.nc.v4.f32 {%r178,%r179,%r180,%r181}, [%rd49]; + // end inline asm + add.s64 %rd50, %rd11, 14352; + // begin inline asm + ld.global.nc.v4.f32 {%r182,%r183,%r184,%r185}, [%rd50]; + // end inline asm + fma.rn.f32 %r563, %r554, %r178, %r530; + fma.rn.f32 %r564, %r553, %r179, %r563; + fma.rn.f32 %r565, %r552, %r180, %r564; + fma.rn.f32 %r566, %r551, %r181, %r565; + fma.rn.f32 %r567, %r550, %r182, %r566; + fma.rn.f32 %r568, %r549, %r183, %r567; + fma.rn.f32 %r569, %r548, %r184, %r568; + fma.rn.f32 %r570, %r547, %r185, %r569; + add.s64 %rd51, %rd11, 24576; + // begin inline asm + ld.global.nc.v4.f32 {%r186,%r187,%r188,%r189}, [%rd51]; + // end inline asm + add.s64 %rd52, %rd11, 24592; + // begin inline asm + ld.global.nc.v4.f32 {%r190,%r191,%r192,%r193}, [%rd52]; + // end inline asm + fma.rn.f32 %r571, %r554, %r186, %r538; + fma.rn.f32 %r572, %r553, %r187, %r571; + fma.rn.f32 %r573, %r552, %r188, %r572; + fma.rn.f32 %r574, %r551, %r189, %r573; + fma.rn.f32 %r575, %r550, %r190, %r574; + fma.rn.f32 %r576, %r549, %r191, %r575; + fma.rn.f32 %r577, %r548, %r192, %r576; + fma.rn.f32 %r578, %r547, %r193, %r577; + add.s64 %rd53, %rd11, 34816; + // begin inline asm + ld.global.nc.v4.f32 {%r194,%r195,%r196,%r197}, [%rd53]; + // end inline asm + add.s64 %rd54, %rd11, 34832; + // begin inline asm + ld.global.nc.v4.f32 {%r198,%r199,%r200,%r201}, [%rd54]; + // end inline asm + fma.rn.f32 %r579, %r554, %r194, %r546; + fma.rn.f32 %r580, %r553, %r195, %r579; + fma.rn.f32 %r581, %r552, %r196, %r580; + fma.rn.f32 %r582, %r551, %r197, %r581; + fma.rn.f32 %r583, %r550, %r198, %r582; + fma.rn.f32 %r584, %r549, %r199, %r583; + fma.rn.f32 %r585, %r548, %r200, %r584; + fma.rn.f32 %r586, %r547, %r201, %r585; + add.s64 %rd55, %rd10, 2560; + // begin inline asm + ld.global.nc.v4.u32 {%r202,%r203,%r204,%r205}, [%rd55]; + // end inline asm + and.b32 %r587, %r205, -65536; + shl.b32 %r588, %r205, 16; + and.b32 %r589, %r204, -65536; + shl.b32 %r590, %r204, 16; + and.b32 %r591, %r203, -65536; + shl.b32 %r592, %r203, 16; + and.b32 %r593, %r202, -65536; + shl.b32 %r594, %r202, 16; + add.s64 %rd56, %rd11, 5120; + // begin inline asm + ld.global.nc.v4.f32 {%r206,%r207,%r208,%r209}, [%rd56]; + // end inline asm + add.s64 %rd57, %rd11, 5136; + // begin inline asm + ld.global.nc.v4.f32 {%r210,%r211,%r212,%r213}, [%rd57]; + // end inline asm + fma.rn.f32 %r595, %r594, %r206, %r562; + fma.rn.f32 %r596, %r593, %r207, %r595; + fma.rn.f32 %r597, %r592, %r208, %r596; + fma.rn.f32 %r598, %r591, %r209, %r597; + fma.rn.f32 %r599, %r590, %r210, %r598; + fma.rn.f32 %r600, %r589, %r211, %r599; + fma.rn.f32 %r601, %r588, %r212, %r600; + fma.rn.f32 %r602, %r587, %r213, %r601; + add.s64 %rd58, %rd11, 15360; + // begin inline asm + ld.global.nc.v4.f32 {%r214,%r215,%r216,%r217}, [%rd58]; + // end inline asm + add.s64 %rd59, %rd11, 15376; + // begin inline asm + ld.global.nc.v4.f32 {%r218,%r219,%r220,%r221}, [%rd59]; + // end inline asm + fma.rn.f32 %r603, %r594, %r214, %r570; + fma.rn.f32 %r604, %r593, %r215, %r603; + fma.rn.f32 %r605, %r592, %r216, %r604; + fma.rn.f32 %r606, %r591, %r217, %r605; + fma.rn.f32 %r607, %r590, %r218, %r606; + fma.rn.f32 %r608, %r589, %r219, %r607; + fma.rn.f32 %r609, %r588, %r220, %r608; + fma.rn.f32 %r610, %r587, %r221, %r609; + add.s64 %rd60, %rd11, 25600; + // begin inline asm + ld.global.nc.v4.f32 {%r222,%r223,%r224,%r225}, [%rd60]; + // end inline asm + add.s64 %rd61, %rd11, 25616; + // begin inline asm + ld.global.nc.v4.f32 {%r226,%r227,%r228,%r229}, [%rd61]; + // end inline asm + fma.rn.f32 %r611, %r594, %r222, %r578; + fma.rn.f32 %r612, %r593, %r223, %r611; + fma.rn.f32 %r613, %r592, %r224, %r612; + fma.rn.f32 %r614, %r591, %r225, %r613; + fma.rn.f32 %r615, %r590, %r226, %r614; + fma.rn.f32 %r616, %r589, %r227, %r615; + fma.rn.f32 %r617, %r588, %r228, %r616; + fma.rn.f32 %r618, %r587, %r229, %r617; + add.s64 %rd62, %rd11, 35840; + // begin inline asm + ld.global.nc.v4.f32 {%r230,%r231,%r232,%r233}, [%rd62]; + // end inline asm + add.s64 %rd63, %rd11, 35856; + // begin inline asm + ld.global.nc.v4.f32 {%r234,%r235,%r236,%r237}, [%rd63]; + // end inline asm + fma.rn.f32 %r619, %r594, %r230, %r586; + fma.rn.f32 %r620, %r593, %r231, %r619; + fma.rn.f32 %r621, %r592, %r232, %r620; + fma.rn.f32 %r622, %r591, %r233, %r621; + fma.rn.f32 %r623, %r590, %r234, %r622; + fma.rn.f32 %r624, %r589, %r235, %r623; + fma.rn.f32 %r625, %r588, %r236, %r624; + fma.rn.f32 %r626, %r587, %r237, %r625; + add.s64 %rd64, %rd10, 3072; + // begin inline asm + ld.global.nc.v4.u32 {%r238,%r239,%r240,%r241}, [%rd64]; + // end inline asm + and.b32 %r627, %r241, -65536; + shl.b32 %r628, %r241, 16; + and.b32 %r629, %r240, -65536; + shl.b32 %r630, %r240, 16; + and.b32 %r631, %r239, -65536; + shl.b32 %r632, %r239, 16; + and.b32 %r633, %r238, -65536; + shl.b32 %r634, %r238, 16; + add.s64 %rd65, %rd11, 6144; + // begin inline asm + ld.global.nc.v4.f32 {%r242,%r243,%r244,%r245}, [%rd65]; + // end inline asm + add.s64 %rd66, %rd11, 6160; + // begin inline asm + ld.global.nc.v4.f32 {%r246,%r247,%r248,%r249}, [%rd66]; + // end inline asm + fma.rn.f32 %r635, %r634, %r242, %r602; + fma.rn.f32 %r636, %r633, %r243, %r635; + fma.rn.f32 %r637, %r632, %r244, %r636; + fma.rn.f32 %r638, %r631, %r245, %r637; + fma.rn.f32 %r639, %r630, %r246, %r638; + fma.rn.f32 %r640, %r629, %r247, %r639; + fma.rn.f32 %r641, %r628, %r248, %r640; + fma.rn.f32 %r642, %r627, %r249, %r641; + add.s64 %rd67, %rd11, 16384; + // begin inline asm + ld.global.nc.v4.f32 {%r250,%r251,%r252,%r253}, [%rd67]; + // end inline asm + add.s64 %rd68, %rd11, 16400; + // begin inline asm + ld.global.nc.v4.f32 {%r254,%r255,%r256,%r257}, [%rd68]; + // end inline asm + fma.rn.f32 %r643, %r634, %r250, %r610; + fma.rn.f32 %r644, %r633, %r251, %r643; + fma.rn.f32 %r645, %r632, %r252, %r644; + fma.rn.f32 %r646, %r631, %r253, %r645; + fma.rn.f32 %r647, %r630, %r254, %r646; + fma.rn.f32 %r648, %r629, %r255, %r647; + fma.rn.f32 %r649, %r628, %r256, %r648; + fma.rn.f32 %r650, %r627, %r257, %r649; + add.s64 %rd69, %rd11, 26624; + // begin inline asm + ld.global.nc.v4.f32 {%r258,%r259,%r260,%r261}, [%rd69]; + // end inline asm + add.s64 %rd70, %rd11, 26640; + // begin inline asm + ld.global.nc.v4.f32 {%r262,%r263,%r264,%r265}, [%rd70]; + // end inline asm + fma.rn.f32 %r651, %r634, %r258, %r618; + fma.rn.f32 %r652, %r633, %r259, %r651; + fma.rn.f32 %r653, %r632, %r260, %r652; + fma.rn.f32 %r654, %r631, %r261, %r653; + fma.rn.f32 %r655, %r630, %r262, %r654; + fma.rn.f32 %r656, %r629, %r263, %r655; + fma.rn.f32 %r657, %r628, %r264, %r656; + fma.rn.f32 %r658, %r627, %r265, %r657; + add.s64 %rd71, %rd11, 36864; + // begin inline asm + ld.global.nc.v4.f32 {%r266,%r267,%r268,%r269}, [%rd71]; + // end inline asm + add.s64 %rd72, %rd11, 36880; + // begin inline asm + ld.global.nc.v4.f32 {%r270,%r271,%r272,%r273}, [%rd72]; + // end inline asm + fma.rn.f32 %r659, %r634, %r266, %r626; + fma.rn.f32 %r660, %r633, %r267, %r659; + fma.rn.f32 %r661, %r632, %r268, %r660; + fma.rn.f32 %r662, %r631, %r269, %r661; + fma.rn.f32 %r663, %r630, %r270, %r662; + fma.rn.f32 %r664, %r629, %r271, %r663; + fma.rn.f32 %r665, %r628, %r272, %r664; + fma.rn.f32 %r666, %r627, %r273, %r665; + add.s64 %rd73, %rd10, 3584; + // begin inline asm + ld.global.nc.v4.u32 {%r274,%r275,%r276,%r277}, [%rd73]; + // end inline asm + and.b32 %r667, %r277, -65536; + shl.b32 %r668, %r277, 16; + and.b32 %r669, %r276, -65536; + shl.b32 %r670, %r276, 16; + and.b32 %r671, %r275, -65536; + shl.b32 %r672, %r275, 16; + and.b32 %r673, %r274, -65536; + shl.b32 %r674, %r274, 16; + add.s64 %rd74, %rd11, 7168; + // begin inline asm + ld.global.nc.v4.f32 {%r278,%r279,%r280,%r281}, [%rd74]; + // end inline asm + add.s64 %rd75, %rd11, 7184; + // begin inline asm + ld.global.nc.v4.f32 {%r282,%r283,%r284,%r285}, [%rd75]; + // end inline asm + fma.rn.f32 %r675, %r674, %r278, %r642; + fma.rn.f32 %r676, %r673, %r279, %r675; + fma.rn.f32 %r677, %r672, %r280, %r676; + fma.rn.f32 %r678, %r671, %r281, %r677; + fma.rn.f32 %r679, %r670, %r282, %r678; + fma.rn.f32 %r680, %r669, %r283, %r679; + fma.rn.f32 %r681, %r668, %r284, %r680; + fma.rn.f32 %r682, %r667, %r285, %r681; + add.s64 %rd76, %rd11, 17408; + // begin inline asm + ld.global.nc.v4.f32 {%r286,%r287,%r288,%r289}, [%rd76]; + // end inline asm + add.s64 %rd77, %rd11, 17424; + // begin inline asm + ld.global.nc.v4.f32 {%r290,%r291,%r292,%r293}, [%rd77]; + // end inline asm + fma.rn.f32 %r683, %r674, %r286, %r650; + fma.rn.f32 %r684, %r673, %r287, %r683; + fma.rn.f32 %r685, %r672, %r288, %r684; + fma.rn.f32 %r686, %r671, %r289, %r685; + fma.rn.f32 %r687, %r670, %r290, %r686; + fma.rn.f32 %r688, %r669, %r291, %r687; + fma.rn.f32 %r689, %r668, %r292, %r688; + fma.rn.f32 %r690, %r667, %r293, %r689; + add.s64 %rd78, %rd11, 27648; + // begin inline asm + ld.global.nc.v4.f32 {%r294,%r295,%r296,%r297}, [%rd78]; + // end inline asm + add.s64 %rd79, %rd11, 27664; + // begin inline asm + ld.global.nc.v4.f32 {%r298,%r299,%r300,%r301}, [%rd79]; + // end inline asm + fma.rn.f32 %r691, %r674, %r294, %r658; + fma.rn.f32 %r692, %r673, %r295, %r691; + fma.rn.f32 %r693, %r672, %r296, %r692; + fma.rn.f32 %r694, %r671, %r297, %r693; + fma.rn.f32 %r695, %r670, %r298, %r694; + fma.rn.f32 %r696, %r669, %r299, %r695; + fma.rn.f32 %r697, %r668, %r300, %r696; + fma.rn.f32 %r698, %r667, %r301, %r697; + add.s64 %rd80, %rd11, 37888; + // begin inline asm + ld.global.nc.v4.f32 {%r302,%r303,%r304,%r305}, [%rd80]; + // end inline asm + add.s64 %rd81, %rd11, 37904; + // begin inline asm + ld.global.nc.v4.f32 {%r306,%r307,%r308,%r309}, [%rd81]; + // end inline asm + fma.rn.f32 %r699, %r674, %r302, %r666; + fma.rn.f32 %r700, %r673, %r303, %r699; + fma.rn.f32 %r701, %r672, %r304, %r700; + fma.rn.f32 %r702, %r671, %r305, %r701; + fma.rn.f32 %r703, %r670, %r306, %r702; + fma.rn.f32 %r704, %r669, %r307, %r703; + fma.rn.f32 %r705, %r668, %r308, %r704; + fma.rn.f32 %r706, %r667, %r309, %r705; + add.s64 %rd82, %rd10, 4096; + // begin inline asm + ld.global.nc.v4.u32 {%r310,%r311,%r312,%r313}, [%rd82]; + // end inline asm + and.b32 %r707, %r313, -65536; + shl.b32 %r708, %r313, 16; + and.b32 %r709, %r312, -65536; + shl.b32 %r710, %r312, 16; + and.b32 %r711, %r311, -65536; + shl.b32 %r712, %r311, 16; + and.b32 %r713, %r310, -65536; + shl.b32 %r714, %r310, 16; + add.s64 %rd83, %rd11, 8192; + // begin inline asm + ld.global.nc.v4.f32 {%r314,%r315,%r316,%r317}, [%rd83]; + // end inline asm + add.s64 %rd84, %rd11, 8208; + // begin inline asm + ld.global.nc.v4.f32 {%r318,%r319,%r320,%r321}, [%rd84]; + // end inline asm + fma.rn.f32 %r715, %r714, %r314, %r682; + fma.rn.f32 %r716, %r713, %r315, %r715; + fma.rn.f32 %r717, %r712, %r316, %r716; + fma.rn.f32 %r718, %r711, %r317, %r717; + fma.rn.f32 %r719, %r710, %r318, %r718; + fma.rn.f32 %r720, %r709, %r319, %r719; + fma.rn.f32 %r721, %r708, %r320, %r720; + fma.rn.f32 %r722, %r707, %r321, %r721; + add.s64 %rd85, %rd11, 18432; + // begin inline asm + ld.global.nc.v4.f32 {%r322,%r323,%r324,%r325}, [%rd85]; + // end inline asm + add.s64 %rd86, %rd11, 18448; + // begin inline asm + ld.global.nc.v4.f32 {%r326,%r327,%r328,%r329}, [%rd86]; + // end inline asm + fma.rn.f32 %r723, %r714, %r322, %r690; + fma.rn.f32 %r724, %r713, %r323, %r723; + fma.rn.f32 %r725, %r712, %r324, %r724; + fma.rn.f32 %r726, %r711, %r325, %r725; + fma.rn.f32 %r727, %r710, %r326, %r726; + fma.rn.f32 %r728, %r709, %r327, %r727; + fma.rn.f32 %r729, %r708, %r328, %r728; + fma.rn.f32 %r730, %r707, %r329, %r729; + add.s64 %rd87, %rd11, 28672; + // begin inline asm + ld.global.nc.v4.f32 {%r330,%r331,%r332,%r333}, [%rd87]; + // end inline asm + add.s64 %rd88, %rd11, 28688; + // begin inline asm + ld.global.nc.v4.f32 {%r334,%r335,%r336,%r337}, [%rd88]; + // end inline asm + fma.rn.f32 %r731, %r714, %r330, %r698; + fma.rn.f32 %r732, %r713, %r331, %r731; + fma.rn.f32 %r733, %r712, %r332, %r732; + fma.rn.f32 %r734, %r711, %r333, %r733; + fma.rn.f32 %r735, %r710, %r334, %r734; + fma.rn.f32 %r736, %r709, %r335, %r735; + fma.rn.f32 %r737, %r708, %r336, %r736; + fma.rn.f32 %r738, %r707, %r337, %r737; + add.s64 %rd89, %rd11, 38912; + // begin inline asm + ld.global.nc.v4.f32 {%r338,%r339,%r340,%r341}, [%rd89]; + // end inline asm + add.s64 %rd90, %rd11, 38928; + // begin inline asm + ld.global.nc.v4.f32 {%r342,%r343,%r344,%r345}, [%rd90]; + // end inline asm + fma.rn.f32 %r739, %r714, %r338, %r706; + fma.rn.f32 %r740, %r713, %r339, %r739; + fma.rn.f32 %r741, %r712, %r340, %r740; + fma.rn.f32 %r742, %r711, %r341, %r741; + fma.rn.f32 %r743, %r710, %r342, %r742; + fma.rn.f32 %r744, %r709, %r343, %r743; + fma.rn.f32 %r745, %r708, %r344, %r744; + fma.rn.f32 %r746, %r707, %r345, %r745; + add.s64 %rd91, %rd10, 4608; + // begin inline asm + ld.global.nc.v4.u32 {%r346,%r347,%r348,%r349}, [%rd91]; + // end inline asm + and.b32 %r747, %r349, -65536; + shl.b32 %r748, %r349, 16; + and.b32 %r749, %r348, -65536; + shl.b32 %r750, %r348, 16; + and.b32 %r751, %r347, -65536; + shl.b32 %r752, %r347, 16; + and.b32 %r753, %r346, -65536; + shl.b32 %r754, %r346, 16; + add.s64 %rd92, %rd11, 9216; + // begin inline asm + ld.global.nc.v4.f32 {%r350,%r351,%r352,%r353}, [%rd92]; + // end inline asm + add.s64 %rd93, %rd11, 9232; + // begin inline asm + ld.global.nc.v4.f32 {%r354,%r355,%r356,%r357}, [%rd93]; + // end inline asm + fma.rn.f32 %r755, %r754, %r350, %r722; + fma.rn.f32 %r756, %r753, %r351, %r755; + fma.rn.f32 %r757, %r752, %r352, %r756; + fma.rn.f32 %r758, %r751, %r353, %r757; + fma.rn.f32 %r759, %r750, %r354, %r758; + fma.rn.f32 %r760, %r749, %r355, %r759; + fma.rn.f32 %r761, %r748, %r356, %r760; + fma.rn.f32 %r762, %r747, %r357, %r761; + add.s64 %rd94, %rd11, 19456; + // begin inline asm + ld.global.nc.v4.f32 {%r358,%r359,%r360,%r361}, [%rd94]; + // end inline asm + add.s64 %rd95, %rd11, 19472; + // begin inline asm + ld.global.nc.v4.f32 {%r362,%r363,%r364,%r365}, [%rd95]; + // end inline asm + fma.rn.f32 %r763, %r754, %r358, %r730; + fma.rn.f32 %r764, %r753, %r359, %r763; + fma.rn.f32 %r765, %r752, %r360, %r764; + fma.rn.f32 %r766, %r751, %r361, %r765; + fma.rn.f32 %r767, %r750, %r362, %r766; + fma.rn.f32 %r768, %r749, %r363, %r767; + fma.rn.f32 %r769, %r748, %r364, %r768; + fma.rn.f32 %r4, %r747, %r365, %r769; + add.s64 %rd96, %rd11, 29696; + // begin inline asm + ld.global.nc.v4.f32 {%r366,%r367,%r368,%r369}, [%rd96]; + // end inline asm + add.s64 %rd97, %rd11, 29712; + // begin inline asm + ld.global.nc.v4.f32 {%r370,%r371,%r372,%r373}, [%rd97]; + // end inline asm + fma.rn.f32 %r770, %r754, %r366, %r738; + fma.rn.f32 %r771, %r753, %r367, %r770; + fma.rn.f32 %r772, %r752, %r368, %r771; + fma.rn.f32 %r773, %r751, %r369, %r772; + fma.rn.f32 %r774, %r750, %r370, %r773; + fma.rn.f32 %r775, %r749, %r371, %r774; + fma.rn.f32 %r776, %r748, %r372, %r775; + fma.rn.f32 %r5, %r747, %r373, %r776; + add.s64 %rd98, %rd11, 39936; + // begin inline asm + ld.global.nc.v4.f32 {%r374,%r375,%r376,%r377}, [%rd98]; + // end inline asm + add.s64 %rd99, %rd11, 39952; + // begin inline asm + ld.global.nc.v4.f32 {%r378,%r379,%r380,%r381}, [%rd99]; + // end inline asm + fma.rn.f32 %r777, %r754, %r374, %r746; + fma.rn.f32 %r778, %r753, %r375, %r777; + fma.rn.f32 %r779, %r752, %r376, %r778; + fma.rn.f32 %r780, %r751, %r377, %r779; + fma.rn.f32 %r781, %r750, %r378, %r780; + fma.rn.f32 %r782, %r749, %r379, %r781; + fma.rn.f32 %r783, %r748, %r380, %r782; + fma.rn.f32 %r6, %r747, %r381, %r783; + setp.ne.b32 %p3, %r3, 0; + mul.wide.s32 %rd108, %r383, 4; + add.s64 %rd2, %rd100, %rd108; + add.s64 %rd3, %rd101, %rd108; + cvt.s64.s32 %rd4, %r16; + shfl.sync.bfly.b32 %r784|%p4, %r762, 16, 31, -1; + add.f32 %r785, %r762, %r784; + shfl.sync.bfly.b32 %r786|%p5, %r785, 8, 31, -1; + add.f32 %r787, %r785, %r786; + shfl.sync.bfly.b32 %r788|%p6, %r787, 4, 31, -1; + add.f32 %r789, %r787, %r788; + shfl.sync.bfly.b32 %r790|%p7, %r789, 2, 31, -1; + add.f32 %r791, %r789, %r790; + shfl.sync.bfly.b32 %r792|%p8, %r791, 1, 31, -1; + add.f32 %r7, %r791, %r792; + @%p3 bra $L__BB4_9; + setp.lt.s32 %p9, %r2, %r16; + @%p9 bra $L__BB4_4; + mul.f32 %r793, %r7, 0fBFB8AA3B; + ex2.approx.f32 %r794, %r793; + add.f32 %r795, %r794, 0f3F800000; + rcp.rn.f32 %r932, %r795; + mov.b64 %rd126, %rd9; + bra.uni $L__BB4_8; +$L__BB4_4: + ld.global.nc.b32 %r796, [%rd2]; + add.f32 %r931, %r7, %r796; + setp.gt.f32 %p10, %r931, 0f41A00000; + @%p10 bra $L__BB4_7; + mul.f32 %r797, %r931, 0f3FB8AA3B; + ex2.approx.f32 %r8, %r797; + mov.b32 %r798, 0f3F800000; + add.rz.f32 %r799, %r8, %r798; + add.s32 %r800, %r799, -1061158912; + and.b32 %r801, %r800, -8388608; + sub.s32 %r802, %r8, %r801; + sub.s32 %r803, 1082130432, %r801; + fma.rn.f32 %r804, %r803, 0f3E800000, 0fBF800000; + add.f32 %r805, %r804, %r802; + cvt.rn.f32.s32 %r806, %r801; + mul.f32 %r807, %r806, 0f34000000; + fma.rn.f32 %r808, %r805, 0fBD39BF78, 0f3DD80012; + fma.rn.f32 %r809, %r808, %r805, 0fBE0778E0; + fma.rn.f32 %r810, %r809, %r805, 0f3E146475; + fma.rn.f32 %r811, %r810, %r805, 0fBE2A68DD; + fma.rn.f32 %r812, %r811, %r805, 0f3E4CAF9E; + fma.rn.f32 %r813, %r812, %r805, 0fBE800042; + fma.rn.f32 %r814, %r813, %r805, 0f3EAAAAE6; + fma.rn.f32 %r815, %r814, %r805, 0fBF000000; + mul.f32 %r816, %r805, %r815; + fma.rn.f32 %r817, %r816, %r805, %r805; + fma.rn.f32 %r931, %r807, 0f3F317218, %r817; + setp.lt.u32 %p11, %r8, 2139095040; + @%p11 bra $L__BB4_7; + setp.gt.s32 %p12, %r8, -1082130432; + fma.rn.f32 %r818, %r8, 0f7F800000, 0f7F800000; + selp.f32 %r819, %r818, %r931, %p12; + setp.eq.f32 %p13, %r8, 0f00000000; + selp.f32 %r931, 0f80000000, %r819, %p13; +$L__BB4_7: + ld.global.nc.b32 %r820, [%rd3]; + mul.f32 %r932, %r820, %r931; + mov.b64 %rd126, %rd129; +$L__BB4_8: + cvta.to.global.u64 %rd109, %rd126; + shl.b64 %rd110, %rd1, 2; + add.s64 %rd111, %rd109, %rd110; + st.global.b32 [%rd111], %r932; +$L__BB4_9: + setp.ne.b32 %p14, %r3, 0; + shfl.sync.bfly.b32 %r821|%p15, %r4, 16, 31, -1; + add.f32 %r822, %r4, %r821; + shfl.sync.bfly.b32 %r823|%p16, %r822, 8, 31, -1; + add.f32 %r824, %r822, %r823; + shfl.sync.bfly.b32 %r825|%p17, %r824, 4, 31, -1; + add.f32 %r826, %r824, %r825; + shfl.sync.bfly.b32 %r827|%p18, %r826, 2, 31, -1; + add.f32 %r828, %r826, %r827; + shfl.sync.bfly.b32 %r829|%p19, %r828, 1, 31, -1; + add.f32 %r9, %r828, %r829; + @%p14 bra $L__BB4_17; + setp.lt.s32 %p20, %r2, %r16; + @%p20 bra $L__BB4_12; + mul.f32 %r830, %r9, 0fBFB8AA3B; + ex2.approx.f32 %r831, %r830; + add.f32 %r832, %r831, 0f3F800000; + rcp.rn.f32 %r934, %r832; + mov.b64 %rd127, %rd9; + bra.uni $L__BB4_16; +$L__BB4_12: + ld.global.nc.b32 %r833, [%rd2]; + add.f32 %r933, %r9, %r833; + setp.gt.f32 %p21, %r933, 0f41A00000; + @%p21 bra $L__BB4_15; + mul.f32 %r834, %r933, 0f3FB8AA3B; + ex2.approx.f32 %r10, %r834; + mov.b32 %r835, 0f3F800000; + add.rz.f32 %r836, %r10, %r835; + add.s32 %r837, %r836, -1061158912; + and.b32 %r838, %r837, -8388608; + sub.s32 %r839, %r10, %r838; + sub.s32 %r840, 1082130432, %r838; + fma.rn.f32 %r841, %r840, 0f3E800000, 0fBF800000; + add.f32 %r842, %r841, %r839; + cvt.rn.f32.s32 %r843, %r838; + mul.f32 %r844, %r843, 0f34000000; + fma.rn.f32 %r845, %r842, 0fBD39BF78, 0f3DD80012; + fma.rn.f32 %r846, %r845, %r842, 0fBE0778E0; + fma.rn.f32 %r847, %r846, %r842, 0f3E146475; + fma.rn.f32 %r848, %r847, %r842, 0fBE2A68DD; + fma.rn.f32 %r849, %r848, %r842, 0f3E4CAF9E; + fma.rn.f32 %r850, %r849, %r842, 0fBE800042; + fma.rn.f32 %r851, %r850, %r842, 0f3EAAAAE6; + fma.rn.f32 %r852, %r851, %r842, 0fBF000000; + mul.f32 %r853, %r842, %r852; + fma.rn.f32 %r854, %r853, %r842, %r842; + fma.rn.f32 %r933, %r844, 0f3F317218, %r854; + setp.lt.u32 %p22, %r10, 2139095040; + @%p22 bra $L__BB4_15; + setp.gt.s32 %p23, %r10, -1082130432; + fma.rn.f32 %r855, %r10, 0f7F800000, 0f7F800000; + selp.f32 %r856, %r855, %r933, %p23; + setp.eq.f32 %p24, %r10, 0f00000000; + selp.f32 %r933, 0f80000000, %r856, %p24; +$L__BB4_15: + ld.global.nc.b32 %r857, [%rd3]; + mul.f32 %r934, %r857, %r933; + mov.b64 %rd127, %rd129; +$L__BB4_16: + cvta.to.global.u64 %rd112, %rd127; + add.s64 %rd113, %rd4, %rd1; + shl.b64 %rd114, %rd113, 2; + add.s64 %rd115, %rd112, %rd114; + st.global.b32 [%rd115], %r934; +$L__BB4_17: + setp.ne.b32 %p25, %r3, 0; + shfl.sync.bfly.b32 %r858|%p26, %r5, 16, 31, -1; + add.f32 %r859, %r5, %r858; + shfl.sync.bfly.b32 %r860|%p27, %r859, 8, 31, -1; + add.f32 %r861, %r859, %r860; + shfl.sync.bfly.b32 %r862|%p28, %r861, 4, 31, -1; + add.f32 %r863, %r861, %r862; + shfl.sync.bfly.b32 %r864|%p29, %r863, 2, 31, -1; + add.f32 %r865, %r863, %r864; + shfl.sync.bfly.b32 %r866|%p30, %r865, 1, 31, -1; + add.f32 %r11, %r865, %r866; + @%p25 bra $L__BB4_25; + setp.lt.s32 %p31, %r2, %r16; + @%p31 bra $L__BB4_20; + mul.f32 %r867, %r11, 0fBFB8AA3B; + ex2.approx.f32 %r868, %r867; + add.f32 %r869, %r868, 0f3F800000; + rcp.rn.f32 %r936, %r869; + mov.b64 %rd128, %rd9; + bra.uni $L__BB4_24; +$L__BB4_20: + ld.global.nc.b32 %r870, [%rd2]; + add.f32 %r935, %r11, %r870; + setp.gt.f32 %p32, %r935, 0f41A00000; + @%p32 bra $L__BB4_23; + mul.f32 %r871, %r935, 0f3FB8AA3B; + ex2.approx.f32 %r12, %r871; + mov.b32 %r872, 0f3F800000; + add.rz.f32 %r873, %r12, %r872; + add.s32 %r874, %r873, -1061158912; + and.b32 %r875, %r874, -8388608; + sub.s32 %r876, %r12, %r875; + sub.s32 %r877, 1082130432, %r875; + fma.rn.f32 %r878, %r877, 0f3E800000, 0fBF800000; + add.f32 %r879, %r878, %r876; + cvt.rn.f32.s32 %r880, %r875; + mul.f32 %r881, %r880, 0f34000000; + fma.rn.f32 %r882, %r879, 0fBD39BF78, 0f3DD80012; + fma.rn.f32 %r883, %r882, %r879, 0fBE0778E0; + fma.rn.f32 %r884, %r883, %r879, 0f3E146475; + fma.rn.f32 %r885, %r884, %r879, 0fBE2A68DD; + fma.rn.f32 %r886, %r885, %r879, 0f3E4CAF9E; + fma.rn.f32 %r887, %r886, %r879, 0fBE800042; + fma.rn.f32 %r888, %r887, %r879, 0f3EAAAAE6; + fma.rn.f32 %r889, %r888, %r879, 0fBF000000; + mul.f32 %r890, %r879, %r889; + fma.rn.f32 %r891, %r890, %r879, %r879; + fma.rn.f32 %r935, %r881, 0f3F317218, %r891; + setp.lt.u32 %p33, %r12, 2139095040; + @%p33 bra $L__BB4_23; + setp.gt.s32 %p34, %r12, -1082130432; + fma.rn.f32 %r892, %r12, 0f7F800000, 0f7F800000; + selp.f32 %r893, %r892, %r935, %p34; + setp.eq.f32 %p35, %r12, 0f00000000; + selp.f32 %r935, 0f80000000, %r893, %p35; +$L__BB4_23: + ld.global.nc.b32 %r894, [%rd3]; + mul.f32 %r936, %r894, %r935; + mov.b64 %rd128, %rd129; +$L__BB4_24: + cvta.to.global.u64 %rd116, %rd128; + shl.b64 %rd117, %rd4, 1; + add.s64 %rd118, %rd117, %rd1; + shl.b64 %rd119, %rd118, 2; + add.s64 %rd120, %rd116, %rd119; + st.global.b32 [%rd120], %r936; +$L__BB4_25: + setp.ne.b32 %p36, %r3, 0; + shfl.sync.bfly.b32 %r895|%p37, %r6, 16, 31, -1; + add.f32 %r896, %r6, %r895; + shfl.sync.bfly.b32 %r897|%p38, %r896, 8, 31, -1; + add.f32 %r898, %r896, %r897; + shfl.sync.bfly.b32 %r899|%p39, %r898, 4, 31, -1; + add.f32 %r900, %r898, %r899; + shfl.sync.bfly.b32 %r901|%p40, %r900, 2, 31, -1; + add.f32 %r902, %r900, %r901; + shfl.sync.bfly.b32 %r903|%p41, %r902, 1, 31, -1; + add.f32 %r13, %r902, %r903; + @%p36 bra $L__BB4_33; + setp.lt.s32 %p42, %r2, %r16; + ld.global.nc.b32 %r14, [%rd3]; + @%p42 bra $L__BB4_28; + mul.f32 %r904, %r13, 0fBFB8AA3B; + ex2.approx.f32 %r905, %r904; + add.f32 %r906, %r905, 0f3F800000; + rcp.rn.f32 %r938, %r906; + mov.b64 %rd129, %rd9; + bra.uni $L__BB4_32; +$L__BB4_28: + ld.global.nc.b32 %r907, [%rd2]; + add.f32 %r937, %r13, %r907; + setp.gt.f32 %p43, %r937, 0f41A00000; + @%p43 bra $L__BB4_31; + mul.f32 %r908, %r937, 0f3FB8AA3B; + ex2.approx.f32 %r15, %r908; + mov.b32 %r909, 0f3F800000; + add.rz.f32 %r910, %r15, %r909; + add.s32 %r911, %r910, -1061158912; + and.b32 %r912, %r911, -8388608; + sub.s32 %r913, %r15, %r912; + sub.s32 %r914, 1082130432, %r912; + fma.rn.f32 %r915, %r914, 0f3E800000, 0fBF800000; + add.f32 %r916, %r915, %r913; + cvt.rn.f32.s32 %r917, %r912; + mul.f32 %r918, %r917, 0f34000000; + fma.rn.f32 %r919, %r916, 0fBD39BF78, 0f3DD80012; + fma.rn.f32 %r920, %r919, %r916, 0fBE0778E0; + fma.rn.f32 %r921, %r920, %r916, 0f3E146475; + fma.rn.f32 %r922, %r921, %r916, 0fBE2A68DD; + fma.rn.f32 %r923, %r922, %r916, 0f3E4CAF9E; + fma.rn.f32 %r924, %r923, %r916, 0fBE800042; + fma.rn.f32 %r925, %r924, %r916, 0f3EAAAAE6; + fma.rn.f32 %r926, %r925, %r916, 0fBF000000; + mul.f32 %r927, %r916, %r926; + fma.rn.f32 %r928, %r927, %r916, %r916; + fma.rn.f32 %r937, %r918, 0f3F317218, %r928; + setp.lt.u32 %p44, %r15, 2139095040; + @%p44 bra $L__BB4_31; + setp.gt.s32 %p45, %r15, -1082130432; + fma.rn.f32 %r929, %r15, 0f7F800000, 0f7F800000; + selp.f32 %r930, %r929, %r937, %p45; + setp.eq.f32 %p46, %r15, 0f00000000; + selp.f32 %r937, 0f80000000, %r930, %p46; +$L__BB4_31: + mul.f32 %r938, %r14, %r937; +$L__BB4_32: + cvta.to.global.u64 %rd121, %rd129; + mad.lo.s64 %rd122, %rd4, 3, %rd1; + shl.b64 %rd123, %rd122, 2; + add.s64 %rd124, %rd121, %rd123; + st.global.b32 [%rd124], %r938; +$L__BB4_33: + ret; + +} + // .globl leleka_gdn_ab_unrolled_t5 +.visible .entry leleka_gdn_ab_unrolled_t5( + .param .u64 .ptr .align 1 leleka_gdn_ab_unrolled_t5_param_0, + .param .u64 .ptr .align 1 leleka_gdn_ab_unrolled_t5_param_1, + .param .u64 .ptr .align 1 leleka_gdn_ab_unrolled_t5_param_2, + .param .u64 .ptr .align 1 leleka_gdn_ab_unrolled_t5_param_3, + .param .u64 .ptr .align 1 leleka_gdn_ab_unrolled_t5_param_4, + .param .u64 .ptr .align 1 leleka_gdn_ab_unrolled_t5_param_5, + .param .u64 .ptr .align 1 leleka_gdn_ab_unrolled_t5_param_6, + .param .u32 leleka_gdn_ab_unrolled_t5_param_7, + .param .u32 leleka_gdn_ab_unrolled_t5_param_8, + .param .u32 leleka_gdn_ab_unrolled_t5_param_9 +) +.maxntid 64 +{ + .reg .pred %p<58>; + .reg .b32 %r<1140>; + .reg .b64 %rd<156>; + + ld.param.b64 %rd5, [leleka_gdn_ab_unrolled_t5_param_1]; + ld.param.b64 %rd6, [leleka_gdn_ab_unrolled_t5_param_3]; + ld.param.b64 %rd7, [leleka_gdn_ab_unrolled_t5_param_4]; + ld.param.b64 %rd155, [leleka_gdn_ab_unrolled_t5_param_5]; + ld.param.b64 %rd8, [leleka_gdn_ab_unrolled_t5_param_6]; + ld.param.b32 %r19, [leleka_gdn_ab_unrolled_t5_param_8]; + mov.u32 %r20, %ctaid.x; + mov.u32 %r21, %ntid.x; + shr.u32 %r22, %r21, 5; + mov.u32 %r1, %tid.x; + shr.u32 %r23, %r1, 5; + mad.lo.s32 %r2, %r22, %r20, %r23; + shl.b32 %r24, %r19, 1; + setp.ge.s32 %p1, %r2, %r24; + @%p1 bra $L__BB5_41; + ld.param.b64 %rd150, [leleka_gdn_ab_unrolled_t5_param_2]; + ld.param.b64 %rd149, [leleka_gdn_ab_unrolled_t5_param_0]; + and.b32 %r3, %r1, 31; + cvta.to.global.u64 %rd119, %rd6; + cvta.to.global.u64 %rd120, %rd7; + setp.lt.s32 %p2, %r2, %r19; + selp.b32 %r465, 0, %r19, %p2; + sub.s32 %r466, %r2, %r465; + selp.b64 %rd121, %rd5, %rd150, %p2; + cvt.s64.s32 %rd1, %r466; + mul.wide.s32 %rd122, %r466, 5120; + add.s64 %rd123, %rd121, %rd122; + shl.b32 %r467, %r1, 4; + cvt.u64.u32 %rd124, %r467; + and.b64 %rd125, %rd124, 496; + add.s64 %rd9, %rd123, %rd125; + // begin inline asm + ld.global.nc.v4.u32 {%r25,%r26,%r27,%r28}, [%rd9]; + // end inline asm + and.b32 %r468, %r28, -65536; + shl.b32 %r469, %r28, 16; + and.b32 %r470, %r27, -65536; + shl.b32 %r471, %r27, 16; + and.b32 %r472, %r26, -65536; + shl.b32 %r473, %r26, 16; + and.b32 %r474, %r25, -65536; + shl.b32 %r475, %r25, 16; + shl.b32 %r476, %r1, 3; + and.b32 %r477, %r476, 248; + mul.wide.u32 %rd126, %r477, 4; + add.s64 %rd10, %rd149, %rd126; + // begin inline asm + ld.global.nc.v4.f32 {%r29,%r30,%r31,%r32}, [%rd10]; + // end inline asm + add.s64 %rd11, %rd10, 16; + // begin inline asm + ld.global.nc.v4.f32 {%r33,%r34,%r35,%r36}, [%rd11]; + // end inline asm + fma.rn.f32 %r478, %r475, %r29, 0f00000000; + fma.rn.f32 %r479, %r474, %r30, %r478; + fma.rn.f32 %r480, %r473, %r31, %r479; + fma.rn.f32 %r481, %r472, %r32, %r480; + fma.rn.f32 %r482, %r471, %r33, %r481; + fma.rn.f32 %r483, %r470, %r34, %r482; + fma.rn.f32 %r484, %r469, %r35, %r483; + fma.rn.f32 %r485, %r468, %r36, %r484; + add.s64 %rd12, %rd10, 10240; + // begin inline asm + ld.global.nc.v4.f32 {%r37,%r38,%r39,%r40}, [%rd12]; + // end inline asm + add.s64 %rd13, %rd10, 10256; + // begin inline asm + ld.global.nc.v4.f32 {%r41,%r42,%r43,%r44}, [%rd13]; + // end inline asm + fma.rn.f32 %r486, %r475, %r37, 0f00000000; + fma.rn.f32 %r487, %r474, %r38, %r486; + fma.rn.f32 %r488, %r473, %r39, %r487; + fma.rn.f32 %r489, %r472, %r40, %r488; + fma.rn.f32 %r490, %r471, %r41, %r489; + fma.rn.f32 %r491, %r470, %r42, %r490; + fma.rn.f32 %r492, %r469, %r43, %r491; + fma.rn.f32 %r493, %r468, %r44, %r492; + add.s64 %rd14, %rd10, 20480; + // begin inline asm + ld.global.nc.v4.f32 {%r45,%r46,%r47,%r48}, [%rd14]; + // end inline asm + add.s64 %rd15, %rd10, 20496; + // begin inline asm + ld.global.nc.v4.f32 {%r49,%r50,%r51,%r52}, [%rd15]; + // end inline asm + fma.rn.f32 %r494, %r475, %r45, 0f00000000; + fma.rn.f32 %r495, %r474, %r46, %r494; + fma.rn.f32 %r496, %r473, %r47, %r495; + fma.rn.f32 %r497, %r472, %r48, %r496; + fma.rn.f32 %r498, %r471, %r49, %r497; + fma.rn.f32 %r499, %r470, %r50, %r498; + fma.rn.f32 %r500, %r469, %r51, %r499; + fma.rn.f32 %r501, %r468, %r52, %r500; + add.s64 %rd16, %rd10, 30720; + // begin inline asm + ld.global.nc.v4.f32 {%r53,%r54,%r55,%r56}, [%rd16]; + // end inline asm + add.s64 %rd17, %rd10, 30736; + // begin inline asm + ld.global.nc.v4.f32 {%r57,%r58,%r59,%r60}, [%rd17]; + // end inline asm + fma.rn.f32 %r502, %r475, %r53, 0f00000000; + fma.rn.f32 %r503, %r474, %r54, %r502; + fma.rn.f32 %r504, %r473, %r55, %r503; + fma.rn.f32 %r505, %r472, %r56, %r504; + fma.rn.f32 %r506, %r471, %r57, %r505; + fma.rn.f32 %r507, %r470, %r58, %r506; + fma.rn.f32 %r508, %r469, %r59, %r507; + fma.rn.f32 %r509, %r468, %r60, %r508; + add.s64 %rd18, %rd10, 40960; + // begin inline asm + ld.global.nc.v4.f32 {%r61,%r62,%r63,%r64}, [%rd18]; + // end inline asm + add.s64 %rd19, %rd10, 40976; + // begin inline asm + ld.global.nc.v4.f32 {%r65,%r66,%r67,%r68}, [%rd19]; + // end inline asm + fma.rn.f32 %r510, %r475, %r61, 0f00000000; + fma.rn.f32 %r511, %r474, %r62, %r510; + fma.rn.f32 %r512, %r473, %r63, %r511; + fma.rn.f32 %r513, %r472, %r64, %r512; + fma.rn.f32 %r514, %r471, %r65, %r513; + fma.rn.f32 %r515, %r470, %r66, %r514; + fma.rn.f32 %r516, %r469, %r67, %r515; + fma.rn.f32 %r517, %r468, %r68, %r516; + add.s64 %rd20, %rd9, 512; + // begin inline asm + ld.global.nc.v4.u32 {%r69,%r70,%r71,%r72}, [%rd20]; + // end inline asm + and.b32 %r518, %r72, -65536; + shl.b32 %r519, %r72, 16; + and.b32 %r520, %r71, -65536; + shl.b32 %r521, %r71, 16; + and.b32 %r522, %r70, -65536; + shl.b32 %r523, %r70, 16; + and.b32 %r524, %r69, -65536; + shl.b32 %r525, %r69, 16; + add.s64 %rd21, %rd10, 1024; + // begin inline asm + ld.global.nc.v4.f32 {%r73,%r74,%r75,%r76}, [%rd21]; + // end inline asm + add.s64 %rd22, %rd10, 1040; + // begin inline asm + ld.global.nc.v4.f32 {%r77,%r78,%r79,%r80}, [%rd22]; + // end inline asm + fma.rn.f32 %r526, %r525, %r73, %r485; + fma.rn.f32 %r527, %r524, %r74, %r526; + fma.rn.f32 %r528, %r523, %r75, %r527; + fma.rn.f32 %r529, %r522, %r76, %r528; + fma.rn.f32 %r530, %r521, %r77, %r529; + fma.rn.f32 %r531, %r520, %r78, %r530; + fma.rn.f32 %r532, %r519, %r79, %r531; + fma.rn.f32 %r533, %r518, %r80, %r532; + add.s64 %rd23, %rd10, 11264; + // begin inline asm + ld.global.nc.v4.f32 {%r81,%r82,%r83,%r84}, [%rd23]; + // end inline asm + add.s64 %rd24, %rd10, 11280; + // begin inline asm + ld.global.nc.v4.f32 {%r85,%r86,%r87,%r88}, [%rd24]; + // end inline asm + fma.rn.f32 %r534, %r525, %r81, %r493; + fma.rn.f32 %r535, %r524, %r82, %r534; + fma.rn.f32 %r536, %r523, %r83, %r535; + fma.rn.f32 %r537, %r522, %r84, %r536; + fma.rn.f32 %r538, %r521, %r85, %r537; + fma.rn.f32 %r539, %r520, %r86, %r538; + fma.rn.f32 %r540, %r519, %r87, %r539; + fma.rn.f32 %r541, %r518, %r88, %r540; + add.s64 %rd25, %rd10, 21504; + // begin inline asm + ld.global.nc.v4.f32 {%r89,%r90,%r91,%r92}, [%rd25]; + // end inline asm + add.s64 %rd26, %rd10, 21520; + // begin inline asm + ld.global.nc.v4.f32 {%r93,%r94,%r95,%r96}, [%rd26]; + // end inline asm + fma.rn.f32 %r542, %r525, %r89, %r501; + fma.rn.f32 %r543, %r524, %r90, %r542; + fma.rn.f32 %r544, %r523, %r91, %r543; + fma.rn.f32 %r545, %r522, %r92, %r544; + fma.rn.f32 %r546, %r521, %r93, %r545; + fma.rn.f32 %r547, %r520, %r94, %r546; + fma.rn.f32 %r548, %r519, %r95, %r547; + fma.rn.f32 %r549, %r518, %r96, %r548; + add.s64 %rd27, %rd10, 31744; + // begin inline asm + ld.global.nc.v4.f32 {%r97,%r98,%r99,%r100}, [%rd27]; + // end inline asm + add.s64 %rd28, %rd10, 31760; + // begin inline asm + ld.global.nc.v4.f32 {%r101,%r102,%r103,%r104}, [%rd28]; + // end inline asm + fma.rn.f32 %r550, %r525, %r97, %r509; + fma.rn.f32 %r551, %r524, %r98, %r550; + fma.rn.f32 %r552, %r523, %r99, %r551; + fma.rn.f32 %r553, %r522, %r100, %r552; + fma.rn.f32 %r554, %r521, %r101, %r553; + fma.rn.f32 %r555, %r520, %r102, %r554; + fma.rn.f32 %r556, %r519, %r103, %r555; + fma.rn.f32 %r557, %r518, %r104, %r556; + add.s64 %rd29, %rd10, 41984; + // begin inline asm + ld.global.nc.v4.f32 {%r105,%r106,%r107,%r108}, [%rd29]; + // end inline asm + add.s64 %rd30, %rd10, 42000; + // begin inline asm + ld.global.nc.v4.f32 {%r109,%r110,%r111,%r112}, [%rd30]; + // end inline asm + fma.rn.f32 %r558, %r525, %r105, %r517; + fma.rn.f32 %r559, %r524, %r106, %r558; + fma.rn.f32 %r560, %r523, %r107, %r559; + fma.rn.f32 %r561, %r522, %r108, %r560; + fma.rn.f32 %r562, %r521, %r109, %r561; + fma.rn.f32 %r563, %r520, %r110, %r562; + fma.rn.f32 %r564, %r519, %r111, %r563; + fma.rn.f32 %r565, %r518, %r112, %r564; + add.s64 %rd31, %rd9, 1024; + // begin inline asm + ld.global.nc.v4.u32 {%r113,%r114,%r115,%r116}, [%rd31]; + // end inline asm + and.b32 %r566, %r116, -65536; + shl.b32 %r567, %r116, 16; + and.b32 %r568, %r115, -65536; + shl.b32 %r569, %r115, 16; + and.b32 %r570, %r114, -65536; + shl.b32 %r571, %r114, 16; + and.b32 %r572, %r113, -65536; + shl.b32 %r573, %r113, 16; + add.s64 %rd32, %rd10, 2048; + // begin inline asm + ld.global.nc.v4.f32 {%r117,%r118,%r119,%r120}, [%rd32]; + // end inline asm + add.s64 %rd33, %rd10, 2064; + // begin inline asm + ld.global.nc.v4.f32 {%r121,%r122,%r123,%r124}, [%rd33]; + // end inline asm + fma.rn.f32 %r574, %r573, %r117, %r533; + fma.rn.f32 %r575, %r572, %r118, %r574; + fma.rn.f32 %r576, %r571, %r119, %r575; + fma.rn.f32 %r577, %r570, %r120, %r576; + fma.rn.f32 %r578, %r569, %r121, %r577; + fma.rn.f32 %r579, %r568, %r122, %r578; + fma.rn.f32 %r580, %r567, %r123, %r579; + fma.rn.f32 %r581, %r566, %r124, %r580; + add.s64 %rd34, %rd10, 12288; + // begin inline asm + ld.global.nc.v4.f32 {%r125,%r126,%r127,%r128}, [%rd34]; + // end inline asm + add.s64 %rd35, %rd10, 12304; + // begin inline asm + ld.global.nc.v4.f32 {%r129,%r130,%r131,%r132}, [%rd35]; + // end inline asm + fma.rn.f32 %r582, %r573, %r125, %r541; + fma.rn.f32 %r583, %r572, %r126, %r582; + fma.rn.f32 %r584, %r571, %r127, %r583; + fma.rn.f32 %r585, %r570, %r128, %r584; + fma.rn.f32 %r586, %r569, %r129, %r585; + fma.rn.f32 %r587, %r568, %r130, %r586; + fma.rn.f32 %r588, %r567, %r131, %r587; + fma.rn.f32 %r589, %r566, %r132, %r588; + add.s64 %rd36, %rd10, 22528; + // begin inline asm + ld.global.nc.v4.f32 {%r133,%r134,%r135,%r136}, [%rd36]; + // end inline asm + add.s64 %rd37, %rd10, 22544; + // begin inline asm + ld.global.nc.v4.f32 {%r137,%r138,%r139,%r140}, [%rd37]; + // end inline asm + fma.rn.f32 %r590, %r573, %r133, %r549; + fma.rn.f32 %r591, %r572, %r134, %r590; + fma.rn.f32 %r592, %r571, %r135, %r591; + fma.rn.f32 %r593, %r570, %r136, %r592; + fma.rn.f32 %r594, %r569, %r137, %r593; + fma.rn.f32 %r595, %r568, %r138, %r594; + fma.rn.f32 %r596, %r567, %r139, %r595; + fma.rn.f32 %r597, %r566, %r140, %r596; + add.s64 %rd38, %rd10, 32768; + // begin inline asm + ld.global.nc.v4.f32 {%r141,%r142,%r143,%r144}, [%rd38]; + // end inline asm + add.s64 %rd39, %rd10, 32784; + // begin inline asm + ld.global.nc.v4.f32 {%r145,%r146,%r147,%r148}, [%rd39]; + // end inline asm + fma.rn.f32 %r598, %r573, %r141, %r557; + fma.rn.f32 %r599, %r572, %r142, %r598; + fma.rn.f32 %r600, %r571, %r143, %r599; + fma.rn.f32 %r601, %r570, %r144, %r600; + fma.rn.f32 %r602, %r569, %r145, %r601; + fma.rn.f32 %r603, %r568, %r146, %r602; + fma.rn.f32 %r604, %r567, %r147, %r603; + fma.rn.f32 %r605, %r566, %r148, %r604; + add.s64 %rd40, %rd10, 43008; + // begin inline asm + ld.global.nc.v4.f32 {%r149,%r150,%r151,%r152}, [%rd40]; + // end inline asm + add.s64 %rd41, %rd10, 43024; + // begin inline asm + ld.global.nc.v4.f32 {%r153,%r154,%r155,%r156}, [%rd41]; + // end inline asm + fma.rn.f32 %r606, %r573, %r149, %r565; + fma.rn.f32 %r607, %r572, %r150, %r606; + fma.rn.f32 %r608, %r571, %r151, %r607; + fma.rn.f32 %r609, %r570, %r152, %r608; + fma.rn.f32 %r610, %r569, %r153, %r609; + fma.rn.f32 %r611, %r568, %r154, %r610; + fma.rn.f32 %r612, %r567, %r155, %r611; + fma.rn.f32 %r613, %r566, %r156, %r612; + add.s64 %rd42, %rd9, 1536; + // begin inline asm + ld.global.nc.v4.u32 {%r157,%r158,%r159,%r160}, [%rd42]; + // end inline asm + and.b32 %r614, %r160, -65536; + shl.b32 %r615, %r160, 16; + and.b32 %r616, %r159, -65536; + shl.b32 %r617, %r159, 16; + and.b32 %r618, %r158, -65536; + shl.b32 %r619, %r158, 16; + and.b32 %r620, %r157, -65536; + shl.b32 %r621, %r157, 16; + add.s64 %rd43, %rd10, 3072; + // begin inline asm + ld.global.nc.v4.f32 {%r161,%r162,%r163,%r164}, [%rd43]; + // end inline asm + add.s64 %rd44, %rd10, 3088; + // begin inline asm + ld.global.nc.v4.f32 {%r165,%r166,%r167,%r168}, [%rd44]; + // end inline asm + fma.rn.f32 %r622, %r621, %r161, %r581; + fma.rn.f32 %r623, %r620, %r162, %r622; + fma.rn.f32 %r624, %r619, %r163, %r623; + fma.rn.f32 %r625, %r618, %r164, %r624; + fma.rn.f32 %r626, %r617, %r165, %r625; + fma.rn.f32 %r627, %r616, %r166, %r626; + fma.rn.f32 %r628, %r615, %r167, %r627; + fma.rn.f32 %r629, %r614, %r168, %r628; + add.s64 %rd45, %rd10, 13312; + // begin inline asm + ld.global.nc.v4.f32 {%r169,%r170,%r171,%r172}, [%rd45]; + // end inline asm + add.s64 %rd46, %rd10, 13328; + // begin inline asm + ld.global.nc.v4.f32 {%r173,%r174,%r175,%r176}, [%rd46]; + // end inline asm + fma.rn.f32 %r630, %r621, %r169, %r589; + fma.rn.f32 %r631, %r620, %r170, %r630; + fma.rn.f32 %r632, %r619, %r171, %r631; + fma.rn.f32 %r633, %r618, %r172, %r632; + fma.rn.f32 %r634, %r617, %r173, %r633; + fma.rn.f32 %r635, %r616, %r174, %r634; + fma.rn.f32 %r636, %r615, %r175, %r635; + fma.rn.f32 %r637, %r614, %r176, %r636; + add.s64 %rd47, %rd10, 23552; + // begin inline asm + ld.global.nc.v4.f32 {%r177,%r178,%r179,%r180}, [%rd47]; + // end inline asm + add.s64 %rd48, %rd10, 23568; + // begin inline asm + ld.global.nc.v4.f32 {%r181,%r182,%r183,%r184}, [%rd48]; + // end inline asm + fma.rn.f32 %r638, %r621, %r177, %r597; + fma.rn.f32 %r639, %r620, %r178, %r638; + fma.rn.f32 %r640, %r619, %r179, %r639; + fma.rn.f32 %r641, %r618, %r180, %r640; + fma.rn.f32 %r642, %r617, %r181, %r641; + fma.rn.f32 %r643, %r616, %r182, %r642; + fma.rn.f32 %r644, %r615, %r183, %r643; + fma.rn.f32 %r645, %r614, %r184, %r644; + add.s64 %rd49, %rd10, 33792; + // begin inline asm + ld.global.nc.v4.f32 {%r185,%r186,%r187,%r188}, [%rd49]; + // end inline asm + add.s64 %rd50, %rd10, 33808; + // begin inline asm + ld.global.nc.v4.f32 {%r189,%r190,%r191,%r192}, [%rd50]; + // end inline asm + fma.rn.f32 %r646, %r621, %r185, %r605; + fma.rn.f32 %r647, %r620, %r186, %r646; + fma.rn.f32 %r648, %r619, %r187, %r647; + fma.rn.f32 %r649, %r618, %r188, %r648; + fma.rn.f32 %r650, %r617, %r189, %r649; + fma.rn.f32 %r651, %r616, %r190, %r650; + fma.rn.f32 %r652, %r615, %r191, %r651; + fma.rn.f32 %r653, %r614, %r192, %r652; + add.s64 %rd51, %rd10, 44032; + // begin inline asm + ld.global.nc.v4.f32 {%r193,%r194,%r195,%r196}, [%rd51]; + // end inline asm + add.s64 %rd52, %rd10, 44048; + // begin inline asm + ld.global.nc.v4.f32 {%r197,%r198,%r199,%r200}, [%rd52]; + // end inline asm + fma.rn.f32 %r654, %r621, %r193, %r613; + fma.rn.f32 %r655, %r620, %r194, %r654; + fma.rn.f32 %r656, %r619, %r195, %r655; + fma.rn.f32 %r657, %r618, %r196, %r656; + fma.rn.f32 %r658, %r617, %r197, %r657; + fma.rn.f32 %r659, %r616, %r198, %r658; + fma.rn.f32 %r660, %r615, %r199, %r659; + fma.rn.f32 %r661, %r614, %r200, %r660; + add.s64 %rd53, %rd9, 2048; + // begin inline asm + ld.global.nc.v4.u32 {%r201,%r202,%r203,%r204}, [%rd53]; + // end inline asm + and.b32 %r662, %r204, -65536; + shl.b32 %r663, %r204, 16; + and.b32 %r664, %r203, -65536; + shl.b32 %r665, %r203, 16; + and.b32 %r666, %r202, -65536; + shl.b32 %r667, %r202, 16; + and.b32 %r668, %r201, -65536; + shl.b32 %r669, %r201, 16; + add.s64 %rd54, %rd10, 4096; + // begin inline asm + ld.global.nc.v4.f32 {%r205,%r206,%r207,%r208}, [%rd54]; + // end inline asm + add.s64 %rd55, %rd10, 4112; + // begin inline asm + ld.global.nc.v4.f32 {%r209,%r210,%r211,%r212}, [%rd55]; + // end inline asm + fma.rn.f32 %r670, %r669, %r205, %r629; + fma.rn.f32 %r671, %r668, %r206, %r670; + fma.rn.f32 %r672, %r667, %r207, %r671; + fma.rn.f32 %r673, %r666, %r208, %r672; + fma.rn.f32 %r674, %r665, %r209, %r673; + fma.rn.f32 %r675, %r664, %r210, %r674; + fma.rn.f32 %r676, %r663, %r211, %r675; + fma.rn.f32 %r677, %r662, %r212, %r676; + add.s64 %rd56, %rd10, 14336; + // begin inline asm + ld.global.nc.v4.f32 {%r213,%r214,%r215,%r216}, [%rd56]; + // end inline asm + add.s64 %rd57, %rd10, 14352; + // begin inline asm + ld.global.nc.v4.f32 {%r217,%r218,%r219,%r220}, [%rd57]; + // end inline asm + fma.rn.f32 %r678, %r669, %r213, %r637; + fma.rn.f32 %r679, %r668, %r214, %r678; + fma.rn.f32 %r680, %r667, %r215, %r679; + fma.rn.f32 %r681, %r666, %r216, %r680; + fma.rn.f32 %r682, %r665, %r217, %r681; + fma.rn.f32 %r683, %r664, %r218, %r682; + fma.rn.f32 %r684, %r663, %r219, %r683; + fma.rn.f32 %r685, %r662, %r220, %r684; + add.s64 %rd58, %rd10, 24576; + // begin inline asm + ld.global.nc.v4.f32 {%r221,%r222,%r223,%r224}, [%rd58]; + // end inline asm + add.s64 %rd59, %rd10, 24592; + // begin inline asm + ld.global.nc.v4.f32 {%r225,%r226,%r227,%r228}, [%rd59]; + // end inline asm + fma.rn.f32 %r686, %r669, %r221, %r645; + fma.rn.f32 %r687, %r668, %r222, %r686; + fma.rn.f32 %r688, %r667, %r223, %r687; + fma.rn.f32 %r689, %r666, %r224, %r688; + fma.rn.f32 %r690, %r665, %r225, %r689; + fma.rn.f32 %r691, %r664, %r226, %r690; + fma.rn.f32 %r692, %r663, %r227, %r691; + fma.rn.f32 %r693, %r662, %r228, %r692; + add.s64 %rd60, %rd10, 34816; + // begin inline asm + ld.global.nc.v4.f32 {%r229,%r230,%r231,%r232}, [%rd60]; + // end inline asm + add.s64 %rd61, %rd10, 34832; + // begin inline asm + ld.global.nc.v4.f32 {%r233,%r234,%r235,%r236}, [%rd61]; + // end inline asm + fma.rn.f32 %r694, %r669, %r229, %r653; + fma.rn.f32 %r695, %r668, %r230, %r694; + fma.rn.f32 %r696, %r667, %r231, %r695; + fma.rn.f32 %r697, %r666, %r232, %r696; + fma.rn.f32 %r698, %r665, %r233, %r697; + fma.rn.f32 %r699, %r664, %r234, %r698; + fma.rn.f32 %r700, %r663, %r235, %r699; + fma.rn.f32 %r701, %r662, %r236, %r700; + add.s64 %rd62, %rd10, 45056; + // begin inline asm + ld.global.nc.v4.f32 {%r237,%r238,%r239,%r240}, [%rd62]; + // end inline asm + add.s64 %rd63, %rd10, 45072; + // begin inline asm + ld.global.nc.v4.f32 {%r241,%r242,%r243,%r244}, [%rd63]; + // end inline asm + fma.rn.f32 %r702, %r669, %r237, %r661; + fma.rn.f32 %r703, %r668, %r238, %r702; + fma.rn.f32 %r704, %r667, %r239, %r703; + fma.rn.f32 %r705, %r666, %r240, %r704; + fma.rn.f32 %r706, %r665, %r241, %r705; + fma.rn.f32 %r707, %r664, %r242, %r706; + fma.rn.f32 %r708, %r663, %r243, %r707; + fma.rn.f32 %r709, %r662, %r244, %r708; + add.s64 %rd64, %rd9, 2560; + // begin inline asm + ld.global.nc.v4.u32 {%r245,%r246,%r247,%r248}, [%rd64]; + // end inline asm + and.b32 %r710, %r248, -65536; + shl.b32 %r711, %r248, 16; + and.b32 %r712, %r247, -65536; + shl.b32 %r713, %r247, 16; + and.b32 %r714, %r246, -65536; + shl.b32 %r715, %r246, 16; + and.b32 %r716, %r245, -65536; + shl.b32 %r717, %r245, 16; + add.s64 %rd65, %rd10, 5120; + // begin inline asm + ld.global.nc.v4.f32 {%r249,%r250,%r251,%r252}, [%rd65]; + // end inline asm + add.s64 %rd66, %rd10, 5136; + // begin inline asm + ld.global.nc.v4.f32 {%r253,%r254,%r255,%r256}, [%rd66]; + // end inline asm + fma.rn.f32 %r718, %r717, %r249, %r677; + fma.rn.f32 %r719, %r716, %r250, %r718; + fma.rn.f32 %r720, %r715, %r251, %r719; + fma.rn.f32 %r721, %r714, %r252, %r720; + fma.rn.f32 %r722, %r713, %r253, %r721; + fma.rn.f32 %r723, %r712, %r254, %r722; + fma.rn.f32 %r724, %r711, %r255, %r723; + fma.rn.f32 %r725, %r710, %r256, %r724; + add.s64 %rd67, %rd10, 15360; + // begin inline asm + ld.global.nc.v4.f32 {%r257,%r258,%r259,%r260}, [%rd67]; + // end inline asm + add.s64 %rd68, %rd10, 15376; + // begin inline asm + ld.global.nc.v4.f32 {%r261,%r262,%r263,%r264}, [%rd68]; + // end inline asm + fma.rn.f32 %r726, %r717, %r257, %r685; + fma.rn.f32 %r727, %r716, %r258, %r726; + fma.rn.f32 %r728, %r715, %r259, %r727; + fma.rn.f32 %r729, %r714, %r260, %r728; + fma.rn.f32 %r730, %r713, %r261, %r729; + fma.rn.f32 %r731, %r712, %r262, %r730; + fma.rn.f32 %r732, %r711, %r263, %r731; + fma.rn.f32 %r733, %r710, %r264, %r732; + add.s64 %rd69, %rd10, 25600; + // begin inline asm + ld.global.nc.v4.f32 {%r265,%r266,%r267,%r268}, [%rd69]; + // end inline asm + add.s64 %rd70, %rd10, 25616; + // begin inline asm + ld.global.nc.v4.f32 {%r269,%r270,%r271,%r272}, [%rd70]; + // end inline asm + fma.rn.f32 %r734, %r717, %r265, %r693; + fma.rn.f32 %r735, %r716, %r266, %r734; + fma.rn.f32 %r736, %r715, %r267, %r735; + fma.rn.f32 %r737, %r714, %r268, %r736; + fma.rn.f32 %r738, %r713, %r269, %r737; + fma.rn.f32 %r739, %r712, %r270, %r738; + fma.rn.f32 %r740, %r711, %r271, %r739; + fma.rn.f32 %r741, %r710, %r272, %r740; + add.s64 %rd71, %rd10, 35840; + // begin inline asm + ld.global.nc.v4.f32 {%r273,%r274,%r275,%r276}, [%rd71]; + // end inline asm + add.s64 %rd72, %rd10, 35856; + // begin inline asm + ld.global.nc.v4.f32 {%r277,%r278,%r279,%r280}, [%rd72]; + // end inline asm + fma.rn.f32 %r742, %r717, %r273, %r701; + fma.rn.f32 %r743, %r716, %r274, %r742; + fma.rn.f32 %r744, %r715, %r275, %r743; + fma.rn.f32 %r745, %r714, %r276, %r744; + fma.rn.f32 %r746, %r713, %r277, %r745; + fma.rn.f32 %r747, %r712, %r278, %r746; + fma.rn.f32 %r748, %r711, %r279, %r747; + fma.rn.f32 %r749, %r710, %r280, %r748; + add.s64 %rd73, %rd10, 46080; + // begin inline asm + ld.global.nc.v4.f32 {%r281,%r282,%r283,%r284}, [%rd73]; + // end inline asm + add.s64 %rd74, %rd10, 46096; + // begin inline asm + ld.global.nc.v4.f32 {%r285,%r286,%r287,%r288}, [%rd74]; + // end inline asm + fma.rn.f32 %r750, %r717, %r281, %r709; + fma.rn.f32 %r751, %r716, %r282, %r750; + fma.rn.f32 %r752, %r715, %r283, %r751; + fma.rn.f32 %r753, %r714, %r284, %r752; + fma.rn.f32 %r754, %r713, %r285, %r753; + fma.rn.f32 %r755, %r712, %r286, %r754; + fma.rn.f32 %r756, %r711, %r287, %r755; + fma.rn.f32 %r757, %r710, %r288, %r756; + add.s64 %rd75, %rd9, 3072; + // begin inline asm + ld.global.nc.v4.u32 {%r289,%r290,%r291,%r292}, [%rd75]; + // end inline asm + and.b32 %r758, %r292, -65536; + shl.b32 %r759, %r292, 16; + and.b32 %r760, %r291, -65536; + shl.b32 %r761, %r291, 16; + and.b32 %r762, %r290, -65536; + shl.b32 %r763, %r290, 16; + and.b32 %r764, %r289, -65536; + shl.b32 %r765, %r289, 16; + add.s64 %rd76, %rd10, 6144; + // begin inline asm + ld.global.nc.v4.f32 {%r293,%r294,%r295,%r296}, [%rd76]; + // end inline asm + add.s64 %rd77, %rd10, 6160; + // begin inline asm + ld.global.nc.v4.f32 {%r297,%r298,%r299,%r300}, [%rd77]; + // end inline asm + fma.rn.f32 %r766, %r765, %r293, %r725; + fma.rn.f32 %r767, %r764, %r294, %r766; + fma.rn.f32 %r768, %r763, %r295, %r767; + fma.rn.f32 %r769, %r762, %r296, %r768; + fma.rn.f32 %r770, %r761, %r297, %r769; + fma.rn.f32 %r771, %r760, %r298, %r770; + fma.rn.f32 %r772, %r759, %r299, %r771; + fma.rn.f32 %r773, %r758, %r300, %r772; + add.s64 %rd78, %rd10, 16384; + // begin inline asm + ld.global.nc.v4.f32 {%r301,%r302,%r303,%r304}, [%rd78]; + // end inline asm + add.s64 %rd79, %rd10, 16400; + // begin inline asm + ld.global.nc.v4.f32 {%r305,%r306,%r307,%r308}, [%rd79]; + // end inline asm + fma.rn.f32 %r774, %r765, %r301, %r733; + fma.rn.f32 %r775, %r764, %r302, %r774; + fma.rn.f32 %r776, %r763, %r303, %r775; + fma.rn.f32 %r777, %r762, %r304, %r776; + fma.rn.f32 %r778, %r761, %r305, %r777; + fma.rn.f32 %r779, %r760, %r306, %r778; + fma.rn.f32 %r780, %r759, %r307, %r779; + fma.rn.f32 %r781, %r758, %r308, %r780; + add.s64 %rd80, %rd10, 26624; + // begin inline asm + ld.global.nc.v4.f32 {%r309,%r310,%r311,%r312}, [%rd80]; + // end inline asm + add.s64 %rd81, %rd10, 26640; + // begin inline asm + ld.global.nc.v4.f32 {%r313,%r314,%r315,%r316}, [%rd81]; + // end inline asm + fma.rn.f32 %r782, %r765, %r309, %r741; + fma.rn.f32 %r783, %r764, %r310, %r782; + fma.rn.f32 %r784, %r763, %r311, %r783; + fma.rn.f32 %r785, %r762, %r312, %r784; + fma.rn.f32 %r786, %r761, %r313, %r785; + fma.rn.f32 %r787, %r760, %r314, %r786; + fma.rn.f32 %r788, %r759, %r315, %r787; + fma.rn.f32 %r789, %r758, %r316, %r788; + add.s64 %rd82, %rd10, 36864; + // begin inline asm + ld.global.nc.v4.f32 {%r317,%r318,%r319,%r320}, [%rd82]; + // end inline asm + add.s64 %rd83, %rd10, 36880; + // begin inline asm + ld.global.nc.v4.f32 {%r321,%r322,%r323,%r324}, [%rd83]; + // end inline asm + fma.rn.f32 %r790, %r765, %r317, %r749; + fma.rn.f32 %r791, %r764, %r318, %r790; + fma.rn.f32 %r792, %r763, %r319, %r791; + fma.rn.f32 %r793, %r762, %r320, %r792; + fma.rn.f32 %r794, %r761, %r321, %r793; + fma.rn.f32 %r795, %r760, %r322, %r794; + fma.rn.f32 %r796, %r759, %r323, %r795; + fma.rn.f32 %r797, %r758, %r324, %r796; + add.s64 %rd84, %rd10, 47104; + // begin inline asm + ld.global.nc.v4.f32 {%r325,%r326,%r327,%r328}, [%rd84]; + // end inline asm + add.s64 %rd85, %rd10, 47120; + // begin inline asm + ld.global.nc.v4.f32 {%r329,%r330,%r331,%r332}, [%rd85]; + // end inline asm + fma.rn.f32 %r798, %r765, %r325, %r757; + fma.rn.f32 %r799, %r764, %r326, %r798; + fma.rn.f32 %r800, %r763, %r327, %r799; + fma.rn.f32 %r801, %r762, %r328, %r800; + fma.rn.f32 %r802, %r761, %r329, %r801; + fma.rn.f32 %r803, %r760, %r330, %r802; + fma.rn.f32 %r804, %r759, %r331, %r803; + fma.rn.f32 %r805, %r758, %r332, %r804; + add.s64 %rd86, %rd9, 3584; + // begin inline asm + ld.global.nc.v4.u32 {%r333,%r334,%r335,%r336}, [%rd86]; + // end inline asm + and.b32 %r806, %r336, -65536; + shl.b32 %r807, %r336, 16; + and.b32 %r808, %r335, -65536; + shl.b32 %r809, %r335, 16; + and.b32 %r810, %r334, -65536; + shl.b32 %r811, %r334, 16; + and.b32 %r812, %r333, -65536; + shl.b32 %r813, %r333, 16; + add.s64 %rd87, %rd10, 7168; + // begin inline asm + ld.global.nc.v4.f32 {%r337,%r338,%r339,%r340}, [%rd87]; + // end inline asm + add.s64 %rd88, %rd10, 7184; + // begin inline asm + ld.global.nc.v4.f32 {%r341,%r342,%r343,%r344}, [%rd88]; + // end inline asm + fma.rn.f32 %r814, %r813, %r337, %r773; + fma.rn.f32 %r815, %r812, %r338, %r814; + fma.rn.f32 %r816, %r811, %r339, %r815; + fma.rn.f32 %r817, %r810, %r340, %r816; + fma.rn.f32 %r818, %r809, %r341, %r817; + fma.rn.f32 %r819, %r808, %r342, %r818; + fma.rn.f32 %r820, %r807, %r343, %r819; + fma.rn.f32 %r821, %r806, %r344, %r820; + add.s64 %rd89, %rd10, 17408; + // begin inline asm + ld.global.nc.v4.f32 {%r345,%r346,%r347,%r348}, [%rd89]; + // end inline asm + add.s64 %rd90, %rd10, 17424; + // begin inline asm + ld.global.nc.v4.f32 {%r349,%r350,%r351,%r352}, [%rd90]; + // end inline asm + fma.rn.f32 %r822, %r813, %r345, %r781; + fma.rn.f32 %r823, %r812, %r346, %r822; + fma.rn.f32 %r824, %r811, %r347, %r823; + fma.rn.f32 %r825, %r810, %r348, %r824; + fma.rn.f32 %r826, %r809, %r349, %r825; + fma.rn.f32 %r827, %r808, %r350, %r826; + fma.rn.f32 %r828, %r807, %r351, %r827; + fma.rn.f32 %r829, %r806, %r352, %r828; + add.s64 %rd91, %rd10, 27648; + // begin inline asm + ld.global.nc.v4.f32 {%r353,%r354,%r355,%r356}, [%rd91]; + // end inline asm + add.s64 %rd92, %rd10, 27664; + // begin inline asm + ld.global.nc.v4.f32 {%r357,%r358,%r359,%r360}, [%rd92]; + // end inline asm + fma.rn.f32 %r830, %r813, %r353, %r789; + fma.rn.f32 %r831, %r812, %r354, %r830; + fma.rn.f32 %r832, %r811, %r355, %r831; + fma.rn.f32 %r833, %r810, %r356, %r832; + fma.rn.f32 %r834, %r809, %r357, %r833; + fma.rn.f32 %r835, %r808, %r358, %r834; + fma.rn.f32 %r836, %r807, %r359, %r835; + fma.rn.f32 %r837, %r806, %r360, %r836; + add.s64 %rd93, %rd10, 37888; + // begin inline asm + ld.global.nc.v4.f32 {%r361,%r362,%r363,%r364}, [%rd93]; + // end inline asm + add.s64 %rd94, %rd10, 37904; + // begin inline asm + ld.global.nc.v4.f32 {%r365,%r366,%r367,%r368}, [%rd94]; + // end inline asm + fma.rn.f32 %r838, %r813, %r361, %r797; + fma.rn.f32 %r839, %r812, %r362, %r838; + fma.rn.f32 %r840, %r811, %r363, %r839; + fma.rn.f32 %r841, %r810, %r364, %r840; + fma.rn.f32 %r842, %r809, %r365, %r841; + fma.rn.f32 %r843, %r808, %r366, %r842; + fma.rn.f32 %r844, %r807, %r367, %r843; + fma.rn.f32 %r845, %r806, %r368, %r844; + add.s64 %rd95, %rd10, 48128; + // begin inline asm + ld.global.nc.v4.f32 {%r369,%r370,%r371,%r372}, [%rd95]; + // end inline asm + add.s64 %rd96, %rd10, 48144; + // begin inline asm + ld.global.nc.v4.f32 {%r373,%r374,%r375,%r376}, [%rd96]; + // end inline asm + fma.rn.f32 %r846, %r813, %r369, %r805; + fma.rn.f32 %r847, %r812, %r370, %r846; + fma.rn.f32 %r848, %r811, %r371, %r847; + fma.rn.f32 %r849, %r810, %r372, %r848; + fma.rn.f32 %r850, %r809, %r373, %r849; + fma.rn.f32 %r851, %r808, %r374, %r850; + fma.rn.f32 %r852, %r807, %r375, %r851; + fma.rn.f32 %r853, %r806, %r376, %r852; + add.s64 %rd97, %rd9, 4096; + // begin inline asm + ld.global.nc.v4.u32 {%r377,%r378,%r379,%r380}, [%rd97]; + // end inline asm + and.b32 %r854, %r380, -65536; + shl.b32 %r855, %r380, 16; + and.b32 %r856, %r379, -65536; + shl.b32 %r857, %r379, 16; + and.b32 %r858, %r378, -65536; + shl.b32 %r859, %r378, 16; + and.b32 %r860, %r377, -65536; + shl.b32 %r861, %r377, 16; + add.s64 %rd98, %rd10, 8192; + // begin inline asm + ld.global.nc.v4.f32 {%r381,%r382,%r383,%r384}, [%rd98]; + // end inline asm + add.s64 %rd99, %rd10, 8208; + // begin inline asm + ld.global.nc.v4.f32 {%r385,%r386,%r387,%r388}, [%rd99]; + // end inline asm + fma.rn.f32 %r862, %r861, %r381, %r821; + fma.rn.f32 %r863, %r860, %r382, %r862; + fma.rn.f32 %r864, %r859, %r383, %r863; + fma.rn.f32 %r865, %r858, %r384, %r864; + fma.rn.f32 %r866, %r857, %r385, %r865; + fma.rn.f32 %r867, %r856, %r386, %r866; + fma.rn.f32 %r868, %r855, %r387, %r867; + fma.rn.f32 %r869, %r854, %r388, %r868; + add.s64 %rd100, %rd10, 18432; + // begin inline asm + ld.global.nc.v4.f32 {%r389,%r390,%r391,%r392}, [%rd100]; + // end inline asm + add.s64 %rd101, %rd10, 18448; + // begin inline asm + ld.global.nc.v4.f32 {%r393,%r394,%r395,%r396}, [%rd101]; + // end inline asm + fma.rn.f32 %r870, %r861, %r389, %r829; + fma.rn.f32 %r871, %r860, %r390, %r870; + fma.rn.f32 %r872, %r859, %r391, %r871; + fma.rn.f32 %r873, %r858, %r392, %r872; + fma.rn.f32 %r874, %r857, %r393, %r873; + fma.rn.f32 %r875, %r856, %r394, %r874; + fma.rn.f32 %r876, %r855, %r395, %r875; + fma.rn.f32 %r877, %r854, %r396, %r876; + add.s64 %rd102, %rd10, 28672; + // begin inline asm + ld.global.nc.v4.f32 {%r397,%r398,%r399,%r400}, [%rd102]; + // end inline asm + add.s64 %rd103, %rd10, 28688; + // begin inline asm + ld.global.nc.v4.f32 {%r401,%r402,%r403,%r404}, [%rd103]; + // end inline asm + fma.rn.f32 %r878, %r861, %r397, %r837; + fma.rn.f32 %r879, %r860, %r398, %r878; + fma.rn.f32 %r880, %r859, %r399, %r879; + fma.rn.f32 %r881, %r858, %r400, %r880; + fma.rn.f32 %r882, %r857, %r401, %r881; + fma.rn.f32 %r883, %r856, %r402, %r882; + fma.rn.f32 %r884, %r855, %r403, %r883; + fma.rn.f32 %r885, %r854, %r404, %r884; + add.s64 %rd104, %rd10, 38912; + // begin inline asm + ld.global.nc.v4.f32 {%r405,%r406,%r407,%r408}, [%rd104]; + // end inline asm + add.s64 %rd105, %rd10, 38928; + // begin inline asm + ld.global.nc.v4.f32 {%r409,%r410,%r411,%r412}, [%rd105]; + // end inline asm + fma.rn.f32 %r886, %r861, %r405, %r845; + fma.rn.f32 %r887, %r860, %r406, %r886; + fma.rn.f32 %r888, %r859, %r407, %r887; + fma.rn.f32 %r889, %r858, %r408, %r888; + fma.rn.f32 %r890, %r857, %r409, %r889; + fma.rn.f32 %r891, %r856, %r410, %r890; + fma.rn.f32 %r892, %r855, %r411, %r891; + fma.rn.f32 %r893, %r854, %r412, %r892; + add.s64 %rd106, %rd10, 49152; + // begin inline asm + ld.global.nc.v4.f32 {%r413,%r414,%r415,%r416}, [%rd106]; + // end inline asm + add.s64 %rd107, %rd10, 49168; + // begin inline asm + ld.global.nc.v4.f32 {%r417,%r418,%r419,%r420}, [%rd107]; + // end inline asm + fma.rn.f32 %r894, %r861, %r413, %r853; + fma.rn.f32 %r895, %r860, %r414, %r894; + fma.rn.f32 %r896, %r859, %r415, %r895; + fma.rn.f32 %r897, %r858, %r416, %r896; + fma.rn.f32 %r898, %r857, %r417, %r897; + fma.rn.f32 %r899, %r856, %r418, %r898; + fma.rn.f32 %r900, %r855, %r419, %r899; + fma.rn.f32 %r901, %r854, %r420, %r900; + add.s64 %rd108, %rd9, 4608; + // begin inline asm + ld.global.nc.v4.u32 {%r421,%r422,%r423,%r424}, [%rd108]; + // end inline asm + and.b32 %r902, %r424, -65536; + shl.b32 %r903, %r424, 16; + and.b32 %r904, %r423, -65536; + shl.b32 %r905, %r423, 16; + and.b32 %r906, %r422, -65536; + shl.b32 %r907, %r422, 16; + and.b32 %r908, %r421, -65536; + shl.b32 %r909, %r421, 16; + add.s64 %rd109, %rd10, 9216; + // begin inline asm + ld.global.nc.v4.f32 {%r425,%r426,%r427,%r428}, [%rd109]; + // end inline asm + add.s64 %rd110, %rd10, 9232; + // begin inline asm + ld.global.nc.v4.f32 {%r429,%r430,%r431,%r432}, [%rd110]; + // end inline asm + fma.rn.f32 %r910, %r909, %r425, %r869; + fma.rn.f32 %r911, %r908, %r426, %r910; + fma.rn.f32 %r912, %r907, %r427, %r911; + fma.rn.f32 %r913, %r906, %r428, %r912; + fma.rn.f32 %r914, %r905, %r429, %r913; + fma.rn.f32 %r915, %r904, %r430, %r914; + fma.rn.f32 %r916, %r903, %r431, %r915; + fma.rn.f32 %r917, %r902, %r432, %r916; + add.s64 %rd111, %rd10, 19456; + // begin inline asm + ld.global.nc.v4.f32 {%r433,%r434,%r435,%r436}, [%rd111]; + // end inline asm + add.s64 %rd112, %rd10, 19472; + // begin inline asm + ld.global.nc.v4.f32 {%r437,%r438,%r439,%r440}, [%rd112]; + // end inline asm + fma.rn.f32 %r918, %r909, %r433, %r877; + fma.rn.f32 %r919, %r908, %r434, %r918; + fma.rn.f32 %r920, %r907, %r435, %r919; + fma.rn.f32 %r921, %r906, %r436, %r920; + fma.rn.f32 %r922, %r905, %r437, %r921; + fma.rn.f32 %r923, %r904, %r438, %r922; + fma.rn.f32 %r924, %r903, %r439, %r923; + fma.rn.f32 %r4, %r902, %r440, %r924; + add.s64 %rd113, %rd10, 29696; + // begin inline asm + ld.global.nc.v4.f32 {%r441,%r442,%r443,%r444}, [%rd113]; + // end inline asm + add.s64 %rd114, %rd10, 29712; + // begin inline asm + ld.global.nc.v4.f32 {%r445,%r446,%r447,%r448}, [%rd114]; + // end inline asm + fma.rn.f32 %r925, %r909, %r441, %r885; + fma.rn.f32 %r926, %r908, %r442, %r925; + fma.rn.f32 %r927, %r907, %r443, %r926; + fma.rn.f32 %r928, %r906, %r444, %r927; + fma.rn.f32 %r929, %r905, %r445, %r928; + fma.rn.f32 %r930, %r904, %r446, %r929; + fma.rn.f32 %r931, %r903, %r447, %r930; + fma.rn.f32 %r5, %r902, %r448, %r931; + add.s64 %rd115, %rd10, 39936; + // begin inline asm + ld.global.nc.v4.f32 {%r449,%r450,%r451,%r452}, [%rd115]; + // end inline asm + add.s64 %rd116, %rd10, 39952; + // begin inline asm + ld.global.nc.v4.f32 {%r453,%r454,%r455,%r456}, [%rd116]; + // end inline asm + fma.rn.f32 %r932, %r909, %r449, %r893; + fma.rn.f32 %r933, %r908, %r450, %r932; + fma.rn.f32 %r934, %r907, %r451, %r933; + fma.rn.f32 %r935, %r906, %r452, %r934; + fma.rn.f32 %r936, %r905, %r453, %r935; + fma.rn.f32 %r937, %r904, %r454, %r936; + fma.rn.f32 %r938, %r903, %r455, %r937; + fma.rn.f32 %r6, %r902, %r456, %r938; + add.s64 %rd117, %rd10, 50176; + // begin inline asm + ld.global.nc.v4.f32 {%r457,%r458,%r459,%r460}, [%rd117]; + // end inline asm + add.s64 %rd118, %rd10, 50192; + // begin inline asm + ld.global.nc.v4.f32 {%r461,%r462,%r463,%r464}, [%rd118]; + // end inline asm + fma.rn.f32 %r939, %r909, %r457, %r901; + fma.rn.f32 %r940, %r908, %r458, %r939; + fma.rn.f32 %r941, %r907, %r459, %r940; + fma.rn.f32 %r942, %r906, %r460, %r941; + fma.rn.f32 %r943, %r905, %r461, %r942; + fma.rn.f32 %r944, %r904, %r462, %r943; + fma.rn.f32 %r945, %r903, %r463, %r944; + fma.rn.f32 %r7, %r902, %r464, %r945; + setp.ne.b32 %p3, %r3, 0; + mul.wide.s32 %rd127, %r466, 4; + add.s64 %rd2, %rd119, %rd127; + add.s64 %rd3, %rd120, %rd127; + cvt.s64.s32 %rd4, %r19; + shfl.sync.bfly.b32 %r946|%p4, %r917, 16, 31, -1; + add.f32 %r947, %r917, %r946; + shfl.sync.bfly.b32 %r948|%p5, %r947, 8, 31, -1; + add.f32 %r949, %r947, %r948; + shfl.sync.bfly.b32 %r950|%p6, %r949, 4, 31, -1; + add.f32 %r951, %r949, %r950; + shfl.sync.bfly.b32 %r952|%p7, %r951, 2, 31, -1; + add.f32 %r953, %r951, %r952; + shfl.sync.bfly.b32 %r954|%p8, %r953, 1, 31, -1; + add.f32 %r8, %r953, %r954; + @%p3 bra $L__BB5_9; + setp.lt.s32 %p9, %r2, %r19; + @%p9 bra $L__BB5_4; + mul.f32 %r955, %r8, 0fBFB8AA3B; + ex2.approx.f32 %r956, %r955; + add.f32 %r957, %r956, 0f3F800000; + rcp.rn.f32 %r1131, %r957; + mov.b64 %rd151, %rd8; + bra.uni $L__BB5_8; +$L__BB5_4: + ld.global.nc.b32 %r958, [%rd2]; + add.f32 %r1130, %r8, %r958; + setp.gt.f32 %p10, %r1130, 0f41A00000; + @%p10 bra $L__BB5_7; + mul.f32 %r959, %r1130, 0f3FB8AA3B; + ex2.approx.f32 %r9, %r959; + mov.b32 %r960, 0f3F800000; + add.rz.f32 %r961, %r9, %r960; + add.s32 %r962, %r961, -1061158912; + and.b32 %r963, %r962, -8388608; + sub.s32 %r964, %r9, %r963; + sub.s32 %r965, 1082130432, %r963; + fma.rn.f32 %r966, %r965, 0f3E800000, 0fBF800000; + add.f32 %r967, %r966, %r964; + cvt.rn.f32.s32 %r968, %r963; + mul.f32 %r969, %r968, 0f34000000; + fma.rn.f32 %r970, %r967, 0fBD39BF78, 0f3DD80012; + fma.rn.f32 %r971, %r970, %r967, 0fBE0778E0; + fma.rn.f32 %r972, %r971, %r967, 0f3E146475; + fma.rn.f32 %r973, %r972, %r967, 0fBE2A68DD; + fma.rn.f32 %r974, %r973, %r967, 0f3E4CAF9E; + fma.rn.f32 %r975, %r974, %r967, 0fBE800042; + fma.rn.f32 %r976, %r975, %r967, 0f3EAAAAE6; + fma.rn.f32 %r977, %r976, %r967, 0fBF000000; + mul.f32 %r978, %r967, %r977; + fma.rn.f32 %r979, %r978, %r967, %r967; + fma.rn.f32 %r1130, %r969, 0f3F317218, %r979; + setp.lt.u32 %p11, %r9, 2139095040; + @%p11 bra $L__BB5_7; + setp.gt.s32 %p12, %r9, -1082130432; + fma.rn.f32 %r980, %r9, 0f7F800000, 0f7F800000; + selp.f32 %r981, %r980, %r1130, %p12; + setp.eq.f32 %p13, %r9, 0f00000000; + selp.f32 %r1130, 0f80000000, %r981, %p13; +$L__BB5_7: + ld.global.nc.b32 %r982, [%rd3]; + mul.f32 %r1131, %r982, %r1130; + mov.b64 %rd151, %rd155; +$L__BB5_8: + cvta.to.global.u64 %rd128, %rd151; + shl.b64 %rd129, %rd1, 2; + add.s64 %rd130, %rd128, %rd129; + st.global.b32 [%rd130], %r1131; +$L__BB5_9: + setp.ne.b32 %p14, %r3, 0; + shfl.sync.bfly.b32 %r983|%p15, %r4, 16, 31, -1; + add.f32 %r984, %r4, %r983; + shfl.sync.bfly.b32 %r985|%p16, %r984, 8, 31, -1; + add.f32 %r986, %r984, %r985; + shfl.sync.bfly.b32 %r987|%p17, %r986, 4, 31, -1; + add.f32 %r988, %r986, %r987; + shfl.sync.bfly.b32 %r989|%p18, %r988, 2, 31, -1; + add.f32 %r990, %r988, %r989; + shfl.sync.bfly.b32 %r991|%p19, %r990, 1, 31, -1; + add.f32 %r10, %r990, %r991; + @%p14 bra $L__BB5_17; + setp.lt.s32 %p20, %r2, %r19; + @%p20 bra $L__BB5_12; + mul.f32 %r992, %r10, 0fBFB8AA3B; + ex2.approx.f32 %r993, %r992; + add.f32 %r994, %r993, 0f3F800000; + rcp.rn.f32 %r1133, %r994; + mov.b64 %rd152, %rd8; + bra.uni $L__BB5_16; +$L__BB5_12: + ld.global.nc.b32 %r995, [%rd2]; + add.f32 %r1132, %r10, %r995; + setp.gt.f32 %p21, %r1132, 0f41A00000; + @%p21 bra $L__BB5_15; + mul.f32 %r996, %r1132, 0f3FB8AA3B; + ex2.approx.f32 %r11, %r996; + mov.b32 %r997, 0f3F800000; + add.rz.f32 %r998, %r11, %r997; + add.s32 %r999, %r998, -1061158912; + and.b32 %r1000, %r999, -8388608; + sub.s32 %r1001, %r11, %r1000; + sub.s32 %r1002, 1082130432, %r1000; + fma.rn.f32 %r1003, %r1002, 0f3E800000, 0fBF800000; + add.f32 %r1004, %r1003, %r1001; + cvt.rn.f32.s32 %r1005, %r1000; + mul.f32 %r1006, %r1005, 0f34000000; + fma.rn.f32 %r1007, %r1004, 0fBD39BF78, 0f3DD80012; + fma.rn.f32 %r1008, %r1007, %r1004, 0fBE0778E0; + fma.rn.f32 %r1009, %r1008, %r1004, 0f3E146475; + fma.rn.f32 %r1010, %r1009, %r1004, 0fBE2A68DD; + fma.rn.f32 %r1011, %r1010, %r1004, 0f3E4CAF9E; + fma.rn.f32 %r1012, %r1011, %r1004, 0fBE800042; + fma.rn.f32 %r1013, %r1012, %r1004, 0f3EAAAAE6; + fma.rn.f32 %r1014, %r1013, %r1004, 0fBF000000; + mul.f32 %r1015, %r1004, %r1014; + fma.rn.f32 %r1016, %r1015, %r1004, %r1004; + fma.rn.f32 %r1132, %r1006, 0f3F317218, %r1016; + setp.lt.u32 %p22, %r11, 2139095040; + @%p22 bra $L__BB5_15; + setp.gt.s32 %p23, %r11, -1082130432; + fma.rn.f32 %r1017, %r11, 0f7F800000, 0f7F800000; + selp.f32 %r1018, %r1017, %r1132, %p23; + setp.eq.f32 %p24, %r11, 0f00000000; + selp.f32 %r1132, 0f80000000, %r1018, %p24; +$L__BB5_15: + ld.global.nc.b32 %r1019, [%rd3]; + mul.f32 %r1133, %r1019, %r1132; + mov.b64 %rd152, %rd155; +$L__BB5_16: + cvta.to.global.u64 %rd131, %rd152; + add.s64 %rd132, %rd4, %rd1; + shl.b64 %rd133, %rd132, 2; + add.s64 %rd134, %rd131, %rd133; + st.global.b32 [%rd134], %r1133; +$L__BB5_17: + setp.ne.b32 %p25, %r3, 0; + shfl.sync.bfly.b32 %r1020|%p26, %r5, 16, 31, -1; + add.f32 %r1021, %r5, %r1020; + shfl.sync.bfly.b32 %r1022|%p27, %r1021, 8, 31, -1; + add.f32 %r1023, %r1021, %r1022; + shfl.sync.bfly.b32 %r1024|%p28, %r1023, 4, 31, -1; + add.f32 %r1025, %r1023, %r1024; + shfl.sync.bfly.b32 %r1026|%p29, %r1025, 2, 31, -1; + add.f32 %r1027, %r1025, %r1026; + shfl.sync.bfly.b32 %r1028|%p30, %r1027, 1, 31, -1; + add.f32 %r12, %r1027, %r1028; + @%p25 bra $L__BB5_25; + setp.lt.s32 %p31, %r2, %r19; + @%p31 bra $L__BB5_20; + mul.f32 %r1029, %r12, 0fBFB8AA3B; + ex2.approx.f32 %r1030, %r1029; + add.f32 %r1031, %r1030, 0f3F800000; + rcp.rn.f32 %r1135, %r1031; + mov.b64 %rd153, %rd8; + bra.uni $L__BB5_24; +$L__BB5_20: + ld.global.nc.b32 %r1032, [%rd2]; + add.f32 %r1134, %r12, %r1032; + setp.gt.f32 %p32, %r1134, 0f41A00000; + @%p32 bra $L__BB5_23; + mul.f32 %r1033, %r1134, 0f3FB8AA3B; + ex2.approx.f32 %r13, %r1033; + mov.b32 %r1034, 0f3F800000; + add.rz.f32 %r1035, %r13, %r1034; + add.s32 %r1036, %r1035, -1061158912; + and.b32 %r1037, %r1036, -8388608; + sub.s32 %r1038, %r13, %r1037; + sub.s32 %r1039, 1082130432, %r1037; + fma.rn.f32 %r1040, %r1039, 0f3E800000, 0fBF800000; + add.f32 %r1041, %r1040, %r1038; + cvt.rn.f32.s32 %r1042, %r1037; + mul.f32 %r1043, %r1042, 0f34000000; + fma.rn.f32 %r1044, %r1041, 0fBD39BF78, 0f3DD80012; + fma.rn.f32 %r1045, %r1044, %r1041, 0fBE0778E0; + fma.rn.f32 %r1046, %r1045, %r1041, 0f3E146475; + fma.rn.f32 %r1047, %r1046, %r1041, 0fBE2A68DD; + fma.rn.f32 %r1048, %r1047, %r1041, 0f3E4CAF9E; + fma.rn.f32 %r1049, %r1048, %r1041, 0fBE800042; + fma.rn.f32 %r1050, %r1049, %r1041, 0f3EAAAAE6; + fma.rn.f32 %r1051, %r1050, %r1041, 0fBF000000; + mul.f32 %r1052, %r1041, %r1051; + fma.rn.f32 %r1053, %r1052, %r1041, %r1041; + fma.rn.f32 %r1134, %r1043, 0f3F317218, %r1053; + setp.lt.u32 %p33, %r13, 2139095040; + @%p33 bra $L__BB5_23; + setp.gt.s32 %p34, %r13, -1082130432; + fma.rn.f32 %r1054, %r13, 0f7F800000, 0f7F800000; + selp.f32 %r1055, %r1054, %r1134, %p34; + setp.eq.f32 %p35, %r13, 0f00000000; + selp.f32 %r1134, 0f80000000, %r1055, %p35; +$L__BB5_23: + ld.global.nc.b32 %r1056, [%rd3]; + mul.f32 %r1135, %r1056, %r1134; + mov.b64 %rd153, %rd155; +$L__BB5_24: + cvta.to.global.u64 %rd135, %rd153; + shl.b64 %rd136, %rd4, 1; + add.s64 %rd137, %rd136, %rd1; + shl.b64 %rd138, %rd137, 2; + add.s64 %rd139, %rd135, %rd138; + st.global.b32 [%rd139], %r1135; +$L__BB5_25: + setp.ne.b32 %p36, %r3, 0; + shfl.sync.bfly.b32 %r1057|%p37, %r6, 16, 31, -1; + add.f32 %r1058, %r6, %r1057; + shfl.sync.bfly.b32 %r1059|%p38, %r1058, 8, 31, -1; + add.f32 %r1060, %r1058, %r1059; + shfl.sync.bfly.b32 %r1061|%p39, %r1060, 4, 31, -1; + add.f32 %r1062, %r1060, %r1061; + shfl.sync.bfly.b32 %r1063|%p40, %r1062, 2, 31, -1; + add.f32 %r1064, %r1062, %r1063; + shfl.sync.bfly.b32 %r1065|%p41, %r1064, 1, 31, -1; + add.f32 %r14, %r1064, %r1065; + @%p36 bra $L__BB5_33; + setp.lt.s32 %p42, %r2, %r19; + @%p42 bra $L__BB5_28; + mul.f32 %r1066, %r14, 0fBFB8AA3B; + ex2.approx.f32 %r1067, %r1066; + add.f32 %r1068, %r1067, 0f3F800000; + rcp.rn.f32 %r1137, %r1068; + mov.b64 %rd154, %rd8; + bra.uni $L__BB5_32; +$L__BB5_28: + ld.global.nc.b32 %r1069, [%rd2]; + add.f32 %r1136, %r14, %r1069; + setp.gt.f32 %p43, %r1136, 0f41A00000; + @%p43 bra $L__BB5_31; + mul.f32 %r1070, %r1136, 0f3FB8AA3B; + ex2.approx.f32 %r15, %r1070; + mov.b32 %r1071, 0f3F800000; + add.rz.f32 %r1072, %r15, %r1071; + add.s32 %r1073, %r1072, -1061158912; + and.b32 %r1074, %r1073, -8388608; + sub.s32 %r1075, %r15, %r1074; + sub.s32 %r1076, 1082130432, %r1074; + fma.rn.f32 %r1077, %r1076, 0f3E800000, 0fBF800000; + add.f32 %r1078, %r1077, %r1075; + cvt.rn.f32.s32 %r1079, %r1074; + mul.f32 %r1080, %r1079, 0f34000000; + fma.rn.f32 %r1081, %r1078, 0fBD39BF78, 0f3DD80012; + fma.rn.f32 %r1082, %r1081, %r1078, 0fBE0778E0; + fma.rn.f32 %r1083, %r1082, %r1078, 0f3E146475; + fma.rn.f32 %r1084, %r1083, %r1078, 0fBE2A68DD; + fma.rn.f32 %r1085, %r1084, %r1078, 0f3E4CAF9E; + fma.rn.f32 %r1086, %r1085, %r1078, 0fBE800042; + fma.rn.f32 %r1087, %r1086, %r1078, 0f3EAAAAE6; + fma.rn.f32 %r1088, %r1087, %r1078, 0fBF000000; + mul.f32 %r1089, %r1078, %r1088; + fma.rn.f32 %r1090, %r1089, %r1078, %r1078; + fma.rn.f32 %r1136, %r1080, 0f3F317218, %r1090; + setp.lt.u32 %p44, %r15, 2139095040; + @%p44 bra $L__BB5_31; + setp.gt.s32 %p45, %r15, -1082130432; + fma.rn.f32 %r1091, %r15, 0f7F800000, 0f7F800000; + selp.f32 %r1092, %r1091, %r1136, %p45; + setp.eq.f32 %p46, %r15, 0f00000000; + selp.f32 %r1136, 0f80000000, %r1092, %p46; +$L__BB5_31: + ld.global.nc.b32 %r1093, [%rd3]; + mul.f32 %r1137, %r1093, %r1136; + mov.b64 %rd154, %rd155; +$L__BB5_32: + cvta.to.global.u64 %rd140, %rd154; + mad.lo.s64 %rd141, %rd4, 3, %rd1; + shl.b64 %rd142, %rd141, 2; + add.s64 %rd143, %rd140, %rd142; + st.global.b32 [%rd143], %r1137; +$L__BB5_33: + setp.ne.b32 %p47, %r3, 0; + shfl.sync.bfly.b32 %r1094|%p48, %r7, 16, 31, -1; + add.f32 %r1095, %r7, %r1094; + shfl.sync.bfly.b32 %r1096|%p49, %r1095, 8, 31, -1; + add.f32 %r1097, %r1095, %r1096; + shfl.sync.bfly.b32 %r1098|%p50, %r1097, 4, 31, -1; + add.f32 %r1099, %r1097, %r1098; + shfl.sync.bfly.b32 %r1100|%p51, %r1099, 2, 31, -1; + add.f32 %r1101, %r1099, %r1100; + shfl.sync.bfly.b32 %r1102|%p52, %r1101, 1, 31, -1; + add.f32 %r16, %r1101, %r1102; + @%p47 bra $L__BB5_41; + setp.lt.s32 %p53, %r2, %r19; + ld.global.nc.b32 %r17, [%rd3]; + @%p53 bra $L__BB5_36; + mul.f32 %r1103, %r16, 0fBFB8AA3B; + ex2.approx.f32 %r1104, %r1103; + add.f32 %r1105, %r1104, 0f3F800000; + rcp.rn.f32 %r1139, %r1105; + mov.b64 %rd155, %rd8; + bra.uni $L__BB5_40; +$L__BB5_36: + ld.global.nc.b32 %r1106, [%rd2]; + add.f32 %r1138, %r16, %r1106; + setp.gt.f32 %p54, %r1138, 0f41A00000; + @%p54 bra $L__BB5_39; + mul.f32 %r1107, %r1138, 0f3FB8AA3B; + ex2.approx.f32 %r18, %r1107; + mov.b32 %r1108, 0f3F800000; + add.rz.f32 %r1109, %r18, %r1108; + add.s32 %r1110, %r1109, -1061158912; + and.b32 %r1111, %r1110, -8388608; + sub.s32 %r1112, %r18, %r1111; + sub.s32 %r1113, 1082130432, %r1111; + fma.rn.f32 %r1114, %r1113, 0f3E800000, 0fBF800000; + add.f32 %r1115, %r1114, %r1112; + cvt.rn.f32.s32 %r1116, %r1111; + mul.f32 %r1117, %r1116, 0f34000000; + fma.rn.f32 %r1118, %r1115, 0fBD39BF78, 0f3DD80012; + fma.rn.f32 %r1119, %r1118, %r1115, 0fBE0778E0; + fma.rn.f32 %r1120, %r1119, %r1115, 0f3E146475; + fma.rn.f32 %r1121, %r1120, %r1115, 0fBE2A68DD; + fma.rn.f32 %r1122, %r1121, %r1115, 0f3E4CAF9E; + fma.rn.f32 %r1123, %r1122, %r1115, 0fBE800042; + fma.rn.f32 %r1124, %r1123, %r1115, 0f3EAAAAE6; + fma.rn.f32 %r1125, %r1124, %r1115, 0fBF000000; + mul.f32 %r1126, %r1115, %r1125; + fma.rn.f32 %r1127, %r1126, %r1115, %r1115; + fma.rn.f32 %r1138, %r1117, 0f3F317218, %r1127; + setp.lt.u32 %p55, %r18, 2139095040; + @%p55 bra $L__BB5_39; + setp.gt.s32 %p56, %r18, -1082130432; + fma.rn.f32 %r1128, %r18, 0f7F800000, 0f7F800000; + selp.f32 %r1129, %r1128, %r1138, %p56; + setp.eq.f32 %p57, %r18, 0f00000000; + selp.f32 %r1138, 0f80000000, %r1129, %p57; +$L__BB5_39: + mul.f32 %r1139, %r17, %r1138; +$L__BB5_40: + cvta.to.global.u64 %rd144, %rd155; + shl.b64 %rd145, %rd4, 2; + add.s64 %rd146, %rd145, %rd1; + shl.b64 %rd147, %rd146, 2; + add.s64 %rd148, %rd144, %rd147; + st.global.b32 [%rd148], %r1139; +$L__BB5_41: + ret; + +} + // .globl leleka_gdn_ab_unrolled_t6 +.visible .entry leleka_gdn_ab_unrolled_t6( + .param .u64 .ptr .align 1 leleka_gdn_ab_unrolled_t6_param_0, + .param .u64 .ptr .align 1 leleka_gdn_ab_unrolled_t6_param_1, + .param .u64 .ptr .align 1 leleka_gdn_ab_unrolled_t6_param_2, + .param .u64 .ptr .align 1 leleka_gdn_ab_unrolled_t6_param_3, + .param .u64 .ptr .align 1 leleka_gdn_ab_unrolled_t6_param_4, + .param .u64 .ptr .align 1 leleka_gdn_ab_unrolled_t6_param_5, + .param .u64 .ptr .align 1 leleka_gdn_ab_unrolled_t6_param_6, + .param .u32 leleka_gdn_ab_unrolled_t6_param_7, + .param .u32 leleka_gdn_ab_unrolled_t6_param_8, + .param .u32 leleka_gdn_ab_unrolled_t6_param_9 +) +.maxntid 64 +{ + .reg .pred %p<69>; + .reg .b32 %r<1341>; + .reg .b64 %rd<181>; + + ld.param.b64 %rd5, [leleka_gdn_ab_unrolled_t6_param_1]; + ld.param.b64 %rd6, [leleka_gdn_ab_unrolled_t6_param_3]; + ld.param.b64 %rd7, [leleka_gdn_ab_unrolled_t6_param_4]; + ld.param.b64 %rd180, [leleka_gdn_ab_unrolled_t6_param_5]; + ld.param.b64 %rd8, [leleka_gdn_ab_unrolled_t6_param_6]; + ld.param.b32 %r22, [leleka_gdn_ab_unrolled_t6_param_8]; + mov.u32 %r23, %ctaid.x; + mov.u32 %r24, %ntid.x; + shr.u32 %r25, %r24, 5; + mov.u32 %r1, %tid.x; + shr.u32 %r26, %r1, 5; + mad.lo.s32 %r2, %r25, %r23, %r26; + shl.b32 %r27, %r22, 1; + setp.ge.s32 %p1, %r2, %r27; + @%p1 bra $L__BB6_49; + ld.param.b64 %rd174, [leleka_gdn_ab_unrolled_t6_param_2]; + ld.param.b64 %rd173, [leleka_gdn_ab_unrolled_t6_param_0]; + and.b32 %r3, %r1, 31; + cvta.to.global.u64 %rd139, %rd6; + cvta.to.global.u64 %rd140, %rd7; + setp.lt.s32 %p2, %r2, %r22; + selp.b32 %r548, 0, %r22, %p2; + sub.s32 %r549, %r2, %r548; + selp.b64 %rd141, %rd5, %rd174, %p2; + cvt.s64.s32 %rd1, %r549; + mul.wide.s32 %rd142, %r549, 5120; + add.s64 %rd143, %rd141, %rd142; + shl.b32 %r550, %r1, 4; + cvt.u64.u32 %rd144, %r550; + and.b64 %rd145, %rd144, 496; + add.s64 %rd9, %rd143, %rd145; + // begin inline asm + ld.global.nc.v4.u32 {%r28,%r29,%r30,%r31}, [%rd9]; + // end inline asm + and.b32 %r551, %r31, -65536; + shl.b32 %r552, %r31, 16; + and.b32 %r553, %r30, -65536; + shl.b32 %r554, %r30, 16; + and.b32 %r555, %r29, -65536; + shl.b32 %r556, %r29, 16; + and.b32 %r557, %r28, -65536; + shl.b32 %r558, %r28, 16; + shl.b32 %r559, %r1, 3; + and.b32 %r560, %r559, 248; + mul.wide.u32 %rd146, %r560, 4; + add.s64 %rd10, %rd173, %rd146; + // begin inline asm + ld.global.nc.v4.f32 {%r32,%r33,%r34,%r35}, [%rd10]; + // end inline asm + add.s64 %rd11, %rd10, 16; + // begin inline asm + ld.global.nc.v4.f32 {%r36,%r37,%r38,%r39}, [%rd11]; + // end inline asm + fma.rn.f32 %r561, %r558, %r32, 0f00000000; + fma.rn.f32 %r562, %r557, %r33, %r561; + fma.rn.f32 %r563, %r556, %r34, %r562; + fma.rn.f32 %r564, %r555, %r35, %r563; + fma.rn.f32 %r565, %r554, %r36, %r564; + fma.rn.f32 %r566, %r553, %r37, %r565; + fma.rn.f32 %r567, %r552, %r38, %r566; + fma.rn.f32 %r568, %r551, %r39, %r567; + add.s64 %rd12, %rd10, 10240; + // begin inline asm + ld.global.nc.v4.f32 {%r40,%r41,%r42,%r43}, [%rd12]; + // end inline asm + add.s64 %rd13, %rd10, 10256; + // begin inline asm + ld.global.nc.v4.f32 {%r44,%r45,%r46,%r47}, [%rd13]; + // end inline asm + fma.rn.f32 %r569, %r558, %r40, 0f00000000; + fma.rn.f32 %r570, %r557, %r41, %r569; + fma.rn.f32 %r571, %r556, %r42, %r570; + fma.rn.f32 %r572, %r555, %r43, %r571; + fma.rn.f32 %r573, %r554, %r44, %r572; + fma.rn.f32 %r574, %r553, %r45, %r573; + fma.rn.f32 %r575, %r552, %r46, %r574; + fma.rn.f32 %r576, %r551, %r47, %r575; + add.s64 %rd14, %rd10, 20480; + // begin inline asm + ld.global.nc.v4.f32 {%r48,%r49,%r50,%r51}, [%rd14]; + // end inline asm + add.s64 %rd15, %rd10, 20496; + // begin inline asm + ld.global.nc.v4.f32 {%r52,%r53,%r54,%r55}, [%rd15]; + // end inline asm + fma.rn.f32 %r577, %r558, %r48, 0f00000000; + fma.rn.f32 %r578, %r557, %r49, %r577; + fma.rn.f32 %r579, %r556, %r50, %r578; + fma.rn.f32 %r580, %r555, %r51, %r579; + fma.rn.f32 %r581, %r554, %r52, %r580; + fma.rn.f32 %r582, %r553, %r53, %r581; + fma.rn.f32 %r583, %r552, %r54, %r582; + fma.rn.f32 %r584, %r551, %r55, %r583; + add.s64 %rd16, %rd10, 30720; + // begin inline asm + ld.global.nc.v4.f32 {%r56,%r57,%r58,%r59}, [%rd16]; + // end inline asm + add.s64 %rd17, %rd10, 30736; + // begin inline asm + ld.global.nc.v4.f32 {%r60,%r61,%r62,%r63}, [%rd17]; + // end inline asm + fma.rn.f32 %r585, %r558, %r56, 0f00000000; + fma.rn.f32 %r586, %r557, %r57, %r585; + fma.rn.f32 %r587, %r556, %r58, %r586; + fma.rn.f32 %r588, %r555, %r59, %r587; + fma.rn.f32 %r589, %r554, %r60, %r588; + fma.rn.f32 %r590, %r553, %r61, %r589; + fma.rn.f32 %r591, %r552, %r62, %r590; + fma.rn.f32 %r592, %r551, %r63, %r591; + add.s64 %rd18, %rd10, 40960; + // begin inline asm + ld.global.nc.v4.f32 {%r64,%r65,%r66,%r67}, [%rd18]; + // end inline asm + add.s64 %rd19, %rd10, 40976; + // begin inline asm + ld.global.nc.v4.f32 {%r68,%r69,%r70,%r71}, [%rd19]; + // end inline asm + fma.rn.f32 %r593, %r558, %r64, 0f00000000; + fma.rn.f32 %r594, %r557, %r65, %r593; + fma.rn.f32 %r595, %r556, %r66, %r594; + fma.rn.f32 %r596, %r555, %r67, %r595; + fma.rn.f32 %r597, %r554, %r68, %r596; + fma.rn.f32 %r598, %r553, %r69, %r597; + fma.rn.f32 %r599, %r552, %r70, %r598; + fma.rn.f32 %r600, %r551, %r71, %r599; + add.s64 %rd20, %rd10, 51200; + // begin inline asm + ld.global.nc.v4.f32 {%r72,%r73,%r74,%r75}, [%rd20]; + // end inline asm + add.s64 %rd21, %rd10, 51216; + // begin inline asm + ld.global.nc.v4.f32 {%r76,%r77,%r78,%r79}, [%rd21]; + // end inline asm + fma.rn.f32 %r601, %r558, %r72, 0f00000000; + fma.rn.f32 %r602, %r557, %r73, %r601; + fma.rn.f32 %r603, %r556, %r74, %r602; + fma.rn.f32 %r604, %r555, %r75, %r603; + fma.rn.f32 %r605, %r554, %r76, %r604; + fma.rn.f32 %r606, %r553, %r77, %r605; + fma.rn.f32 %r607, %r552, %r78, %r606; + fma.rn.f32 %r608, %r551, %r79, %r607; + add.s64 %rd22, %rd9, 512; + // begin inline asm + ld.global.nc.v4.u32 {%r80,%r81,%r82,%r83}, [%rd22]; + // end inline asm + and.b32 %r609, %r83, -65536; + shl.b32 %r610, %r83, 16; + and.b32 %r611, %r82, -65536; + shl.b32 %r612, %r82, 16; + and.b32 %r613, %r81, -65536; + shl.b32 %r614, %r81, 16; + and.b32 %r615, %r80, -65536; + shl.b32 %r616, %r80, 16; + add.s64 %rd23, %rd10, 1024; + // begin inline asm + ld.global.nc.v4.f32 {%r84,%r85,%r86,%r87}, [%rd23]; + // end inline asm + add.s64 %rd24, %rd10, 1040; + // begin inline asm + ld.global.nc.v4.f32 {%r88,%r89,%r90,%r91}, [%rd24]; + // end inline asm + fma.rn.f32 %r617, %r616, %r84, %r568; + fma.rn.f32 %r618, %r615, %r85, %r617; + fma.rn.f32 %r619, %r614, %r86, %r618; + fma.rn.f32 %r620, %r613, %r87, %r619; + fma.rn.f32 %r621, %r612, %r88, %r620; + fma.rn.f32 %r622, %r611, %r89, %r621; + fma.rn.f32 %r623, %r610, %r90, %r622; + fma.rn.f32 %r624, %r609, %r91, %r623; + add.s64 %rd25, %rd10, 11264; + // begin inline asm + ld.global.nc.v4.f32 {%r92,%r93,%r94,%r95}, [%rd25]; + // end inline asm + add.s64 %rd26, %rd10, 11280; + // begin inline asm + ld.global.nc.v4.f32 {%r96,%r97,%r98,%r99}, [%rd26]; + // end inline asm + fma.rn.f32 %r625, %r616, %r92, %r576; + fma.rn.f32 %r626, %r615, %r93, %r625; + fma.rn.f32 %r627, %r614, %r94, %r626; + fma.rn.f32 %r628, %r613, %r95, %r627; + fma.rn.f32 %r629, %r612, %r96, %r628; + fma.rn.f32 %r630, %r611, %r97, %r629; + fma.rn.f32 %r631, %r610, %r98, %r630; + fma.rn.f32 %r632, %r609, %r99, %r631; + add.s64 %rd27, %rd10, 21504; + // begin inline asm + ld.global.nc.v4.f32 {%r100,%r101,%r102,%r103}, [%rd27]; + // end inline asm + add.s64 %rd28, %rd10, 21520; + // begin inline asm + ld.global.nc.v4.f32 {%r104,%r105,%r106,%r107}, [%rd28]; + // end inline asm + fma.rn.f32 %r633, %r616, %r100, %r584; + fma.rn.f32 %r634, %r615, %r101, %r633; + fma.rn.f32 %r635, %r614, %r102, %r634; + fma.rn.f32 %r636, %r613, %r103, %r635; + fma.rn.f32 %r637, %r612, %r104, %r636; + fma.rn.f32 %r638, %r611, %r105, %r637; + fma.rn.f32 %r639, %r610, %r106, %r638; + fma.rn.f32 %r640, %r609, %r107, %r639; + add.s64 %rd29, %rd10, 31744; + // begin inline asm + ld.global.nc.v4.f32 {%r108,%r109,%r110,%r111}, [%rd29]; + // end inline asm + add.s64 %rd30, %rd10, 31760; + // begin inline asm + ld.global.nc.v4.f32 {%r112,%r113,%r114,%r115}, [%rd30]; + // end inline asm + fma.rn.f32 %r641, %r616, %r108, %r592; + fma.rn.f32 %r642, %r615, %r109, %r641; + fma.rn.f32 %r643, %r614, %r110, %r642; + fma.rn.f32 %r644, %r613, %r111, %r643; + fma.rn.f32 %r645, %r612, %r112, %r644; + fma.rn.f32 %r646, %r611, %r113, %r645; + fma.rn.f32 %r647, %r610, %r114, %r646; + fma.rn.f32 %r648, %r609, %r115, %r647; + add.s64 %rd31, %rd10, 41984; + // begin inline asm + ld.global.nc.v4.f32 {%r116,%r117,%r118,%r119}, [%rd31]; + // end inline asm + add.s64 %rd32, %rd10, 42000; + // begin inline asm + ld.global.nc.v4.f32 {%r120,%r121,%r122,%r123}, [%rd32]; + // end inline asm + fma.rn.f32 %r649, %r616, %r116, %r600; + fma.rn.f32 %r650, %r615, %r117, %r649; + fma.rn.f32 %r651, %r614, %r118, %r650; + fma.rn.f32 %r652, %r613, %r119, %r651; + fma.rn.f32 %r653, %r612, %r120, %r652; + fma.rn.f32 %r654, %r611, %r121, %r653; + fma.rn.f32 %r655, %r610, %r122, %r654; + fma.rn.f32 %r656, %r609, %r123, %r655; + add.s64 %rd33, %rd10, 52224; + // begin inline asm + ld.global.nc.v4.f32 {%r124,%r125,%r126,%r127}, [%rd33]; + // end inline asm + add.s64 %rd34, %rd10, 52240; + // begin inline asm + ld.global.nc.v4.f32 {%r128,%r129,%r130,%r131}, [%rd34]; + // end inline asm + fma.rn.f32 %r657, %r616, %r124, %r608; + fma.rn.f32 %r658, %r615, %r125, %r657; + fma.rn.f32 %r659, %r614, %r126, %r658; + fma.rn.f32 %r660, %r613, %r127, %r659; + fma.rn.f32 %r661, %r612, %r128, %r660; + fma.rn.f32 %r662, %r611, %r129, %r661; + fma.rn.f32 %r663, %r610, %r130, %r662; + fma.rn.f32 %r664, %r609, %r131, %r663; + add.s64 %rd35, %rd9, 1024; + // begin inline asm + ld.global.nc.v4.u32 {%r132,%r133,%r134,%r135}, [%rd35]; + // end inline asm + and.b32 %r665, %r135, -65536; + shl.b32 %r666, %r135, 16; + and.b32 %r667, %r134, -65536; + shl.b32 %r668, %r134, 16; + and.b32 %r669, %r133, -65536; + shl.b32 %r670, %r133, 16; + and.b32 %r671, %r132, -65536; + shl.b32 %r672, %r132, 16; + add.s64 %rd36, %rd10, 2048; + // begin inline asm + ld.global.nc.v4.f32 {%r136,%r137,%r138,%r139}, [%rd36]; + // end inline asm + add.s64 %rd37, %rd10, 2064; + // begin inline asm + ld.global.nc.v4.f32 {%r140,%r141,%r142,%r143}, [%rd37]; + // end inline asm + fma.rn.f32 %r673, %r672, %r136, %r624; + fma.rn.f32 %r674, %r671, %r137, %r673; + fma.rn.f32 %r675, %r670, %r138, %r674; + fma.rn.f32 %r676, %r669, %r139, %r675; + fma.rn.f32 %r677, %r668, %r140, %r676; + fma.rn.f32 %r678, %r667, %r141, %r677; + fma.rn.f32 %r679, %r666, %r142, %r678; + fma.rn.f32 %r680, %r665, %r143, %r679; + add.s64 %rd38, %rd10, 12288; + // begin inline asm + ld.global.nc.v4.f32 {%r144,%r145,%r146,%r147}, [%rd38]; + // end inline asm + add.s64 %rd39, %rd10, 12304; + // begin inline asm + ld.global.nc.v4.f32 {%r148,%r149,%r150,%r151}, [%rd39]; + // end inline asm + fma.rn.f32 %r681, %r672, %r144, %r632; + fma.rn.f32 %r682, %r671, %r145, %r681; + fma.rn.f32 %r683, %r670, %r146, %r682; + fma.rn.f32 %r684, %r669, %r147, %r683; + fma.rn.f32 %r685, %r668, %r148, %r684; + fma.rn.f32 %r686, %r667, %r149, %r685; + fma.rn.f32 %r687, %r666, %r150, %r686; + fma.rn.f32 %r688, %r665, %r151, %r687; + add.s64 %rd40, %rd10, 22528; + // begin inline asm + ld.global.nc.v4.f32 {%r152,%r153,%r154,%r155}, [%rd40]; + // end inline asm + add.s64 %rd41, %rd10, 22544; + // begin inline asm + ld.global.nc.v4.f32 {%r156,%r157,%r158,%r159}, [%rd41]; + // end inline asm + fma.rn.f32 %r689, %r672, %r152, %r640; + fma.rn.f32 %r690, %r671, %r153, %r689; + fma.rn.f32 %r691, %r670, %r154, %r690; + fma.rn.f32 %r692, %r669, %r155, %r691; + fma.rn.f32 %r693, %r668, %r156, %r692; + fma.rn.f32 %r694, %r667, %r157, %r693; + fma.rn.f32 %r695, %r666, %r158, %r694; + fma.rn.f32 %r696, %r665, %r159, %r695; + add.s64 %rd42, %rd10, 32768; + // begin inline asm + ld.global.nc.v4.f32 {%r160,%r161,%r162,%r163}, [%rd42]; + // end inline asm + add.s64 %rd43, %rd10, 32784; + // begin inline asm + ld.global.nc.v4.f32 {%r164,%r165,%r166,%r167}, [%rd43]; + // end inline asm + fma.rn.f32 %r697, %r672, %r160, %r648; + fma.rn.f32 %r698, %r671, %r161, %r697; + fma.rn.f32 %r699, %r670, %r162, %r698; + fma.rn.f32 %r700, %r669, %r163, %r699; + fma.rn.f32 %r701, %r668, %r164, %r700; + fma.rn.f32 %r702, %r667, %r165, %r701; + fma.rn.f32 %r703, %r666, %r166, %r702; + fma.rn.f32 %r704, %r665, %r167, %r703; + add.s64 %rd44, %rd10, 43008; + // begin inline asm + ld.global.nc.v4.f32 {%r168,%r169,%r170,%r171}, [%rd44]; + // end inline asm + add.s64 %rd45, %rd10, 43024; + // begin inline asm + ld.global.nc.v4.f32 {%r172,%r173,%r174,%r175}, [%rd45]; + // end inline asm + fma.rn.f32 %r705, %r672, %r168, %r656; + fma.rn.f32 %r706, %r671, %r169, %r705; + fma.rn.f32 %r707, %r670, %r170, %r706; + fma.rn.f32 %r708, %r669, %r171, %r707; + fma.rn.f32 %r709, %r668, %r172, %r708; + fma.rn.f32 %r710, %r667, %r173, %r709; + fma.rn.f32 %r711, %r666, %r174, %r710; + fma.rn.f32 %r712, %r665, %r175, %r711; + add.s64 %rd46, %rd10, 53248; + // begin inline asm + ld.global.nc.v4.f32 {%r176,%r177,%r178,%r179}, [%rd46]; + // end inline asm + add.s64 %rd47, %rd10, 53264; + // begin inline asm + ld.global.nc.v4.f32 {%r180,%r181,%r182,%r183}, [%rd47]; + // end inline asm + fma.rn.f32 %r713, %r672, %r176, %r664; + fma.rn.f32 %r714, %r671, %r177, %r713; + fma.rn.f32 %r715, %r670, %r178, %r714; + fma.rn.f32 %r716, %r669, %r179, %r715; + fma.rn.f32 %r717, %r668, %r180, %r716; + fma.rn.f32 %r718, %r667, %r181, %r717; + fma.rn.f32 %r719, %r666, %r182, %r718; + fma.rn.f32 %r720, %r665, %r183, %r719; + add.s64 %rd48, %rd9, 1536; + // begin inline asm + ld.global.nc.v4.u32 {%r184,%r185,%r186,%r187}, [%rd48]; + // end inline asm + and.b32 %r721, %r187, -65536; + shl.b32 %r722, %r187, 16; + and.b32 %r723, %r186, -65536; + shl.b32 %r724, %r186, 16; + and.b32 %r725, %r185, -65536; + shl.b32 %r726, %r185, 16; + and.b32 %r727, %r184, -65536; + shl.b32 %r728, %r184, 16; + add.s64 %rd49, %rd10, 3072; + // begin inline asm + ld.global.nc.v4.f32 {%r188,%r189,%r190,%r191}, [%rd49]; + // end inline asm + add.s64 %rd50, %rd10, 3088; + // begin inline asm + ld.global.nc.v4.f32 {%r192,%r193,%r194,%r195}, [%rd50]; + // end inline asm + fma.rn.f32 %r729, %r728, %r188, %r680; + fma.rn.f32 %r730, %r727, %r189, %r729; + fma.rn.f32 %r731, %r726, %r190, %r730; + fma.rn.f32 %r732, %r725, %r191, %r731; + fma.rn.f32 %r733, %r724, %r192, %r732; + fma.rn.f32 %r734, %r723, %r193, %r733; + fma.rn.f32 %r735, %r722, %r194, %r734; + fma.rn.f32 %r736, %r721, %r195, %r735; + add.s64 %rd51, %rd10, 13312; + // begin inline asm + ld.global.nc.v4.f32 {%r196,%r197,%r198,%r199}, [%rd51]; + // end inline asm + add.s64 %rd52, %rd10, 13328; + // begin inline asm + ld.global.nc.v4.f32 {%r200,%r201,%r202,%r203}, [%rd52]; + // end inline asm + fma.rn.f32 %r737, %r728, %r196, %r688; + fma.rn.f32 %r738, %r727, %r197, %r737; + fma.rn.f32 %r739, %r726, %r198, %r738; + fma.rn.f32 %r740, %r725, %r199, %r739; + fma.rn.f32 %r741, %r724, %r200, %r740; + fma.rn.f32 %r742, %r723, %r201, %r741; + fma.rn.f32 %r743, %r722, %r202, %r742; + fma.rn.f32 %r744, %r721, %r203, %r743; + add.s64 %rd53, %rd10, 23552; + // begin inline asm + ld.global.nc.v4.f32 {%r204,%r205,%r206,%r207}, [%rd53]; + // end inline asm + add.s64 %rd54, %rd10, 23568; + // begin inline asm + ld.global.nc.v4.f32 {%r208,%r209,%r210,%r211}, [%rd54]; + // end inline asm + fma.rn.f32 %r745, %r728, %r204, %r696; + fma.rn.f32 %r746, %r727, %r205, %r745; + fma.rn.f32 %r747, %r726, %r206, %r746; + fma.rn.f32 %r748, %r725, %r207, %r747; + fma.rn.f32 %r749, %r724, %r208, %r748; + fma.rn.f32 %r750, %r723, %r209, %r749; + fma.rn.f32 %r751, %r722, %r210, %r750; + fma.rn.f32 %r752, %r721, %r211, %r751; + add.s64 %rd55, %rd10, 33792; + // begin inline asm + ld.global.nc.v4.f32 {%r212,%r213,%r214,%r215}, [%rd55]; + // end inline asm + add.s64 %rd56, %rd10, 33808; + // begin inline asm + ld.global.nc.v4.f32 {%r216,%r217,%r218,%r219}, [%rd56]; + // end inline asm + fma.rn.f32 %r753, %r728, %r212, %r704; + fma.rn.f32 %r754, %r727, %r213, %r753; + fma.rn.f32 %r755, %r726, %r214, %r754; + fma.rn.f32 %r756, %r725, %r215, %r755; + fma.rn.f32 %r757, %r724, %r216, %r756; + fma.rn.f32 %r758, %r723, %r217, %r757; + fma.rn.f32 %r759, %r722, %r218, %r758; + fma.rn.f32 %r760, %r721, %r219, %r759; + add.s64 %rd57, %rd10, 44032; + // begin inline asm + ld.global.nc.v4.f32 {%r220,%r221,%r222,%r223}, [%rd57]; + // end inline asm + add.s64 %rd58, %rd10, 44048; + // begin inline asm + ld.global.nc.v4.f32 {%r224,%r225,%r226,%r227}, [%rd58]; + // end inline asm + fma.rn.f32 %r761, %r728, %r220, %r712; + fma.rn.f32 %r762, %r727, %r221, %r761; + fma.rn.f32 %r763, %r726, %r222, %r762; + fma.rn.f32 %r764, %r725, %r223, %r763; + fma.rn.f32 %r765, %r724, %r224, %r764; + fma.rn.f32 %r766, %r723, %r225, %r765; + fma.rn.f32 %r767, %r722, %r226, %r766; + fma.rn.f32 %r768, %r721, %r227, %r767; + add.s64 %rd59, %rd10, 54272; + // begin inline asm + ld.global.nc.v4.f32 {%r228,%r229,%r230,%r231}, [%rd59]; + // end inline asm + add.s64 %rd60, %rd10, 54288; + // begin inline asm + ld.global.nc.v4.f32 {%r232,%r233,%r234,%r235}, [%rd60]; + // end inline asm + fma.rn.f32 %r769, %r728, %r228, %r720; + fma.rn.f32 %r770, %r727, %r229, %r769; + fma.rn.f32 %r771, %r726, %r230, %r770; + fma.rn.f32 %r772, %r725, %r231, %r771; + fma.rn.f32 %r773, %r724, %r232, %r772; + fma.rn.f32 %r774, %r723, %r233, %r773; + fma.rn.f32 %r775, %r722, %r234, %r774; + fma.rn.f32 %r776, %r721, %r235, %r775; + add.s64 %rd61, %rd9, 2048; + // begin inline asm + ld.global.nc.v4.u32 {%r236,%r237,%r238,%r239}, [%rd61]; + // end inline asm + and.b32 %r777, %r239, -65536; + shl.b32 %r778, %r239, 16; + and.b32 %r779, %r238, -65536; + shl.b32 %r780, %r238, 16; + and.b32 %r781, %r237, -65536; + shl.b32 %r782, %r237, 16; + and.b32 %r783, %r236, -65536; + shl.b32 %r784, %r236, 16; + add.s64 %rd62, %rd10, 4096; + // begin inline asm + ld.global.nc.v4.f32 {%r240,%r241,%r242,%r243}, [%rd62]; + // end inline asm + add.s64 %rd63, %rd10, 4112; + // begin inline asm + ld.global.nc.v4.f32 {%r244,%r245,%r246,%r247}, [%rd63]; + // end inline asm + fma.rn.f32 %r785, %r784, %r240, %r736; + fma.rn.f32 %r786, %r783, %r241, %r785; + fma.rn.f32 %r787, %r782, %r242, %r786; + fma.rn.f32 %r788, %r781, %r243, %r787; + fma.rn.f32 %r789, %r780, %r244, %r788; + fma.rn.f32 %r790, %r779, %r245, %r789; + fma.rn.f32 %r791, %r778, %r246, %r790; + fma.rn.f32 %r792, %r777, %r247, %r791; + add.s64 %rd64, %rd10, 14336; + // begin inline asm + ld.global.nc.v4.f32 {%r248,%r249,%r250,%r251}, [%rd64]; + // end inline asm + add.s64 %rd65, %rd10, 14352; + // begin inline asm + ld.global.nc.v4.f32 {%r252,%r253,%r254,%r255}, [%rd65]; + // end inline asm + fma.rn.f32 %r793, %r784, %r248, %r744; + fma.rn.f32 %r794, %r783, %r249, %r793; + fma.rn.f32 %r795, %r782, %r250, %r794; + fma.rn.f32 %r796, %r781, %r251, %r795; + fma.rn.f32 %r797, %r780, %r252, %r796; + fma.rn.f32 %r798, %r779, %r253, %r797; + fma.rn.f32 %r799, %r778, %r254, %r798; + fma.rn.f32 %r800, %r777, %r255, %r799; + add.s64 %rd66, %rd10, 24576; + // begin inline asm + ld.global.nc.v4.f32 {%r256,%r257,%r258,%r259}, [%rd66]; + // end inline asm + add.s64 %rd67, %rd10, 24592; + // begin inline asm + ld.global.nc.v4.f32 {%r260,%r261,%r262,%r263}, [%rd67]; + // end inline asm + fma.rn.f32 %r801, %r784, %r256, %r752; + fma.rn.f32 %r802, %r783, %r257, %r801; + fma.rn.f32 %r803, %r782, %r258, %r802; + fma.rn.f32 %r804, %r781, %r259, %r803; + fma.rn.f32 %r805, %r780, %r260, %r804; + fma.rn.f32 %r806, %r779, %r261, %r805; + fma.rn.f32 %r807, %r778, %r262, %r806; + fma.rn.f32 %r808, %r777, %r263, %r807; + add.s64 %rd68, %rd10, 34816; + // begin inline asm + ld.global.nc.v4.f32 {%r264,%r265,%r266,%r267}, [%rd68]; + // end inline asm + add.s64 %rd69, %rd10, 34832; + // begin inline asm + ld.global.nc.v4.f32 {%r268,%r269,%r270,%r271}, [%rd69]; + // end inline asm + fma.rn.f32 %r809, %r784, %r264, %r760; + fma.rn.f32 %r810, %r783, %r265, %r809; + fma.rn.f32 %r811, %r782, %r266, %r810; + fma.rn.f32 %r812, %r781, %r267, %r811; + fma.rn.f32 %r813, %r780, %r268, %r812; + fma.rn.f32 %r814, %r779, %r269, %r813; + fma.rn.f32 %r815, %r778, %r270, %r814; + fma.rn.f32 %r816, %r777, %r271, %r815; + add.s64 %rd70, %rd10, 45056; + // begin inline asm + ld.global.nc.v4.f32 {%r272,%r273,%r274,%r275}, [%rd70]; + // end inline asm + add.s64 %rd71, %rd10, 45072; + // begin inline asm + ld.global.nc.v4.f32 {%r276,%r277,%r278,%r279}, [%rd71]; + // end inline asm + fma.rn.f32 %r817, %r784, %r272, %r768; + fma.rn.f32 %r818, %r783, %r273, %r817; + fma.rn.f32 %r819, %r782, %r274, %r818; + fma.rn.f32 %r820, %r781, %r275, %r819; + fma.rn.f32 %r821, %r780, %r276, %r820; + fma.rn.f32 %r822, %r779, %r277, %r821; + fma.rn.f32 %r823, %r778, %r278, %r822; + fma.rn.f32 %r824, %r777, %r279, %r823; + add.s64 %rd72, %rd10, 55296; + // begin inline asm + ld.global.nc.v4.f32 {%r280,%r281,%r282,%r283}, [%rd72]; + // end inline asm + add.s64 %rd73, %rd10, 55312; + // begin inline asm + ld.global.nc.v4.f32 {%r284,%r285,%r286,%r287}, [%rd73]; + // end inline asm + fma.rn.f32 %r825, %r784, %r280, %r776; + fma.rn.f32 %r826, %r783, %r281, %r825; + fma.rn.f32 %r827, %r782, %r282, %r826; + fma.rn.f32 %r828, %r781, %r283, %r827; + fma.rn.f32 %r829, %r780, %r284, %r828; + fma.rn.f32 %r830, %r779, %r285, %r829; + fma.rn.f32 %r831, %r778, %r286, %r830; + fma.rn.f32 %r832, %r777, %r287, %r831; + add.s64 %rd74, %rd9, 2560; + // begin inline asm + ld.global.nc.v4.u32 {%r288,%r289,%r290,%r291}, [%rd74]; + // end inline asm + and.b32 %r833, %r291, -65536; + shl.b32 %r834, %r291, 16; + and.b32 %r835, %r290, -65536; + shl.b32 %r836, %r290, 16; + and.b32 %r837, %r289, -65536; + shl.b32 %r838, %r289, 16; + and.b32 %r839, %r288, -65536; + shl.b32 %r840, %r288, 16; + add.s64 %rd75, %rd10, 5120; + // begin inline asm + ld.global.nc.v4.f32 {%r292,%r293,%r294,%r295}, [%rd75]; + // end inline asm + add.s64 %rd76, %rd10, 5136; + // begin inline asm + ld.global.nc.v4.f32 {%r296,%r297,%r298,%r299}, [%rd76]; + // end inline asm + fma.rn.f32 %r841, %r840, %r292, %r792; + fma.rn.f32 %r842, %r839, %r293, %r841; + fma.rn.f32 %r843, %r838, %r294, %r842; + fma.rn.f32 %r844, %r837, %r295, %r843; + fma.rn.f32 %r845, %r836, %r296, %r844; + fma.rn.f32 %r846, %r835, %r297, %r845; + fma.rn.f32 %r847, %r834, %r298, %r846; + fma.rn.f32 %r848, %r833, %r299, %r847; + add.s64 %rd77, %rd10, 15360; + // begin inline asm + ld.global.nc.v4.f32 {%r300,%r301,%r302,%r303}, [%rd77]; + // end inline asm + add.s64 %rd78, %rd10, 15376; + // begin inline asm + ld.global.nc.v4.f32 {%r304,%r305,%r306,%r307}, [%rd78]; + // end inline asm + fma.rn.f32 %r849, %r840, %r300, %r800; + fma.rn.f32 %r850, %r839, %r301, %r849; + fma.rn.f32 %r851, %r838, %r302, %r850; + fma.rn.f32 %r852, %r837, %r303, %r851; + fma.rn.f32 %r853, %r836, %r304, %r852; + fma.rn.f32 %r854, %r835, %r305, %r853; + fma.rn.f32 %r855, %r834, %r306, %r854; + fma.rn.f32 %r856, %r833, %r307, %r855; + add.s64 %rd79, %rd10, 25600; + // begin inline asm + ld.global.nc.v4.f32 {%r308,%r309,%r310,%r311}, [%rd79]; + // end inline asm + add.s64 %rd80, %rd10, 25616; + // begin inline asm + ld.global.nc.v4.f32 {%r312,%r313,%r314,%r315}, [%rd80]; + // end inline asm + fma.rn.f32 %r857, %r840, %r308, %r808; + fma.rn.f32 %r858, %r839, %r309, %r857; + fma.rn.f32 %r859, %r838, %r310, %r858; + fma.rn.f32 %r860, %r837, %r311, %r859; + fma.rn.f32 %r861, %r836, %r312, %r860; + fma.rn.f32 %r862, %r835, %r313, %r861; + fma.rn.f32 %r863, %r834, %r314, %r862; + fma.rn.f32 %r864, %r833, %r315, %r863; + add.s64 %rd81, %rd10, 35840; + // begin inline asm + ld.global.nc.v4.f32 {%r316,%r317,%r318,%r319}, [%rd81]; + // end inline asm + add.s64 %rd82, %rd10, 35856; + // begin inline asm + ld.global.nc.v4.f32 {%r320,%r321,%r322,%r323}, [%rd82]; + // end inline asm + fma.rn.f32 %r865, %r840, %r316, %r816; + fma.rn.f32 %r866, %r839, %r317, %r865; + fma.rn.f32 %r867, %r838, %r318, %r866; + fma.rn.f32 %r868, %r837, %r319, %r867; + fma.rn.f32 %r869, %r836, %r320, %r868; + fma.rn.f32 %r870, %r835, %r321, %r869; + fma.rn.f32 %r871, %r834, %r322, %r870; + fma.rn.f32 %r872, %r833, %r323, %r871; + add.s64 %rd83, %rd10, 46080; + // begin inline asm + ld.global.nc.v4.f32 {%r324,%r325,%r326,%r327}, [%rd83]; + // end inline asm + add.s64 %rd84, %rd10, 46096; + // begin inline asm + ld.global.nc.v4.f32 {%r328,%r329,%r330,%r331}, [%rd84]; + // end inline asm + fma.rn.f32 %r873, %r840, %r324, %r824; + fma.rn.f32 %r874, %r839, %r325, %r873; + fma.rn.f32 %r875, %r838, %r326, %r874; + fma.rn.f32 %r876, %r837, %r327, %r875; + fma.rn.f32 %r877, %r836, %r328, %r876; + fma.rn.f32 %r878, %r835, %r329, %r877; + fma.rn.f32 %r879, %r834, %r330, %r878; + fma.rn.f32 %r880, %r833, %r331, %r879; + add.s64 %rd85, %rd10, 56320; + // begin inline asm + ld.global.nc.v4.f32 {%r332,%r333,%r334,%r335}, [%rd85]; + // end inline asm + add.s64 %rd86, %rd10, 56336; + // begin inline asm + ld.global.nc.v4.f32 {%r336,%r337,%r338,%r339}, [%rd86]; + // end inline asm + fma.rn.f32 %r881, %r840, %r332, %r832; + fma.rn.f32 %r882, %r839, %r333, %r881; + fma.rn.f32 %r883, %r838, %r334, %r882; + fma.rn.f32 %r884, %r837, %r335, %r883; + fma.rn.f32 %r885, %r836, %r336, %r884; + fma.rn.f32 %r886, %r835, %r337, %r885; + fma.rn.f32 %r887, %r834, %r338, %r886; + fma.rn.f32 %r888, %r833, %r339, %r887; + add.s64 %rd87, %rd9, 3072; + // begin inline asm + ld.global.nc.v4.u32 {%r340,%r341,%r342,%r343}, [%rd87]; + // end inline asm + and.b32 %r889, %r343, -65536; + shl.b32 %r890, %r343, 16; + and.b32 %r891, %r342, -65536; + shl.b32 %r892, %r342, 16; + and.b32 %r893, %r341, -65536; + shl.b32 %r894, %r341, 16; + and.b32 %r895, %r340, -65536; + shl.b32 %r896, %r340, 16; + add.s64 %rd88, %rd10, 6144; + // begin inline asm + ld.global.nc.v4.f32 {%r344,%r345,%r346,%r347}, [%rd88]; + // end inline asm + add.s64 %rd89, %rd10, 6160; + // begin inline asm + ld.global.nc.v4.f32 {%r348,%r349,%r350,%r351}, [%rd89]; + // end inline asm + fma.rn.f32 %r897, %r896, %r344, %r848; + fma.rn.f32 %r898, %r895, %r345, %r897; + fma.rn.f32 %r899, %r894, %r346, %r898; + fma.rn.f32 %r900, %r893, %r347, %r899; + fma.rn.f32 %r901, %r892, %r348, %r900; + fma.rn.f32 %r902, %r891, %r349, %r901; + fma.rn.f32 %r903, %r890, %r350, %r902; + fma.rn.f32 %r904, %r889, %r351, %r903; + add.s64 %rd90, %rd10, 16384; + // begin inline asm + ld.global.nc.v4.f32 {%r352,%r353,%r354,%r355}, [%rd90]; + // end inline asm + add.s64 %rd91, %rd10, 16400; + // begin inline asm + ld.global.nc.v4.f32 {%r356,%r357,%r358,%r359}, [%rd91]; + // end inline asm + fma.rn.f32 %r905, %r896, %r352, %r856; + fma.rn.f32 %r906, %r895, %r353, %r905; + fma.rn.f32 %r907, %r894, %r354, %r906; + fma.rn.f32 %r908, %r893, %r355, %r907; + fma.rn.f32 %r909, %r892, %r356, %r908; + fma.rn.f32 %r910, %r891, %r357, %r909; + fma.rn.f32 %r911, %r890, %r358, %r910; + fma.rn.f32 %r912, %r889, %r359, %r911; + add.s64 %rd92, %rd10, 26624; + // begin inline asm + ld.global.nc.v4.f32 {%r360,%r361,%r362,%r363}, [%rd92]; + // end inline asm + add.s64 %rd93, %rd10, 26640; + // begin inline asm + ld.global.nc.v4.f32 {%r364,%r365,%r366,%r367}, [%rd93]; + // end inline asm + fma.rn.f32 %r913, %r896, %r360, %r864; + fma.rn.f32 %r914, %r895, %r361, %r913; + fma.rn.f32 %r915, %r894, %r362, %r914; + fma.rn.f32 %r916, %r893, %r363, %r915; + fma.rn.f32 %r917, %r892, %r364, %r916; + fma.rn.f32 %r918, %r891, %r365, %r917; + fma.rn.f32 %r919, %r890, %r366, %r918; + fma.rn.f32 %r920, %r889, %r367, %r919; + add.s64 %rd94, %rd10, 36864; + // begin inline asm + ld.global.nc.v4.f32 {%r368,%r369,%r370,%r371}, [%rd94]; + // end inline asm + add.s64 %rd95, %rd10, 36880; + // begin inline asm + ld.global.nc.v4.f32 {%r372,%r373,%r374,%r375}, [%rd95]; + // end inline asm + fma.rn.f32 %r921, %r896, %r368, %r872; + fma.rn.f32 %r922, %r895, %r369, %r921; + fma.rn.f32 %r923, %r894, %r370, %r922; + fma.rn.f32 %r924, %r893, %r371, %r923; + fma.rn.f32 %r925, %r892, %r372, %r924; + fma.rn.f32 %r926, %r891, %r373, %r925; + fma.rn.f32 %r927, %r890, %r374, %r926; + fma.rn.f32 %r928, %r889, %r375, %r927; + add.s64 %rd96, %rd10, 47104; + // begin inline asm + ld.global.nc.v4.f32 {%r376,%r377,%r378,%r379}, [%rd96]; + // end inline asm + add.s64 %rd97, %rd10, 47120; + // begin inline asm + ld.global.nc.v4.f32 {%r380,%r381,%r382,%r383}, [%rd97]; + // end inline asm + fma.rn.f32 %r929, %r896, %r376, %r880; + fma.rn.f32 %r930, %r895, %r377, %r929; + fma.rn.f32 %r931, %r894, %r378, %r930; + fma.rn.f32 %r932, %r893, %r379, %r931; + fma.rn.f32 %r933, %r892, %r380, %r932; + fma.rn.f32 %r934, %r891, %r381, %r933; + fma.rn.f32 %r935, %r890, %r382, %r934; + fma.rn.f32 %r936, %r889, %r383, %r935; + add.s64 %rd98, %rd10, 57344; + // begin inline asm + ld.global.nc.v4.f32 {%r384,%r385,%r386,%r387}, [%rd98]; + // end inline asm + add.s64 %rd99, %rd10, 57360; + // begin inline asm + ld.global.nc.v4.f32 {%r388,%r389,%r390,%r391}, [%rd99]; + // end inline asm + fma.rn.f32 %r937, %r896, %r384, %r888; + fma.rn.f32 %r938, %r895, %r385, %r937; + fma.rn.f32 %r939, %r894, %r386, %r938; + fma.rn.f32 %r940, %r893, %r387, %r939; + fma.rn.f32 %r941, %r892, %r388, %r940; + fma.rn.f32 %r942, %r891, %r389, %r941; + fma.rn.f32 %r943, %r890, %r390, %r942; + fma.rn.f32 %r944, %r889, %r391, %r943; + add.s64 %rd100, %rd9, 3584; + // begin inline asm + ld.global.nc.v4.u32 {%r392,%r393,%r394,%r395}, [%rd100]; + // end inline asm + and.b32 %r945, %r395, -65536; + shl.b32 %r946, %r395, 16; + and.b32 %r947, %r394, -65536; + shl.b32 %r948, %r394, 16; + and.b32 %r949, %r393, -65536; + shl.b32 %r950, %r393, 16; + and.b32 %r951, %r392, -65536; + shl.b32 %r952, %r392, 16; + add.s64 %rd101, %rd10, 7168; + // begin inline asm + ld.global.nc.v4.f32 {%r396,%r397,%r398,%r399}, [%rd101]; + // end inline asm + add.s64 %rd102, %rd10, 7184; + // begin inline asm + ld.global.nc.v4.f32 {%r400,%r401,%r402,%r403}, [%rd102]; + // end inline asm + fma.rn.f32 %r953, %r952, %r396, %r904; + fma.rn.f32 %r954, %r951, %r397, %r953; + fma.rn.f32 %r955, %r950, %r398, %r954; + fma.rn.f32 %r956, %r949, %r399, %r955; + fma.rn.f32 %r957, %r948, %r400, %r956; + fma.rn.f32 %r958, %r947, %r401, %r957; + fma.rn.f32 %r959, %r946, %r402, %r958; + fma.rn.f32 %r960, %r945, %r403, %r959; + add.s64 %rd103, %rd10, 17408; + // begin inline asm + ld.global.nc.v4.f32 {%r404,%r405,%r406,%r407}, [%rd103]; + // end inline asm + add.s64 %rd104, %rd10, 17424; + // begin inline asm + ld.global.nc.v4.f32 {%r408,%r409,%r410,%r411}, [%rd104]; + // end inline asm + fma.rn.f32 %r961, %r952, %r404, %r912; + fma.rn.f32 %r962, %r951, %r405, %r961; + fma.rn.f32 %r963, %r950, %r406, %r962; + fma.rn.f32 %r964, %r949, %r407, %r963; + fma.rn.f32 %r965, %r948, %r408, %r964; + fma.rn.f32 %r966, %r947, %r409, %r965; + fma.rn.f32 %r967, %r946, %r410, %r966; + fma.rn.f32 %r968, %r945, %r411, %r967; + add.s64 %rd105, %rd10, 27648; + // begin inline asm + ld.global.nc.v4.f32 {%r412,%r413,%r414,%r415}, [%rd105]; + // end inline asm + add.s64 %rd106, %rd10, 27664; + // begin inline asm + ld.global.nc.v4.f32 {%r416,%r417,%r418,%r419}, [%rd106]; + // end inline asm + fma.rn.f32 %r969, %r952, %r412, %r920; + fma.rn.f32 %r970, %r951, %r413, %r969; + fma.rn.f32 %r971, %r950, %r414, %r970; + fma.rn.f32 %r972, %r949, %r415, %r971; + fma.rn.f32 %r973, %r948, %r416, %r972; + fma.rn.f32 %r974, %r947, %r417, %r973; + fma.rn.f32 %r975, %r946, %r418, %r974; + fma.rn.f32 %r976, %r945, %r419, %r975; + add.s64 %rd107, %rd10, 37888; + // begin inline asm + ld.global.nc.v4.f32 {%r420,%r421,%r422,%r423}, [%rd107]; + // end inline asm + add.s64 %rd108, %rd10, 37904; + // begin inline asm + ld.global.nc.v4.f32 {%r424,%r425,%r426,%r427}, [%rd108]; + // end inline asm + fma.rn.f32 %r977, %r952, %r420, %r928; + fma.rn.f32 %r978, %r951, %r421, %r977; + fma.rn.f32 %r979, %r950, %r422, %r978; + fma.rn.f32 %r980, %r949, %r423, %r979; + fma.rn.f32 %r981, %r948, %r424, %r980; + fma.rn.f32 %r982, %r947, %r425, %r981; + fma.rn.f32 %r983, %r946, %r426, %r982; + fma.rn.f32 %r984, %r945, %r427, %r983; + add.s64 %rd109, %rd10, 48128; + // begin inline asm + ld.global.nc.v4.f32 {%r428,%r429,%r430,%r431}, [%rd109]; + // end inline asm + add.s64 %rd110, %rd10, 48144; + // begin inline asm + ld.global.nc.v4.f32 {%r432,%r433,%r434,%r435}, [%rd110]; + // end inline asm + fma.rn.f32 %r985, %r952, %r428, %r936; + fma.rn.f32 %r986, %r951, %r429, %r985; + fma.rn.f32 %r987, %r950, %r430, %r986; + fma.rn.f32 %r988, %r949, %r431, %r987; + fma.rn.f32 %r989, %r948, %r432, %r988; + fma.rn.f32 %r990, %r947, %r433, %r989; + fma.rn.f32 %r991, %r946, %r434, %r990; + fma.rn.f32 %r992, %r945, %r435, %r991; + add.s64 %rd111, %rd10, 58368; + // begin inline asm + ld.global.nc.v4.f32 {%r436,%r437,%r438,%r439}, [%rd111]; + // end inline asm + add.s64 %rd112, %rd10, 58384; + // begin inline asm + ld.global.nc.v4.f32 {%r440,%r441,%r442,%r443}, [%rd112]; + // end inline asm + fma.rn.f32 %r993, %r952, %r436, %r944; + fma.rn.f32 %r994, %r951, %r437, %r993; + fma.rn.f32 %r995, %r950, %r438, %r994; + fma.rn.f32 %r996, %r949, %r439, %r995; + fma.rn.f32 %r997, %r948, %r440, %r996; + fma.rn.f32 %r998, %r947, %r441, %r997; + fma.rn.f32 %r999, %r946, %r442, %r998; + fma.rn.f32 %r1000, %r945, %r443, %r999; + add.s64 %rd113, %rd9, 4096; + // begin inline asm + ld.global.nc.v4.u32 {%r444,%r445,%r446,%r447}, [%rd113]; + // end inline asm + and.b32 %r1001, %r447, -65536; + shl.b32 %r1002, %r447, 16; + and.b32 %r1003, %r446, -65536; + shl.b32 %r1004, %r446, 16; + and.b32 %r1005, %r445, -65536; + shl.b32 %r1006, %r445, 16; + and.b32 %r1007, %r444, -65536; + shl.b32 %r1008, %r444, 16; + add.s64 %rd114, %rd10, 8192; + // begin inline asm + ld.global.nc.v4.f32 {%r448,%r449,%r450,%r451}, [%rd114]; + // end inline asm + add.s64 %rd115, %rd10, 8208; + // begin inline asm + ld.global.nc.v4.f32 {%r452,%r453,%r454,%r455}, [%rd115]; + // end inline asm + fma.rn.f32 %r1009, %r1008, %r448, %r960; + fma.rn.f32 %r1010, %r1007, %r449, %r1009; + fma.rn.f32 %r1011, %r1006, %r450, %r1010; + fma.rn.f32 %r1012, %r1005, %r451, %r1011; + fma.rn.f32 %r1013, %r1004, %r452, %r1012; + fma.rn.f32 %r1014, %r1003, %r453, %r1013; + fma.rn.f32 %r1015, %r1002, %r454, %r1014; + fma.rn.f32 %r1016, %r1001, %r455, %r1015; + add.s64 %rd116, %rd10, 18432; + // begin inline asm + ld.global.nc.v4.f32 {%r456,%r457,%r458,%r459}, [%rd116]; + // end inline asm + add.s64 %rd117, %rd10, 18448; + // begin inline asm + ld.global.nc.v4.f32 {%r460,%r461,%r462,%r463}, [%rd117]; + // end inline asm + fma.rn.f32 %r1017, %r1008, %r456, %r968; + fma.rn.f32 %r1018, %r1007, %r457, %r1017; + fma.rn.f32 %r1019, %r1006, %r458, %r1018; + fma.rn.f32 %r1020, %r1005, %r459, %r1019; + fma.rn.f32 %r1021, %r1004, %r460, %r1020; + fma.rn.f32 %r1022, %r1003, %r461, %r1021; + fma.rn.f32 %r1023, %r1002, %r462, %r1022; + fma.rn.f32 %r1024, %r1001, %r463, %r1023; + add.s64 %rd118, %rd10, 28672; + // begin inline asm + ld.global.nc.v4.f32 {%r464,%r465,%r466,%r467}, [%rd118]; + // end inline asm + add.s64 %rd119, %rd10, 28688; + // begin inline asm + ld.global.nc.v4.f32 {%r468,%r469,%r470,%r471}, [%rd119]; + // end inline asm + fma.rn.f32 %r1025, %r1008, %r464, %r976; + fma.rn.f32 %r1026, %r1007, %r465, %r1025; + fma.rn.f32 %r1027, %r1006, %r466, %r1026; + fma.rn.f32 %r1028, %r1005, %r467, %r1027; + fma.rn.f32 %r1029, %r1004, %r468, %r1028; + fma.rn.f32 %r1030, %r1003, %r469, %r1029; + fma.rn.f32 %r1031, %r1002, %r470, %r1030; + fma.rn.f32 %r1032, %r1001, %r471, %r1031; + add.s64 %rd120, %rd10, 38912; + // begin inline asm + ld.global.nc.v4.f32 {%r472,%r473,%r474,%r475}, [%rd120]; + // end inline asm + add.s64 %rd121, %rd10, 38928; + // begin inline asm + ld.global.nc.v4.f32 {%r476,%r477,%r478,%r479}, [%rd121]; + // end inline asm + fma.rn.f32 %r1033, %r1008, %r472, %r984; + fma.rn.f32 %r1034, %r1007, %r473, %r1033; + fma.rn.f32 %r1035, %r1006, %r474, %r1034; + fma.rn.f32 %r1036, %r1005, %r475, %r1035; + fma.rn.f32 %r1037, %r1004, %r476, %r1036; + fma.rn.f32 %r1038, %r1003, %r477, %r1037; + fma.rn.f32 %r1039, %r1002, %r478, %r1038; + fma.rn.f32 %r1040, %r1001, %r479, %r1039; + add.s64 %rd122, %rd10, 49152; + // begin inline asm + ld.global.nc.v4.f32 {%r480,%r481,%r482,%r483}, [%rd122]; + // end inline asm + add.s64 %rd123, %rd10, 49168; + // begin inline asm + ld.global.nc.v4.f32 {%r484,%r485,%r486,%r487}, [%rd123]; + // end inline asm + fma.rn.f32 %r1041, %r1008, %r480, %r992; + fma.rn.f32 %r1042, %r1007, %r481, %r1041; + fma.rn.f32 %r1043, %r1006, %r482, %r1042; + fma.rn.f32 %r1044, %r1005, %r483, %r1043; + fma.rn.f32 %r1045, %r1004, %r484, %r1044; + fma.rn.f32 %r1046, %r1003, %r485, %r1045; + fma.rn.f32 %r1047, %r1002, %r486, %r1046; + fma.rn.f32 %r1048, %r1001, %r487, %r1047; + add.s64 %rd124, %rd10, 59392; + // begin inline asm + ld.global.nc.v4.f32 {%r488,%r489,%r490,%r491}, [%rd124]; + // end inline asm + add.s64 %rd125, %rd10, 59408; + // begin inline asm + ld.global.nc.v4.f32 {%r492,%r493,%r494,%r495}, [%rd125]; + // end inline asm + fma.rn.f32 %r1049, %r1008, %r488, %r1000; + fma.rn.f32 %r1050, %r1007, %r489, %r1049; + fma.rn.f32 %r1051, %r1006, %r490, %r1050; + fma.rn.f32 %r1052, %r1005, %r491, %r1051; + fma.rn.f32 %r1053, %r1004, %r492, %r1052; + fma.rn.f32 %r1054, %r1003, %r493, %r1053; + fma.rn.f32 %r1055, %r1002, %r494, %r1054; + fma.rn.f32 %r1056, %r1001, %r495, %r1055; + add.s64 %rd126, %rd9, 4608; + // begin inline asm + ld.global.nc.v4.u32 {%r496,%r497,%r498,%r499}, [%rd126]; + // end inline asm + and.b32 %r1057, %r499, -65536; + shl.b32 %r1058, %r499, 16; + and.b32 %r1059, %r498, -65536; + shl.b32 %r1060, %r498, 16; + and.b32 %r1061, %r497, -65536; + shl.b32 %r1062, %r497, 16; + and.b32 %r1063, %r496, -65536; + shl.b32 %r1064, %r496, 16; + add.s64 %rd127, %rd10, 9216; + // begin inline asm + ld.global.nc.v4.f32 {%r500,%r501,%r502,%r503}, [%rd127]; + // end inline asm + add.s64 %rd128, %rd10, 9232; + // begin inline asm + ld.global.nc.v4.f32 {%r504,%r505,%r506,%r507}, [%rd128]; + // end inline asm + fma.rn.f32 %r1065, %r1064, %r500, %r1016; + fma.rn.f32 %r1066, %r1063, %r501, %r1065; + fma.rn.f32 %r1067, %r1062, %r502, %r1066; + fma.rn.f32 %r1068, %r1061, %r503, %r1067; + fma.rn.f32 %r1069, %r1060, %r504, %r1068; + fma.rn.f32 %r1070, %r1059, %r505, %r1069; + fma.rn.f32 %r1071, %r1058, %r506, %r1070; + fma.rn.f32 %r1072, %r1057, %r507, %r1071; + add.s64 %rd129, %rd10, 19456; + // begin inline asm + ld.global.nc.v4.f32 {%r508,%r509,%r510,%r511}, [%rd129]; + // end inline asm + add.s64 %rd130, %rd10, 19472; + // begin inline asm + ld.global.nc.v4.f32 {%r512,%r513,%r514,%r515}, [%rd130]; + // end inline asm + fma.rn.f32 %r1073, %r1064, %r508, %r1024; + fma.rn.f32 %r1074, %r1063, %r509, %r1073; + fma.rn.f32 %r1075, %r1062, %r510, %r1074; + fma.rn.f32 %r1076, %r1061, %r511, %r1075; + fma.rn.f32 %r1077, %r1060, %r512, %r1076; + fma.rn.f32 %r1078, %r1059, %r513, %r1077; + fma.rn.f32 %r1079, %r1058, %r514, %r1078; + fma.rn.f32 %r4, %r1057, %r515, %r1079; + add.s64 %rd131, %rd10, 29696; + // begin inline asm + ld.global.nc.v4.f32 {%r516,%r517,%r518,%r519}, [%rd131]; + // end inline asm + add.s64 %rd132, %rd10, 29712; + // begin inline asm + ld.global.nc.v4.f32 {%r520,%r521,%r522,%r523}, [%rd132]; + // end inline asm + fma.rn.f32 %r1080, %r1064, %r516, %r1032; + fma.rn.f32 %r1081, %r1063, %r517, %r1080; + fma.rn.f32 %r1082, %r1062, %r518, %r1081; + fma.rn.f32 %r1083, %r1061, %r519, %r1082; + fma.rn.f32 %r1084, %r1060, %r520, %r1083; + fma.rn.f32 %r1085, %r1059, %r521, %r1084; + fma.rn.f32 %r1086, %r1058, %r522, %r1085; + fma.rn.f32 %r5, %r1057, %r523, %r1086; + add.s64 %rd133, %rd10, 39936; + // begin inline asm + ld.global.nc.v4.f32 {%r524,%r525,%r526,%r527}, [%rd133]; + // end inline asm + add.s64 %rd134, %rd10, 39952; + // begin inline asm + ld.global.nc.v4.f32 {%r528,%r529,%r530,%r531}, [%rd134]; + // end inline asm + fma.rn.f32 %r1087, %r1064, %r524, %r1040; + fma.rn.f32 %r1088, %r1063, %r525, %r1087; + fma.rn.f32 %r1089, %r1062, %r526, %r1088; + fma.rn.f32 %r1090, %r1061, %r527, %r1089; + fma.rn.f32 %r1091, %r1060, %r528, %r1090; + fma.rn.f32 %r1092, %r1059, %r529, %r1091; + fma.rn.f32 %r1093, %r1058, %r530, %r1092; + fma.rn.f32 %r6, %r1057, %r531, %r1093; + add.s64 %rd135, %rd10, 50176; + // begin inline asm + ld.global.nc.v4.f32 {%r532,%r533,%r534,%r535}, [%rd135]; + // end inline asm + add.s64 %rd136, %rd10, 50192; + // begin inline asm + ld.global.nc.v4.f32 {%r536,%r537,%r538,%r539}, [%rd136]; + // end inline asm + fma.rn.f32 %r1094, %r1064, %r532, %r1048; + fma.rn.f32 %r1095, %r1063, %r533, %r1094; + fma.rn.f32 %r1096, %r1062, %r534, %r1095; + fma.rn.f32 %r1097, %r1061, %r535, %r1096; + fma.rn.f32 %r1098, %r1060, %r536, %r1097; + fma.rn.f32 %r1099, %r1059, %r537, %r1098; + fma.rn.f32 %r1100, %r1058, %r538, %r1099; + fma.rn.f32 %r7, %r1057, %r539, %r1100; + add.s64 %rd137, %rd10, 60416; + // begin inline asm + ld.global.nc.v4.f32 {%r540,%r541,%r542,%r543}, [%rd137]; + // end inline asm + add.s64 %rd138, %rd10, 60432; + // begin inline asm + ld.global.nc.v4.f32 {%r544,%r545,%r546,%r547}, [%rd138]; + // end inline asm + fma.rn.f32 %r1101, %r1064, %r540, %r1056; + fma.rn.f32 %r1102, %r1063, %r541, %r1101; + fma.rn.f32 %r1103, %r1062, %r542, %r1102; + fma.rn.f32 %r1104, %r1061, %r543, %r1103; + fma.rn.f32 %r1105, %r1060, %r544, %r1104; + fma.rn.f32 %r1106, %r1059, %r545, %r1105; + fma.rn.f32 %r1107, %r1058, %r546, %r1106; + fma.rn.f32 %r8, %r1057, %r547, %r1107; + setp.ne.b32 %p3, %r3, 0; + mul.wide.s32 %rd147, %r549, 4; + add.s64 %rd2, %rd139, %rd147; + add.s64 %rd3, %rd140, %rd147; + cvt.s64.s32 %rd4, %r22; + shfl.sync.bfly.b32 %r1108|%p4, %r1072, 16, 31, -1; + add.f32 %r1109, %r1072, %r1108; + shfl.sync.bfly.b32 %r1110|%p5, %r1109, 8, 31, -1; + add.f32 %r1111, %r1109, %r1110; + shfl.sync.bfly.b32 %r1112|%p6, %r1111, 4, 31, -1; + add.f32 %r1113, %r1111, %r1112; + shfl.sync.bfly.b32 %r1114|%p7, %r1113, 2, 31, -1; + add.f32 %r1115, %r1113, %r1114; + shfl.sync.bfly.b32 %r1116|%p8, %r1115, 1, 31, -1; + add.f32 %r9, %r1115, %r1116; + @%p3 bra $L__BB6_9; + setp.lt.s32 %p9, %r2, %r22; + @%p9 bra $L__BB6_4; + mul.f32 %r1117, %r9, 0fBFB8AA3B; + ex2.approx.f32 %r1118, %r1117; + add.f32 %r1119, %r1118, 0f3F800000; + rcp.rn.f32 %r1330, %r1119; + mov.b64 %rd175, %rd8; + bra.uni $L__BB6_8; +$L__BB6_4: + ld.global.nc.b32 %r1120, [%rd2]; + add.f32 %r1329, %r9, %r1120; + setp.gt.f32 %p10, %r1329, 0f41A00000; + @%p10 bra $L__BB6_7; + mul.f32 %r1121, %r1329, 0f3FB8AA3B; + ex2.approx.f32 %r10, %r1121; + mov.b32 %r1122, 0f3F800000; + add.rz.f32 %r1123, %r10, %r1122; + add.s32 %r1124, %r1123, -1061158912; + and.b32 %r1125, %r1124, -8388608; + sub.s32 %r1126, %r10, %r1125; + sub.s32 %r1127, 1082130432, %r1125; + fma.rn.f32 %r1128, %r1127, 0f3E800000, 0fBF800000; + add.f32 %r1129, %r1128, %r1126; + cvt.rn.f32.s32 %r1130, %r1125; + mul.f32 %r1131, %r1130, 0f34000000; + fma.rn.f32 %r1132, %r1129, 0fBD39BF78, 0f3DD80012; + fma.rn.f32 %r1133, %r1132, %r1129, 0fBE0778E0; + fma.rn.f32 %r1134, %r1133, %r1129, 0f3E146475; + fma.rn.f32 %r1135, %r1134, %r1129, 0fBE2A68DD; + fma.rn.f32 %r1136, %r1135, %r1129, 0f3E4CAF9E; + fma.rn.f32 %r1137, %r1136, %r1129, 0fBE800042; + fma.rn.f32 %r1138, %r1137, %r1129, 0f3EAAAAE6; + fma.rn.f32 %r1139, %r1138, %r1129, 0fBF000000; + mul.f32 %r1140, %r1129, %r1139; + fma.rn.f32 %r1141, %r1140, %r1129, %r1129; + fma.rn.f32 %r1329, %r1131, 0f3F317218, %r1141; + setp.lt.u32 %p11, %r10, 2139095040; + @%p11 bra $L__BB6_7; + setp.gt.s32 %p12, %r10, -1082130432; + fma.rn.f32 %r1142, %r10, 0f7F800000, 0f7F800000; + selp.f32 %r1143, %r1142, %r1329, %p12; + setp.eq.f32 %p13, %r10, 0f00000000; + selp.f32 %r1329, 0f80000000, %r1143, %p13; +$L__BB6_7: + ld.global.nc.b32 %r1144, [%rd3]; + mul.f32 %r1330, %r1144, %r1329; + mov.b64 %rd175, %rd180; +$L__BB6_8: + cvta.to.global.u64 %rd148, %rd175; + shl.b64 %rd149, %rd1, 2; + add.s64 %rd150, %rd148, %rd149; + st.global.b32 [%rd150], %r1330; +$L__BB6_9: + setp.ne.b32 %p14, %r3, 0; + shfl.sync.bfly.b32 %r1145|%p15, %r4, 16, 31, -1; + add.f32 %r1146, %r4, %r1145; + shfl.sync.bfly.b32 %r1147|%p16, %r1146, 8, 31, -1; + add.f32 %r1148, %r1146, %r1147; + shfl.sync.bfly.b32 %r1149|%p17, %r1148, 4, 31, -1; + add.f32 %r1150, %r1148, %r1149; + shfl.sync.bfly.b32 %r1151|%p18, %r1150, 2, 31, -1; + add.f32 %r1152, %r1150, %r1151; + shfl.sync.bfly.b32 %r1153|%p19, %r1152, 1, 31, -1; + add.f32 %r11, %r1152, %r1153; + @%p14 bra $L__BB6_17; + setp.lt.s32 %p20, %r2, %r22; + @%p20 bra $L__BB6_12; + mul.f32 %r1154, %r11, 0fBFB8AA3B; + ex2.approx.f32 %r1155, %r1154; + add.f32 %r1156, %r1155, 0f3F800000; + rcp.rn.f32 %r1332, %r1156; + mov.b64 %rd176, %rd8; + bra.uni $L__BB6_16; +$L__BB6_12: + ld.global.nc.b32 %r1157, [%rd2]; + add.f32 %r1331, %r11, %r1157; + setp.gt.f32 %p21, %r1331, 0f41A00000; + @%p21 bra $L__BB6_15; + mul.f32 %r1158, %r1331, 0f3FB8AA3B; + ex2.approx.f32 %r12, %r1158; + mov.b32 %r1159, 0f3F800000; + add.rz.f32 %r1160, %r12, %r1159; + add.s32 %r1161, %r1160, -1061158912; + and.b32 %r1162, %r1161, -8388608; + sub.s32 %r1163, %r12, %r1162; + sub.s32 %r1164, 1082130432, %r1162; + fma.rn.f32 %r1165, %r1164, 0f3E800000, 0fBF800000; + add.f32 %r1166, %r1165, %r1163; + cvt.rn.f32.s32 %r1167, %r1162; + mul.f32 %r1168, %r1167, 0f34000000; + fma.rn.f32 %r1169, %r1166, 0fBD39BF78, 0f3DD80012; + fma.rn.f32 %r1170, %r1169, %r1166, 0fBE0778E0; + fma.rn.f32 %r1171, %r1170, %r1166, 0f3E146475; + fma.rn.f32 %r1172, %r1171, %r1166, 0fBE2A68DD; + fma.rn.f32 %r1173, %r1172, %r1166, 0f3E4CAF9E; + fma.rn.f32 %r1174, %r1173, %r1166, 0fBE800042; + fma.rn.f32 %r1175, %r1174, %r1166, 0f3EAAAAE6; + fma.rn.f32 %r1176, %r1175, %r1166, 0fBF000000; + mul.f32 %r1177, %r1166, %r1176; + fma.rn.f32 %r1178, %r1177, %r1166, %r1166; + fma.rn.f32 %r1331, %r1168, 0f3F317218, %r1178; + setp.lt.u32 %p22, %r12, 2139095040; + @%p22 bra $L__BB6_15; + setp.gt.s32 %p23, %r12, -1082130432; + fma.rn.f32 %r1179, %r12, 0f7F800000, 0f7F800000; + selp.f32 %r1180, %r1179, %r1331, %p23; + setp.eq.f32 %p24, %r12, 0f00000000; + selp.f32 %r1331, 0f80000000, %r1180, %p24; +$L__BB6_15: + ld.global.nc.b32 %r1181, [%rd3]; + mul.f32 %r1332, %r1181, %r1331; + mov.b64 %rd176, %rd180; +$L__BB6_16: + cvta.to.global.u64 %rd151, %rd176; + add.s64 %rd152, %rd4, %rd1; + shl.b64 %rd153, %rd152, 2; + add.s64 %rd154, %rd151, %rd153; + st.global.b32 [%rd154], %r1332; +$L__BB6_17: + setp.ne.b32 %p25, %r3, 0; + shfl.sync.bfly.b32 %r1182|%p26, %r5, 16, 31, -1; + add.f32 %r1183, %r5, %r1182; + shfl.sync.bfly.b32 %r1184|%p27, %r1183, 8, 31, -1; + add.f32 %r1185, %r1183, %r1184; + shfl.sync.bfly.b32 %r1186|%p28, %r1185, 4, 31, -1; + add.f32 %r1187, %r1185, %r1186; + shfl.sync.bfly.b32 %r1188|%p29, %r1187, 2, 31, -1; + add.f32 %r1189, %r1187, %r1188; + shfl.sync.bfly.b32 %r1190|%p30, %r1189, 1, 31, -1; + add.f32 %r13, %r1189, %r1190; + @%p25 bra $L__BB6_25; + setp.lt.s32 %p31, %r2, %r22; + @%p31 bra $L__BB6_20; + mul.f32 %r1191, %r13, 0fBFB8AA3B; + ex2.approx.f32 %r1192, %r1191; + add.f32 %r1193, %r1192, 0f3F800000; + rcp.rn.f32 %r1334, %r1193; + mov.b64 %rd177, %rd8; + bra.uni $L__BB6_24; +$L__BB6_20: + ld.global.nc.b32 %r1194, [%rd2]; + add.f32 %r1333, %r13, %r1194; + setp.gt.f32 %p32, %r1333, 0f41A00000; + @%p32 bra $L__BB6_23; + mul.f32 %r1195, %r1333, 0f3FB8AA3B; + ex2.approx.f32 %r14, %r1195; + mov.b32 %r1196, 0f3F800000; + add.rz.f32 %r1197, %r14, %r1196; + add.s32 %r1198, %r1197, -1061158912; + and.b32 %r1199, %r1198, -8388608; + sub.s32 %r1200, %r14, %r1199; + sub.s32 %r1201, 1082130432, %r1199; + fma.rn.f32 %r1202, %r1201, 0f3E800000, 0fBF800000; + add.f32 %r1203, %r1202, %r1200; + cvt.rn.f32.s32 %r1204, %r1199; + mul.f32 %r1205, %r1204, 0f34000000; + fma.rn.f32 %r1206, %r1203, 0fBD39BF78, 0f3DD80012; + fma.rn.f32 %r1207, %r1206, %r1203, 0fBE0778E0; + fma.rn.f32 %r1208, %r1207, %r1203, 0f3E146475; + fma.rn.f32 %r1209, %r1208, %r1203, 0fBE2A68DD; + fma.rn.f32 %r1210, %r1209, %r1203, 0f3E4CAF9E; + fma.rn.f32 %r1211, %r1210, %r1203, 0fBE800042; + fma.rn.f32 %r1212, %r1211, %r1203, 0f3EAAAAE6; + fma.rn.f32 %r1213, %r1212, %r1203, 0fBF000000; + mul.f32 %r1214, %r1203, %r1213; + fma.rn.f32 %r1215, %r1214, %r1203, %r1203; + fma.rn.f32 %r1333, %r1205, 0f3F317218, %r1215; + setp.lt.u32 %p33, %r14, 2139095040; + @%p33 bra $L__BB6_23; + setp.gt.s32 %p34, %r14, -1082130432; + fma.rn.f32 %r1216, %r14, 0f7F800000, 0f7F800000; + selp.f32 %r1217, %r1216, %r1333, %p34; + setp.eq.f32 %p35, %r14, 0f00000000; + selp.f32 %r1333, 0f80000000, %r1217, %p35; +$L__BB6_23: + ld.global.nc.b32 %r1218, [%rd3]; + mul.f32 %r1334, %r1218, %r1333; + mov.b64 %rd177, %rd180; +$L__BB6_24: + cvta.to.global.u64 %rd155, %rd177; + shl.b64 %rd156, %rd4, 1; + add.s64 %rd157, %rd156, %rd1; + shl.b64 %rd158, %rd157, 2; + add.s64 %rd159, %rd155, %rd158; + st.global.b32 [%rd159], %r1334; +$L__BB6_25: + setp.ne.b32 %p36, %r3, 0; + shfl.sync.bfly.b32 %r1219|%p37, %r6, 16, 31, -1; + add.f32 %r1220, %r6, %r1219; + shfl.sync.bfly.b32 %r1221|%p38, %r1220, 8, 31, -1; + add.f32 %r1222, %r1220, %r1221; + shfl.sync.bfly.b32 %r1223|%p39, %r1222, 4, 31, -1; + add.f32 %r1224, %r1222, %r1223; + shfl.sync.bfly.b32 %r1225|%p40, %r1224, 2, 31, -1; + add.f32 %r1226, %r1224, %r1225; + shfl.sync.bfly.b32 %r1227|%p41, %r1226, 1, 31, -1; + add.f32 %r15, %r1226, %r1227; + @%p36 bra $L__BB6_33; + setp.lt.s32 %p42, %r2, %r22; + @%p42 bra $L__BB6_28; + mul.f32 %r1228, %r15, 0fBFB8AA3B; + ex2.approx.f32 %r1229, %r1228; + add.f32 %r1230, %r1229, 0f3F800000; + rcp.rn.f32 %r1336, %r1230; + mov.b64 %rd178, %rd8; + bra.uni $L__BB6_32; +$L__BB6_28: + ld.global.nc.b32 %r1231, [%rd2]; + add.f32 %r1335, %r15, %r1231; + setp.gt.f32 %p43, %r1335, 0f41A00000; + @%p43 bra $L__BB6_31; + mul.f32 %r1232, %r1335, 0f3FB8AA3B; + ex2.approx.f32 %r16, %r1232; + mov.b32 %r1233, 0f3F800000; + add.rz.f32 %r1234, %r16, %r1233; + add.s32 %r1235, %r1234, -1061158912; + and.b32 %r1236, %r1235, -8388608; + sub.s32 %r1237, %r16, %r1236; + sub.s32 %r1238, 1082130432, %r1236; + fma.rn.f32 %r1239, %r1238, 0f3E800000, 0fBF800000; + add.f32 %r1240, %r1239, %r1237; + cvt.rn.f32.s32 %r1241, %r1236; + mul.f32 %r1242, %r1241, 0f34000000; + fma.rn.f32 %r1243, %r1240, 0fBD39BF78, 0f3DD80012; + fma.rn.f32 %r1244, %r1243, %r1240, 0fBE0778E0; + fma.rn.f32 %r1245, %r1244, %r1240, 0f3E146475; + fma.rn.f32 %r1246, %r1245, %r1240, 0fBE2A68DD; + fma.rn.f32 %r1247, %r1246, %r1240, 0f3E4CAF9E; + fma.rn.f32 %r1248, %r1247, %r1240, 0fBE800042; + fma.rn.f32 %r1249, %r1248, %r1240, 0f3EAAAAE6; + fma.rn.f32 %r1250, %r1249, %r1240, 0fBF000000; + mul.f32 %r1251, %r1240, %r1250; + fma.rn.f32 %r1252, %r1251, %r1240, %r1240; + fma.rn.f32 %r1335, %r1242, 0f3F317218, %r1252; + setp.lt.u32 %p44, %r16, 2139095040; + @%p44 bra $L__BB6_31; + setp.gt.s32 %p45, %r16, -1082130432; + fma.rn.f32 %r1253, %r16, 0f7F800000, 0f7F800000; + selp.f32 %r1254, %r1253, %r1335, %p45; + setp.eq.f32 %p46, %r16, 0f00000000; + selp.f32 %r1335, 0f80000000, %r1254, %p46; +$L__BB6_31: + ld.global.nc.b32 %r1255, [%rd3]; + mul.f32 %r1336, %r1255, %r1335; + mov.b64 %rd178, %rd180; +$L__BB6_32: + cvta.to.global.u64 %rd160, %rd178; + mad.lo.s64 %rd161, %rd4, 3, %rd1; + shl.b64 %rd162, %rd161, 2; + add.s64 %rd163, %rd160, %rd162; + st.global.b32 [%rd163], %r1336; +$L__BB6_33: + setp.ne.b32 %p47, %r3, 0; + shfl.sync.bfly.b32 %r1256|%p48, %r7, 16, 31, -1; + add.f32 %r1257, %r7, %r1256; + shfl.sync.bfly.b32 %r1258|%p49, %r1257, 8, 31, -1; + add.f32 %r1259, %r1257, %r1258; + shfl.sync.bfly.b32 %r1260|%p50, %r1259, 4, 31, -1; + add.f32 %r1261, %r1259, %r1260; + shfl.sync.bfly.b32 %r1262|%p51, %r1261, 2, 31, -1; + add.f32 %r1263, %r1261, %r1262; + shfl.sync.bfly.b32 %r1264|%p52, %r1263, 1, 31, -1; + add.f32 %r17, %r1263, %r1264; + @%p47 bra $L__BB6_41; + setp.lt.s32 %p53, %r2, %r22; + @%p53 bra $L__BB6_36; + mul.f32 %r1265, %r17, 0fBFB8AA3B; + ex2.approx.f32 %r1266, %r1265; + add.f32 %r1267, %r1266, 0f3F800000; + rcp.rn.f32 %r1338, %r1267; + mov.b64 %rd179, %rd8; + bra.uni $L__BB6_40; +$L__BB6_36: + ld.global.nc.b32 %r1268, [%rd2]; + add.f32 %r1337, %r17, %r1268; + setp.gt.f32 %p54, %r1337, 0f41A00000; + @%p54 bra $L__BB6_39; + mul.f32 %r1269, %r1337, 0f3FB8AA3B; + ex2.approx.f32 %r18, %r1269; + mov.b32 %r1270, 0f3F800000; + add.rz.f32 %r1271, %r18, %r1270; + add.s32 %r1272, %r1271, -1061158912; + and.b32 %r1273, %r1272, -8388608; + sub.s32 %r1274, %r18, %r1273; + sub.s32 %r1275, 1082130432, %r1273; + fma.rn.f32 %r1276, %r1275, 0f3E800000, 0fBF800000; + add.f32 %r1277, %r1276, %r1274; + cvt.rn.f32.s32 %r1278, %r1273; + mul.f32 %r1279, %r1278, 0f34000000; + fma.rn.f32 %r1280, %r1277, 0fBD39BF78, 0f3DD80012; + fma.rn.f32 %r1281, %r1280, %r1277, 0fBE0778E0; + fma.rn.f32 %r1282, %r1281, %r1277, 0f3E146475; + fma.rn.f32 %r1283, %r1282, %r1277, 0fBE2A68DD; + fma.rn.f32 %r1284, %r1283, %r1277, 0f3E4CAF9E; + fma.rn.f32 %r1285, %r1284, %r1277, 0fBE800042; + fma.rn.f32 %r1286, %r1285, %r1277, 0f3EAAAAE6; + fma.rn.f32 %r1287, %r1286, %r1277, 0fBF000000; + mul.f32 %r1288, %r1277, %r1287; + fma.rn.f32 %r1289, %r1288, %r1277, %r1277; + fma.rn.f32 %r1337, %r1279, 0f3F317218, %r1289; + setp.lt.u32 %p55, %r18, 2139095040; + @%p55 bra $L__BB6_39; + setp.gt.s32 %p56, %r18, -1082130432; + fma.rn.f32 %r1290, %r18, 0f7F800000, 0f7F800000; + selp.f32 %r1291, %r1290, %r1337, %p56; + setp.eq.f32 %p57, %r18, 0f00000000; + selp.f32 %r1337, 0f80000000, %r1291, %p57; +$L__BB6_39: + ld.global.nc.b32 %r1292, [%rd3]; + mul.f32 %r1338, %r1292, %r1337; + mov.b64 %rd179, %rd180; +$L__BB6_40: + cvta.to.global.u64 %rd164, %rd179; + shl.b64 %rd165, %rd4, 2; + add.s64 %rd166, %rd165, %rd1; + shl.b64 %rd167, %rd166, 2; + add.s64 %rd168, %rd164, %rd167; + st.global.b32 [%rd168], %r1338; +$L__BB6_41: + setp.ne.b32 %p58, %r3, 0; + shfl.sync.bfly.b32 %r1293|%p59, %r8, 16, 31, -1; + add.f32 %r1294, %r8, %r1293; + shfl.sync.bfly.b32 %r1295|%p60, %r1294, 8, 31, -1; + add.f32 %r1296, %r1294, %r1295; + shfl.sync.bfly.b32 %r1297|%p61, %r1296, 4, 31, -1; + add.f32 %r1298, %r1296, %r1297; + shfl.sync.bfly.b32 %r1299|%p62, %r1298, 2, 31, -1; + add.f32 %r1300, %r1298, %r1299; + shfl.sync.bfly.b32 %r1301|%p63, %r1300, 1, 31, -1; + add.f32 %r19, %r1300, %r1301; + @%p58 bra $L__BB6_49; + setp.lt.s32 %p64, %r2, %r22; + ld.global.nc.b32 %r20, [%rd3]; + @%p64 bra $L__BB6_44; + mul.f32 %r1302, %r19, 0fBFB8AA3B; + ex2.approx.f32 %r1303, %r1302; + add.f32 %r1304, %r1303, 0f3F800000; + rcp.rn.f32 %r1340, %r1304; + mov.b64 %rd180, %rd8; + bra.uni $L__BB6_48; +$L__BB6_44: + ld.global.nc.b32 %r1305, [%rd2]; + add.f32 %r1339, %r19, %r1305; + setp.gt.f32 %p65, %r1339, 0f41A00000; + @%p65 bra $L__BB6_47; + mul.f32 %r1306, %r1339, 0f3FB8AA3B; + ex2.approx.f32 %r21, %r1306; + mov.b32 %r1307, 0f3F800000; + add.rz.f32 %r1308, %r21, %r1307; + add.s32 %r1309, %r1308, -1061158912; + and.b32 %r1310, %r1309, -8388608; + sub.s32 %r1311, %r21, %r1310; + sub.s32 %r1312, 1082130432, %r1310; + fma.rn.f32 %r1313, %r1312, 0f3E800000, 0fBF800000; + add.f32 %r1314, %r1313, %r1311; + cvt.rn.f32.s32 %r1315, %r1310; + mul.f32 %r1316, %r1315, 0f34000000; + fma.rn.f32 %r1317, %r1314, 0fBD39BF78, 0f3DD80012; + fma.rn.f32 %r1318, %r1317, %r1314, 0fBE0778E0; + fma.rn.f32 %r1319, %r1318, %r1314, 0f3E146475; + fma.rn.f32 %r1320, %r1319, %r1314, 0fBE2A68DD; + fma.rn.f32 %r1321, %r1320, %r1314, 0f3E4CAF9E; + fma.rn.f32 %r1322, %r1321, %r1314, 0fBE800042; + fma.rn.f32 %r1323, %r1322, %r1314, 0f3EAAAAE6; + fma.rn.f32 %r1324, %r1323, %r1314, 0fBF000000; + mul.f32 %r1325, %r1314, %r1324; + fma.rn.f32 %r1326, %r1325, %r1314, %r1314; + fma.rn.f32 %r1339, %r1316, 0f3F317218, %r1326; + setp.lt.u32 %p66, %r21, 2139095040; + @%p66 bra $L__BB6_47; + setp.gt.s32 %p67, %r21, -1082130432; + fma.rn.f32 %r1327, %r21, 0f7F800000, 0f7F800000; + selp.f32 %r1328, %r1327, %r1339, %p67; + setp.eq.f32 %p68, %r21, 0f00000000; + selp.f32 %r1339, 0f80000000, %r1328, %p68; +$L__BB6_47: + mul.f32 %r1340, %r20, %r1339; +$L__BB6_48: + cvta.to.global.u64 %rd169, %rd180; + mad.lo.s64 %rd170, %rd4, 5, %rd1; + shl.b64 %rd171, %rd170, 2; + add.s64 %rd172, %rd169, %rd171; + st.global.b32 [%rd172], %r1340; +$L__BB6_49: + ret; + +} + // .globl leleka_gdn_ab_unrolled_t8 +.visible .entry leleka_gdn_ab_unrolled_t8( + .param .u64 .ptr .align 1 leleka_gdn_ab_unrolled_t8_param_0, + .param .u64 .ptr .align 1 leleka_gdn_ab_unrolled_t8_param_1, + .param .u64 .ptr .align 1 leleka_gdn_ab_unrolled_t8_param_2, + .param .u64 .ptr .align 1 leleka_gdn_ab_unrolled_t8_param_3, + .param .u64 .ptr .align 1 leleka_gdn_ab_unrolled_t8_param_4, + .param .u64 .ptr .align 1 leleka_gdn_ab_unrolled_t8_param_5, + .param .u64 .ptr .align 1 leleka_gdn_ab_unrolled_t8_param_6, + .param .u32 leleka_gdn_ab_unrolled_t8_param_7, + .param .u32 leleka_gdn_ab_unrolled_t8_param_8, + .param .u32 leleka_gdn_ab_unrolled_t8_param_9 +) +.maxntid 64 +{ + .reg .pred %p<179>; + .reg .b32 %r<1673>; + .reg .b64 %rd<228>; + + ld.param.b64 %rd6, [leleka_gdn_ab_unrolled_t8_param_0]; + ld.param.b64 %rd7, [leleka_gdn_ab_unrolled_t8_param_1]; + ld.param.b64 %rd8, [leleka_gdn_ab_unrolled_t8_param_2]; + ld.param.b32 %r102, [leleka_gdn_ab_unrolled_t8_param_8]; + ld.param.b32 %r103, [leleka_gdn_ab_unrolled_t8_param_9]; + mov.u32 %r104, %ctaid.x; + mov.u32 %r105, %ntid.x; + shr.u32 %r106, %r105, 5; + mov.u32 %r107, %tid.x; + shr.u32 %r108, %r107, 5; + mad.lo.s32 %r1, %r106, %r104, %r108; + and.b32 %r2, %r107, 31; + shl.b32 %r109, %r102, 1; + setp.ge.s32 %p1, %r1, %r109; + mov.b32 %r1649, 0f00000000; + mov.b32 %r1650, 0f00000000; + mov.b32 %r1651, 0f00000000; + mov.b32 %r1652, 0f00000000; + mov.b32 %r1653, 0f00000000; + mov.b32 %r1654, 0f00000000; + mov.b32 %r1655, 0f00000000; + @%p1 bra $L__BB7_163; + setp.lt.s32 %p2, %r1, %r102; + selp.b32 %r114, 0, %r102, %p2; + sub.s32 %r115, %r1, %r114; + selp.b64 %rd10, %rd7, %rd8, %p2; + cvt.s64.s32 %rd1, %r115; + mul.wide.s32 %rd11, %r115, 5120; + add.s64 %rd12, %rd10, %rd11; + setp.lt.s32 %p3, %r103, 1; + add.s32 %r3, %r103, -1; + min.u32 %r116, %r3, 7; + add.s32 %r4, %r116, 1; + mul.wide.u32 %rd13, %r2, 16; + add.s64 %rd9, %rd12, %rd13; + // begin inline asm + ld.global.nc.v4.u32 {%r110,%r111,%r112,%r113}, [%rd9]; + // end inline asm + shl.b32 %r117, %r2, 3; + mul.wide.u32 %rd14, %r117, 4; + add.s64 %rd2, %rd6, %rd14; + mov.b32 %r1656, 0f00000000; + @%p3 bra $L__BB7_10; + shl.b32 %r6, %r110, 16; + and.b32 %r7, %r110, -65536; + shl.b32 %r8, %r111, 16; + and.b32 %r9, %r111, -65536; + shl.b32 %r10, %r112, 16; + and.b32 %r11, %r112, -65536; + shl.b32 %r12, %r113, 16; + and.b32 %r13, %r113, -65536; + // begin inline asm + ld.global.nc.v4.f32 {%r118,%r119,%r120,%r121}, [%rd2]; + // end inline asm + add.s64 %rd15, %rd2, 16; + // begin inline asm + ld.global.nc.v4.f32 {%r122,%r123,%r124,%r125}, [%rd15]; + // end inline asm + fma.rn.f32 %r126, %r6, %r118, 0f00000000; + fma.rn.f32 %r127, %r7, %r119, %r126; + fma.rn.f32 %r128, %r8, %r120, %r127; + fma.rn.f32 %r129, %r9, %r121, %r128; + fma.rn.f32 %r130, %r10, %r122, %r129; + fma.rn.f32 %r131, %r11, %r123, %r130; + fma.rn.f32 %r132, %r12, %r124, %r131; + fma.rn.f32 %r1656, %r13, %r125, %r132; + setp.eq.b32 %p4, %r3, 0; + @%p4 bra $L__BB7_10; + add.s64 %rd16, %rd2, 10240; + // begin inline asm + ld.global.nc.v4.f32 {%r133,%r134,%r135,%r136}, [%rd16]; + // end inline asm + add.s64 %rd17, %rd2, 10256; + // begin inline asm + ld.global.nc.v4.f32 {%r137,%r138,%r139,%r140}, [%rd17]; + // end inline asm + fma.rn.f32 %r141, %r6, %r133, 0f00000000; + fma.rn.f32 %r142, %r7, %r134, %r141; + fma.rn.f32 %r143, %r8, %r135, %r142; + fma.rn.f32 %r144, %r9, %r136, %r143; + fma.rn.f32 %r145, %r10, %r137, %r144; + fma.rn.f32 %r146, %r11, %r138, %r145; + fma.rn.f32 %r147, %r12, %r139, %r146; + fma.rn.f32 %r1655, %r13, %r140, %r147; + setp.eq.b32 %p5, %r4, 2; + @%p5 bra $L__BB7_10; + add.s64 %rd18, %rd2, 20480; + // begin inline asm + ld.global.nc.v4.f32 {%r148,%r149,%r150,%r151}, [%rd18]; + // end inline asm + add.s64 %rd19, %rd2, 20496; + // begin inline asm + ld.global.nc.v4.f32 {%r152,%r153,%r154,%r155}, [%rd19]; + // end inline asm + fma.rn.f32 %r156, %r6, %r148, 0f00000000; + fma.rn.f32 %r157, %r7, %r149, %r156; + fma.rn.f32 %r158, %r8, %r150, %r157; + fma.rn.f32 %r159, %r9, %r151, %r158; + fma.rn.f32 %r160, %r10, %r152, %r159; + fma.rn.f32 %r161, %r11, %r153, %r160; + fma.rn.f32 %r162, %r12, %r154, %r161; + fma.rn.f32 %r1654, %r13, %r155, %r162; + setp.eq.b32 %p6, %r4, 3; + @%p6 bra $L__BB7_10; + add.s64 %rd20, %rd2, 30720; + // begin inline asm + ld.global.nc.v4.f32 {%r163,%r164,%r165,%r166}, [%rd20]; + // end inline asm + add.s64 %rd21, %rd2, 30736; + // begin inline asm + ld.global.nc.v4.f32 {%r167,%r168,%r169,%r170}, [%rd21]; + // end inline asm + fma.rn.f32 %r171, %r6, %r163, 0f00000000; + fma.rn.f32 %r172, %r7, %r164, %r171; + fma.rn.f32 %r173, %r8, %r165, %r172; + fma.rn.f32 %r174, %r9, %r166, %r173; + fma.rn.f32 %r175, %r10, %r167, %r174; + fma.rn.f32 %r176, %r11, %r168, %r175; + fma.rn.f32 %r177, %r12, %r169, %r176; + fma.rn.f32 %r1653, %r13, %r170, %r177; + setp.eq.b32 %p7, %r4, 4; + @%p7 bra $L__BB7_10; + add.s64 %rd22, %rd2, 40960; + // begin inline asm + ld.global.nc.v4.f32 {%r178,%r179,%r180,%r181}, [%rd22]; + // end inline asm + add.s64 %rd23, %rd2, 40976; + // begin inline asm + ld.global.nc.v4.f32 {%r182,%r183,%r184,%r185}, [%rd23]; + // end inline asm + fma.rn.f32 %r186, %r6, %r178, 0f00000000; + fma.rn.f32 %r187, %r7, %r179, %r186; + fma.rn.f32 %r188, %r8, %r180, %r187; + fma.rn.f32 %r189, %r9, %r181, %r188; + fma.rn.f32 %r190, %r10, %r182, %r189; + fma.rn.f32 %r191, %r11, %r183, %r190; + fma.rn.f32 %r192, %r12, %r184, %r191; + fma.rn.f32 %r1652, %r13, %r185, %r192; + setp.eq.b32 %p8, %r4, 5; + @%p8 bra $L__BB7_10; + add.s64 %rd24, %rd2, 51200; + // begin inline asm + ld.global.nc.v4.f32 {%r193,%r194,%r195,%r196}, [%rd24]; + // end inline asm + add.s64 %rd25, %rd2, 51216; + // begin inline asm + ld.global.nc.v4.f32 {%r197,%r198,%r199,%r200}, [%rd25]; + // end inline asm + fma.rn.f32 %r201, %r6, %r193, 0f00000000; + fma.rn.f32 %r202, %r7, %r194, %r201; + fma.rn.f32 %r203, %r8, %r195, %r202; + fma.rn.f32 %r204, %r9, %r196, %r203; + fma.rn.f32 %r205, %r10, %r197, %r204; + fma.rn.f32 %r206, %r11, %r198, %r205; + fma.rn.f32 %r207, %r12, %r199, %r206; + fma.rn.f32 %r1651, %r13, %r200, %r207; + setp.eq.b32 %p9, %r4, 6; + @%p9 bra $L__BB7_10; + add.s64 %rd26, %rd2, 61440; + // begin inline asm + ld.global.nc.v4.f32 {%r208,%r209,%r210,%r211}, [%rd26]; + // end inline asm + add.s64 %rd27, %rd2, 61456; + // begin inline asm + ld.global.nc.v4.f32 {%r212,%r213,%r214,%r215}, [%rd27]; + // end inline asm + fma.rn.f32 %r216, %r6, %r208, 0f00000000; + fma.rn.f32 %r217, %r7, %r209, %r216; + fma.rn.f32 %r218, %r8, %r210, %r217; + fma.rn.f32 %r219, %r9, %r211, %r218; + fma.rn.f32 %r220, %r10, %r212, %r219; + fma.rn.f32 %r221, %r11, %r213, %r220; + fma.rn.f32 %r222, %r12, %r214, %r221; + fma.rn.f32 %r1650, %r13, %r215, %r222; + setp.eq.b32 %p10, %r4, 7; + @%p10 bra $L__BB7_10; + add.s64 %rd28, %rd2, 71680; + // begin inline asm + ld.global.nc.v4.f32 {%r223,%r224,%r225,%r226}, [%rd28]; + // end inline asm + add.s64 %rd29, %rd2, 71696; + // begin inline asm + ld.global.nc.v4.f32 {%r227,%r228,%r229,%r230}, [%rd29]; + // end inline asm + fma.rn.f32 %r231, %r6, %r223, 0f00000000; + fma.rn.f32 %r232, %r7, %r224, %r231; + fma.rn.f32 %r233, %r8, %r225, %r232; + fma.rn.f32 %r234, %r9, %r226, %r233; + fma.rn.f32 %r235, %r10, %r227, %r234; + fma.rn.f32 %r236, %r11, %r228, %r235; + fma.rn.f32 %r237, %r12, %r229, %r236; + fma.rn.f32 %r1649, %r13, %r230, %r237; +$L__BB7_10: + setp.lt.s32 %p11, %r103, 1; + add.s64 %rd30, %rd9, 512; + // begin inline asm + ld.global.nc.v4.u32 {%r238,%r239,%r240,%r241}, [%rd30]; + // end inline asm + @%p11 bra $L__BB7_19; + shl.b32 %r14, %r238, 16; + and.b32 %r15, %r238, -65536; + shl.b32 %r16, %r239, 16; + and.b32 %r17, %r239, -65536; + shl.b32 %r18, %r240, 16; + and.b32 %r19, %r240, -65536; + shl.b32 %r20, %r241, 16; + and.b32 %r21, %r241, -65536; + add.s64 %rd31, %rd2, 1024; + // begin inline asm + ld.global.nc.v4.f32 {%r242,%r243,%r244,%r245}, [%rd31]; + // end inline asm + add.s64 %rd32, %rd2, 1040; + // begin inline asm + ld.global.nc.v4.f32 {%r246,%r247,%r248,%r249}, [%rd32]; + // end inline asm + fma.rn.f32 %r250, %r14, %r242, %r1656; + fma.rn.f32 %r251, %r15, %r243, %r250; + fma.rn.f32 %r252, %r16, %r244, %r251; + fma.rn.f32 %r253, %r17, %r245, %r252; + fma.rn.f32 %r254, %r18, %r246, %r253; + fma.rn.f32 %r255, %r19, %r247, %r254; + fma.rn.f32 %r256, %r20, %r248, %r255; + fma.rn.f32 %r1656, %r21, %r249, %r256; + setp.eq.b32 %p12, %r3, 0; + @%p12 bra $L__BB7_19; + add.s64 %rd33, %rd31, 10240; + // begin inline asm + ld.global.nc.v4.f32 {%r257,%r258,%r259,%r260}, [%rd33]; + // end inline asm + add.s64 %rd34, %rd31, 10256; + // begin inline asm + ld.global.nc.v4.f32 {%r261,%r262,%r263,%r264}, [%rd34]; + // end inline asm + fma.rn.f32 %r265, %r14, %r257, %r1655; + fma.rn.f32 %r266, %r15, %r258, %r265; + fma.rn.f32 %r267, %r16, %r259, %r266; + fma.rn.f32 %r268, %r17, %r260, %r267; + fma.rn.f32 %r269, %r18, %r261, %r268; + fma.rn.f32 %r270, %r19, %r262, %r269; + fma.rn.f32 %r271, %r20, %r263, %r270; + fma.rn.f32 %r1655, %r21, %r264, %r271; + setp.eq.b32 %p13, %r4, 2; + @%p13 bra $L__BB7_19; + add.s64 %rd35, %rd31, 20480; + // begin inline asm + ld.global.nc.v4.f32 {%r272,%r273,%r274,%r275}, [%rd35]; + // end inline asm + add.s64 %rd36, %rd31, 20496; + // begin inline asm + ld.global.nc.v4.f32 {%r276,%r277,%r278,%r279}, [%rd36]; + // end inline asm + fma.rn.f32 %r280, %r14, %r272, %r1654; + fma.rn.f32 %r281, %r15, %r273, %r280; + fma.rn.f32 %r282, %r16, %r274, %r281; + fma.rn.f32 %r283, %r17, %r275, %r282; + fma.rn.f32 %r284, %r18, %r276, %r283; + fma.rn.f32 %r285, %r19, %r277, %r284; + fma.rn.f32 %r286, %r20, %r278, %r285; + fma.rn.f32 %r1654, %r21, %r279, %r286; + setp.eq.b32 %p14, %r4, 3; + @%p14 bra $L__BB7_19; + add.s64 %rd37, %rd31, 30720; + // begin inline asm + ld.global.nc.v4.f32 {%r287,%r288,%r289,%r290}, [%rd37]; + // end inline asm + add.s64 %rd38, %rd31, 30736; + // begin inline asm + ld.global.nc.v4.f32 {%r291,%r292,%r293,%r294}, [%rd38]; + // end inline asm + fma.rn.f32 %r295, %r14, %r287, %r1653; + fma.rn.f32 %r296, %r15, %r288, %r295; + fma.rn.f32 %r297, %r16, %r289, %r296; + fma.rn.f32 %r298, %r17, %r290, %r297; + fma.rn.f32 %r299, %r18, %r291, %r298; + fma.rn.f32 %r300, %r19, %r292, %r299; + fma.rn.f32 %r301, %r20, %r293, %r300; + fma.rn.f32 %r1653, %r21, %r294, %r301; + setp.eq.b32 %p15, %r4, 4; + @%p15 bra $L__BB7_19; + add.s64 %rd39, %rd31, 40960; + // begin inline asm + ld.global.nc.v4.f32 {%r302,%r303,%r304,%r305}, [%rd39]; + // end inline asm + add.s64 %rd40, %rd31, 40976; + // begin inline asm + ld.global.nc.v4.f32 {%r306,%r307,%r308,%r309}, [%rd40]; + // end inline asm + fma.rn.f32 %r310, %r14, %r302, %r1652; + fma.rn.f32 %r311, %r15, %r303, %r310; + fma.rn.f32 %r312, %r16, %r304, %r311; + fma.rn.f32 %r313, %r17, %r305, %r312; + fma.rn.f32 %r314, %r18, %r306, %r313; + fma.rn.f32 %r315, %r19, %r307, %r314; + fma.rn.f32 %r316, %r20, %r308, %r315; + fma.rn.f32 %r1652, %r21, %r309, %r316; + setp.eq.b32 %p16, %r4, 5; + @%p16 bra $L__BB7_19; + add.s64 %rd41, %rd31, 51200; + // begin inline asm + ld.global.nc.v4.f32 {%r317,%r318,%r319,%r320}, [%rd41]; + // end inline asm + add.s64 %rd42, %rd31, 51216; + // begin inline asm + ld.global.nc.v4.f32 {%r321,%r322,%r323,%r324}, [%rd42]; + // end inline asm + fma.rn.f32 %r325, %r14, %r317, %r1651; + fma.rn.f32 %r326, %r15, %r318, %r325; + fma.rn.f32 %r327, %r16, %r319, %r326; + fma.rn.f32 %r328, %r17, %r320, %r327; + fma.rn.f32 %r329, %r18, %r321, %r328; + fma.rn.f32 %r330, %r19, %r322, %r329; + fma.rn.f32 %r331, %r20, %r323, %r330; + fma.rn.f32 %r1651, %r21, %r324, %r331; + setp.eq.b32 %p17, %r4, 6; + @%p17 bra $L__BB7_19; + add.s64 %rd43, %rd31, 61440; + // begin inline asm + ld.global.nc.v4.f32 {%r332,%r333,%r334,%r335}, [%rd43]; + // end inline asm + add.s64 %rd44, %rd31, 61456; + // begin inline asm + ld.global.nc.v4.f32 {%r336,%r337,%r338,%r339}, [%rd44]; + // end inline asm + fma.rn.f32 %r340, %r14, %r332, %r1650; + fma.rn.f32 %r341, %r15, %r333, %r340; + fma.rn.f32 %r342, %r16, %r334, %r341; + fma.rn.f32 %r343, %r17, %r335, %r342; + fma.rn.f32 %r344, %r18, %r336, %r343; + fma.rn.f32 %r345, %r19, %r337, %r344; + fma.rn.f32 %r346, %r20, %r338, %r345; + fma.rn.f32 %r1650, %r21, %r339, %r346; + setp.eq.b32 %p18, %r4, 7; + @%p18 bra $L__BB7_19; + add.s64 %rd45, %rd31, 71680; + // begin inline asm + ld.global.nc.v4.f32 {%r347,%r348,%r349,%r350}, [%rd45]; + // end inline asm + add.s64 %rd46, %rd31, 71696; + // begin inline asm + ld.global.nc.v4.f32 {%r351,%r352,%r353,%r354}, [%rd46]; + // end inline asm + fma.rn.f32 %r355, %r14, %r347, %r1649; + fma.rn.f32 %r356, %r15, %r348, %r355; + fma.rn.f32 %r357, %r16, %r349, %r356; + fma.rn.f32 %r358, %r17, %r350, %r357; + fma.rn.f32 %r359, %r18, %r351, %r358; + fma.rn.f32 %r360, %r19, %r352, %r359; + fma.rn.f32 %r361, %r20, %r353, %r360; + fma.rn.f32 %r1649, %r21, %r354, %r361; +$L__BB7_19: + setp.lt.s32 %p19, %r103, 1; + add.s64 %rd47, %rd9, 1024; + // begin inline asm + ld.global.nc.v4.u32 {%r362,%r363,%r364,%r365}, [%rd47]; + // end inline asm + @%p19 bra $L__BB7_28; + shl.b32 %r22, %r362, 16; + and.b32 %r23, %r362, -65536; + shl.b32 %r24, %r363, 16; + and.b32 %r25, %r363, -65536; + shl.b32 %r26, %r364, 16; + and.b32 %r27, %r364, -65536; + shl.b32 %r28, %r365, 16; + and.b32 %r29, %r365, -65536; + add.s64 %rd48, %rd2, 2048; + // begin inline asm + ld.global.nc.v4.f32 {%r366,%r367,%r368,%r369}, [%rd48]; + // end inline asm + add.s64 %rd49, %rd2, 2064; + // begin inline asm + ld.global.nc.v4.f32 {%r370,%r371,%r372,%r373}, [%rd49]; + // end inline asm + fma.rn.f32 %r374, %r22, %r366, %r1656; + fma.rn.f32 %r375, %r23, %r367, %r374; + fma.rn.f32 %r376, %r24, %r368, %r375; + fma.rn.f32 %r377, %r25, %r369, %r376; + fma.rn.f32 %r378, %r26, %r370, %r377; + fma.rn.f32 %r379, %r27, %r371, %r378; + fma.rn.f32 %r380, %r28, %r372, %r379; + fma.rn.f32 %r1656, %r29, %r373, %r380; + setp.eq.b32 %p20, %r3, 0; + @%p20 bra $L__BB7_28; + add.s64 %rd50, %rd48, 10240; + // begin inline asm + ld.global.nc.v4.f32 {%r381,%r382,%r383,%r384}, [%rd50]; + // end inline asm + add.s64 %rd51, %rd48, 10256; + // begin inline asm + ld.global.nc.v4.f32 {%r385,%r386,%r387,%r388}, [%rd51]; + // end inline asm + fma.rn.f32 %r389, %r22, %r381, %r1655; + fma.rn.f32 %r390, %r23, %r382, %r389; + fma.rn.f32 %r391, %r24, %r383, %r390; + fma.rn.f32 %r392, %r25, %r384, %r391; + fma.rn.f32 %r393, %r26, %r385, %r392; + fma.rn.f32 %r394, %r27, %r386, %r393; + fma.rn.f32 %r395, %r28, %r387, %r394; + fma.rn.f32 %r1655, %r29, %r388, %r395; + setp.eq.b32 %p21, %r4, 2; + @%p21 bra $L__BB7_28; + add.s64 %rd52, %rd48, 20480; + // begin inline asm + ld.global.nc.v4.f32 {%r396,%r397,%r398,%r399}, [%rd52]; + // end inline asm + add.s64 %rd53, %rd48, 20496; + // begin inline asm + ld.global.nc.v4.f32 {%r400,%r401,%r402,%r403}, [%rd53]; + // end inline asm + fma.rn.f32 %r404, %r22, %r396, %r1654; + fma.rn.f32 %r405, %r23, %r397, %r404; + fma.rn.f32 %r406, %r24, %r398, %r405; + fma.rn.f32 %r407, %r25, %r399, %r406; + fma.rn.f32 %r408, %r26, %r400, %r407; + fma.rn.f32 %r409, %r27, %r401, %r408; + fma.rn.f32 %r410, %r28, %r402, %r409; + fma.rn.f32 %r1654, %r29, %r403, %r410; + setp.eq.b32 %p22, %r4, 3; + @%p22 bra $L__BB7_28; + add.s64 %rd54, %rd48, 30720; + // begin inline asm + ld.global.nc.v4.f32 {%r411,%r412,%r413,%r414}, [%rd54]; + // end inline asm + add.s64 %rd55, %rd48, 30736; + // begin inline asm + ld.global.nc.v4.f32 {%r415,%r416,%r417,%r418}, [%rd55]; + // end inline asm + fma.rn.f32 %r419, %r22, %r411, %r1653; + fma.rn.f32 %r420, %r23, %r412, %r419; + fma.rn.f32 %r421, %r24, %r413, %r420; + fma.rn.f32 %r422, %r25, %r414, %r421; + fma.rn.f32 %r423, %r26, %r415, %r422; + fma.rn.f32 %r424, %r27, %r416, %r423; + fma.rn.f32 %r425, %r28, %r417, %r424; + fma.rn.f32 %r1653, %r29, %r418, %r425; + setp.eq.b32 %p23, %r4, 4; + @%p23 bra $L__BB7_28; + add.s64 %rd56, %rd48, 40960; + // begin inline asm + ld.global.nc.v4.f32 {%r426,%r427,%r428,%r429}, [%rd56]; + // end inline asm + add.s64 %rd57, %rd48, 40976; + // begin inline asm + ld.global.nc.v4.f32 {%r430,%r431,%r432,%r433}, [%rd57]; + // end inline asm + fma.rn.f32 %r434, %r22, %r426, %r1652; + fma.rn.f32 %r435, %r23, %r427, %r434; + fma.rn.f32 %r436, %r24, %r428, %r435; + fma.rn.f32 %r437, %r25, %r429, %r436; + fma.rn.f32 %r438, %r26, %r430, %r437; + fma.rn.f32 %r439, %r27, %r431, %r438; + fma.rn.f32 %r440, %r28, %r432, %r439; + fma.rn.f32 %r1652, %r29, %r433, %r440; + setp.eq.b32 %p24, %r4, 5; + @%p24 bra $L__BB7_28; + add.s64 %rd58, %rd48, 51200; + // begin inline asm + ld.global.nc.v4.f32 {%r441,%r442,%r443,%r444}, [%rd58]; + // end inline asm + add.s64 %rd59, %rd48, 51216; + // begin inline asm + ld.global.nc.v4.f32 {%r445,%r446,%r447,%r448}, [%rd59]; + // end inline asm + fma.rn.f32 %r449, %r22, %r441, %r1651; + fma.rn.f32 %r450, %r23, %r442, %r449; + fma.rn.f32 %r451, %r24, %r443, %r450; + fma.rn.f32 %r452, %r25, %r444, %r451; + fma.rn.f32 %r453, %r26, %r445, %r452; + fma.rn.f32 %r454, %r27, %r446, %r453; + fma.rn.f32 %r455, %r28, %r447, %r454; + fma.rn.f32 %r1651, %r29, %r448, %r455; + setp.eq.b32 %p25, %r4, 6; + @%p25 bra $L__BB7_28; + add.s64 %rd60, %rd48, 61440; + // begin inline asm + ld.global.nc.v4.f32 {%r456,%r457,%r458,%r459}, [%rd60]; + // end inline asm + add.s64 %rd61, %rd48, 61456; + // begin inline asm + ld.global.nc.v4.f32 {%r460,%r461,%r462,%r463}, [%rd61]; + // end inline asm + fma.rn.f32 %r464, %r22, %r456, %r1650; + fma.rn.f32 %r465, %r23, %r457, %r464; + fma.rn.f32 %r466, %r24, %r458, %r465; + fma.rn.f32 %r467, %r25, %r459, %r466; + fma.rn.f32 %r468, %r26, %r460, %r467; + fma.rn.f32 %r469, %r27, %r461, %r468; + fma.rn.f32 %r470, %r28, %r462, %r469; + fma.rn.f32 %r1650, %r29, %r463, %r470; + setp.eq.b32 %p26, %r4, 7; + @%p26 bra $L__BB7_28; + add.s64 %rd62, %rd48, 71680; + // begin inline asm + ld.global.nc.v4.f32 {%r471,%r472,%r473,%r474}, [%rd62]; + // end inline asm + add.s64 %rd63, %rd48, 71696; + // begin inline asm + ld.global.nc.v4.f32 {%r475,%r476,%r477,%r478}, [%rd63]; + // end inline asm + fma.rn.f32 %r479, %r22, %r471, %r1649; + fma.rn.f32 %r480, %r23, %r472, %r479; + fma.rn.f32 %r481, %r24, %r473, %r480; + fma.rn.f32 %r482, %r25, %r474, %r481; + fma.rn.f32 %r483, %r26, %r475, %r482; + fma.rn.f32 %r484, %r27, %r476, %r483; + fma.rn.f32 %r485, %r28, %r477, %r484; + fma.rn.f32 %r1649, %r29, %r478, %r485; +$L__BB7_28: + setp.lt.s32 %p27, %r103, 1; + add.s64 %rd64, %rd9, 1536; + // begin inline asm + ld.global.nc.v4.u32 {%r486,%r487,%r488,%r489}, [%rd64]; + // end inline asm + @%p27 bra $L__BB7_37; + shl.b32 %r30, %r486, 16; + and.b32 %r31, %r486, -65536; + shl.b32 %r32, %r487, 16; + and.b32 %r33, %r487, -65536; + shl.b32 %r34, %r488, 16; + and.b32 %r35, %r488, -65536; + shl.b32 %r36, %r489, 16; + and.b32 %r37, %r489, -65536; + add.s64 %rd65, %rd2, 3072; + // begin inline asm + ld.global.nc.v4.f32 {%r490,%r491,%r492,%r493}, [%rd65]; + // end inline asm + add.s64 %rd66, %rd2, 3088; + // begin inline asm + ld.global.nc.v4.f32 {%r494,%r495,%r496,%r497}, [%rd66]; + // end inline asm + fma.rn.f32 %r498, %r30, %r490, %r1656; + fma.rn.f32 %r499, %r31, %r491, %r498; + fma.rn.f32 %r500, %r32, %r492, %r499; + fma.rn.f32 %r501, %r33, %r493, %r500; + fma.rn.f32 %r502, %r34, %r494, %r501; + fma.rn.f32 %r503, %r35, %r495, %r502; + fma.rn.f32 %r504, %r36, %r496, %r503; + fma.rn.f32 %r1656, %r37, %r497, %r504; + setp.eq.b32 %p28, %r3, 0; + @%p28 bra $L__BB7_37; + add.s64 %rd67, %rd65, 10240; + // begin inline asm + ld.global.nc.v4.f32 {%r505,%r506,%r507,%r508}, [%rd67]; + // end inline asm + add.s64 %rd68, %rd65, 10256; + // begin inline asm + ld.global.nc.v4.f32 {%r509,%r510,%r511,%r512}, [%rd68]; + // end inline asm + fma.rn.f32 %r513, %r30, %r505, %r1655; + fma.rn.f32 %r514, %r31, %r506, %r513; + fma.rn.f32 %r515, %r32, %r507, %r514; + fma.rn.f32 %r516, %r33, %r508, %r515; + fma.rn.f32 %r517, %r34, %r509, %r516; + fma.rn.f32 %r518, %r35, %r510, %r517; + fma.rn.f32 %r519, %r36, %r511, %r518; + fma.rn.f32 %r1655, %r37, %r512, %r519; + setp.eq.b32 %p29, %r4, 2; + @%p29 bra $L__BB7_37; + add.s64 %rd69, %rd65, 20480; + // begin inline asm + ld.global.nc.v4.f32 {%r520,%r521,%r522,%r523}, [%rd69]; + // end inline asm + add.s64 %rd70, %rd65, 20496; + // begin inline asm + ld.global.nc.v4.f32 {%r524,%r525,%r526,%r527}, [%rd70]; + // end inline asm + fma.rn.f32 %r528, %r30, %r520, %r1654; + fma.rn.f32 %r529, %r31, %r521, %r528; + fma.rn.f32 %r530, %r32, %r522, %r529; + fma.rn.f32 %r531, %r33, %r523, %r530; + fma.rn.f32 %r532, %r34, %r524, %r531; + fma.rn.f32 %r533, %r35, %r525, %r532; + fma.rn.f32 %r534, %r36, %r526, %r533; + fma.rn.f32 %r1654, %r37, %r527, %r534; + setp.eq.b32 %p30, %r4, 3; + @%p30 bra $L__BB7_37; + add.s64 %rd71, %rd65, 30720; + // begin inline asm + ld.global.nc.v4.f32 {%r535,%r536,%r537,%r538}, [%rd71]; + // end inline asm + add.s64 %rd72, %rd65, 30736; + // begin inline asm + ld.global.nc.v4.f32 {%r539,%r540,%r541,%r542}, [%rd72]; + // end inline asm + fma.rn.f32 %r543, %r30, %r535, %r1653; + fma.rn.f32 %r544, %r31, %r536, %r543; + fma.rn.f32 %r545, %r32, %r537, %r544; + fma.rn.f32 %r546, %r33, %r538, %r545; + fma.rn.f32 %r547, %r34, %r539, %r546; + fma.rn.f32 %r548, %r35, %r540, %r547; + fma.rn.f32 %r549, %r36, %r541, %r548; + fma.rn.f32 %r1653, %r37, %r542, %r549; + setp.eq.b32 %p31, %r4, 4; + @%p31 bra $L__BB7_37; + add.s64 %rd73, %rd65, 40960; + // begin inline asm + ld.global.nc.v4.f32 {%r550,%r551,%r552,%r553}, [%rd73]; + // end inline asm + add.s64 %rd74, %rd65, 40976; + // begin inline asm + ld.global.nc.v4.f32 {%r554,%r555,%r556,%r557}, [%rd74]; + // end inline asm + fma.rn.f32 %r558, %r30, %r550, %r1652; + fma.rn.f32 %r559, %r31, %r551, %r558; + fma.rn.f32 %r560, %r32, %r552, %r559; + fma.rn.f32 %r561, %r33, %r553, %r560; + fma.rn.f32 %r562, %r34, %r554, %r561; + fma.rn.f32 %r563, %r35, %r555, %r562; + fma.rn.f32 %r564, %r36, %r556, %r563; + fma.rn.f32 %r1652, %r37, %r557, %r564; + setp.eq.b32 %p32, %r4, 5; + @%p32 bra $L__BB7_37; + add.s64 %rd75, %rd65, 51200; + // begin inline asm + ld.global.nc.v4.f32 {%r565,%r566,%r567,%r568}, [%rd75]; + // end inline asm + add.s64 %rd76, %rd65, 51216; + // begin inline asm + ld.global.nc.v4.f32 {%r569,%r570,%r571,%r572}, [%rd76]; + // end inline asm + fma.rn.f32 %r573, %r30, %r565, %r1651; + fma.rn.f32 %r574, %r31, %r566, %r573; + fma.rn.f32 %r575, %r32, %r567, %r574; + fma.rn.f32 %r576, %r33, %r568, %r575; + fma.rn.f32 %r577, %r34, %r569, %r576; + fma.rn.f32 %r578, %r35, %r570, %r577; + fma.rn.f32 %r579, %r36, %r571, %r578; + fma.rn.f32 %r1651, %r37, %r572, %r579; + setp.eq.b32 %p33, %r4, 6; + @%p33 bra $L__BB7_37; + add.s64 %rd77, %rd65, 61440; + // begin inline asm + ld.global.nc.v4.f32 {%r580,%r581,%r582,%r583}, [%rd77]; + // end inline asm + add.s64 %rd78, %rd65, 61456; + // begin inline asm + ld.global.nc.v4.f32 {%r584,%r585,%r586,%r587}, [%rd78]; + // end inline asm + fma.rn.f32 %r588, %r30, %r580, %r1650; + fma.rn.f32 %r589, %r31, %r581, %r588; + fma.rn.f32 %r590, %r32, %r582, %r589; + fma.rn.f32 %r591, %r33, %r583, %r590; + fma.rn.f32 %r592, %r34, %r584, %r591; + fma.rn.f32 %r593, %r35, %r585, %r592; + fma.rn.f32 %r594, %r36, %r586, %r593; + fma.rn.f32 %r1650, %r37, %r587, %r594; + setp.eq.b32 %p34, %r4, 7; + @%p34 bra $L__BB7_37; + add.s64 %rd79, %rd65, 71680; + // begin inline asm + ld.global.nc.v4.f32 {%r595,%r596,%r597,%r598}, [%rd79]; + // end inline asm + add.s64 %rd80, %rd65, 71696; + // begin inline asm + ld.global.nc.v4.f32 {%r599,%r600,%r601,%r602}, [%rd80]; + // end inline asm + fma.rn.f32 %r603, %r30, %r595, %r1649; + fma.rn.f32 %r604, %r31, %r596, %r603; + fma.rn.f32 %r605, %r32, %r597, %r604; + fma.rn.f32 %r606, %r33, %r598, %r605; + fma.rn.f32 %r607, %r34, %r599, %r606; + fma.rn.f32 %r608, %r35, %r600, %r607; + fma.rn.f32 %r609, %r36, %r601, %r608; + fma.rn.f32 %r1649, %r37, %r602, %r609; +$L__BB7_37: + setp.lt.s32 %p35, %r103, 1; + add.s64 %rd81, %rd9, 2048; + // begin inline asm + ld.global.nc.v4.u32 {%r610,%r611,%r612,%r613}, [%rd81]; + // end inline asm + @%p35 bra $L__BB7_46; + shl.b32 %r38, %r610, 16; + and.b32 %r39, %r610, -65536; + shl.b32 %r40, %r611, 16; + and.b32 %r41, %r611, -65536; + shl.b32 %r42, %r612, 16; + and.b32 %r43, %r612, -65536; + shl.b32 %r44, %r613, 16; + and.b32 %r45, %r613, -65536; + add.s64 %rd82, %rd2, 4096; + // begin inline asm + ld.global.nc.v4.f32 {%r614,%r615,%r616,%r617}, [%rd82]; + // end inline asm + add.s64 %rd83, %rd2, 4112; + // begin inline asm + ld.global.nc.v4.f32 {%r618,%r619,%r620,%r621}, [%rd83]; + // end inline asm + fma.rn.f32 %r622, %r38, %r614, %r1656; + fma.rn.f32 %r623, %r39, %r615, %r622; + fma.rn.f32 %r624, %r40, %r616, %r623; + fma.rn.f32 %r625, %r41, %r617, %r624; + fma.rn.f32 %r626, %r42, %r618, %r625; + fma.rn.f32 %r627, %r43, %r619, %r626; + fma.rn.f32 %r628, %r44, %r620, %r627; + fma.rn.f32 %r1656, %r45, %r621, %r628; + setp.eq.b32 %p36, %r3, 0; + @%p36 bra $L__BB7_46; + add.s64 %rd84, %rd82, 10240; + // begin inline asm + ld.global.nc.v4.f32 {%r629,%r630,%r631,%r632}, [%rd84]; + // end inline asm + add.s64 %rd85, %rd82, 10256; + // begin inline asm + ld.global.nc.v4.f32 {%r633,%r634,%r635,%r636}, [%rd85]; + // end inline asm + fma.rn.f32 %r637, %r38, %r629, %r1655; + fma.rn.f32 %r638, %r39, %r630, %r637; + fma.rn.f32 %r639, %r40, %r631, %r638; + fma.rn.f32 %r640, %r41, %r632, %r639; + fma.rn.f32 %r641, %r42, %r633, %r640; + fma.rn.f32 %r642, %r43, %r634, %r641; + fma.rn.f32 %r643, %r44, %r635, %r642; + fma.rn.f32 %r1655, %r45, %r636, %r643; + setp.eq.b32 %p37, %r4, 2; + @%p37 bra $L__BB7_46; + add.s64 %rd86, %rd82, 20480; + // begin inline asm + ld.global.nc.v4.f32 {%r644,%r645,%r646,%r647}, [%rd86]; + // end inline asm + add.s64 %rd87, %rd82, 20496; + // begin inline asm + ld.global.nc.v4.f32 {%r648,%r649,%r650,%r651}, [%rd87]; + // end inline asm + fma.rn.f32 %r652, %r38, %r644, %r1654; + fma.rn.f32 %r653, %r39, %r645, %r652; + fma.rn.f32 %r654, %r40, %r646, %r653; + fma.rn.f32 %r655, %r41, %r647, %r654; + fma.rn.f32 %r656, %r42, %r648, %r655; + fma.rn.f32 %r657, %r43, %r649, %r656; + fma.rn.f32 %r658, %r44, %r650, %r657; + fma.rn.f32 %r1654, %r45, %r651, %r658; + setp.eq.b32 %p38, %r4, 3; + @%p38 bra $L__BB7_46; + add.s64 %rd88, %rd82, 30720; + // begin inline asm + ld.global.nc.v4.f32 {%r659,%r660,%r661,%r662}, [%rd88]; + // end inline asm + add.s64 %rd89, %rd82, 30736; + // begin inline asm + ld.global.nc.v4.f32 {%r663,%r664,%r665,%r666}, [%rd89]; + // end inline asm + fma.rn.f32 %r667, %r38, %r659, %r1653; + fma.rn.f32 %r668, %r39, %r660, %r667; + fma.rn.f32 %r669, %r40, %r661, %r668; + fma.rn.f32 %r670, %r41, %r662, %r669; + fma.rn.f32 %r671, %r42, %r663, %r670; + fma.rn.f32 %r672, %r43, %r664, %r671; + fma.rn.f32 %r673, %r44, %r665, %r672; + fma.rn.f32 %r1653, %r45, %r666, %r673; + setp.eq.b32 %p39, %r4, 4; + @%p39 bra $L__BB7_46; + add.s64 %rd90, %rd82, 40960; + // begin inline asm + ld.global.nc.v4.f32 {%r674,%r675,%r676,%r677}, [%rd90]; + // end inline asm + add.s64 %rd91, %rd82, 40976; + // begin inline asm + ld.global.nc.v4.f32 {%r678,%r679,%r680,%r681}, [%rd91]; + // end inline asm + fma.rn.f32 %r682, %r38, %r674, %r1652; + fma.rn.f32 %r683, %r39, %r675, %r682; + fma.rn.f32 %r684, %r40, %r676, %r683; + fma.rn.f32 %r685, %r41, %r677, %r684; + fma.rn.f32 %r686, %r42, %r678, %r685; + fma.rn.f32 %r687, %r43, %r679, %r686; + fma.rn.f32 %r688, %r44, %r680, %r687; + fma.rn.f32 %r1652, %r45, %r681, %r688; + setp.eq.b32 %p40, %r4, 5; + @%p40 bra $L__BB7_46; + add.s64 %rd92, %rd82, 51200; + // begin inline asm + ld.global.nc.v4.f32 {%r689,%r690,%r691,%r692}, [%rd92]; + // end inline asm + add.s64 %rd93, %rd82, 51216; + // begin inline asm + ld.global.nc.v4.f32 {%r693,%r694,%r695,%r696}, [%rd93]; + // end inline asm + fma.rn.f32 %r697, %r38, %r689, %r1651; + fma.rn.f32 %r698, %r39, %r690, %r697; + fma.rn.f32 %r699, %r40, %r691, %r698; + fma.rn.f32 %r700, %r41, %r692, %r699; + fma.rn.f32 %r701, %r42, %r693, %r700; + fma.rn.f32 %r702, %r43, %r694, %r701; + fma.rn.f32 %r703, %r44, %r695, %r702; + fma.rn.f32 %r1651, %r45, %r696, %r703; + setp.eq.b32 %p41, %r4, 6; + @%p41 bra $L__BB7_46; + add.s64 %rd94, %rd82, 61440; + // begin inline asm + ld.global.nc.v4.f32 {%r704,%r705,%r706,%r707}, [%rd94]; + // end inline asm + add.s64 %rd95, %rd82, 61456; + // begin inline asm + ld.global.nc.v4.f32 {%r708,%r709,%r710,%r711}, [%rd95]; + // end inline asm + fma.rn.f32 %r712, %r38, %r704, %r1650; + fma.rn.f32 %r713, %r39, %r705, %r712; + fma.rn.f32 %r714, %r40, %r706, %r713; + fma.rn.f32 %r715, %r41, %r707, %r714; + fma.rn.f32 %r716, %r42, %r708, %r715; + fma.rn.f32 %r717, %r43, %r709, %r716; + fma.rn.f32 %r718, %r44, %r710, %r717; + fma.rn.f32 %r1650, %r45, %r711, %r718; + setp.eq.b32 %p42, %r4, 7; + @%p42 bra $L__BB7_46; + add.s64 %rd96, %rd82, 71680; + // begin inline asm + ld.global.nc.v4.f32 {%r719,%r720,%r721,%r722}, [%rd96]; + // end inline asm + add.s64 %rd97, %rd82, 71696; + // begin inline asm + ld.global.nc.v4.f32 {%r723,%r724,%r725,%r726}, [%rd97]; + // end inline asm + fma.rn.f32 %r727, %r38, %r719, %r1649; + fma.rn.f32 %r728, %r39, %r720, %r727; + fma.rn.f32 %r729, %r40, %r721, %r728; + fma.rn.f32 %r730, %r41, %r722, %r729; + fma.rn.f32 %r731, %r42, %r723, %r730; + fma.rn.f32 %r732, %r43, %r724, %r731; + fma.rn.f32 %r733, %r44, %r725, %r732; + fma.rn.f32 %r1649, %r45, %r726, %r733; +$L__BB7_46: + setp.lt.s32 %p43, %r103, 1; + add.s64 %rd98, %rd9, 2560; + // begin inline asm + ld.global.nc.v4.u32 {%r734,%r735,%r736,%r737}, [%rd98]; + // end inline asm + @%p43 bra $L__BB7_55; + shl.b32 %r46, %r734, 16; + and.b32 %r47, %r734, -65536; + shl.b32 %r48, %r735, 16; + and.b32 %r49, %r735, -65536; + shl.b32 %r50, %r736, 16; + and.b32 %r51, %r736, -65536; + shl.b32 %r52, %r737, 16; + and.b32 %r53, %r737, -65536; + add.s64 %rd99, %rd2, 5120; + // begin inline asm + ld.global.nc.v4.f32 {%r738,%r739,%r740,%r741}, [%rd99]; + // end inline asm + add.s64 %rd100, %rd2, 5136; + // begin inline asm + ld.global.nc.v4.f32 {%r742,%r743,%r744,%r745}, [%rd100]; + // end inline asm + fma.rn.f32 %r746, %r46, %r738, %r1656; + fma.rn.f32 %r747, %r47, %r739, %r746; + fma.rn.f32 %r748, %r48, %r740, %r747; + fma.rn.f32 %r749, %r49, %r741, %r748; + fma.rn.f32 %r750, %r50, %r742, %r749; + fma.rn.f32 %r751, %r51, %r743, %r750; + fma.rn.f32 %r752, %r52, %r744, %r751; + fma.rn.f32 %r1656, %r53, %r745, %r752; + setp.eq.b32 %p44, %r3, 0; + @%p44 bra $L__BB7_55; + add.s64 %rd101, %rd99, 10240; + // begin inline asm + ld.global.nc.v4.f32 {%r753,%r754,%r755,%r756}, [%rd101]; + // end inline asm + add.s64 %rd102, %rd99, 10256; + // begin inline asm + ld.global.nc.v4.f32 {%r757,%r758,%r759,%r760}, [%rd102]; + // end inline asm + fma.rn.f32 %r761, %r46, %r753, %r1655; + fma.rn.f32 %r762, %r47, %r754, %r761; + fma.rn.f32 %r763, %r48, %r755, %r762; + fma.rn.f32 %r764, %r49, %r756, %r763; + fma.rn.f32 %r765, %r50, %r757, %r764; + fma.rn.f32 %r766, %r51, %r758, %r765; + fma.rn.f32 %r767, %r52, %r759, %r766; + fma.rn.f32 %r1655, %r53, %r760, %r767; + setp.eq.b32 %p45, %r4, 2; + @%p45 bra $L__BB7_55; + add.s64 %rd103, %rd99, 20480; + // begin inline asm + ld.global.nc.v4.f32 {%r768,%r769,%r770,%r771}, [%rd103]; + // end inline asm + add.s64 %rd104, %rd99, 20496; + // begin inline asm + ld.global.nc.v4.f32 {%r772,%r773,%r774,%r775}, [%rd104]; + // end inline asm + fma.rn.f32 %r776, %r46, %r768, %r1654; + fma.rn.f32 %r777, %r47, %r769, %r776; + fma.rn.f32 %r778, %r48, %r770, %r777; + fma.rn.f32 %r779, %r49, %r771, %r778; + fma.rn.f32 %r780, %r50, %r772, %r779; + fma.rn.f32 %r781, %r51, %r773, %r780; + fma.rn.f32 %r782, %r52, %r774, %r781; + fma.rn.f32 %r1654, %r53, %r775, %r782; + setp.eq.b32 %p46, %r4, 3; + @%p46 bra $L__BB7_55; + add.s64 %rd105, %rd99, 30720; + // begin inline asm + ld.global.nc.v4.f32 {%r783,%r784,%r785,%r786}, [%rd105]; + // end inline asm + add.s64 %rd106, %rd99, 30736; + // begin inline asm + ld.global.nc.v4.f32 {%r787,%r788,%r789,%r790}, [%rd106]; + // end inline asm + fma.rn.f32 %r791, %r46, %r783, %r1653; + fma.rn.f32 %r792, %r47, %r784, %r791; + fma.rn.f32 %r793, %r48, %r785, %r792; + fma.rn.f32 %r794, %r49, %r786, %r793; + fma.rn.f32 %r795, %r50, %r787, %r794; + fma.rn.f32 %r796, %r51, %r788, %r795; + fma.rn.f32 %r797, %r52, %r789, %r796; + fma.rn.f32 %r1653, %r53, %r790, %r797; + setp.eq.b32 %p47, %r4, 4; + @%p47 bra $L__BB7_55; + add.s64 %rd107, %rd99, 40960; + // begin inline asm + ld.global.nc.v4.f32 {%r798,%r799,%r800,%r801}, [%rd107]; + // end inline asm + add.s64 %rd108, %rd99, 40976; + // begin inline asm + ld.global.nc.v4.f32 {%r802,%r803,%r804,%r805}, [%rd108]; + // end inline asm + fma.rn.f32 %r806, %r46, %r798, %r1652; + fma.rn.f32 %r807, %r47, %r799, %r806; + fma.rn.f32 %r808, %r48, %r800, %r807; + fma.rn.f32 %r809, %r49, %r801, %r808; + fma.rn.f32 %r810, %r50, %r802, %r809; + fma.rn.f32 %r811, %r51, %r803, %r810; + fma.rn.f32 %r812, %r52, %r804, %r811; + fma.rn.f32 %r1652, %r53, %r805, %r812; + setp.eq.b32 %p48, %r4, 5; + @%p48 bra $L__BB7_55; + add.s64 %rd109, %rd99, 51200; + // begin inline asm + ld.global.nc.v4.f32 {%r813,%r814,%r815,%r816}, [%rd109]; + // end inline asm + add.s64 %rd110, %rd99, 51216; + // begin inline asm + ld.global.nc.v4.f32 {%r817,%r818,%r819,%r820}, [%rd110]; + // end inline asm + fma.rn.f32 %r821, %r46, %r813, %r1651; + fma.rn.f32 %r822, %r47, %r814, %r821; + fma.rn.f32 %r823, %r48, %r815, %r822; + fma.rn.f32 %r824, %r49, %r816, %r823; + fma.rn.f32 %r825, %r50, %r817, %r824; + fma.rn.f32 %r826, %r51, %r818, %r825; + fma.rn.f32 %r827, %r52, %r819, %r826; + fma.rn.f32 %r1651, %r53, %r820, %r827; + setp.eq.b32 %p49, %r4, 6; + @%p49 bra $L__BB7_55; + add.s64 %rd111, %rd99, 61440; + // begin inline asm + ld.global.nc.v4.f32 {%r828,%r829,%r830,%r831}, [%rd111]; + // end inline asm + add.s64 %rd112, %rd99, 61456; + // begin inline asm + ld.global.nc.v4.f32 {%r832,%r833,%r834,%r835}, [%rd112]; + // end inline asm + fma.rn.f32 %r836, %r46, %r828, %r1650; + fma.rn.f32 %r837, %r47, %r829, %r836; + fma.rn.f32 %r838, %r48, %r830, %r837; + fma.rn.f32 %r839, %r49, %r831, %r838; + fma.rn.f32 %r840, %r50, %r832, %r839; + fma.rn.f32 %r841, %r51, %r833, %r840; + fma.rn.f32 %r842, %r52, %r834, %r841; + fma.rn.f32 %r1650, %r53, %r835, %r842; + setp.eq.b32 %p50, %r4, 7; + @%p50 bra $L__BB7_55; + add.s64 %rd113, %rd99, 71680; + // begin inline asm + ld.global.nc.v4.f32 {%r843,%r844,%r845,%r846}, [%rd113]; + // end inline asm + add.s64 %rd114, %rd99, 71696; + // begin inline asm + ld.global.nc.v4.f32 {%r847,%r848,%r849,%r850}, [%rd114]; + // end inline asm + fma.rn.f32 %r851, %r46, %r843, %r1649; + fma.rn.f32 %r852, %r47, %r844, %r851; + fma.rn.f32 %r853, %r48, %r845, %r852; + fma.rn.f32 %r854, %r49, %r846, %r853; + fma.rn.f32 %r855, %r50, %r847, %r854; + fma.rn.f32 %r856, %r51, %r848, %r855; + fma.rn.f32 %r857, %r52, %r849, %r856; + fma.rn.f32 %r1649, %r53, %r850, %r857; +$L__BB7_55: + setp.lt.s32 %p51, %r103, 1; + add.s64 %rd115, %rd9, 3072; + // begin inline asm + ld.global.nc.v4.u32 {%r858,%r859,%r860,%r861}, [%rd115]; + // end inline asm + @%p51 bra $L__BB7_64; + shl.b32 %r54, %r858, 16; + and.b32 %r55, %r858, -65536; + shl.b32 %r56, %r859, 16; + and.b32 %r57, %r859, -65536; + shl.b32 %r58, %r860, 16; + and.b32 %r59, %r860, -65536; + shl.b32 %r60, %r861, 16; + and.b32 %r61, %r861, -65536; + add.s64 %rd116, %rd2, 6144; + // begin inline asm + ld.global.nc.v4.f32 {%r862,%r863,%r864,%r865}, [%rd116]; + // end inline asm + add.s64 %rd117, %rd2, 6160; + // begin inline asm + ld.global.nc.v4.f32 {%r866,%r867,%r868,%r869}, [%rd117]; + // end inline asm + fma.rn.f32 %r870, %r54, %r862, %r1656; + fma.rn.f32 %r871, %r55, %r863, %r870; + fma.rn.f32 %r872, %r56, %r864, %r871; + fma.rn.f32 %r873, %r57, %r865, %r872; + fma.rn.f32 %r874, %r58, %r866, %r873; + fma.rn.f32 %r875, %r59, %r867, %r874; + fma.rn.f32 %r876, %r60, %r868, %r875; + fma.rn.f32 %r1656, %r61, %r869, %r876; + setp.eq.b32 %p52, %r3, 0; + @%p52 bra $L__BB7_64; + add.s64 %rd118, %rd116, 10240; + // begin inline asm + ld.global.nc.v4.f32 {%r877,%r878,%r879,%r880}, [%rd118]; + // end inline asm + add.s64 %rd119, %rd116, 10256; + // begin inline asm + ld.global.nc.v4.f32 {%r881,%r882,%r883,%r884}, [%rd119]; + // end inline asm + fma.rn.f32 %r885, %r54, %r877, %r1655; + fma.rn.f32 %r886, %r55, %r878, %r885; + fma.rn.f32 %r887, %r56, %r879, %r886; + fma.rn.f32 %r888, %r57, %r880, %r887; + fma.rn.f32 %r889, %r58, %r881, %r888; + fma.rn.f32 %r890, %r59, %r882, %r889; + fma.rn.f32 %r891, %r60, %r883, %r890; + fma.rn.f32 %r1655, %r61, %r884, %r891; + setp.eq.b32 %p53, %r4, 2; + @%p53 bra $L__BB7_64; + add.s64 %rd120, %rd116, 20480; + // begin inline asm + ld.global.nc.v4.f32 {%r892,%r893,%r894,%r895}, [%rd120]; + // end inline asm + add.s64 %rd121, %rd116, 20496; + // begin inline asm + ld.global.nc.v4.f32 {%r896,%r897,%r898,%r899}, [%rd121]; + // end inline asm + fma.rn.f32 %r900, %r54, %r892, %r1654; + fma.rn.f32 %r901, %r55, %r893, %r900; + fma.rn.f32 %r902, %r56, %r894, %r901; + fma.rn.f32 %r903, %r57, %r895, %r902; + fma.rn.f32 %r904, %r58, %r896, %r903; + fma.rn.f32 %r905, %r59, %r897, %r904; + fma.rn.f32 %r906, %r60, %r898, %r905; + fma.rn.f32 %r1654, %r61, %r899, %r906; + setp.eq.b32 %p54, %r4, 3; + @%p54 bra $L__BB7_64; + add.s64 %rd122, %rd116, 30720; + // begin inline asm + ld.global.nc.v4.f32 {%r907,%r908,%r909,%r910}, [%rd122]; + // end inline asm + add.s64 %rd123, %rd116, 30736; + // begin inline asm + ld.global.nc.v4.f32 {%r911,%r912,%r913,%r914}, [%rd123]; + // end inline asm + fma.rn.f32 %r915, %r54, %r907, %r1653; + fma.rn.f32 %r916, %r55, %r908, %r915; + fma.rn.f32 %r917, %r56, %r909, %r916; + fma.rn.f32 %r918, %r57, %r910, %r917; + fma.rn.f32 %r919, %r58, %r911, %r918; + fma.rn.f32 %r920, %r59, %r912, %r919; + fma.rn.f32 %r921, %r60, %r913, %r920; + fma.rn.f32 %r1653, %r61, %r914, %r921; + setp.eq.b32 %p55, %r4, 4; + @%p55 bra $L__BB7_64; + add.s64 %rd124, %rd116, 40960; + // begin inline asm + ld.global.nc.v4.f32 {%r922,%r923,%r924,%r925}, [%rd124]; + // end inline asm + add.s64 %rd125, %rd116, 40976; + // begin inline asm + ld.global.nc.v4.f32 {%r926,%r927,%r928,%r929}, [%rd125]; + // end inline asm + fma.rn.f32 %r930, %r54, %r922, %r1652; + fma.rn.f32 %r931, %r55, %r923, %r930; + fma.rn.f32 %r932, %r56, %r924, %r931; + fma.rn.f32 %r933, %r57, %r925, %r932; + fma.rn.f32 %r934, %r58, %r926, %r933; + fma.rn.f32 %r935, %r59, %r927, %r934; + fma.rn.f32 %r936, %r60, %r928, %r935; + fma.rn.f32 %r1652, %r61, %r929, %r936; + setp.eq.b32 %p56, %r4, 5; + @%p56 bra $L__BB7_64; + add.s64 %rd126, %rd116, 51200; + // begin inline asm + ld.global.nc.v4.f32 {%r937,%r938,%r939,%r940}, [%rd126]; + // end inline asm + add.s64 %rd127, %rd116, 51216; + // begin inline asm + ld.global.nc.v4.f32 {%r941,%r942,%r943,%r944}, [%rd127]; + // end inline asm + fma.rn.f32 %r945, %r54, %r937, %r1651; + fma.rn.f32 %r946, %r55, %r938, %r945; + fma.rn.f32 %r947, %r56, %r939, %r946; + fma.rn.f32 %r948, %r57, %r940, %r947; + fma.rn.f32 %r949, %r58, %r941, %r948; + fma.rn.f32 %r950, %r59, %r942, %r949; + fma.rn.f32 %r951, %r60, %r943, %r950; + fma.rn.f32 %r1651, %r61, %r944, %r951; + setp.eq.b32 %p57, %r4, 6; + @%p57 bra $L__BB7_64; + add.s64 %rd128, %rd116, 61440; + // begin inline asm + ld.global.nc.v4.f32 {%r952,%r953,%r954,%r955}, [%rd128]; + // end inline asm + add.s64 %rd129, %rd116, 61456; + // begin inline asm + ld.global.nc.v4.f32 {%r956,%r957,%r958,%r959}, [%rd129]; + // end inline asm + fma.rn.f32 %r960, %r54, %r952, %r1650; + fma.rn.f32 %r961, %r55, %r953, %r960; + fma.rn.f32 %r962, %r56, %r954, %r961; + fma.rn.f32 %r963, %r57, %r955, %r962; + fma.rn.f32 %r964, %r58, %r956, %r963; + fma.rn.f32 %r965, %r59, %r957, %r964; + fma.rn.f32 %r966, %r60, %r958, %r965; + fma.rn.f32 %r1650, %r61, %r959, %r966; + setp.eq.b32 %p58, %r4, 7; + @%p58 bra $L__BB7_64; + add.s64 %rd130, %rd116, 71680; + // begin inline asm + ld.global.nc.v4.f32 {%r967,%r968,%r969,%r970}, [%rd130]; + // end inline asm + add.s64 %rd131, %rd116, 71696; + // begin inline asm + ld.global.nc.v4.f32 {%r971,%r972,%r973,%r974}, [%rd131]; + // end inline asm + fma.rn.f32 %r975, %r54, %r967, %r1649; + fma.rn.f32 %r976, %r55, %r968, %r975; + fma.rn.f32 %r977, %r56, %r969, %r976; + fma.rn.f32 %r978, %r57, %r970, %r977; + fma.rn.f32 %r979, %r58, %r971, %r978; + fma.rn.f32 %r980, %r59, %r972, %r979; + fma.rn.f32 %r981, %r60, %r973, %r980; + fma.rn.f32 %r1649, %r61, %r974, %r981; +$L__BB7_64: + setp.lt.s32 %p59, %r103, 1; + add.s64 %rd132, %rd9, 3584; + // begin inline asm + ld.global.nc.v4.u32 {%r982,%r983,%r984,%r985}, [%rd132]; + // end inline asm + @%p59 bra $L__BB7_73; + shl.b32 %r62, %r982, 16; + and.b32 %r63, %r982, -65536; + shl.b32 %r64, %r983, 16; + and.b32 %r65, %r983, -65536; + shl.b32 %r66, %r984, 16; + and.b32 %r67, %r984, -65536; + shl.b32 %r68, %r985, 16; + and.b32 %r69, %r985, -65536; + add.s64 %rd133, %rd2, 7168; + // begin inline asm + ld.global.nc.v4.f32 {%r986,%r987,%r988,%r989}, [%rd133]; + // end inline asm + add.s64 %rd134, %rd2, 7184; + // begin inline asm + ld.global.nc.v4.f32 {%r990,%r991,%r992,%r993}, [%rd134]; + // end inline asm + fma.rn.f32 %r994, %r62, %r986, %r1656; + fma.rn.f32 %r995, %r63, %r987, %r994; + fma.rn.f32 %r996, %r64, %r988, %r995; + fma.rn.f32 %r997, %r65, %r989, %r996; + fma.rn.f32 %r998, %r66, %r990, %r997; + fma.rn.f32 %r999, %r67, %r991, %r998; + fma.rn.f32 %r1000, %r68, %r992, %r999; + fma.rn.f32 %r1656, %r69, %r993, %r1000; + setp.eq.b32 %p60, %r3, 0; + @%p60 bra $L__BB7_73; + add.s64 %rd135, %rd133, 10240; + // begin inline asm + ld.global.nc.v4.f32 {%r1001,%r1002,%r1003,%r1004}, [%rd135]; + // end inline asm + add.s64 %rd136, %rd133, 10256; + // begin inline asm + ld.global.nc.v4.f32 {%r1005,%r1006,%r1007,%r1008}, [%rd136]; + // end inline asm + fma.rn.f32 %r1009, %r62, %r1001, %r1655; + fma.rn.f32 %r1010, %r63, %r1002, %r1009; + fma.rn.f32 %r1011, %r64, %r1003, %r1010; + fma.rn.f32 %r1012, %r65, %r1004, %r1011; + fma.rn.f32 %r1013, %r66, %r1005, %r1012; + fma.rn.f32 %r1014, %r67, %r1006, %r1013; + fma.rn.f32 %r1015, %r68, %r1007, %r1014; + fma.rn.f32 %r1655, %r69, %r1008, %r1015; + setp.eq.b32 %p61, %r4, 2; + @%p61 bra $L__BB7_73; + add.s64 %rd137, %rd133, 20480; + // begin inline asm + ld.global.nc.v4.f32 {%r1016,%r1017,%r1018,%r1019}, [%rd137]; + // end inline asm + add.s64 %rd138, %rd133, 20496; + // begin inline asm + ld.global.nc.v4.f32 {%r1020,%r1021,%r1022,%r1023}, [%rd138]; + // end inline asm + fma.rn.f32 %r1024, %r62, %r1016, %r1654; + fma.rn.f32 %r1025, %r63, %r1017, %r1024; + fma.rn.f32 %r1026, %r64, %r1018, %r1025; + fma.rn.f32 %r1027, %r65, %r1019, %r1026; + fma.rn.f32 %r1028, %r66, %r1020, %r1027; + fma.rn.f32 %r1029, %r67, %r1021, %r1028; + fma.rn.f32 %r1030, %r68, %r1022, %r1029; + fma.rn.f32 %r1654, %r69, %r1023, %r1030; + setp.eq.b32 %p62, %r4, 3; + @%p62 bra $L__BB7_73; + add.s64 %rd139, %rd133, 30720; + // begin inline asm + ld.global.nc.v4.f32 {%r1031,%r1032,%r1033,%r1034}, [%rd139]; + // end inline asm + add.s64 %rd140, %rd133, 30736; + // begin inline asm + ld.global.nc.v4.f32 {%r1035,%r1036,%r1037,%r1038}, [%rd140]; + // end inline asm + fma.rn.f32 %r1039, %r62, %r1031, %r1653; + fma.rn.f32 %r1040, %r63, %r1032, %r1039; + fma.rn.f32 %r1041, %r64, %r1033, %r1040; + fma.rn.f32 %r1042, %r65, %r1034, %r1041; + fma.rn.f32 %r1043, %r66, %r1035, %r1042; + fma.rn.f32 %r1044, %r67, %r1036, %r1043; + fma.rn.f32 %r1045, %r68, %r1037, %r1044; + fma.rn.f32 %r1653, %r69, %r1038, %r1045; + setp.eq.b32 %p63, %r4, 4; + @%p63 bra $L__BB7_73; + add.s64 %rd141, %rd133, 40960; + // begin inline asm + ld.global.nc.v4.f32 {%r1046,%r1047,%r1048,%r1049}, [%rd141]; + // end inline asm + add.s64 %rd142, %rd133, 40976; + // begin inline asm + ld.global.nc.v4.f32 {%r1050,%r1051,%r1052,%r1053}, [%rd142]; + // end inline asm + fma.rn.f32 %r1054, %r62, %r1046, %r1652; + fma.rn.f32 %r1055, %r63, %r1047, %r1054; + fma.rn.f32 %r1056, %r64, %r1048, %r1055; + fma.rn.f32 %r1057, %r65, %r1049, %r1056; + fma.rn.f32 %r1058, %r66, %r1050, %r1057; + fma.rn.f32 %r1059, %r67, %r1051, %r1058; + fma.rn.f32 %r1060, %r68, %r1052, %r1059; + fma.rn.f32 %r1652, %r69, %r1053, %r1060; + setp.eq.b32 %p64, %r4, 5; + @%p64 bra $L__BB7_73; + add.s64 %rd143, %rd133, 51200; + // begin inline asm + ld.global.nc.v4.f32 {%r1061,%r1062,%r1063,%r1064}, [%rd143]; + // end inline asm + add.s64 %rd144, %rd133, 51216; + // begin inline asm + ld.global.nc.v4.f32 {%r1065,%r1066,%r1067,%r1068}, [%rd144]; + // end inline asm + fma.rn.f32 %r1069, %r62, %r1061, %r1651; + fma.rn.f32 %r1070, %r63, %r1062, %r1069; + fma.rn.f32 %r1071, %r64, %r1063, %r1070; + fma.rn.f32 %r1072, %r65, %r1064, %r1071; + fma.rn.f32 %r1073, %r66, %r1065, %r1072; + fma.rn.f32 %r1074, %r67, %r1066, %r1073; + fma.rn.f32 %r1075, %r68, %r1067, %r1074; + fma.rn.f32 %r1651, %r69, %r1068, %r1075; + setp.eq.b32 %p65, %r4, 6; + @%p65 bra $L__BB7_73; + add.s64 %rd145, %rd133, 61440; + // begin inline asm + ld.global.nc.v4.f32 {%r1076,%r1077,%r1078,%r1079}, [%rd145]; + // end inline asm + add.s64 %rd146, %rd133, 61456; + // begin inline asm + ld.global.nc.v4.f32 {%r1080,%r1081,%r1082,%r1083}, [%rd146]; + // end inline asm + fma.rn.f32 %r1084, %r62, %r1076, %r1650; + fma.rn.f32 %r1085, %r63, %r1077, %r1084; + fma.rn.f32 %r1086, %r64, %r1078, %r1085; + fma.rn.f32 %r1087, %r65, %r1079, %r1086; + fma.rn.f32 %r1088, %r66, %r1080, %r1087; + fma.rn.f32 %r1089, %r67, %r1081, %r1088; + fma.rn.f32 %r1090, %r68, %r1082, %r1089; + fma.rn.f32 %r1650, %r69, %r1083, %r1090; + setp.eq.b32 %p66, %r4, 7; + @%p66 bra $L__BB7_73; + add.s64 %rd147, %rd133, 71680; + // begin inline asm + ld.global.nc.v4.f32 {%r1091,%r1092,%r1093,%r1094}, [%rd147]; + // end inline asm + add.s64 %rd148, %rd133, 71696; + // begin inline asm + ld.global.nc.v4.f32 {%r1095,%r1096,%r1097,%r1098}, [%rd148]; + // end inline asm + fma.rn.f32 %r1099, %r62, %r1091, %r1649; + fma.rn.f32 %r1100, %r63, %r1092, %r1099; + fma.rn.f32 %r1101, %r64, %r1093, %r1100; + fma.rn.f32 %r1102, %r65, %r1094, %r1101; + fma.rn.f32 %r1103, %r66, %r1095, %r1102; + fma.rn.f32 %r1104, %r67, %r1096, %r1103; + fma.rn.f32 %r1105, %r68, %r1097, %r1104; + fma.rn.f32 %r1649, %r69, %r1098, %r1105; +$L__BB7_73: + setp.lt.s32 %p67, %r103, 1; + add.s64 %rd149, %rd9, 4096; + // begin inline asm + ld.global.nc.v4.u32 {%r1106,%r1107,%r1108,%r1109}, [%rd149]; + // end inline asm + @%p67 bra $L__BB7_82; + shl.b32 %r70, %r1106, 16; + and.b32 %r71, %r1106, -65536; + shl.b32 %r72, %r1107, 16; + and.b32 %r73, %r1107, -65536; + shl.b32 %r74, %r1108, 16; + and.b32 %r75, %r1108, -65536; + shl.b32 %r76, %r1109, 16; + and.b32 %r77, %r1109, -65536; + add.s64 %rd150, %rd2, 8192; + // begin inline asm + ld.global.nc.v4.f32 {%r1110,%r1111,%r1112,%r1113}, [%rd150]; + // end inline asm + add.s64 %rd151, %rd2, 8208; + // begin inline asm + ld.global.nc.v4.f32 {%r1114,%r1115,%r1116,%r1117}, [%rd151]; + // end inline asm + fma.rn.f32 %r1118, %r70, %r1110, %r1656; + fma.rn.f32 %r1119, %r71, %r1111, %r1118; + fma.rn.f32 %r1120, %r72, %r1112, %r1119; + fma.rn.f32 %r1121, %r73, %r1113, %r1120; + fma.rn.f32 %r1122, %r74, %r1114, %r1121; + fma.rn.f32 %r1123, %r75, %r1115, %r1122; + fma.rn.f32 %r1124, %r76, %r1116, %r1123; + fma.rn.f32 %r1656, %r77, %r1117, %r1124; + setp.eq.b32 %p68, %r3, 0; + @%p68 bra $L__BB7_82; + add.s64 %rd152, %rd150, 10240; + // begin inline asm + ld.global.nc.v4.f32 {%r1125,%r1126,%r1127,%r1128}, [%rd152]; + // end inline asm + add.s64 %rd153, %rd150, 10256; + // begin inline asm + ld.global.nc.v4.f32 {%r1129,%r1130,%r1131,%r1132}, [%rd153]; + // end inline asm + fma.rn.f32 %r1133, %r70, %r1125, %r1655; + fma.rn.f32 %r1134, %r71, %r1126, %r1133; + fma.rn.f32 %r1135, %r72, %r1127, %r1134; + fma.rn.f32 %r1136, %r73, %r1128, %r1135; + fma.rn.f32 %r1137, %r74, %r1129, %r1136; + fma.rn.f32 %r1138, %r75, %r1130, %r1137; + fma.rn.f32 %r1139, %r76, %r1131, %r1138; + fma.rn.f32 %r1655, %r77, %r1132, %r1139; + setp.eq.b32 %p69, %r4, 2; + @%p69 bra $L__BB7_82; + add.s64 %rd154, %rd150, 20480; + // begin inline asm + ld.global.nc.v4.f32 {%r1140,%r1141,%r1142,%r1143}, [%rd154]; + // end inline asm + add.s64 %rd155, %rd150, 20496; + // begin inline asm + ld.global.nc.v4.f32 {%r1144,%r1145,%r1146,%r1147}, [%rd155]; + // end inline asm + fma.rn.f32 %r1148, %r70, %r1140, %r1654; + fma.rn.f32 %r1149, %r71, %r1141, %r1148; + fma.rn.f32 %r1150, %r72, %r1142, %r1149; + fma.rn.f32 %r1151, %r73, %r1143, %r1150; + fma.rn.f32 %r1152, %r74, %r1144, %r1151; + fma.rn.f32 %r1153, %r75, %r1145, %r1152; + fma.rn.f32 %r1154, %r76, %r1146, %r1153; + fma.rn.f32 %r1654, %r77, %r1147, %r1154; + setp.eq.b32 %p70, %r4, 3; + @%p70 bra $L__BB7_82; + add.s64 %rd156, %rd150, 30720; + // begin inline asm + ld.global.nc.v4.f32 {%r1155,%r1156,%r1157,%r1158}, [%rd156]; + // end inline asm + add.s64 %rd157, %rd150, 30736; + // begin inline asm + ld.global.nc.v4.f32 {%r1159,%r1160,%r1161,%r1162}, [%rd157]; + // end inline asm + fma.rn.f32 %r1163, %r70, %r1155, %r1653; + fma.rn.f32 %r1164, %r71, %r1156, %r1163; + fma.rn.f32 %r1165, %r72, %r1157, %r1164; + fma.rn.f32 %r1166, %r73, %r1158, %r1165; + fma.rn.f32 %r1167, %r74, %r1159, %r1166; + fma.rn.f32 %r1168, %r75, %r1160, %r1167; + fma.rn.f32 %r1169, %r76, %r1161, %r1168; + fma.rn.f32 %r1653, %r77, %r1162, %r1169; + setp.eq.b32 %p71, %r4, 4; + @%p71 bra $L__BB7_82; + add.s64 %rd158, %rd150, 40960; + // begin inline asm + ld.global.nc.v4.f32 {%r1170,%r1171,%r1172,%r1173}, [%rd158]; + // end inline asm + add.s64 %rd159, %rd150, 40976; + // begin inline asm + ld.global.nc.v4.f32 {%r1174,%r1175,%r1176,%r1177}, [%rd159]; + // end inline asm + fma.rn.f32 %r1178, %r70, %r1170, %r1652; + fma.rn.f32 %r1179, %r71, %r1171, %r1178; + fma.rn.f32 %r1180, %r72, %r1172, %r1179; + fma.rn.f32 %r1181, %r73, %r1173, %r1180; + fma.rn.f32 %r1182, %r74, %r1174, %r1181; + fma.rn.f32 %r1183, %r75, %r1175, %r1182; + fma.rn.f32 %r1184, %r76, %r1176, %r1183; + fma.rn.f32 %r1652, %r77, %r1177, %r1184; + setp.eq.b32 %p72, %r4, 5; + @%p72 bra $L__BB7_82; + add.s64 %rd160, %rd150, 51200; + // begin inline asm + ld.global.nc.v4.f32 {%r1185,%r1186,%r1187,%r1188}, [%rd160]; + // end inline asm + add.s64 %rd161, %rd150, 51216; + // begin inline asm + ld.global.nc.v4.f32 {%r1189,%r1190,%r1191,%r1192}, [%rd161]; + // end inline asm + fma.rn.f32 %r1193, %r70, %r1185, %r1651; + fma.rn.f32 %r1194, %r71, %r1186, %r1193; + fma.rn.f32 %r1195, %r72, %r1187, %r1194; + fma.rn.f32 %r1196, %r73, %r1188, %r1195; + fma.rn.f32 %r1197, %r74, %r1189, %r1196; + fma.rn.f32 %r1198, %r75, %r1190, %r1197; + fma.rn.f32 %r1199, %r76, %r1191, %r1198; + fma.rn.f32 %r1651, %r77, %r1192, %r1199; + setp.eq.b32 %p73, %r4, 6; + @%p73 bra $L__BB7_82; + add.s64 %rd162, %rd150, 61440; + // begin inline asm + ld.global.nc.v4.f32 {%r1200,%r1201,%r1202,%r1203}, [%rd162]; + // end inline asm + add.s64 %rd163, %rd150, 61456; + // begin inline asm + ld.global.nc.v4.f32 {%r1204,%r1205,%r1206,%r1207}, [%rd163]; + // end inline asm + fma.rn.f32 %r1208, %r70, %r1200, %r1650; + fma.rn.f32 %r1209, %r71, %r1201, %r1208; + fma.rn.f32 %r1210, %r72, %r1202, %r1209; + fma.rn.f32 %r1211, %r73, %r1203, %r1210; + fma.rn.f32 %r1212, %r74, %r1204, %r1211; + fma.rn.f32 %r1213, %r75, %r1205, %r1212; + fma.rn.f32 %r1214, %r76, %r1206, %r1213; + fma.rn.f32 %r1650, %r77, %r1207, %r1214; + setp.eq.b32 %p74, %r4, 7; + @%p74 bra $L__BB7_82; + add.s64 %rd164, %rd150, 71680; + // begin inline asm + ld.global.nc.v4.f32 {%r1215,%r1216,%r1217,%r1218}, [%rd164]; + // end inline asm + add.s64 %rd165, %rd150, 71696; + // begin inline asm + ld.global.nc.v4.f32 {%r1219,%r1220,%r1221,%r1222}, [%rd165]; + // end inline asm + fma.rn.f32 %r1223, %r70, %r1215, %r1649; + fma.rn.f32 %r1224, %r71, %r1216, %r1223; + fma.rn.f32 %r1225, %r72, %r1217, %r1224; + fma.rn.f32 %r1226, %r73, %r1218, %r1225; + fma.rn.f32 %r1227, %r74, %r1219, %r1226; + fma.rn.f32 %r1228, %r75, %r1220, %r1227; + fma.rn.f32 %r1229, %r76, %r1221, %r1228; + fma.rn.f32 %r1649, %r77, %r1222, %r1229; +$L__BB7_82: + setp.lt.s32 %p75, %r103, 1; + add.s64 %rd166, %rd9, 4608; + // begin inline asm + ld.global.nc.v4.u32 {%r1230,%r1231,%r1232,%r1233}, [%rd166]; + // end inline asm + @%p75 bra $L__BB7_91; + shl.b32 %r78, %r1230, 16; + and.b32 %r79, %r1230, -65536; + shl.b32 %r80, %r1231, 16; + and.b32 %r81, %r1231, -65536; + shl.b32 %r82, %r1232, 16; + and.b32 %r83, %r1232, -65536; + shl.b32 %r84, %r1233, 16; + and.b32 %r85, %r1233, -65536; + add.s64 %rd167, %rd2, 9216; + // begin inline asm + ld.global.nc.v4.f32 {%r1234,%r1235,%r1236,%r1237}, [%rd167]; + // end inline asm + add.s64 %rd168, %rd2, 9232; + // begin inline asm + ld.global.nc.v4.f32 {%r1238,%r1239,%r1240,%r1241}, [%rd168]; + // end inline asm + fma.rn.f32 %r1242, %r78, %r1234, %r1656; + fma.rn.f32 %r1243, %r79, %r1235, %r1242; + fma.rn.f32 %r1244, %r80, %r1236, %r1243; + fma.rn.f32 %r1245, %r81, %r1237, %r1244; + fma.rn.f32 %r1246, %r82, %r1238, %r1245; + fma.rn.f32 %r1247, %r83, %r1239, %r1246; + fma.rn.f32 %r1248, %r84, %r1240, %r1247; + fma.rn.f32 %r1656, %r85, %r1241, %r1248; + setp.eq.b32 %p76, %r3, 0; + @%p76 bra $L__BB7_91; + add.s64 %rd169, %rd167, 10240; + // begin inline asm + ld.global.nc.v4.f32 {%r1249,%r1250,%r1251,%r1252}, [%rd169]; + // end inline asm + add.s64 %rd170, %rd167, 10256; + // begin inline asm + ld.global.nc.v4.f32 {%r1253,%r1254,%r1255,%r1256}, [%rd170]; + // end inline asm + fma.rn.f32 %r1257, %r78, %r1249, %r1655; + fma.rn.f32 %r1258, %r79, %r1250, %r1257; + fma.rn.f32 %r1259, %r80, %r1251, %r1258; + fma.rn.f32 %r1260, %r81, %r1252, %r1259; + fma.rn.f32 %r1261, %r82, %r1253, %r1260; + fma.rn.f32 %r1262, %r83, %r1254, %r1261; + fma.rn.f32 %r1263, %r84, %r1255, %r1262; + fma.rn.f32 %r1655, %r85, %r1256, %r1263; + setp.eq.b32 %p77, %r4, 2; + @%p77 bra $L__BB7_91; + add.s64 %rd171, %rd167, 20480; + // begin inline asm + ld.global.nc.v4.f32 {%r1264,%r1265,%r1266,%r1267}, [%rd171]; + // end inline asm + add.s64 %rd172, %rd167, 20496; + // begin inline asm + ld.global.nc.v4.f32 {%r1268,%r1269,%r1270,%r1271}, [%rd172]; + // end inline asm + fma.rn.f32 %r1272, %r78, %r1264, %r1654; + fma.rn.f32 %r1273, %r79, %r1265, %r1272; + fma.rn.f32 %r1274, %r80, %r1266, %r1273; + fma.rn.f32 %r1275, %r81, %r1267, %r1274; + fma.rn.f32 %r1276, %r82, %r1268, %r1275; + fma.rn.f32 %r1277, %r83, %r1269, %r1276; + fma.rn.f32 %r1278, %r84, %r1270, %r1277; + fma.rn.f32 %r1654, %r85, %r1271, %r1278; + setp.eq.b32 %p78, %r4, 3; + @%p78 bra $L__BB7_91; + add.s64 %rd173, %rd167, 30720; + // begin inline asm + ld.global.nc.v4.f32 {%r1279,%r1280,%r1281,%r1282}, [%rd173]; + // end inline asm + add.s64 %rd174, %rd167, 30736; + // begin inline asm + ld.global.nc.v4.f32 {%r1283,%r1284,%r1285,%r1286}, [%rd174]; + // end inline asm + fma.rn.f32 %r1287, %r78, %r1279, %r1653; + fma.rn.f32 %r1288, %r79, %r1280, %r1287; + fma.rn.f32 %r1289, %r80, %r1281, %r1288; + fma.rn.f32 %r1290, %r81, %r1282, %r1289; + fma.rn.f32 %r1291, %r82, %r1283, %r1290; + fma.rn.f32 %r1292, %r83, %r1284, %r1291; + fma.rn.f32 %r1293, %r84, %r1285, %r1292; + fma.rn.f32 %r1653, %r85, %r1286, %r1293; + setp.eq.b32 %p79, %r4, 4; + @%p79 bra $L__BB7_91; + add.s64 %rd175, %rd167, 40960; + // begin inline asm + ld.global.nc.v4.f32 {%r1294,%r1295,%r1296,%r1297}, [%rd175]; + // end inline asm + add.s64 %rd176, %rd167, 40976; + // begin inline asm + ld.global.nc.v4.f32 {%r1298,%r1299,%r1300,%r1301}, [%rd176]; + // end inline asm + fma.rn.f32 %r1302, %r78, %r1294, %r1652; + fma.rn.f32 %r1303, %r79, %r1295, %r1302; + fma.rn.f32 %r1304, %r80, %r1296, %r1303; + fma.rn.f32 %r1305, %r81, %r1297, %r1304; + fma.rn.f32 %r1306, %r82, %r1298, %r1305; + fma.rn.f32 %r1307, %r83, %r1299, %r1306; + fma.rn.f32 %r1308, %r84, %r1300, %r1307; + fma.rn.f32 %r1652, %r85, %r1301, %r1308; + setp.eq.b32 %p80, %r4, 5; + @%p80 bra $L__BB7_91; + add.s64 %rd177, %rd167, 51200; + // begin inline asm + ld.global.nc.v4.f32 {%r1309,%r1310,%r1311,%r1312}, [%rd177]; + // end inline asm + add.s64 %rd178, %rd167, 51216; + // begin inline asm + ld.global.nc.v4.f32 {%r1313,%r1314,%r1315,%r1316}, [%rd178]; + // end inline asm + fma.rn.f32 %r1317, %r78, %r1309, %r1651; + fma.rn.f32 %r1318, %r79, %r1310, %r1317; + fma.rn.f32 %r1319, %r80, %r1311, %r1318; + fma.rn.f32 %r1320, %r81, %r1312, %r1319; + fma.rn.f32 %r1321, %r82, %r1313, %r1320; + fma.rn.f32 %r1322, %r83, %r1314, %r1321; + fma.rn.f32 %r1323, %r84, %r1315, %r1322; + fma.rn.f32 %r1651, %r85, %r1316, %r1323; + setp.eq.b32 %p81, %r4, 6; + @%p81 bra $L__BB7_91; + add.s64 %rd179, %rd167, 61440; + // begin inline asm + ld.global.nc.v4.f32 {%r1324,%r1325,%r1326,%r1327}, [%rd179]; + // end inline asm + add.s64 %rd180, %rd167, 61456; + // begin inline asm + ld.global.nc.v4.f32 {%r1328,%r1329,%r1330,%r1331}, [%rd180]; + // end inline asm + fma.rn.f32 %r1332, %r78, %r1324, %r1650; + fma.rn.f32 %r1333, %r79, %r1325, %r1332; + fma.rn.f32 %r1334, %r80, %r1326, %r1333; + fma.rn.f32 %r1335, %r81, %r1327, %r1334; + fma.rn.f32 %r1336, %r82, %r1328, %r1335; + fma.rn.f32 %r1337, %r83, %r1329, %r1336; + fma.rn.f32 %r1338, %r84, %r1330, %r1337; + fma.rn.f32 %r1650, %r85, %r1331, %r1338; + setp.eq.b32 %p82, %r4, 7; + @%p82 bra $L__BB7_91; + add.s64 %rd181, %rd167, 71680; + // begin inline asm + ld.global.nc.v4.f32 {%r1339,%r1340,%r1341,%r1342}, [%rd181]; + // end inline asm + add.s64 %rd182, %rd167, 71696; + // begin inline asm + ld.global.nc.v4.f32 {%r1343,%r1344,%r1345,%r1346}, [%rd182]; + // end inline asm + fma.rn.f32 %r1347, %r78, %r1339, %r1649; + fma.rn.f32 %r1348, %r79, %r1340, %r1347; + fma.rn.f32 %r1349, %r80, %r1341, %r1348; + fma.rn.f32 %r1350, %r81, %r1342, %r1349; + fma.rn.f32 %r1351, %r82, %r1343, %r1350; + fma.rn.f32 %r1352, %r83, %r1344, %r1351; + fma.rn.f32 %r1353, %r84, %r1345, %r1352; + fma.rn.f32 %r1649, %r85, %r1346, %r1353; +$L__BB7_91: + setp.lt.s32 %p83, %r103, 1; + @%p83 bra $L__BB7_163; + ld.param.b64 %rd219, [leleka_gdn_ab_unrolled_t8_param_4]; + ld.param.b64 %rd218, [leleka_gdn_ab_unrolled_t8_param_3]; + setp.eq.b32 %p84, %r2, 0; + cvta.to.global.u64 %rd183, %rd218; + shl.b64 %rd184, %rd1, 2; + add.s64 %rd3, %rd183, %rd184; + cvta.to.global.u64 %rd185, %rd219; + add.s64 %rd4, %rd185, %rd184; + cvt.s64.s32 %rd5, %r102; + shfl.sync.bfly.b32 %r1354|%p85, %r1656, 16, 31, -1; + add.f32 %r1355, %r1656, %r1354; + shfl.sync.bfly.b32 %r1356|%p86, %r1355, 8, 31, -1; + add.f32 %r1357, %r1355, %r1356; + shfl.sync.bfly.b32 %r1358|%p87, %r1357, 4, 31, -1; + add.f32 %r1359, %r1357, %r1358; + shfl.sync.bfly.b32 %r1360|%p88, %r1359, 2, 31, -1; + add.f32 %r1361, %r1359, %r1360; + shfl.sync.bfly.b32 %r1362|%p89, %r1361, 1, 31, -1; + add.f32 %r5, %r1361, %r1362; + @%p84 bra $L__BB7_93; + bra.uni $L__BB7_100; +$L__BB7_93: + setp.lt.s32 %p90, %r1, %r102; + @%p90 bra $L__BB7_95; + ld.param.b64 %rd220, [leleka_gdn_ab_unrolled_t8_param_6]; + mul.f32 %r1363, %r5, 0fBFB8AA3B; + ex2.approx.f32 %r1364, %r1363; + add.f32 %r1365, %r1364, 0f3F800000; + rcp.rn.f32 %r1658, %r1365; + bra.uni $L__BB7_99; +$L__BB7_95: + ld.global.nc.b32 %r1366, [%rd3]; + add.f32 %r1657, %r5, %r1366; + setp.gt.f32 %p91, %r1657, 0f41A00000; + @%p91 bra $L__BB7_98; + mul.f32 %r1367, %r1657, 0f3FB8AA3B; + ex2.approx.f32 %r86, %r1367; + mov.b32 %r1368, 0f3F800000; + add.rz.f32 %r1369, %r86, %r1368; + add.s32 %r1370, %r1369, -1061158912; + and.b32 %r1371, %r1370, -8388608; + sub.s32 %r1372, %r86, %r1371; + sub.s32 %r1373, 1082130432, %r1371; + fma.rn.f32 %r1374, %r1373, 0f3E800000, 0fBF800000; + add.f32 %r1375, %r1374, %r1372; + cvt.rn.f32.s32 %r1376, %r1371; + mul.f32 %r1377, %r1376, 0f34000000; + fma.rn.f32 %r1378, %r1375, 0fBD39BF78, 0f3DD80012; + fma.rn.f32 %r1379, %r1378, %r1375, 0fBE0778E0; + fma.rn.f32 %r1380, %r1379, %r1375, 0f3E146475; + fma.rn.f32 %r1381, %r1380, %r1375, 0fBE2A68DD; + fma.rn.f32 %r1382, %r1381, %r1375, 0f3E4CAF9E; + fma.rn.f32 %r1383, %r1382, %r1375, 0fBE800042; + fma.rn.f32 %r1384, %r1383, %r1375, 0f3EAAAAE6; + fma.rn.f32 %r1385, %r1384, %r1375, 0fBF000000; + mul.f32 %r1386, %r1375, %r1385; + fma.rn.f32 %r1387, %r1386, %r1375, %r1375; + fma.rn.f32 %r1657, %r1377, 0f3F317218, %r1387; + setp.lt.u32 %p92, %r86, 2139095040; + @%p92 bra $L__BB7_98; + setp.gt.s32 %p93, %r86, -1082130432; + fma.rn.f32 %r1388, %r86, 0f7F800000, 0f7F800000; + selp.f32 %r1389, %r1388, %r1657, %p93; + setp.eq.f32 %p94, %r86, 0f00000000; + selp.f32 %r1657, 0f80000000, %r1389, %p94; +$L__BB7_98: + ld.param.b64 %rd220, [leleka_gdn_ab_unrolled_t8_param_5]; + ld.global.nc.b32 %r1390, [%rd4]; + mul.f32 %r1658, %r1390, %r1657; +$L__BB7_99: + cvta.to.global.u64 %rd186, %rd220; + add.s64 %rd187, %rd186, %rd184; + st.global.b32 [%rd187], %r1658; +$L__BB7_100: + setp.eq.b32 %p95, %r3, 0; + @%p95 bra $L__BB7_163; + setp.ne.b32 %p96, %r2, 0; + shfl.sync.bfly.b32 %r1391|%p97, %r1655, 16, 31, -1; + add.f32 %r1392, %r1655, %r1391; + shfl.sync.bfly.b32 %r1393|%p98, %r1392, 8, 31, -1; + add.f32 %r1394, %r1392, %r1393; + shfl.sync.bfly.b32 %r1395|%p99, %r1394, 4, 31, -1; + add.f32 %r1396, %r1394, %r1395; + shfl.sync.bfly.b32 %r1397|%p100, %r1396, 2, 31, -1; + add.f32 %r1398, %r1396, %r1397; + shfl.sync.bfly.b32 %r1399|%p101, %r1398, 1, 31, -1; + add.f32 %r87, %r1398, %r1399; + @%p96 bra $L__BB7_109; + setp.lt.s32 %p102, %r1, %r102; + @%p102 bra $L__BB7_104; + ld.param.b64 %rd221, [leleka_gdn_ab_unrolled_t8_param_6]; + mul.f32 %r1400, %r87, 0fBFB8AA3B; + ex2.approx.f32 %r1401, %r1400; + add.f32 %r1402, %r1401, 0f3F800000; + rcp.rn.f32 %r1660, %r1402; + bra.uni $L__BB7_108; +$L__BB7_104: + ld.global.nc.b32 %r1403, [%rd3]; + add.f32 %r1659, %r87, %r1403; + setp.gt.f32 %p103, %r1659, 0f41A00000; + @%p103 bra $L__BB7_107; + mul.f32 %r1404, %r1659, 0f3FB8AA3B; + ex2.approx.f32 %r88, %r1404; + mov.b32 %r1405, 0f3F800000; + add.rz.f32 %r1406, %r88, %r1405; + add.s32 %r1407, %r1406, -1061158912; + and.b32 %r1408, %r1407, -8388608; + sub.s32 %r1409, %r88, %r1408; + sub.s32 %r1410, 1082130432, %r1408; + fma.rn.f32 %r1411, %r1410, 0f3E800000, 0fBF800000; + add.f32 %r1412, %r1411, %r1409; + cvt.rn.f32.s32 %r1413, %r1408; + mul.f32 %r1414, %r1413, 0f34000000; + fma.rn.f32 %r1415, %r1412, 0fBD39BF78, 0f3DD80012; + fma.rn.f32 %r1416, %r1415, %r1412, 0fBE0778E0; + fma.rn.f32 %r1417, %r1416, %r1412, 0f3E146475; + fma.rn.f32 %r1418, %r1417, %r1412, 0fBE2A68DD; + fma.rn.f32 %r1419, %r1418, %r1412, 0f3E4CAF9E; + fma.rn.f32 %r1420, %r1419, %r1412, 0fBE800042; + fma.rn.f32 %r1421, %r1420, %r1412, 0f3EAAAAE6; + fma.rn.f32 %r1422, %r1421, %r1412, 0fBF000000; + mul.f32 %r1423, %r1412, %r1422; + fma.rn.f32 %r1424, %r1423, %r1412, %r1412; + fma.rn.f32 %r1659, %r1414, 0f3F317218, %r1424; + setp.lt.u32 %p104, %r88, 2139095040; + @%p104 bra $L__BB7_107; + setp.gt.s32 %p105, %r88, -1082130432; + fma.rn.f32 %r1425, %r88, 0f7F800000, 0f7F800000; + selp.f32 %r1426, %r1425, %r1659, %p105; + setp.eq.f32 %p106, %r88, 0f00000000; + selp.f32 %r1659, 0f80000000, %r1426, %p106; +$L__BB7_107: + ld.param.b64 %rd221, [leleka_gdn_ab_unrolled_t8_param_5]; + ld.global.nc.b32 %r1427, [%rd4]; + mul.f32 %r1660, %r1427, %r1659; +$L__BB7_108: + cvta.to.global.u64 %rd188, %rd221; + add.s64 %rd189, %rd5, %rd1; + shl.b64 %rd190, %rd189, 2; + add.s64 %rd191, %rd188, %rd190; + st.global.b32 [%rd191], %r1660; +$L__BB7_109: + setp.eq.b32 %p107, %r4, 2; + @%p107 bra $L__BB7_163; + setp.ne.b32 %p108, %r2, 0; + shfl.sync.bfly.b32 %r1428|%p109, %r1654, 16, 31, -1; + add.f32 %r1429, %r1654, %r1428; + shfl.sync.bfly.b32 %r1430|%p110, %r1429, 8, 31, -1; + add.f32 %r1431, %r1429, %r1430; + shfl.sync.bfly.b32 %r1432|%p111, %r1431, 4, 31, -1; + add.f32 %r1433, %r1431, %r1432; + shfl.sync.bfly.b32 %r1434|%p112, %r1433, 2, 31, -1; + add.f32 %r1435, %r1433, %r1434; + shfl.sync.bfly.b32 %r1436|%p113, %r1435, 1, 31, -1; + add.f32 %r89, %r1435, %r1436; + @%p108 bra $L__BB7_118; + setp.lt.s32 %p114, %r1, %r102; + @%p114 bra $L__BB7_113; + ld.param.b64 %rd222, [leleka_gdn_ab_unrolled_t8_param_6]; + mul.f32 %r1437, %r89, 0fBFB8AA3B; + ex2.approx.f32 %r1438, %r1437; + add.f32 %r1439, %r1438, 0f3F800000; + rcp.rn.f32 %r1662, %r1439; + bra.uni $L__BB7_117; +$L__BB7_113: + ld.global.nc.b32 %r1440, [%rd3]; + add.f32 %r1661, %r89, %r1440; + setp.gt.f32 %p115, %r1661, 0f41A00000; + @%p115 bra $L__BB7_116; + mul.f32 %r1441, %r1661, 0f3FB8AA3B; + ex2.approx.f32 %r90, %r1441; + mov.b32 %r1442, 0f3F800000; + add.rz.f32 %r1443, %r90, %r1442; + add.s32 %r1444, %r1443, -1061158912; + and.b32 %r1445, %r1444, -8388608; + sub.s32 %r1446, %r90, %r1445; + sub.s32 %r1447, 1082130432, %r1445; + fma.rn.f32 %r1448, %r1447, 0f3E800000, 0fBF800000; + add.f32 %r1449, %r1448, %r1446; + cvt.rn.f32.s32 %r1450, %r1445; + mul.f32 %r1451, %r1450, 0f34000000; + fma.rn.f32 %r1452, %r1449, 0fBD39BF78, 0f3DD80012; + fma.rn.f32 %r1453, %r1452, %r1449, 0fBE0778E0; + fma.rn.f32 %r1454, %r1453, %r1449, 0f3E146475; + fma.rn.f32 %r1455, %r1454, %r1449, 0fBE2A68DD; + fma.rn.f32 %r1456, %r1455, %r1449, 0f3E4CAF9E; + fma.rn.f32 %r1457, %r1456, %r1449, 0fBE800042; + fma.rn.f32 %r1458, %r1457, %r1449, 0f3EAAAAE6; + fma.rn.f32 %r1459, %r1458, %r1449, 0fBF000000; + mul.f32 %r1460, %r1449, %r1459; + fma.rn.f32 %r1461, %r1460, %r1449, %r1449; + fma.rn.f32 %r1661, %r1451, 0f3F317218, %r1461; + setp.lt.u32 %p116, %r90, 2139095040; + @%p116 bra $L__BB7_116; + setp.gt.s32 %p117, %r90, -1082130432; + fma.rn.f32 %r1462, %r90, 0f7F800000, 0f7F800000; + selp.f32 %r1463, %r1462, %r1661, %p117; + setp.eq.f32 %p118, %r90, 0f00000000; + selp.f32 %r1661, 0f80000000, %r1463, %p118; +$L__BB7_116: + ld.param.b64 %rd222, [leleka_gdn_ab_unrolled_t8_param_5]; + ld.global.nc.b32 %r1464, [%rd4]; + mul.f32 %r1662, %r1464, %r1661; +$L__BB7_117: + cvta.to.global.u64 %rd192, %rd222; + shl.b64 %rd193, %rd5, 1; + add.s64 %rd194, %rd193, %rd1; + shl.b64 %rd195, %rd194, 2; + add.s64 %rd196, %rd192, %rd195; + st.global.b32 [%rd196], %r1662; +$L__BB7_118: + setp.eq.b32 %p119, %r4, 3; + @%p119 bra $L__BB7_163; + setp.ne.b32 %p120, %r2, 0; + shfl.sync.bfly.b32 %r1465|%p121, %r1653, 16, 31, -1; + add.f32 %r1466, %r1653, %r1465; + shfl.sync.bfly.b32 %r1467|%p122, %r1466, 8, 31, -1; + add.f32 %r1468, %r1466, %r1467; + shfl.sync.bfly.b32 %r1469|%p123, %r1468, 4, 31, -1; + add.f32 %r1470, %r1468, %r1469; + shfl.sync.bfly.b32 %r1471|%p124, %r1470, 2, 31, -1; + add.f32 %r1472, %r1470, %r1471; + shfl.sync.bfly.b32 %r1473|%p125, %r1472, 1, 31, -1; + add.f32 %r91, %r1472, %r1473; + @%p120 bra $L__BB7_127; + setp.lt.s32 %p126, %r1, %r102; + @%p126 bra $L__BB7_122; + ld.param.b64 %rd223, [leleka_gdn_ab_unrolled_t8_param_6]; + mul.f32 %r1474, %r91, 0fBFB8AA3B; + ex2.approx.f32 %r1475, %r1474; + add.f32 %r1476, %r1475, 0f3F800000; + rcp.rn.f32 %r1664, %r1476; + bra.uni $L__BB7_126; +$L__BB7_122: + ld.global.nc.b32 %r1477, [%rd3]; + add.f32 %r1663, %r91, %r1477; + setp.gt.f32 %p127, %r1663, 0f41A00000; + @%p127 bra $L__BB7_125; + mul.f32 %r1478, %r1663, 0f3FB8AA3B; + ex2.approx.f32 %r92, %r1478; + mov.b32 %r1479, 0f3F800000; + add.rz.f32 %r1480, %r92, %r1479; + add.s32 %r1481, %r1480, -1061158912; + and.b32 %r1482, %r1481, -8388608; + sub.s32 %r1483, %r92, %r1482; + sub.s32 %r1484, 1082130432, %r1482; + fma.rn.f32 %r1485, %r1484, 0f3E800000, 0fBF800000; + add.f32 %r1486, %r1485, %r1483; + cvt.rn.f32.s32 %r1487, %r1482; + mul.f32 %r1488, %r1487, 0f34000000; + fma.rn.f32 %r1489, %r1486, 0fBD39BF78, 0f3DD80012; + fma.rn.f32 %r1490, %r1489, %r1486, 0fBE0778E0; + fma.rn.f32 %r1491, %r1490, %r1486, 0f3E146475; + fma.rn.f32 %r1492, %r1491, %r1486, 0fBE2A68DD; + fma.rn.f32 %r1493, %r1492, %r1486, 0f3E4CAF9E; + fma.rn.f32 %r1494, %r1493, %r1486, 0fBE800042; + fma.rn.f32 %r1495, %r1494, %r1486, 0f3EAAAAE6; + fma.rn.f32 %r1496, %r1495, %r1486, 0fBF000000; + mul.f32 %r1497, %r1486, %r1496; + fma.rn.f32 %r1498, %r1497, %r1486, %r1486; + fma.rn.f32 %r1663, %r1488, 0f3F317218, %r1498; + setp.lt.u32 %p128, %r92, 2139095040; + @%p128 bra $L__BB7_125; + setp.gt.s32 %p129, %r92, -1082130432; + fma.rn.f32 %r1499, %r92, 0f7F800000, 0f7F800000; + selp.f32 %r1500, %r1499, %r1663, %p129; + setp.eq.f32 %p130, %r92, 0f00000000; + selp.f32 %r1663, 0f80000000, %r1500, %p130; +$L__BB7_125: + ld.param.b64 %rd223, [leleka_gdn_ab_unrolled_t8_param_5]; + ld.global.nc.b32 %r1501, [%rd4]; + mul.f32 %r1664, %r1501, %r1663; +$L__BB7_126: + cvta.to.global.u64 %rd197, %rd223; + mad.lo.s64 %rd198, %rd5, 3, %rd1; + shl.b64 %rd199, %rd198, 2; + add.s64 %rd200, %rd197, %rd199; + st.global.b32 [%rd200], %r1664; +$L__BB7_127: + setp.eq.b32 %p131, %r4, 4; + @%p131 bra $L__BB7_163; + setp.ne.b32 %p132, %r2, 0; + shfl.sync.bfly.b32 %r1502|%p133, %r1652, 16, 31, -1; + add.f32 %r1503, %r1652, %r1502; + shfl.sync.bfly.b32 %r1504|%p134, %r1503, 8, 31, -1; + add.f32 %r1505, %r1503, %r1504; + shfl.sync.bfly.b32 %r1506|%p135, %r1505, 4, 31, -1; + add.f32 %r1507, %r1505, %r1506; + shfl.sync.bfly.b32 %r1508|%p136, %r1507, 2, 31, -1; + add.f32 %r1509, %r1507, %r1508; + shfl.sync.bfly.b32 %r1510|%p137, %r1509, 1, 31, -1; + add.f32 %r93, %r1509, %r1510; + @%p132 bra $L__BB7_136; + setp.lt.s32 %p138, %r1, %r102; + @%p138 bra $L__BB7_131; + ld.param.b64 %rd224, [leleka_gdn_ab_unrolled_t8_param_6]; + mul.f32 %r1511, %r93, 0fBFB8AA3B; + ex2.approx.f32 %r1512, %r1511; + add.f32 %r1513, %r1512, 0f3F800000; + rcp.rn.f32 %r1666, %r1513; + bra.uni $L__BB7_135; +$L__BB7_131: + ld.global.nc.b32 %r1514, [%rd3]; + add.f32 %r1665, %r93, %r1514; + setp.gt.f32 %p139, %r1665, 0f41A00000; + @%p139 bra $L__BB7_134; + mul.f32 %r1515, %r1665, 0f3FB8AA3B; + ex2.approx.f32 %r94, %r1515; + mov.b32 %r1516, 0f3F800000; + add.rz.f32 %r1517, %r94, %r1516; + add.s32 %r1518, %r1517, -1061158912; + and.b32 %r1519, %r1518, -8388608; + sub.s32 %r1520, %r94, %r1519; + sub.s32 %r1521, 1082130432, %r1519; + fma.rn.f32 %r1522, %r1521, 0f3E800000, 0fBF800000; + add.f32 %r1523, %r1522, %r1520; + cvt.rn.f32.s32 %r1524, %r1519; + mul.f32 %r1525, %r1524, 0f34000000; + fma.rn.f32 %r1526, %r1523, 0fBD39BF78, 0f3DD80012; + fma.rn.f32 %r1527, %r1526, %r1523, 0fBE0778E0; + fma.rn.f32 %r1528, %r1527, %r1523, 0f3E146475; + fma.rn.f32 %r1529, %r1528, %r1523, 0fBE2A68DD; + fma.rn.f32 %r1530, %r1529, %r1523, 0f3E4CAF9E; + fma.rn.f32 %r1531, %r1530, %r1523, 0fBE800042; + fma.rn.f32 %r1532, %r1531, %r1523, 0f3EAAAAE6; + fma.rn.f32 %r1533, %r1532, %r1523, 0fBF000000; + mul.f32 %r1534, %r1523, %r1533; + fma.rn.f32 %r1535, %r1534, %r1523, %r1523; + fma.rn.f32 %r1665, %r1525, 0f3F317218, %r1535; + setp.lt.u32 %p140, %r94, 2139095040; + @%p140 bra $L__BB7_134; + setp.gt.s32 %p141, %r94, -1082130432; + fma.rn.f32 %r1536, %r94, 0f7F800000, 0f7F800000; + selp.f32 %r1537, %r1536, %r1665, %p141; + setp.eq.f32 %p142, %r94, 0f00000000; + selp.f32 %r1665, 0f80000000, %r1537, %p142; +$L__BB7_134: + ld.param.b64 %rd224, [leleka_gdn_ab_unrolled_t8_param_5]; + ld.global.nc.b32 %r1538, [%rd4]; + mul.f32 %r1666, %r1538, %r1665; +$L__BB7_135: + cvta.to.global.u64 %rd201, %rd224; + shl.b64 %rd202, %rd5, 2; + add.s64 %rd203, %rd202, %rd1; + shl.b64 %rd204, %rd203, 2; + add.s64 %rd205, %rd201, %rd204; + st.global.b32 [%rd205], %r1666; +$L__BB7_136: + setp.eq.b32 %p143, %r4, 5; + @%p143 bra $L__BB7_163; + setp.ne.b32 %p144, %r2, 0; + shfl.sync.bfly.b32 %r1539|%p145, %r1651, 16, 31, -1; + add.f32 %r1540, %r1651, %r1539; + shfl.sync.bfly.b32 %r1541|%p146, %r1540, 8, 31, -1; + add.f32 %r1542, %r1540, %r1541; + shfl.sync.bfly.b32 %r1543|%p147, %r1542, 4, 31, -1; + add.f32 %r1544, %r1542, %r1543; + shfl.sync.bfly.b32 %r1545|%p148, %r1544, 2, 31, -1; + add.f32 %r1546, %r1544, %r1545; + shfl.sync.bfly.b32 %r1547|%p149, %r1546, 1, 31, -1; + add.f32 %r95, %r1546, %r1547; + @%p144 bra $L__BB7_145; + setp.lt.s32 %p150, %r1, %r102; + @%p150 bra $L__BB7_140; + ld.param.b64 %rd225, [leleka_gdn_ab_unrolled_t8_param_6]; + mul.f32 %r1548, %r95, 0fBFB8AA3B; + ex2.approx.f32 %r1549, %r1548; + add.f32 %r1550, %r1549, 0f3F800000; + rcp.rn.f32 %r1668, %r1550; + bra.uni $L__BB7_144; +$L__BB7_140: + ld.global.nc.b32 %r1551, [%rd3]; + add.f32 %r1667, %r95, %r1551; + setp.gt.f32 %p151, %r1667, 0f41A00000; + @%p151 bra $L__BB7_143; + mul.f32 %r1552, %r1667, 0f3FB8AA3B; + ex2.approx.f32 %r96, %r1552; + mov.b32 %r1553, 0f3F800000; + add.rz.f32 %r1554, %r96, %r1553; + add.s32 %r1555, %r1554, -1061158912; + and.b32 %r1556, %r1555, -8388608; + sub.s32 %r1557, %r96, %r1556; + sub.s32 %r1558, 1082130432, %r1556; + fma.rn.f32 %r1559, %r1558, 0f3E800000, 0fBF800000; + add.f32 %r1560, %r1559, %r1557; + cvt.rn.f32.s32 %r1561, %r1556; + mul.f32 %r1562, %r1561, 0f34000000; + fma.rn.f32 %r1563, %r1560, 0fBD39BF78, 0f3DD80012; + fma.rn.f32 %r1564, %r1563, %r1560, 0fBE0778E0; + fma.rn.f32 %r1565, %r1564, %r1560, 0f3E146475; + fma.rn.f32 %r1566, %r1565, %r1560, 0fBE2A68DD; + fma.rn.f32 %r1567, %r1566, %r1560, 0f3E4CAF9E; + fma.rn.f32 %r1568, %r1567, %r1560, 0fBE800042; + fma.rn.f32 %r1569, %r1568, %r1560, 0f3EAAAAE6; + fma.rn.f32 %r1570, %r1569, %r1560, 0fBF000000; + mul.f32 %r1571, %r1560, %r1570; + fma.rn.f32 %r1572, %r1571, %r1560, %r1560; + fma.rn.f32 %r1667, %r1562, 0f3F317218, %r1572; + setp.lt.u32 %p152, %r96, 2139095040; + @%p152 bra $L__BB7_143; + setp.gt.s32 %p153, %r96, -1082130432; + fma.rn.f32 %r1573, %r96, 0f7F800000, 0f7F800000; + selp.f32 %r1574, %r1573, %r1667, %p153; + setp.eq.f32 %p154, %r96, 0f00000000; + selp.f32 %r1667, 0f80000000, %r1574, %p154; +$L__BB7_143: + ld.param.b64 %rd225, [leleka_gdn_ab_unrolled_t8_param_5]; + ld.global.nc.b32 %r1575, [%rd4]; + mul.f32 %r1668, %r1575, %r1667; +$L__BB7_144: + cvta.to.global.u64 %rd206, %rd225; + mad.lo.s64 %rd207, %rd5, 5, %rd1; + shl.b64 %rd208, %rd207, 2; + add.s64 %rd209, %rd206, %rd208; + st.global.b32 [%rd209], %r1668; +$L__BB7_145: + setp.eq.b32 %p155, %r4, 6; + @%p155 bra $L__BB7_163; + setp.ne.b32 %p156, %r2, 0; + shfl.sync.bfly.b32 %r1576|%p157, %r1650, 16, 31, -1; + add.f32 %r1577, %r1650, %r1576; + shfl.sync.bfly.b32 %r1578|%p158, %r1577, 8, 31, -1; + add.f32 %r1579, %r1577, %r1578; + shfl.sync.bfly.b32 %r1580|%p159, %r1579, 4, 31, -1; + add.f32 %r1581, %r1579, %r1580; + shfl.sync.bfly.b32 %r1582|%p160, %r1581, 2, 31, -1; + add.f32 %r1583, %r1581, %r1582; + shfl.sync.bfly.b32 %r1584|%p161, %r1583, 1, 31, -1; + add.f32 %r97, %r1583, %r1584; + @%p156 bra $L__BB7_154; + setp.lt.s32 %p162, %r1, %r102; + @%p162 bra $L__BB7_149; + ld.param.b64 %rd226, [leleka_gdn_ab_unrolled_t8_param_6]; + mul.f32 %r1585, %r97, 0fBFB8AA3B; + ex2.approx.f32 %r1586, %r1585; + add.f32 %r1587, %r1586, 0f3F800000; + rcp.rn.f32 %r1670, %r1587; + bra.uni $L__BB7_153; +$L__BB7_149: + ld.global.nc.b32 %r1588, [%rd3]; + add.f32 %r1669, %r97, %r1588; + setp.gt.f32 %p163, %r1669, 0f41A00000; + @%p163 bra $L__BB7_152; + mul.f32 %r1589, %r1669, 0f3FB8AA3B; + ex2.approx.f32 %r98, %r1589; + mov.b32 %r1590, 0f3F800000; + add.rz.f32 %r1591, %r98, %r1590; + add.s32 %r1592, %r1591, -1061158912; + and.b32 %r1593, %r1592, -8388608; + sub.s32 %r1594, %r98, %r1593; + sub.s32 %r1595, 1082130432, %r1593; + fma.rn.f32 %r1596, %r1595, 0f3E800000, 0fBF800000; + add.f32 %r1597, %r1596, %r1594; + cvt.rn.f32.s32 %r1598, %r1593; + mul.f32 %r1599, %r1598, 0f34000000; + fma.rn.f32 %r1600, %r1597, 0fBD39BF78, 0f3DD80012; + fma.rn.f32 %r1601, %r1600, %r1597, 0fBE0778E0; + fma.rn.f32 %r1602, %r1601, %r1597, 0f3E146475; + fma.rn.f32 %r1603, %r1602, %r1597, 0fBE2A68DD; + fma.rn.f32 %r1604, %r1603, %r1597, 0f3E4CAF9E; + fma.rn.f32 %r1605, %r1604, %r1597, 0fBE800042; + fma.rn.f32 %r1606, %r1605, %r1597, 0f3EAAAAE6; + fma.rn.f32 %r1607, %r1606, %r1597, 0fBF000000; + mul.f32 %r1608, %r1597, %r1607; + fma.rn.f32 %r1609, %r1608, %r1597, %r1597; + fma.rn.f32 %r1669, %r1599, 0f3F317218, %r1609; + setp.lt.u32 %p164, %r98, 2139095040; + @%p164 bra $L__BB7_152; + setp.gt.s32 %p165, %r98, -1082130432; + fma.rn.f32 %r1610, %r98, 0f7F800000, 0f7F800000; + selp.f32 %r1611, %r1610, %r1669, %p165; + setp.eq.f32 %p166, %r98, 0f00000000; + selp.f32 %r1669, 0f80000000, %r1611, %p166; +$L__BB7_152: + ld.param.b64 %rd226, [leleka_gdn_ab_unrolled_t8_param_5]; + ld.global.nc.b32 %r1612, [%rd4]; + mul.f32 %r1670, %r1612, %r1669; +$L__BB7_153: + cvta.to.global.u64 %rd210, %rd226; + mad.lo.s64 %rd211, %rd5, 6, %rd1; + shl.b64 %rd212, %rd211, 2; + add.s64 %rd213, %rd210, %rd212; + st.global.b32 [%rd213], %r1670; +$L__BB7_154: + setp.eq.b32 %p167, %r4, 7; + @%p167 bra $L__BB7_163; + setp.ne.b32 %p168, %r2, 0; + shfl.sync.bfly.b32 %r1613|%p169, %r1649, 16, 31, -1; + add.f32 %r1614, %r1649, %r1613; + shfl.sync.bfly.b32 %r1615|%p170, %r1614, 8, 31, -1; + add.f32 %r1616, %r1614, %r1615; + shfl.sync.bfly.b32 %r1617|%p171, %r1616, 4, 31, -1; + add.f32 %r1618, %r1616, %r1617; + shfl.sync.bfly.b32 %r1619|%p172, %r1618, 2, 31, -1; + add.f32 %r1620, %r1618, %r1619; + shfl.sync.bfly.b32 %r1621|%p173, %r1620, 1, 31, -1; + add.f32 %r99, %r1620, %r1621; + @%p168 bra $L__BB7_163; + setp.lt.s32 %p174, %r1, %r102; + ld.global.nc.b32 %r100, [%rd4]; + @%p174 bra $L__BB7_158; + ld.param.b64 %rd227, [leleka_gdn_ab_unrolled_t8_param_6]; + mul.f32 %r1622, %r99, 0fBFB8AA3B; + ex2.approx.f32 %r1623, %r1622; + add.f32 %r1624, %r1623, 0f3F800000; + rcp.rn.f32 %r1672, %r1624; + bra.uni $L__BB7_162; +$L__BB7_158: + ld.global.nc.b32 %r1625, [%rd3]; + add.f32 %r1671, %r99, %r1625; + setp.gt.f32 %p175, %r1671, 0f41A00000; + @%p175 bra $L__BB7_161; + mul.f32 %r1626, %r1671, 0f3FB8AA3B; + ex2.approx.f32 %r101, %r1626; + mov.b32 %r1627, 0f3F800000; + add.rz.f32 %r1628, %r101, %r1627; + add.s32 %r1629, %r1628, -1061158912; + and.b32 %r1630, %r1629, -8388608; + sub.s32 %r1631, %r101, %r1630; + sub.s32 %r1632, 1082130432, %r1630; + fma.rn.f32 %r1633, %r1632, 0f3E800000, 0fBF800000; + add.f32 %r1634, %r1633, %r1631; + cvt.rn.f32.s32 %r1635, %r1630; + mul.f32 %r1636, %r1635, 0f34000000; + fma.rn.f32 %r1637, %r1634, 0fBD39BF78, 0f3DD80012; + fma.rn.f32 %r1638, %r1637, %r1634, 0fBE0778E0; + fma.rn.f32 %r1639, %r1638, %r1634, 0f3E146475; + fma.rn.f32 %r1640, %r1639, %r1634, 0fBE2A68DD; + fma.rn.f32 %r1641, %r1640, %r1634, 0f3E4CAF9E; + fma.rn.f32 %r1642, %r1641, %r1634, 0fBE800042; + fma.rn.f32 %r1643, %r1642, %r1634, 0f3EAAAAE6; + fma.rn.f32 %r1644, %r1643, %r1634, 0fBF000000; + mul.f32 %r1645, %r1634, %r1644; + fma.rn.f32 %r1646, %r1645, %r1634, %r1634; + fma.rn.f32 %r1671, %r1636, 0f3F317218, %r1646; + setp.lt.u32 %p176, %r101, 2139095040; + @%p176 bra $L__BB7_161; + setp.gt.s32 %p177, %r101, -1082130432; + fma.rn.f32 %r1647, %r101, 0f7F800000, 0f7F800000; + selp.f32 %r1648, %r1647, %r1671, %p177; + setp.eq.f32 %p178, %r101, 0f00000000; + selp.f32 %r1671, 0f80000000, %r1648, %p178; +$L__BB7_161: + ld.param.b64 %rd227, [leleka_gdn_ab_unrolled_t8_param_5]; + mul.f32 %r1672, %r100, %r1671; +$L__BB7_162: + cvta.to.global.u64 %rd214, %rd227; + mad.lo.s64 %rd215, %rd5, 7, %rd1; + shl.b64 %rd216, %rd215, 2; + add.s64 %rd217, %rd214, %rd216; + st.global.b32 [%rd217], %r1672; +$L__BB7_163: + ret; + +} diff --git a/crates/cuda-driver/tests/original_serve_preflight_probe/synthetic_verifier.rs b/crates/cuda-driver/tests/original_serve_preflight_probe/synthetic_verifier.rs index 4dbac323..875df6ee 100644 --- a/crates/cuda-driver/tests/original_serve_preflight_probe/synthetic_verifier.rs +++ b/crates/cuda-driver/tests/original_serve_preflight_probe/synthetic_verifier.rs @@ -16,14 +16,14 @@ mod window; /// The drafter of the serve stack: the draft ring and its actor. type Mtp<'ctx> = (MtpOriginalInt8<'ctx>, OriginalMtpActor<'ctx>); /// A verifier over the window resources of one request. -type Verifier<'w, 'ctx> = OriginalVerifier<'ctx, OriginalVerifyWindowResources<'w, 'ctx>>; +type Verifier<'w, 'ctx> = OriginalVerifier<'ctx, OriginalVerifyWindowResources<'ctx>>; /// The QSA index checkpoint and the mapped prefix a request ends with. type Kept<'ctx> = (Option>, Option); /// The twelve resident QSA indices and the twelve mapped journals. type Owners<'ctx> = ([OriginalQsaResidentIndex<'ctx>; 12], [OriginalQsaMappedJournal<'ctx>; 12]); -fn rope<'a, 'ctx>() -> OriginalVerifyRope<'a, 'ctx> { +fn rope<'ctx>() -> OriginalVerifyRope<'ctx> { OriginalVerifyRope { theta_scale: 1e7f32.powf(-2.0 / 64.0), freq_scale: 1.0, @@ -50,8 +50,8 @@ pub(super) struct Drafting<'a, 'ctx> { pub(super) reset_snapshot: &'a mut Option, } /// What a request leaves for `take_apart`: the QSA journal and the checkpoint and mapped prefix its replay ended with. -struct QsaRequestEnd<'w, 'ctx> { - journal: Rc>, +struct QsaRequestEnd<'ctx> { + journal: Rc>, kept: Kept<'ctx>, } /// The expert formats, geometry and layout, and the head and embedding rows. @@ -189,10 +189,10 @@ impl<'a, 'ctx> Rig<'a, 'ctx> { Some((indices.try_into().ok().expect("12"), mapped.try_into().ok().expect("12"))) } /// The twelve QSA owners as one journal over the mapped prefixes, with the workspace they were prepared on. - fn qsa_journal<'w>(&'w self) -> Option<(Rc>, NativeBatchWorkspace<'ctx>)> { + fn qsa_journal<'w>(&'w self) -> Option<(Rc>, NativeBatchWorkspace<'ctx>)> { let mut batch_ws = step!("native_batch_workspace", self.context.native_batch_workspace())?; let (indices, mapped) = self.qsa_owners(&mut batch_ws)?; - let gamma: [&DeviceBuffer<'ctx>; 12] = std::array::from_fn(|i| &self.w.gamma[i]); + let gamma: [DeviceRef<'ctx>; 12] = std::array::from_fn(|i| self.w.gamma[i].clone()); let journal = step!( "OriginalVerifyQsaJournal::new", OriginalVerifyQsaJournal::new(self.context, indices, mapped, gamma, rope()) @@ -217,7 +217,7 @@ impl<'a, 'ctx> Rig<'a, 'ctx> { let before_verifier = context.allocated_bytes(); let verifier = step!( "OriginalVerifier::new", - OriginalVerifier::>::new(context, self.parts.g) + OriginalVerifier::>::new(context, self.parts.g) )?; eprintln!( "PREFLIGHT verifier bank device={}MiB mapped_host={}MiB (context allocated {}MiB -> {}MiB)", @@ -252,7 +252,7 @@ impl<'a, 'ctx> Rig<'a, 'ctx> { fn record<'w>( &self, verifier: &mut Verifier<'w, 'ctx>, - mut windows: Vec>>, + mut windows: Vec>>, ) -> bool { let max_t = self.max_t; let commit = windows.pop().flatten().expect("commit aggregate"); @@ -275,7 +275,7 @@ impl<'a, 'ctx> Rig<'a, 'ctx> { request: usize, verifier: Verifier<'w, 'ctx>, mtp: &mut Option>, - qsa: QsaRequestEnd<'w, 'ctx>, + qsa: QsaRequestEnd<'ctx>, ) -> Option<()> { let QsaRequestEnd { journal: qsa_journal, kept: (last_checkpoint, last_prefix) } = qsa; if std::env::var_os("PROBE_NO_RELEASE").is_none() { 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 e68980cc..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 @@ -111,7 +111,7 @@ impl<'ctx> Replay<'ctx> { Some((window.selection, completed)) } /// The reads `OriginalServeHost::publish_committed` / `settle_state` make after a commit. - fn reads<'w>(&mut self, verifier: &mut Verifier<'w, 'ctx>, qsa_journal: &Rc>) { + fn reads<'w>(&mut self, verifier: &mut Verifier<'w, 'ctx>, qsa_journal: &Rc>) { let _ = step!("verifier.accepted_tokens", verifier.accepted_tokens().map(|a| a.len())); let publish_ws = &mut self.publish_ws; self.last_checkpoint = step!( @@ -176,7 +176,7 @@ impl<'a, 'ctx> Rig<'a, 'ctx> { request: usize, verifier: &mut Verifier<'w, 'ctx>, drafting: Drafting<'_, 'ctx>, - qsa_journal: &Rc>, + qsa_journal: &Rc>, ) -> Option> { let Drafting { mtp, reset_snapshot } = drafting; let mut replay = Replay::start(self.context)?; diff --git a/crates/cuda-driver/tests/original_serve_preflight_probe/synthetic_verifier/weights.rs b/crates/cuda-driver/tests/original_serve_preflight_probe/synthetic_verifier/weights.rs index 7272eaed..7d4eb5ab 100644 --- a/crates/cuda-driver/tests/original_serve_preflight_probe/synthetic_verifier/weights.rs +++ b/crates/cuda-driver/tests/original_serve_preflight_probe/synthetic_verifier/weights.rs @@ -2,57 +2,57 @@ use super::*; /// One allocation, reported as the other preflight steps are. -fn alloc<'ctx>(context: &'ctx Context<'ctx>, name: impl std::fmt::Display, bytes: usize) -> Option> { - step!(name, context.allocate(bytes)) +fn alloc<'ctx>(context: &'ctx Context<'ctx>, name: impl std::fmt::Display, bytes: usize) -> Option> { + step!(name, context.allocate(bytes).map(DeviceRef::from_buffer)) } fn size(kind: u32, n_in: usize, n_out: usize) -> Result { native_head_row_bytes(kind, n_in).map(|r| r * n_out) } /// The hyper-connection weights of one half layer. pub(super) struct Hc<'ctx> { - pub(super) norm: DeviceBuffer<'ctx>, - pub(super) down: DeviceBuffer<'ctx>, - pub(super) up: DeviceBuffer<'ctx>, - pub(super) inject: DeviceBuffer<'ctx>, + pub(super) norm: DeviceRef<'ctx>, + pub(super) down: DeviceRef<'ctx>, + pub(super) up: DeviceRef<'ctx>, + pub(super) inject: DeviceRef<'ctx>, } pub(super) struct Ple<'ctx> { - pub(super) key: DeviceBuffer<'ctx>, - pub(super) value: DeviceBuffer<'ctx>, - pub(super) norm_key: DeviceBuffer<'ctx>, - pub(super) norm_query: DeviceBuffer<'ctx>, - pub(super) norm_conv: DeviceBuffer<'ctx>, - pub(super) conv1d: DeviceBuffer<'ctx>, - pub(super) scratch: DeviceBuffer<'ctx>, - pub(super) history: DeviceBuffer<'ctx>, + pub(super) key: DeviceRef<'ctx>, + pub(super) value: DeviceRef<'ctx>, + pub(super) norm_key: DeviceRef<'ctx>, + pub(super) norm_query: DeviceRef<'ctx>, + pub(super) norm_conv: DeviceRef<'ctx>, + pub(super) conv1d: DeviceRef<'ctx>, + pub(super) scratch: DeviceRef<'ctx>, + pub(super) history: DeviceRef<'ctx>, } /// The router and the shared experts. pub(super) struct Moe<'ctx> { - pub(super) router: DeviceBuffer<'ctx>, - pub(super) gate_inp: DeviceBuffer<'ctx>, - pub(super) gate: DeviceBuffer<'ctx>, - pub(super) up: DeviceBuffer<'ctx>, - pub(super) down: DeviceBuffer<'ctx>, + pub(super) router: DeviceRef<'ctx>, + pub(super) gate_inp: DeviceRef<'ctx>, + pub(super) gate: DeviceRef<'ctx>, + pub(super) up: DeviceRef<'ctx>, + pub(super) down: DeviceRef<'ctx>, } /// The GDN weights that are not matrices. pub(super) struct Gdn<'ctx> { - pub(super) conv: DeviceBuffer<'ctx>, - pub(super) alpha: DeviceBuffer<'ctx>, - pub(super) beta: DeviceBuffer<'ctx>, - pub(super) dt: DeviceBuffer<'ctx>, - pub(super) a: DeviceBuffer<'ctx>, - pub(super) norm: DeviceBuffer<'ctx>, + pub(super) conv: DeviceRef<'ctx>, + pub(super) alpha: DeviceRef<'ctx>, + pub(super) beta: DeviceRef<'ctx>, + pub(super) dt: DeviceRef<'ctx>, + pub(super) a: DeviceRef<'ctx>, + pub(super) norm: DeviceRef<'ctx>, } pub(super) struct Weights<'ctx> { - pub(super) proj: Vec>, + pub(super) proj: Vec>, pub(super) hc: Hc<'ctx>, pub(super) ple: Ple<'ctx>, /// QSA norms and indexer projections: pairwise disjoint per layer. - pub(super) qsa: Vec>>, - pub(super) gamma: Vec>, + pub(super) qsa: Vec>>, + pub(super) gamma: Vec>, pub(super) moe: Moe<'ctx>, pub(super) gdn: Gdn<'ctx>, } -fn projections<'ctx>(context: &'ctx Context<'ctx>, proj: &[u32]) -> Option>> { +fn projections<'ctx>(context: &'ctx Context<'ctx>, proj: &[u32]) -> Option>> { let mats: Vec<(usize, usize)> = vec![(2560, 10240), (2560, 6144), (6144, 2560), (2560, 512), (2560, 512), (2560, 12288), (6144, 2560)]; let mut proj_bufs = Vec::new(); @@ -82,7 +82,7 @@ fn ple<'ctx>(context: &'ctx Context<'ctx>) -> Option> { history: alloc(context, "alloc ple_history", 9 * 10240 * 4)?, }) } -fn qsa_norms<'ctx>(context: &'ctx Context<'ctx>) -> Option>>> { +fn qsa_norms<'ctx>(context: &'ctx Context<'ctx>) -> Option>>> { let mut qsa_bufs = Vec::new(); for layer in 0..12 { let mut five = Vec::new(); @@ -93,7 +93,7 @@ fn qsa_norms<'ctx>(context: &'ctx Context<'ctx>) -> Option(context: &'ctx Context<'ctx>) -> Option>> { +fn gammas<'ctx>(context: &'ctx Context<'ctx>) -> Option>> { let mut gamma_bufs = Vec::new(); for i in 0..12 { gamma_bufs.push(alloc(context, format!("alloc gamma[{i}]"), 512)?); diff --git a/crates/cuda-driver/tests/original_serve_preflight_probe/synthetic_verifier/window.rs b/crates/cuda-driver/tests/original_serve_preflight_probe/synthetic_verifier/window.rs index 838f92f4..9967e7e6 100644 --- a/crates/cuda-driver/tests/original_serve_preflight_probe/synthetic_verifier/window.rs +++ b/crates/cuda-driver/tests/original_serve_preflight_probe/synthetic_verifier/window.rs @@ -7,8 +7,8 @@ impl<'a, 'ctx> Rig<'a, 'ctx> { &'w self, verifier: &Verifier<'w, 'ctx>, canonical: &mut OriginalVerifyCanonicalGdn<'ctx>, - qsa_journal: &Rc>, - ) -> Option>>> { + qsa_journal: &Rc>, + ) -> Option>>> { let mut windows = Vec::new(); for t in 1..=self.max_t + 1 { let window_t = if t <= self.max_t { t } else { self.max_t }; @@ -20,15 +20,15 @@ impl<'a, 'ctx> Rig<'a, 'ctx> { } Some(windows) } - fn gdn_weights(&self) -> [OriginalVerifyGdnWeights<'_, 'ctx>; 36] { + fn gdn_weights(&self) -> [OriginalVerifyGdnWeights<'ctx>; 36] { let gdn = &self.w.gdn; std::array::from_fn(|_| OriginalVerifyGdnWeights { - conv: &gdn.conv, - alpha: &gdn.alpha, - beta: &gdn.beta, - dt: &gdn.dt, - a: &gdn.a, - norm: &gdn.norm, + conv: gdn.conv.clone(), + alpha: gdn.alpha.clone(), + beta: gdn.beta.clone(), + dt: gdn.dt.clone(), + a: gdn.a.clone(), + norm: gdn.norm.clone(), }) } /// The GDN journal, the head and embedding rows and the layout. @@ -37,14 +37,14 @@ impl<'a, 'ctx> Rig<'a, 'ctx> { window_t: usize, verifier: &Verifier<'w, 'ctx>, canonical: &mut OriginalVerifyCanonicalGdn<'ctx>, - qsa_journal: &Rc>, - ) -> Option> { + qsa_journal: &Rc>, + ) -> Option> { let context = self.context; let gdn_weights = self.gdn_weights(); let bank = step!("verifier.bank()", verifier.bank())?; let journal = step!( format!("gdn_journal(t={window_t})"), - bank.gdn_journal(canonical, gdn_weights, Some(&self.w.ple.history)) + bank.gdn_journal(canonical, gdn_weights, Some(self.w.ple.history.clone())) )?; let head_rows = step!(format!("head.rows({window_t})"), self.parts.head.rows(window_t))?; let resources = step!( @@ -57,95 +57,86 @@ impl<'a, 'ctx> Rig<'a, 'ctx> { OriginalVerifyWindowResources::new(context, resources, embed_rows, self.parts.layout.clone(), window_t) ) } - fn gdn_proj(&self) -> Vec> { + fn gdn_proj(&self) -> Vec> { let (proj, bufs) = (self.proj, &self.w.proj); (0..36) .map(|_| OriginalVerifyGdnProjections { - qkv: OriginalVerifyNativeMatrix { kind: proj[0], buffer: &bufs[0] }, - gate: OriginalVerifyNativeMatrix { kind: proj[1], buffer: &bufs[1] }, - out: OriginalVerifyNativeMatrix { kind: proj[2], buffer: &bufs[2] }, + qkv: OriginalVerifyNativeMatrix { kind: proj[0], buffer: bufs[0].clone() }, + gate: OriginalVerifyNativeMatrix { kind: proj[1], buffer: bufs[1].clone() }, + out: OriginalVerifyNativeMatrix { kind: proj[2], buffer: bufs[2].clone() }, }) .collect::>() } - fn qsa_proj(&self) -> Vec> { + fn qsa_proj(&self) -> Vec> { let (proj, bufs) = (self.proj, &self.w.proj); (0..12) .map(|_| OriginalVerifyQsaProjections { - k: OriginalVerifyNativeMatrix { kind: proj[3], buffer: &bufs[3] }, - v: OriginalVerifyNativeMatrix { kind: proj[4], buffer: &bufs[4] }, - q: OriginalVerifyNativeMatrix { kind: proj[5], buffer: &bufs[5] }, - out: OriginalVerifyNativeMatrix { kind: proj[6], buffer: &bufs[6] }, + k: OriginalVerifyNativeMatrix { kind: proj[3], buffer: bufs[3].clone() }, + v: OriginalVerifyNativeMatrix { kind: proj[4], buffer: bufs[4].clone() }, + q: OriginalVerifyNativeMatrix { kind: proj[5], buffer: bufs[5].clone() }, + out: OriginalVerifyNativeMatrix { kind: proj[6], buffer: bufs[6].clone() }, }) .collect::>() } fn with_projections<'w>( &'w self, - w: OriginalVerifyWindowResources<'w, 'ctx>, - ) -> Option> { + w: OriginalVerifyWindowResources<'ctx>, + ) -> Option> { step!( "with_projections", OriginalVerifyProjBinding::new(self.context, &self.parts.g, self.gdn_proj(), self.qsa_proj()) .and_then(|p| w.with_projections(p)) ) } - fn half(&self) -> HcHalfBuffers<'_, 'ctx> { + fn half(&self) -> HcHalfBuffers<'ctx> { let hc = &self.w.hc; - HcHalfBuffers { norm: &hc.norm, down: &hc.down, up: &hc.up, inject: &hc.inject } + HcHalfBuffers { norm: hc.norm.clone(), down: hc.down.clone(), up: hc.up.clone(), inject: hc.inject.clone() } } - fn with_gr<'w>( - &'w self, - w: OriginalVerifyWindowResources<'w, 'ctx>, - ) -> Option> { + fn with_gr<'w>(&'w self, w: OriginalVerifyWindowResources<'ctx>) -> Option> { let (hc, ple) = (&self.w.hc, &self.w.ple); let layers: Vec<_> = (0..48).map(|_| HcLayerBuffers { attention: self.half(), ffn: self.half() }).collect(); - let output = HcOutputBuffers { norm: &hc.norm, down: &hc.down, up: &hc.up }; + let output = HcOutputBuffers { norm: hc.norm.clone(), down: hc.down.clone(), up: hc.up.clone() }; let ple = PleBuffers { - key: PleKeyBuffer::Bf16(&ple.key), - value: &ple.value, - norm_key: &ple.norm_key, - norm_query: &ple.norm_query, - norm_conv: &ple.norm_conv, - conv1d: &ple.conv1d, - scratch: &ple.scratch, - history: &ple.history, + key: PleKeyBuffer::Bf16(ple.key.clone()), + value: ple.value.clone(), + norm_key: ple.norm_key.clone(), + norm_query: ple.norm_query.clone(), + norm_conv: ple.norm_conv.clone(), + conv1d: ple.conv1d.clone(), + scratch: ple.scratch.clone(), + history: ple.history.clone(), }; step!( "with_gr", OriginalVerifyGrBinding::new(self.context, layers, output, Some(ple)).and_then(|b| w.with_gr(b)) ) } - fn with_qsa<'w>( - &'w self, - w: OriginalVerifyWindowResources<'w, 'ctx>, - ) -> Option> { + fn with_qsa<'w>(&'w self, w: OriginalVerifyWindowResources<'ctx>) -> Option> { let qsa = &self.w.qsa; - let qsa_layers: [OriginalVerifyQsaLayerWeights<'_, 'ctx>; 12] = + let qsa_layers: [OriginalVerifyQsaLayerWeights<'ctx>; 12] = std::array::from_fn(|i| OriginalVerifyQsaLayerWeights { - attn_q_norm: &qsa[i][0], - attn_k_norm: &qsa[i][1], - index_q_norm: &qsa[i][2], - index_k_proj: &qsa[i][3], - index_q_proj: &qsa[i][4], + attn_q_norm: qsa[i][0].clone(), + attn_k_norm: qsa[i][1].clone(), + index_q_norm: qsa[i][2].clone(), + index_k_proj: qsa[i][3].clone(), + index_q_proj: qsa[i][4].clone(), }); step!( "with_qsa", OriginalVerifyQsaBinding::new(self.context, self.parts.g, qsa_layers).and_then(|b| w.with_qsa(b)) ) } - fn with_moe<'w>( - &'w self, - w: OriginalVerifyWindowResources<'w, 'ctx>, - ) -> Option> { + fn with_moe<'w>(&'w self, w: OriginalVerifyWindowResources<'ctx>) -> Option> { let (moe, shared) = (&self.w.moe, self.shared); let moe_layers: Vec<_> = (0..48) .map(|_| OriginalVerifyMoeLayerWeights { - router: &moe.router, - gate_inp_shexp: &moe.gate_inp, - gate_shexp: &moe.gate, + router: moe.router.clone(), + gate_inp_shexp: moe.gate_inp.clone(), + gate_shexp: moe.gate.clone(), gate_shexp_type: shared[0], - up_shexp: &moe.up, + up_shexp: moe.up.clone(), up_shexp_type: shared[1], - down_shexp: &moe.down, + down_shexp: moe.down.clone(), down_shexp_type: shared[2], }) .collect(); diff --git a/crates/deploy/src/profile/profile_limits.rs b/crates/deploy/src/profile/profile_limits.rs index 52a6c6dd..213785ac 100644 --- a/crates/deploy/src/profile/profile_limits.rs +++ b/crates/deploy/src/profile/profile_limits.rs @@ -111,8 +111,8 @@ 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_* or \ - LELEKA_PLE_* name (or LELEKA_CHAIN)" + "engine_env key {key} must be an upper-case LELEKA_ORIGINAL_SERVE_*, LELEKA_SM120_*, \ + LELEKA_DRAFT_* or LELEKA_PLE_* name (or LELEKA_CHAIN)" )); } if value.is_empty() || value.len() > 1024 || value.chars().any(char::is_control) { @@ -126,11 +126,13 @@ impl Profile { } /// LELEKA_CHAIN selects the chain-kernel group (docs/chain-kernels.md), LELEKA_SM120_* the compute-capability-12 -/// kernel switches (docs/experiments/draft-round-5090.md), LELEKA_PLE_* the GGUF PLE row reader +/// 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. 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"; known diff --git a/crates/deploy/src/profile/tests/builtin_profiles.rs b/crates/deploy/src/profile/tests/builtin_profiles.rs index 91ca51e3..8ecec13e 100644 --- a/crates/deploy/src/profile/tests/builtin_profiles.rs +++ b/crates/deploy/src/profile/tests/builtin_profiles.rs @@ -189,8 +189,14 @@ fn only_the_5090_profiles_enable_the_sm120_main_attention_and_swiglu_kernels() { } } -/// Engine switches of the compute capability 12 kernels that replace the main attention and the gate/up SwiGLU. -const SM120_MAIN_KERNEL_KEYS: [&str; 2] = ["LELEKA_SM120_ATTN_DAILY", "LELEKA_SM120_GU_SWIGLU"]; +/// Engine switches of the compute capability 12 kernels (main attention, gate/up SwiGLU) and of the GDN side streams. +const SM120_MAIN_KERNEL_KEYS: [&str; 5] = [ + "LELEKA_SM120_ATTN_DAILY", + "LELEKA_SM120_GU_SWIGLU", + "LELEKA_SM120_SIDE_MIXER", + "LELEKA_SM120_SIDE_QSA", + "LELEKA_SM120_SIDE_SHARED", +]; #[test] fn validation_rejects_unsafe_values() { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_verify.rs b/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_verify.rs index 050233fc..3dfefb3b 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_verify.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_verify.rs @@ -1,10 +1,11 @@ -//! Router and shared-expert operands of the Original verifier window, borrowed from the MoE cache. +//! Router and shared-expert operands of the Original verifier window, shared with the MoE cache. //! //! The window reads the router matrix and the shared expert (gate, up, down and the shared scalar) of all -//! 48 layers at once, in place, for the whole decode phase. The prompt path loads exactly the same raw -//! tensors layer by layer (`original_shared_layer`); `ensure_original_verify_shared` runs that loader for -//! every layer and then proves all 192 tensors are resident together (a load of a later layer may not have -//! evicted an earlier one), and `original_verify_moe` lends them. Nothing is copied or re-encoded: the +//! 48 layers at once, in place, for the whole decode phase. It holds them as shared handles (`DeviceRef`), so the +//! assembly does not borrow the cache and an entry the cache evicts stays alive while it is held. The prompt path +//! loads exactly the same raw tensors layer by layer (`original_shared_layer`); `ensure_original_verify_shared` runs +//! that loader for every layer and then proves all 192 tensors are resident together (a load of a later layer may +//! not have evicted an earlier one), and `original_verify_moe` hands them out. Nothing is copied or re-encoded: the //! routed experts are not here (the verifier's expert tier is the pool callback). use super::*; use crate::qwen_forward::original_serve_verifier::VerifyWeights; @@ -12,7 +13,7 @@ use crate::qwen_forward::{ contract::{Dimension, LayerId}, dense_weight_cache::DenseWeightCache, }; -use leleka_cuda_driver::{OriginalVerifyGeometry, OriginalVerifyMoeBinding, OriginalVerifyMoeLayerWeights}; +use leleka_cuda_driver::{DeviceRef, OriginalVerifyGeometry, OriginalVerifyMoeBinding, OriginalVerifyMoeLayerWeights}; /// Descriptors of one layer's shared gate, up, down and the shared scalar, in that order. pub(in crate::qwen_forward) type SharedKeys = Vec<[MoeWeightDescriptor; 4]>; @@ -39,28 +40,29 @@ impl<'ctx> MoeWeightCache<'ctx> { Ok(all) } - fn raw_shared(&self, key: &MoeWeightDescriptor) -> Result<&DeviceBuffer<'ctx>> { + /// A shared handle to the raw tensor of `key`: one reference-count increment, no copy. + fn raw_shared(&self, key: &MoeWeightDescriptor) -> Result> { let entry = self.main.get(key).ok_or(Error::IdentityMismatch)?; if entry.charged_bytes != key.bytes { return Err(Error::IdentityMismatch); } match &entry.weight { - EncodedWeight::Raw(buffer) => Ok(buffer), + EncodedWeight::Raw(buffer) => Ok(buffer.clone()), _ => Err(Error::IdentityMismatch), } } - fn verify_moe_layer<'a>( - &'a self, + fn verify_moe_layer( + &self, binding: &ModelBinding, - dense: &'a DenseWeightCache<'ctx>, + dense: &DenseWeightCache<'ctx>, layer: usize, keys: &[MoeWeightDescriptor; 4], - ) -> Result> { + ) -> Result> { if keys.iter().any(|key| key.layer as usize != layer) { return Err(Error::IdentityMismatch); } Ok(OriginalVerifyMoeLayerWeights { - router: dense.router(binding, layer as u32)?, + router: dense.router_handle(binding, layer as u32)?, gate_inp_shexp: self.raw_shared(&keys[3])?, gate_shexp: self.raw_shared(&keys[0])?, gate_shexp_type: keys[0].raw_kind, @@ -78,7 +80,7 @@ impl<'a, 'ctx> VerifyWeights<'a, 'ctx> { &self, binding: &ModelBinding, geometry: &OriginalVerifyGeometry, - ) -> Result> { + ) -> Result> { let (moe, dense, shared) = (self.moe, self.dense, self.shared); moe.validate(binding, moe.context)?; if shared.len() != 48 { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/cache_profile_fill/moe_weight_cache/pinned_triplet_preload.rs b/crates/engine-qwen35-cuda/src/qwen_forward/cache_profile_fill/moe_weight_cache/pinned_triplet_preload.rs index 4d7af059..ea7e081e 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/cache_profile_fill/moe_weight_cache/pinned_triplet_preload.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/cache_profile_fill/moe_weight_cache/pinned_triplet_preload.rs @@ -147,7 +147,7 @@ impl<'ctx> MoeWeightCache<'ctx> { EncodedWeight::Dual(format, owner) } else { // Original upload includes the same full encoded bytes. - EncodedWeight::Raw(self.upload(&raw[i])?) + EncodedWeight::Raw(DeviceRef::from_buffer(self.upload(&raw[i])?)) }; owned[i] = Some(weight); } diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/cache_profile_fill/shared_quartet_preload.rs b/crates/engine-qwen35-cuda/src/qwen_forward/cache_profile_fill/shared_quartet_preload.rs index 3d34cbc8..e4f6962a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/cache_profile_fill/shared_quartet_preload.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/cache_profile_fill/shared_quartet_preload.rs @@ -95,7 +95,7 @@ impl<'ctx> MoeWeightCache<'ctx> { if raw.len() != key.bytes { return Err(Error::InvalidDimension); } - owned[index] = Some(EncodedWeight::Raw(self.upload(&raw)?)); + owned[index] = Some(EncodedWeight::Raw(DeviceRef::from_buffer(self.upload(&raw)?))); } Ok(()) } diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/dense_original_verify.rs b/crates/engine-qwen35-cuda/src/qwen_forward/dense_original_verify.rs index 6e308a99..1cecb0ae 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/dense_original_verify.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/dense_original_verify.rs @@ -1,9 +1,10 @@ //! Weight bindings of the Original verifier window that the dense cache owns: the hyper-connection weights //! of the 48 layers, the final mixer and the PLE block (`OriginalVerifyGrBinding`), and the QSA norms and -//! indexer projections of the twelve QSA layers (`OriginalVerifyQsaBinding`). They are the cache's own -//! allocations, borrowed for the lifetime of a decode phase: the very buffers the prompt path reads, so the -//! window and the prefill cannot disagree about a weight. Native MMVQ projections are -//! `original_verify_projections`; router and shared experts live in the MoE cache (`cache_original_verify`). +//! indexer projections of the twelve QSA layers (`OriginalVerifyQsaBinding`). They are shared handles +//! (`DeviceRef`) to the cache's own allocations: the very buffers the prompt path reads, so the window and the +//! prefill cannot disagree about a weight, and a held assembly keeps them alive without borrowing the cache. +//! Native MMVQ projections are `original_verify_projections`; router and shared experts live in the MoE cache +//! (`cache_original_verify`). use super::*; use leleka_cuda_driver::{ HcHalfBuffers, HcLayerBuffers, HcOutputBuffers, OriginalVerifyGeometry, OriginalVerifyGrBinding, @@ -11,9 +12,20 @@ use leleka_cuda_driver::{ }; impl<'ctx> DenseWeightCache<'ctx> { - fn verify_gr_half<'a>(&'a self, binding: &ModelBinding, role: GrRole) -> Result> { + /// The handles of a hyper-connection entry's present buffers (norm, down, up, inject), owner checked. + fn gr_handles(&self, entry: &GrResident) -> Result<[Option>; 4]> { + if !Rc::ptr_eq(&self.owner, &entry.owner) { + return Err(Error::IdentityMismatch); + } + let mut handles: [Option>; 4] = Default::default(); + for (handle, slot) in handles.iter_mut().zip(entry.buffers) { + *handle = slot.map(|index| self.handle(index)).transpose()?; + } + Ok(handles) + } + fn verify_gr_half(&self, binding: &ModelBinding, role: GrRole) -> Result> { let entry = self.gr(binding, role)?; - let [norm, down, up, inject] = self.gr_buffers(entry)?; + let [norm, down, up, inject] = self.gr_handles(entry)?; Ok(HcHalfBuffers { norm: norm.ok_or(Error::IdentityMismatch)?, down: down.ok_or(Error::IdentityMismatch)?, @@ -21,42 +33,45 @@ impl<'ctx> DenseWeightCache<'ctx> { inject: inject.ok_or(Error::IdentityMismatch)?, }) } - fn verify_gr_output<'a>(&'a self, binding: &ModelBinding) -> Result> { + fn verify_gr_output(&self, binding: &ModelBinding) -> Result> { let entry = self.gr(binding, GrRole::Final)?; - let [norm, down, up, _] = self.gr_buffers(entry)?; + let [norm, down, up, _] = self.gr_handles(entry)?; Ok(HcOutputBuffers { norm: norm.ok_or(Error::IdentityMismatch)?, down: down.ok_or(Error::IdentityMismatch)?, up: up.ok_or(Error::IdentityMismatch)?, }) } - fn verify_ple_buffers<'a>( - &'a self, + fn verify_ple_buffers( + &self, binding: &ModelBinding, - ple_scratch: &'a DeviceBuffer<'ctx>, - ple_history: &'a DeviceBuffer<'ctx>, - ) -> Result> { + ple_scratch: &DeviceRef<'ctx>, + ple_history: &DeviceRef<'ctx>, + ) -> Result> { let ple = self.ple(binding, self.context)?; - let [norm_key, norm_query, norm_conv, conv1d] = self.ple_aux(ple)?; + // the size checks of the accessors stay; the handles come from the same slots + self.ple_key(ple)?; + self.ple_value(ple)?; + let [norm_key, norm_query, norm_conv, conv1d] = self.handles(self.ple_aux_slots(ple)?)?; Ok(PleBuffers { - key: PleKeyBuffer::Bf16(self.ple_key(ple)?), - value: self.ple_value(ple)?, + key: PleKeyBuffer::Bf16(self.handle(ple.key)?), + value: self.handle(ple.value)?, norm_key, norm_query, norm_conv, conv1d, - scratch: ple_scratch, - history: ple_history, + scratch: ple_scratch.clone(), + history: ple_history.clone(), }) } /// `hc_*` weights of every layer half, the `output_hc_*` mixer and the PLE block. `ple_history` must be /// the buffer the verify journal snapshots; `ple_scratch` at least `PLE_SCRATCH_BYTES`. - pub(in crate::qwen_forward) fn original_verify_gr<'a>( - &'a self, + pub(in crate::qwen_forward) fn original_verify_gr( + &self, binding: &ModelBinding, - ple_scratch: &'a DeviceBuffer<'ctx>, - ple_history: &'a DeviceBuffer<'ctx>, - ) -> Result> { + ple_scratch: &DeviceRef<'ctx>, + ple_history: &DeviceRef<'ctx>, + ) -> Result> { self.check(binding)?; let mut layers = Vec::new(); layers.try_reserve_exact(48).map_err(|_| Error::InputAllocation)?; @@ -71,33 +86,29 @@ impl<'ctx> DenseWeightCache<'ctx> { OriginalVerifyGrBinding::new(self.context, layers, output, Some(ple)).map_err(driver_error) } - fn verify_qsa_layer<'a>( - &'a self, - binding: &ModelBinding, - layer: u32, - ) -> Result> { + fn verify_qsa_layer(&self, binding: &ModelBinding, layer: u32) -> Result> { let entry = self.qsa(binding, layer)?; // norms: [q, k, index q, index k]; the index-k gamma belongs to the journal - let norms = self.qsa_norms(entry)?; - let (index_k, kind_k) = self.qsa_matrix(entry, QsaMatrixRole::IndexK)?; - let (index_q, kind_q) = self.qsa_matrix(entry, QsaMatrixRole::IndexQ)?; + let [attn_q_norm, attn_k_norm, index_q_norm, _] = self.handles(self.qsa_norm_slots(entry)?)?; + let (index_k, kind_k) = self.qsa_matrix_slot(entry, QsaMatrixRole::IndexK)?; + let (index_q, kind_q) = self.qsa_matrix_slot(entry, QsaMatrixRole::IndexQ)?; if kind_k != QsaMatrixKind::Bf16 || kind_q != QsaMatrixKind::Bf16 { return Err(Error::Unsupported(crate::qwen_forward::contract::Stage::QsaIndex)); } Ok(OriginalVerifyQsaLayerWeights { - attn_q_norm: norms[0], - attn_k_norm: norms[1], - index_q_norm: norms[2], - index_k_proj: index_k, - index_q_proj: index_q, + attn_q_norm, + attn_k_norm, + index_q_norm, + index_k_proj: self.handle(index_k)?, + index_q_proj: self.handle(index_q)?, }) } /// The twelve QSA layers' Q/K norms, indexer Q norm and the BF16 indexer K/Q projections. - pub(in crate::qwen_forward) fn original_verify_qsa<'a>( - &'a self, + pub(in crate::qwen_forward) fn original_verify_qsa( + &self, binding: &ModelBinding, geometry: &OriginalVerifyGeometry, - ) -> Result> { + ) -> Result> { self.check(binding)?; let mut layers = Vec::new(); layers.try_reserve_exact(12).map_err(|_| Error::InputAllocation)?; @@ -107,8 +118,14 @@ impl<'ctx> DenseWeightCache<'ctx> { } layers.push(self.verify_qsa_layer(binding, layer.index())?); } - let layers: [OriginalVerifyQsaLayerWeights<'a, 'ctx>; 12] = + let layers: [OriginalVerifyQsaLayerWeights<'ctx>; 12] = layers.try_into().map_err(|_| Error::InvalidDimension)?; OriginalVerifyQsaBinding::new(self.context, *geometry, layers).map_err(driver_error) } + /// The router matrix of `layer` for the verifier window's MoE binding (a shared handle). + pub(in crate::qwen_forward) fn router_handle(&self, binding: &ModelBinding, layer: u32) -> Result> { + self.check(binding)?; + self.hit()?; + self.handle(*self.router.get(layer as usize).ok_or(Error::InvalidLayer)?) + } } diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache.rs b/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache.rs index 06882935..1b65cabc 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache.rs @@ -16,7 +16,7 @@ use crate::model_binding::qwen4exp_input::{ use leleka_cuda_driver::GrBatchInjectWorkspace; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use leleka_cuda_driver::OriginalVerifyGdnWeights; -use leleka_cuda_driver::{Context, DeviceBuffer, DeviceSlice, SlabAllocator, SlabPolicy}; +use leleka_cuda_driver::{Context, DeviceBuffer, DeviceRef, SlabAllocator, SlabPolicy}; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use leleka_cuda_driver::{ OriginalVerifyGdnProjections, OriginalVerifyGeometry, OriginalVerifyNativeMatrix, OriginalVerifyProjBinding, @@ -78,7 +78,7 @@ pub(crate) struct DenseWeightCache<'ctx> { context: &'ctx Context<'ctx>, /// Every resident weight, in `add` order. Small ones are sub-ranges of 64 MiB slabs (`dense_slab_policy`): the /// driver rounds each separate allocation above 1 MiB up to 2 MiB, which took 688 MiB for about 700 buffers. - buffers: Vec>, + buffers: Vec>, slabs: Option>, gdn: Vec>, gdn_mirrors: Vec>>>, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_cache_gdn_qsa_workspaces.rs b/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_cache_gdn_qsa_workspaces.rs index eb7b659c..c0012fa6 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_cache_gdn_qsa_workspaces.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_cache_gdn_qsa_workspaces.rs @@ -224,4 +224,18 @@ impl<'ctx> DenseWeightCache<'ctx> { pub(in super::super) fn buffer(&self, index: usize) -> Result<&DeviceBuffer<'ctx>> { self.buffers.get(index).map(|slice| &**slice).ok_or(Error::IdentityMismatch) } + /// A shared handle to buffer `index` for a held verify assembly: one reference-count increment, so the + /// allocation outlives this cache's own release of it. + pub(in super::super) fn handle(&self, index: usize) -> Result> { + self.buffers.get(index).cloned().ok_or(Error::IdentityMismatch) + } + /// `handle` of several slots at once, in order. + pub(in super::super) fn handles(&self, slots: [usize; N]) -> Result<[DeviceRef<'ctx>; N]> { + let mut out = Vec::new(); + out.try_reserve_exact(N).map_err(|_| Error::InputAllocation)?; + for slot in slots { + out.push(self.handle(slot)?); + } + out.try_into().map_err(|_| Error::InvalidDimension) + } } diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_cache_matrix_registration.rs b/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_cache_matrix_registration.rs index 037de0d0..975185a3 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_cache_matrix_registration.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_cache_matrix_registration.rs @@ -29,7 +29,7 @@ impl<'ctx> DenseWeightCache<'ctx> { return Err(primary); } let index = self.buffers.len(); - self.buffers.push(b); + self.buffers.push(DeviceRef::from_slice(b)); let mut c = self.counters.get(); c.matrices = c.matrices.checked_add(1).ok_or(Error::Overflow)?; c.read_bytes = c.read_bytes.checked_add(source_bytes as u64).ok_or(Error::Overflow)?; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_cache_ple_and_verify_weights.rs b/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_cache_ple_and_verify_weights.rs index 9494d843..1a73325a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_cache_ple_and_verify_weights.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_cache_ple_and_verify_weights.rs @@ -53,21 +53,30 @@ impl<'ctx> DenseWeightCache<'ctx> { Err(Error::Unsupported(super::super::super::contract::Stage::Input)) } pub(in super::super::super) fn ple_aux(&self, entry: &PleResident) -> Result<[&DeviceBuffer<'ctx>; 4]> { + let slots = self.ple_aux_slots(entry)?; + Ok([self.buffer(slots[0])?, self.buffer(slots[1])?, self.buffer(slots[2])?, self.buffer(slots[3])?]) + } + /// The cache slots of the PLE norms and the causal convolution (`ple_aux` order). + pub(in super::super::super) fn ple_aux_slots(&self, entry: &PleResident) -> Result<[usize; 4]> { if !Rc::ptr_eq(&self.owner, &entry.owner) { return Err(Error::IdentityMismatch); } - Ok([ - self.buffer(entry.aux[0])?, - self.buffer(entry.aux[1])?, - self.buffer(entry.aux[2])?, - self.buffer(entry.aux[3])?, - ]) + Ok(entry.aux) } pub(in super::super::super) fn gdn_matrix( &self, entry: &GdnResident, role: GdnMatrixRole, ) -> Result<(&DeviceBuffer<'ctx>, GdnMatrixKind)> { + let (index, kind) = self.gdn_matrix_slot(entry, role)?; + Ok((self.buffer(index)?, kind)) + } + /// The cache slot and storage kind of one GDN matrix. + pub(in super::super::super) fn gdn_matrix_slot( + &self, + entry: &GdnResident, + role: GdnMatrixRole, + ) -> Result<(usize, GdnMatrixKind)> { if !Rc::ptr_eq(&self.owner, &entry.owner) { return Err(Error::IdentityMismatch); } @@ -78,28 +87,27 @@ impl<'ctx> DenseWeightCache<'ctx> { GdnMatrixRole::Beta => 3, GdnMatrixRole::Out => 4, }; - let (index, kind) = entry.matrices[i]; - Ok((self.buffer(index)?, kind)) + Ok(entry.matrices[i]) } pub(in super::super::super) fn gdn_aux(&self, entry: &GdnResident) -> Result<[&DeviceBuffer<'ctx>; 4]> { + let slots = self.gdn_aux_slots(entry)?; + Ok([self.buffer(slots[0])?, self.buffer(slots[1])?, self.buffer(slots[2])?, self.buffer(slots[3])?]) + } + /// The cache slots of a GDN layer's conv, dt, a and norm tensors (`gdn_aux` order). + pub(in super::super::super) fn gdn_aux_slots(&self, entry: &GdnResident) -> Result<[usize; 4]> { if !Rc::ptr_eq(&self.owner, &entry.owner) { return Err(Error::IdentityMismatch); } - Ok([ - self.buffer(entry.aux[0])?, - self.buffer(entry.aux[1])?, - self.buffer(entry.aux[2])?, - self.buffer(entry.aux[3])?, - ]) + Ok(entry.aux) } /// Ordered, retained operands for the native verifier's thirty-six GDN /// layers. These are the cache's actual allocations: no host-side weight /// conversion or subrange projection is permitted at this boundary. #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] - pub(in super::super::super) fn original_verify_gdn_weights<'a>( - &'a self, + pub(in super::super::super) fn original_verify_gdn_weights( + &self, binding: &ModelBinding, - ) -> Result<[OriginalVerifyGdnWeights<'a, 'ctx>; 36]> { + ) -> Result<[OriginalVerifyGdnWeights<'ctx>; 36]> { self.check(binding)?; let mut retained = Vec::new(); retained.try_reserve_exact(36).map_err(|_| Error::InputAllocation)?; @@ -112,27 +120,23 @@ impl<'ctx> DenseWeightCache<'ctx> { retained.try_into().map_err(|_| Error::InvalidDimension) } #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] - fn original_verify_gdn_layer<'a>( - &'a self, - binding: &ModelBinding, - index: u32, - ) -> Result> { + fn original_verify_gdn_layer(&self, binding: &ModelBinding, index: u32) -> Result> { let resident = self.gdn(binding, index)?; - let (alpha, alpha_kind) = self.gdn_matrix(resident, GdnMatrixRole::Alpha)?; - let (beta, beta_kind) = self.gdn_matrix(resident, GdnMatrixRole::Beta)?; + let (alpha, alpha_kind) = self.gdn_matrix_slot(resident, GdnMatrixRole::Alpha)?; + let (beta, beta_kind) = self.gdn_matrix_slot(resident, GdnMatrixRole::Beta)?; if alpha_kind != GdnMatrixKind::Bf16 || beta_kind != GdnMatrixKind::Bf16 { return Err(Error::Unsupported(super::super::super::contract::Stage::Gdn)); } - let aux = self.gdn_aux(resident)?; - Ok(OriginalVerifyGdnWeights { conv: aux[0], alpha, beta, dt: aux[1], a: aux[2], norm: aux[3] }) + let [conv, dt, a, norm] = self.handles(self.gdn_aux_slots(resident)?)?; + Ok(OriginalVerifyGdnWeights { conv, alpha: self.handle(alpha)?, beta: self.handle(beta)?, dt, a, norm }) } /// The twelve QSA layers' indexer K norm gamma (128 F32 each), in layer order: the verifier's /// indexer append re-normalizes each raw index key with exactly these cache allocations. #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] - pub(in super::super::super) fn original_verify_qsa_gamma<'a>( - &'a self, + pub(in super::super::super) fn original_verify_qsa_gamma( + &self, binding: &ModelBinding, - ) -> Result<[&'a DeviceBuffer<'ctx>; 12]> { + ) -> Result<[DeviceRef<'ctx>; 12]> { self.check(binding)?; let mut gamma = Vec::new(); gamma.try_reserve_exact(12).map_err(|_| Error::InputAllocation)?; @@ -142,20 +146,16 @@ impl<'ctx> DenseWeightCache<'ctx> { } let resident = self.qsa(binding, layer.index())?; // norms: [q, k, index q, index k] - gamma.push(self.qsa_norms(resident)?[3]); + gamma.push(self.handle(self.qsa_norm_slots(resident)?[3])?); } gamma.try_into().map_err(|_| Error::InvalidDimension) } #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] - fn verify_gdn_projections<'a>( - &'a self, - binding: &ModelBinding, - layer: u32, - ) -> Result> { + fn verify_gdn_projections(&self, binding: &ModelBinding, layer: u32) -> Result> { let resident = self.gdn(binding, layer)?; - let matrix = |role| -> Result> { - let (buffer, kind) = self.gdn_matrix(resident, role)?; - Ok(OriginalVerifyNativeMatrix { kind: gdn_native_type(kind)?, buffer }) + let matrix = |role| -> Result> { + let (slot, kind) = self.gdn_matrix_slot(resident, role)?; + Ok(OriginalVerifyNativeMatrix { kind: gdn_native_type(kind)?, buffer: self.handle(slot)? }) }; Ok(OriginalVerifyGdnProjections { qkv: matrix(GdnMatrixRole::Qkv)?, @@ -164,15 +164,11 @@ impl<'ctx> DenseWeightCache<'ctx> { }) } #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] - fn verify_qsa_projections<'a>( - &'a self, - binding: &ModelBinding, - layer: u32, - ) -> Result> { + fn verify_qsa_projections(&self, binding: &ModelBinding, layer: u32) -> Result> { let resident = self.qsa(binding, layer)?; - let matrix = |role| -> Result> { - let (buffer, kind) = self.qsa_matrix(resident, role)?; - Ok(OriginalVerifyNativeMatrix { kind: qsa_native_type(kind)?, buffer }) + let matrix = |role| -> Result> { + let (slot, kind) = self.qsa_matrix_slot(resident, role)?; + Ok(OriginalVerifyNativeMatrix { kind: qsa_native_type(kind)?, buffer: self.handle(slot)? }) }; Ok(OriginalVerifyQsaProjections { k: matrix(QsaMatrixRole::K)?, @@ -182,14 +178,14 @@ impl<'ctx> DenseWeightCache<'ctx> { }) } /// The native-format (GGUF block) MMVQ projection matrices of the 36 GDN and 12 QSA - /// layers for the literal Verifier window: the cache's own allocations, borrowed. + /// layers for the literal Verifier window: shared handles to the cache's own allocations. /// A matrix the cache holds as BF16 has no native MMVQ owner and is refused. #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] - pub(in super::super::super) fn original_verify_projections<'a>( - &'a self, + pub(in super::super::super) fn original_verify_projections( + &self, binding: &ModelBinding, geometry: &OriginalVerifyGeometry, - ) -> Result> { + ) -> Result> { self.check(binding)?; let mut gdn = Vec::new(); let mut qsa = Vec::new(); @@ -208,6 +204,15 @@ impl<'ctx> DenseWeightCache<'ctx> { entry: &QsaResident, role: QsaMatrixRole, ) -> Result<(&DeviceBuffer<'ctx>, QsaMatrixKind)> { + let (index, kind) = self.qsa_matrix_slot(entry, role)?; + Ok((self.buffer(index)?, kind)) + } + /// The cache slot and storage kind of one QSA matrix. + pub(in super::super::super) fn qsa_matrix_slot( + &self, + entry: &QsaResident, + role: QsaMatrixRole, + ) -> Result<(usize, QsaMatrixKind)> { if !Rc::ptr_eq(&self.owner, &entry.owner) { return Err(Error::IdentityMismatch); } @@ -219,19 +224,18 @@ impl<'ctx> DenseWeightCache<'ctx> { QsaMatrixRole::IndexK => 4, QsaMatrixRole::Out => 5, }; - let (index, kind) = entry.matrices[i]; - Ok((self.buffer(index)?, kind)) + Ok(entry.matrices[i]) } pub(in super::super::super) fn qsa_norms(&self, entry: &QsaResident) -> Result<[&DeviceBuffer<'ctx>; 4]> { + let slots = self.qsa_norm_slots(entry)?; + Ok([self.buffer(slots[0])?, self.buffer(slots[1])?, self.buffer(slots[2])?, self.buffer(slots[3])?]) + } + /// The cache slots of a QSA layer's q, k, indexer-q and indexer-k norms (`qsa_norms` order). + pub(in super::super::super) fn qsa_norm_slots(&self, entry: &QsaResident) -> Result<[usize; 4]> { if !Rc::ptr_eq(&self.owner, &entry.owner) { return Err(Error::IdentityMismatch); } - Ok([ - self.buffer(entry.norms[0])?, - self.buffer(entry.norms[1])?, - self.buffer(entry.norms[2])?, - self.buffer(entry.norms[3])?, - ]) + Ok(entry.norms) } } 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 decb3ad3..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 @@ -264,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/moe_weight_cache.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache.rs index 97a23c55..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 @@ -6,7 +6,7 @@ use crate::model_binding::qwen4exp_input::{ MtpRole, }; use leleka_cuda_driver::{ - Context, DeviceBuffer, MmqFormat, MmqWeights, MmqWorkspace, MtpInputWorkspace, RoutedFiniteStage, + Context, DeviceBuffer, DeviceRef, MmqFormat, MmqWeights, MmqWorkspace, MtpInputWorkspace, RoutedFiniteStage, RoutedGroupWorkspace, RoutedStageFiniteGuard, }; use std::cell::{Cell, RefCell}; @@ -76,7 +76,9 @@ pub(crate) struct WeightCacheCounters { // One allocation per actual descriptor. Dual storage is shared by native and // experimental MMQ consumers; the native logical extent never exposes a view. enum EncodedWeight<'ctx> { - Raw(DeviceBuffer<'ctx>), + /// A shared handle: the verify window's assembly holds the shared-expert and router tensors in place across + /// requests, so an evicted entry's memory outlives the cache's book while a held assembly still has it. + Raw(DeviceRef<'ctx>), Dual(MmqFormat, MmqWeights<'ctx>), } #[derive(Clone, Copy)] @@ -170,9 +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 (`window_pins`), and how many raw entries were evicted. - window_pins: std::collections::HashSet, - raw_evictions: 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>, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_main_entry_routed_source/fill_fns.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_main_entry_routed_source/fill_fns.rs index 1cf0898b..11bae258 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_main_entry_routed_source/fill_fns.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_main_entry_routed_source/fill_fns.rs @@ -142,7 +142,7 @@ impl<'ctx> MoeWeightCache<'ctx> { charged_bytes: usize, ) -> Result> { let Some((format, expected)) = dual else { - return Ok(EncodedWeight::Raw(self.upload(&bytes)?)); + return Ok(EncodedWeight::Raw(DeviceRef::from_buffer(self.upload(&bytes)?))); }; let built = self.context.mmq_weights(format, &bytes); self.admit_dual_weight(built, (format, expected), (bytes.len(), charged_bytes)) @@ -157,7 +157,7 @@ impl<'ctx> MoeWeightCache<'ctx> { charged_bytes: usize, ) -> Result> { let Some((format, expected)) = dual else { - return Ok(EncodedWeight::Raw(self.upload(&bytes)?)); + return Ok(EncodedWeight::Raw(DeviceRef::from_buffer(self.upload(&bytes)?))); }; let raw_bytes = bytes.len(); let shape = gate_up_shape(key)?; 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 91def268..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 @@ -31,7 +31,7 @@ macro_rules! blank_cache { adaptive_shared: None, age: 0, window_pins: Default::default(), - raw_evictions: 0, + 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 92ea856c..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,7 +139,7 @@ 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_pins.contains(&key) { + if self.window_pinned(&key) { return true; } #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] 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 2e150ad7..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,7 +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(&entry.weight); + 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 a4ffe70c..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,7 +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(&entry.weight); + 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 index 4449f7fd..c2494e94 100644 --- 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 @@ -1,39 +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. While a graph set is held -//! across requests the prompt path must not free them: `pin_for_window` makes the cache skip them when it needs room -//! (the same rule as the profile's permanent pool), and `raw_evictions` counts every raw entry the cache did free, so a -//! graph set recorded before such an eviction is never replayed (the count is part of the graph key's weights epoch). +//! 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(&mut self, keys: &[[MoeWeightDescriptor; 4]]) -> Result<()> { + 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); } - self.window_pins.extend(keys.iter().flatten().copied()); + 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(&mut self) { - if !self.window_pins.is_empty() { - self.window_pins.clear(); - self.raw_evictions = self.raw_evictions.wrapping_add(1); + 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)); } } - /// Raw entries freed so far, plus the pins released: unchanged between two requests means every address a window - /// graph read is still the same live buffer. + /// 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 + self.raw_evictions.get() } - /// Account an entry the cache is about to free (the window reads raw entries only). - pub(super) fn note_eviction(&mut self, weight: &EncodedWeight<'ctx>) { - if matches!(weight, EncodedWeight::Raw(_)) { - self.raw_evictions = self.raw_evictions.wrapping_add(1); + 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 7a6736ea..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 @@ -177,7 +177,7 @@ impl RopeConstants { magnitude: args.attn_factor, } } - pub(in crate::qwen_forward) fn verify_rope<'a, 'ctx>(&self) -> OriginalVerifyRope<'a, 'ctx> { + pub(in crate::qwen_forward) fn verify_rope<'ctx>(&self) -> OriginalVerifyRope<'ctx> { OriginalVerifyRope { theta_scale: self.theta_scale, freq_scale: self.freq_scale, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_host.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_host.rs index f51ef93e..3243d7b8 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_host.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_host.rs @@ -77,7 +77,7 @@ pub(in crate::qwen_forward) struct OriginalServeHost<'a, 'ctx> { history: &'a mut OriginalNativePenaltyHistory<'ctx>, pool: &'a mut dyn OriginalServePool<'ctx>, /// A second reference to the verifier's QSA journal, only to read the committed mapped prefixes. - qsa: Rc>, + qsa: Rc>, /// Model layer index of journal layer `i`. slots: [usize; 12], ple_history: &'a DeviceBuffer<'ctx>, @@ -105,7 +105,7 @@ pub(in crate::qwen_forward) struct HostOwners<'a, 'ctx> { pub(in crate::qwen_forward) kar: Option<&'a mut KarPleCache<'ctx>>, pub(in crate::qwen_forward) history: &'a mut OriginalNativePenaltyHistory<'ctx>, pub(in crate::qwen_forward) pool: &'a mut dyn OriginalServePool<'ctx>, - pub(in crate::qwen_forward) qsa: Rc>, + pub(in crate::qwen_forward) qsa: Rc>, pub(in crate::qwen_forward) slots: [usize; 12], pub(in crate::qwen_forward) ple_history: &'a DeviceBuffer<'ctx>, pub(in crate::qwen_forward) policy: &'a OriginalMtpFullPolicy, 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 a1c47d84..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}, @@ -59,8 +59,9 @@ use crate::backend::original_prompt::{PlanError, PlanLimits, PromptOptions, Prom use crate::model_binding::qwen4exp_input::ModelBinding; use leleka_context::memory_plan::KvFormat; use leleka_cuda_driver::{ - Context, DeviceBuffer, NativeHeadDispatch, OriginalExpertCache, OriginalMtpFullPolicy, OriginalMtpScalarPolicy, - OriginalPrefillArena, OriginalVerifyExpertFormats, PLE_SCRATCH_BYTES, PrefillLayoutOptions, + Context, DeviceBuffer, DeviceRef, NativeHeadDispatch, OriginalExpertCache, OriginalMtpFullPolicy, + OriginalMtpScalarPolicy, OriginalPrefillArena, OriginalVerifyExpertFormats, PLE_SCRATCH_BYTES, + PrefillLayoutOptions, }; use std::{path::PathBuf, rc::Rc, time::Instant}; @@ -191,10 +192,13 @@ 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: DeviceBuffer<'ctx>, - ple_scratch: DeviceBuffer<'ctx>, + ple_history: DeviceRef<'ctx>, + ple_scratch: DeviceRef<'ctx>, /// The prompt path's own buffers; `None` while it borrows the expert cache's last slots instead. arena: Option>, /// The VRAM expert tier (`None`: off). @@ -236,6 +240,7 @@ 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 index 073c0628..ea7a9e07 100644 --- 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 @@ -182,8 +182,9 @@ impl GraphReuse { /// 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 self.held.take().is_some() { + if let Some(held) = self.held.take() { retire(); + drop(held); } } @@ -198,10 +199,173 @@ impl GraphReuse { } } -/// The one line `open` writes when the switch is on while the stack cannot keep an assembly yet. -pub(crate) fn refusal_line(requested: bool) -> Option<&'static str> { +/// 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) requested: refused, the verify bank has no park/rearm API and ", - "the assembly still borrows the stack (docs/experiments/decode-graph-reuse.md); every request records graphs", + "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/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 f660c59b..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()?; +) -> std::result::Result<(usize, std::result::Result, AssembleFailure<'ctx>>), SpecError> { let p = profile::span("decode.assemble"); let mut refill = refill; let mut queue_refill = || refill.queue(inputs.binding, moe); @@ -111,7 +111,7 @@ fn assemble_attempt<'a, 'ctx>( owners_slot: &mut Option>, max_t: usize, queue_refill: &mut impl FnMut() -> Result<()>, -) -> std::result::Result, (AssembleFailure<'ctx>, Option)> { +) -> std::result::Result, (AssembleFailure<'ctx>, Option)> { let Some(owners) = owners_slot.take() else { return Err(( AssembleFailure { failure: Error::IdentityMismatch.into(), owners: None, window_cap: None }, @@ -141,8 +141,8 @@ pub(super) fn settle_deferred_refill( } /// Close the verifier and hand the physical QSA owners back to the executor at the session's lineage. -pub(super) fn return_owners<'a, 'ctx>( - resources: DecodeResources<'a, 'ctx>, +pub(super) fn return_owners<'ctx>( + resources: DecodeResources<'ctx>, executor: &mut OriginalPromptExecutor<'ctx>, binding: &ModelBinding, dense: &DenseWeightCache<'ctx>, @@ -152,11 +152,11 @@ pub(super) fn return_owners<'a, 'ctx>( } /// The assembly's outcome: the resources, or the failure with the owners given back (or the stack marked broken). -pub(super) fn resolve_assembled<'a, 'ctx>( - assembled: std::result::Result, AssembleFailure<'ctx>>, +pub(super) fn resolve_assembled<'ctx>( + assembled: std::result::Result, AssembleFailure<'ctx>>, mut home: QsaOwnerHome<'_, 'ctx>, broken: &mut Option, -) -> std::result::Result, SpecError> { +) -> std::result::Result, SpecError> { let lost = match assembled { Ok(resources) => return Ok(resources), Err(lost) => lost, @@ -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<'a, 'ctx>( - resources: DecodeResources<'a, '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 1a4adabf..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; @@ -18,14 +18,13 @@ pub(super) struct Staged<'ctx> { } /// The assembly's outcome: the window width it settled on and the resources or the failure. -pub(super) type Assembled<'s, 'ctx> = (usize, std::result::Result, AssembleFailure<'ctx>>); +pub(super) type Assembled<'ctx> = (usize, std::result::Result, AssembleFailure<'ctx>>); /// The expert pool a request runs over: the GPU share over the CPU pool, or the CPU pool alone (decided at run time). type PoolRef<'q, 'ctx> = &'q mut dyn OriginalServePool<'ctx>; /// The pool, the QSA journal with its layer slots, and the PLE history image a host is built over. -type HostTail<'h, 'ctx> = - (PoolRef<'h, 'ctx>, Rc>, [usize; 12], &'h DeviceBuffer<'ctx>); +type HostTail<'h, 'ctx> = (PoolRef<'h, 'ctx>, Rc>, [usize; 12], &'h DeviceBuffer<'ctx>); impl<'a, 'ctx> OriginalServeStack<'a, 'ctx> { /// The request's start: a poisoned controller is renewed, the base position is checked, the PLE history is seeded @@ -62,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). - pub(super) fn assemble(&mut self, staged: &Staged<'ctx>) -> std::result::Result, SpecError> { + /// 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, @@ -85,21 +177,16 @@ 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 /// are fewer than asked for. pub(super) fn resolve( &mut self, - assembled: Assembled<'s, 'ctx>, - ) -> std::result::Result, SpecError> { + assembled: Assembled<'ctx>, + ) -> std::result::Result, SpecError> { let (used_max_t, assembled) = assembled; self.book.marks.assembled = self.book.marks.since(&self.policy.config.clock); if let Some(error) = settle_deferred_refill(&mut *self.refill.pending, &mut *self.tier.expert_cache) { @@ -124,7 +211,7 @@ impl<'s, 'a, 'ctx> DecodeView<'s, 'a, 'ctx> { /// The deferred refill failed: the stack is broken; the owners of an assembled verifier go back. fn abandon( &mut self, - assembled: std::result::Result, AssembleFailure<'ctx>>, + assembled: std::result::Result, AssembleFailure<'ctx>>, error: Error, ) -> SpecError { self.book.broken.get_or_insert(error); @@ -138,9 +225,9 @@ impl<'s, 'a, 'ctx> DecodeView<'s, 'a, 'ctx> { /// The windows that fit are fewer than the verifier was built for: the policy and its arms follow. fn narrow( &mut self, - resources: DecodeResources<'s, 'ctx>, + resources: DecodeResources<'ctx>, used_max_t: usize, - ) -> std::result::Result, SpecError> { + ) -> std::result::Result, SpecError> { if used_max_t < *self.arms.verifier_max_t { let stack = (&mut *self.policy.settings, &mut *self.policy.controller, &mut *self.arms.verifier_max_t); let executor = &mut *self.owners.executor; @@ -159,9 +246,10 @@ impl<'s, 'a, 'ctx> DecodeView<'s, 'a, 'ctx> { mut self, request: &ServeRequest, sampling: RequestSampling, - resources: DecodeResources<'s, '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); @@ -170,7 +258,7 @@ impl<'s, 'a, 'ctx> DecodeView<'s, 'a, 'ctx> { let groups = (&self.ids, &self.reads, &mut self.tier, &self.policy); let pool = expert_pool(groups, &mut gpu_pool)?; let want_tail = begin_tail(&mut self.policy, &mut self.book); - let tail = (pool, Rc::clone(&qsa), slots, self.ple_history); + let tail = (pool, Rc::clone(&qsa), slots, &**self.ple_history); let owners = host_owners((&self.ids, &self.reads, &mut self.owners, &mut self.extra), tail); let host = OriginalServeHost::new(owners, committed, self.policy.config.max_context as u64, sampling); let env = serve_env(&mut self.policy, &mut self.book, want_tail); @@ -179,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 3716d351..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 @@ -20,7 +20,7 @@ pub(super) struct Reads<'s, 'ctx> { pub(super) dense: &'s DenseWeightCache<'ctx>, pub(super) moe: &'s MoeWeightCache<'ctx>, pub(super) formats: &'s OriginalVerifyExpertFormats, - pub(super) ple_scratch: &'s DeviceBuffer<'ctx>, + pub(super) ple_scratch: &'s DeviceRef<'ctx>, } /// The constants the verifier window reads. @@ -92,7 +92,9 @@ pub(super) struct DecodeView<'s, 'a, 'ctx> { pub(super) policy: Policy<'s>, pub(super) arms: Arms<'s>, pub(super) book: Book<'s, 'ctx>, - pub(super) ple_history: &'s DeviceBuffer<'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 58ce3059..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,7 +31,7 @@ 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::refusal_line(crate::settings::process().serve.decode_graph_reuse) { + 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_open/open_phases.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_open/open_phases.rs index 53e4a371..0da2bef4 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_open/open_phases.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_open/open_phases.rs @@ -29,8 +29,8 @@ pub(super) struct Core<'ctx> { pub(super) struct Buffers<'a, 'ctx> { pub(super) arena: Option>, pub(super) history: OriginalNativePenaltyHistory<'ctx>, - pub(super) ple_history: DeviceBuffer<'ctx>, - pub(super) ple_scratch: DeviceBuffer<'ctx>, + pub(super) ple_history: DeviceRef<'ctx>, + pub(super) ple_scratch: DeviceRef<'ctx>, pub(super) pool: CpuExpertPool<'a>, pub(super) empty_session: OriginalSessionCheckpoint<'ctx>, pub(super) empty_draft: OriginalDraftCheckpoint, @@ -103,10 +103,10 @@ pub(super) fn load_buffers<'a, 'ctx>( fn ple_buffers<'ctx>( context: &'ctx Context<'ctx>, -) -> std::result::Result<(DeviceBuffer<'ctx>, DeviceBuffer<'ctx>), ServeFailure> { +) -> std::result::Result<(DeviceRef<'ctx>, DeviceRef<'ctx>), ServeFailure> { let ple_history = context.allocate(PLE_HISTORY_BYTES).map_err(at("ple_history"))?; let ple_scratch = context.allocate(PLE_SCRATCH_BYTES).map_err(at("ple_scratch"))?; - Ok((ple_history, ple_scratch)) + Ok((DeviceRef::from_buffer(ple_history), DeviceRef::from_buffer(ple_scratch))) } fn empty_checkpoints<'ctx>( diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/serve_parts.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/serve_parts.rs index 2d7de959..020ed613 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/serve_parts.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/serve_parts.rs @@ -6,7 +6,7 @@ use crate::qwen_forward::original_serve_engine::{OriginalServePort, ServeCallbac use crate::qwen_forward::original_serve_host::HostOutcome; use leleka_cuda_driver::{OriginalVerifier, OriginalVerifyWindowResources}; -type Verifier<'a, 'ctx> = OriginalVerifier<'ctx, OriginalVerifyWindowResources<'a, 'ctx>>; +type Verifier<'a, 'ctx> = OriginalVerifier<'ctx, OriginalVerifyWindowResources<'ctx>>; /// The borrowed state the serve step reads and writes besides the verifier and the host. pub(super) struct ServeEnv<'r, '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 394ca338..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 @@ -20,7 +20,7 @@ use super::{ }; use crate::model_binding::qwen4exp_input::{BoundLayerKind, ModelBinding}; use leleka_cuda_driver::{ - Context, DeviceBuffer, OriginalQsaMappedJournal, OriginalQsaResidentIndex, OriginalVerifier, + Context, DeviceBuffer, DeviceRef, OriginalQsaMappedJournal, OriginalQsaResidentIndex, OriginalVerifier, OriginalVerifyExpertFormats, OriginalVerifyQsaJournal, OriginalVerifyResources, OriginalVerifyWindowPolicy, OriginalVerifyWindowResources, }; @@ -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 { @@ -84,9 +90,9 @@ pub(in crate::qwen_forward) fn driver_error(error: &leleka_cuda_driver::Error) - type QsaOwners<'ctx> = [Option<(OriginalQsaResidentIndex<'ctx>, OriginalQsaMappedJournal<'ctx>)>; 48]; /// The verifier plus the one extra reference to the QSA journal that lets the owners be recovered. -pub(in crate::qwen_forward) struct DecodeResources<'a, 'ctx> { - pub(in crate::qwen_forward) verifier: OriginalVerifier<'ctx, OriginalVerifyWindowResources<'a, 'ctx>>, - pub(in crate::qwen_forward) qsa: Rc>, +pub(in crate::qwen_forward) struct DecodeResources<'ctx> { + pub(in crate::qwen_forward) verifier: OriginalVerifier<'ctx, OriginalVerifyWindowResources<'ctx>>, + pub(in crate::qwen_forward) qsa: Rc>, /// Model layer index of journal layer `i` (the owners were handed over in ascending slot order). pub(in crate::qwen_forward) slots: [usize; 12], } @@ -166,7 +172,7 @@ fn gdn_layer_priors<'p>(binding: &ModelBinding, base: &'p OriginalVerifiedBase<' /// Upload the session's PLE prior into the device history image the commit graph keeps current. pub(in crate::qwen_forward) fn seed_ple_history<'ctx>( base: &OriginalVerifiedBase<'_>, - ple_history: &mut DeviceBuffer<'ctx>, + ple_history: &DeviceRef<'ctx>, ) -> std::result::Result<(), ServeFailure> { let ple = base.ple.as_ref().ok_or(Error::IdentityMismatch)?; if ple.history().len() != PLE_HISTORY_VALUES || ple_history.len() != PLE_HISTORY_BYTES { @@ -177,7 +183,7 @@ pub(in crate::qwen_forward) fn seed_ple_history<'ctx>( for value in ple.history() { bytes.extend_from_slice(&value.to_le_bytes()); } - ple_history.copy_from(&bytes)?; + ple_history.copy_from_shared(&bytes)?; Ok(()) } @@ -201,7 +207,7 @@ pub(in crate::qwen_forward) struct VerifyWeights<'a, 'ctx> { pub(in crate::qwen_forward) moe: &'a MoeWeightCache<'ctx>, pub(in crate::qwen_forward) shared: &'a SharedKeys, pub(in crate::qwen_forward) formats: &'a OriginalVerifyExpertFormats, - pub(in crate::qwen_forward) ple_scratch: &'a DeviceBuffer<'ctx>, + pub(in crate::qwen_forward) ple_scratch: &'a DeviceRef<'ctx>, } /// What `assemble` reads: the borrowed weights and constants of one decode phase. `ple_history` must already hold the @@ -212,7 +218,7 @@ pub(in crate::qwen_forward) struct AssembleInputs<'x, 'a, 'ctx> { pub(in crate::qwen_forward) weights: &'x VerifyWeights<'a, 'ctx>, pub(in crate::qwen_forward) output: &'x OriginalNativeOutput<'ctx>, pub(in crate::qwen_forward) base: &'x OriginalVerifiedBase<'ctx>, - pub(in crate::qwen_forward) ple_history: &'a DeviceBuffer<'ctx>, + pub(in crate::qwen_forward) ple_history: &'a DeviceRef<'ctx>, pub(in crate::qwen_forward) rope: &'x RopeConstants, pub(in crate::qwen_forward) blobs: &'x ExpertBlobSizes, pub(in crate::qwen_forward) max_cells: usize, @@ -227,7 +233,7 @@ impl<'a, 'ctx> AssembleInputs<'_, 'a, 'ctx> { owners: QsaOwners<'ctx>, max_t: usize, after_prepare: &mut impl FnMut() -> std::result::Result<(), Error>, - ) -> std::result::Result, AssembleFailure<'ctx>> { + ) -> std::result::Result, AssembleFailure<'ctx>> { let (prepared, owners) = self.prepare(owners, max_t, after_prepare)?; self.record(prepared, owners, max_t) } @@ -240,7 +246,7 @@ impl<'a, 'ctx> AssembleInputs<'_, 'a, 'ctx> { mut owners: QsaOwners<'ctx>, max_t: usize, after_prepare: &mut impl FnMut() -> std::result::Result<(), Error>, - ) -> std::result::Result<(Prepared<'a, 'ctx>, QsaOwners<'ctx>), AssembleFailure<'ctx>> { + ) -> std::result::Result<(Prepared<'ctx>, QsaOwners<'ctx>), AssembleFailure<'ctx>> { let refused = |failure, owners| AssembleFailure { failure, owners: Some(owners), window_cap: None }; // The window graphs bind each layer's streamed-KV resolver. The prompt path initialises it lazily on its // first append, so a ONE-token prompt on a fresh stack reaches the capture with none: initialise it here @@ -265,10 +271,10 @@ impl<'a, 'ctx> AssembleInputs<'_, 'a, 'ctx> { /// From here the owners move into the journal; a failure gives them back when the journal can. fn record( &self, - prepared: Prepared<'a, 'ctx>, + prepared: Prepared<'ctx>, owners: QsaOwners<'ctx>, max_t: usize, - ) -> std::result::Result, AssembleFailure<'ctx>> { + ) -> std::result::Result, AssembleFailure<'ctx>> { let (geometry, mut canonical, gamma) = prepared; let (slots, indices, mapped) = split_owners(owners)?; let p = super::original_serve_profile::span("assemble.qsa_journal"); @@ -311,8 +317,8 @@ fn ensure_resolvers<'ctx>( /// Close the verifier (drains both streams, drops every graph and aggregate) and take the physical QSA /// owners back from the journal. -pub(in crate::qwen_forward) fn disassemble<'a, 'ctx>( - resources: DecodeResources<'a, 'ctx>, +pub(in crate::qwen_forward) fn disassemble<'ctx>( + resources: DecodeResources<'ctx>, ) -> std::result::Result, ServeFailure> { let DecodeResources { verifier, qsa, slots } = resources; let closed = verifier.close(); @@ -324,7 +330,7 @@ pub(in crate::qwen_forward) fn disassemble<'a, 'ctx>( } } -fn recover<'a, 'ctx>(qsa: Rc>, slots: [usize; 12]) -> Option> { +fn recover<'ctx>(qsa: Rc>, slots: [usize; 12]) -> Option> { let (indices, mapped) = OriginalVerifyQsaJournal::into_owners(qsa).ok()?; place_owners(slots, indices, mapped) } @@ -345,6 +351,7 @@ fn place_owners<'ctx>( 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/assemble_parts.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_verifier/assemble_parts.rs index daf31953..d515e56f 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_verifier/assemble_parts.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_verifier/assemble_parts.rs @@ -3,22 +3,21 @@ #[allow(unused_imports)] use super::*; -use leleka_cuda_driver::{OriginalNativeEmbedRows, OriginalVerifyCanonicalGdn, OriginalVerifyGeometry}; +use leleka_cuda_driver::{DeviceRef, OriginalNativeEmbedRows, OriginalVerifyCanonicalGdn, OriginalVerifyGeometry}; -type Window<'a, 'ctx> = OriginalVerifyWindowResources<'a, 'ctx>; -type Qsa<'a, 'ctx> = Rc>; +type Window<'ctx> = OriginalVerifyWindowResources<'ctx>; +type Qsa<'ctx> = Rc>; /// The physical QSA owners split into their slots, resident indices and mapped journals (twelve layers each). pub(super) type QsaParts<'ctx> = ([usize; 12], [OriginalQsaResidentIndex<'ctx>; 12], [OriginalQsaMappedJournal<'ctx>; 12]); /// What the assembly checks before it consumes the owners: the geometry, the canonical GDN image and the QSA gamma. -pub(super) type Prepared<'a, 'ctx> = - (OriginalVerifyGeometry, OriginalVerifyCanonicalGdn<'ctx>, [&'a DeviceBuffer<'ctx>; 12]); +pub(super) type Prepared<'ctx> = (OriginalVerifyGeometry, OriginalVerifyCanonicalGdn<'ctx>, [DeviceRef<'ctx>; 12]); impl<'a, 'ctx> AssembleInputs<'_, 'a, 'ctx> { /// Everything that can be refused WITHOUT consuming the owners. - pub(super) fn prepare_assembly(&self, max_t: usize) -> std::result::Result, ServeFailure> { + pub(super) fn prepare_assembly(&self, max_t: usize) -> std::result::Result, ServeFailure> { let (binding, dense, context) = (self.binding, self.weights.dense, self.context); let (base, ple_history, blobs) = (self.base, self.ple_history, self.blobs); let geometry = verify_geometry(max_t, self.max_cells, blobs)?; @@ -64,25 +63,25 @@ pub(super) struct RecordEnv<'x, 'a, 'ctx> { pub(super) context: &'ctx Context<'ctx>, pub(super) weights: &'x VerifyWeights<'a, 'ctx>, pub(super) output: &'x OriginalNativeOutput<'ctx>, - pub(super) ple_history: &'a DeviceBuffer<'ctx>, + pub(super) ple_history: &'a DeviceRef<'ctx>, pub(super) blobs: &'x ExpertBlobSizes, pub(super) geometry: OriginalVerifyGeometry, - pub(super) qsa: &'x Qsa<'a, 'ctx>, + pub(super) qsa: &'x Qsa<'ctx>, } -type Aggregates<'a, 'ctx> = (Vec>>, Window<'a, 'ctx>); +type Aggregates<'ctx> = (Vec>>, Window<'ctx>); /// One window aggregate of width `t` over the verifier's bank and the canonical GDN image. fn aggregate<'a, 'ctx>( env: &RecordEnv<'_, 'a, 'ctx>, - verifier: &mut OriginalVerifier<'ctx, Window<'a, 'ctx>>, + verifier: &mut OriginalVerifier<'ctx, Window<'ctx>>, canonical: &mut OriginalVerifyCanonicalGdn<'ctx>, t: usize, -) -> std::result::Result, ServeFailure> { +) -> std::result::Result, ServeFailure> { let (binding, context, weights) = (env.binding, env.context, env.weights); let dense = weights.dense; let gdn_weights = dense.original_verify_gdn_weights(binding)?; - let journal = verifier.bank()?.gdn_journal(canonical, gdn_weights, Some(env.ple_history))?; + let journal = verifier.bank()?.gdn_journal(canonical, gdn_weights, Some(env.ple_history.clone()))?; let head = env.output.rows(binding, t)?; let resources = OriginalVerifyResources::new(context, journal, Rc::clone(env.qsa), head)?; let embed = env.output.embedding(binding)?.rows(t)?; @@ -92,10 +91,10 @@ fn aggregate<'a, 'ctx>( /// The window's resources: the embedding rows, the projections, the GR, the QSA and the MoE of the verify path. fn window_over<'a, 'ctx>( env: &RecordEnv<'_, 'a, 'ctx>, - resources: OriginalVerifyResources<'a, 'ctx>, + resources: OriginalVerifyResources<'ctx>, embed: OriginalNativeEmbedRows<'ctx>, t: usize, -) -> std::result::Result, ServeFailure> { +) -> std::result::Result, ServeFailure> { let (binding, context, weights, geometry) = (env.binding, env.context, env.weights, &env.geometry); let dense = weights.dense; let window = OriginalVerifyWindowResources::new(context, resources, embed, env.blobs.layout()?, t)? @@ -107,8 +106,8 @@ fn window_over<'a, 'ctx>( /// The QSA and MoE attachments of the verify path. fn with_qsa_moe<'a, 'ctx>( env: &RecordEnv<'_, 'a, 'ctx>, - window: Window<'a, 'ctx>, -) -> std::result::Result, ServeFailure> { + window: Window<'ctx>, +) -> std::result::Result, ServeFailure> { let (binding, weights, geometry) = (env.binding, env.weights, &env.geometry); let dense = weights.dense; let window = window.with_qsa(dense.original_verify_qsa(binding, geometry)?)?; @@ -119,10 +118,10 @@ fn with_qsa_moe<'a, 'ctx>( /// The aggregates of the windows T = 1..=max_t and of the commit graph. fn build_aggregates<'a, 'ctx>( env: &RecordEnv<'_, 'a, 'ctx>, - verifier: &mut OriginalVerifier<'ctx, Window<'a, 'ctx>>, + verifier: &mut OriginalVerifier<'ctx, Window<'ctx>>, canonical: &mut OriginalVerifyCanonicalGdn<'ctx>, max_t: usize, -) -> std::result::Result, ServeFailure> { +) -> std::result::Result, ServeFailure> { let mut windows = Vec::new(); windows.try_reserve_exact(max_t).map_err(|_| Error::InputAllocation)?; for t in 1..=max_t { @@ -134,12 +133,12 @@ fn build_aggregates<'a, 'ctx>( /// Record every window graph and the commit graph. A refusal closes the verifier and names the narrower window worth /// retrying. -fn record_windows<'a, 'ctx>( - mut verifier: OriginalVerifier<'ctx, Window<'a, 'ctx>>, - aggregates: Aggregates<'a, 'ctx>, +fn record_windows<'ctx>( + mut verifier: OriginalVerifier<'ctx, Window<'ctx>>, + aggregates: Aggregates<'ctx>, shape: (usize, u8), window_cap: &mut Option, -) -> std::result::Result>, ServeFailure> { +) -> std::result::Result>, ServeFailure> { let (max_t, pcie_mode) = shape; let (mut windows, commit) = aggregates; let _ = leleka_cuda_driver::original_capture_timing::take(); @@ -185,9 +184,9 @@ pub(super) fn capture_verifier<'a, 'ctx>( canonical: &mut OriginalVerifyCanonicalGdn<'ctx>, shape: (usize, u8), window_cap: &mut Option, -) -> std::result::Result>, ServeFailure> { +) -> std::result::Result>, ServeFailure> { let p = super::super::original_serve_profile::span("assemble.verifier_new"); - let mut verifier = OriginalVerifier::<'ctx, Window<'a, 'ctx>>::new(env.context, env.geometry)?; + let mut verifier = OriginalVerifier::<'ctx, Window<'ctx>>::new(env.context, env.geometry)?; drop(p); let p = super::super::original_serve_profile::span("assemble.aggregates"); let built = build_aggregates(env, &mut verifier, canonical, shape.0); @@ -207,7 +206,7 @@ impl<'x, 'a, 'ctx> RecordEnv<'x, 'a, 'ctx> { pub(super) fn new( inputs: &AssembleInputs<'x, 'a, 'ctx>, geometry: OriginalVerifyGeometry, - qsa: &'x Qsa<'a, 'ctx>, + qsa: &'x Qsa<'ctx>, ) -> Self { Self { binding: inputs.binding, 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 index 081a228a..ea5f9662 100644 --- 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 @@ -2,40 +2,59 @@ //! //! `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: until `OriginalVerifier` has them (the -//! speed session's part of the feature) both refuse, so a kept assembly is retired at once and every request records -//! its graphs, exactly as with the switch off. When the bank has them, only these two bodies change. +//! 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; -impl<'a, 'ctx> HeldAssembly, QsaOwners<'ctx>> for DecodeResources<'a, 'ctx> { - /// `OriginalVerifier::park` (drain both streams, wait a pending commit): not there yet. +/// 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 { - false + self.verifier.park().is_ok() } fn lend(&mut self) -> Option> { - let (indices, mapped) = self.qsa.lend().ok()?; - place_owners(self.slots, indices, mapped) + 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(std::array::from_fn(|_| None)) }; + 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)), } } - /// `OriginalVerifier::rearm` (reseed the canonical image and the PLE history in place, reset the window state and - /// the flags): not there yet. - fn rearm(&mut self, _seed: &OriginalVerifiedBase<'ctx>) -> bool { - false + 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) } } diff --git a/deploy/rust-runtime/profiles/rtx5090-32g-file.json b/deploy/rust-runtime/profiles/rtx5090-32g-file.json index 7a1c878d..8b30d197 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"}, + "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"}, "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 6a3fe3d7..abe5ae51 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_PLE_DIRECT": "0", "LELEKA_ORIGINAL_SERVE_GGUF_PLE": "1"}, + "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_PLE_DIRECT": "0", "LELEKA_ORIGINAL_SERVE_GGUF_PLE": "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 3ae2c0a7..4509ba03 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). 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"}, + "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"}, "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/experiments/decode-graph-reuse.md b/docs/experiments/decode-graph-reuse.md index d62d7d5a..99af17b7 100644 --- a/docs/experiments/decode-graph-reuse.md +++ b/docs/experiments/decode-graph-reuse.md @@ -1,12 +1,11 @@ # Decode graph reuse across requests (ledger row Q7) -Status: part 1 and the stack protocol are coded behind `LELEKA_DECODE_GRAPH_REUSE` (off by default, typed setting -`serve.decode_graph_reuse`): the reuse policy (`DecodeGraphKey`, `GraphReuse::begin` / `end`, `HeldAssembly`), the QSA -owner loan in the driver journal (B2), the drafter-binding decision (B3), the shared-expert pin and weights epoch, all -tested on the lifecycle fake. The real stack does not keep an assembly yet: B1 (the assembly borrows the stack) is the -speed session's handle change in `original_verify_window_{moe,gr,proj,qsa}.rs`, and the verify bank's `park` / `rearm` / -`reseed` (part 2) is theirs too; `DecodeResources::park` and `rearm` refuse until then. With the switch on, `open` says so -on stderr and every request records its graphs, as without the switch. No speedup claim. +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 @@ -91,9 +90,9 @@ Owners of the epochs: 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. What is not done and why +## 4. The pieces: handles (speed session), owner loan, drafter, stack wiring -### B1. The held assembly cannot borrow the stack (blocked: forbidden files) +### 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 @@ -142,7 +141,7 @@ owners are out, so a graph run, a window arm or a commit over a lent journal fai `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 in the policy, not in the real stack) +### 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`). @@ -152,23 +151,46 @@ retirement (key change, owners moved, refused re-arm, `invalidate`) and per requ 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, mechanical once the bank has `park` / `rearm` and the assembly stops borrowing the stack (B1) +### The stack side (wired) -1. `OriginalServeStack` gets `held: GraphReuse>` (`GraphReuse::new(settings.serve.decode_graph_reuse)`), - and an `owners_epoch`/`weights_epoch` source for the key (`MoeWeightCache::weights_epoch()`, pinning via - `pin_for_window(&shared)` when a set is kept and `unpin_window()` on retire). -2. `decode_phase`: build `DecodeGraphKey` in `decode_stage` (from `verifier_max_t`, `max_cells`, `pcie_mode`, tier present, - `qsa_cluster_requested`, the epochs). Replace `executor.take_qsa_owners()` + `assemble_decode` by - `held.begin((&key, &base), owners, retire)`: `Reused(resources)` skips `AssembleInputs::assemble`; - `Record { owners, .. }` assembles as today over those owners; `Lost` marks the stack broken. -3. `teardown_decode`: `match held.end(&key, resources, |owners| home.adopt(owners))`: `Kept` returns (no `release_mtp`, no - `disassemble`); `Retire { assembly, owners_home: false }` is the current path (`release_mtp`, `disassemble`, adopt); - `Retire { owners_home: true }` calls `release_mtp` and drops the assembly (the owners are already home). -4. `held.invalidate(retire)` on `reconfigure`, `reset_expert_tier`, a broken stack and `narrow_window_policy`. -5. With the switch off `GraphReuse::end` always returns `Retire { owners_home: false }` and `begin` returns - `Record { Disabled }` with the owners untouched: the path is the current one. +* `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. -### Scenarios the real implementation must pass (the lifecycle fake runs them: `backend/lifecycle_tests/graphs.rs`) +### 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 | | --- | --- | @@ -181,7 +203,7 @@ a re-arm must clear it (today `set_prompt_len` does; check `OriginalMtpActor` fo | `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 (speed session's files; the policy codes against `Reusable::rearm`) +### 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*`): @@ -226,10 +248,21 @@ The policy retires and re-records on any `Err` or `false`, so a partial re-arm i ## 5. Validation (GPU, orchestrator) -Identity of greedy output reuse-on vs off over N requests with different prompts and lengths and a forced eviction in between -(must re-record, and match); paired A/B of `decode.assemble`, `decode.disassemble`, `record.capture`, `record.instantiate`, -`record.modules`, the first-draft capture in `draft.*`, and end-to-end request time; VRAM at the decode low-water mark (a kept -set holds the graph pool during prefill: the prefill arena and loan ladder budget shrink by the pool size). +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 diff --git a/docs/experiments/step-ledger.md b/docs/experiments/step-ledger.md index 56f4cb26..6979c821 100644 --- a/docs/experiments/step-ledger.md +++ b/docs/experiments/step-ledger.md @@ -1,216 +1,249 @@ -# Step ledger: every place where Leleka (LEL) loses to vanilla Strata (VANL), in pipeline order, request to decode - -Owner rule (2026-11-09): every step where we lose is recorded, even 0.02 ms. A row is never dropped as "below noise", "under 1 %", "neutral" or "NO-GO because small". This file is the single register; the narrative and the measurements behind it stay in `docs/experiments/codex-compare-speed-gap.md` (cited as *gap doc*). - -**Arms.** LEL = release package `leleka-0.1.0-17e372944279` (CUPTI `CL.1`: plus the lever 1 switches `ATTN_DAILY`, `GU_SWIGLU`). VANL = vanilla 0.2.6, tail skip and CPU prefill share off. Differences are LEL minus VANL: positive = we are slower. "ms/round" means per speculation round of the verify window; one round is 17.9 ms in LEL and 15.9 ms in VANL in the CUPTI window. - -**Closing rule.** A row is `fixed` only with (1) a measured *section* delta of that very step (CUPTI window or PROFILE lines of the step, not the end-to-end A/B, which cannot see 0.05 ms), (2) identity (bitwise for non-lossy changes: `draftround-id.sh` top-16 logprob rows and draft trace; placement-class changes need the gate against the control placement), and (3) the end-to-end paired A/B of the whole set of fixes. Statuses: `open` (nothing done), `fixing` (code or run exists, closing evidence incomplete), `fixed`, `proved-equal` (measured equal, or measured in our favour: the sign is in the difference column). - -**Owners.** `device` = verify graph and everything on the GPU (this register, session `hexagonal-44f3f4`); `hex-finish` = host, draft and prefill. - -**Sources.** `CUPTI` = one 15 s window over replay request 29 (67k context), runs `/data/leleka-e2e/spd-gap/runs/cupti/{CL.1,CM.1,VANL}/win-r29.lct`, scripts `scripts/e2e/codex/speed/{cupti_layer_phases,cupti_doorbell_latency,cupti_verify_graph,cupti_stream_overlap,kernel_roles}.py` and `decode_rounds.py`. One window per arm: the greedy trajectories differ a little (hit mix, window width), so a per-kernel mean can carry the entry mix. `PROFILE` = the product's own `LELEKA_SERVE_PROFILE` lines (`runs/main/P`). `LOG` = engine logs of the replay cells. `ORCH` = figure given by the orchestrator session, not re-derived here. - -**Order (owner rule 2026-11-09).** The ledger follows the request linearly, from the request into the engine, through prefill, to the decode round (draft, verify graph, accept, commit, publication of the tokens, next round). Work goes in this order: step N is closed (`fixed`, or `proved-equal` with a section measurement) before step N+1. Prefill and host are led by `hex-finish`, the decode part (verify graph, accept on the device, branch overlap, their streams) by `device`; both run in parallel, each in its own order. After each group of steps comes the end-to-end paired A/B of the group. - -Row ids are stable (they are cited in `codex-compare-speed-gap.md` and in reports); the section decides the order, not the number. - - -## A. Request into the engine (HTTP and gateway, tokenizer, prefix cache) - -No per-step figure exists for A1-A3; each is a `not measured` row that needs a section measurement before it can be closed. - -| id | step | LEL | VANL | difference | source | owner | status | -| --- | --- | ---: | ---: | ---: | --- | --- | --- | -| 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 | fixing (probe queued) | -| 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 | fixing (probe queued) | -| 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 | fixing (VANL from its existing logs; only if the LEL sum is larger, one run of the instrumented copy of vanilla gives the split) | -| 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 - -| 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: 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 in job `prefill-ladder-ab-pairs-6-10` | LOG | hex-finish | fixing (profile switch ready, commit after job `prefill-ladder-ab-pairs-6-10`) | -| 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: 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) | -| 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) | -| 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 (code `prefill.refill`, 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 hand-over: graph assembly per request (code `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 | hex-finish | fixing (code 278d67eeb, switch `LELEKA_DECODE_GRAPH_REUSE` off by default, identity and section delta pending): key, policy (`begin`/`end`), QSA owner loan in the journal, drafter release on retire and shared-expert pin are in and tested on the lifecycle fake; the stack does not keep the graphs yet, waiting on the speed session: handles instead of `&'a DeviceBuffer` in `original_verify_window_*` (the assembly borrows the stack) and the verify bank's `park`/`rearm`/`reseed`; design and scenarios `docs/experiments/decode-graph-reuse.md` | -| 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 | -| 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 - -Round-level totals first (they are the sum of the steps below). - -| id | step | LEL | VANL | difference | source | owner | status | -| --- | --- | ---: | ---: | ---: | --- | --- | --- | -| R1 | round wall (graph start to start) | 17.864 | 15.886 | +1.978 | CUPTI | device | open | -| R4 | GPU idle over the round | 2.574 | 3.103 | -0.529 (busy 85.6 % against 80.5 %) | CUPTI | device | proved-equal (LEL ahead) | -| Q9 | round count: tokens per round | 3.59-3.66 | 2.95 | +0.64..+0.71 tokens per round (+22 %): our adaptive window pays +3.1 ms for +0.65 tokens | LOG | device | proved-equal (net +2.8 % decode, kept) | - -## C1. Draft (chain from the previous commit to the verify window's tokens) - -| id | step | LEL | VANL | difference | source | owner | status | -| --- | --- | ---: | ---: | ---: | --- | --- | --- | -| 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` | +# Step ledger: every place where Leleka (LEL) loses to vanilla Strata (VANL), in pipeline order, request to decode + +Owner rule (2026-11-09): every step where we lose is recorded, even 0.02 ms. A row is never dropped as "below noise", "under 1 %", "neutral" or "NO-GO because small". This file is the single register; the narrative and the measurements behind it stay in `docs/experiments/codex-compare-speed-gap.md` (cited as *gap doc*). + +**Arms.** LEL = release package `leleka-0.1.0-17e372944279` (CUPTI `CL.1`: plus the lever 1 switches `ATTN_DAILY`, `GU_SWIGLU`). VANL = vanilla 0.2.6, tail skip and CPU prefill share off. Differences are LEL minus VANL: positive = we are slower. "ms/round" means per speculation round of the verify window; one round is 17.9 ms in LEL and 15.9 ms in VANL in the CUPTI window. + +**Closing rule.** A row is `fixed` only with (1) a measured *section* delta of that very step (CUPTI window or PROFILE lines of the step, not the end-to-end A/B, which cannot see 0.05 ms), (2) identity (bitwise for non-lossy changes: `draftround-id.sh` top-16 logprob rows and draft trace; placement-class changes need the gate against the control placement), and (3) the end-to-end paired A/B of the whole set of fixes. Statuses: `open` (nothing done), `fixing` (code or run exists, closing evidence incomplete), `fixed`, `proved-equal` (measured equal, or measured in our favour: the sign is in the difference column). + +**Owners.** `device` = verify graph and everything on the GPU (this register, session `hexagonal-44f3f4`); `hex-finish` = host, draft and prefill. + +**Sources.** `CUPTI` = one 15 s window over replay request 29 (67k context), runs `/data/leleka-e2e/spd-gap/runs/cupti/{CL.1,CM.1,VANL}/win-r29.lct`, scripts `scripts/e2e/codex/speed/{cupti_layer_phases,cupti_doorbell_latency,cupti_verify_graph,cupti_stream_overlap,kernel_roles}.py` and `decode_rounds.py`. One window per arm: the greedy trajectories differ a little (hit mix, window width), so a per-kernel mean can carry the entry mix. `PROFILE` = the product's own `LELEKA_SERVE_PROFILE` lines (`runs/main/P`). `LOG` = engine logs of the replay cells. `ORCH` = figure given by the orchestrator session, not re-derived here. + +**Order (owner rule 2026-11-09).** The ledger follows the request linearly, from the request into the engine, through prefill, to the decode round (draft, verify graph, accept, commit, publication of the tokens, next round). Work goes in this order: step N is closed (`fixed`, or `proved-equal` with a section measurement) before step N+1. Prefill and host are led by `hex-finish`, the decode part (verify graph, accept on the device, branch overlap, their streams) by `device`; both run in parallel, each in its own order. After each group of steps comes the end-to-end paired A/B of the group. + +Row ids are stable (they are cited in `codex-compare-speed-gap.md` and in reports); the section decides the order, not the number. + + +## A. Request into the engine (HTTP and gateway, tokenizer, prefix cache) + +No per-step figure exists for A1-A3; each is a `not measured` row that needs a section measurement before it can be closed. + +| id | step | LEL | VANL | difference | source | owner | status | +| --- | --- | ---: | ---: | ---: | --- | --- | --- | +| 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 | fixing (probe queued) | +| 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 | fixing (probe queued) | +| 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 | fixing (VANL from its existing logs; only if the LEL sum is larger, one run of the instrumented copy of vanilla gives the split) | +| 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 + +| 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: 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 in job `prefill-ladder-ab-pairs-6-10` | LOG | hex-finish | fixing (profile switch ready, commit after job `prefill-ladder-ab-pairs-6-10`) | +| 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: 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) | +| 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) | +| 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 (code SHA, 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` | +| 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 | +| 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 + +Round-level totals first (they are the sum of the steps below). + +| id | step | LEL | VANL | difference | source | owner | status | +| --- | --- | ---: | ---: | ---: | --- | --- | --- | +| R1 | round wall (graph start to start) | 17.864 | 15.886 | +1.978 | CUPTI | device | open | +| R4 | GPU idle over the round | 2.574 | 3.103 | -0.529 (busy 85.6 % against 80.5 %) | CUPTI | device | proved-equal (LEL ahead) | +| Q9 | round count: tokens per round | 3.59-3.66 | 2.95 | +0.64..+0.71 tokens per round (+22 %): our adaptive window pays +3.1 ms for +0.65 tokens | LOG | device | proved-equal (net +2.8 % decode, kept) | + +## C1. Draft (chain from the previous commit to the verify window's tokens) + +| id | step | LEL | VANL | difference | source | owner | status | +| --- | --- | ---: | ---: | ---: | --- | --- | --- | +| 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` | | 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`) | | 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 | - -## C2. Verify graph: embed, 48 layers (mixer half, FFN half), final write and head - -Structure first, then the layer steps in graph order: embed (R7), mixer half (V3 and the kernels in it), FFN half (V2/V4 and the kernels in it), tail (R8). - -| id | step | LEL | VANL | difference | source | owner | status | -| --- | --- | ---: | ---: | ---: | --- | --- | --- | -| V1 | streams in the verify graph | 1 | 11 | wall time with two or more streams active: 0 against 2.03 ms | CUPTI | device | fixing | -| R2 | verify graph GPU span | 13.561 | 11.743 | +1.818 | CUPTI | device | open | -| V9 | verify graph kernel time sum | 13.349 | 13.728 | -0.379 (VANL runs kernels concurrently: its span is shorter than its sum) | CUPTI | device | proved-equal (LEL ahead) | -| V8 | launches per verify graph | 2061 | 2098 | -37 | CUPTI | device | proved-equal (LEL ahead) | -| R5 | verify graph launch call (host) | 1.485 | 1.509 | -0.024 | CUPTI | device | proved-equal (LEL ahead) | -| R6 | idle inside the verify graph (2052 gaps against 1193 per round, mean 0.1 us) | 0.213 | 0.119 | +0.094 | CUPTI | device | open | -| R7 | first doorbell after graph start (embed, first layer mixer) | 0.132 | 0.117 | +0.015 | CUPTI | device | open | -| V3 | mixer phase (`add_hits` end to next doorbell) | 6.366 | 5.963 | +0.403 | CUPTI | device | fixing | -| V3a | GDN gates and gate projection on side streams (`LELEKA_SM120_SIDE_MIXER=1`, existing, off) | mixer 5.913, round 17.508 (`CM.1`) | mixer 5.963 | section delta mixer -0.453, round -0.356; mixer phase now equal to VANL | CUPTI | device | fixing (identity `spd-sqid1`, A/B `spd-sm1` queued/running) | -| V3b | QSA indexer chain and query chain on side streams (`LELEKA_SM120_SIDE_QSA`, code `0c30105d4`, off) | in line | 0.509 ms of overlap with the main stream (main+qsa) | not yet measured; VANL mixer phase is already matched by V3a | CUPTI (VANL) | device | fixing (window `spd-sqw`, identity `spd-sqid1`) | -| K6 | attention role in total (norm/RoPE, appends, scores, top-k, resolve, chunk, merge, gate) | 1.357 | 1.125 | +0.232 | CUPTI role table | device | open | -| K1 | attention decode chunk (`leleka_qsa_decode_chunk_daily` 18.3 us, 12 per graph) against `attn_chunk_kernel_pre75` (17.1 us) | 0.220 | 0.206 | +0.014 | CUPTI | device | open | -| K2 | indexer block scores (`leleka_qsa_decode_scores` 14.2 us against `block_scores_multi` 17.1 us) | 0.170 | 0.205 | -0.035 | CUPTI | device | proved-equal (LEL ahead) | -| K3 | block top-k cluster (17.3 us against 18.0 us) | 0.208 | 0.216 | -0.008 | CUPTI | device | proved-equal (LEL ahead) | -| K4 | KV miss copy / copy kernel (11.1 us against 11.6 us) | 0.133 | 0.139 | -0.006 | CUPTI | device | proved-equal (LEL ahead) | -| K5 | KV resolve (7.8 us against 8.4 us) | 0.094 | 0.100 | -0.006 | CUPTI | device | proved-equal (LEL ahead) | -| K7 | GDN role in total (step, conv, ab, commit) | 0.914 | 0.759 | +0.155 | CUPTI role table | device | open | -| K7a | GDN step/norm in the verify graph (`verify_gdn_step_norm_multi` 6.1 us against `gdn_step_norm_multi` 6.2 us, but 36 against 30.9 launches) | 0.220 | 0.191 | +0.029 | CUPTI | device | open | -| K7b | GDN alpha/beta (`chain_gdn_ab_multi` 36 x 8.5 us against `gdn_ab_multi` 22.9 x 10.5 us plus the rest) | 0.307 | 0.344 | -0.037 | CUPTI | device | proved-equal (LEL ahead) | -| K12 | dense projections, lm head, MMVQ/MMVF role (`head_n*`, `bf16_f32_mmvf_multi`) | 3.892 | 4.589 | -0.697 | CUPTI | device | proved-equal (LEL ahead) | -| S1 | `ATTN_DAILY` (decode attention) | on since lever 1 | on | paired decode +1.85 % with S2 (CI excludes zero), identity PASS (teacher-forced, 2057 of 2057 rows); no section delta of its own | gap doc lever 1 | device | fixing (needs a CUPTI section delta) | -| S3 | `SIDE_MIXER=2` | GDN part off by default, QSA part not ported before `0c30105d4` | on | V3a, V3b | CUPTI | device | fixing | -| S8 | `MMVQ_IL` (2-4 and 5-8 columns) | not ported | on | estimate 0.10-0.40; CUPTI role K12 shows our dense projections faster by 0.70 in total | upstream plan | device | open | -| S10 | batched K/V append and indexer append | per row (`verify_qsa_append_analytic` 138 x 1.04 us, `mtp_original_append` 49 x 1.6 us) | batched (`append` 12 x 3.0 us, `kv_append_q8` 14.6 x 2.2 us) | estimate 0.05-0.10 | upstream plan, CUPTI | device | open | -| V2 | FFN phase (doorbell to `add_hits` end) | 6.600 | 5.293 | +1.307 | CUPTI | device | open | -| V4 | doorbell to first routed expert (gate/up) start, us | 27.6 | 15.0 | +12.6 us x 48 = +0.60 ms | CUPTI | device | fixing | -| V4a | shared expert on a side stream, forked after the doorbell, joined before the combine (`LELEKA_SM120_SIDE_SHARED`, code `255159a89`, off) | 27.6 us before the first expert | 15.0 us | section delta pending (`spd-sqw` window `CE.1`) | CUPTI | device | fixing | -| V4b | routed experts on their own branch (VANL: plan wait, VRAM experts, `fetch_blobs`, CPU wait, `add_hits` on a side stream; main stream does the shared expert and the next norm) | all on the capture stream | branch | rest of V2 after V4a, not yet known | CUPTI | device | open | -| V4c | norms and hyper-connection reads (`gr_norm_split`, `gr_down`, `gr_up`) as separate branches | main stream | main stream (VANL does not branch them; a layer's `gr_*` chain stays on the main stream) | no structural difference; kernels in K8..K10 | CUPTI | device | proved-equal | -| V5 | flag waits on the CPU leg (`verify_wait_flag_ge` 96 x 26.9 us + `chain_wait_copy_i32` 48 x 5.4 us against `wait_flag_ge` 144 x 8.1 us) | 2.836 | 1.160 | +1.676 | CUPTI | device | open | -| V6 | PCIe fetch and CPU-row hand-over (doorbell, mapped copies, `fetch_blobs`, `add_hits`, `rebase_ptrs`) | 0.488 | 2.109 | -1.621 | CUPTI | device | proved-equal (LEL ahead) | -| V7 | V5 + V6, the whole miss-leg handling | 3.324 | 3.269 | +0.055 (+0.17 by an earlier count of the same sets) | CUPTI | device | open | -| K11 | routed experts in the verify graph, role total (gate/up/SwiGLU, down) | 2.507 | 2.484 | +0.023 (entry mix differs; at equal entry counts LEL is faster: `window_moe_down_20` 13.6 us with 40 entries against 17.4 us, `sm120_moe_gu_swiglu_22` 12.3 us with 50 entries against 26 us with 40) | CUPTI | device | open | -| K15 | hit tally `add_hits` (48 x 1.2 us against 48 x 1.3 us) | 0.059 | 0.063 | -0.004 | CUPTI | device | proved-equal (LEL ahead) | -| S2 | `GU_SWIGLU` (routed expert gate/up + SwiGLU + q8_1) | on since lever 1 | on | as S1 | gap doc lever 1 | device | fixing (needs a CUPTI section delta) | -| S7 | sub16 routed-expert kernels beyond `GU_SWIGLU` | warp-per-row | sub16 | estimate 0.20-0.35; the CUPTI pair K11 does not show LEL slower, so this must be re-measured by kernel before any work | upstream plan | device | open | -| S11 | float4 combine | not ported | `combine_k10_vec4` 50.6 x 1.2 us | estimate 0.05-0.10 | upstream plan | device | open | -| K8 | hyper-connection down (`chain_gr_down_t2w8_nb4` 11.1 us against `gr_down_staged` 11.5 us) | 1.063 | 1.112 | -0.049 | CUPTI | device | proved-equal (LEL ahead) | -| K9 | hyper-connection up (`chain_gr_up8` 8.5 us against `gr_up75` + `gr_up_multi` variants) | 0.817 | 0.877 | -0.060 | CUPTI | device | proved-equal (LEL ahead) | -| K10 | hyper-connection split (`chain_gr_split` 96 x 3.1 us against `gr_norm_split` 97 x 2.9 us) | 0.299 | 0.280 | +0.019 | CUPTI | device | open | -| S4 | `GR_DOWN_TG` | 9.7 us (`chain_gr_down_t2w8_nb4`) | 18.4 us | -8.7 us | gap doc | device | proved-equal (LEL ahead) | -| S5 | `GR_UP75` (hoisted row loads) | partial | on | estimate 0.05-0.10 | upstream plan | device | open | -| K14 | small kernels (norms, PLE, copies, sampler) | 0.049 | 0.253 | -0.204 | CUPTI role table | device | proved-equal (LEL ahead) | -| R8 | tail after the last layer's `add_hits` (final write, head, argmax) | 0.463 | 0.373 | +0.090 | CUPTI | device | open | -| S9 | `HEAD_MIX_MULTI` | not ported | on | estimate 0.06-0.10 | upstream plan | device | open | - -## C3. Accept (verdict of the window on the device) and the hand-over to the next draft - -| id | step | LEL | VANL | difference | source | owner | status | -| --- | --- | ---: | ---: | ---: | --- | --- | --- | -| O7 | accept to draft: host chain from the end of the verify graph to the first draft kernel (code `finish_window`, `verifier_head_after_drain`, `validate_completed_logits`, commit enqueue, `launch_draft`) | CUPTI `CL.1`, per round, from the end of the verify graph: 5.6 us compute-stream sync returns; 8.3-14.9 two `cuLaunchKernel` (`verify_clear_status`, `verify_scan_logits`); 14.2-22.6 `cuStreamSynchronize`; 23.1-38.1 `cuMemcpyDtoH` (4 B); 38.3-39.4 `cuCtxSynchronize`; so the logits finite check is 3 syncs + 1 DtoH + 2 launches = ~34 us; then commit `cuGraphLaunch` (182 kernels, call 107 us under CUPTI) and the draft round graph `cuGraphLaunch` (168 kernels, 138 us under CUPTI); first draft kernel `mtp_full_copy_i32_from_mapped` at median 292 us. PROFILE (no tracer, `runs/dc1`, 13,530 rounds): `drv.head` 0.033 + `drv.commit_enqueue` 0.005 + `draft.launch` 0.019 + `mtp.launch_record`/`stage_enqueue` 0.015 = ~0.07 ms of host time | VANL `win-r29`: graph end, then `cudaGraphLaunch` of a 12-kernel graph (22 us call) and of a 74-kernel graph (101 us call), first kernel at median 21.7 us, no logits scan kernels | CUPTI +0.27 ms; PROFILE host 0.07 ms | CUPTI, PROFILE | hex-finish | fixing: (1) the 34 us logits check goes to the device (speed session's agent); (2) the rest of the CUPTI gap is graph-launch call time, which grows with the node count (182 + 168 kernels in LEL against 12 + 74 in VANL) and which the tracer inflates (PROFILE shows 0.005 and 0.019 ms for the same calls), so it cannot be read as host time without a tracer-free measure: next, GPU-event stamps under `LELEKA_SERVE_PROFILE` (verify end, draft round graph start); (3) the draft already does not wait for the commit event (`draft_after_commit` off), so no ordering change is open there | - -## C4. Commit (accepted-prefix graph, GDN replay, QSA tail restore, re-append, PLE history) - -| id | step | LEL | VANL | difference | source | owner | status | -| --- | --- | ---: | ---: | ---: | --- | --- | --- | -| S6 | `COMMIT_BATCH` + state-only GDN commit (commit graph 158 kernels, 0.463 ms) | not ported | on (`gdn_step_commit_layers` 0.9 per round, 0.095 ms) | estimate 0.25-0.35 | upstream plan, CUPTI | device | open | -| O11 | commit graph (158 kernels, `verify_gdn_conv_commit` 36 x 1.7 us) | 0.463 | 0.095 (`gdn_step_commit_layers`) | +0.37 (S6) | CUPTI | device | open | -| O10 | fused commit (`LELEKA_DRAFT_FUSED_COMMIT`) | measured | | -0.024 | ORCH | hex-finish | fixing | - -## C5. Publication of the tokens, host work and syncs around the round - -| id | step | LEL | VANL | difference | source | owner | status | -| --- | --- | ---: | ---: | ---: | --- | --- | --- | -| R3 | verify end to next verify start (draft, commit, host, CPU-leg join) | 4.304 | 4.144 | +0.160 | CUPTI | hex-finish | open | -| O4 | API calls per round | 207 | 20 | +187 | CUPTI | hex-finish | open | -| O5 | copies per round (count, MB) | 121 (71.5 MB) | 12 (23.6 MB) | +109 copies, +47.9 MB | CUPTI | hex-finish | open | -| O6 | syncs per round (count, host time) | 27.8 (2.468 ms) | 89 (0.926 ms) | -61 syncs, +1.542 ms of host sync time (overlapped with GPU work: R3 is only +0.16) | CUPTI | hex-finish | open | -| O13 | host work around a group (split 3, spans 2, publish plan 6, open and zero 5 us; 48 groups) | 0.8 | not measured | n/a | PROFILE | hex-finish | open | -| O1 | kernels per round | 2691 | 2245 | +446 | CUPTI | hex-finish | open | - -## C6. Between rounds and requests: expert tier (hit rate, placement) - -The tier adapts every 4 rounds and survives across requests. - -| id | step | LEL | VANL | difference | source | owner | status | -| --- | --- | ---: | ---: | ---: | --- | --- | --- | -| H1 | VRAM hit share in the replay | 90.8 % | 92.8 % | -2.0 points; 28 % more misses | LOG | device | open | -| H2 | VRAM hit share weighted by decode time in real sessions | nestng-crm 91.38 %, ttt 92.68 % | 92.41 %, 93.38 % | -1.03 and -0.70 points; at most 0.57 ms per round per point, so up to 0.59 and 0.40 ms per round | LOG | device | open | -| H3 | short requests (< 600 tokens) hit share | 86.9 % | 89.9 % | -3.0 points (up to 7 in single requests) | LOG | device | open | -| H4 | expert slots | 12,192 | 12,575 (+3 %) | -383 slots; variant H (reserves 130 / 500 MiB, about +190 slots): VRAM share +0.44 points, ms/round -0.44 (-2.19 %, CI -3.55..-0.83), tokens per round -1.69 %, decode +0.51 % (CI -0.19..+1.20), end-to-end +1.06 % (CI -0.38..+2.50) | A/B `ab-l3v2` | device | fixing (placement-class: needs the gate against the control placement) | -| H5 | adaptive tie order (equal-gain swaps share the cap across layers, `LELEKA_ADAPT_TIE_SPREAD`, `9d130fd38`) | low layer first | | run `spd-xa/xb` queued | gap doc | device | fixing | -| H6 | tier knobs: adapt every 2, 192 swaps, decay 0.85, margin 1.0 (`spd-w1..w5`) | 4, 96, 0.7, 1.5 | same policy | runs queued | gap doc | device | fixing | -| H7 | first rounds of a request see an unadapted tier | | | not isolated | gap doc | device | open | -| H8 | CPU expert compute per expert (2 MB) | 39 us (52 GB/s) | 44 us | -5 us | PROFILE | hex-finish | proved-equal (LEL ahead) | - -## Counts - -Computed by `scripts/e2e/codex/speed/ledger_counts.py` (2026-11-09): 86 rows. - -| status | rows | device | hex-finish | both | -| --- | ---: | ---: | ---: | ---: | -| open | 52 | 28 | 23 | 1 | -| fixing | 14 | 12 | 2 | 0 | -| fixed | 0 | 0 | 0 | 0 | -| proved-equal | 20 | 18 | 2 | 0 | - -Nothing is `fixed` yet: the closing rule needs a section delta, identity and the set A/B for the same row, and no row has all three. - - -## Order of work in the device part (linear in the graph; step N closed before step N+1) - -The device part starts at the verify graph; the draft (C1) and the host (C5) belong to `hex-finish`. - -1. C2, structure: V1 closes when V3a, V3b, V4a and V4b are closed. -2. C2, mixer half in graph order: V3a (GDN branch; A/B `spd-sm1`, identity `spd-sqid1`), V3b (QSA branch; window `CN.1`, A/B `spd-sqn`), then the kernels of the half: K1, K6, K7, K7a, S1, S8, S10. -3. C2, FFN half: V4a (shared expert; window `CE.1`, A/B `spd-sqe`), V4b (routed-expert branch), V5, V7, K11, S2, S7, S11, then K10, S5 and the tail R8, S9. -4. C3 accept (O7), C4 commit (S6, O11). -5. C6 hit rate and tier placement (device side: H1..H7). - -Each step is closed with: section delta (CUPTI of that step), identity, and the end-to-end paired A/B after the group. - -## U. Upstream fixes and small wins after the pin (checked 2026-11-09 against `strata-upstream/main`, reference only, `engine/strata` untouched) - -Owner rule: small upstream wins (+0.3..0.5 %) are taken too. "VANL" here is vanilla 0.2.6; upstream items dated after it are wins on top of vanilla, not gaps against it. Each row says whether we have the analogue, then the closing evidence needed. - -| id | step | LEL | VANL / upstream | difference | source | owner | status | -| --- | --- | --- | --- | --- | --- | --- | --- | -| U1 | prefill: GDN recurrence as a chunked scan on tensor cores (code `STRATA_GDN_TC`, upstream commits `8c2a84694` opt-in 2026-10-26, default `6858c919c` 2026-11-07 with `STRATA_GDN_CONVL2=2`) | present behind an off-by-default switch (`LELEKA_PREFILL_GDN_TC`); the default prompt GDN kernels stay the sealed Original ones (`leleka_prefill_gdn_rec` / `_kh`); the pinned `engine/strata` (0.1.50) has no `GDN_TC` either | upstream 0.2.9: prompt +4.4 % at 4K, +5.5 % at 16K, +5.7 % at 32K; **lossy**: first-token KL mean 0.0019, max 0.0125; engine gates it at run time (compute capability >= 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 | -| 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 | - -## 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 | -| `pr-van` | removed | empty-request probe on VANL; vanilla is not re-measured (owner 2026-11-09) | A1-A3 | +| 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 | + +## C2. Verify graph: embed, 48 layers (mixer half, FFN half), final write and head + +Structure first, then the layer steps in graph order: embed (R7), mixer half (V3 and the kernels in it), FFN half (V2/V4 and the kernels in it), tail (R8). + +| id | step | LEL | VANL | difference | source | owner | status | +| --- | --- | ---: | ---: | ---: | --- | --- | --- | +| V1 | streams in the verify graph | 1 | 11 | wall time with two or more streams active: 0 against 2.03 ms | CUPTI | device | fixing | +| R2 | verify graph GPU span | 13.561 | 11.743 | +1.818 | CUPTI | device | open | +| V9 | verify graph kernel time sum | 13.349 | 13.728 | -0.379 (VANL runs kernels concurrently: its span is shorter than its sum) | CUPTI | device | proved-equal (LEL ahead) | +| V8 | launches per verify graph | 2061 | 2098 | -37 | CUPTI | device | proved-equal (LEL ahead) | +| R5 | verify graph launch call (host) | 1.485 | 1.509 | -0.024 | CUPTI | device | proved-equal (LEL ahead) | +| R6 | idle inside the verify graph (2052 gaps against 1193 per round, mean 0.1 us) | 0.213 | 0.119 | +0.094 | CUPTI | device | open | +| R7 | first doorbell after graph start (embed, first layer mixer) | 0.132 | 0.117 | +0.015 | CUPTI | device | open | +| V3 | mixer phase (`add_hits` end to next doorbell) | 6.366 | 5.963 | +0.403 | CUPTI | device | fixing | +| verify: side branch of the GDN mixer (V3a) | GDN gates and gate projection on side streams (`LELEKA_SM120_SIDE_MIXER=1`, existing, off) | mixer 5.913, round 17.508 (`CM.1`) | mixer 5.963 | section delta mixer -0.453, round -0.356; mixer phase now equal to VANL | CUPTI | device | fixed (identity `spd-sqid1` P2 PASS: 2057 top-16 rows bit-identical, 0 argmax flips, draft trace 518/518; A/B `ab-sm` n=10 decode +1.39 %, CI +0.46..+2.32 %; default ON in the 5090 profiles; closed 2026-11-09 by section delta + identity (owner method); set A/B `verify-side-branches-ab-mixer-only-vs-all-branches` checks the set for regression) | +| verify: side branches of the QSA indexer and query chains (V3b) | QSA indexer chain and query chain on side streams (`LELEKA_SM120_SIDE_QSA`, code `0c30105d4`, off) | in line | 0.509 ms of overlap with the main stream (main+qsa) | section delta (`CN.1` against `CL.1`, same replay window r29): mixer phase of a QSA layer 184.5 -> 169.7 us p50 (-14.8 us x 12 = -0.18 ms/round); `CT.1` (all three) 169.2 us. FFN phase rose in `CN.1` on GDN layers too (109 -> 131 us), which the branch does not touch, so the whole-graph time of that window (14.62 against 13.56 ms mean) is window drift, not the branch; the A/B decides | CUPTI (VANL) | device | fixed (A/B `ab-sqn` L against N, n=10: decode tok/s +0.35 %, CI -0.23..+0.93 % (not significant, no regression); ms/token 5.635 -> 5.616; ms/round +0.11, CI -2.99..+4.11 %; end-to-end +0.87 %, CI -0.16..+1.90 %; default ON in the 5090 profiles; closed 2026-11-09 by section delta + identity (owner method); set A/B `verify-side-branches-ab-mixer-only-vs-all-branches` checks the set for regression) | +| K6 | attention role in total (norm/RoPE, appends, scores, top-k, resolve, chunk, merge, gate) | 1.357 | 1.125 | +0.232 | CUPTI role table | device | fixing (QSA prelude fused: switch `LELEKA_SM120_FUSED_QSA_PRELUDE` (off), branch `claude/verify-qsa-fused-prelude` merged, per layer 2n+1 launches -> 2; identity `verify-new-switches-identity` P2/P3, section `verify-new-switches-cupti-windows` CQ.1 against CL.2) | +| K1 | attention decode chunk (`leleka_qsa_decode_chunk_daily` 18.3 us, 12 per graph) against `attn_chunk_kernel_pre75` (17.1 us) | 0.220 | 0.206 | +0.014 | CUPTI | device | fixing (no code of its own: chunk kernel at parity (+0.014 ms), rides with the K6 windows) | +| K2 | indexer block scores (`leleka_qsa_decode_scores` 14.2 us against `block_scores_multi` 17.1 us) | 0.170 | 0.205 | -0.035 | CUPTI | device | proved-equal (LEL ahead) | +| K3 | block top-k cluster (17.3 us against 18.0 us) | 0.208 | 0.216 | -0.008 | CUPTI | device | proved-equal (LEL ahead) | +| K4 | KV miss copy / copy kernel (11.1 us against 11.6 us) | 0.133 | 0.139 | -0.006 | CUPTI | device | proved-equal (LEL ahead) | +| K5 | KV resolve (7.8 us against 8.4 us) | 0.094 | 0.100 | -0.006 | CUPTI | device | proved-equal (LEL ahead) | +| K7 | GDN role in total (step, conv, ab, commit) | 0.914 | 0.759 | +0.155 | CUPTI role table | device | fixing (GDN fused step: switch `LELEKA_SM120_FUSED_GDN` (off), branch `claude/verify-gdn-fused-kernels` merged, 3 launches per GDN layer -> 1; identity P4/P5, section CG.1 against CL.2) | +| K7a | GDN step/norm in the verify graph (`verify_gdn_step_norm_multi` 6.1 us against `gdn_step_norm_multi` 6.2 us, but 36 against 30.9 launches) | 0.220 | 0.191 | +0.029 | CUPTI | device | fixing (as K7 (36 -> 36 step launches stay, the conv and a/b launches go)) | +| K7b | GDN alpha/beta (`chain_gdn_ab_multi` 36 x 8.5 us against `gdn_ab_multi` 22.9 x 10.5 us plus the rest) | 0.307 | 0.344 | -0.037 | CUPTI | device | proved-equal (LEL ahead) | +| K12 | dense projections, lm head, MMVQ/MMVF role (`head_n*`, `bf16_f32_mmvf_multi`) | 3.892 | 4.589 | -0.697 | CUPTI | device | proved-equal (LEL ahead) | +| S1 | `ATTN_DAILY` (decode attention) | on since lever 1 | on | paired decode +1.85 % with S2 (CI excludes zero), identity PASS (teacher-forced, 2057 of 2057 rows); no section delta of its own | gap doc lever 1 | device | fixing (needs a CUPTI section delta) | +| verify: side-stream mixer switch (SIDE_MIXER=2) (S3) | `SIDE_MIXER=2` | GDN part off by default, QSA part not ported before `0c30105d4` | on | V3a, V3b | CUPTI | device | fixed (closed by V3a/V3b/V4a) | +| S8 | `MMVQ_IL` (2-4 and 5-8 columns) | not ported | on | estimate 0.10-0.40; CUPTI role K12 shows our dense projections faster by 0.70 in total | upstream plan | device | open | +| verify: batched K/V and indexer append (S10) | batched K/V append and indexer append | per row (`verify_qsa_append_analytic` 138 x 1.04 us, `mtp_original_append` 49 x 1.6 us) | batched (`append` 12 x 3.0 us, `kv_append_q8` 14.6 x 2.2 us) | estimate 0.05-0.10 | upstream plan, CUPTI | device | fixing (as K6 (batched K/V and indexer append inside the QSA prelude fusion)) | +| V2 | FFN phase (doorbell to `add_hits` end) | 6.600 | 5.293 | +1.307 | CUPTI | device | open | +| verify: doorbell to first routed expert (V4) | doorbell to first routed expert (gate/up) start, us | 27.6 | 15.0 | +12.6 us x 48 = +0.60 ms; with `SIDE_SHARED` (`CE.1`) 10.9 us, i.e. below VANL (`CT.1` 11.5 us) | CUPTI | device | fixed (closed by V3a/V3b/V4a) | +| verify: shared expert on a side stream (V4a) | shared expert on a side stream, forked after the doorbell, joined before the combine (`LELEKA_SM120_SIDE_SHARED`, code `255159a89`, off) | 27.6 us before the first expert | 15.0 us | section delta (`CE.1` against `CL.1`): doorbell to first expert 27.6 -> 10.9 us (VANL 15.0), FFN phase 6.600 -> 6.267 ms (-0.333; qsa layers 99.8 -> 87.6, gdn 109.3 -> 102.7 us p50), graph p50 12.386 -> 11.944 ms (-0.44); identity `spd-sqid1` P4 PASS: 2057 rows bit-identical, draft trace 518/518; A/B `ab-sqe` (L against E, n=10): decode tok/s +0.29 %, CI -0.43..+1.01 % (not significant); ms/round -0.61 (-2.97 %), CI -6.08..+0.15 %; tokens/round 3.64 -> 3.54 (live replay placement noise, numerics are identical); stays OFF; the CUPTI section gain (-0.33 ms) is of the size the replay cannot resolve at n=10, so 10 more pairs (`spd-sqe2`) and the set A/B M against all side parts (`verify-side-branches-ab-mixer-only-vs-all-branches`) are queued | CUPTI | device | fixed (closed 2026-11-09 by section delta + identity (owner method); set A/B `verify-side-branches-ab-mixer-only-vs-all-branches` checks the set for regression) | +| V4b | routed experts on their own branch (VANL: plan wait, VRAM experts, `fetch_blobs`, CPU wait, `add_hits` on a side stream; main stream does the shared expert and the next norm) | all on the capture stream | branch | rest of V2 after V4a, not yet known | CUPTI | device | open | +| V4c | norms and hyper-connection reads (`gr_norm_split`, `gr_down`, `gr_up`) as separate branches | main stream | main stream (VANL does not branch them; a layer's `gr_*` chain stays on the main stream) | no structural difference; kernels in K8..K10 | CUPTI | device | proved-equal | +| V5 | flag waits on the CPU leg (`verify_wait_flag_ge` 96 x 26.9 us + `chain_wait_copy_i32` 48 x 5.4 us against `wait_flag_ge` 144 x 8.1 us) | 2.836 | 1.160 | +1.676 | CUPTI | device | open | +| V6 | PCIe fetch and CPU-row hand-over (doorbell, mapped copies, `fetch_blobs`, `add_hits`, `rebase_ptrs`) | 0.488 | 2.109 | -1.621 | CUPTI | device | proved-equal (LEL ahead) | +| V7 | V5 + V6, the whole miss-leg handling | 3.324 | 3.269 | +0.055 (+0.17 by an earlier count of the same sets) | CUPTI | device | open | +| K11 | routed experts in the verify graph, role total (gate/up/SwiGLU, down) | 2.507 | 2.484 | +0.023 (entry mix differs; at equal entry counts LEL is faster: `window_moe_down_20` 13.6 us with 40 entries against 17.4 us, `sm120_moe_gu_swiglu_22` 12.3 us with 50 entries against 26 us with 40) | CUPTI | device | open | +| K15 | hit tally `add_hits` (48 x 1.2 us against 48 x 1.3 us) | 0.059 | 0.063 | -0.004 | CUPTI | device | proved-equal (LEL ahead) | +| S2 | `GU_SWIGLU` (routed expert gate/up + SwiGLU + q8_1) | on since lever 1 | on | as S1 | gap doc lever 1 | device | fixing (needs a CUPTI section delta) | +| S7 | sub16 routed-expert kernels beyond `GU_SWIGLU` | warp-per-row | sub16 | estimate 0.20-0.35; the CUPTI pair K11 does not show LEL slower, so this must be re-measured by kernel before any work | upstream plan | device | open | +| S11 | float4 combine | not ported | `combine_k10_vec4` 50.6 x 1.2 us | estimate 0.05-0.10 | upstream plan | device | open | +| K8 | hyper-connection down (`chain_gr_down_t2w8_nb4` 11.1 us against `gr_down_staged` 11.5 us) | 1.063 | 1.112 | -0.049 | CUPTI | device | proved-equal (LEL ahead) | +| K9 | hyper-connection up (`chain_gr_up8` 8.5 us against `gr_up75` + `gr_up_multi` variants) | 0.817 | 0.877 | -0.060 | CUPTI | device | proved-equal (LEL ahead) | +| K10 | hyper-connection split (`chain_gr_split` 96 x 3.1 us against `gr_norm_split` 97 x 2.9 us) | 0.299 | 0.280 | +0.019 | CUPTI | device | open | +| S4 | `GR_DOWN_TG` | 9.7 us (`chain_gr_down_t2w8_nb4`) | 18.4 us | -8.7 us | gap doc | device | proved-equal (LEL ahead) | +| S5 | `GR_UP75` (hoisted row loads) | partial | on | estimate 0.05-0.10 | upstream plan | device | open | +| K14 | small kernels (norms, PLE, copies, sampler) | 0.049 | 0.253 | -0.204 | CUPTI role table | device | proved-equal (LEL ahead) | +| R8 | tail after the last layer's `add_hits` (final write, head, argmax) | 0.463 | 0.373 | +0.090 | CUPTI | device | open | +| S9 | `HEAD_MIX_MULTI` | not ported | on | estimate 0.06-0.10 | upstream plan | device | open | + +## C2u. Upstream cc 12.0 defaults after 0.2.6 (owner 2026-11-09: +0.3 % and +0.5 % are tokens too) + +These are in upstream `strata-upstream/main` (October 31 to November 1) and not in the vanilla 0.2.6 arms (`VANL` 202.1 tok/s), so they widen upstream's lead; we take them when we have no equivalent. Columns `LEL` = what our tree has, `VANL` = the upstream claim. + +| id | step | LEL | VANL | difference | source | owner | status | +| --- | --- | --- | --- | --- | --- | --- | --- | +| verify: programmatic dependent launch on the all-resident verify graph (U1) | PDL (`081d1c04d`): kernels carry `griddepcontrol.wait` after their constant-weight loads and are launched with the programmatic stream-serialization attribute inside the graph capture, only kernel-to-kernel edges, cc >= 9 | not present: the verify window issues ordinary launches (`launch_ex.rs` has only the cluster attribute); our sealed PTX has no `griddepcontrol` | claim +0.3..0.5 % decode, bit-identical, RTX PRO 5000, all-resident graph; -1.6..-4.5 % in the doorbell graph of a partly resident cache (our serve graph is the doorbell graph, hit rate 90.8 %) | not measured | upstream commit, `pdl.hpp` | device | open (plan: kernel edits in the dense kernels that upstream opted in - `native_mmvq` x4, `native_bf16` x1, `verify_kernels` x2 - behind `LELEKA_SM120_PDL`, off; section = gap between consecutive kernels in a CUPTI window; only worth keeping if the doorbell graph does not lose) | +| verify: unrolled bf16 router read (U2) | `STRATA_SMALL_UNR` bit 0 (`bf16_f32_mmvf_multi`, constant-trip loops), default 3 on cc 12.0 (`08b20b104`) | no (our router read is the Original-literal kernel) | claim +0.18 % agent, +0.28 % code_py, 5/5 pairs, bitwise | not measured | upstream commit | device | open | +| verify: unrolled GDN a/b projection (U3) | `STRATA_SMALL_UNR` bit 1 (`gdn_ab_body`; ours `verify_gdn_ab_multi_kernel`) | no | same A/B as U2 (bits 0 and 1 together) | not measured; part of the GDN role K7 | upstream commit | device | fixing (`LELEKA_SM120_GDN_AB_UNROLL` (off), same branch as K7; identity P6, section CV.1 against CL.2) | +| verify: batched staging and read loads of the HC read (U4) | `STRATA_GR_V3_PF` bits 0 and 2 of `gr_down_v3`/`gr_up_v3` (`08b20b104`) | no `GR_V3` port (`upstream-port-plan.md` 5.7); our HC kernels are the chain kernels (`chain_gr_down_t2w8_nb4` 11.1 us, `chain_gr_up8` 8.5 us), ahead of vanilla 0.2.6 by K8/K9 | no number of its own | not measured against the chain kernels | upstream commit | device | open (needs the same-T kernel table of upstream's variant against the chain kernel) | +| verify: HC down kernel, two rows a warp for windows of 5+ rows (U5) | `STRATA_GR_V3_PF` bit 7, default mask 133 on sm_120 (`4ab81c796`, `5f24b96db`, merged as `27a3e056a`; bitwise, same dots in the same order) | not present; chain down kernel by window rows in `CL.1` (gy = rows/2): T 1-2 9.35 us, T 3-4 10.65 us, T 5-6 13.11 us, T 7-8 15.33 us (vanilla 0.2.6 `VANL` by its own grid-y 1/2/3/4/6: 8.80 / 9.04 / 10.18 / 12.54 / 15.92 us; a different row mapping) | down kernel 16.1 / 16.2 / 17.6 / 19.5 -> 13.3 / 14.1 / 14.7 / 15.6 us at T 5-8 (upstream's own table); serve A/B spec 6 +1.21 %, spec 8 +1.4 %, ids identical 96/96 | ours at T 5-8 is 13.1 / 15.3 us against upstream's own table 13.3 / 14.1 / 14.7 / 15.6 us (other card, RTX PRO 5000): level with upstream's bit-7 kernel within about 1 us; upstream's kernel is not measured on the 5090 | upstream commit | device | open (kernel micro-benchmark `verify-hc-down-kernel-microbench-vs-upstream` queued, branch `claude/verify-hc-down-microbench` merged: upstream masks 0/5/133 against `chain_gr_down_t2w8_nb4`, T 1-8, cold and warm weights, byte compare; the vanilla window is impossible, vanilla 0.2.6 has no mask 133; the grid-y of the two kernels is NOT the same row mapping (our launches: gy 2 most, vanilla: gy 4 most), so the two tables above cannot be compared row for row; the per-T comparison needs the window rows of each graph, taken from the graph's other kernels) | + +## C3. Accept (verdict of the window on the device) and the hand-over to the next draft + +| id | step | LEL | VANL | difference | source | owner | status | +| --- | --- | ---: | ---: | ---: | --- | --- | --- | +| O7 | verify end to first draft kernel, ms (design note `docs/experiments/verify-accept-on-device.md`: vanilla decides the accept count on the HOST too, `generate.cpp:15255`; what vanilla keeps on the device is the finite check of the head logits, one sync; ours does a second launch pair, a stream sync, a DtoH and a context sync) | 0.32 | 0.08 | +0.24 | ORCH | hex-finish (finite check: device) | fixing (`LELEKA_SM120_ACCEPT_ON_DEVICE` (off): the finite check of the head logits inside the verify graph, branch `claude/verify-accept-on-device` merged; identity P7, section CA.1 (the three tail kernels, no DtoH/context sync after the window); the host chain (0.2 ms) is hex-finish) | + +## C4. Commit (accepted-prefix graph, GDN replay, QSA tail restore, re-append, PLE history) + +| id | step | LEL | VANL | difference | source | owner | status | +| --- | --- | ---: | ---: | ---: | --- | --- | --- | +| verify: fused commit graph (accepted-prefix commit) (S6) | `COMMIT_BATCH` + state-only GDN commit (commit graph 158 kernels, 0.463 ms) | not ported | on (`gdn_step_commit_layers` 0.9 per round, 0.095 ms) | estimate 0.25-0.35 | upstream plan, CUPTI | device | fixing (the fused commit graph exists since draft-round: `LELEKA_DRAFT_FUSED_COMMIT=on`, 182 -> 4 nodes, GPU 516 -> 125 us, identity 2057/2057 rows and 1036/1036 draft-trace lines; it was never in the profile because the replay A/B called it neutral; now: section window `CF.1`/`CU.1` (`verify-fused-commit-cupti-windows`) and identity `verify-fused-commit-and-side-branches-identity` P2/P3 on this tree, then ON in the 5090 profiles) | +| verify: commit graph kernel count (O11) | commit graph (158 kernels, `verify_gdn_conv_commit` 36 x 1.7 us) | 0.463 | 0.095 (`gdn_step_commit_layers`) | +0.37 (S6) | CUPTI | device | fixing (as S6) | +| O10 | fused commit (`LELEKA_DRAFT_FUSED_COMMIT`) | measured | | -0.024 | ORCH | hex-finish | fixing | + +## C5. Publication of the tokens, host work and syncs around the round + +| id | step | LEL | VANL | difference | source | owner | status | +| --- | --- | ---: | ---: | ---: | --- | --- | --- | +| R3 | verify end to next verify start (draft, commit, host, CPU-leg join) | 4.304 | 4.144 | +0.160 | CUPTI | hex-finish | open | +| O4 | API calls per round | 207 | 20 | +187 | CUPTI | hex-finish | open | +| O5 | copies per round (count, MB) | 121 (71.5 MB) | 12 (23.6 MB) | +109 copies, +47.9 MB | CUPTI | hex-finish | open | +| O6 | syncs per round (count, host time) | 27.8 (2.468 ms) | 89 (0.926 ms) | -61 syncs, +1.542 ms of host sync time (overlapped with GPU work: R3 is only +0.16) | CUPTI | hex-finish | open | +| O13 | host work around a group (split 3, spans 2, publish plan 6, open and zero 5 us; 48 groups) | 0.8 | not measured | n/a | PROFILE | hex-finish | open | +| O1 | kernels per round | 2691 | 2245 | +446 | CUPTI | hex-finish | open | + +## C6. Between rounds and requests: expert tier (hit rate, placement) + +The tier adapts every 4 rounds and survives across requests. + +| id | step | LEL | VANL | difference | source | owner | status | +| --- | --- | ---: | ---: | ---: | --- | --- | --- | +| H1 | VRAM hit share in the replay | 90.8 % | 92.8 % | -2.0 points; 28 % more misses | LOG | device | open | +| H2 | VRAM hit share weighted by decode time in real sessions | nestng-crm 91.38 %, ttt 92.68 % | 92.41 %, 93.38 % | -1.03 and -0.70 points; at most 0.57 ms per round per point, so up to 0.59 and 0.40 ms per round | LOG | device | open | +| H3 | short requests (< 600 tokens) hit share | 86.9 % | 89.9 % | -3.0 points (up to 7 in single requests) | LOG | device | open | +| H4 | expert slots | 12,192 | 12,575 (+3 %) | -383 slots; variant H (reserves 130 / 500 MiB, about +190 slots): VRAM share +0.44 points, ms/round -0.44 (-2.19 %, CI -3.55..-0.83), tokens per round -1.69 %, decode +0.51 % (CI -0.19..+1.20), end-to-end +1.06 % (CI -0.38..+2.50) | A/B `ab-l3v2` | device | fixing (placement-class: needs the gate against the control placement) | +| H5 | adaptive tie order (equal-gain swaps share the cap across layers, `LELEKA_ADAPT_TIE_SPREAD`, `9d130fd38`) | low layer first | | run `memory-tier-tie-spread-ab-first-half/xb` queued | gap doc | device | fixing | +| H6 | tier knobs: adapt every 2, 192 swaps, decay 0.85, margin 1.0 (`spd-w1..w5`) | 4, 96, 0.7, 1.5 | same policy | runs queued | gap doc | device | fixing | +| H7 | first rounds of a request see an unadapted tier | | | not isolated | gap doc | device | open | +| H8 | CPU expert compute per expert (2 MB) | 39 us (52 GB/s) | 44 us | -5 us | PROFILE | hex-finish | proved-equal (LEL ahead) | + +## Counts + +Computed by `scripts/e2e/codex/speed/ledger_counts.py` (2026-11-09): 86 rows. + +| status | rows | device | hex-finish | both | +| --- | ---: | ---: | ---: | ---: | +| open | 52 | 28 | 23 | 1 | +| fixing | 14 | 12 | 2 | 0 | +| fixed | 0 | 0 | 0 | 0 | +| proved-equal | 20 | 18 | 2 | 0 | + +Nothing is `fixed` yet: the closing rule needs a section delta, identity and the set A/B for the same row, and no row has all three. + + +## Order of work in the device part (linear in the graph; step N closed before step N+1) + +The device part starts at the verify graph; the draft (C1) and the host (C5) belong to `hex-finish`. + +1. C2, structure: V1 closes when V3a, V3b, V4a and V4b are closed. +2. C2, mixer half in graph order: V3a (GDN branch; A/B `spd-sm1`, identity `spd-sqid1`), V3b (QSA branch; window `CN.1`, A/B `spd-sqn`), then the kernels of the half: K1, K6, K7, K7a, S1, S8, S10. +3. C2, FFN half: V4a (shared expert; window `CE.1`, A/B `spd-sqe`), V4b (routed-expert branch), V5, V7, K11, S2, S7, S11, then K10, S5 and the tail R8, S9. +4. C3 accept (O7), C4 commit (S6, O11). +5. C6 hit rate and tier placement (device side: H1..H7). + +Each step is closed with: section delta (CUPTI of that step), identity, and the end-to-end paired A/B after the group. + +## Job names (old code name -> readable name) + +Queue stubs and result directories carry the readable name from 2026-11-09 (`--`, area prefix `prefill-`, `verify-`, `draft-`, `host-`, `memory-`). A job that already ran or runs keeps its directory; this table is the correspondence. + +| old name | readable name | state | +| --- | --- | --- | +| `spd-sm0` | verify-side-mixer-cupti-window (dir `runs/cupti/CM.1`) | done | +| `spd-sm1` | verify-side-mixer-ab-default-vs-on (dir `runs/ab-sm`) | done | +| `spd-sqid1` | verify-side-branches-identity (dir `runs/id-sq1`) | done | +| `spd-sqw` | verify-side-qsa-and-shared-cupti-windows (dirs `runs/cupti/CE.1`, `CN.1`, `CT.1`) | done | +| `spd-sqe` | verify-side-shared-ab-default-vs-on (dir `runs/ab-sqe`) | done | +| `spd-sqe2` | verify-side-shared-ab-more-pairs | withdrawn | +| `spd-sqn` | verify-side-qsa-ab-default-vs-on (dir `runs/ab-sqn`) | running | +| `spd-sqa` | verify-side-branches-ab-mixer-only-vs-all-branches (dir of the same name) | queued, renamed | +| `spd-sqf` | verify-fused-commit-cupti-windows (dir of the same name) | queued, renamed | +| `spd-sqid2` | verify-fused-commit-and-side-branches-identity (dir of the same name) | queued, renamed | +| `spd-xa`, `spd-xb` | memory-tier-tie-spread-ab-first-half, -second-half (dir `runs/memory-tier-tie-spread-ab`) | queued, renamed | +| `spd-cuo` | draft-and-verify-cupti-windows-leleka (dir `runs/cupti/CL.1`) | done | +| `spd-cuv` | draft-and-verify-cupti-windows-vanilla (dir `runs/cupti/VANL`) | done | +| `spd-w1` .. `spd-w5` | memory-tier-policy-screening-round-1 .. 5 | done | + +## U. Upstream fixes and small wins after the pin (checked 2026-11-09 against `strata-upstream/main`, reference only, `engine/strata` untouched) + +Owner rule: small upstream wins (+0.3..0.5 %) are taken too. "VANL" here is vanilla 0.2.6; upstream items dated after it are wins on top of vanilla, not gaps against it. Each row says whether we have the analogue, then the closing evidence needed. + +| id | step | LEL | VANL / upstream | difference | source | owner | status | +| --- | --- | --- | --- | --- | --- | --- | --- | +| U1 | prefill: GDN recurrence as a chunked scan on tensor cores (code `STRATA_GDN_TC`, upstream commits `8c2a84694` opt-in 2026-10-26, default `6858c919c` 2026-11-07 with `STRATA_GDN_CONVL2=2`) | present behind an off-by-default switch (`LELEKA_PREFILL_GDN_TC`); the default prompt GDN kernels stay the sealed Original ones (`leleka_prefill_gdn_rec` / `_kh`); the pinned `engine/strata` (0.1.50) has no `GDN_TC` either | upstream 0.2.9: prompt +4.4 % at 4K, +5.5 % at 16K, +5.7 % at 32K; **lossy**: first-token KL mean 0.0019, max 0.0125; engine gates it at run time (compute capability >= 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 | +| 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 | + +## 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 | +| `pr-van` | removed | empty-request probe on VANL; vanilla is not re-measured (owner 2026-11-09) | A1-A3 | diff --git a/docs/experiments/verify-accept-on-device.md b/docs/experiments/verify-accept-on-device.md new file mode 100644 index 00000000..a32e7bed --- /dev/null +++ b/docs/experiments/verify-accept-on-device.md @@ -0,0 +1,210 @@ +# Verify end to the first draft kernel (ledger row O7): where the 0.32 ms go, and what "accept on the device" is + +Status: sections 1-7 are a reading of the code and of existing measurements; section 8 is option A, implemented behind +`LELEKA_SM120_ACCEPT_ON_DEVICE` (default off) on the coordinator's decision. No GPU run: nothing here is measured. Base: `5b8c0eba0` (branch +`claude/speed-vs-strata-08143a`), Strata pin `41cf05a06a25` (`docs/upstream.md`). Ledger row: `step-ledger.md` section C3, +O7: LEL 0.32 ms, VANL 0.08 ms ("accept decided on the device"), +0.24 ms, source ORCH (a figure given by the +orchestrator session; this note does not re-derive it). + +## 1. Result in five lines + +1. **The premise of the row is not what the vanilla code does.** In vanilla's greedy serve loop the accept count `a` is + computed on the host (`engine/strata/src/program/generate.cpp:15255`: `while (a < T-1 && window[a+1] == outv[a]) ++a`), + the commit gets `a + 1` from the host (`:15271`), and `MtpDrafter::draft` receives `a` as an `int`, writes it to a + host-mapped word (`src/core/mtp.cpp:1605`, `h_row_[0] = a`) and picks the round graph by `T` (`:1580-1582`). The + device-side accept in the vanilla tree is the probabilistic rejection sampler (`STRATA_SPEC_PROB`, + `src/kernels/cuda/sampler.cu:883-1045`), which is another mode and not the default greedy path. +2. **What vanilla does keep on the device is the finite (NaN) verdict of the head logits.** `Verifier::record` captures + `logits_nonfinite_rows` into the window's own stream after the greedy pick (`src/core/verify.cpp:2380`); after the + window's one `cudaStreamSynchronize` (`:3178`) the host only reads the mapped ids (`:3260`) and the mapped flags + (`note_nonfinite`, `:4180`). No extra launch, no second sync. +3. **Ours does that check after the drain, with two more synchronisations** (section 2, hops 4-5), in files that are ours + (`verify_gdn_journal_ladder_logits_scan.rs`, `original_verify_schedule/window_phases.rs`, + `original_gpu_verify_bridge.rs`). +4. **An exact device-side accept that removes a host round trip cannot be built inside our files.** Every consumer of `a` + (the controller, the draft round, the chain steps, token emission, the NaN guard) is host code outside them + (section 4). I stopped at the decision point and gave the options (section 5); the coordinator chose option A, which + is section 8. +5. **Recommendation:** option A (the finite verdict into the verify graph, mapped result, no new PTX; it is vanilla's + structure and lives in our files) as the step for this row, with the honest size: the only measured span of the scan + is 0.05 ms per round (older tree), i.e. about a fifth of the +0.24 ms. The rest of the gap is the host chain between the + sync and the draft launch (hex-finish). + +## 2. Our path, verify graph end to the first draft kernel + +Per round, in call order. File:line refer to this tree (`crates/cuda-driver/src` and +`crates/engine-qwen35-cuda/src/qwen_forward`). + +| hop | what happens | where | host or GPU | figure (source) | +| --- | --- | --- | --- | --- | +| 1 | last kernel of the window graph (greedy argmax into the head rows' mapped words) ends | `native_head/original_native_head_rows/original_native_head_rows_greedy_submit.rs:84-104` (`greedy`), captured by `capture_head_greedy` from `original_verify_window_ops/window_ops_kernels_and_pcie_plan.rs:244` | GPU | n/a | +| 2 | `compute.synchronize_with_receipt()` returns, then `copy.synchronize()` (already idle), `release_pcie_sources`, `record_window_profile` (off) | `original_verify_schedule/window_phases.rs:277-285` (`drv.sync_compute`, `drv.sync_copy`) | host wake from a blocking sync | not isolated; `drv.sync_compute` + `drv.head` together 0.88 ms incl. the last layer and head on the GPU (`docs/serve-step-costs.md`, job 901) | +| 3 | `verifier_head_after_drain`: stream and receipt checks, `resources_after_stream_drain` | `original_gpu_verify_bridge.rs:7-20` | host | below the noise of the spans | +| 4 | **post-drain logits scan, launch and stream sync**: `verify_clear_status` + `verify_scan_logits` over all `T x vocab` words are launched on the compute stream, then `stream.synchronize()` | `original_verify/original_verify_gdn_journal/verify_gdn_journal_ladder_logits_scan.rs:116-136` (`head.validate_stream`) | host launch (2 kernels) + a second blocking sync + the scan itself on the GPU | `head.validate_logits` (the whole of hops 4 and 5): 0.05 ms per round, job 901 on `claude/ms-trim` (`docs/serve-step-costs.md`: "head validation scan 0.05") | +| 5 | **status read back**: `cuMemcpyDtoH` of the 4-byte status from the arena's `hit_count` scratch, then a context-wide `synchronize` | same file `:138-157` (`head.validate_ctx_copy`) | host, third sync of the window | in the 0.05 ms above | +| 6 | `sample_on_stream` is skipped for greedy; `read_selection` reads the mapped ids and range-checks them; `complete_window` copies them, sets `window_ready` | `original_native_head_rows_greedy_submit.rs:156-168, 235-242`, `window_phases.rs:303-321` (`head.read_ids`) | host | not isolated | +| 7 | back in the engine: `admit_receipt`, `quality_force::apply`, optional traces, `NativeWindow` built | `original_serve_native/native_serve_port_original_serve_port.rs:60-89` | host | in the "verify_commit outside any span" row below | +| 8 | controller: `accepted_prefix` (the `while` loop over `inputs`/`outputs`), `note_round_profile`, `begin_adaptation` (choose + queue swaps), `commit_verified(keep = a + 1)` | `original_spec_controller/original_spec_controller_methods/commit_parts.rs:12-24, 78-121`; `native_serve_port_original_serve_port.rs:92-109` | host | `verify_commit` outside any span 0.094 ms at 247k context (0.038 at 45k) (`draft-tail-5090.md` table); `round.adapt` (choose + queue) 0.079-0.084 ms (`decode-tail-5090.md`, section 5) | +| 9 | commit enqueue: `host.commit_enqueued`, `Verifier::commit` = `stage_commit(keep)`, graph launch, event record (async, no wait) | `original_verify_schedule/original_verifier.rs:34-67`, `original_verify/share_window_modules/original_verify_bank.rs:158` | host | `drv.commit_enqueue` 0.004 ms, `round.commit` 0.005-0.006 ms (`draft-round-5090.md` section 2; `draft-tail-5090.md`) | +| 10 | `draft_overlapped` -> `launch_overlapped`: `take_window_parts`, `host.launch_draft` (staging of the round's mapped words including `a`, snapshot publication, round graph launch). The draft stream does not wait for the commit event unless `LELEKA_SERVE_DRAFT_AFTER_COMMIT=on` | `original_serve_native/native_window.rs:155-201`, `draft_waits_for_commit` `:272`; draft side in `mtp_original_*` (hex-finish) | host | `draft.launch` 0.027-0.041 ms untraced (`draft-round-5090.md` section 2; `decode-tail-5090.md` section 5); window graph launch 0.008 ms | +| 11 | first kernel of the MTP round graph starts | | GPU | tracer timeline: verify end -> first kernel of the round graph 315 us (before), 230 us (fused commit + attention switch) in a CUPTI window; the tracer inflates the launch calls (`draft-round-5090.md` section 2) | + +Sum of the independently measured host spans of hops 4-5, 8, 9, 10: 0.05 + (0.09 + 0.08) + 0.005 + 0.035 = about 0.26 +ms, plus the wake-up latencies of three blocking syncs that nobody has isolated. That is the same size as the ORCH 0.32 +ms. It is an addition of figures from different trees and runs (older `ms-trim` for the scan, 247k context for +`verify_commit`), so it is an estimate and not a trace. The CUPTI window `CL.1` has the real gap; the script that prints +round and verify-graph spans is `scripts/e2e/codex/speed/decode_rounds.py` (the "verify end to first draft kernel" +column is the orchestrator's). + +Where the draft sits relative to the commit: the commit graph is not on the draft's critical path (the draft stream no +longer waits for it, `draft-round-5090.md` section 2: draft end - commit end 1,066 us), so hop 9 costs the critical path +only its host time (about 0.01 ms), not the commit graph's GPU time. + +## 3. Vanilla's path (the 0.08 ms) + +| hop | what happens | where | +| --- | --- | --- | +| 1 | window graph ends; its tail contains the greedy pick **and** `logits_nonfinite_rows` writing to mapped flags | `src/core/verify.cpp:2372-2380` | +| 2 | one `cudaStreamSynchronize(cs_)`; `copy_` is synchronised only if it was used | `:3178`, `:3213-3216` | +| 3 | the host reads the mapped ids (`out[t]`), then `note_nonfinite` reads the mapped flags: no launch, no sync | `:3260`, `:4180-4200` | +| 4 | `a` by the `while` loop; adaptive tier on a separate `std::thread` (not on the path) | `generate.cpp:15255-15270` | +| 5 | `ver.commit(a + 1)`: enqueue, async | `:15271`, `core/verify.cpp` `set_commit_async` | +| 6 | `nonfinite_hit` reads the flags already read; tokens are printed and flushed; `mtp.draft(T, outv, p, a, ...)` stages the mapped words (`h_row_[0] = a`, cells `p + a + j`) and launches the round graph on its own stream `cs_` with no dependency on the commit | `:15276-15316`, `src/core/mtp.cpp:1597-1629` | + +So the difference is not "device against host accept". It is: one blocking sync against three (hops 2, 4, 5 of ours), +no scan launch against two kernels, and a short host chain (no `begin_adaptation`, no controller bookkeeping, no +snapshot publication) before the draft launch. + +## 4. Can an exact device-side accept be built inside our files? + +The computation itself is trivial and exact: one single-thread kernel after the greedy pick that compares +`inputs[i + 1]` with `ids[i]` (the staged window tokens are on the device) and stores `a` or `keep = a + 1`. It would be +bitwise-equal to the host loop (integer compare). The question is who can consume it without a host read, and there the +answer is no, inside our files: + +1. **The draft round and chain** need `a` in host-staged mapped words before the launch: `launch_inner` reads + `window.accepted_row` (`mtp_original_full_drafter/original_mtp_drafter/original_mtp_drafter_launch_rounds.rs:16, 131`), + the chain steps' cells are `p + a + j` staged by the host (vanilla: `mtp.cpp:1601-1603`). Making the round graph read + `a` from the device means editing `mtp_original_*` and the draft kernels' operand addresses: another team's files, and + the chain steps `j >= 1` would still have to be launched from the host after reading draft `j - 1` (the stop rule + `p_j >= min_p` is host-side, both in vanilla `mtp.cpp:1694` and ours). +2. **The controller** (emission of tokens, EOS, the budget `max_new`, the adaptive window policy `observe`, the + cancel check) needs `a` on the host in the same round; it cannot be deferred. +3. **The commit** is the only consumer that could take a device value: its `keep` is a mapped word staged by + `stage_commit` (`original_verify_bank.rs:158`, ours). Enqueuing the commit graph right behind the window in the same + stream, with `keep` computed on the device, would remove hop 9 from the host path (about 0.01 ms) and nothing else, + because the commit is not on the draft's critical path. It is also **unsafe**: the NaN guard may refuse the window + (`discard_window` in `verifier_commit_window_lifecycle.rs` requires that no commit was enqueued, and + `native_serve_port_original_serve_port.rs` `discard_window` fails the port if one is pending: "an enqueued commit + cannot be undone"), and the finite verdict is exactly what is decided after the drain. A pre-launched commit would + have to run behind the finite verdict on the device (a conditional graph node), which is a larger design for a 0.01 + ms host saving. +4. **CUDA conditional nodes** (graph `switch` on `a`) could select the right draft round graph on the device and drop + the host launch altogether, but the draft graphs are keyed per row count and rebuilt per request + (`OriginalGraphKey::MtpRound { rows, coupled }`), the chain steps are host-driven, and it is a new draft design + (`hex-finish`, `mtp_original_*`). Not a step of the device part. + +Verdict: **not implementable as an exact, same-policy device accept inside `original_verify_window_*`, +`original_verify_gpu_plan*` and the cuda-driver verify files without edits to the draft chain and the controller**. +Per the brief I stop here. + +## 5. Options and recommendation + +| option | what | files | saves (documented / estimated) | risk | +| --- | --- | --- | --- | --- | +| **A. Finite verdict in the verify graph** (vanilla's structure; the "verdict decided on the device") | capture `verify_clear_status` + `verify_scan_logits` (already in the sealed `original_verify.ptx`) after `capture_head_greedy` in `OriginalVerifyWindowOps::head`, the result in a host-mapped word; post-drain code only reads it (no launch, no stream sync, no `cuMemcpyDtoH`, no context sync) | ours: `original_verify_window_ops/window_ops_kernels_and_pcie_plan.rs`, `verify_gdn_journal_ladder_logits_scan.rs`, `original_gpu_verify_bridge.rs`, the mapped-slot list in `original_verify.rs`; one new mapped word; no new PTX | hops 4-5: 0.05 ms per round measured on `ms-trim` (job 901); the GPU part (the scan over `T x 248k` words, 2 extra kernels) moves into the graph's own tail | the scan kernel `atomicOr`s into the status: on a device-arena word that is fine, on host-mapped memory atomics are platform dependent. The safe form is: scan into a device word (as now), then a plain 4-byte store to the mapped word at the end of the graph (the greedy kernel already stores its ids to mapped memory this way). The NaN guard behaviour must stay (`Error::NonFiniteMmqOutput("Original Verifier full logits")` before any token is used); a test with an injected non-finite logit (the vanilla analogue is `STRATA_NAN_INJECT`) is needed on the GPU. No number of the model changes | +| B. Shorten the host chain between the sync and the draft launch | `begin_adaptation` (0.08), `verify_commit` bookkeeping (0.09 at 247k, O(context)), draft staging (0.03-0.04): move off the path or make O(1) | `original_spec_controller*`, `original_serve_native*`, `mtp_original_*`: hex-finish | up to 0.15-0.20 ms of the 0.24 (sum of documented spans) | owned by `hex-finish`; the two earlier trims (`decode-tail`, `draft-round`) already took 0.16 ms and 0.03 ms of it | +| C. Commit pre-launched with a device `keep` | section 4, item 3 | ours | 0.01 ms host, 0 on the critical path | breaks `discard_window` unless conditioned on the finite verdict; not recommended | +| D. Device-selected draft (conditional graph nodes) | section 4, item 4 | draft chain | host launch of the round graph, potentially most of hop 10 | new design in their files; not a device-part step | + +Recommendation: **A for this row** (smallest, exact, in our files, it is what vanilla has), with the expectation set +from the data: about 0.05 ms, not 0.24. Close the remaining part of O7 by B with `hex-finish`. If A is approved I would +implement it under `LELEKA_SM120_ACCEPT_ON_DEVICE` (default off, resolved in `original_verify_window_sm120.rs` in its own +block), keep the post-drain scan as the off path, and add unit tests for the switch resolution, for the graph recording +(two more nodes in the verify graph, `DBG graph window t=.. nodes=`), and for the refusal on a non-zero status. Suggested +ledger text for O7 meanwhile: "vanilla's greedy accept is host-side (generate.cpp:15255); the difference is the +finite-verdict scan after the drain (3 syncs against 1) and the host chain before the draft launch". + +## 6. How the orchestrator would see option A in a CUPTI window (if built) + +* Before: after the verify graph, standalone launches of `verify_clear_status` and `verify_scan_logits` (1 block, then up + to 65535 blocks of 256 threads) on the compute stream, followed by a gap while the host does `cuMemcpyDtoH` and a + context synchronize, then the commit and draft launches. +* After: the same two kernels as the last nodes of the verify graph (kernels per verify graph +2, outside-the-graph + kernels per round -2), and no `cuMemcpyDtoH` / `cuCtxSynchronize` in the API-call list between the window and the + commit (the ledger's API calls per round, row O4, and syncs per round, row O6, fall by one and one respectively). +* Host-side check without CUPTI: `LELEKA_SERVE_PROFILE=1`, spans `head.validate_logits`, `head.validate_stream` and + `head.validate_ctx_copy` (all three should vanish or become sub-microsecond), `drv.head`. + +## 7. Sources + +* `engine/strata/src/program/generate.cpp:15236-15316`, `src/core/mtp.cpp:1559-1744`, `src/core/verify.cpp:2372-2380, + 3170-3270, 4180-4200` (vanilla, read-only). +* `docs/experiments/draft-round-5090.md` section 2 (CUPTI window of the commit, round and step graphs; untraced host + spans), `docs/experiments/decode-tail-5090.md` sections 5-6 (host spans per round), `docs/experiments/draft-tail-5090.md` + (per-round table at 247k), `docs/serve-step-costs.md` (job 901, "head validation scan 0.05"), + `docs/experiments/codex-compare-speed-gap.md` "Kernel level: one CUPTI window of request 29" (round 17.86 against 15.89 + ms; after the verify graph to the next start 4.30 against 4.14), `docs/experiments/step-ledger.md` C3/C5. + +## 8. Option A as built: `LELEKA_SM120_ACCEPT_ON_DEVICE` (default off) + +**What it does.** With the switch on, the verify graph of every T ends with the finite scan of the head logits, after +the greedy pick: `verify_clear_status`, `verify_scan_logits` (both already in the sealed `original_verify.ptx`, the +same launch shapes and arguments as the literal post-drain scan) and one more node, `verify_copy_i32_from_mapped_kernel` +with `n = 1`, that stores the status word into a host-mapped verdict word (a plain store, as the greedy kernel stores its +ids; no atomics on mapped memory). So the graph has three more kernel nodes, not two: the store is the third. The +post-drain check then reads that word and launches, copies and synchronises nothing. With the switch off nothing is +recorded and the post-drain path is the literal one, unchanged. + +**Semantics when on (same as off).** The verdict is read at the same place, in `verifier_head_after_drain` before the +head selection is read and before `complete_window`, so a non-finite window raises the same +`Error::NonFiniteMmqOutput("Original Verifier full logits")` before `window_ready` is set and before any commit can be +enqueued (the commit needs `window_ready`). `discard_window` and the controller's NaN-guard path are untouched. The word +is `0` finite, `1` non-finite; it is armed with a pending sentinel (`0x5a5a5a5a`) at allocation and after each read, so a +graph that did not store it reads as an `InvalidDriverValue` error, never as "finite". + +**Switch.** `Sm120Switches.accept_on_device`, `DEFAULT_ON_ACCEPT_ON_DEVICE = false`, resolved in +`original_verify_window_sm120.rs` in its own lines (variable `LELEKA_SM120_ACCEPT_ON_DEVICE`, `=1`/`on` on, `=0`/`off` +off; a card below compute capability 12.x never takes it, like the others). `resolve_sm120_switches` marks the head rows +of the graph being recorded (each T has its own) through a `Cell` on `OriginalNativeHeadRows`; `WindowPolicy` +(398 lines) is not touched. The startup line `leleka-serve sm120 switches: ...` prints `accept_on_device` in the +requested set. + +**Files.** `original_verify/finite_verdict.rs` (new: the commands, the verdict decode, the post-drain dispatch), +`original_verify_window_sm120.rs` (switch), `original_verify_window_ops/original_verifier.rs` (marks the head rows), +`original_verify_window_ops/window_ops_kernels_and_pcie_plan.rs` (`head()` records the tail), +`original_verify/original_verify_gdn_journal/verify_gdn_journal_ladder_logits_scan.rs` (shared operands, the capture), +`native_head/...` (the mapped verdict word next to the ids), `original_gpu_verify_bridge.rs` (the post-drain dispatch), +`original_verify.rs` (one `mod`). No PTX was added or changed, so no nvcc was needed. + +**Identity.** The model's numbers are not touched: nothing is recorded before the greedy pick changes, the added nodes +read the logits and write only the status scratch (`hit_count` word 0, which the literal post-drain scan already +overwrote) and the verdict word. The ids, logits and top-16 rows must be bit-equal; the orchestrator's teacher-forced job +(`draftround-id.sh`) with the switch set is the gate. The scan ordering relative to the commit graph is the stream +order, as before. + +**Tests (unit, no GPU):** switch default off, on by variable, master switch, below 12.x, not a side branch +(`original_verify_window_sm120.rs`); the graph tail is exactly `verify_clear_status`, `verify_scan_logits`, the store, in +that order, with the literal scan's launch shapes; the verdict decode (finite, non-finite with the literal error, pending +or stale words refused); with the verdict in the graph the post-drain scan closure (launch, stream sync, copy back, +context sync) is never called and only the mapped read runs, and with the switch off the scan runs and the word is not +read; the same error on both paths. Not covered without a GPU: that the recorded graph really has the three nodes +last (the recorder needs a device); the orchestrator checks it with `DBG graph window t=.. nodes=` (+3 nodes per window +graph with the switch on) and with a CUPTI window (below). + +**How to see it.** CUPTI window: with the switch on, `verify_clear_status`, `verify_scan_logits` and +`verify_copy_i32_from_mapped_kernel` (1 block) are the last three kernels of each verify graph and no longer launch +after it; no `cuMemcpyDtoH` and no `cuCtxSynchronize` between the window's `cuStreamSynchronize` and the commit launch +(API calls per round -1 to -2, syncs per round -2, rows O4 and O6). `LELEKA_SERVE_PROFILE=1`: the spans +`head.validate_logits`, `head.validate_stream` and `head.validate_ctx_copy` disappear. Expected size: the 0.05 ms per round +measured for the scan on the older tree (section 2), not the whole +0.24 ms. + +**Risks.** (1) The extra three nodes sit at the end of the graph and add their GPU time (the scan over `T x 248k` words, +a few microseconds) to the graph itself while the host no longer waits for a separate launch; the net is for the +measurement to say. (2) The store to mapped memory is visible to the host after the stream synchronisation, as the ids +are; no separate fence was added. (3) A non-finite logit must still be injected on a GPU once to see the error path +(vanilla has `STRATA_NAN_INJECT`; ours has no injector for the logits). + +### Corrected wording for ledger row O7 (section C3), to copy + +> | O7 | verify end to first draft kernel, ms | 0.32 | 0.08 | +0.24 | ORCH | hex-finish + device | fixing: the accept count is host-side in both engines (vanilla `generate.cpp:15255`, the draft takes `a` as an `int` and stages it, `mtp.cpp:1605`); the vanilla window decides only the finite verdict of the logits on the device (`verify.cpp:2380`) and reads it with the window's one sync, ours scans after the drain (stream sync, copy back, context sync: three syncs against one, 0.05 ms in the older profile). Device part: `LELEKA_SM120_ACCEPT_ON_DEVICE` records the scan in the verify graph (code on `claude/verify-accept-on-device`, off, not measured). The rest of the gap is the host chain between the sync and the draft launch (controller bookkeeping 0.09 at 247k, `begin_adaptation` 0.08, draft staging 0.03-0.04), `hex-finish`. Note: `docs/experiments/verify-accept-on-device.md` | diff --git a/docs/experiments/verify-decode-graph-reuse-handles.md b/docs/experiments/verify-decode-graph-reuse-handles.md new file mode 100644 index 00000000..0bdff4ef --- /dev/null +++ b/docs/experiments/verify-decode-graph-reuse-handles.md @@ -0,0 +1,146 @@ +# Decode graph reuse, driver side: shared handles, park, re-arm (ledger row Q7) + +Status: implemented and unit tested without a GPU; NOT run on a device. Nothing changes on the existing paths (no new +switch, no kernel, no argument of a captured launch). The policy side (`LELEKA_DECODE_GRAPH_REUSE`, the key, the pin and +epoch, the owner loan, the drafter binding) is the hex-finish team's; this is the part they listed as blocked +("B1" and "Part 2" of `decode-graph-reuse.md`, branch `claude/prefill-latency` a4a8d597f). No performance claim: +the section to watch is `decode.assemble` (`record_all` 83 ms of 98-109 ms per request, `decode-graph-reuse.md`). + +## 1. What changed + +### 1.1 `DeviceRef<'ctx>` (crates/cuda-driver/src/device_ref.rs) + +An `Rc` handle to a device allocation, `Clone`, `Deref`: + +* from a whole buffer (`from_buffer`, owns it) or from a `DeviceSlice` (`from_slice`: the alias of exactly + `[offset, offset + len)` of a 64 MiB slab, plus the `Rc` of the slab that keeps it alive). Offset and length are the + alias' own (`len()`, the address); there is no separate `(offset, len)` pair to disagree with the buffer. +* `release(self)`: the sole holder frees (the last handle of a slab frees the slab); with other holders it frees nothing + and returns `Ok`, the last holder frees on drop. So a cache that evicts or closes while an assembly holds an entry + leaves the allocation alive and the cache's own accounting. +* `DeviceBuffer::copy_from_shared(&self, ..)`: the `copy_from` transfer through a shared borrow (`copy_from` now calls it), + used to seed the PLE history behind the handle. + +### 1.2 The `'a` is gone from the verify-window types + +`OriginalVerifyWindowResources<'ctx>`, `OriginalVerifyResources`, `OriginalVerifyGdnJournal`, `OriginalVerifyGdnWeights`, +`OriginalVerifyQsaJournal` (its twelve gamma buffers), `OriginalVerifyRope` (now `Clone`, not `Copy`; its optional tables +are handles, always `None` in the serve stack), the GR/MoE/projection/QSA bindings and their element types now hold +`DeviceRef`s. Files: `original_verify_window_{moe,gr,proj,qsa}.rs` (+ their subdirectories), `original_verify.rs`, +`original_verify/**`, `original_verify_window_ops*`, `qsa_verification_commit*`, `original_serve_access.rs`, the preflight +probe in `crates/cuda-driver/tests`. `DecodeResources<'ctx>` (engine) follows. + +`qwen_dispatch/fixed_operands.rs` is NOT changed: its 34 `&'a DeviceBuffer` are the operand groups of single kernel +calls (`MtpGrWeights`, `QsaPackedKv`, ...), built and dropped inside one call; nothing stores them, so they do not +tie an assembly to the caches. + +### 1.3 Engine plumbing (minimum to hand out clones; the files are listed in the report) + +* `DenseWeightCache::buffers: Vec`; `handle(i)` / `handles([i; N])` clone; the slot accessors are split into + `*_slot(s)` (role to index, owner check) plus the unchanged `&DeviceBuffer` accessors, so the prefill callers + (`gdn_matrix`, `gdn_aux`, `qsa_matrix`, `qsa_norms`, `ple_aux`, `router`) keep their types. +* `original_verify_gr/_qsa/_projections/_gdn_weights/_qsa_gamma` and `router_handle` return handles. +* `MoeWeightCache`: `EncodedWeight::Raw(DeviceRef)`; `raw_shared` returns a clone; eviction (`EncodedWeight::close`) + releases the cache's handle only. +* Stack: `ple_history` / `ple_scratch` are `DeviceRef`s; `AssembleInputs` / `VerifyWeights` take `&DeviceRef`; + `seed_ple_history(&DeviceRef)`. + +### 1.4 Hot loop + +Handles are cloned only while an assembly is built (engine caches, `assemble_parts.rs`) and in `park` / `rearm`. +The recorders, `OriginalVerifier::run` / `commit`, the journals and the graph validation read them through `Deref` +(`&**handle`, `Option::as_deref`); no allocation, no count traffic. Guard test: +`device_ref::tests::the_window_and_journal_modules_never_clone_a_handle` (source scan of the window-ops and journal modules). + +## 2. The API + +```rust +pub struct OriginalVerifyRearm<'s> { pub gdn_states: [&'s [f32]; 36], pub gdn_histories: [&'s [f32]; 36], pub ple_history: &'s [f32] } +impl OriginalVerifier<'ctx, R> { pub fn park(&mut self) -> Result<()>; pub fn rearm(&mut self, seed: OriginalVerifyRearm<'_>) -> Result<()>; } +impl OriginalVerifyCanonicalGdn<'_> { pub fn reseed(&self, states: [&[f32]; 36], histories: [&[f32]; 36]) -> Result<()>; } +``` + +`park`: refused (nothing changed) for a failed / released verifier or a window `active` or completed but neither +committed nor discarded (`window_ready`). Otherwise `wait_commit`, synchronize `compute` and `copy`, retire every graph's +launch (`resources_after_wait`), drop the held PCIe sources. An error fails the verifier. Graphs, bank, streams, event stay. + +`rearm`: order of refusals, none of which changes anything: seed shapes (`check_shapes`: 36 x `128*48*128`, 36 x +`10240*3`, `9*10240` f32), then `require_rearmable` (not failed / released here or by the watchdog registry, `active`, +`window_ready`, `commit_pending` false; bank and commit graph present; every graph idle; the QSA journal valid, not armed, +all twelve indices and journals idle and published at one position). After that any error sets `failed` (the stack retires +the set and records a new one, "a partial re-arm is safe"). The work, in this order: bank re-arm (below), canonical GDN +reseed and PLE history upload through the commit graph's journal (every aggregate shares both), counters. + +`reseed`: the intake of `original_verify_canonical_gdn` again, in place: same lengths check, finite check per layer, +36 x `copy_from_range_shared`; the device address of the image does not change. 117.7 MB host to device plus the f32 +to bytes conversion per layer, the same cost as today's upload. + +## 3. Reset checklist (what a fresh `new()` + `record_all` leaves, and where it is restored) + +| State | Restored to | Where | +| --- | --- | --- | +| `windows`, `commits`, `completed_generation`, `completed_ids`, profile counters | 0 / None / `[0; 8]` / default | `OriginalVerifier::reset_run_counters` (`original_verify_schedule/verifier_park_rearm.rs`) | +| `commit_pending`, `window_ready`, `active`, `failed`, `released` | false (preconditions) | `require_rearmable` | +| `split`, `groups`, `resource_keys`, window/commit graphs, streams, event, `test_stall` | unchanged (as recorded) | not touched | +| watchdog registry numbers (rows, first position, layer step, active) | 0 / false | `Registration::reset_window` (`original_verify_diag.rs`) | +| bank staged window (`t`, `position`, `tokens`, `keep`) | `StagedWindow::EMPTY` | `Book::rearmed` (`original_verify/original_verify_rearm.rs`) | +| bank generation and `Physical.generation` | + 1 (stale `OriginalVerifyRow` / `OriginalVerifyWindow` refused, `validate_context`) | `OriginalVerifyBank::rearm` | +| bank `released` | false | `Book::rearmed` | +| `pcie_sources` (registered banks held to the copy fence) | cleared | `release_pcie_sources`, also in `park` | +| `pcie_mode`, `pcie_roles` | unchanged (they are in the key) | not touched | +| mapped staging 0..=14: tokens, steps, positions, commit record, PLE rows, sampled ids, CPU rows, doorbell `seq` (9), flags served / plan (A) / copies (B) (10, 11, 12), CPU output (13), published GPU plan and fetch tables (14) | all zero (`initialize_zero`) | `Physical::reset_to_recorded`, `ResetPlan` | +| arena: GDN / QSA journals, `tail_snap`, `hist_snap`, `plan` copy, expert `staging`, `head_logits`, the `hit_count` status word of `verify_clear_status` | zero (`cuMemsetD8`, then a context synchronize) | `Physical::zero_device` | +| profile stamp buffer (`STRATA_VERIFY_PROFILE`) | zero | `Physical::zero_device` | +| canonical GDN image (36 states, 36 histories) | the seed, same address | `OriginalVerifyCanonicalGdn::reseed` / `Canonical::reseed` | +| PLE history image | the seed | `reseed_images` (journal `ple_buffer()`, `copy_from_shared`) | + +The flags a window waits on or raises are already zeroed by `stage` at the start of every window (`write_staged_rows`), so +a request that ends normally leaves them reusable; the re-arm restores the post-record value anyway (a released +verifier is refused, so the `u32::MAX` of `release_gpu_waits` never reaches a re-armed bank). The finite verdict word of the +head rows is re-armed by every `finish_same_stream`; the scan status is cleared by the graph. + +## 4. Not covered + +* The policy: key, `GraphReuse`, `LELEKA_DECODE_GRAPH_REUSE`, `weights_epoch` (not on this base: it is `moe_weight_cache/window_pins.rs` + in `claude/prefill-latency`; it belongs in `room` and `room_protected`, the two eviction sites, and my change leaves them as they were), + pinning, the QSA owner loan (`lend` / `take_back`, not on this base either: `require_idle` only checks the journal is quiet, + it does NOT compare owner addresses; if the owners moved, the graphs point at freed memory, so that comparison is the + loan's job), the drafter's programs bound to the bank (B3: after a re-arm the first draft must not reuse a tail of the previous request). +* A tensor the cache evicts and loads again lives at a new address; the held assembly keeps the old allocation with the same + bytes (weights are immutable), at the price of VRAM until the set is retired. Nothing here retires it. +* VRAM of a kept set (nine graphs, bank arena, mapped staging, 118 MB canonical image) during the prefill; the pool is the + stack's budget question (`decode-graph-reuse.md` section 5). +* Head-row and embedding-row aggregates: their words are rewritten by every window; not reset. +* `OriginalVerifyQsaJournal::snapshots` (the NaN-guard flag, set per request by `serve`) and its snapshot buffers. +* Any change of `max_t`, `max_cells`, expert formats, `WindowPolicy`, sm120 switches: a different recording. +* `target/` is not part of the change; no kernel, PTX or asset changed. + +## 5. Tests + +Without a GPU (`cargo test -p leleka-cuda-driver --features cuda-driver --lib`, 431 tests, 14 new): +`original_verify::rearm::tests` (seed shapes, little-endian PLE bytes, `Book::rearmed` clears the window, un-releases and +advances the generation by one without wrapping, the reset plan covers 15 mapped allocations, the arena and the profile), +`schedule::verifier_park_rearm::tests` (counters, the refusal for each of failed / released / active / window_ready / +commit_pending that changes nothing, no recording, wrong seed first, `park` refusals and the no-op `park`), +`diag::tests::a_rearmed_registration_...`, `device_ref::tests::the_window_and_journal_modules_never_clone_a_handle`. + +On a GPU (orchestrator): + +1. `LELEKA_VERIFY_WINDOW_GPU=yes cargo test -p leleka-cuda-driver --features cuda-driver --lib -- --ignored device_ref` + (handle release semantics, slab lifetime after the allocator released it). +2. The identity job over N requests with different prompts and lengths with the stack calling `park` / `rearm` (hex-finish): + top-16 logprob rows and the draft trace equal to the fresh-assembly run; the first window of request 2 accepted at the + QSA owners' position; `verifier.windows()` and the commit count of request 2 only; a `Row` / `Window` of request 1 + refused after the re-arm; the canonical image holds request 2's seed (`with_committed_gdn` after the first commit). +3. Re-arm cost: `drv.*` host spans and the new `rearm` time (H2D 117.7 MB + the arena memset, expected well below the + 83-85 ms of `record_all`; not measured here). + +## 6. Risks + +* Tensor addresses must not move while a set is held. Handles guarantee the memory is alive, not that the cache still + points at it; the stack must keep the key (weights epoch, owners). +* `rearm` zeroes the whole arena and every mapped allocation: correct for "fresh" semantics, a memset of the arena size + per request. If a measurement shows it matters, the reset can be narrowed to the spans that carry state, but that is a + separate, measured change. +* The merge with the owner loan touches `qsa_verification_commit/*` too (`require_idle` reads `indices[0]` and + `check_idle_at`, which become `Option` borrows there). diff --git a/docs/experiments/verify-gdn-fused-kernels.md b/docs/experiments/verify-gdn-fused-kernels.md new file mode 100644 index 00000000..5f0c829f --- /dev/null +++ b/docs/experiments/verify-gdn-fused-kernels.md @@ -0,0 +1,182 @@ +# Verify window, GDN layers: one launch instead of three, and the unrolled a/b projection + +Branch `claude/verify-gdn-fused-kernels` (base `91a130da6`, branch `claude/speed-vs-strata-08143a`). Ledger rows +`docs/experiments/step-ledger.md`: K7 (GDN role in total, +0.155 ms per round against vanilla), K7a (GDN step/norm in +the verify graph, +0.029 ms, 36 against 30.9 launches), U3 (upstream `STRATA_SMALL_UNR` bit 1, the unrolled GDN a/b +projection). Nothing here was measured on a GPU: this note states what the code does, how it was checked without one, +and what the orchestrator should look at. + +## What a GDN layer records today + +`record_window` calls `gdn_conv`, `gdn_alpha_beta`, `gdn_recurrence` for each of the 36 GDN layers +(`original_verify_window_record.rs`, `pre_gdn_front` / `pre_gdn_back`). Each one is one kernel of `original_verify.ptx`: + +| call | kernel | grid x block | +| --- | --- | --- | +| `gdn_conv` | `verify_gdn_conv_l2_multi_kernel` | 80 x T, 128 | +| `gdn_alpha_beta` | `verify_gdn_ab_multi_kernel`, or `chain_gdn_ab_multi_kernel` with `LELEKA_CHAIN_AB` (`LELEKA_CHAIN=all`, the 5090 profile) | 12 x 256, or 96 x 32 | +| `gdn_recurrence` | `verify_gdn_step_norm_multi_kernel` | 48, 128 x 4 | + +That is 108 launches per verify graph. Vanilla also runs conv, ab and step as three kernels, so the gap K7 is launch count +and the conv (grid 80 x T of 128 threads for a 10240 x 4 tap convolution, one launch of its own). + +## `LELEKA_SM120_FUSED_GDN` (default off) + +One new kernel, `leleka_verify_gdn_fused_step` (`crates/cuda-driver/src/sm120_gdn_fused.cu`), 48 blocks of 128 x 4, +one block per value head: the Original's step loop with its loads redirected to shared memory, preceded by: + +* **conv prologue.** The block convolves the q chunk (`head % 16`), the k chunk (`16 + head % 16`) and its own v chunk + (`32 + head`), 128 channels each, for the new tokens `[t_begin, t_end)`. The 3 x m tasks are dealt to the four 128-thread + groups (`threadIdx.y`); every group runs the same number of rounds and one barrier per round, an idle task computes zeros. + q, k and v go to shared memory (`FusedShared`, 18.6 KB). The blocks of heads < 16 write q and k to `h`, every block writes + its v chunk to `h`: the commit graph (`draft_commit.cu`, `verify_gdn_step_norm_multi_kernel` with `n_keep`) and a later + group of a split window read `h`, so each of the 80 chunks of a row still has exactly one writer. The q/k conv of a head + pair is computed by the three heads that share it (the redundancy of this design; only the heads < 16 store it). +* **gates.** With `ab_x != 0` warp 0 and warp 1 of the block compute alpha row `head` and beta row `head` for the new + tokens (the ten weight chunks are loaded first, so they are in flight during the conv; the dot products then run per + lane in the Original's order) and write `gate` / `beta` to global (the commit reads them) and to shared memory. With + `ab_x == 0` they are read (see SIDE_MIXER below). +* **replayed tokens.** Tokens before `t_begin` (the earlier group of a split window) are read from `h` / `gate` / `beta` + into shared memory, as the Original reads them. Their state update is done; their o dot product and output path never + feed the state and are not computed (as `draft_commit.cu`). +* **step loop.** `s = fma(g, s, k * delta)` etc. over shared `q`, `k`, `v`, `gate`, `beta`. Barriers per token: one for + `kv` (double buffered by token parity, so a replayed token has only this one), and for an output token one for `o` and + one for the squared-sum partials. The Original had six per token. + +The state is not written (the window passes `n_keep = 0`), as before. + +### Dispatch (`original_verify_window_ops/gdn_stages.rs`, `GdnFusedPolicy::stages`) + +| switches | `gdn_conv` | `gdn_alpha_beta` | `gdn_recurrence` | GDN launches per layer | +| --- | --- | --- | --- | --- | +| off | conv | ab | step | 3 | +| `FUSED_GDN` | nothing | nothing | fused (gates in kernel) | 1 | +| `SIDE_MIXER` | conv | nothing (side stream 0) | step | 3 (one on the side stream) | +| `FUSED_GDN` + `SIDE_MIXER` | nothing | nothing (side stream 0) | fused (gates read, after the side joins) | 2 (one on the side stream) | + +So 108 launches per verify graph become 36 (72 on the main stream with SIDE_MIXER). Only the conv is fused with +SIDE_MIXER, as designed: the gates stay on side stream 0 and the fused launch comes after both joins. The conv no longer +overlaps the side-stream gates in that combination; that is a cost to read off the CUPTI window, not a measured one. +Split windows (`groups == 2`) fuse with the gates in the kernel. + +## `LELEKA_SM120_GDN_AB_UNROLL` (default off, independent) + +Upstream commit `08b20b104` (`gdn_ab_body`, `STRATA_SMALL_UNR` bit 1): the same a/b projection with the loop over the ten +32-lane passes (`j = lane + 32 jj`, all below 320) and over the tokens at constant trip counts, so the loads of several +passes can be issued before the first FMA chain. Its own entries in the same asset: `leleka_gdn_ab_unrolled_t1..t6` +(exact token count) and `_t8` (T = 7 and 8, run time count, upstream's `kVerifyNarrowT` split). It replaces the a/b kernel +wherever that runs as a kernel of its own (no `FUSED_GDN`, and the side-stream gates). + +Geometry: one warp per row, 96 blocks of 32 threads, the shape of `chain_gdn_ab_multi_kernel` that `LELEKA_CHAIN=all` +records, so the unrolled loop is the only difference to the shipped kernel. Upstream's own shape (48 blocks of 64 +threads, two rows a block) runs the same entries (`row = blockIdx.x * (blockDim.x / 32) + warp`); the probe covers both. +Expectation to keep honest: the shipped chain kernel already hoists the ten weight loads (K7b: 8.5 us, ahead of +vanilla's 10.5 us), so the unroll may add little over it; with `FUSED_GDN` the gates are inside the fused launch and this +switch only affects the side-stream branch. + +## Bitwise argument + +The target is "identical to the three kernels", after the driver's JIT, which loads `cuModuleLoadData` with default +options (`original_verify_ffi.rs`). + +1. **Same expressions, same PTX shape, not intrinsics.** The brief suggested `__fmul_rn` / `__fsub_rn` to forbid + contraction. That is wrong for these kernels. ptxas contracts a plain `mul.f32` that feeds an `add.f32` / `sub.f32` + into one FFMA (checked on `rnr5090` with ptxas 13.2.86 `-arch=sm_120`: a two-instruction kernel with `mul.f32` + + `sub.f32` assembles to a single FFMA, the `.rn` forms to FMUL + FADD; `--fmad=false` makes the plain form behave like + `.rn`). The sealed `original_verify.ptx` has a plain `mul.f32`, `sub.f32`, `mul.f32` for `delta = beta * (v - g * kv)`, + so the Original *executes* `beta * fma(-g, kv, v)`. An intrinsic version would not. The kernel therefore uses the + same plain C++ expressions as `original_verify.cu` (and explicit `fmaf` where the Original has `fmaf`), and a unit test + compares the PTX. +2. **PTX comparison (CPU, unit tests `original_verify_window_gdn_fused::tests`):** the numeric instruction sequence of the + Original's conv kernel (26 instructions: `mul`, 3 `fma`, silu by `div.rn`, `y * y`, five butterfly adds, barrier, the + four-partial sum, `rsqrt.approx`, `mul`) is a contiguous run of the fused kernel; the delta (`add add add mul sub mul`) + and the whole output tail (`rsqrt.approx` of 128 at run time, `ss / 128 + eps` as one `fma.rn`, `rcp.rn` for the + sigmoid) are runs of both; the set of numeric opcodes of the fused kernel equals the union of the three Originals', with + no `.rn`-suffixed `add` / `mul` / `sub`, no `.ftz`, no approximate division; each unrolled entry has the Original a/b + kernel's opcode set. The ten `log1pf` polynomial constants are the same in 13.0.88 (`original_verify.ptx`) and 13.2.86 + (`chain_window.ptx`, this asset). +3. **Arithmetic order.** Conv: `((v1*w1 -> fma v0 -> fma v2 -> fma x)`, silu `div.rn`, L2 partials by xor butterfly over + a warp then `((p0+p1)+p2)+p3`. Gates: per-lane chunk-ascending fma chains, xor butterfly, the Original's gate/beta + formulas. Step: `kv` fma chain from 0, `((r0+r1)+r2)+r3`, `s = fma(g, s, k*delta)`, `o = fma(s, q, o)` in `r` order, + `oc = sum * rsqrt(128)`, `scale = rsqrt(ss/128 + eps)`, `y = oc * scale * gamma * rcp(1 + exp(-z))`. +4. **Model-free probe, not run by this task (no GPU):** `tools/gdn-fused/gdn_fused_probe.cpp` runs the fused launch next + to the three Original kernels for T = 1..8, every split of the window into two groups, gates in the kernel and joined, + three seeds, and compares every byte of `h`, `gate`, `beta`, `y`, state and history; it also compares every unrolled entry + (both geometries) with the Original and the chain a/b kernel. Build: `tools/gdn-fused/build.sh` (nvcc 13.2.2), run + `gdn_fused_probe OUTDIR/ptx`. It compiles (`nvcc -c`, checked on the server) and has not been executed. + +## Asset and sealing + +* Source `crates/cuda-driver/src/sm120_gdn_fused.cu`, PTX `sm120_gdn_fused.ptx` beside it, sm_120 only + (`ptx-sm86/MANIFEST.json`: "not built for sm_86 by design"; the switches take effect on a 12.x card only). +* Built on `rnr5090` (compile only, no GPU) with `~/cuda-toolkits/13.2.2/bin/nvcc --ptx -O3 -arch=sm_120 -std=c++17 + --fmad=true --ftz=false` (13.2.86, the recipe of `original_verify.cu` / `draft_commit.cu`). sha256 `.cu` + `f46a3c59dd2e203d1ba1b997f5e2f5aeaa40185d72468bce2ceb12d1ecbdb95f`, `.ptx` + `9da33e8217c1e4daa2d26f9739874978e9c206eb5f30f9417f5df8b526e37f17`. +* Pinned in `GDN_FUSED.sha` (`original_verify/original_verify_window_gdn_fused.rs`); plan entry in + `scripts/gpu-bringup/extra-seal-plan.json` (group `sm120-decode`). The pin was filled by hand from the digest (the + `seal_pins.py` flow needs a compile manifest); `assert_sealed_and_fail_closed` checks pin, structure and the refusals. +* Fails closed: a requested switch whose asset is not sealed refuses the recording with `Original verifier asset + unsealed: sm120_gdn_fused.ptx (...)` (`gdn_fused::prepare`), instead of silently running the default path under the name + of the switch (the `ATTN_DAILY` precedent falls back silently, which would mislabel a paired A/B arm). +* `ptxas -v` (sm_120): fused step 64 registers, 18640 bytes shared, 20 bytes of spill; unrolled `t1..t6, t8`: 39, 48, 48, + 52, 50, 56, 44 registers, no spill. +* Server path created (orchestrator may move it to garbage): + `/data/leleka-e2e/spd-gap/ptx-build/verify-gdn-fused-kernels/` (the `.cu`, `.ptx`, test PTX of the contraction check, + cubins, `ptxas-v.txt`, probe object). + +## Where the code is + +| file | change | +| --- | --- | +| `crates/cuda-driver/src/sm120_gdn_fused.cu`, `.ptx` | new asset | +| `crates/cuda-driver/src/original_verify/original_verify_window_gdn_fused.rs` (+ `/tests.rs`) | switches resolution, asset, launch DTOs, stage plan (`GdnFusedPolicy::stages`), 18 tests | +| `crates/cuda-driver/src/original_verify/original_verify_gdn_journal/verify_gdn_fused_step.rs` | `capture_fused_recurrence`, `capture_ab_unrolled` (operand spans as `capture_layer_stage`) | +| `crates/cuda-driver/src/original_verify_window_ops/gdn_stages.rs` | the three `WindowOps` GDN calls (moved out of `window_ops_kernels_and_pcie_plan.rs`) | +| `original_verify_window_sm120.rs` | `fused_gdn`, `gdn_ab_unroll` in `Sm120Switches`, `DEFAULT_ON_*` (separate block) | +| `original_verify.rs`, `original_verify_gdn_journal.rs`, `original_verify_window_ops.rs`, `original_verifier.rs` | one `mod` line each, the `gdn` field of the ops struct and its resolution | +| `verify_gdn_journal_stage_and_commit.rs` | `StageOperands` / `stage_operands` `pub(super)` | +| `ptx-sm86/MANIFEST.json`, `scripts/gpu-bringup/extra-seal-plan.json` | not-built-for-sm_86 note, plan entry | +| `tools/gdn-fused/` | probe and build script | + +## Tests and gates (no GPU) + +* `test -p leleka-cuda-driver --features cuda-driver --lib original_verify`: 179 passed (161 on the base commit + 18 new), + 11 ignored (GPU). Whole crate (`--features cuda-driver`): lib 397 passed, 78 ignored, the integration tests as before. +* New tests: default off; each variable turns on its own switch and nothing else, 12.0 and 12.1 take it, below 12 never; + asset sealed and exports every entry; launches per layer with the switch (3 -> 1; with the side branch 3 -> 2; 108 -> + 36 per graph); the unrolled gates replace only the a/b kernel; the argument words follow `FusedGdnArgs` of the kernel + source (parsed from the `.cu`); the fused launch writes `h`, `gate`, `beta`, `y` and carries no activation row when + joined; row range refusals; unrolled entry by token count; the unrolled launch takes the Original's arguments; the four + PTX comparisons above. +* `python3 scripts/check-architecture.py`: 0 errors (the new files use `dir/name.rs` paths, so the `path-include` + ratchet does not rise). `scripts/check-limits.py --base claude/speed-vs-strata-08143a`: 0 errors. + +## For the orchestrator + +Identity (teacher-forced replay, top-16 rows + draft trace): arm A default, arm B `LELEKA_SM120_FUSED_GDN=1`, arm C +`LELEKA_SM120_GDN_AB_UNROLL=1`, arm D `FUSED_GDN=1` + `LELEKA_SM120_SIDE_MIXER=1` (the joined path), each with the +shipped `LELEKA_CHAIN=all`. Only the env switch is needed. Look for a split window in the replay (`groups == 2`) and for +T = 1..8; the probe covers them without a model. + +CUPTI window, kernel names: + +* before: `verify_gdn_conv_l2_multi_kernel`, `chain_gdn_ab_multi_kernel` (or `verify_gdn_ab_multi_kernel`), + `verify_gdn_step_norm_multi_kernel` (36 each per verify graph; the last one also appears in the unfused commit graph); +* after `FUSED_GDN`: `leleka_verify_gdn_fused_step`, 36 per verify graph, the three above absent from the window graph; + launches per verify graph (V8) 2061 -> 1989 by count (-72); +* after `GDN_AB_UNROLL`: `leleka_gdn_ab_unrolled_t` in place of the a/b kernel. + +The section delta is K7 minus the commit part: sum of the three kernels per graph (conv, ab, step) against the fused +kernel. Risks to read off the window: the fused kernel runs 48 blocks only, so its prologue is serial per block (conv of +three chunks, then the gates, then the loop), the q/k conv is done three times, and with SIDE_MIXER the conv no longer +overlaps the gates. No gain is claimed. + +## Identity risks left + +* ptxas contraction decisions follow the PTX shape; the shapes were compared, but SASS was not (no `nvdisasm` in the server + toolkit). The probe is the proof. +* The barrier hazards of the double buffered `red_kv`, `l2` and the single `red_o` / `wsum` were argued on paper (each + buffer is re-written only after a barrier all readers have passed) and cannot be seen by a unit test. +* `log1pf` and the other libdevice expansions come from nvcc 13.2.86 here and 13.0.88 in `original_verify.ptx`; the + constants of `log1pf` are equal, the rest of the sequences are covered by the opcode-set test. diff --git a/docs/experiments/verify-hc-down-kernel-microbench-vs-upstream.md b/docs/experiments/verify-hc-down-kernel-microbench-vs-upstream.md new file mode 100644 index 00000000..c9c33b51 --- /dev/null +++ b/docs/experiments/verify-hc-down-kernel-microbench-vs-upstream.md @@ -0,0 +1,135 @@ +# Hyper-connection down kernel: upstream `gr_down_v3_kernel` (masks 133 / 5) against our `chain_gr_down_t2w8_nb4`, per window rows (ledger row U5) + +Status: the program is written, built and frozen on the server; it has **not been run** (the GPU is a queue; the orchestrator installs and +queues the stub). Nothing in this note is measured. Base: `6b2a69f1d` (branch `claude/speed-vs-strata-08143a`, contains `05e9acdaa`), +upstream `strata-upstream/main` = `504b143342a9fe1aa8320a7b31e11f5c0ac265c3`. Ledger rows: `step-ledger.md` K8 (`chain_gr_down_t2w8_nb4` +11.1 us against `gr_down_staged` 11.5 us), U4 (batched staging/read loads, `STRATA_GR_V3_PF` bits 0 and 2), U5 (bit 7, two rows a warp for +windows of 5+ rows, mask 133, upstream commits `4ab81c796`, `5f24b96db`, `08b20b104`). + +## 1. Question + +Per window rows T = 1..8 on the RTX 5090: is upstream's down kernel (mask 133 = 128 + 4 + 1, and for reference mask 5 and the plain mask 0) faster +than ours, by how many microseconds, and are the outputs bitwise equal? + +## 2. What the two kernels are (read from the code, not from the ledger) + +| | upstream `gr_down_v3_kernel` (`src/kernels/cuda/fused_gr.cu`) | ours `chain_gr_down_t2w8_nb4` (`crates/cuda-driver/src/chain_window.cu`) | +| --- | --- | --- | +| input | `R`, `bo_prev`, `inj_prev`, `w_norm` of every token: the kernel itself builds `R' * w_norm` in shared memory and sums `R'^2` | `xn` = normalised activations, written before by the separate kernel `chain_gr_split` (3 us in K10) | +| output | **unscaled partial dots** `part[token][stream][row]` (324 rows: 320 down + 4 inject) and `ssg` (sum of squares per stream); `lo`, `rs` and `inject_out` come out of the prologue of the following `gr_up_v3_kernel` | final `lo = silu(dot / hc)` and `inject_out` per token, `rs` from `chain_gr_split` | +| summation | per stream (2560 columns, 10 chunks a lane), then `fmaf(rs[c], part_c, sum)` over the 4 streams | one 10240-column dot in tile order, on activations already multiplied by `rs` | +| grid (T = 1..4) | mask 5 and 133: `gr_down_v3_kernel<1,T,exact,R2V=1,PF=1>`, grid (41, 4), 256 threads, dynamic shared `T * 10240` B | grid (41, ceil(T/2)), 256 threads, dynamic shared 4 tiles of 2 tokens = 40960 B (20480 B at T = 1) | +| grid (T = 5..8) | mask 133: `<1,T,exact,R2V=2,PF=0,RB=true>`, grid (21, 4), shared `T * 10240` B (up to 81920 B); mask 5: as above (41, 4) | the same formula, ceil(T/2) = 3 / 3 / 4 / 4 | + +Consequences, stated so the result is not over-read: + +* **Not bitwise.** The two kernels sum the same products in a different order and place the rms scale differently (upstream's own header says "ANOTHER + SUMMATION ORDER"). Equality to the bit is not expected; the harness reports how large the difference is (section 5). Upstream's masks 0 / 5 / 133 are + claimed bitwise equal to each other (`gr_v3_screen`); the harness checks that claim on `part` and `ssg`. +* **Upstream's down kernel does more than ours** (it stages `R' * w_norm` and reduces the sum of squares; ours has that in `chain_gr_split`). The fair + pair for "the HC read up to the low-rank activation" is therefore reported both ways: our down kernel alone, and our split + down. + The whole read (down + up for upstream, split + down + up8 for ours) is measured as a third comparison. +* Upstream's default on cc 12.0 is mask 133 (`include/strata/core/bw_dense_defaults.hpp`, `gr_v3_pf_default`). Its dispatch for mask 133 is bit 7 for + n >= 5 (R2V = 2 register-blocked), else bit 0 (`PF=1`, staging loads of all tokens in flight) for n <= 4; bit 2 belongs to the up kernel. The harness + copies that selection ladder (`upstream_down_launch.inc`) and calls upstream's own launch helpers. + +## 3. Method + +One program, `scripts/e2e/codex/speed/verify-hc-down-kernel-microbench-vs-upstream/microbench.cu` (+ `upstream_down_launch.inc`, +`compare_outputs.inc`, `summarize.py`, `build.sh`, `ours-shim/`): + +* Upstream: `fused_gr.cu` is `#include`d whole and unmodified (so kernels, constants and helpers are upstream's own); compiled with nvcc 13.2.2 + `-O3 -DNDEBUG -arch=sm_120 -std=c++17` (see assumptions). The down kernels are launched directly (masks 0, 5, 133). For the pipeline and for the + real `rs` / `inject_out` / `mixed` outputs upstream's own entry point `fused_gr_read_multi` runs with `STRATA_GR_V3=1` and `fused_gr_v3_pf(mask)`. +* Ours: the **sealed `chain_window.ptx` through `cuModuleLoadData`** (how the product loads it), launched with `cuLaunchKernel` with the 912-byte + by-value `GrMulti` filled the way `multi_words` in `original_verify_window_gr/assets.rs` does; geometry from `tiled_down_geometry` (grid + `(41, ceil(T/2))`, 256 threads, 40960 B shared), `chain_gr_split` grid `(T, 4)`, `chain_gr_up8` 320 blocks. The same source built by nvcc 13.2.2 to a + cubin (flags of `extra-seal-plan.json`: `-O3 -arch=sm_120 -std=c++17 --fmad=true --ftz=false`) is measured next to it, which separates the driver's + PTX JIT from the kernel (`build.sh` also checks that the regenerated PTX is the sealed one: the three HC kernels are identical, differences are only in + mangled-name hashes and in the sampler and swiglu kernels). +* Inputs (same for every variant): the distributions and the seed (7) of upstream's `gr_v3_screen.cpp`: `R ~ N(0,1)`, `bo ~ 0.5 N`, `inj ~ N(0,1)`, + `w_norm = 1 + 0.3 N`, `w_down ~ 0.02 N` (bf16, `[320][10240]`), `w_up ~ 0.05 N` (bf16, `[10240][320]`), `w_inject ~ 0.02 N` (bf16, `[4][10240]`), `apply = 1`, + inject on (a layer read). Model dims: `N = 2560`, `HC = 4`, `LR = 320`, `D = 10240`, from `fused_gr.cu` (`kCompiledGeometry`) and + `chain_window.cu`, equal in both. Weight values do not change the timing; the bit comparison uses the same finite values in both. +* Timing, three views, interleaved over variants and rounds (7 rounds, the start variant rotated each round): + 1. **graph, cold weights (headline)**: 64 launches captured in one CUDA graph, each on its own copy of the layer weights (64 sets, 13.2 MB each, 845 MB; + the 5090's L2 is 96 MB, so the weights come from DRAM as in the engine, where 96 layer halves rotate). Per-launch time = graph time / 64; 40 replays + a round, so `n = 280` graph replays a variant and T. Median, p10, p90 over the replays, and the range of the per-round medians (the noise bound). + 2. **graph, warm weights**: the same, all 64 launches on set 0 (weights stay in L2): the kernel's compute/issue floor. + 3. **single launch**: a 50 us spin kernel keeps the stream ahead of the host, then event, launch, event; 120 launches a round; includes the + event overhead, which the two empty-kernel rows measure. + Also timed in every view: an **empty kernel with the same grid, block, dynamic shared memory and by-value argument** as upstream's mask 133 launch and as + ours (the launch-shape floor; subtract it to compare kernel bodies, or compare it between the two shapes), and the **whole read** (graph, cold weights). +* A 2 s warm-up of the real kernels runs first; the stub samples SM clock, power and throttle reasons once a second (`smi.csv`). +* Correctness (`compare_outputs.inc`), per T, window rows with `apply = 1`: + A. upstream masks 5 / 133 against mask 0, byte for byte on `part` and `ssg` (upstream's claim); + B. our sealed PTX against our nvcc cubin, byte for byte on `lo`, `inject_out`, `rs`; + C. our down stage (`lo`, `inject_out`, `rs`) against each upstream mask. Upstream's `lo` never leaves shared memory, so it is rebuilt from `part` / `ssg` + by `mb_finalize_down`, a transcription of the prologue lines of `gr_up_v3_kernel` (marked as such in the source); `rs` and `inject_out` are also + compared from upstream's real up kernel (D); + D. the whole read: `R` (updated in place), `rs`, `inject_out`, `mixed` of ours (split + down + up8) against upstream's real `fused_gr_read_multi`, each mask. + Each comparison prints the number of words, the number that differ bitwise, the largest absolute and relative difference, the largest distance in ulps, + and non-finite counts. + +## 4. Inputs (sha256; the full list of 419 files is `MANIFEST.sha256` on the server) + +Server directory `/data/leleka-e2e/spd-gap/microbench/verify-hc-down-kernel-microbench-vs-upstream/` (frozen read-only; the stub runs `sha256sum -c MANIFEST.sha256` +first and refuses to start on a mismatch): + +| file | sha256 | +| --- | --- | +| `upstream-src/src/kernels/cuda/fused_gr.cu` (`strata-upstream/main:src/kernels/cuda/fused_gr.cu`) | `35a9f21a5eeaa187c8f20cc8ae35e31ccb563f663f199b305e104a4c81fc589f` | +| `upstream-src/include/**` (228 files) and `s26_tsum.cuh`, `gr_v3_screen.cpp`, `fused_gr_bench.cpp` | in `MANIFEST.sha256` | +| `ours-src/crates/cuda-driver/src/chain_window.cu` (git blob `4cb96e8bd`) | `54ff6a3d96ac6c5ebbc30b7d9f3dea021c6589892eaefd777300d7d80645f9af` | +| `ours-src/crates/cuda-driver/src/chain_window.ptx` (sealed; git blob `716a0d24e`) | `a3abdc4186b66d51a80c8ef52f636f1893a2136b887cd6548786fea279ef71ba` | +| `harness/microbench.cu` | `bd5d6f768af1d50e9897f12138488676a628a06b5cfc5c46fff23e5db6290505` | +| `harness/upstream_down_launch.inc` | `923c4edeabffc2d24128134ee29842ba2ae34e1517077a37ed4fd5b4d4e7b7c4` | +| `harness/compare_outputs.inc` | `6a184d3399a3eb9b9cd92e198397ec4c584c7fc1615e526ddd1672d2f2d9e417` | +| `harness/summarize.py` | `d2625d2e35029437078f551c73d58b7b89bfdb71359a6c23d2c7282784185ec1` | +| `harness/build.sh` | `516b2d3751f615f3dfd0b0590c307a816e84e40ec8a1f04349ba28e25ee90da5` | +| `harness/ours-shim/strata/kernels/fused_gr.hpp` | `3022f1d2362bc2eb6ac2c8a59015e90a920ce272440682763b76c3b001e93942` | +| `build/microbench` | `0601fa9c1790ceba12d7f66935912b6128c26bd3bef5da3f1d40461fbc419c31` | +| `build/chain_window.cubin` | `fdeb42ab660991bc84ddc5bcb201671eedcc962d0f3068a9a3624f80b227f0c1` | + +## 5. How to read `result.txt` + +Written to `/result.txt` (earlier results are kept as `result..txt`; clocks in `smi.csv`). + +* Top: environment, clocks, the sha256 of binary and inputs, then `SHAPE` lines (grid, block and dynamic shared of each kernel per T), then the + `CORRECTNESS` / `DIFF` lines (before any timing), then `TIME` lines (one per mode, T and variant: median, p10, p90, min, mean, range of the per-round + medians, n) and `CSV,` lines (the same numbers for scripts). +* Bottom, `== tables`: per mode a table of medians with p10..p90 per T, and delta tables `ours - upstream` (microseconds and percent; **positive = upstream + faster**). A `*` marks a delta larger than the sum of the per-round-median ranges of the two variants, i.e. resolved against the run's own noise; no `*` + = not resolved. Delta tables: our down kernel alone, and our split + down, each against mask 133, 5, 0; and the whole read. +* The answer to the ledger question per T: row `ours_ptx` against `up_m133` and `up_m5` in "graph-batched, cold weights (headline)" (our down alone), and + `ours_split+down` against the same for the complete stage; `ours_cubin` against `ours_ptx` shows whether the driver's JIT matters; the `empty_*` columns give + the launch-shape floor of each kernel's grid. +* Bitwise: `DIFF ... part/ssg` of mask 5 / 133 against mask 0 must say `differing 0` (upstream's claim; if not, say so in the ledger); `ours_sealed_ptx vs + ours_nvcc_cubin` must say 0; `ours_sealed_ptx vs upstream_mask*` for `lo`, `inject_out`, `rs` and the whole read (`R updated`, `mixed`) is the data + the ledger needs: `differing` words, `max_abs`, `max_rel`, `max_ulp`. The final line `CORRECTNESS summary: N unexpected` counts only the first two + checks and non-finite outputs; ours-versus-upstream differences are not counted as failures. +* Cross-check against upstream's own number (RTX PRO 5000, `step-ledger.md` U5): its down kernel 16.1 / 16.2 / 17.6 / 19.5 -> 13.3 / 14.1 / 14.7 / 15.6 us at + T 5-8 (plain -> mask 133, in situ, other card). The mask-0 and mask-133 rows here should show the same direction; the absolute values need not match. + +Command (after the orchestrator has installed the stub in `~/work/gpu-runs/holder2/jobs/`): the job runs +`bash ~/work/gpu-runs/holder2/jobs/verify-hc-down-kernel-microbench-vs-upstream.sh`. A short check run: `MB_ARGS="--tmin 1 --tmax 2 --rounds 2 --replays 10" bash `. +Run time estimate (not measured): 2 to 4 minutes after the PTX has been JIT-compiled by the driver (the 2.3 MB module). + +## 6. Assumptions and limits + +* **The program has not run on the GPU.** It compiles (nvcc 13.2.2, no warnings beyond a suppressed unreachable-loop remark in upstream's own template) and was + reviewed by reading only, but a first run can still fail at a launch; the stub's exit code and `result.txt` show where. Nothing here was validated on a device. +* The headline timing is graph-batched, per launch inside a graph (launch gaps inside a graph are included, about the same for every variant: see the empty + rows). It is **not** the CUPTI in-situ kernel duration of K8 / `CL.1` (11.1 us, 9.35-15.33 us by rows), where the neighbouring kernels, the L2 state and the + clock differ; do not compare absolute values with those. The comparison between variants inside one run is the result. +* "Cold" means rotating 64 weight sets of 6.6 MB (down + inject) so that none is in L2 at its next use; the 5090 L2 size is printed in the first line. The + activations (`R`, `xn`) are L2-resident in every variant. In the engine the previous kernels have touched other data between two reads; that is not modelled. +* Upstream's build flags are taken from `cmake/backends/cuda.cmake` / `strata_gpu_engine.cmake` (Release, architecture 120, no fast-math for `fused_gr.cu`); the + CUDA language standard of the upstream build is not stated there, and `-std=c++17` is used. nvcc 13.2.2 is the toolchain of both sides; upstream's + release builds may use another CUDA version, whose code generation can differ. +* Ours through the driver JIT and as an nvcc cubin are both measured; the product uses the former. +* The `ours-shim/fused_gr.hpp` is needed only for the nvcc rebuild of `chain_window.cu` (the header in `engine/strata/include` has a 168-byte `FusedGrArgs`; the + sealed kernels use the 112-byte layout). The sealed PTX needs no header. +* The `lo` comparison goes through a transcription of the up kernel's prologue (`mb_finalize_down`), not through upstream's compiled code; the `rs`, + `inject_out`, `R`, `mixed` comparisons use upstream's real kernels. +* The GPU is shared by queue: another process on the card during the run would spoil it; the stub holds `gpu.lock` and logs the compute apps and the clocks. diff --git a/docs/experiments/verify-qsa-fused-prelude.md b/docs/experiments/verify-qsa-fused-prelude.md new file mode 100644 index 00000000..330792c5 --- /dev/null +++ b/docs/experiments/verify-qsa-fused-prelude.md @@ -0,0 +1,100 @@ +# Verify window, QSA layer: fused K/V and indexer append (`LELEKA_SM120_FUSED_QSA_PRELUDE`) + +Ledger rows: S10 (batched K/V and indexer append), the append part of K6 (attention role, +0.232 ms per round against +vanilla). Status: implemented, opt-in, default off, **no GPU number exists** (nothing was run; the orchestrator +measures). Sources: `original_verify_window_qsa/fused_prelude.rs` (plans, assets), `original_verify_window_qsa_kv_rows.cu`, +`original_verify_window_qsa_index_rows.cu`, the wiring in `original_verify_window_ops/qsa_prelude_ops.rs`, +`original_verify_window_qsa/qsa_window/qsa_window_prelude_rows.rs` and `qsa_verification_commit/ +verify_qsa_journal_index_image.rs`. + +## 1. What the graph records today (per QSA layer, 12 per graph, n = window rows of the group) + +| # | launch | count | grid x block | what it writes | +|---|--------|-------|--------------|----------------| +| 1 | `qsa_index_k` (bf16 gemv) | 1 | | `idx_raw_L[q][row]` | +| 2 | mmvq K, mmvq V | 2 | | `kcur`, `vcur` | +| 3 | `qsa_k_norm_rope` (`qsa_decode_rms`, `qsa_decode_rope`, fast math) | 2 | | `kcur` in place | +| 4 | `verify_copy_from_mapped_kernel` (tail snapshot, first group only) | 1 | 1 x 256 | `tail_snap[q]` <- index tail | +| 5 | `mtp_original_append` | n | (kv_heads, head_dim/64, 2) x 64 | K and V int8 codes + f16 scales, resident page and host copy | +| 6 | `verify_qsa_append_analytic` | n | 1 x 256 | tail slots, `dead`, pooled key blocks, `block_pos` | + +Rows 4 to 6 are `2 n + 1` launches. Vanilla does the same work as `kv_append_q8_steps` (one launch, `kv_append_q8_kernel`) +and `native_qsa_indexer_append_steps` (one launch, `append` with `n_steps`), see `engine/strata/src/kernels/cuda/kv_q8.cu` +and `native_qsa_indexer.cu`; ledger S10: vanilla `append` 12 x 3.0 us and `kv_append_q8` 14.6 x 2.2 us per round against our +`verify_qsa_append_analytic` 138 x 1.04 us and `mtp_original_append` 49 x 1.6 us (CUPTI, `step-ledger.md` row S10). + +## 2. What can be merged bitwise + +**K/V rows (row 5): n launches -> 1.** Rows are independent: row j reads only its own `step` row and its own K/V row and +writes its own cell (codes and scales are per row, head and 64-value group; no read-modify-write of a shared scale). The +merged kernel is the Original multi-token form (`kv_append_q8_kernel`, S26 STRATA_LFUSE) with rows along the grid. +One CTA of 256 threads is one (row, K or V, head), its four 64-thread quarters are four 64-value groups, so each group +of 64 values is reduced as in the Original (shuffle max in each warp, `fmaxf` of the two warp values; max is exact), and +the scale, code and stores are the same operations. Precise math, like `mtp_original_kv.cu` (`amax / 127.0f`, `x / sf` +are `div.rn.f32` in both PTX files). + +**Tail snapshot + indexer rows (rows 4 and 6): 1 + n launches -> 1.** Row r + 1 reads what row r wrote (tail slots, `dead`, +pooled keys), so the rows are a chain; one CTA of the same 256 threads runs the snapshot copy and then the body of +`verify_qsa_append_analytic` once per row, in order (the same construction as `draft_commit_qsa.cu`, one layer per block). +Fast math like the Original indexer (powf/cosf/sinf approximate). The snapshot reads the tail before any row writes it +(a barrier separates them); a row that only stores into the tail touches no shared memory and only its own column, so it +needs no barrier; a row that closes a block ends with the barrier the single launches had at kernel end. +Only the analytic RoPE variant is fused; with retained angle tables (`verify_qsa_append_table`) the per-row launches stay. + +Not merged, and why: + +* **`qsa_k_norm_rope` into the K append.** Its output feeds the append directly, but the norm/RoPE kernels are fast math + (`__powf`, `div.approx`) and the append is precise (`div.rn`): one translation unit cannot be both without rewriting the + arithmetic by hand, and a mismatch there changes K codes. Not worth the identity risk for 2 launches per layer. +* **One launch for K/V rows and indexer rows.** Saves 1 more launch per layer, but needs one math mode for both halves + (same objection) and would join the indexer chain to the K/V chain, which `SIDE_QSA` runs on different streams. +* **`qsa_index_k` and the mmvq K/V**: projections, other owners. + +## 3. Launches saved + +Per graph (12 QSA layers, one row group of n rows): before `12 (2 n + 1)`, after `24`. n = 1: 36 -> 24; n = 4: 108 -> 24; +n = 8: 204 -> 24. Split windows (two groups): the snapshot only before the first group's rows, as today. The saving in +time is not claimed here; the ledger estimate for S10 is 0.05 to 0.10 ms per round (upstream plan, not a measurement). + +## 4. Order and the SIDE_QSA branches + +The fused launches sit exactly where the launches they replace sit: + +* in-line order (`SIDE_QSA` off): K/V rows after `qsa_k_norm_rope` (the `qsa_kv_append` call), indexer launch at the + `qsa_indexer_append` call; `qsa_tail_snapshot` records nothing (the snapshot is the indexer launch's first step). The + snapshot used to precede the K/V append; the two touch disjoint memory (`tail_snap`/index tail against the KV pools). +* `SIDE_QSA` on: the indexer launch replaces snapshot + append inside `issue_indexer_chain` (side stream 0, between + `qsa_index_k` and `qsa_index_q_path`); the K/V rows stay on the capture stream after `qsa_k_norm_rope`. Joins are + unchanged (`qsa_kv_resolve` joins stream 0, `qsa_decode_attention` joins stream 1). + +The four combinations of the two switches therefore record the same dependency edges as before, with fewer nodes. + +## 5. Identity argument and risk + +* Same arithmetic per output word, argued per kernel above. Checked here without a GPU: the PTX of + `leleka_verify_qsa_index_rows` has the same count of every floating-point instruction as the Original + `verify_qsa_append_analytic` entry of `original_verify_qsa.ptx` (add/sub/mul/fma, `rsqrt.approx`, `div.approx`, `ex2`, + `lg2`, `sin.approx`, `cos.approx`, `shfl.bfly`); `leleka_verify_qsa_kv_rows` has the same `div.rn.f32` (2), `max.f32` (6), + `abs`, `shfl` (5) and `cvt.rni` as `mtp_original_append` of `mtp_original_kv.ptx`. This is a plausibility check, not a proof. +* Residual risks: (a) a different instruction selection of an identical expression inside a loop (FMA contraction of + `a * c - z * s`), which the counts above do not show; (b) a block-barrier mistake in the indexer chain; (c) two rows + of one window with the same position (rows would race in the K/V kernel; the window never does this, positions are + distinct consecutive cells). +* Gate: `tools/verify-qsa-fused-prelude/prelude_probe.cpp` (model-free, compares every output byte of the literal launches and + of the fused ones on random inputs, all `pos % 4` phases, `pos == 0`, skipped rows, snapshot on and off, three RoPE + settings), then the teacher-forced identity job with only `LELEKA_SM120_FUSED_QSA_PRELUDE=1` set. + +## 6. Build and seal + +Both PTX files were compiled with nvcc 13.2.86 on the server (compile only, `/data/leleka-e2e/spd-gap/ptx-build/ +verify-qsa-fused-prelude/`), recompiled once to confirm identical bytes, and pinned (`original_verify_window_qsa/fused_prelude.rs` +`KV_ROWS.sha`, `INDEX_ROWS.sha`); recipes in `scripts/gpu-bringup/extra-seal-plan.json` (group `verify-qsa-prelude`), sm_86 +companions are "not built by design" in `ptx-sm86/MANIFEST.json`. The switch resolves off when a pin does not match +(`fused_prelude::resolve`). + +## 7. What to look at in the CUPTI window + +Before (per QSA layer): `verify_copy_from_mapped_kernel` (1, 256 threads), `mtp_original_append` (n), `verify_qsa_append_analytic` +(n). After: `leleka_verify_qsa_kv_rows` (1 per layer, grid `n * 2 * kv_heads`, 256 threads) and `leleka_verify_qsa_index_rows` +(1 per layer, 1 CTA). Launches per graph from `12 (2 n + 1)` to 24; the section to compare is the QSA role (K6) and the +sum of the three replaced kernels against the two new ones. diff --git a/scripts/e2e/codex/speed/ledger_counts.py b/scripts/e2e/codex/speed/ledger_counts.py index 6f77ad0c..68b4a486 100644 --- a/scripts/e2e/codex/speed/ledger_counts.py +++ b/scripts/e2e/codex/speed/ledger_counts.py @@ -11,7 +11,8 @@ path = sys.argv[1] if len(sys.argv) > 1 else "docs/experiments/step-ledger.md" by_status, by_owner = collections.Counter(), collections.Counter() for line in open(path, encoding="utf-8"): cells = [c.strip() for c in line.strip().strip("|").split("|")] - if len(cells) < 6 or not re.fullmatch(r"[A-Z]\d+[a-z]?", cells[0]): + labelled = re.search(r"\(([A-Z]\d+[a-z]?)\)$", cells[0]) + if len(cells) < 6 or not (labelled or re.fullmatch(r"[A-Z]\d+[a-z]?", cells[0])): continue status = cells[-1].split(" ")[0].split("(")[0] by_status[status] += 1 diff --git a/scripts/e2e/codex/speed/spd_ab_job.sh b/scripts/e2e/codex/speed/spd_ab_job.sh index 359de42a..d17d457c 100644 --- a/scripts/e2e/codex/speed/spd_ab_job.sh +++ b/scripts/e2e/codex/speed/spd_ab_job.sh @@ -58,7 +58,7 @@ COMMON="--assets $AS --state-dir $ST --prefix $PFX --bin-src $BIN --cublas-dir $ 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 CUDA_INJECTION64_PATH LELEKA_CUPTI_TRIGGER LCT_MAX_SECONDS LELEKA_ADAPT_TIE_SPREAD LELEKA_ADAPT_DECAY LELEKA_ADAPT_MARGIN LELEKA_ORIGINAL_SERVE_ADAPT_SWAPS LELEKA_REFILL_DEFER LELEKA_ORIGINAL_SERVE_DECODE_RESERVE_MIB LELEKA_ORIGINAL_SERVE_VRAM_RESERVE_MIB LELEKA_BRINGUP_TRACE LELEKA_PREFILL_PROFILE_SYNC LELEKA_ORIGINAL_SERVE_ADAPT_EVERY LELEKA_SM120_ATTN_DAILY LELEKA_SM120_GU_SWIGLU LELEKA_SM120_SIDE_MIXER LELEKA_SM120_SIDE_QSA LELEKA_SM120_SIDE_SHARED LELEKA_ORIGINAL_SERVE_PCIE_FRAC LELEKA_SERVE_PROFILE STRATA_VERIFY_PROFILE LELEKA_ROUTE_TAIL_SKIP LELEKA_ROUTE_TAIL_SKIP_MAX_CACHED LELEKA_SPEC LELEKA_SPEC_ADAPTIVE LELEKA_SPEC_FLOOR_CEILING LELEKA_SPEC_STATS + unset CUDA_INJECTION64_PATH LELEKA_CUPTI_TRIGGER LCT_MAX_SECONDS LELEKA_ADAPT_TIE_SPREAD LELEKA_ADAPT_DECAY LELEKA_ADAPT_MARGIN LELEKA_ORIGINAL_SERVE_ADAPT_SWAPS LELEKA_REFILL_DEFER LELEKA_ORIGINAL_SERVE_DECODE_RESERVE_MIB LELEKA_ORIGINAL_SERVE_VRAM_RESERVE_MIB LELEKA_BRINGUP_TRACE LELEKA_PREFILL_PROFILE_SYNC LELEKA_ORIGINAL_SERVE_ADAPT_EVERY LELEKA_SM120_ATTN_DAILY LELEKA_SM120_GU_SWIGLU LELEKA_SM120_SIDE_MIXER LELEKA_SM120_SIDE_QSA LELEKA_SM120_SIDE_SHARED LELEKA_DRAFT_FUSED_COMMIT LELEKA_SM120_FUSED_QSA_PRELUDE LELEKA_SM120_FUSED_GDN LELEKA_SM120_GDN_AB_UNROLL LELEKA_SM120_ACCEPT_ON_DEVICE LELEKA_ORIGINAL_SERVE_PCIE_FRAC LELEKA_SERVE_PROFILE STRATA_VERIFY_PROFILE LELEKA_ROUTE_TAIL_SKIP LELEKA_ROUTE_TAIL_SKIP_MAX_CACHED LELEKA_SPEC LELEKA_SPEC_ADAPTIVE LELEKA_SPEC_FLOOR_CEILING LELEKA_SPEC_STATS FLOOR=""; UPX="" case $vb in A) ;; @@ -75,13 +75,16 @@ for v in $VARS; do W3) export LELEKA_ADAPT_DECAY=0.85;; # longer memory of the routing counts (default 0.7) W4) export LELEKA_ADAPT_MARGIN=1.0;; # swap on a smaller count lead (default 1.5) X) export LELEKA_ADAPT_TIE_SPREAD=on;; # equal-gain swaps share the 96-swap cap across layers (needs a binary with the switch: SPD_BIN) - C|CL|CM|CN|CE|CT) [ "$vb" != C ] && export LELEKA_SM120_ATTN_DAILY=1 LELEKA_SM120_GU_SWIGLU=1; [ "$vb" = CM ] && export LELEKA_SM120_SIDE_MIXER=1; { [ "$vb" = CN ] || [ "$vb" = CT ]; } && export LELEKA_SM120_SIDE_QSA=1; { [ "$vb" = CE ] || [ "$vb" = CT ]; } && export LELEKA_SM120_SIDE_SHARED=1; export CUDA_INJECTION64_PATH=$DRT/tools/libleleka_cupti_trace.so LELEKA_CUPTI_TRIGGER=$D/cupti.trigger LCT_MAX_SECONDS=60 LD_LIBRARY_PATH=$DRT/cupti/lib:$LD_LIBRARY_PATH;; # one CUPTI kernel window (WIN_S seconds) over request SPD_TRIG_AT of the replay; a profiling run, never an A/B arm + C|CL|CM|CN|CE|CT|CF|CU|CQ|CG|CV|CA|CY) [ "$vb" != C ] && export LELEKA_SM120_ATTN_DAILY=1 LELEKA_SM120_GU_SWIGLU=1; { [ "$vb" = CM ] || [ "$vb" = CU ]; } && export LELEKA_SM120_SIDE_MIXER=1; { [ "$vb" = CF ] || [ "$vb" = CU ]; } && export LELEKA_DRAFT_FUSED_COMMIT=on; { [ "$vb" = CN ] || [ "$vb" = CT ] || [ "$vb" = CU ]; } && export LELEKA_SM120_SIDE_QSA=1; { [ "$vb" = CE ] || [ "$vb" = CT ] || [ "$vb" = CU ]; } && export LELEKA_SM120_SIDE_SHARED=1; { [ "$vb" = CQ ] || [ "$vb" = CY ]; } && export LELEKA_SM120_FUSED_QSA_PRELUDE=1; { [ "$vb" = CG ] || [ "$vb" = CY ]; } && export LELEKA_SM120_FUSED_GDN=1; [ "$vb" = CV ] && export LELEKA_SM120_GDN_AB_UNROLL=1; { [ "$vb" = CA ] || [ "$vb" = CY ]; } && export LELEKA_SM120_ACCEPT_ON_DEVICE=1; [ "$vb" = CY ] && export LELEKA_SM120_SIDE_MIXER=1 LELEKA_SM120_SIDE_QSA=1 LELEKA_SM120_SIDE_SHARED=1 LELEKA_DRAFT_FUSED_COMMIT=on; export CUDA_INJECTION64_PATH=$DRT/tools/libleleka_cupti_trace.so LELEKA_CUPTI_TRIGGER=$D/cupti.trigger LCT_MAX_SECONDS=60 LD_LIBRARY_PATH=$DRT/cupti/lib:$LD_LIBRARY_PATH;; # one CUPTI kernel window (WIN_S seconds) over request SPD_TRIG_AT of the replay; a profiling run, never an A/B arm P) export LELEKA_SERVE_PROFILE=1 STRATA_VERIFY_PROFILE=1;; Q) export LELEKA_SERVE_PROFILE=1 LELEKA_BRINGUP_TRACE=1 LELEKA_PREFILL_PROFILE_SYNC=1;; # per-stage prefill timing (not for A/B pairs: the sync drains change timings) M) export LELEKA_SM120_ATTN_DAILY=1 LELEKA_SM120_GU_SWIGLU=1 LELEKA_SM120_SIDE_MIXER=1;; N) export LELEKA_SM120_ATTN_DAILY=1 LELEKA_SM120_GU_SWIGLU=1 LELEKA_SM120_SIDE_QSA=1;; # L + the QSA indexer/query chains on side streams (needs SPD_BIN with the switch) E) export LELEKA_SM120_ATTN_DAILY=1 LELEKA_SM120_GU_SWIGLU=1 LELEKA_SM120_SIDE_SHARED=1;; # L + the shared expert on a side stream T) export LELEKA_SM120_ATTN_DAILY=1 LELEKA_SM120_GU_SWIGLU=1 LELEKA_SM120_SIDE_QSA=1 LELEKA_SM120_SIDE_SHARED=1;; # both # L + the verify graph's side streams (SIDE_MIXER); base of the pair is L + U) export 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;; # M + the QSA chains + the shared expert: all three side-stream parts (base of the set A/B is M, the 5090 profile default) + P2) export 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_DRAFT_FUSED_COMMIT=on;; # the 5090 profile set (base of the group A/B of the new switches) + Z) export 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_DRAFT_FUSED_COMMIT=on LELEKA_SM120_FUSED_QSA_PRELUDE=1 LELEKA_SM120_FUSED_GDN=1 LELEKA_SM120_GDN_AB_UNROLL=1 LELEKA_SM120_ACCEPT_ON_DEVICE=1;; # profile set + every new verify switch that passed identity (edit the list before queueing) R) export LELEKA_REFILL_DEFER=on;; # lever 5: the lent-slot refill queued inside the decode phase's assembly (same copies, other time) S) export LELEKA_ROUTE_TAIL_SKIP=7 LELEKA_ROUTE_TAIL_SKIP_MAX_CACHED=100;; T*) export LELEKA_ROUTE_TAIL_SKIP=7 LELEKA_ROUTE_TAIL_SKIP_MAX_CACHED=100; p=${vb#T}; p=${p%[a-z]}; [ "$p" != 45 ] && export LELEKA_ORIGINAL_SERVE_PCIE_FRAC=0.$p;; @@ -114,11 +117,11 @@ for v in $VARS; do done touch "$D/replay.jsonl" else - case $vb in C|CL|CM|CN|CE|CT) cupti_arm=1;; *) cupti_arm=0;; esac + case $vb in C|CL|CM|CN|CE|CT|CF|CU|CQ|CG|CV|CA|CY) cupti_arm=1;; *) cupti_arm=0;; esac if [ $cupti_arm = 1 ]; then spd_watch "$D/replay.jsonl" "$D/cupti.trigger" "$D" "$TRIG_AT" & WATCH_PID=$!; fi python3 -I "$SPD/tools/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" - case $vb in C|CL|CM|CN|CE|CT) cupti_arm=1;; *) cupti_arm=0;; esac + case $vb in C|CL|CM|CN|CE|CT|CF|CU|CQ|CG|CV|CA|CY) cupti_arm=1;; *) cupti_arm=0;; esac if [ $cupti_arm = 1 ]; then for _ in $(seq 1 60); do [ -e "$D/cupti.trigger.done" ] && break; sleep 1; done; kill "$WATCH_PID" 2>/dev/null; fi fi cp "$ST/logs/engine.log" "$D/engine.log" 2>/dev/null; cp "$ST/logs/requests.log" "$D/requests.log" 2>/dev/null diff --git a/scripts/e2e/codex/speed/verify-hc-down-kernel-microbench-vs-upstream.sh b/scripts/e2e/codex/speed/verify-hc-down-kernel-microbench-vs-upstream.sh new file mode 100755 index 00000000..cf369788 --- /dev/null +++ b/scripts/e2e/codex/speed/verify-hc-down-kernel-microbench-vs-upstream.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash +# Ledger row U5 (docs/experiments/step-ledger.md C2u): kernel micro-benchmark of upstream Strata's hyper-connection down kernel +# (gr_down_v3_kernel, STRATA_GR_V3_PF masks 0 / 5 / 133) against our chain_gr_down_t2w8_nb4, window rows T = 1..8, on the 5090. +# Small GPU job (about 3 minutes, a few hundred MB of device memory, no model): takes /data/leleka-e2e/gpu.lock like the other short stubs +# (poll up to 30 min) and does not take MODEL.lock. Copy to ~/work/gpu-runs/holder2/jobs/ (installed and queued by the orchestrator). +# Method, inputs, how to read the result: docs/experiments/verify-hc-down-kernel-microbench-vs-upstream.md +# MB_ARGS="--tmin 1 --tmax 2 --rounds 2" optional: a short run (the full defaults are in the doc) +set -uo pipefail +D=/data/leleka-e2e/spd-gap/microbench/verify-hc-down-kernel-microbench-vs-upstream +LOCK=/data/leleka-e2e/gpu.lock +OUT=$D/result.txt +cd "$D" || { echo "no $D"; exit 2; } + +# measurement inputs are frozen and recorded: refuse to run when one is missing or its digest differs +sha256sum --quiet -c MANIFEST.sha256 || { echo "MANIFEST.sha256 does not match the files in $D"; exit 5; } + +got=0 +for _ in $(seq 1 360); do + if mkdir "$LOCK" 2>/dev/null; then echo "verify-hc-down-kernel-microbench-vs-upstream $(date -u +%FT%TZ)" >"$LOCK/owner"; got=1; break; fi + sleep 5 +done +[ $got = 1 ] || { echo "GPU lock held by: $(cat "$LOCK/owner" 2>/dev/null)"; exit 3; } +release() { if grep -q "verify-hc-down-kernel-microbench-vs-upstream" "$LOCK/owner" 2>/dev/null; then rm -f "$LOCK/owner"; rmdir "$LOCK"; fi; } +trap release EXIT + +[ -e "$OUT" ] && mv "$OUT" "$D/result.$(date -u +%Y%m%dT%H%M%SZ).txt" +SMI_PID= +{ + echo "== environment" + date -u +%FT%TZ; uname -r + nvidia-smi --query-gpu=name,driver_version,clocks.max.sm,clocks.sm,power.limit,temperature.gpu --format=csv + echo "GPU compute apps at start (an idle resident holder is expected and does not run kernels):" + nvidia-smi --query-compute-apps=pid,name,used_memory --format=csv,noheader || true + echo "binary and inputs (full list: $D/MANIFEST.sha256, verified above):" + sha256sum build/microbench build/chain_window.cubin ours-src/crates/cuda-driver/src/chain_window.ptx upstream-src/src/kernels/cuda/fused_gr.cu harness/microbench.cu + # SM clock, power and throttle reasons once a second during the run (the timings are only comparable at steady clocks) + nvidia-smi --query-gpu=timestamp,clocks.sm,clocks.mem,power.draw,temperature.gpu,clocks_throttle_reasons.active --format=csv,noheader -l 1 >"$D/smi.csv" 2>&1 & + SMI_PID=$! + echo "== microbench" + # shellcheck disable=SC2086 + timeout 1800 build/microbench --ptx ours-src/crates/cuda-driver/src/chain_window.ptx --cubin build/chain_window.cubin ${MB_ARGS:-} + echo "microbench exit code $?" + kill "$SMI_PID" 2>/dev/null + echo "== sm clock during the run (MHz): min / max / throttle reasons seen" + awk -F', ' '{c=$2+0; if (min==""||cmax) max=c; r[$6]++} END {printf "%s / %s\n", min, max; for (k in r) printf " %s x%d\n", k, r[k]}' "$D/smi.csv" +} 2>&1 | tee "$OUT" +# per-T tables and deltas from the CSV lines of the finished file (appended to result.txt) +{ echo "== tables (python3 harness/summarize.py result.txt)"; python3 -I harness/summarize.py "$OUT"; } | tee -a "$OUT" diff --git a/scripts/e2e/codex/speed/verify-hc-down-kernel-microbench-vs-upstream/build.sh b/scripts/e2e/codex/speed/verify-hc-down-kernel-microbench-vs-upstream/build.sh new file mode 100755 index 00000000..2fdd752b --- /dev/null +++ b/scripts/e2e/codex/speed/verify-hc-down-kernel-microbench-vs-upstream/build.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +# Builds the micro-benchmark on the 5090 server (no GPU needed). Run from anywhere: +# bash build.sh /data/leleka-e2e/spd-gap/microbench/verify-hc-down-kernel-microbench-vs-upstream +# Layout under that directory (see MANIFEST there): +# upstream-src/ git archive of strata-upstream/main (include/, src/kernels/cuda/fused_gr.cu, s26_tsum.cuh), unmodified +# ours-src/ git archive of the repository commit (crates/cuda-driver/src/chain_window.{cu,ptx}, engine/strata/include) +# harness/ this directory of the repository (scripts/e2e/codex/speed/verify-hc-down-kernel-microbench-vs-upstream/): +# microbench.cu, upstream_down_launch.inc, compare_outputs.inc, summarize.py, build.sh, and +# ours-shim/ = the 112-byte FusedGrArgs header the sealed chain kernels were built against (see its comment) +# build/ microbench (binary), chain_window.cubin, chain_window.regen.ptx +set -euo pipefail +ROOT=${1:?directory} +NVCC=${NVCC:-$HOME/cuda-toolkits/13.2.2/bin/nvcc} +cd "$ROOT/build" +# 1. our kernels from source with the flags of extra-seal-plan.json (chain_window): PTX (to check it is the sealed one) and a cubin +OURS_FLAGS="-O3 -arch=sm_120 -std=c++17 --fmad=true --ftz=false -I$ROOT/harness/ours-shim -I$ROOT/ours-src/engine/strata/include" +nice -n 10 "$NVCC" -ptx $OURS_FLAGS "$ROOT/ours-src/crates/cuda-driver/src/chain_window.cu" -o chain_window.regen.ptx +nice -n 10 "$NVCC" -cubin $OURS_FLAGS "$ROOT/ours-src/crates/cuda-driver/src/chain_window.cu" -o chain_window.cubin +# the regenerated PTX equals the sealed one except for the hash in the mangled anonymous-namespace names and the sampler kernel (not used here) +norm() { grep -v '^//' "$1" | tr -d '\0' | sed -E 's/GLOBAL__N__[0-9a-f]+_/GLOBAL__N__X_/g'; } +diff <(norm chain_window.regen.ptx) <(norm "$ROOT/ours-src/crates/cuda-driver/src/chain_window.ptx") | grep -c '^[<>]' | sed 's/^/regenerated-vs-sealed PTX: differing lines (mangled-name hash excluded): /' || true +# 2. the micro-benchmark: upstream fused_gr.cu included whole, flags of a Release build for compute capability 12.0 (cmake/backends/cuda.cmake: architecture 120) +nice -n 10 "$NVCC" -O3 -DNDEBUG -std=c++17 -arch=sm_120 -diag-suppress 128 -I"$ROOT/upstream-src/include" -I"$ROOT/upstream-src/src/kernels/cuda" -I"$ROOT/harness" \ + "$ROOT/harness/microbench.cu" -o microbench -lcuda +ls -l microbench chain_window.cubin diff --git a/scripts/e2e/codex/speed/verify-hc-down-kernel-microbench-vs-upstream/compare_outputs.inc b/scripts/e2e/codex/speed/verify-hc-down-kernel-microbench-vs-upstream/compare_outputs.inc new file mode 100644 index 00000000..9301ad1c --- /dev/null +++ b/scripts/e2e/codex/speed/verify-hc-down-kernel-microbench-vs-upstream/compare_outputs.inc @@ -0,0 +1,115 @@ +// Included by microbench.cu inside namespace strata::kernels::microbench: the byte-level comparison of the outputs, per window rows T. +// +// A. upstream down kernel alone, masks 0 / 5 / 133: `part` and `ssg` (its own output buffers) byte for byte against mask 0 +// (upstream claims bitwise: gr_v3_screen), then through mb_finalize_down the quantities ours writes: lo, inject_out, rs. +// B. ours down alone (chain_gr_split + chain_gr_down_t2w8_nb4): sealed PTX against the nvcc cubin byte for byte (lo, inject_out, rs). +// C. ours (sealed PTX) against each upstream mask: lo, inject_out, rs (the down stage's result), as bit differences, largest absolute / +// relative difference and largest distance in units in the last place. +// D. the whole read (ours split+down+up8, upstream fused_gr_read_multi = gr_down_v3 + gr_up_v3): R (updated in place), rs, inject_out, mixed. +// Ours and upstream do NOT sum the 10240 products of a dot in the same order (ours: the activations normalised by the split kernel, tiles in +// order, one warp row; upstream: per stream on unnormalised values, scaled afterwards), so bitwise equality is not expected: the numbers are the answer. +struct Diff { size_t n = 0, bits = 0, nonfinite_a = 0, nonfinite_b = 0; double max_abs = 0, max_rel = 0; long long max_ulp = 0; }; +static long long ordered_bits(float x) { int32_t i; std::memcpy(&i, &x, 4); return i < 0 ? (long long) INT32_MIN - i : (long long) i; } +static Diff diff_floats(const std::vector& a, const std::vector& b) { + Diff d; d.n = a.size(); + for (size_t i = 0; i < a.size(); ++i) { + uint32_t ua, ub; std::memcpy(&ua, &a[i], 4); std::memcpy(&ub, &b[i], 4); + d.nonfinite_a += !std::isfinite(a[i]); d.nonfinite_b += !std::isfinite(b[i]); + if (ua == ub) continue; + ++d.bits; + const double abs = std::fabs((double) a[i] - (double) b[i]), mag = std::max(std::fabs((double) a[i]), std::fabs((double) b[i])); + d.max_abs = std::max(d.max_abs, abs); + if (mag > 0) d.max_rel = std::max(d.max_rel, abs / mag); + d.max_ulp = std::max(d.max_ulp, std::llabs(ordered_bits(a[i]) - ordered_bits(b[i]))); + } + return d; +} +static std::vector fetch(const float* p, size_t n) { std::vector v(n); CU_RT(cudaMemcpy(v.data(), p, n * 4, cudaMemcpyDeviceToHost)); return v; } +static void print_diff(int T, const char* what, const char* a_name, const char* b_name, const Diff& d) { + std::printf("DIFF T=%d %-12s %-34s vs %-34s words %6zu differing %6zu (%6.2f%%) max_abs %.3e max_rel %.3e max_ulp %lld nonfinite %zu/%zu\n", T, what, a_name, b_name, d.n, d.bits, + 100.0 * (double) d.bits / (double) std::max(d.n, 1), d.max_abs, d.max_rel, d.max_ulp, d.nonfinite_a, d.nonfinite_b); +} + +struct DownResult { std::vector part, ssg, lo, inject, rs; }; +struct ReadResult { std::vector lo, inject, rs, R, mixed; }; + +static int compare_outputs(const Options& o, Context& c, bool have_cubin, cudaStream_t s) { + int unexpected = 0; + const int masks[3] = {0, 5, 133}; + const char* mask_name[3] = {"upstream_mask0", "upstream_mask5", "upstream_mask133"}; + Work pu[3], po, pc; + float *d_lo[3], *d_inj[3], *d_rs[3]; + for (int i = 0; i < 3; ++i) { pu[i] = new_work(c.in); d_lo[i] = dev_floats(kTokensMax * LR); d_inj[i] = dev_floats(kTokensMax * HC); d_rs[i] = dev_floats(kTokensMax * HC); } + po = new_work(c.in); pc = new_work(c.in); + const WeightSet& ws = c.sets[0]; + for (int T = o.tmin; T <= o.tmax; ++T) { + std::printf("CORRECTNESS T=%d (apply=1, w_inject on, weight set 0, seed 7)\n", T); + DownResult up[3]; + for (int i = 0; i < 3; ++i) { // A + reset_work(pu[i], c.in); + const GrMulti m = upstream_multi(T, pu[i], ws, c.in); + mb_launch_upstream_down(masks[i], T, m, mb_part(pu[i].scratch), mb_ssg(pu[i].scratch, T), s); + mb_finalize_down<<<1, THREADS, 0, s>>>(m, mb_part(pu[i].scratch), mb_ssg(pu[i].scratch, T), d_lo[i], d_inj[i], d_rs[i]); + CU_RT(cudaStreamSynchronize(s)); + up[i] = {fetch(mb_part(pu[i].scratch), (size_t) T * HC * PR), fetch(mb_ssg(pu[i].scratch, T), (size_t) T * HC), fetch(d_lo[i], (size_t) T * LR), + fetch(d_inj[i], (size_t) T * HC), fetch(d_rs[i], (size_t) T * HC)}; + } + for (int i = 1; i < 3; ++i) { + const Diff dp = diff_floats(up[i].part, up[0].part), ds = diff_floats(up[i].ssg, up[0].ssg); + print_diff(T, "part", mask_name[i], mask_name[0], dp); print_diff(T, "ssg", mask_name[i], mask_name[0], ds); + unexpected += (dp.bits != 0) + (ds.bits != 0); + } + ReadResult ours[2]; // B: 0 = sealed PTX, 1 = cubin + for (int k = 0; k < (have_cubin ? 2 : 1); ++k) { + Work& w = k == 0 ? po : pc; + const OursKernels& kern = k == 0 ? c.ptx : c.cubin; + reset_work(w, c.in); + const OursByValue m = ours_multi(T, w, ws, c.in); + ours_launch(kern.split, m, ours_split_grid(T), 0, s); + ours_launch(kern.down, m, ours_down_grid(T), ours_down_shared(T), s); + CU_RT(cudaStreamSynchronize(s)); + ours[k].lo = fetch(w.lo, (size_t) T * LR); ours[k].inject = fetch(w.inject_out, (size_t) T * HC); ours[k].rs = fetch(w.rs, (size_t) T * HC); + } + if (have_cubin) { + const char* a = "ours_sealed_ptx"; const char* b = "ours_nvcc_cubin"; + const Diff dl = diff_floats(ours[0].lo, ours[1].lo), di = diff_floats(ours[0].inject, ours[1].inject), dr = diff_floats(ours[0].rs, ours[1].rs); + print_diff(T, "lo", a, b, dl); print_diff(T, "inject_out", a, b, di); print_diff(T, "rs", a, b, dr); + unexpected += (dl.bits != 0) + (di.bits != 0) + (dr.bits != 0); + } + for (int i = 0; i < 3; ++i) { // C + print_diff(T, "lo", "ours_sealed_ptx", mask_name[i], diff_floats(ours[0].lo, up[i].lo)); + print_diff(T, "inject_out", "ours_sealed_ptx", mask_name[i], diff_floats(ours[0].inject, up[i].inject)); + print_diff(T, "rs", "ours_sealed_ptx", mask_name[i], diff_floats(ours[0].rs, up[i].rs)); + } + // D: the whole read + Work& wr = po; + reset_work(wr, c.in); + const OursByValue m = ours_multi(T, wr, ws, c.in); + ours_launch(c.ptx.split, m, ours_split_grid(T), 0, s); ours_launch(c.ptx.down, m, ours_down_grid(T), ours_down_shared(T), s); ours_launch(c.ptx.up8, m, ours_up8_grid(), 0, s); + CU_RT(cudaStreamSynchronize(s)); + const ReadResult whole_ours{fetch(wr.lo, (size_t) T * LR), fetch(wr.inject_out, (size_t) T * HC), fetch(wr.rs, (size_t) T * HC), fetch(wr.R, (size_t) T * D), fetch(wr.mixed, (size_t) T * N)}; + ReadResult whole_up[3]; + for (int i = 0; i < 3; ++i) { + reset_work(pu[i], c.in); + FusedGrArgs a[kTokensMax]; + for (int t = 0; t < T; ++t) a[t] = upstream_args(t, pu[i], ws, c.in); + fused_gr_v3_pf(masks[i]); + fused_gr_read_multi(a, T, pu[i].scratch, (void*) s); + CU_RT(cudaStreamSynchronize(s)); + whole_up[i] = {{}, fetch(pu[i].inject_out, (size_t) T * HC), fetch(pu[i].rs, (size_t) T * HC), fetch(pu[i].R, (size_t) T * D), fetch(pu[i].mixed, (size_t) T * N)}; + print_diff(T, "rs(real up)", "ours_pipeline", mask_name[i], diff_floats(whole_ours.rs, whole_up[i].rs)); + print_diff(T, "inject(real)", "ours_pipeline", mask_name[i], diff_floats(whole_ours.inject, whole_up[i].inject)); + print_diff(T, "R updated", "ours_pipeline", mask_name[i], diff_floats(whole_ours.R, whole_up[i].R)); + print_diff(T, "mixed", "ours_pipeline", mask_name[i], diff_floats(whole_ours.mixed, whole_up[i].mixed)); + if (i > 0) { + const Diff dm = diff_floats(whole_up[i].mixed, whole_up[0].mixed), dr = diff_floats(whole_up[i].R, whole_up[0].R); + print_diff(T, "mixed", mask_name[i], mask_name[0], dm); print_diff(T, "R updated", mask_name[i], mask_name[0], dr); + unexpected += (dm.bits != 0) + (dr.bits != 0); + } + } + const Diff nf = diff_floats(whole_ours.mixed, whole_ours.mixed); + unexpected += (int) nf.nonfinite_a; + } + std::printf("CORRECTNESS summary: %d unexpected (upstream masks not equal to each other, ptx vs cubin differing, or non-finite outputs); ours-vs-upstream differences are data, not counted\n", unexpected); + return unexpected; +} diff --git a/scripts/e2e/codex/speed/verify-hc-down-kernel-microbench-vs-upstream/microbench.cu b/scripts/e2e/codex/speed/verify-hc-down-kernel-microbench-vs-upstream/microbench.cu new file mode 100644 index 00000000..74b6e2b9 --- /dev/null +++ b/scripts/e2e/codex/speed/verify-hc-down-kernel-microbench-vs-upstream/microbench.cu @@ -0,0 +1,343 @@ +// Kernel micro-benchmark: upstream Strata's hyper-connection down kernel (gr_down_v3_kernel, STRATA_GR_V3_PF masks 0 / 5 / 133) against +// our chain_gr_down_t2w8_nb4 (sealed PTX through the driver API, as the product loads it; and the same source built by nvcc), window +// rows T = 1..8, same random inputs. Method, inputs and how to read the result: docs/experiments/verify-hc-down-kernel-microbench-vs-upstream.md +// +// One translation unit: upstream's fused_gr.cu is #included whole (unmodified, from git object strata-upstream/main), so the kernels, the +// geometry constants and the launch helpers are upstream's own. +#include + +#include "fused_gr.cu" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace strata::kernels { +// defined in upstream's verify_kernels.cu (timestamp kernel for its profile windows); fused_gr.cu only calls it when a stamp buffer is passed, which this harness never does +void gpu_stamp(unsigned long long*, int, void*) {} +namespace microbench { + +#define CU_RT(x) do { cudaError_t e_ = (x); if (e_ != cudaSuccess) { std::fprintf(stderr, "%s:%d %s: %s\n", __FILE__, __LINE__, #x, cudaGetErrorString(e_)); std::exit(2); } } while (0) +#define CU_DRV(x) do { CUresult r_ = (x); if (r_ != CUDA_SUCCESS) { const char* m_ = "?"; cuGetErrorString(r_, &m_); std::fprintf(stderr, "%s:%d %s: %s\n", __FILE__, __LINE__, #x, m_); std::exit(2); } } while (0) + +#include "upstream_down_launch.inc" + +constexpr int kTokensMax = kFusedGrMaxT; // 8 +constexpr int kOursWords = 114; // GrMulti of the sealed chain kernels: 8 x 14 words of FusedGrArgs (112 B), xn, T = 912 bytes +struct OursByValue { uint64_t w[kOursWords]; }; +static_assert(sizeof(OursByValue) == 912, "GrMulti of the sealed chain kernels"); +__global__ void __launch_bounds__(THREADS) mb_empty_ours_shape(OursByValue m) { if (m.w[113] == ~0ull) *reinterpret_cast(m.w[10]) = 0.0f; } +__global__ void mb_spin_ns(unsigned long long ns) { + unsigned long long t0, t; + asm volatile("mov.u64 %0, %%globaltimer;" : "=l"(t0)); + do { asm volatile("mov.u64 %0, %%globaltimer;" : "=l"(t)); } while (t - t0 < ns); +} + +static uint16_t bf16_bits(float x) { uint32_t u; std::memcpy(&u, &x, 4); return (uint16_t) ((u + 0x7fff + ((u >> 16) & 1)) >> 16); } + +struct WeightSet { uint16_t *down, *up, *inject; float* norm; }; +struct Work { float *R, *lo, *rs, *inject_out, *mixed, *scratch; }; +struct Inputs { float *bo, *inj; std::vector R0; }; + +static float* dev_floats(size_t n) { float* p; CU_RT(cudaMalloc((void**) &p, n * 4)); CU_RT(cudaMemset(p, 0xff, n * 4)); return p; } +static Work new_work(const Inputs& in) { + Work w{dev_floats((size_t) kTokensMax * D), dev_floats((size_t) kTokensMax * LR), dev_floats((size_t) kTokensMax * HC), dev_floats((size_t) kTokensMax * HC), + dev_floats((size_t) kTokensMax * N), dev_floats((size_t) kTokensMax * D * 4)}; + CU_RT(cudaMemcpy(w.R, in.R0.data(), in.R0.size() * 4, cudaMemcpyHostToDevice)); + return w; +} +static void reset_work(const Work& w, const Inputs& in) { + CU_RT(cudaMemcpy(w.R, in.R0.data(), in.R0.size() * 4, cudaMemcpyHostToDevice)); + CU_RT(cudaMemset(w.lo, 0xff, kTokensMax * LR * 4)); CU_RT(cudaMemset(w.rs, 0xff, kTokensMax * HC * 4)); + CU_RT(cudaMemset(w.inject_out, 0xff, kTokensMax * HC * 4)); CU_RT(cudaMemset(w.mixed, 0xff, (size_t) kTokensMax * N * 4)); + CU_RT(cudaMemset(w.scratch, 0xff, (size_t) kTokensMax * D * 4 * 4)); +} + +static FusedGrArgs upstream_args(int t, const Work& w, const WeightSet& ws, const Inputs& in) { + FusedGrArgs a; + a.R = w.R + (size_t) t * D; a.R_out = w.R + (size_t) t * D; a.apply = true; + a.bo_prev = in.bo + (size_t) t * N; a.inj_prev = in.inj + (size_t) t * HC; + a.w_norm = ws.norm; a.w_down = ws.down; a.w_up = ws.up; a.w_inject = ws.inject; + a.lo = w.lo + (size_t) t * LR; a.rs = w.rs + (size_t) t * HC; a.inject_out = w.inject_out + (size_t) t * HC; a.mixed = w.mixed + (size_t) t * N; + return a; +} +static GrMulti upstream_multi(int T, const Work& w, const WeightSet& ws, const Inputs& in) { + GrMulti m{}; + for (int t = 0; t < T; ++t) m.a[t] = upstream_args(t, w, ws, in); + m.xn = w.scratch; m.T = T; + return m; +} +// the 14 words per row of `multi_words` (crates/cuda-driver/src/original_verify_window_gr/assets.rs), then xn and T +static OursByValue ours_multi(int T, const Work& w, const WeightSet& ws, const Inputs& in) { + OursByValue o{}; + auto p = [](const void* x) { return (uint64_t) (uintptr_t) x; }; + const float eps = 1e-6f; uint32_t eps_bits; std::memcpy(&eps_bits, &eps, 4); + for (int t = 0; t < T; ++t) { + uint64_t* a = &o.w[t * 14]; + a[0] = p(w.R + (size_t) t * D); a[1] = a[0]; a[2] = 1; a[3] = p(in.bo + (size_t) t * N); a[4] = p(in.inj + (size_t) t * HC); + a[5] = p(ws.norm); a[6] = p(ws.down); a[7] = p(ws.up); a[8] = p(ws.inject); a[9] = eps_bits; + a[10] = p(w.lo + (size_t) t * LR); a[11] = p(w.rs + (size_t) t * HC); a[12] = p(w.inject_out + (size_t) t * HC); a[13] = p(w.mixed + (size_t) t * N); + } + o.w[112] = p(w.scratch); o.w[113] = (uint64_t) T; + return o; +} + +struct OursKernels { CUmodule mod = nullptr; CUfunction split = nullptr, down = nullptr, up8 = nullptr; std::string label; }; +static bool load_ours(const std::string& path, bool is_ptx, const char* label, OursKernels& k) { + std::ifstream f(path, std::ios::binary); + if (!f) { std::fprintf(stderr, "cannot read %s\n", path.c_str()); return false; } + std::vector image((std::istreambuf_iterator(f)), std::istreambuf_iterator()); + if (is_ptx) { while (!image.empty() && image.back() == '\0') image.pop_back(); image.push_back('\0'); } // the product appends one NUL to the PTX text + CU_DRV(cuModuleLoadData(&k.mod, image.data())); + CU_DRV(cuModuleGetFunction(&k.split, k.mod, "chain_gr_split")); + CU_DRV(cuModuleGetFunction(&k.down, k.mod, "chain_gr_down_t2w8_nb4")); + CU_DRV(cuModuleGetFunction(&k.up8, k.mod, "chain_gr_up8")); + k.label = label; + return true; +} +static void ours_launch(CUfunction fn, OursByValue m, dim3 grid, unsigned shared, cudaStream_t s) { + void* params[1] = {&m}; + CU_DRV(cuLaunchKernel(fn, grid.x, grid.y, grid.z, THREADS, 1, 1, shared, (CUstream) s, params, nullptr)); +} +static dim3 ours_split_grid(int T) { return dim3(T, HC); } +static dim3 ours_down_grid(int T) { return dim3(LR / 8 + 1, (T + 1) / 2); } // original_verify_window_gr::tiled_down_geometry: 41 blocks of 8 rows, grid.y = ceil(T / 2) +static unsigned ours_down_shared(int T) { return 4u * (unsigned) std::min(T, 2) * 1280u * 4u; } +static dim3 ours_up8_grid() { return dim3((N / 16) * 2); } // UP_BLOCKS * 2 = 320 blocks of 256 threads + +// ------------------------------------------------------------------------------------------------ variants +struct Variant { std::string name; std::function run; }; // (T, weight set, stream) +struct Context { + std::vector sets; Inputs in; + Work w_down_u, w_down_o, w_down_c, w_pipe_u, w_pipe_o; // separate output buffers per measured variant family + OursKernels ptx, cubin; +}; + +static std::vector down_variants(Context& c, bool with_cubin) { + std::vector v; + const int masks[] = {0, 5, 133}; + const char* names[] = {"upstream_mask0_plain", "upstream_mask5_batched_staging_loads", "upstream_mask133_register_blocked_dot"}; + for (int i = 0; i < 3; ++i) { + const int mask = masks[i]; + v.push_back({names[i], [&c, mask](int T, int set, cudaStream_t s) { + const GrMulti m = upstream_multi(T, c.w_down_u, c.sets[set], c.in); + mb_launch_upstream_down(mask, T, m, mb_part(c.w_down_u.scratch), mb_ssg(c.w_down_u.scratch, T), s); + }}); + } + v.push_back({"ours_down_t2w8_nb4_sealed_ptx", [&c](int T, int set, cudaStream_t s) { + ours_launch(c.ptx.down, ours_multi(T, c.w_down_o, c.sets[set], c.in), ours_down_grid(T), ours_down_shared(T), s); + }}); + if (with_cubin) v.push_back({"ours_down_t2w8_nb4_nvcc_cubin", [&c](int T, int set, cudaStream_t s) { + ours_launch(c.cubin.down, ours_multi(T, c.w_down_c, c.sets[set], c.in), ours_down_grid(T), ours_down_shared(T), s); + }}); + v.push_back({"ours_split_plus_down_sealed_ptx", [&c](int T, int set, cudaStream_t s) { + const OursByValue m = ours_multi(T, c.w_down_o, c.sets[set], c.in); + ours_launch(c.ptx.split, m, ours_split_grid(T), 0, s); + ours_launch(c.ptx.down, m, ours_down_grid(T), ours_down_shared(T), s); + }}); + v.push_back({"empty_kernel_with_upstream_mask133_launch_shape", [&c](int T, int, cudaStream_t s) { + const MbLaunchShape sh = mb_upstream_down_shape(133, T); + mb_empty_upstream_shape<<>>(upstream_multi(T, c.w_down_u, c.sets[0], c.in)); + }}); + v.push_back({"empty_kernel_with_our_launch_shape", [&c](int T, int, cudaStream_t s) { + mb_empty_ours_shape<<>>(ours_multi(T, c.w_down_o, c.sets[0], c.in)); + }}); + return v; +} +static std::vector pipeline_variants(Context& c) { + std::vector v; + for (int mask : {0, 5, 133}) { + const std::string name = "pipeline_upstream_mask" + std::to_string(mask) + "_down_plus_up"; + v.push_back({name, [&c, mask](int T, int set, cudaStream_t s) { + FusedGrArgs a[kTokensMax]; + for (int t = 0; t < T; ++t) a[t] = upstream_args(t, c.w_pipe_u, c.sets[set], c.in); + fused_gr_v3_pf(mask); + fused_gr_read_multi(a, T, c.w_pipe_u.scratch, (void*) s); // upstream's own entry point: STRATA_GR_V3=1 -> gr_down_v3 + gr_up_v3 + }}); + } + v.push_back({"pipeline_ours_split_down_up8_sealed_ptx", [&c](int T, int set, cudaStream_t s) { + const OursByValue m = ours_multi(T, c.w_pipe_o, c.sets[set], c.in); + ours_launch(c.ptx.split, m, ours_split_grid(T), 0, s); + ours_launch(c.ptx.down, m, ours_down_grid(T), ours_down_shared(T), s); + ours_launch(c.ptx.up8, m, ours_up8_grid(), 0, s); + }}); + return v; +} + +// ------------------------------------------------------------------------------------------------ statistics +struct Stat { double median, p10, p90, mn, mean, round_med_lo, round_med_hi; size_t n; }; +static double pick(const std::vector& s, double p) { return s[(size_t) std::floor(p * (double) (s.size() - 1) + 0.5)]; } +static Stat summarize(const std::vector>& rounds) { + std::vector all, meds; + for (auto r : rounds) { std::sort(r.begin(), r.end()); meds.push_back(pick(r, 0.5)); all.insert(all.end(), r.begin(), r.end()); } + std::sort(all.begin(), all.end()); std::sort(meds.begin(), meds.end()); + double sum = 0; for (double x : all) sum += x; + return {pick(all, 0.5), pick(all, 0.1), pick(all, 0.9), all.front(), sum / (double) all.size(), meds.front(), meds.back(), all.size()}; +} +static void print_stat(const char* mode, int T, const std::string& name, const Stat& s) { + std::printf("TIME %-26s T=%d %-52s median %8.3f p10 %8.3f p90 %8.3f min %8.3f mean %8.3f round-medians %8.3f..%8.3f n=%zu\n", mode, T, name.c_str(), s.median, s.p10, s.p90, s.mn, + s.mean, s.round_med_lo, s.round_med_hi, s.n); + std::printf("CSV,%s,%d,%s,%.4f,%.4f,%.4f,%.4f,%.4f,%.4f,%.4f,%zu\n", mode, T, name.c_str(), s.median, s.p10, s.p90, s.mn, s.mean, s.round_med_lo, s.round_med_hi, s.n); +} + +struct Options { int tmin = 1, tmax = 8, rounds = 7, replays = 40, nodes = 64, sets = 64, single = 120; std::string ptx, cubin; }; + +// graph-batched: `nodes` launches (cycling over the weight sets when cold) captured into one CUDA graph; per-launch time = graph time / nodes +static void time_graphs(const Options& o, Context& c, const std::vector& vars, int T, bool cold, cudaStream_t s) { + const char* mode = cold ? "graph_cold_weights" : "graph_warm_weights"; + std::vector exec(vars.size()); + for (size_t vi = 0; vi < vars.size(); ++vi) { + for (int i = 0; i < 2; ++i) vars[vi].run(T, 0, s); // first-use attribute setup and module state outside the capture + CU_RT(cudaStreamSynchronize(s)); + cudaGraph_t g; + CU_RT(cudaStreamBeginCapture(s, cudaStreamCaptureModeRelaxed)); + for (int i = 0; i < o.nodes; ++i) vars[vi].run(T, cold ? i % (int) c.sets.size() : 0, s); + CU_RT(cudaStreamEndCapture(s, &g)); + CU_RT(cudaGraphInstantiate(&exec[vi], g, 0)); + CU_RT(cudaGraphDestroy(g)); + } + std::vector e0(o.replays), e1(o.replays); + for (int i = 0; i < o.replays; ++i) { CU_RT(cudaEventCreate(&e0[i])); CU_RT(cudaEventCreate(&e1[i])); } + std::vector>> data(vars.size()); + for (int r = 0; r < o.rounds; ++r) + for (size_t k = 0; k < vars.size(); ++k) { + const size_t vi = (k + (size_t) r) % vars.size(); // rotate the start so no variant always follows the same neighbour + for (int i = 0; i < 3; ++i) CU_RT(cudaGraphLaunch(exec[vi], s)); + for (int i = 0; i < o.replays; ++i) { CU_RT(cudaEventRecord(e0[i], s)); CU_RT(cudaGraphLaunch(exec[vi], s)); CU_RT(cudaEventRecord(e1[i], s)); } + CU_RT(cudaStreamSynchronize(s)); + std::vector us; + for (int i = 0; i < o.replays; ++i) { float ms; CU_RT(cudaEventElapsedTime(&ms, e0[i], e1[i])); us.push_back(1000.0 * ms / o.nodes); } + data[vi].push_back(us); + } + for (size_t vi = 0; vi < vars.size(); ++vi) { print_stat(mode, T, vars[vi].name, summarize(data[vi])); CU_RT(cudaGraphExecDestroy(exec[vi])); } + for (int i = 0; i < o.replays; ++i) { cudaEventDestroy(e0[i]); cudaEventDestroy(e1[i]); } +} + +// single launch: a 50 us spin kernel keeps the stream ahead of the host, then event, launch(es), event; weights rotate over the sets +static void time_single(const Options& o, Context& c, const std::vector& vars, int T, cudaStream_t s) { + std::vector e0(o.single), e1(o.single); + for (int i = 0; i < o.single; ++i) { CU_RT(cudaEventCreate(&e0[i])); CU_RT(cudaEventCreate(&e1[i])); } + std::vector>> data(vars.size()); + int counter = 0; + for (int r = 0; r < o.rounds; ++r) + for (size_t k = 0; k < vars.size(); ++k) { + const size_t vi = (k + (size_t) r) % vars.size(); + for (int i = 0; i < o.single; ++i) { + mb_spin_ns<<<1, 1, 0, s>>>(50000ull); + CU_RT(cudaEventRecord(e0[i], s)); + vars[vi].run(T, counter++ % (int) c.sets.size(), s); + CU_RT(cudaEventRecord(e1[i], s)); + } + CU_RT(cudaStreamSynchronize(s)); + std::vector us; + for (int i = 0; i < o.single; ++i) { float ms; CU_RT(cudaEventElapsedTime(&ms, e0[i], e1[i])); us.push_back(1000.0 * ms); } + data[vi].push_back(us); + } + for (size_t vi = 0; vi < vars.size(); ++vi) print_stat("single_launch_cold_weights", T, vars[vi].name, summarize(data[vi])); + for (int i = 0; i < o.single; ++i) { cudaEventDestroy(e0[i]); cudaEventDestroy(e1[i]); } +} + +#include "compare_outputs.inc" + +static int run(int argc, char** argv) { + Options o; + for (int i = 1; i < argc; ++i) { + const std::string a = argv[i]; + auto next = [&]() { return i + 1 < argc ? std::atoi(argv[++i]) : 0; }; + if (a == "--ptx" && i + 1 < argc) o.ptx = argv[++i]; + else if (a == "--cubin" && i + 1 < argc) o.cubin = argv[++i]; + else if (a == "--rounds") o.rounds = next(); + else if (a == "--replays") o.replays = next(); + else if (a == "--nodes") o.nodes = next(); + else if (a == "--sets") o.sets = next(); + else if (a == "--single") o.single = next(); + else if (a == "--tmin") o.tmin = next(); + else if (a == "--tmax") o.tmax = next(); + else { std::fprintf(stderr, "unknown argument %s\n", a.c_str()); return 1; } + } + if (o.ptx.empty()) { std::fprintf(stderr, "usage: microbench --ptx chain_window.ptx [--cubin chain_window.cubin] [--rounds R --replays N --nodes B --sets S --single N --tmin 1 --tmax 8]\n"); return 1; } + setenv("STRATA_GR_V3", "1", 1); // upstream's own entry point (fused_gr_read_multi) takes the v3 read, as on an sm_120 card by default + setvbuf(stdout, nullptr, _IOLBF, 0); + CU_RT(cudaFree(0)); + int dev = 0, rtv = 0, drv = 0; + CU_RT(cudaGetDevice(&dev)); cudaRuntimeGetVersion(&rtv); cudaDriverGetVersion(&drv); + cudaDeviceProp prop; CU_RT(cudaGetDeviceProperties(&prop, dev)); + std::printf("device %d %s cc %d.%d SMs %d L2 %d MiB runtime %d driver %d\n", dev, prop.name, prop.major, prop.minor, prop.multiProcessorCount, prop.l2CacheSize >> 20, rtv, drv); + std::printf("config rounds %d replays %d nodes %d sets %d single %d T %d..%d N %d HC %d LR %d D %d\n", o.rounds, o.replays, o.nodes, o.sets, o.single, o.tmin, o.tmax, N, HC, LR, D); + std::printf("upstream default mask on cc 12.0 is 133 (include/strata/core/bw_dense_defaults.hpp gr_v3_pf_default); gr_r2() = %d (STRATA_GR_R2 default)\n", gr_r2()); + + Context c; + std::mt19937 rng(7); // the seed and the distributions of upstream's tools gr_v3_screen.cpp + std::normal_distribution nd(0.f, 1.f); + std::vector bo((size_t) kTokensMax * N), inj((size_t) kTokensMax * HC), wn(D); + c.in.R0.resize((size_t) kTokensMax * D); + for (auto& x : c.in.R0) x = nd(rng); + for (auto& x : bo) x = 0.5f * nd(rng); + for (auto& x : inj) x = nd(rng); + for (auto& x : wn) x = 1.0f + 0.3f * nd(rng); + std::vector wd((size_t) LR * D), wu((size_t) D * LR), wi((size_t) HC * D); + for (auto& x : wd) x = bf16_bits(0.02f * nd(rng)); + for (auto& x : wu) x = bf16_bits(0.05f * nd(rng)); + for (auto& x : wi) x = bf16_bits(0.02f * nd(rng)); + CU_RT(cudaMalloc((void**) &c.in.bo, bo.size() * 4)); CU_RT(cudaMemcpy(c.in.bo, bo.data(), bo.size() * 4, cudaMemcpyHostToDevice)); + CU_RT(cudaMalloc((void**) &c.in.inj, inj.size() * 4)); CU_RT(cudaMemcpy(c.in.inj, inj.data(), inj.size() * 4, cudaMemcpyHostToDevice)); + for (int i = 0; i < o.sets; ++i) { + WeightSet w; + CU_RT(cudaMalloc((void**) &w.down, wd.size() * 2)); CU_RT(cudaMemcpy(w.down, wd.data(), wd.size() * 2, cudaMemcpyHostToDevice)); + CU_RT(cudaMalloc((void**) &w.up, wu.size() * 2)); CU_RT(cudaMemcpy(w.up, wu.data(), wu.size() * 2, cudaMemcpyHostToDevice)); + CU_RT(cudaMalloc((void**) &w.inject, wi.size() * 2)); CU_RT(cudaMemcpy(w.inject, wi.data(), wi.size() * 2, cudaMemcpyHostToDevice)); + CU_RT(cudaMalloc((void**) &w.norm, wn.size() * 4)); CU_RT(cudaMemcpy(w.norm, wn.data(), wn.size() * 4, cudaMemcpyHostToDevice)); + c.sets.push_back(w); + } + c.w_down_u = new_work(c.in); c.w_down_o = new_work(c.in); c.w_down_c = new_work(c.in); c.w_pipe_u = new_work(c.in); c.w_pipe_o = new_work(c.in); + CU_RT(cudaFuncSetAttribute(mb_empty_upstream_shape, cudaFuncAttributeMaxDynamicSharedMemorySize, 8 * N * (int) sizeof(float))); + mb_set_upstream_attributes(); + + CU_DRV(cuInit(0)); + if (!load_ours(o.ptx, true, "sealed PTX via cuModuleLoadData", c.ptx)) return 1; + const bool have_cubin = !o.cubin.empty() && load_ours(o.cubin, false, "nvcc cubin", c.cubin); + cudaStream_t s; CU_RT(cudaStreamCreateWithFlags(&s, cudaStreamNonBlocking)); + CU_RT(cudaDeviceSynchronize()); + + const int failures = compare_outputs(o, c, have_cubin, s); + + // the activations of the ours-down-only timing: what the split kernel writes for a full window (the down kernel reads xn and nothing else) + for (Work* w : {&c.w_down_o, &c.w_down_c}) { + ours_launch(c.ptx.split, ours_multi(kTokensMax, *w, c.sets[0], c.in), ours_split_grid(kTokensMax), 0, s); + CU_RT(cudaStreamSynchronize(s)); + } + const std::vector down = down_variants(c, have_cubin), pipe = pipeline_variants(c); + { // clocks up before the first measurement: about two seconds of the real kernels, all window sizes + const auto t0 = std::chrono::steady_clock::now(); + while (std::chrono::duration(std::chrono::steady_clock::now() - t0).count() < 2.0) { + for (int i = 0; i < 200; ++i) { down[3].run(1 + i % kTokensMax, i % (int) c.sets.size(), s); down[0].run(1 + i % kTokensMax, i % (int) c.sets.size(), s); } + CU_RT(cudaStreamSynchronize(s)); + } + } + for (int T = o.tmin; T <= o.tmax; ++T) { + const MbLaunchShape u133 = mb_upstream_down_shape(133, T), u5 = mb_upstream_down_shape(5, T), u0 = mb_upstream_down_shape(0, T); + std::printf("SHAPE T=%d upstream mask0: grid (%d,%d) block %d dyn %zu B %s | mask5: grid (%d,%d) dyn %zu B %s | mask133: grid (%d,%d) dyn %zu B %s | ours down: grid (%d,%d) block %d dyn %u B\n", + T, u0.blocks_x, u0.blocks_y, THREADS, u0.shared, u0.kernel, u5.blocks_x, u5.blocks_y, u5.shared, u5.kernel, u133.blocks_x, u133.blocks_y, u133.shared, u133.kernel, + ours_down_grid(T).x, ours_down_grid(T).y, THREADS, ours_down_shared(T)); + time_graphs(o, c, down, T, true, s); + time_graphs(o, c, down, T, false, s); + time_graphs(o, c, pipe, T, true, s); + time_single(o, c, down, T, s); + } + std::printf("microbench done, correctness failures: %d\n", failures); + return failures ? 3 : 0; +} + +} // namespace microbench +} // namespace strata::kernels + +int main(int argc, char** argv) { return strata::kernels::microbench::run(argc, argv); } diff --git a/scripts/e2e/codex/speed/verify-hc-down-kernel-microbench-vs-upstream/ours-shim/strata/kernels/fused_gr.hpp b/scripts/e2e/codex/speed/verify-hc-down-kernel-microbench-vs-upstream/ours-shim/strata/kernels/fused_gr.hpp new file mode 100644 index 00000000..032247bd --- /dev/null +++ b/scripts/e2e/codex/speed/verify-hc-down-kernel-microbench-vs-upstream/ours-shim/strata/kernels/fused_gr.hpp @@ -0,0 +1,24 @@ +// Shim for the microbench only: the 112-byte FusedGrArgs ABI that the sealed chain_window.ptx was built against +// (crates/cuda-driver static_asserts sizeof(FusedGrArgs) == 112 and sizeof(GrMulti) == 912); the header in engine/strata/include +// has later fields (q8_*, s_*), 168 bytes, which the sealed kernels do not know. Only the fields chain_window.cu uses. +#pragma once +#include +namespace strata::kernels { +struct FusedGrArgs { + const float* R = nullptr; + float* R_out = nullptr; + bool apply = false; + const float* bo_prev = nullptr; + const float* inj_prev = nullptr; + const float* w_norm = nullptr; + const uint16_t* w_down = nullptr; + const uint16_t* w_up = nullptr; + const uint16_t* w_inject = nullptr; + float eps = 1e-6f; + float* lo = nullptr; + float* rs = nullptr; + float* inject_out = nullptr; + float* mixed = nullptr; +}; +constexpr int kFusedGrMaxT = 8; +} // namespace strata::kernels diff --git a/scripts/e2e/codex/speed/verify-hc-down-kernel-microbench-vs-upstream/summarize.py b/scripts/e2e/codex/speed/verify-hc-down-kernel-microbench-vs-upstream/summarize.py new file mode 100644 index 00000000..32ed4e23 --- /dev/null +++ b/scripts/e2e/codex/speed/verify-hc-down-kernel-microbench-vs-upstream/summarize.py @@ -0,0 +1,87 @@ +#!/usr/bin/env python3 +"""Per-T tables from the CSV lines of microbench (stdlib only): python3 -I summarize.py result.txt + +CSV,mode,T,variant,median,p10,p90,min,mean,round_median_lo,round_median_hi,n (microseconds per launch) +A difference "resolved" means |ours - upstream| is larger than the spread of the per-round medians of both (noise bound of the run). +Sign: delta = ours - upstream; positive = upstream is faster. +""" +import sys +from collections import defaultdict + +SHORT = { + "upstream_mask0_plain": "up_m0", + "upstream_mask5_batched_staging_loads": "up_m5", + "upstream_mask133_register_blocked_dot": "up_m133", + "ours_down_t2w8_nb4_sealed_ptx": "ours_ptx", + "ours_down_t2w8_nb4_nvcc_cubin": "ours_cubin", + "ours_split_plus_down_sealed_ptx": "ours_split+down", + "empty_kernel_with_upstream_mask133_launch_shape": "empty_up", + "empty_kernel_with_our_launch_shape": "empty_ours", + "pipeline_upstream_mask0_down_plus_up": "pipe_up_m0", + "pipeline_upstream_mask5_down_plus_up": "pipe_up_m5", + "pipeline_upstream_mask133_down_plus_up": "pipe_up_m133", + "pipeline_ours_split_down_up8_sealed_ptx": "pipe_ours", +} + + +def load(path): + data = defaultdict(lambda: defaultdict(dict)) + for line in open(path, errors="replace"): + if not line.startswith("CSV,"): + continue + f = line.rstrip("\n").split(",") + mode, t, name = f[1], int(f[2]), SHORT.get(f[3], f[3]) + v = [float(x) for x in f[4:11]] + data[mode][t][name] = dict(median=v[0], p10=v[1], p90=v[2], mn=v[3], mean=v[4], lo=v[5], hi=v[6]) + return data + + +def table(data, mode, cols, title): + if mode not in data: + return + print(f"\n== {title}: median us per launch (p10..p90)") + print("T " + "".join(f"{c:>26}" for c in cols)) + for t in sorted(data[mode]): + row = data[mode][t] + cells = [] + for c in cols: + x = row.get(c) + cells.append(f"{x['median']:8.3f} ({x['p10']:6.2f}..{x['p90']:6.2f})" if x else "-") + print(f"{t:<2} " + "".join(f"{c:>26}" for c in cells)) + + +def deltas(data, mode, ours, ups, title): + if mode not in data: + return + print(f"\n== {title}: delta = {ours} - upstream, us per launch (positive: upstream faster); '*' = larger than the round-to-round spread of both") + print("T " + "".join(f"{u:>26}" for u in ups)) + for t in sorted(data[mode]): + row = data[mode][t] + if ours not in row: + continue + cells = [] + for u in ups: + if u not in row: + cells.append("-") + continue + a, b = row[ours], row[u] + d = a["median"] - b["median"] + spread = (a["hi"] - a["lo"]) + (b["hi"] - b["lo"]) + cells.append(f"{d:+8.3f} ({100 * d / b['median']:+6.1f}%) {'*' if abs(d) > spread else ' '}") + print(f"{t:<2} " + "".join(f"{c:>26}" for c in cells)) + + +def main(path): + d = load(path) + down = ["up_m0", "up_m5", "up_m133", "ours_ptx", "ours_cubin", "ours_split+down", "empty_up", "empty_ours"] + for mode, title in (("graph_cold_weights", "graph-batched, cold weights (headline)"), ("graph_warm_weights", "graph-batched, warm weights (L2-resident)"), + ("single_launch_cold_weights", "single launch with events (includes event overhead; see the empty-kernel columns)")): + table(d, mode, down, title) + deltas(d, mode, "ours_ptx", ["up_m133", "up_m5", "up_m0"], title + ", our down kernel alone") + deltas(d, mode, "ours_split+down", ["up_m133", "up_m5", "up_m0"], title + ", our split+down (upstream's down kernel also does the norm's sum of squares and staging)") + table(d, "graph_cold_weights", ["pipe_up_m0", "pipe_up_m5", "pipe_up_m133", "pipe_ours"], "whole read (down+up for upstream, split+down+up8 for ours), cold weights") + deltas(d, "graph_cold_weights", "pipe_ours", ["pipe_up_m133", "pipe_up_m5", "pipe_up_m0"], "whole read") + + +if __name__ == "__main__": + main(sys.argv[1]) diff --git a/scripts/e2e/codex/speed/verify-hc-down-kernel-microbench-vs-upstream/upstream_down_launch.inc b/scripts/e2e/codex/speed/verify-hc-down-kernel-microbench-vs-upstream/upstream_down_launch.inc new file mode 100644 index 00000000..d53a3eb9 --- /dev/null +++ b/scripts/e2e/codex/speed/verify-hc-down-kernel-microbench-vs-upstream/upstream_down_launch.inc @@ -0,0 +1,115 @@ +// Included by microbench.cu INSIDE namespace strata::kernels::microbench, after upstream's fused_gr.cu was included whole +// (so N, HC, D, LR, PR, THREADS, WARPS, GrMulti, gr_down_v3_kernel, gr_down_pf_dispatch, ... are upstream's own, unmodified). +// +// 1. mb_launch_upstream_down: the down-kernel selection of upstream's fused_gr_read_multi_slice (fused_gr.cu, the lines from +// `const int pfm = ...` to the `else gr_down_v3_kernel<1, kFusedGrMaxT, false>` ladder), copied in the same order, for S == 1 +// (split == 1, the case on an sm_120 card), calling upstream's own static launch helpers and kernels. +// 2. mb_set_upstream_attributes: the cudaFuncSetAttribute calls of the same function (its split3 block), for the instantiations the +// plain ladder launches (the PF and RB helpers set their own attributes on first use, as upstream does). +// 3. mb_finalize_down: a TRANSCRIPTION (not upstream's compiled code) of the lines of gr_up_v3_kernel (S == 1, PF == 0 path) that turn +// the down kernel's `part` / `ssg` into rs, lo and inject_out, so the down stage's result can be compared with ours. +// Upstream's up kernel keeps lo in shared memory only, hence the transcription. The same lines run inside the real up kernel in the +// pipeline measurement (whose rs / inject_out / mixed outputs are compared with the real kernel's, not the transcription's). + +static void mb_set_upstream_attributes() { + const int need1 = (int) (kFusedGrMaxT * N * sizeof(float)), need5 = (int) (5 * N * sizeof(float)), need6 = (int) (6 * N * sizeof(float)); + const int need7 = (int) (7 * N * sizeof(float)), need8 = (int) (8 * N * sizeof(float)); + const cudaFuncAttribute dyn = cudaFuncAttributeMaxDynamicSharedMemorySize, carve = cudaFuncAttributePreferredSharedMemoryCarveout; + cudaFuncSetAttribute(gr_down_v3_kernel<1, kFusedGrMaxT, false>, dyn, need1); + cudaFuncSetAttribute(gr_down_v3_kernel<1, 6, true>, dyn, need6); + cudaFuncSetAttribute(gr_down_v3_kernel<1, 5, true>, dyn, need5); + cudaFuncSetAttribute(gr_down_v3_kernel<1, 5, true, 2>, dyn, need5); + cudaFuncSetAttribute(gr_down_v3_kernel<1, 6, true, 2>, dyn, need6); + cudaFuncSetAttribute(gr_down_v3_kernel<1, 7, true, 1>, dyn, need7); + cudaFuncSetAttribute(gr_down_v3_kernel<1, 7, true, 2>, dyn, need7); + cudaFuncSetAttribute(gr_down_v3_kernel<1, 7, true, 4>, dyn, need7); + cudaFuncSetAttribute(gr_down_v3_kernel<1, 8, true, 1>, dyn, need8); + cudaFuncSetAttribute(gr_down_v3_kernel<1, 8, true, 2>, dyn, need8); + cudaFuncSetAttribute(gr_down_v3_kernel<1, 8, true, 4>, dyn, need8); + cudaFuncSetAttribute(gr_down_v3_kernel<1, 1, true>, carve, 100); + cudaFuncSetAttribute(gr_down_v3_kernel<1, 2, true>, carve, 100); + cudaFuncSetAttribute(gr_down_v3_kernel<1, 3, true>, carve, 100); + cudaFuncSetAttribute(gr_down_v3_kernel<1, 4, true>, carve, 100); + cudaFuncSetAttribute(gr_down_v3_kernel<1, 5, true>, carve, 100); + cudaFuncSetAttribute(gr_down_v3_kernel<1, 6, true>, carve, 100); + cudaFuncSetAttribute(gr_down_v3_kernel<1, 4, false>, carve, 100); + cudaFuncSetAttribute(gr_down_v3_kernel<1, kFusedGrMaxT, false>, carve, 100); +} + +// grid / dynamic shared bytes the selection above gives for `mask` and `n_tok` rows (reported next to the timings) +struct MbLaunchShape { int blocks_x, blocks_y; size_t shared; const char* kernel; }; +static MbLaunchShape mb_upstream_down_shape(int mask, int n_tok) { + const size_t sm = (size_t) n_tok * N * sizeof(float); + if ((mask & 128) != 0 && n_tok >= 5) return {LR / (WARPS * 2) + 1, HC, sm, "gr_down_v3_kernel<1,T,exact,R2V=2,PF=0,RB=true>"}; + if ((mask & 3) != 0) return {LR / WARPS + 1, HC, sm, "gr_down_v3_kernel<1,T,exact,R2V=1,PF=mask&3>"}; + if (n_tok >= 5) return {LR / (WARPS * 2) + 1, HC, sm, "gr_down_v3_kernel<1,T,exact,R2V=2,PF=0> (STRATA_GR_R2 default 2)"}; + return {LR / WARPS + 1, HC, sm, "gr_down_v3_kernel<1,T,exact,R2V=1,PF=0>"}; +} + +static void mb_launch_upstream_down(int pfm, int n_tok, const GrMulti& m, float* part, float* ssg, cudaStream_t st) { + const size_t sm = (size_t) n_tok * N * sizeof(float); + if ((pfm & 128) != 0 && n_tok >= 5 && gr_down_rb_dispatch_k<2>(n_tok, m, part, ssg, st)) {} + else if ((pfm & 256) != 0 && gr_down_rb_dispatch_k<4>(n_tok, m, part, ssg, st)) {} + else if (((pfm >> 4) & 3) == 1 && gr_down_r2_dispatch_k<2>(n_tok, m, part, ssg, st)) {} + else if (((pfm >> 4) & 3) == 2 && gr_down_r2_dispatch_k<4>(n_tok, m, part, ssg, st)) {} + else if ((pfm & 3) != 0 && gr_down_pf_dispatch(pfm & 3, n_tok, m, part, ssg, st)) {} + else if (n_tok == 1) gr_down_v3_kernel<1, 1, true><<>>(m, part, ssg); + else if (n_tok == 2) gr_down_v3_kernel<1, 2, true><<>>(m, part, ssg); + else if (n_tok == 3) gr_down_v3_kernel<1, 3, true><<>>(m, part, ssg); + else if (n_tok == 4) gr_down_v3_kernel<1, 4, true><<>>(m, part, ssg); + else if (n_tok == 5 && gr_r2() == 2) gr_down_v3_kernel<1, 5, true, 2><<>>(m, part, ssg); + else if (n_tok == 5) gr_down_v3_kernel<1, 5, true><<>>(m, part, ssg); + else if (n_tok == 6 && gr_r2() == 2) gr_down_v3_kernel<1, 6, true, 2><<>>(m, part, ssg); + else if (n_tok == 6) gr_down_v3_kernel<1, 6, true><<>>(m, part, ssg); + else if (n_tok == 7 && gr_r2() == 2) gr_down_v3_kernel<1, 7, true, 2><<>>(m, part, ssg); + else if (n_tok == 7 && gr_r2() == 4) gr_down_v3_kernel<1, 7, true, 4><<>>(m, part, ssg); + else if (n_tok == 7 && gr_r2() == 1) gr_down_v3_kernel<1, 7, true, 1><<>>(m, part, ssg); + else if (n_tok == 8 && gr_r2() == 2) gr_down_v3_kernel<1, 8, true, 2><<>>(m, part, ssg); + else if (n_tok == 8 && gr_r2() == 4) gr_down_v3_kernel<1, 8, true, 4><<>>(m, part, ssg); + else if (n_tok == 8 && gr_r2() == 1) gr_down_v3_kernel<1, 8, true, 1><<>>(m, part, ssg); + else gr_down_v3_kernel<1, kFusedGrMaxT, false><<>>(m, part, ssg); +} + +// part / ssg live in the read's scratch exactly as fused_gr_read_multi_slice lays them out +static float* mb_part(float* scratch) { return scratch; } +static float* mb_ssg(float* scratch, int n_tok) { return scratch + (size_t) n_tok * HC * 2 * PR; } + +__global__ void __launch_bounds__(THREADS) mb_finalize_down(GrMulti m, const float* part, const float* ssg, float* lo_out, float* inject_out_out, float* rs_out) { + __shared__ float rsS[kFusedGrMaxT][HC]; + const int t = threadIdx.x, T = m.T; + if (t < T * HC) { // gr_up_v3_kernel: the rms scale of (token, stream) + const int k = t / HC, c = t - k * HC; + float ss = 0.0f; + ss += ssg[t]; + const float r = rsqrtf(ss / (float) N + m.a[k].eps); + rsS[k][c] = r; + rs_out[t] = r; + } + __syncthreads(); + for (int i = t; i < T * LR; i += THREADS) { + const int k = i / LR, r = i - k * LR; + float sum = 0.0f; +#pragma unroll + for (int c = 0; c < HC; ++c) { + float p = 0.0f; + p += part[(((size_t) k * HC + c) * 1 + 0) * PR + r]; + sum = fmaf(rsS[k][c], p, sum); + } + const float x = sum / (float) HC; + lo_out[(size_t) k * LR + r] = x / (1.0f + __expf(-x)); + } + if (t < T * HC) { + const int k = t / HC, cc = t - k * HC; + float sum = 0.0f; +#pragma unroll + for (int c = 0; c < HC; ++c) { + float p = 0.0f; + p += part[(((size_t) k * HC + c) * 1 + 0) * PR + LR + cc]; + sum = fmaf(rsS[k][c], p, sum); + } + inject_out_out[t] = sum; + } +} + +// launch-shape floor: a kernel with the same grid / block / dynamic shared memory / by-value argument and an empty body +__global__ void __launch_bounds__(THREADS) mb_empty_upstream_shape(GrMulti m) { if (m.T < 0) m.a[0].lo[0] = 0.0f; } diff --git a/scripts/e2e/codex/speed/verify-switches-identity.sh b/scripts/e2e/codex/speed/verify-switches-identity.sh new file mode 100644 index 00000000..c53620eb --- /dev/null +++ b/scripts/e2e/codex/speed/verify-switches-identity.sh @@ -0,0 +1,85 @@ +#!/usr/bin/env bash +# Copy of draftround-id.sh with up to nine processes (P1 reference, P2..P9 changed). Original header: +# draft-round identity gate (bitwise): teacher-forced replay of the 256k-class capture night5-long-256k (5 requests, recorded replies, decode capped at MAX_NEW forced tokens +# each), production shape, top-16 logprobs of every row and the draft trace (LELEKA_TRACE_DRAFT=1: every draft's ids and IEEE bits of its probabilities), seed OFF, ONE test binary +# (dt/$ID_BIN) for all processes, one process per setting, two arms in each (I1 I2: the A/A floor). HOLDER JOB (copy of footprint3-id.sh). +# ID_BIN test binary directory name under /data/leleka-e2e/decode/dt (required) +# P1_ENV extra env of the reference process (default: nothing) +# P2_ENV extra env of the changed process (required) +# P3_ENV .. P9_ENV optional further processes (verify-switches-identity.sh: one setting each) +# ID_OUT output directory (required) MAX_NEW (default 240) ADAPT (default 4: the adaptive tier swaps, as dt-id2) +# SKIP_P1=1 reuse $ID_OUT/idP1.full of an earlier job (same binary, same environment) as the reference instead of running it again +# ~10 GPU-min a process. Verdict: q_pair (top-16 logprob rows, all common rows must be identical) and draftround-idcmp.py (the draft trace lines must be identical). +set -uo pipefail +LOCK=/data/leleka-e2e/gpu.lock +D=${D:-/data/leleka-e2e/decode/dt} # binaries (dt/), dt/tools, dt/scripts; override to run from another tree +DR=${DR:-/data/leleka-e2e/draft-round} # tools + MANIFEST.sha256; override to run from another tree +O=${ID_OUT:?ID_OUT} +ID_BIN=${ID_BIN:?ID_BIN} +MAX_NEW=${MAX_NEW:-240} +ADAPT=${ADAPT:-4} +mkdir -p "$O" +( cd / && sha256sum --quiet -c "$DR/MANIFEST.sha256" ) || { echo "draft-round: MANIFEST.sha256 check failed" >&2; exit 3; } +export LD_LIBRARY_PATH=$HOME/cuda-toolkits/cublas-12.9.1.4/lib:$HOME/cuda-toolkits/13.2.2/lib64:${LD_LIBRARY_PATH:-} +A=$HOME/leleka-gates/assets +G=$HOME/work/gpu-runs +CAP=/data/leleka-e2e/sm120/capture +export LELEKA_STRA169_KAR_PROVENANCE=$A/qwen-iq3-s-l2-v4.kar.provenance.json +export LELEKA_STRA169_IQ3S_SHARD0=$A/model/Qwen3.8-Flash-Next-GSQ-RCO-IQ3_S-00001-of-00002.gguf +export LELEKA_STRA169_IQ3S_SHARD1=$A/model/Qwen3.8-Flash-Next-GSQ-RCO-IQ3_S-00002-of-00002.gguf +export LELEKA_STRA169_MTP_PACK=$A/data/mtp-rt LELEKA_STRA169_MTP_STAGING=$G/mtp-staging-own LELEKA_ORIGINAL_SERVE_BUDGET_GIB=30 +export LELEKA_ORIGINAL_SERVE_EXPERT_PER_LAYER=yes LELEKA_ORIGINAL_SERVE_PCIE_FRAC=0.45 +export LELEKA_SMOKE_PROMPT_CACHE=0 LELEKA_SERVE_PROFILE=1 LELEKA_GRAPH_EXEC_REUSE=off +export LELEKA_ORIGINAL_SERVE_EXPERT_PROFILE=/data/leleka-e2e/decode/assets/expert-profile-upstream.bin +export LELEKA_ORIGINAL_SERVE_RT_DIR=$A/data/mtp-rt +export LELEKA_ORIGINAL_SERVE_EXPERT_SLOTS=8000 LELEKA_CHAIN=all +export LELEKA_ORIGINAL_SERVE_ADAPT_EVERY=$ADAPT LELEKA_ORIGINAL_SERVE_SEED=off LELEKA_ORIGINAL_SERVE_CPU_WORKERS=1 LELEKA_SPEC=4 LELEKA_SPEC_SUFFIX=0 +unset LELEKA_SERVE_DRAFT_AFTER_COMMIT LELEKA_PROMPT_EMBED_ALIAS LELEKA_VRAM_LEDGER LELEKA_DENSE_SLAB LELEKA_FOOTPRINT_LEGACY LELEKA_SM120_ATTN_DAILY_MTP LELEKA_DRAFT_FUSED_COMMIT LELEKA_DRAFT_ROUND +for f in $D/$ID_BIN $D/tools/q_pair.py $D/tools/q_tail_gate.py $DR/tools/draftround-idcmp.py $CAP/night5-long-256k; do + [ -e "$f" ] || { echo "missing $f" >&2; exit 3; } +done +sha256sum $D/$ID_BIN | tee $O/rt.sha256 +shape="reply@8192/8192!orig!fast!nocluster!store!qpf!gpool!mspan" +run() { # label extra-env + got=0 + for i in $(seq 1 1080); do + if mkdir $LOCK 2>/dev/null; then echo "draft-round identity $1 $(date -u +%FT%TZ)" >$LOCK/owner; got=1; break; fi + sleep 5 + done + [ $got = 1 ] || { echo "GPU lock held by: $(cat $LOCK/owner 2>/dev/null)"; return 3; } + avail=$(awk '/MemAvailable/{print int($2/1048576)}' /proc/meminfo); echo "=== $1 extra=[$2] MemAvailable GiB: $avail" + if [ "$avail" -lt 60 ]; then echo "abort: less than 60 GiB available"; rm -f $LOCK/owner; rmdir $LOCK; return 4; fi + date -u +%FT%TZ + env $2 LELEKA_TRACE_DRAFT=1 LELEKA_ORIGINAL_SERVE_REPLAY=yes LELEKA_BRINGUP_TRACE=1 LELEKA_REPLAY_DIR=$CAP/night5-long-256k LELEKA_PREFIX_TRACE=1 LELEKA_REPLAY_PREFIX_MIB=6000 LELEKA_TRACE_PREFILL_R=1 LELEKA_TRACE_LOGPROBS=16 \ + LELEKA_REPLAY_MAX_NEW=$MAX_NEW LELEKA_REPLAY_FORCE=1 LELEKA_REPLAY_ARMS="I1=$shape,I2=$shape" \ + nice -n 5 $D/$ID_BIN --ignored --exact --test-threads=1 --nocapture backend::original_serve_replay::original_serve_replay_smoke > $O/$1.full 2>&1 + echo "rc=$? label=$1"; date -u +%FT%TZ + grep -a -E "^REPLAY #|test result|panicked|FAILED|expert cache [0-9]+ slots" $O/$1.full | cut -c1-200 | tail -14 + grep -a -c "^DRAFT " $O/$1.full + rm -f $LOCK/owner; rmdir $LOCK 2>/dev/null + sleep 15 +} +if [ "${SKIP_P1:-0}" = 1 ]; then [ -s "$O/idP1.full" ] || { echo "SKIP_P1 set but $O/idP1.full is missing" >&2; exit 3; }; else run idP1 "${P1_ENV:-LELEKA_X=1}"; fi +run idP2 "${P2_ENV:?P2_ENV}" +PROCS="idP1 idP2" +for k in 3 4 5 6 7 8 9; do # further processes: P3_ENV .. P9_ENV, one setting each, in order (a gap ends the list) + var="P${k}_ENV"; [ -n "${!var:-}" ] || break + run idP$k "${!var}"; PROCS="$PROCS idP$k" +done +T=$D/tools +for p in $PROCS; do echo "== q_tail_gate $p"; python3 $T/q_tail_gate.py $O/$p.full $CAP/night5-long-256k 2>&1 | tail -8; done +python3 - < "$out/SHA256SUMS" +ls -la "$out" "$out/ptx" diff --git a/tools/gdn-fused/gdn_fused_probe.cpp b/tools/gdn-fused/gdn_fused_probe.cpp new file mode 100644 index 00000000..ad8fd6b1 --- /dev/null +++ b/tools/gdn-fused/gdn_fused_probe.cpp @@ -0,0 +1,208 @@ +// verify-gdn-fused-kernels: model-free probe of crates/cuda-driver/src/sm120_gdn_fused.ptx. NOT RUN by the author (no GPU access in that task): the orchestrator runs it. +// +// The fused GDN layer launch (`leleka_verify_gdn_fused_step`) is run next to the three kernels it replaces (`verify_gdn_conv_l2_multi_kernel`, `verify_gdn_ab_multi_kernel`, +// `verify_gdn_step_norm_multi_kernel` of original_verify.ptx) on real-size random inputs, for every window width T = 1..8, every split of the window into two row groups (the second group +// replays the first group's tokens from h / gate / beta), with the gates computed inside the kernel and with the gates joined (SIDE_MIXER: computed by a separate launch first). EVERY +// byte of h, gate, beta and y is compared, and the canonical state and history must be untouched. The unrolled a/b kernels (`leleka_gdn_ab_unrolled_t*`) are compared with the +// Original's a/b kernel (and chain_window.ptx's `chain_gdn_ab_multi_kernel` when present). Prints "RESULT name key=value" lines; exits 1 if any comparison differs. +// gdn_fused_probe PTXDIR PTXDIR holds original_verify.ptx, sm120_gdn_fused.ptx (and optionally chain_window.ptx): copies of crates/cuda-driver/src/ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define CU(x) do { CUresult r_ = (x); if (r_ != CUDA_SUCCESS) { const char* s_ = nullptr; cuGetErrorString(r_, &s_); fprintf(stderr, "CUDA error %s at %s:%d: %s\n", #x, __FILE__, __LINE__, s_ ? s_ : "?"); exit(2); } } while (0) + +static int g_fail = 0; +static uint64_t g_rng = 0x9e3779b97f4a7c15ull; +static uint32_t rnd() { g_rng ^= g_rng << 13; g_rng ^= g_rng >> 7; g_rng ^= g_rng << 17; return (uint32_t)(g_rng >> 16); } +static float rndf() { return (float)(rnd() & 0xffffff) / 16777216.0f * 2.0f - 1.0f; } // [-1, 1) + +static std::string read_file(const std::string& p) { + FILE* f = fopen(p.c_str(), "rb"); + if (!f) return std::string(); + std::string s; char buf[1 << 16]; size_t n; + while ((n = fread(buf, 1, sizeof buf, f)) > 0) s.append(buf, n); + fclose(f); + return s; +} +static bool load_module(const std::string& p, CUmodule* m) { + std::string s = read_file(p); + if (s.empty()) return false; + s.push_back('\0'); + char log[8192] = {}; + CUjit_option opt[] = {CU_JIT_ERROR_LOG_BUFFER, CU_JIT_ERROR_LOG_BUFFER_SIZE_BYTES}; + void* val[] = {log, (void*)(uintptr_t)sizeof log}; + CUresult r = cuModuleLoadDataEx(m, s.data(), 2, opt, val); + if (r != CUDA_SUCCESS) { fprintf(stderr, "load %s failed: %d %s\n", p.c_str(), (int)r, log); exit(2); } + return true; +} +static CUfunction get_fn(CUmodule m, const char* name) { + CUfunction f; CUresult r = cuModuleGetFunction(&f, m, name); + if (r != CUDA_SUCCESS) { fprintf(stderr, "no entry %s\n", name); exit(2); } + return f; +} +struct Dev { + CUdeviceptr p = 0; size_t n = 0; + void alloc(size_t bytes) { n = bytes; CU(cuMemAlloc(&p, bytes ? bytes : 1)); CU(cuMemsetD8(p, 0, bytes ? bytes : 1)); } + void put(const void* h, size_t bytes) { CU(cuMemcpyHtoD(p, h, bytes)); } + std::vector get() const { std::vector v(n); CU(cuMemcpyDtoH(v.data(), p, n)); return v; } +}; +static bool same(const char* what, const std::vector& a, const std::vector& b) { + if (a.size() != b.size()) { printf("MISMATCH %s: size %zu vs %zu\n", what, a.size(), b.size()); g_fail++; return false; } + size_t bad = 0, first = (size_t)-1; + for (size_t i = 0; i < a.size(); ++i) if (a[i] != b[i]) { if (first == (size_t)-1) first = i; ++bad; } + if (bad) { printf("MISMATCH %s: %zu of %zu bytes differ (first at %zu)\n", what, bad, a.size(), first); g_fail++; return false; } + return true; +} +static CUstream g_s; +static void launch(CUfunction f, unsigned gx, unsigned gy, unsigned bx, unsigned by, void** args) { + CU(cuLaunchKernel(f, gx, gy, 1, bx, by, 1, 0, g_s, args, nullptr)); +} + +constexpr int C = 10240, H = 48, T = 8, N = 2560, ZS = 6144; +constexpr size_t STATE_WORDS = (size_t)128 * 48 * 128; + +// the buffers of one GDN layer; two sets (original / fused) with the same contents +struct Layer { + Dev state, hist, qkv, w, h, gate, beta, z, gamma, y, x, wa, wb, dt, a; +}; +static void alloc_layer(Layer& l) { + l.state.alloc(STATE_WORDS * 4); l.hist.alloc((size_t)C * 3 * 4); l.qkv.alloc((size_t)T * C * 4); l.w.alloc((size_t)C * 4 * 4); + l.h.alloc((size_t)T * C * 4); l.gate.alloc((size_t)T * H * 4); l.beta.alloc((size_t)T * H * 4); l.z.alloc((size_t)T * ZS * 4); + l.gamma.alloc(128 * 4); l.y.alloc((size_t)T * ZS * 4); l.x.alloc((size_t)T * N * 4); l.wa.alloc((size_t)H * N * 2); + l.wb.alloc((size_t)H * N * 2); l.dt.alloc(H * 4); l.a.alloc(H * 4); +} +struct Inputs { std::vector state, hist, qkv, w, z, gamma, x, dt, a; std::vector wa, wb; }; +static Inputs make_inputs(int seed) { + Inputs in; + auto fill = [&](std::vector& v, size_t n, float scale, float shift) { v.resize(n); for (auto& e : v) e = rndf() * scale + shift; }; + fill(in.state, STATE_WORDS, seed ? 0.5f : 2.0f, 0.0f); fill(in.hist, (size_t)C * 3, 1.0f, 0.0f); fill(in.qkv, (size_t)T * C, 1.0f, 0.0f); + fill(in.w, (size_t)C * 4, 0.6f, 0.0f); fill(in.z, (size_t)T * ZS, 2.0f, 0.0f); fill(in.gamma, 128, 0.5f, 1.0f); + fill(in.x, (size_t)T * N, 1.5f, 0.0f); fill(in.dt, H, 1.0f, 0.0f); fill(in.a, H, 0.5f, -1.0f); + auto bf16 = [&](std::vector& v) { v.resize((size_t)H * N); for (auto& e : v) { float f = rndf() * 0.1f; uint32_t u; memcpy(&u, &f, 4); e = (uint16_t)(u >> 16); } }; + bf16(in.wa); bf16(in.wb); + return in; +} +static void upload(Layer& l, const Inputs& in) { + l.state.put(in.state.data(), in.state.size() * 4); l.hist.put(in.hist.data(), in.hist.size() * 4); l.qkv.put(in.qkv.data(), in.qkv.size() * 4); + l.w.put(in.w.data(), in.w.size() * 4); l.z.put(in.z.data(), in.z.size() * 4); l.gamma.put(in.gamma.data(), 512); l.x.put(in.x.data(), in.x.size() * 4); + l.wa.put(in.wa.data(), in.wa.size() * 2); l.wb.put(in.wb.data(), in.wb.size() * 2); l.dt.put(in.dt.data(), H * 4); l.a.put(in.a.data(), H * 4); + for (Dev* d : {&l.h, &l.gate, &l.beta, &l.y}) CU(cuMemsetD8(d->p, 0, d->n)); +} + +struct Fns { CUfunction conv, ab, step, chain_ab, fused, unrolled[7]; }; +static const char* kUnrolled[7] = {"leleka_gdn_ab_unrolled_t1", "leleka_gdn_ab_unrolled_t2", "leleka_gdn_ab_unrolled_t3", "leleka_gdn_ab_unrolled_t4", + "leleka_gdn_ab_unrolled_t5", "leleka_gdn_ab_unrolled_t6", "leleka_gdn_ab_unrolled_t8"}; + +// the Original's three kernels for rows [begin, end) (capture_layer_stage) +static void ab_args_launch(CUfunction f, Layer& l, int begin, int end, unsigned gx, unsigned bx) { + CUdeviceptr x = l.x.p + (size_t)begin * N * 4, wa = l.wa.p, wb = l.wb.p, dt = l.dt.p, a = l.a.p, g = l.gate.p + (size_t)begin * H * 4, b = l.beta.p + (size_t)begin * H * 4; + int n = N, hv = H, t = end - begin; + void* args[] = {&x, &wa, &wb, &dt, &a, &g, &b, &n, &hv, &t}; + launch(f, gx, 1, bx, 1, args); +} +static void original_rows(const Fns& f, Layer& l, int begin, int end, bool with_ab) { + CUdeviceptr hist = l.hist.p, qkv = l.qkv.p, w = l.w.p, h = l.h.p; + int c = C, qkh = 32, tb = begin; float eps = 1e-6f; + void* a1[] = {&hist, &qkv, &w, &h, &c, &qkh, &eps, &tb}; + launch(f.conv, 80, end - begin, 128, 1, a1); + if (with_ab) ab_args_launch(f.ab, l, begin, end, 12, 256); + CUdeviceptr state = l.state.p, g = l.gate.p, b = l.beta.p, z = l.z.p, gm = l.gamma.p, y = l.y.p, nk = 0; + int hk = 16, hv = H, tt = end; + void* a2[] = {&state, &h, &c, &g, &b, &z, &gm, &eps, &y, &hk, &hv, &tt, &nk, &tb}; + launch(f.step, 48, 1, 128, 4, a2); +} +// the fused launch for rows [begin, end); in_kernel = false: the gates were computed by a separate launch before (SIDE_MIXER) +static void fused_rows(const Fns& f, Layer& l, int begin, int end, bool in_kernel) { + float eps = 1e-6f; uint32_t eb; memcpy(&eb, &eps, 4); + uint64_t w[18] = {l.state.p, l.hist.p, l.qkv.p, l.w.p, l.h.p, l.gate.p, l.beta.p, l.z.p, l.gamma.p, l.y.p, + in_kernel ? l.x.p + (size_t)begin * N * 4 : 0, l.wa.p, l.wb.p, l.dt.p, l.a.p, (uint64_t)eb, (uint64_t)begin, (uint64_t)end}; + void* af[] = {w}; + launch(f.fused, 48, 1, 128, 4, af); +} + +static void compare_layers(const char* what, Layer& a, Layer& b) { + CU(cuStreamSynchronize(g_s)); + char name[160]; + for (auto pr : {std::make_pair("h", std::make_pair(&a.h, &b.h)), std::make_pair("gate", std::make_pair(&a.gate, &b.gate)), std::make_pair("beta", std::make_pair(&a.beta, &b.beta)), + std::make_pair("y", std::make_pair(&a.y, &b.y)), std::make_pair("state", std::make_pair(&a.state, &b.state)), std::make_pair("hist", std::make_pair(&a.hist, &b.hist))}) { + snprintf(name, sizeof name, "%s %s", what, pr.first); + same(name, pr.second.first->get(), pr.second.second->get()); + } +} + +static void test_fused(const Fns& f) { + Layer a, b; alloc_layer(a); alloc_layer(b); + int cases = 0; + for (int seed = 0; seed < 3; ++seed) { + Inputs in = make_inputs(seed); + for (int end = 1; end <= T; ++end) { + for (int split = 0; split < end; ++split) { // split == 0: one group of `end` rows; split > 0: rows [0, split) first, then [split, end) + for (int mode = 0; mode < 2; ++mode) { // 0: gates inside the fused launch, 1: gates joined (computed by the separate a/b launch first) + upload(a, in); upload(b, in); + if (split) { original_rows(f, a, 0, split, true); original_rows(f, b, 0, split, true); } + original_rows(f, a, split, end, true); + if (mode == 1) ab_args_launch(f.ab, b, split, end, 12, 256); + fused_rows(f, b, split, end, mode == 0); + char what[96]; snprintf(what, sizeof what, "fused seed %d end %d split %d %s", seed, end, split, mode ? "joined" : "in-kernel"); + compare_layers(what, a, b); + ++cases; + } + } + } + } + printf("RESULT fused cases=%d\n", cases); +} + +static void test_unrolled(const Fns& f) { + Layer a, b; alloc_layer(a); alloc_layer(b); + int cases = 0; + for (int seed = 0; seed < 3; ++seed) { + Inputs in = make_inputs(seed); + for (int rows = 1; rows <= T; ++rows) { + for (int begin = 0; begin + rows <= T; begin += (T - rows > 0 ? T - rows : 1)) { + upload(a, in); upload(b, in); + ab_args_launch(f.ab, a, begin, begin + rows, 12, 256); + char what[96]; snprintf(what, sizeof what, "unrolled-ab seed %d rows %d begin %d", seed, rows, begin); + const unsigned geometry[2][2] = {{96, 32}, {48, 64}}; // the shipped chain shape, upstream's shape + for (const auto& g : geometry) { + upload(b, in); + ab_args_launch(f.unrolled[rows <= 6 ? rows - 1 : 6], b, begin, begin + rows, g[0], g[1]); + CU(cuStreamSynchronize(g_s)); + same(what, a.gate.get(), b.gate.get()); same(what, a.beta.get(), b.beta.get()); + } + if (f.chain_ab) { + upload(b, in); + ab_args_launch(f.chain_ab, b, begin, begin + rows, 96, 32); + CU(cuStreamSynchronize(g_s)); + same(what, a.gate.get(), b.gate.get()); same(what, a.beta.get(), b.beta.get()); + } + ++cases; + } + } + } + printf("RESULT unrolled_ab cases=%d chain=%d\n", cases, f.chain_ab ? 1 : 0); +} + +int main(int argc, char** argv) { + if (argc < 2) { fprintf(stderr, "usage: %s PTXDIR\n", argv[0]); return 2; } + std::string dir = argv[1]; + CU(cuInit(0)); CUdevice dev; CU(cuDeviceGet(&dev, 0)); CUcontext ctx; CU(cuDevicePrimaryCtxRetain(&ctx, dev)); CU(cuCtxSetCurrent(ctx)); CU(cuStreamCreate(&g_s, 0)); + CUmodule mo, mf, mc; + if (!load_module(dir + "/original_verify.ptx", &mo) || !load_module(dir + "/sm120_gdn_fused.ptx", &mf)) { fprintf(stderr, "original_verify.ptx / sm120_gdn_fused.ptx missing in %s\n", dir.c_str()); return 2; } + Fns f = {}; + f.conv = get_fn(mo, "verify_gdn_conv_l2_multi_kernel"); f.ab = get_fn(mo, "verify_gdn_ab_multi_kernel"); f.step = get_fn(mo, "verify_gdn_step_norm_multi_kernel"); + f.fused = get_fn(mf, "leleka_verify_gdn_fused_step"); + for (int i = 0; i < 7; ++i) f.unrolled[i] = get_fn(mf, kUnrolled[i]); + f.chain_ab = load_module(dir + "/chain_window.ptx", &mc) ? get_fn(mc, "chain_gdn_ab_multi_kernel") : nullptr; + test_unrolled(f); + test_fused(f); + printf(g_fail ? "FAIL %d comparisons differ\n" : "PASS every byte identical\n", g_fail); + return g_fail ? 1 : 0; +} diff --git a/tools/verify-qsa-fused-prelude/prelude_probe.cpp b/tools/verify-qsa-fused-prelude/prelude_probe.cpp new file mode 100644 index 00000000..42209775 --- /dev/null +++ b/tools/verify-qsa-fused-prelude/prelude_probe.cpp @@ -0,0 +1,204 @@ +// verify-qsa-fused-prelude: model-free probe of the two fused QSA prelude kernels (docs/experiments/verify-qsa-fused-prelude.md). +// Each fused kernel runs next to the literal launches it replaces on real-size random inputs and EVERY output byte is compared: +// index: [verify_copy_from_mapped_kernel] + n x verify_qsa_append_analytic (original_verify.ptx, original_verify_qsa.ptx) +// against leleka_verify_qsa_index_rows (original_verify_window_qsa_index_rows.ptx) +// kv: n x mtp_original_append (mtp_original_kv.ptx) +// against leleka_verify_qsa_kv_rows (original_verify_window_qsa_kv_rows.ptx) +// Prints "RESULT name key=value" lines and PROBE OK / PROBE FAILED; exit 1 on any difference. Never touches the model. +// prelude_probe PTXDIR PTXDIR holds copies of the five .ptx files from crates/cuda-driver/src/ +// Build (WSL or the build dir only): nvcc -O2 -std=c++17 prelude_probe.cpp -lcuda -o prelude_probe +#include +#include +#include +#include +#include +#include +#include + +#define CU(x) do { CUresult r_ = (x); if (r_ != CUDA_SUCCESS) { const char* s_ = nullptr; cuGetErrorString(r_, &s_); fprintf(stderr, "CUDA error %s at %s:%d: %s\n", #x, __FILE__, __LINE__, s_ ? s_ : "?"); exit(2); } } while (0) + +static int g_fail = 0; +static uint64_t g_rng = 0x9e3779b97f4a7c15ull; +static uint32_t rnd() { g_rng ^= g_rng << 13; g_rng ^= g_rng >> 7; g_rng ^= g_rng << 17; return (uint32_t)(g_rng >> 16); } +static float rndf() { return (float)(rnd() & 0xffffff) / 16777216.0f * 2.0f - 1.0f; } + +static std::string read_file(const std::string& p) { + FILE* f = fopen(p.c_str(), "rb"); + if (!f) { fprintf(stderr, "cannot open %s\n", p.c_str()); exit(2); } + std::string s; char buf[1 << 16]; size_t n; + while ((n = fread(buf, 1, sizeof buf, f)) > 0) s.append(buf, n); + fclose(f); + return s; +} +static CUmodule load_module(const std::string& p) { + std::string s = read_file(p); + s.push_back('\0'); + CUmodule m; char log[8192] = {}; + CUjit_option opt[] = {CU_JIT_ERROR_LOG_BUFFER, CU_JIT_ERROR_LOG_BUFFER_SIZE_BYTES}; + void* val[] = {log, (void*)(uintptr_t)sizeof log}; + if (cuModuleLoadDataEx(&m, s.data(), 2, opt, val) != CUDA_SUCCESS) { fprintf(stderr, "load %s failed: %s\n", p.c_str(), log); exit(2); } + return m; +} +static CUfunction get_fn(CUmodule m, const char* name) { + CUfunction f; + if (cuModuleGetFunction(&f, m, name) != CUDA_SUCCESS) { fprintf(stderr, "no entry %s\n", name); exit(2); } + return f; +} +struct Dev { + CUdeviceptr p = 0; size_t n = 0; + void alloc(size_t bytes) { n = bytes; CU(cuMemAlloc(&p, bytes ? bytes : 1)); CU(cuMemsetD8(p, 0, bytes ? bytes : 1)); } + void put(const void* h, size_t bytes) { CU(cuMemcpyHtoD(p, h, bytes)); } + std::vector get() const { std::vector v(n); CU(cuMemcpyDtoH(v.data(), p, n)); return v; } +}; +static bool same(const char* what, const Dev& a, const Dev& b) { + std::vector x = a.get(), y = b.get(); + size_t bad = 0, first = (size_t)-1; + for (size_t i = 0; i < x.size(); ++i) if (x[i] != y[i]) { if (first == (size_t)-1) first = i; ++bad; } + if (bad) { printf("MISMATCH %s: %zu of %zu bytes differ (first at %zu)\n", what, bad, x.size(), first); g_fail++; return false; } + return true; +} +static CUstream g_s; +static void launch(CUfunction f, unsigned gx, unsigned gy, unsigned bx, void** args) { + CU(cuLaunchKernel(f, gx, gy, 1, bx, 1, 1, 0, g_s, args, nullptr)); +} + +constexpr int D = 128, T = 8, MAX_CELLS = 64 * 4; + +// ---- indexer rows +struct IndexArgs { + uint64_t raw, step, tail, dead, pooled, block_pos, gamma, mtab, snapshot, rows, max_cells; + float epsilon, theta_scale, freq_scale, corr_low, corr_high, ext_factor, mscale, pad; +}; +struct Rope { float theta_scale, freq_scale, corr_low, corr_high, ext_factor, mscale; }; +struct IndexSet { Dev tail, dead, pooled, bpos, snap; }; + +static void index_literal(IndexSet& s, Dev& raw, Dev& step, Dev& gam, bool snapshot, int rows, CUfunction app, CUfunction cpy, const Rope& r) { + if (snapshot) { + CUdeviceptr dst = s.snap.p, src = s.tail.p; int64_t n4 = 96; + void* ac[] = {&dst, &src, &n4}; + launch(cpy, 1, 1, 256, ac); + } + for (int row = 0; row < rows; ++row) { + CUdeviceptr rw = raw.p + (size_t)row * D * 4, pd = step.p + (size_t)row * 16, gm = gam.p, tl = s.tail.p, dd = s.dead.p, po = s.pooled.p, bp = s.bpos.p, mt = 0, rc = 0, rs = 0; + int pb = 0, mc = MAX_CELLS, rm = 0; float e = 1e-6f, th = r.theta_scale, fs = r.freq_scale, cl = r.corr_low, ch = r.corr_high, ex = r.ext_factor, ms = r.mscale; + void* aa[] = {&rw, &pd, &pb, &gm, &e, &tl, &dd, &po, &bp, &mc, &th, &fs, &cl, &ch, &ex, &ms, &mt, &rc, &rs, &rm}; + launch(app, 1, 1, 256, aa); + } +} +static void index_fused(IndexSet& s, Dev& raw, Dev& step, Dev& gam, bool snapshot, int rows, CUfunction fused, const Rope& r) { + IndexArgs a; + memset(&a, 0, sizeof a); + a.raw = raw.p; a.step = step.p; a.tail = s.tail.p; a.dead = s.dead.p; a.pooled = s.pooled.p; a.block_pos = s.bpos.p; a.gamma = gam.p; + a.mtab = 0; a.snapshot = snapshot ? s.snap.p : 0; a.rows = rows; a.max_cells = MAX_CELLS; + a.epsilon = 1e-6f; a.theta_scale = r.theta_scale; a.freq_scale = r.freq_scale; a.corr_low = r.corr_low; a.corr_high = r.corr_high; a.ext_factor = r.ext_factor; a.mscale = r.mscale; + void* af[] = {&a}; + launch(fused, 1, 1, 256, af); +} +static void test_index(CUmodule mo, CUmodule mq, CUmodule mf) { + CUfunction app = get_fn(mq, "verify_qsa_append_analytic"), cpy = get_fn(mo, "verify_copy_from_mapped_kernel"), fused = get_fn(mf, "leleka_verify_qsa_index_rows"); + const size_t pooled_bytes = (size_t)(MAX_CELLS / 4 + 2) * D * 4; + const Rope ropes[] = {{0.7f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f}, {0.8409f, 0.25f, 1.0f, 20.0f, 1.0f, 1.1f}, {0.9f, 0.5f, 2.0f, 30.0f, 0.5f, 1.3f}}; + const int p0s[] = {0, 1, 2, 3, 4, 5, 7, 8, 37, 100, 101, 102, 103, 252}; + IndexSet a, b; Dev raw, step, gam; + for (IndexSet* s : {&a, &b}) { s->tail.alloc(1536); s->dead.alloc(512); s->pooled.alloc(pooled_bytes); s->bpos.alloc(16); s->snap.alloc(1536); } + raw.alloc((size_t)T * D * 4); step.alloc((size_t)T * 16); gam.alloc(512); + int cases = 0; + for (int seed = 0; seed < 120; ++seed) { + const Rope r = ropes[seed % 3]; + const int rows = 1 + (int)(rnd() % T); + const bool snapshot = seed % 5 != 4; + std::vector hraw((size_t)T * D), hg(D), ts(384), ds(128), ps(pooled_bytes / 4); + for (auto& x : hraw) x = rndf() * 2.0f; + for (auto& x : hg) x = rndf() + 1.2f; + for (auto& x : ts) x = rndf(); + for (auto& x : ds) x = rndf(); + for (auto& x : ps) x = rndf(); + int32_t st[T * 4] = {}; + const int p0 = p0s[seed % 14]; + for (int row = 0; row < T; ++row) st[row * 4] = p0 + row; + if (seed % 7 == 6) st[2 * 4] = -1; // a skipped row + if (seed % 11 == 10) st[1 * 4] = MAX_CELLS + 5; // beyond the cells + raw.put(hraw.data(), hraw.size() * 4); step.put(st, sizeof st); gam.put(hg.data(), 512); + int32_t bp0[4] = {-1, 0, 0, 0}; + for (IndexSet* s : {&a, &b}) { s->tail.put(ts.data(), 1536); s->dead.put(ds.data(), 512); s->pooled.put(ps.data(), pooled_bytes); s->bpos.put(bp0, 16); CU(cuMemsetD8(s->snap.p, 0, 1536)); } + index_literal(a, raw, step, gam, snapshot, rows, app, cpy, r); + index_fused(b, raw, step, gam, snapshot, rows, fused, r); + CU(cuStreamSynchronize(g_s)); + char w[96]; + snprintf(w, sizeof w, "index seed %d tail", seed); same(w, a.tail, b.tail); + snprintf(w, sizeof w, "index seed %d dead", seed); same(w, a.dead, b.dead); + snprintf(w, sizeof w, "index seed %d pooled", seed); same(w, a.pooled, b.pooled); + snprintf(w, sizeof w, "index seed %d block_pos", seed); same(w, a.bpos, b.bpos); + snprintf(w, sizeof w, "index seed %d snapshot", seed); same(w, a.snap, b.snap); + ++cases; + } + printf("RESULT index cases=%d\n", cases); +} + +// ---- K/V rows +struct KvArgs { + uint64_t k_q, v_q, k_scale, v_scale, table, host_k_q, host_v_q, host_k_scale, host_v_scale, step, kcur, vcur; + int32_t kv_heads, head_dim, page_size, step_stride, cur_stride, rows; +}; +constexpr int NKV = 2, HD = 256, PAGE = 4, BLOCKS = 64, SLOTS = 24; +struct KvSet { Dev k_q, v_q, k_scale, v_scale, host_k_q, host_v_q, host_k_scale, host_v_scale; }; + +static void test_kv(CUmodule mk, CUmodule mf) { + CUfunction app = get_fn(mk, "mtp_original_append"), fused = get_fn(mf, "leleka_verify_qsa_kv_rows"); + const size_t pool = (size_t)SLOTS * NKV * PAGE * HD, scales = (size_t)SLOTS * NKV * PAGE * (HD / 64) * 2; + const size_t hpool = (size_t)BLOCKS * NKV * PAGE * HD, hscales = (size_t)BLOCKS * NKV * PAGE * (HD / 64) * 2; + KvSet a, b; Dev table, step, kcur, vcur; + for (KvSet* s : {&a, &b}) { s->k_q.alloc(pool); s->v_q.alloc(pool); s->k_scale.alloc(scales); s->v_scale.alloc(scales); s->host_k_q.alloc(hpool); s->host_v_q.alloc(hpool); s->host_k_scale.alloc(hscales); s->host_v_scale.alloc(hscales); } + table.alloc(BLOCKS * 4); step.alloc((size_t)T * 16); kcur.alloc((size_t)T * NKV * HD * 4); vcur.alloc((size_t)T * NKV * HD * 4); + int cases = 0; + for (int seed = 0; seed < 120; ++seed) { + const int rows = 1 + (int)(rnd() % T); + std::vector tab(BLOCKS); + for (int i = 0; i < BLOCKS; ++i) tab[i] = (i % 3 == 2) ? -1 : (i % SLOTS); // some blocks not resident + std::vector hk((size_t)T * NKV * HD), hv(hk.size()); + const float mag = (seed % 4 == 0) ? 1e-3f : (seed % 4 == 1 ? 1.0f : (seed % 4 == 2 ? 300.0f : 0.0f)); + for (auto& x : hk) x = rndf() * mag; + for (auto& x : hv) x = rndf() * mag * ((rnd() & 7) == 0 ? 0.0f : 1.0f); + const int p0 = (int)(rnd() % (BLOCKS * PAGE - T)); + int32_t st[T * 4] = {}; + for (int row = 0; row < T; ++row) st[row * 4] = p0 + row; + table.put(tab.data(), BLOCKS * 4); step.put(st, sizeof st); kcur.put(hk.data(), hk.size() * 4); vcur.put(hv.data(), hv.size() * 4); + for (KvSet* s : {&a, &b}) for (Dev* d : {&s->k_q, &s->v_q, &s->k_scale, &s->v_scale, &s->host_k_q, &s->host_v_q, &s->host_k_scale, &s->host_v_scale}) CU(cuMemsetD8(d->p, 0, d->n)); + for (int row = 0; row < rows; ++row) { + CUdeviceptr kq = a.k_q.p, vq = a.v_q.p, ks = a.k_scale.p, vs = a.v_scale.p, tb = table.p, sp = step.p + (size_t)row * 16; + CUdeviceptr kc = kcur.p + (size_t)row * NKV * HD * 4, vc = vcur.p + (size_t)row * NKV * HD * 4, hkq = a.host_k_q.p, hvq = a.host_v_q.p, hks = a.host_k_scale.p, hvs = a.host_v_scale.p; + int nkv = NKV, hd = HD, pg = PAGE; + void* aa[] = {&kq, &vq, &ks, &vs, &tb, &sp, &kc, &vc, &nkv, &hd, &pg, &hkq, &hvq, &hks, &hvs}; + CU(cuLaunchKernel(app, NKV, HD / 64, 2, 64, 1, 1, 0, g_s, aa, nullptr)); + } + KvArgs f; + memset(&f, 0, sizeof f); + f.k_q = b.k_q.p; f.v_q = b.v_q.p; f.k_scale = b.k_scale.p; f.v_scale = b.v_scale.p; f.table = table.p; + f.host_k_q = b.host_k_q.p; f.host_v_q = b.host_v_q.p; f.host_k_scale = b.host_k_scale.p; f.host_v_scale = b.host_v_scale.p; + f.step = step.p; f.kcur = kcur.p; f.vcur = vcur.p; f.kv_heads = NKV; f.head_dim = HD; f.page_size = PAGE; f.step_stride = 4; f.cur_stride = NKV * HD; f.rows = rows; + void* af[] = {&f}; + launch(fused, rows * 2 * NKV, 1, 256, af); + CU(cuStreamSynchronize(g_s)); + char w[96]; + const struct { const char* n; Dev* x; Dev* y; } cmp[] = {{"k_q", &a.k_q, &b.k_q}, {"v_q", &a.v_q, &b.v_q}, {"k_scale", &a.k_scale, &b.k_scale}, {"v_scale", &a.v_scale, &b.v_scale}, + {"host_k_q", &a.host_k_q, &b.host_k_q}, {"host_v_q", &a.host_v_q, &b.host_v_q}, {"host_k_scale", &a.host_k_scale, &b.host_k_scale}, {"host_v_scale", &a.host_v_scale, &b.host_v_scale}}; + for (const auto& c : cmp) { snprintf(w, sizeof w, "kv seed %d %s", seed, c.n); same(w, *c.x, *c.y); } + ++cases; + } + printf("RESULT kv cases=%d\n", cases); +} + +int main(int argc, char** argv) { + if (argc < 2) { fprintf(stderr, "usage: prelude_probe PTXDIR\n"); return 2; } + std::string dir = argv[1]; + CU(cuInit(0)); + CUdevice dev; CU(cuDeviceGet(&dev, 0)); + CUcontext ctx; CU(cuCtxCreate(&ctx, nullptr, 0, dev)); + CU(cuStreamCreate(&g_s, CU_STREAM_NON_BLOCKING)); + CUmodule mo = load_module(dir + "/original_verify.ptx"), mq = load_module(dir + "/original_verify_qsa.ptx"), mk = load_module(dir + "/mtp_original_kv.ptx"); + CUmodule mfi = load_module(dir + "/original_verify_window_qsa_index_rows.ptx"), mfk = load_module(dir + "/original_verify_window_qsa_kv_rows.ptx"); + test_index(mo, mq, mfi); + test_kv(mk, mfk); + printf(g_fail ? "PROBE FAILED: %d mismatches\n" : "PROBE OK: every output byte identical\n", g_fail); + return g_fail ? 1 : 0; +}