From ada5fc5e68048e39b2e95b0c4c2f0f83ec562ea0 Mon Sep 17 00:00:00 2001 From: Pavlo Ratushnyi Date: Sun, 8 Nov 2026 12:43:15 +0100 Subject: [PATCH] STRA-338 params q02: Launch::new takes a LaunchExtent (grid, block, shared) Co-Authored-By: Claude Sonnet 5.5 --- .../impl_originalverifygdnjournal_2.rs | 4 +- .../impl_originalverifygdnjournal_2_2.rs | 8 +- .../src/original_verify_window_gr.rs | 2 +- .../plan_hc_read_fn.rs | 89 ++++++++++++------- .../plan_ple_row_fn.rs | 16 ++-- .../src/original_verify_window_kernels.rs | 40 +++++++-- .../src/original_verify_window_moe.rs | 2 +- .../plan_expert_groups_fn.rs | 25 +++--- .../plan_f32_to_bf16_fn.rs | 39 +++++--- .../tests/shared_gate_without_native_bf16.rs | 3 +- .../src/original_verify_window_ops.rs | 2 +- ...l_windowops_for_originalverifywindowops.rs | 18 ++-- .../src/original_verify_window_proj.rs | 2 +- .../q8_1_row_bytes_fn.rs | 10 +-- .../src/original_verify_window_qsa.rs | 2 +- .../impl_qsawindow/impl_qsawindow_2.rs | 12 +-- .../impl_qsawindow/impl_qsawindow_2_2.rs | 27 +++--- .../impl_originalverifyqsajournal_2.rs | 4 +- 18 files changed, 185 insertions(+), 120 deletions(-) diff --git a/crates/cuda-driver/src/original_verify/impl_originalverifygdnjournal/impl_originalverifygdnjournal_2.rs b/crates/cuda-driver/src/original_verify/impl_originalverifygdnjournal/impl_originalverifygdnjournal_2.rs index 94804aaf..10ca8f63 100644 --- a/crates/cuda-driver/src/original_verify/impl_originalverifygdnjournal/impl_originalverifygdnjournal_2.rs +++ b/crates/cuda-driver/src/original_verify/impl_originalverifygdnjournal/impl_originalverifygdnjournal_2.rs @@ -179,9 +179,7 @@ impl<'ctx> OriginalVerifyGdnJournal<'_, 'ctx> { kernels::Launch::new( &chain::CHAIN, chain::E_DOORBELL, - [1, 1, 1], - [1024, 1, 1], - 0, + kernels::LaunchExtent::new([1, 1, 1], [1024, 1, 1], 0), vec![ kernels::A::P(a("mixed", begin * g.n * 4, n * g.n * 4)?), kernels::A::P(a("ids", begin * g.k * 4, n * g.k * 4)?), diff --git a/crates/cuda-driver/src/original_verify/impl_originalverifygdnjournal/impl_originalverifygdnjournal_2_2.rs b/crates/cuda-driver/src/original_verify/impl_originalverifygdnjournal/impl_originalverifygdnjournal_2_2.rs index 5201c5c1..3214321b 100644 --- a/crates/cuda-driver/src/original_verify/impl_originalverifygdnjournal/impl_originalverifygdnjournal_2_2.rs +++ b/crates/cuda-driver/src/original_verify/impl_originalverifygdnjournal/impl_originalverifygdnjournal_2_2.rs @@ -112,9 +112,7 @@ impl<'ctx> OriginalVerifyGdnJournal<'_, 'ctx> { kernels::Launch::new( &chain::CHAIN, chain::E_GDN_AB, - [96, 1, 1], - [32, 1, 1], - 0, + 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)?), @@ -245,9 +243,7 @@ impl FusedSpans { kernels::Launch::new( &draft::DRAFT_COMMIT, draft::E_GDN, - [48 + 20, 36, 1], - [128, 4, 1], - 0, + kernels::LaunchExtent::new([48 + 20, 36, 1], [128, 4, 1], 0), vec![kernels::A::Words(vec![ self.state0, LAYER_BYTES as u64, diff --git a/crates/cuda-driver/src/original_verify_window_gr.rs b/crates/cuda-driver/src/original_verify_window_gr.rs index 691322aa..1f9e0369 100644 --- a/crates/cuda-driver/src/original_verify_window_gr.rs +++ b/crates/cuda-driver/src/original_verify_window_gr.rs @@ -22,7 +22,7 @@ //! The Original selects the hc read variant per card (`fused_gr_check`, `STRATA_HC_SPLIT`) and //! the down kernel's tile and token chunking from the device attributes (`down_chunk`); //! `GrConfig` carries exactly those decisions and `GrConfig::from_device` replicates `down_chunk`. -use super::kernels::{A, ArenaMap, AssetSpec, Launch}; +use super::kernels::{A, ArenaMap, AssetSpec, Launch, LaunchExtent}; use super::layout::OriginalVerifyGeometry; use super::proj::{self, NativeWeight, plan_bf16_gemv, plan_mmvq, plan_quantize_q8_1, q8_1_row_bytes}; use super::window_record::{HcHalf, Rows}; diff --git a/crates/cuda-driver/src/original_verify_window_gr/plan_hc_read_fn.rs b/crates/cuda-driver/src/original_verify_window_gr/plan_hc_read_fn.rs index f1e161f5..8c7ef2b8 100644 --- a/crates/cuda-driver/src/original_verify_window_gr/plan_hc_read_fn.rs +++ b/crates/cuda-driver/src/original_verify_window_gr/plan_hc_read_fn.rs @@ -59,15 +59,23 @@ fn hc_read_norm(cfg: &GrConfig, chain_gr: bool, n: usize, full: &[u64]) -> Resul Launch::new( &super::super::chain::CHAIN, super::super::chain::E_GR_SPLIT, - [n as u32, HC as u32, 1], - [THREADS, 1, 1], - 0, + LaunchExtent::new([n as u32, HC as u32, 1], [THREADS, 1, 1], 0), vec![A::Words(full.to_vec())], ) } else if cfg.variant == GrVariant::Plain { - Launch::new(&GR_FUSED, E_NORM, [n as u32, 1, 1], [THREADS, 1, 1], 0, vec![A::Words(full.to_vec())]) + Launch::new( + &GR_FUSED, + E_NORM, + LaunchExtent::new([n as u32, 1, 1], [THREADS, 1, 1], 0), + vec![A::Words(full.to_vec())], + ) } else { - Launch::new(&GR_FUSED, E_SPLIT, [n as u32, HC as u32, 1], [THREADS, 1, 1], 0, vec![A::Words(full.to_vec())]) + Launch::new( + &GR_FUSED, + E_SPLIT, + LaunchExtent::new([n as u32, HC as u32, 1], [THREADS, 1, 1], 0), + vec![A::Words(full.to_vec())], + ) } } @@ -102,29 +110,39 @@ fn hc_read_down_chunk( (ct, shared): (usize, u32), words: impl FnOnce() -> Vec, ) -> Result { - use super::super::chain; - if chain_staged && chain::down_tiled() { - // same arithmetic as the staged kernel; blocks of 8 rows x 2 tokens (grid.y = ceil(ct / 2)) spread the work - // over the SMs, the whole weight row in registers, four tile buffers of two tokens in flight - let (grid, shared) = tiled_down_geometry(ct); - if shared > cfg.usable_shared { - return Err(Error::InvalidProjectionShape); - } - let entry = chain::E_GR_DOWN_T2W8; - return Launch::new(&chain::CHAIN, entry, grid, [THREADS, 1, 1], shared, vec![A::Words(words())]); + if chain_staged && super::super::chain::down_tiled() { + return hc_read_down_tiled(cfg, ct, words); } if chain_staged { - // same arithmetic as the staged kernel; the whole weight row in registers and three (two above six tokens) - // tile buffers in flight - let (entry, buffers) = if ct <= 6 { (chain::E_GR_DOWN_NB3, 3) } else { (chain::E_GR_DOWN_NB2, 2) }; - let shared = buffers * ct as u32 * (STAGED_TILE * 4); - if shared > cfg.usable_shared { - return Err(Error::InvalidProjectionShape); - } - let blocks = [DOWN_BLOCKS, 1, 1]; - return Launch::new(&chain::CHAIN, entry, blocks, [THREADS, 1, 1], shared, vec![A::Words(words())]); + return hc_read_down_buffered(cfg, ct, words); } - Launch::new(&GR_FUSED, cfg.down_entry(), [DOWN_BLOCKS, 1, 1], [THREADS, 1, 1], shared, vec![A::Words(words())]) + let extent = LaunchExtent::new([DOWN_BLOCKS, 1, 1], [THREADS, 1, 1], shared); + Launch::new(&GR_FUSED, cfg.down_entry(), extent, vec![A::Words(words())]) +} + +/// The tiled chain down kernel. Same arithmetic as the staged kernel; blocks of 8 rows x 2 tokens (grid.y = ceil(ct / +/// 2)) spread the work over the SMs, the whole weight row in registers, four tile buffers of two tokens in flight. +fn hc_read_down_tiled(cfg: &GrConfig, ct: usize, words: impl FnOnce() -> Vec) -> Result { + use super::super::chain; + let (grid, shared) = tiled_down_geometry(ct); + if shared > cfg.usable_shared { + return Err(Error::InvalidProjectionShape); + } + let entry = chain::E_GR_DOWN_T2W8; + Launch::new(&chain::CHAIN, entry, LaunchExtent::new(grid, [THREADS, 1, 1], shared), vec![A::Words(words())]) +} + +/// The two/three-buffer chain down kernel. Same arithmetic as the staged kernel; the whole weight row in registers and +/// three (two above six tokens) tile buffers in flight. +fn hc_read_down_buffered(cfg: &GrConfig, ct: usize, words: impl FnOnce() -> Vec) -> Result { + use super::super::chain; + let (entry, buffers) = if ct <= 6 { (chain::E_GR_DOWN_NB3, 3) } else { (chain::E_GR_DOWN_NB2, 2) }; + let shared = buffers * ct as u32 * (STAGED_TILE * 4); + if shared > cfg.usable_shared { + return Err(Error::InvalidProjectionShape); + } + let blocks = [DOWN_BLOCKS, 1, 1]; + Launch::new(&chain::CHAIN, entry, LaunchExtent::new(blocks, [THREADS, 1, 1], shared), vec![A::Words(words())]) } fn hc_read_up(chain_gr: bool, full: Vec) -> Result { @@ -136,9 +154,14 @@ fn hc_read_up(chain_gr: bool, full: Vec) -> Result { } else { (super::super::chain::E_GR_UP16, UP_BLOCKS) }; - Launch::new(&super::super::chain::CHAIN, entry, [blocks, 1, 1], [THREADS, 1, 1], 0, vec![A::Words(full)]) + Launch::new( + &super::super::chain::CHAIN, + entry, + LaunchExtent::new([blocks, 1, 1], [THREADS, 1, 1], 0), + vec![A::Words(full)], + ) } else { - Launch::new(&GR_FUSED, E_UP, [UP_BLOCKS, 1, 1], [THREADS, 1, 1], 0, vec![A::Words(full)]) + Launch::new(&GR_FUSED, E_UP, LaunchExtent::new([UP_BLOCKS, 1, 1], [THREADS, 1, 1], 0), vec![A::Words(full)]) } } @@ -157,9 +180,7 @@ pub(super) fn write_row(arena: &dyn ArenaMap, cfg: &GrConfig, row: usize, produc Launch::new( &GR_POST, "mtp_full_native_write", - [(D as u32).div_ceil(THREADS), 1, 1], - [THREADS, 1, 1], - 0, + LaunchExtent::new([(D as u32).div_ceil(THREADS), 1, 1], [THREADS, 1, 1], 0), vec![A::P(r), A::P(bo), A::P(inject), A::P(r), A::I32(N as i32), A::I32(HC as i32), A::F32(QUARTER)], ) } @@ -226,14 +247,16 @@ fn head_mix_row( let mixed = mixed_base + (t * N * 4) as u64; // native_gr_rms_norm_weighted(R, w_norm, xn, n_embd, hc, eps): n_cols >= 1024 -> <1024>, hc blocks let norm_args = vec![A::P(r), A::P(w.norm), A::P(xn), A::I32(N as i32), A::F32(EPS)]; - let norm = Launch::new(&GR_NORM, "mtp_full_gr_norm", [HC as u32, 1, 1], [1024, 1, 1], 0, norm_args)?; + let norm = + Launch::new(&GR_NORM, "mtp_full_gr_norm", LaunchExtent::new([HC as u32, 1, 1], [1024, 1, 1], 0), norm_args)?; let down = plan_bf16_gemv(xn, D, w.down, lo, LR, D, LR, 1)?; let silu_grid = [(LR as u32).div_ceil(THREADS), 1, 1]; let silu_args = vec![A::P(lo), A::I32(LR as i32), A::F32(QUARTER)]; - let silu = Launch::new(&GR_POST, "mtp_full_down_silu", silu_grid, [THREADS, 1, 1], 0, silu_args)?; + let silu = + Launch::new(&GR_POST, "mtp_full_down_silu", LaunchExtent::new(silu_grid, [THREADS, 1, 1], 0), silu_args)?; let up = plan_bf16_gemv(lo, LR, w.up, gated, D, LR, D, 1)?; let pre_grid = [(N as u32).div_ceil(THREADS), 1, 1]; let pre_args = vec![A::P(xn), A::P(gated), A::P(mixed), A::I32(N as i32), A::I32(HC as i32), A::F32(QUARTER)]; - let pre = Launch::new(&GR_POST, "mtp_full_pre_final", pre_grid, [THREADS, 1, 1], 0, pre_args)?; + let pre = Launch::new(&GR_POST, "mtp_full_pre_final", LaunchExtent::new(pre_grid, [THREADS, 1, 1], 0), pre_args)?; Ok([norm, down, silu, up, pre]) } diff --git a/crates/cuda-driver/src/original_verify_window_gr/plan_ple_row_fn.rs b/crates/cuda-driver/src/original_verify_window_gr/plan_ple_row_fn.rs index 8e3326cd..33695211 100644 --- a/crates/cuda-driver/src/original_verify_window_gr/plan_ple_row_fn.rs +++ b/crates/cuda-driver/src/original_verify_window_gr/plan_ple_row_fn.rs @@ -107,7 +107,7 @@ fn plan_ple_key( fn ple_rms(input: u64, gamma: u64, output: u64) -> Result { let args = vec![A::P(input), A::P(gamma), A::P(output)]; - Launch::new(&PLE_BATCH, "ple_rms", [HC as u32, 1, 1], [1024, 1, 1], 0, args) + Launch::new(&PLE_BATCH, "ple_rms", LaunchExtent::new([HC as u32, 1, 1], [1024, 1, 1], 0), args) } /// native_ple_postops(d_key, hidden, d_value, hist, w, {key=d_query, query=d_norm, gate=d_gate, @@ -116,17 +116,23 @@ fn plan_ple_postops(a: &PleAddrs, r: u64, s: &PleScratch) -> Result<[Launch; 7]> let rms_key = ple_rms(s.key, a.norm_key, s.query)?; let rms_hidden = ple_rms(r, a.norm_query, s.norm)?; let gate_args = vec![A::P(s.query), A::P(s.norm), A::P(s.gate), A::F32(1.0f32 / (N as f32).sqrt())]; - let gate = Launch::new(&PLE_BATCH, "ple_gate", [HC as u32, 1, 1], [512, 1, 1], 0, gate_args)?; + let gate = Launch::new(&PLE_BATCH, "ple_gate", LaunchExtent::new([HC as u32, 1, 1], [512, 1, 1], 0), gate_args)?; let blocks = (D as u32) / THREADS; let broadcast_args = vec![A::P(s.value), A::P(s.gate), A::P(s.gated), A::I32(1)]; - let broadcast = Launch::new(&PLE_BATCH, "ple_broadcast", [blocks, 1, 1], [THREADS, 1, 1], 0, broadcast_args)?; + let broadcast = Launch::new( + &PLE_BATCH, + "ple_broadcast", + LaunchExtent::new([blocks, 1, 1], [THREADS, 1, 1], 0), + broadcast_args, + )?; let rms_gated = ple_rms(s.gated, a.norm_conv, s.norm)?; let conv_args = vec![A::P(a.history), A::P(s.norm), A::P(a.conv1d), A::P(r), A::P(s.gated), A::P(s.conv), A::I32(1)]; - let conv = Launch::new(&PLE_BATCH, "ple_conv", [blocks, 1, 1], [THREADS, 1, 1], 0, conv_args)?; + let conv = Launch::new(&PLE_BATCH, "ple_conv", LaunchExtent::new([blocks, 1, 1], [THREADS, 1, 1], 0), conv_args)?; // ple_history_advance(hist, normalized) let history_args = vec![A::P(a.history), A::P(s.norm), A::I32(1)]; - let history = Launch::new(&PLE_BATCH, "ple_history", [blocks, 1, 1], [THREADS, 1, 1], 0, history_args)?; + let history = + Launch::new(&PLE_BATCH, "ple_history", LaunchExtent::new([blocks, 1, 1], [THREADS, 1, 1], 0), history_args)?; Ok([rms_key, rms_hidden, gate, broadcast, rms_gated, conv, history]) } diff --git a/crates/cuda-driver/src/original_verify_window_kernels.rs b/crates/cuda-driver/src/original_verify_window_kernels.rs index aeb5b80e..c4862669 100644 --- a/crates/cuda-driver/src/original_verify_window_kernels.rs +++ b/crates/cuda-driver/src/original_verify_window_kernels.rs @@ -126,6 +126,22 @@ impl A { } } +/// The `<<>>` extent of one window kernel launch: blocks per grid, threads per block and +/// dynamic shared memory bytes. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub(crate) struct LaunchExtent { + pub grid: [u32; 3], + pub block: [u32; 3], + pub shared: u32, +} +impl LaunchExtent { + /// The extent of `grid` blocks of `block` threads with `shared` bytes of dynamic shared memory. + #[inline] + pub(crate) const fn new(grid: [u32; 3], block: [u32; 3], shared: u32) -> Self { + Self { grid, block, shared } + } +} + /// One `cuLaunchKernel`: `<<>>` of `entry` in `asset`. #[derive(Clone, Debug)] pub(crate) struct Launch { @@ -154,11 +170,10 @@ impl Launch { pub(crate) fn new( asset: &'static AssetSpec, entry: &'static str, - grid: [u32; 3], - block: [u32; 3], - shared: u32, + extent: LaunchExtent, args: Vec, ) -> Result { + let LaunchExtent { grid, block, shared } = extent; if !asset.has_entry(entry) || grid.contains(&0) || block.contains(&0) { return Err(Error::InvalidQwenShape); } @@ -246,10 +261,19 @@ mod tests { #[test] fn launch_refuses_foreign_entries_and_empty_geometry() { - assert!(Launch::new(&SPEC, "a", [1, 1, 1], [32, 1, 1], 0, vec![]).is_ok()); - assert_eq!(Launch::new(&SPEC, "c", [1, 1, 1], [32, 1, 1], 0, vec![]).unwrap_err(), Error::InvalidQwenShape); - assert_eq!(Launch::new(&SPEC, "a", [0, 1, 1], [32, 1, 1], 0, vec![]).unwrap_err(), Error::InvalidQwenShape); - assert_eq!(Launch::new(&SPEC, "a", [1, 1, 1], [32, 0, 1], 0, vec![]).unwrap_err(), Error::InvalidQwenShape); + assert!(Launch::new(&SPEC, "a", LaunchExtent::new([1, 1, 1], [32, 1, 1], 0), vec![]).is_ok()); + assert_eq!( + Launch::new(&SPEC, "c", LaunchExtent::new([1, 1, 1], [32, 1, 1], 0), vec![]).unwrap_err(), + Error::InvalidQwenShape + ); + assert_eq!( + Launch::new(&SPEC, "a", LaunchExtent::new([0, 1, 1], [32, 1, 1], 0), vec![]).unwrap_err(), + Error::InvalidQwenShape + ); + assert_eq!( + Launch::new(&SPEC, "a", LaunchExtent::new([1, 1, 1], [32, 0, 1], 0), vec![]).unwrap_err(), + Error::InvalidQwenShape + ); } #[test] @@ -281,7 +305,7 @@ mod tests { #[test] fn launch_label_names_asset_entry_and_geometry() { - let l = Launch::new(&SPEC, "b", [2, 3, 1], [32, 4, 1], 16, vec![A::I32(1)]).unwrap(); + let l = Launch::new(&SPEC, "b", LaunchExtent::new([2, 3, 1], [32, 4, 1], 16), vec![A::I32(1)]).unwrap(); assert_eq!(l.label(), "demo:b <<<[2, 3, 1],[32, 4, 1],16>>>"); } } diff --git a/crates/cuda-driver/src/original_verify_window_moe.rs b/crates/cuda-driver/src/original_verify_window_moe.rs index f8ed38e8..6672e72a 100644 --- a/crates/cuda-driver/src/original_verify_window_moe.rs +++ b/crates/cuda-driver/src/original_verify_window_moe.rs @@ -30,7 +30,7 @@ //! they live in the new source `original_verify_window_moe_experts.cu` (PTX compiled with nvcc 13.2.86 and sealed //! on 2026-10-15). An asset whose bytes stop matching its pin makes the expert producers fail closed with the //! asset's refusal text. GPU load is verified separately by the host smokes; no numerical claim. -use super::kernels::{A, ArenaMap, AssetSpec, Launch}; +use super::kernels::{A, ArenaMap, AssetSpec, Launch, LaunchExtent}; use super::proj::{self, NativeWeight, plan_bf16_gemv, plan_mmvq, plan_quantize_q8_1}; use super::window_plan::{PlanLayout, WINDOW_LAYERS}; use super::window_record::{ExpertTier, Rows}; diff --git a/crates/cuda-driver/src/original_verify_window_moe/plan_expert_groups_fn.rs b/crates/cuda-driver/src/original_verify_window_moe/plan_expert_groups_fn.rs index 672dc784..887c2d03 100644 --- a/crates/cuda-driver/src/original_verify_window_moe/plan_expert_groups_fn.rs +++ b/crates/cuda-driver/src/original_verify_window_moe/plan_expert_groups_fn.rs @@ -117,13 +117,13 @@ impl GroupPlan { if tiny { let args = vec![A::P(gate), A::P(up), A::P(h), A::P(hq), A::I64(nh as i64)]; let (chain, entry) = (&super::super::chain::CHAIN, super::super::chain::E_SWIGLU_QUANT); - return Ok(vec![Launch::new(chain, entry, grid, [256, 1, 1], 0, args)?]); + return Ok(vec![Launch::new(chain, entry, LaunchExtent::new(grid, [256, 1, 1], 0), args)?]); } let swiglu_args = vec![A::P(gate), A::P(up), A::P(h), A::I64(nh as i64)]; let quant_args = vec![A::P(h), A::P(hq), A::I64(nh as i64)]; Ok(vec![ - Launch::new(&HEAD_IQ_EXPERT, E_SWIGLU_ENTRIES, grid, [256, 1, 1], 0, swiglu_args)?, - Launch::new(&HEAD_IQ_EXPERT, E_QUANTIZE_Q8_1, grid, [256, 1, 1], 0, quant_args)?, + Launch::new(&HEAD_IQ_EXPERT, E_SWIGLU_ENTRIES, LaunchExtent::new(grid, [256, 1, 1], 0), swiglu_args)?, + Launch::new(&HEAD_IQ_EXPERT, E_QUANTIZE_Q8_1, LaunchExtent::new(grid, [256, 1, 1], 0), quant_args)?, ]) } @@ -142,7 +142,7 @@ impl GroupPlan { A::P(self.hq), ]; let grid = [(self.n_ff / 32) as u32, self.cap as u32, 1]; - Launch::new(&super::super::sm120::GU_SWIGLU, entry, grid, [512, 1, 1], 0, args) + Launch::new(&super::super::sm120::GU_SWIGLU, entry, LaunchExtent::new(grid, [512, 1, 1], 0), args) } fn gate_up(&self, entry: &'static str, words: &[u64]) -> Result { @@ -157,7 +157,7 @@ impl GroupPlan { A::P(self.up), ]; let grid = [(2 * self.n_ff).div_ceil(8) as u32, self.cap as u32, 1]; - Launch::new(&EXPERTS, entry, grid, [256, 1, 1], 0, args) + Launch::new(&EXPERTS, entry, LaunchExtent::new(grid, [256, 1, 1], 0), args) } fn down(&self, entry: &'static str, words: Vec) -> Result { @@ -165,7 +165,7 @@ impl GroupPlan { let args = vec![A::P(ptr), A::P(start), A::P(groups), A::P(dst), A::P(self.hq), A::Words(words), A::P(self.out)]; let grid = [self.n_embd.div_ceil(8) as u32, self.cap as u32, 1]; - Launch::new(&EXPERTS, entry, grid, [256, 1, 1], 0, args) + Launch::new(&EXPERTS, entry, LaunchExtent::new(grid, [256, 1, 1], 0), args) } } @@ -183,9 +183,7 @@ pub(crate) fn plan_hit_add(arena: Arena<'_>, g: &OriginalVerifyGeometry, rows: R Ok(vec![Launch::new( &S2_HITS, E_ADD_HITS, - [n_embd.div_ceil(256).min(8) as u32, cap as u32, 1], - [256, 1, 1], - 0, + LaunchExtent::new([n_embd.div_ceil(256).min(8) as u32, cap as u32, 1], [256, 1, 1], 0), vec![A::P(parts), A::P(hit_out), A::P(dst), A::P(count), A::I32(n_embd as i32)], )?]) } @@ -229,14 +227,19 @@ fn combine_row(arena: Arena<'_>, g: &OriginalVerifyGeometry, knobs: &MoeKnobs, t fn combine_native(g: &OriginalVerifyGeometry, [parts, w, shared, bo]: [u64; 4], tokens: usize) -> Result { let (n_embd, k) = (g.n, g.k); let args = vec![A::P(parts), A::P(w), A::P(shared), A::P(bo), A::I64(n_embd as i64), A::I32(k as i32)]; - Launch::new(&COMBINE, E_COMBINE, [n_embd.div_ceil(256) as u32, tokens as u32, 1], [256, 1, 1], 0, args) + Launch::new( + &COMBINE, + E_COMBINE, + LaunchExtent::new([n_embd.div_ceil(256) as u32, tokens as u32, 1], [256, 1, 1], 0), + args, + ) } /// The legacy double-precision `moe_combine` of one row. fn combine_legacy(g: &OriginalVerifyGeometry, [parts, w, shared, bo]: [u64; 4]) -> Result { let (n_embd, k) = (g.n, g.k); let args = vec![A::P(parts), A::P(w), A::P(shared), A::P(bo), A::I32(n_embd as i32), A::I32(k as i32), A::I32(1)]; - Launch::new(&SHARED, E_MOE_COMBINE, [n_embd.div_ceil(128) as u32, 1, 1], [128, 1, 1], 0, args) + Launch::new(&SHARED, E_MOE_COMBINE, LaunchExtent::new([n_embd.div_ceil(128) as u32, 1, 1], [128, 1, 1], 0), args) } /// ONE `native_moe_combine_multi` launch over all rows of the group. diff --git a/crates/cuda-driver/src/original_verify_window_moe/plan_f32_to_bf16_fn.rs b/crates/cuda-driver/src/original_verify_window_moe/plan_f32_to_bf16_fn.rs index 87bca9f8..e225b929 100644 --- a/crates/cuda-driver/src/original_verify_window_moe/plan_f32_to_bf16_fn.rs +++ b/crates/cuda-driver/src/original_verify_window_moe/plan_f32_to_bf16_fn.rs @@ -9,9 +9,7 @@ pub(super) fn plan_f32_to_bf16(x: u64, y: u64, count: usize) -> Result { Launch::new( &ELEMENT, E_TO_BF16, - [count.div_ceil(256) as u32, 1, 1], - [256, 1, 1], - 0, + LaunchExtent::new([count.div_ceil(256) as u32, 1, 1], [256, 1, 1], 0), vec![A::P(x), A::P(y), A::I64(count as i64)], ) } @@ -22,7 +20,12 @@ pub(super) fn plan_f32_to_bf16(x: u64, y: u64, count: usize) -> Result { /// `route<<>>(logits, ids, weights)` (`native_router_top10(_multi)`). pub(super) fn plan_route(logits: u64, ids: u64, weights: u64, tokens: usize) -> Result { - Launch::new(&ROUTER, E_ROUTE, [tokens as u32, 1, 1], [32, 8, 1], 0, vec![A::P(logits), A::P(ids), A::P(weights)]) + Launch::new( + &ROUTER, + E_ROUTE, + LaunchExtent::new([tokens as u32, 1, 1], [32, 8, 1], 0), + vec![A::P(logits), A::P(ids), A::P(weights)], + ) } /// The router of a group: Router logits and top-10 for rows `[tb, te)`. @@ -125,7 +128,7 @@ fn router_top10_generic(spans: &RouterSpans<'_>, y: u64, t: usize) -> Result { let (n, n_embd, n_ff) = (self.n, self.n_embd, self.n_ff); let count = n_ff * n; let args = vec![A::P(gate), A::P(up), A::P(gate), A::I32(count as i32)]; - out.push(Launch::new(&SHARED, E_NATIVE_SWIGLU, [count.div_ceil(128) as u32, 1, 1], [128, 1, 1], 0, args)?); + out.push(Launch::new( + &SHARED, + E_NATIVE_SWIGLU, + LaunchExtent::new([count.div_ceil(128) as u32, 1, 1], [128, 1, 1], 0), + args, + )?); out.push(plan_quantize_q8_1(gate, xq, n_ff, n)?); out.push(plan_mmvq(&self.w.down_shexp, xq, shared, n_ff, n_embd, n, self.knobs.dispatch)?); Ok(()) @@ -224,7 +232,12 @@ impl SharedExpert<'_> { // one GEMV for all rows (outputs identical), one sigmoid launch with thread t = token t out.push(plan_bf16_gemv(self.xm, n_embd, self.w.gate_inp_shexp, gscalar, 1, n_embd, 1, n)?); if !self.tiny { - out.push(Launch::new(&SHARED, E_SIGMOID_MULTI, [1, 1, 1], [n as u32, 1, 1], 0, vec![A::P(gscalar)])?); + out.push(Launch::new( + &SHARED, + E_SIGMOID_MULTI, + LaunchExtent::new([1, 1, 1], [n as u32, 1, 1], 0), + vec![A::P(gscalar)], + )?); } return Ok(()); } @@ -241,11 +254,11 @@ impl SharedExpert<'_> { let x_t = f32s(self.arena, "mixed", row * n_embd, n_embd)?; out.push(plan_bf16_gemv(x_t, n_embd, self.w.gate_inp_shexp, g_t, 1, n_embd, 1, 1)?); if !self.tiny { - out.push(Launch::new(&SHARED, E_SIGMOID, [1, 1, 1], [1, 1, 1], 0, vec![A::P(g_t)])?); + out.push(Launch::new(&SHARED, E_SIGMOID, LaunchExtent::new([1, 1, 1], [1, 1, 1], 0), vec![A::P(g_t)])?); } } else { let args = vec![A::P(self.bf16(row, 1)?), A::P(self.w.gate_inp_shexp), A::P(g_t), A::I32(n_embd as i32)]; - out.push(Launch::new(&SHARED, E_SCALAR_GATE, [1, 1, 1], [256, 1, 1], 0, args)?); + out.push(Launch::new(&SHARED, E_SCALAR_GATE, LaunchExtent::new([1, 1, 1], [256, 1, 1], 0), args)?); } Ok(()) } @@ -257,9 +270,9 @@ impl SharedExpert<'_> { let args = vec![A::P(shared), A::P(gscalar), A::I32(self.n_embd as i32)]; if self.tiny && self.knobs.native_bf16_extra { let (chain, entry) = (&super::super::chain::CHAIN, super::super::chain::E_SCALE_SIGMOID); - out.push(Launch::new(chain, entry, grid, [128, 1, 1], 0, args)?); + out.push(Launch::new(chain, entry, LaunchExtent::new(grid, [128, 1, 1], 0), args)?); } else { - out.push(Launch::new(&SHARED, E_SCALE_ROWS, grid, [128, 1, 1], 0, args)?); + out.push(Launch::new(&SHARED, E_SCALE_ROWS, LaunchExtent::new(grid, [128, 1, 1], 0), args)?); } Ok(()) } @@ -292,9 +305,7 @@ pub(crate) fn plan_quantize_expert_input( Ok(vec![Launch::new( &HEAD_IQ_EXPERT, E_QUANTIZE_Q8_1, - [total.div_ceil(256) as u32, 1, 1], - [256, 1, 1], - 0, + LaunchExtent::new([total.div_ceil(256) as u32, 1, 1], [256, 1, 1], 0), vec![A::P(x), A::P(y), A::I64(total as i64)], )?]) } diff --git a/crates/cuda-driver/src/original_verify_window_moe/tests/shared_gate_without_native_bf16.rs b/crates/cuda-driver/src/original_verify_window_moe/tests/shared_gate_without_native_bf16.rs index 215cf0f3..176a87ce 100644 --- a/crates/cuda-driver/src/original_verify_window_moe/tests/shared_gate_without_native_bf16.rs +++ b/crates/cuda-driver/src/original_verify_window_moe/tests/shared_gate_without_native_bf16.rs @@ -308,7 +308,8 @@ fn expert_launches_load_when_sealed_and_are_refused_on_a_corrupted_pin() { // The same launch against a one-byte-corrupted copy of the asset (synthetic; the real PTX is untouched) // is refused with the asset's refusal text, exactly as the unsealed placeholder was. let bad = EXPERTS.derived(crate::sealed_ptx::test_support::one_byte_corrupted(EXPERTS.ptx), EXPERTS.sha); - let launch = Launch::new(bad, l[0].entry, l[0].grid, l[0].block, l[0].shared, l[0].args.clone()).unwrap(); + let launch = + Launch::new(bad, l[0].entry, LaunchExtent::new(l[0].grid, l[0].block, l[0].shared), l[0].args.clone()).unwrap(); assert_eq!(launch.asset.sealed().unwrap_err(), Error::InvalidDriverValue(EXPERTS.unsealed)); assert!(launch.command().is_ok(), "the plan itself is pure data and unaffected"); } diff --git a/crates/cuda-driver/src/original_verify_window_ops.rs b/crates/cuda-driver/src/original_verify_window_ops.rs index 80d9f37e..ef6a740f 100644 --- a/crates/cuda-driver/src/original_verify_window_ops.rs +++ b/crates/cuda-driver/src/original_verify_window_ops.rs @@ -23,7 +23,7 @@ //! lists them). A partially bound window can therefore never be recorded or replayed. use super::chain; use super::gr::{self, GrConfig, OriginalVerifyGrBinding}; -use super::kernels::{A, AssetSpec, Launch}; +use super::kernels::{A, AssetSpec, Launch, LaunchExtent}; use super::moe::{self, MoeLayerAddrs, OriginalVerifyExpertFormats, OriginalVerifyMoeBinding}; use super::planner::{Planner, WindowWeights}; use super::proj::{self, GdnProjectionAddrs, OriginalVerifyProjBinding, QsaProjectionAddrs}; diff --git a/crates/cuda-driver/src/original_verify_window_ops/impl_windowops_for_originalverifywindowops.rs b/crates/cuda-driver/src/original_verify_window_ops/impl_windowops_for_originalverifywindowops.rs index accbe35d..41d96132 100644 --- a/crates/cuda-driver/src/original_verify_window_ops/impl_windowops_for_originalverifywindowops.rs +++ b/crates/cuda-driver/src/original_verify_window_ops/impl_windowops_for_originalverifywindowops.rs @@ -224,7 +224,12 @@ impl OriginalVerifyWindowOps<'_, '_, '_, '_> { let flag = self.mapped_flag(11)?; let (device, mapped) = self.plan_copy_addresses(rows)?; let args = vec![A::P(flag), A::I32(ring as i32), A::P(device), A::P(mapped), A::I32(words as i32)]; - self.launch(vec![Launch::new(&chain::CHAIN, chain::E_WAIT_COPY_I32, [1, 1, 1], [704, 1, 1], 0, args)?]) + self.launch(vec![Launch::new( + &chain::CHAIN, + chain::E_WAIT_COPY_I32, + LaunchExtent::new([1, 1, 1], [704, 1, 1], 0), + args, + )?]) } /// The CPU-hit rows copied back with the plan's hit list, in the chain glue launch. @@ -235,7 +240,12 @@ impl OriginalVerifyWindowOps<'_, '_, '_, '_> { let count = self.plan_word(rows.group, layout.counts + 1)?; let args = vec![A::P(parts), A::P(mapped), A::I64((g.n / 4) as i64), A::P(hit_rows), A::P(count)]; let grid = [(rows.len() * g.k) as u32, 1, 1]; - self.launch(vec![Launch::new(&chain::CHAIN, chain::E_COPY_ROWS, grid, [128, 1, 1], 0, args)?]) + self.launch(vec![Launch::new( + &chain::CHAIN, + chain::E_COPY_ROWS, + LaunchExtent::new(grid, [128, 1, 1], 0), + args, + )?]) } /// The CPU-hit rows copied back with the plan's hit list, as a plain kernel command. @@ -267,9 +277,7 @@ fn pcie_fetch_launch(source: u64, count: u64, stage: u64, [gate, up, down]: [usi Launch::new( spec, entry, - grid, - block, - 0, + LaunchExtent::new(grid, block, 0), vec![A::P(source), A::P(count), A::P(stage), words(gate), words(up), words(down)], ) } diff --git a/crates/cuda-driver/src/original_verify_window_proj.rs b/crates/cuda-driver/src/original_verify_window_proj.rs index b3776d06..0355a511 100644 --- a/crates/cuda-driver/src/original_verify_window_proj.rs +++ b/crates/cuda-driver/src/original_verify_window_proj.rs @@ -11,7 +11,7 @@ //! * bf16 gemv: `mtp_full_mmvf{B}` for one row, the `_multi_kernel` instantiation //! for 2..=8 rows (the weight row read once, every row its single-row order). use super::OriginalVerifyGeometry; -use super::kernels::{A, ArenaMap, AssetSpec, Launch}; +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; diff --git a/crates/cuda-driver/src/original_verify_window_proj/q8_1_row_bytes_fn.rs b/crates/cuda-driver/src/original_verify_window_proj/q8_1_row_bytes_fn.rs index 99117267..d7f90eb1 100644 --- a/crates/cuda-driver/src/original_verify_window_proj/q8_1_row_bytes_fn.rs +++ b/crates/cuda-driver/src/original_verify_window_proj/q8_1_row_bytes_fn.rs @@ -31,9 +31,7 @@ pub(crate) fn plan_quantize_q8_1(x: u64, xq: u64, n_in: usize, rows: usize) -> R Launch::new( &HEAD_NATIVE, "head_quant", - [total.div_ceil(256) as u32, 1, 1], - [256, 1, 1], - 0, + LaunchExtent::new([total.div_ceil(256) as u32, 1, 1], [256, 1, 1], 0), vec![A::P(x), A::P(xq), A::I32(count)], ) } @@ -59,7 +57,7 @@ pub(crate) fn plan_mmvq( if iq { args.push(A::I32(rows as i32)); } - Launch::new(mmvq_asset(w.ty), entry, grid, block, 0, args) + Launch::new(mmvq_asset(w.ty), entry, LaunchExtent::new(grid, block, 0), args) } /// The shape check of `plan_mmvq` and the `i32` kernel extents `(n_in, n_out)`. @@ -119,12 +117,12 @@ pub(crate) fn plan_bf16_gemv( let block = mmvf_block_size(n_in); if n_tok == 1 && ldy >= n_out { let args = vec![A::P(x), A::P(w), A::P(y), A::I32(n_in32)]; - return Launch::new(&BF16, single_entry(block)?, [grid, 1, 1], [block, 1, 1], 0, args); + return Launch::new(&BF16, single_entry(block)?, LaunchExtent::new([grid, 1, 1], [block, 1, 1], 0), args); } let nt = if n_tok <= 4 { 4 } else { 8 }; let (ldx, ldy, n_tok) = (A::I64(ldx as i64), A::I64(ldy as i64), A::I32(n_tok as i32)); let args = vec![A::P(x), ldx, A::P(w), A::P(y), ldy, A::I32(n_in32), n_tok]; - Launch::new(&BF16, multi_entry(block, nt)?, [grid, 1, 1], [block, 1, 1], 0, args) + Launch::new(&BF16, multi_entry(block, nt)?, LaunchExtent::new([grid, 1, 1], [block, 1, 1], 0), args) } // ------------------------------------------------------------------------------------------------ diff --git a/crates/cuda-driver/src/original_verify_window_qsa.rs b/crates/cuda-driver/src/original_verify_window_qsa.rs index d6cfcb05..7a769249 100644 --- a/crates/cuda-driver/src/original_verify_window_qsa.rs +++ b/crates/cuda-driver/src/original_verify_window_qsa.rs @@ -23,7 +23,7 @@ //! * scores / top-k / resolve / attention: `qsa_decode_scores` (Original //! `block_scores_multi_kernel`, the Original dispatch for 1..=8 queries), `qsa_topk_ref`, //! `leleka_qsa_resolve` + `leleka_qsa_miss_copy`, `leleka_qsa_decode_chunk` / `_merge`. -use super::kernels::{A, ArenaMap, AssetSpec, Launch}; +use super::kernels::{A, ArenaMap, AssetSpec, Launch, LaunchExtent}; use super::proj::{self, plan_bf16_gemv}; use super::window_record::Rows; use super::{OriginalVerifyGeometry, admit, handle}; diff --git a/crates/cuda-driver/src/original_verify_window_qsa/impl_qsawindow/impl_qsawindow_2.rs b/crates/cuda-driver/src/original_verify_window_qsa/impl_qsawindow/impl_qsawindow_2.rs index c3888eae..164a8ade 100644 --- a/crates/cuda-driver/src/original_verify_window_qsa/impl_qsawindow/impl_qsawindow_2.rs +++ b/crates/cuda-driver/src/original_verify_window_qsa/impl_qsawindow/impl_qsawindow_2.rs @@ -34,9 +34,7 @@ impl<'a> QsaWindow<'a> { Launch::new( &DECODE_POSTOPS, "qsa_decode_rms", - [grid_u32(rows)?, 1, 1], - [256, 1, 1], - 0, + LaunchExtent::new([grid_u32(rows)?, 1, 1], [256, 1, 1], 0), vec![A::P(data), A::P(gamma), A::P(data), A::I32(declared_i32(cols)?), A::F32(EPS)], ) } @@ -56,9 +54,7 @@ impl<'a> QsaWindow<'a> { Launch::new( &DECODE_POSTOPS, "qsa_decode_rope", - [grid_u32((width / 2).div_ceil(128))?, grid_u32(rows)?, 1], - [128, 1, 1], - 0, + LaunchExtent::new([grid_u32((width / 2).div_ceil(128))?, grid_u32(rows)?, 1], [128, 1, 1], 0), args, ) } @@ -165,7 +161,7 @@ impl<'a> QsaWindow<'a> { let qcur = self.span("qcur", from * nh * hd * 4, count * nh * hd * 4)?; // `cudaMemcpy2DAsync(qcur, HD*4, qfull, HD*2*4, HD*4, count*NH)` as the sealed word copy let args = vec![A::P(qfull), A::P(qcur), A::I64(count as i64)]; - Launch::new(&SPLIT, "qsa_split_q", [grid_u32(count * nh)?, 1, 1], [256, 1, 1], 0, args) + Launch::new(&SPLIT, "qsa_split_q", LaunchExtent::new([grid_u32(count * nh)?, 1, 1], [256, 1, 1], 0), args) } /// `qsa_q_path`: q/gate split, q RMS norm with `attn_q_norm.weight`, RoPE with the query positions. @@ -238,5 +234,5 @@ fn append_launch(kv: &OriginalVerifyQsaKvBinding, [step, k, v]: [u64; 3], (nkv, args.extend([A::P(kv.table), A::P(step), A::P(k), A::P(v)]); args.extend([A::I32(declared_i32(nkv)?), A::I32(declared_i32(hd)?), A::I32(PAGE_SIZE)]); args.extend(kv.host.iter().map(|&a| A::P(a))); - Launch::new(&KV_APPEND, "mtp_original_append", grid, [64, 1, 1], 0, args) + Launch::new(&KV_APPEND, "mtp_original_append", LaunchExtent::new(grid, [64, 1, 1], 0), args) } diff --git a/crates/cuda-driver/src/original_verify_window_qsa/impl_qsawindow/impl_qsawindow_2_2.rs b/crates/cuda-driver/src/original_verify_window_qsa/impl_qsawindow/impl_qsawindow_2_2.rs index 480d68af..5b8eae5a 100644 --- a/crates/cuda-driver/src/original_verify_window_qsa/impl_qsawindow/impl_qsawindow_2_2.rs +++ b/crates/cuda-driver/src/original_verify_window_qsa/impl_qsawindow/impl_qsawindow_2_2.rs @@ -35,11 +35,16 @@ impl<'a> QsaWindow<'a> { A::I64(mb as i64), A::P(scores), ]; - return Launch::new(&SELECT, "qsa_decode_scores", [256, 1, 1], [256, 1, 1], 0, args); + return Launch::new(&SELECT, "qsa_decode_scores", LaunchExtent::new([256, 1, 1], [256, 1, 1], 0), args); } // block_scores_kernel<<<(ceil(max_blocks / 8), nq), 256>>> let args = vec![A::P(w.kv.pooled), A::P(w.kv.dead), A::P(qidx), A::P(steps), A::I64(mb as i64), A::P(scores)]; - Launch::new(&SELECT, SCORE_SINGLE, [grid_u32(mb.div_ceil(8))?, grid_u32(n)?, 1], [256, 1, 1], 0, args) + Launch::new( + &SELECT, + SCORE_SINGLE, + LaunchExtent::new([grid_u32(mb.div_ceil(8))?, grid_u32(n)?, 1], [256, 1, 1], 0), + args, + ) } /// The top-k of `n` queries over the block scores: the thread-block cluster kernel, or `qsa_topk_ref`. @@ -50,10 +55,10 @@ impl<'a> QsaWindow<'a> { // the same ids let grid = [crate::qsa_cluster::CLUSTER_CTAS, grid_u32(n)?, 1]; let (block, smem) = ([crate::qsa_cluster::BLOCK, 1, 1], crate::qsa_cluster::dynamic_smem(mb)); - let launch = Launch::new(&CLUSTER, CLUSTER_ENTRIES[0], grid, block, smem, args)?; + let launch = Launch::new(&CLUSTER, CLUSTER_ENTRIES[0], LaunchExtent::new(grid, block, smem), args)?; return Ok(launch.clustered(crate::qsa_cluster::CLUSTER_CTAS)); } - Launch::new(&SELECT, "qsa_topk_ref", [grid_u32(n)?, 1, 1], [256, 1, 1], 0, args) + Launch::new(&SELECT, "qsa_topk_ref", LaunchExtent::new([grid_u32(n)?, 1, 1], [256, 1, 1], 0), args) } /// `qsa_kv_resolve`: the selections' blocks resident, device side (`kv_stream_resolve`). @@ -73,8 +78,8 @@ impl<'a> QsaWindow<'a> { let mut copy = vec![A::P(r[4]), A::P(r[5]), A::P(r[6])]; copy.extend(w.kv.host.iter().chain(&w.kv.resident).map(|&a| A::P(a))); Ok(vec![ - Launch::new(&RESOLVER, "leleka_qsa_resolve", [1, 1, 1], [1024, 1, 1], 0, resolve)?, - Launch::new(&RESOLVER, "leleka_qsa_miss_copy", [96, 1, 1], [128, 1, 1], 0, copy)?, + Launch::new(&RESOLVER, "leleka_qsa_resolve", LaunchExtent::new([1, 1, 1], [1024, 1, 1], 0), resolve)?, + Launch::new(&RESOLVER, "leleka_qsa_miss_copy", LaunchExtent::new([96, 1, 1], [128, 1, 1], 0), copy)?, ]) } @@ -119,7 +124,7 @@ impl<'a> QsaWindow<'a> { args.extend([A::P(w.kv.table), A::P(a.ids), A::P(a.steps), A::I32(declared_i32(d.nkv)?), A::I32(PAGE_SIZE)]); args.extend([A::F32(a.scale), A::P(a.acc), A::P(a.part_m), A::P(a.part_l)]); args.extend([A::I32(declared_i32(d.chunks)?), A::I32(declared_i32(d.cap)?), A::I64(d.stride as i64)]); - Launch::new(chunk_asset, chunk_entry, grid, [256, 1, 1], 0, args) + Launch::new(chunk_asset, chunk_entry, LaunchExtent::new(grid, [256, 1, 1], 0), args) } /// The merge kernel (`[n_head, n]` grid): the chunk accumulators combined into the attention output. @@ -131,10 +136,10 @@ impl<'a> QsaWindow<'a> { if self.policy.attn_daily { let (asset, entry) = (&super::super::super::sm120::ATTN_DAILY, super::super::super::sm120::E_ATTN_MERGE_V2); let args = vec![A::P(a.acc), A::P(a.part_m), A::P(a.part_l), chunks, A::P(a.steps), A::P(a.attn), tail]; - return Launch::new(asset, entry, grid, [256, 1, 1], 0, args); + return Launch::new(asset, entry, LaunchExtent::new(grid, [256, 1, 1], 0), args); } let args = vec![A::P(a.acc), A::P(a.part_m), A::P(a.part_l), chunks, A::P(a.attn), tail]; - Launch::new(&ATTENTION, "leleka_qsa_decode_merge", grid, [256, 1, 1], 0, args) + Launch::new(&ATTENTION, "leleka_qsa_decode_merge", LaunchExtent::new(grid, [256, 1, 1], 0), args) } /// `qsa_gate`: `native_qsa_gate_apply(attn, qfull, attn32, heads, HD)`; batched = one launch over `n * NH` heads. @@ -150,9 +155,7 @@ impl<'a> QsaWindow<'a> { Launch::new( &GATE, "verify_window_qsa_gate", - [grid_u32((heads * hd).div_ceil(256))?, 1, 1], - [256, 1, 1], - 0, + LaunchExtent::new([grid_u32((heads * hd).div_ceil(256))?, 1, 1], [256, 1, 1], 0), vec![A::P(attn), A::P(qfull), A::P(out), A::I32(declared_i32(heads)?), A::I32(declared_i32(hd)?)], ) }; diff --git a/crates/cuda-driver/src/qsa_verification_commit/impl_originalverifyqsajournal_2.rs b/crates/cuda-driver/src/qsa_verification_commit/impl_originalverifyqsajournal_2.rs index ef9c7252..fbbe0518 100644 --- a/crates/cuda-driver/src/qsa_verification_commit/impl_originalverifyqsajournal_2.rs +++ b/crates/cuda-driver/src/qsa_verification_commit/impl_originalverifyqsajournal_2.rs @@ -61,9 +61,7 @@ impl<'a, 'ctx> OriginalVerifyQsaJournal<'a, 'ctx> { vec![crate::original_verify::kernels::Launch::new( &crate::original_verify::draft::DRAFT_COMMIT_QSA, crate::original_verify::draft::E_QSA, - [12, 1, 1], - [128, 4, 1], - 0, + crate::original_verify::kernels::LaunchExtent::new([12, 1, 1], [128, 4, 1], 0), vec![crate::original_verify::kernels::A::Words(words)], )?], )?;