Merge branch 'claude/size-cudadriver' into claude/hexagonal-integ

This commit is contained in:
Pavlo Ratushnyi
2026-11-06 14:19:33 +01:00
34 changed files with 6128 additions and 4390 deletions
@@ -9,3 +9,11 @@ mod impl_originalgdnpromptdevice_2;
mod impl_originalgdnpromptdevice_2_2;
#[path = "impl_originalgdnpromptdevice/impl_originalgdnpromptdevice_3.rs"]
mod impl_originalgdnpromptdevice_3;
#[path = "impl_originalgdnpromptdevice/impl_originalgdnpromptdevice_4.rs"]
mod impl_originalgdnpromptdevice_4;
#[path = "impl_originalgdnpromptdevice/impl_originalgdnpromptdevice_5.rs"]
mod impl_originalgdnpromptdevice_5;
#[path = "impl_originalgdnpromptdevice/impl_originalgdnpromptdevice_6.rs"]
mod impl_originalgdnpromptdevice_6;
#[allow(unused_imports)]
use impl_originalgdnpromptdevice_6::{Binder, Carve, Carved, Handles, Phase};
@@ -1,7 +1,9 @@
//! Moved out of the parent module by STRA-338: impl OriginalGdnPromptDevice (2).
//! Moved out of the parent module by STRA-338: impl OriginalGdnPromptDevice (2). `produce` admits the buffers, records
//! the command list (`impl_originalgdnpromptdevice_4.rs`) and drains it (`impl_originalgdnpromptdevice_5.rs`).
#[allow(unused_imports)]
use super::*;
use crate::OriginalPromptRows;
impl<'ctx> OriginalGdnPromptDevice<'ctx> {
/// Consumes the actual affine GR read. `state` is untouched prior; only
@@ -16,9 +18,21 @@ impl<'ctx> OriginalGdnPromptDevice<'ctx> {
next_state: &DeviceBuffer<'ctx>,
history: &[f32],
) -> Result<(OriginalDeviceBlock<'arena, 'loan, 'ctx>, Box<[f32]>)> {
let lease = read.lease();
let t = read.rows();
if self.is_failed() || lease.is_failed() {
self.admit(&read, workspace, history)?;
let handles = self.admit_handles(read.lease(), (workspace, t), &weights, (state, next_state))?;
let commands = self.build_commands(&handles, weights.formats, t)?;
let values = self.drain(workspace, commands, history, (&handles, t))?;
Ok((read.from_completed_block(), values))
}
fn admit(
&self,
read: &OriginalDeviceGrRead<'_, '_, 'ctx>,
workspace: &NativeBatchWorkspace<'ctx>,
history: &[f32],
) -> Result<()> {
let t = read.rows();
if self.is_failed() || read.lease().is_failed() {
return Err(Error::ContextPoisoned);
}
if !read.context_matches(self.context) {
@@ -30,31 +44,46 @@ impl<'ctx> OriginalGdnPromptDevice<'ctx> {
if history.iter().any(|x| !x.is_finite()) {
return Err(Error::NonFiniteMmqOutput("GDN prior history"));
}
workspace.validate_context(self.context)?;
workspace.validate_context(self.context)
}
/// Every owner/alias/shape admission precedes the first write.
fn admit_handles(
&self,
lease: &OriginalPromptRows<'_, '_, '_>,
rows: (&NativeBatchWorkspace<'ctx>, usize),
weights: &OriginalGdnPromptWeights<'_, 'ctx>,
io: (&DeviceBuffer<'ctx>, &DeviceBuffer<'ctx>),
) -> Result<Handles> {
let (workspace, t) = rows;
let batch = self.batch.as_ref().ok_or(Error::ContextPoisoned)?;
let status = batch.status_handle()?;
let mut bindings = Bindings::new();
let mut buffer = |role: Role, b: &DeviceBuffer<'_>, bytes: usize| -> Result<ffi::BufferHandle> {
if !std::ptr::eq(b.context, self.context) {
return Err(Error::ContextMismatch);
}
if b.len() != bytes {
return Err(Error::InvalidQwenShape);
}
let h = b.handle.ok_or(Error::ContextPoisoned)?;
h.validate_projection_extent(bytes, 4)?;
workspace.reject_alias(h, bytes)?;
if h.overlaps(bytes, status, STATUS_BYTES) {
return Err(Error::OutputAliasesInput);
}
bindings.bind(role, h, bytes)?;
Ok(h)
};
let scratch = buffer(Role::Scratch, self.scratch.as_ref().ok_or(Error::ContextPoisoned)?, SCRATCH)?;
let hin = buffer(Role::History, self.history[0].as_ref().ok_or(Error::ContextPoisoned)?, HISTORY)?;
let hout = buffer(Role::NextHistory, self.history[1].as_ref().ok_or(Error::ContextPoisoned)?, HISTORY)?;
let sin = buffer(Role::StateIn, state, STATE_WORDS * 4)?;
let sout = buffer(Role::StateOut, next_state, STATE_WORDS * 4)?;
let mut binder = Binder { context: self.context, workspace, status, bindings: Bindings::new(), t };
let [scratch, hin, hout, sin, sout] = self.admit_state(&mut binder, io)?;
let (w, a) = Self::admit_weights(&mut binder, weights, sin)?;
let c = self.admit_carved(&mut binder, lease)?;
Ok(Handles { status, scratch, hin, hout, sin, sout, w, a, c })
}
fn admit_state(
&self,
binder: &mut Binder<'_, 'ctx>,
io: (&DeviceBuffer<'ctx>, &DeviceBuffer<'ctx>),
) -> Result<[ffi::BufferHandle; 5]> {
let scratch = self.scratch.as_ref().ok_or(Error::ContextPoisoned)?;
let scratch = binder.buffer(Role::Scratch, scratch, SCRATCH)?;
let hin = self.history[0].as_ref().ok_or(Error::ContextPoisoned)?;
let hin = binder.buffer(Role::History, hin, HISTORY)?;
let hout = self.history[1].as_ref().ok_or(Error::ContextPoisoned)?;
let hout = binder.buffer(Role::NextHistory, hout, HISTORY)?;
let sin = binder.buffer(Role::StateIn, io.0, STATE_WORDS * 4)?;
let sout = binder.buffer(Role::StateOut, io.1, STATE_WORDS * 4)?;
Ok([scratch, hin, hout, sin, sout])
}
#[allow(clippy::type_complexity)]
fn admit_weights(
binder: &mut Binder<'_, 'ctx>,
weights: &OriginalGdnPromptWeights<'_, 'ctx>,
sin: ffi::BufferHandle,
) -> Result<([ffi::BufferHandle; 5], [ffi::BufferHandle; 4])> {
let mut w = [sin; 5];
for (i, role, n, k) in [
(0, Role::QkvW, C, N),
@@ -64,478 +93,47 @@ impl<'ctx> OriginalGdnPromptDevice<'ctx> {
(4, Role::BetaW, HV, N),
] {
let bytes = if i < 3 { weights.formats[i].matrix_bytes(n, k)? } else { n * k * 2 };
w[i] = buffer(role, weights.matrices[i], bytes)?;
w[i] = binder.buffer(role, weights.matrices[i], bytes)?;
}
let mut a = [sin; 4];
for (i, role, n) in
[(0, Role::ConvW, C * 4 * 4), (1, Role::Dt, HV * 4), (2, Role::SsmA, HV * 4), (3, Role::Gamma, S * 4)]
{
a[i] = buffer(role, weights.aux[i], n)?;
a[i] = binder.buffer(role, weights.aux[i], n)?;
}
drop(buffer);
let mut carved = |role: Role,
phase: Option<(&str, usize)>,
common: Option<(OriginalPromptSpan, usize)>|
-> Result<ffi::BufferHandle> {
let (h, capacity, bytes) = if let Some((name, width)) = phase {
let (h, n) = lease.span(PrefillPhase::Gdn, name)?;
(h, n, t * width)
} else {
let (r, width) = common.ok_or(Error::InvalidQwenShape)?;
let (h, n) = lease.common_span(r)?;
(h, n, t * width)
};
let h = h.checked_subspan(capacity, 0, bytes)?;
h.validate_projection_extent(bytes, 2)?;
workspace.reject_alias(h, bytes)?;
if h.overlaps(bytes, status, STATUS_BYTES) {
return Err(Error::OutputAliasesInput);
}
bindings.bind(role, h, bytes)?;
Ok(h)
};
let mixed = carved(Role::MixedH, None, Some((OriginalPromptSpan::MixedHalf, 5120)))?;
let high = carved(Role::MixedBf, None, Some((OriginalPromptSpan::MixedHigh, 5120)))?;
Ok((w, a))
}
fn admit_carved(&self, binder: &mut Binder<'_, 'ctx>, lease: &OriginalPromptRows<'_, '_, '_>) -> Result<Carved> {
let (mixed, high, lower) = self.admit_mixed(binder, lease)?;
let p = Self::admit_phase(binder, lease)?;
let bo = binder.carved(lease, Role::Bo, Carve::Common(OriginalPromptSpan::Block, N * 4))?;
Ok(Carved { mixed, high, lower, p, bo })
}
#[allow(clippy::type_complexity)]
fn admit_mixed(
&self,
binder: &mut Binder<'_, 'ctx>,
lease: &OriginalPromptRows<'_, '_, '_>,
) -> Result<(ffi::BufferHandle, ffi::BufferHandle, Option<ffi::BufferHandle>)> {
let mixed = binder.carved(lease, Role::MixedH, Carve::Common(OriginalPromptSpan::MixedHalf, 5120))?;
let high = binder.carved(lease, Role::MixedBf, Carve::Common(OriginalPromptSpan::MixedHigh, 5120))?;
let lower = if self.profile == crate::GrNativeProfile::HighAndLow {
Some(carved(Role::MixedBfLo, None, Some((OriginalPromptSpan::MixedLow, 5120)))?)
Some(binder.carved(lease, Role::MixedBfLo, Carve::Common(OriginalPromptSpan::MixedLow, 5120))?)
} else {
None
};
let qkv = carved(Role::Qkv, Some(("qkv", C * 4)), None)?;
let z = carved(Role::Z, Some(("z", ZV * 4)), None)?;
let ab = carved(Role::Ab, Some(("ab", HV * 8)), None)?;
let gate = carved(Role::Gate, Some(("gate", HV * 4)), None)?;
let beta = carved(Role::Beta, Some(("beta", HV * 4)), None)?;
let h = carved(Role::H, Some(("hbuf", C * 4)), None)?;
let y = carved(Role::Y, Some(("y", ZV * 4)), None)?;
let yh = carved(Role::Y16, Some(("y_h", ZV * 2)), None)?;
let bo = carved(Role::Bo, None, Some((OriginalPromptSpan::Block, N * 4)))?;
drop(carved);
// Every owner/alias/shape admission above precedes the first write.
let mut commands = Vec::new();
commands.try_reserve_exact(48).map_err(|_| Error::HostAllocation)?;
let funcs = batch.functions.as_ref().ok_or(Error::ContextPoisoned)?;
let mut push = |kernel: Kernel, geometry: ([u32; 3], [u32; 3]), args: &[ffi::KernelArg]| -> Result<()> {
commands.push(DeviceCommand::Kernel {
function: funcs.get(kernel),
grid: geometry.0,
block: geometry.1,
args: ffi::GdnPrefillArguments::new(args)?,
});
Ok(())
};
push(Kernel::Zero, linear(SLOTS)?, &[ffi::KernelArg::Pointer(status), ffi::KernelArg::U32(SLOTS as u32)])?;
drop(push);
let add_kernel = |commands: &mut Vec<DeviceCommand>,
kernel: Kernel,
geometry: ([u32; 3], [u32; 3]),
args: &[ffi::KernelArg]|
-> Result<()> {
commands.push(DeviceCommand::Kernel {
function: funcs.get(kernel),
grid: geometry.0,
block: geometry.1,
args: ffi::GdnPrefillArguments::new(args)?,
});
Ok(())
};
let scan = |commands: &mut Vec<DeviceCommand>, stage: GdnBatchStage, data: ffi::BufferHandle| -> Result<()> {
let word = status.checked_subspan(STATUS_BYTES, stage.slot() * 4, 4)?;
add_kernel(
commands,
if stage.is_half() { Kernel::FiniteF16 } else { Kernel::FiniteF32 },
linear(stage.elements(t))?,
&[
ffi::KernelArg::Pointer(data),
ffi::KernelArg::Pointer(word),
ffi::KernelArg::U32(stage.elements(t) as u32),
],
)
};
let fast_dequant = crate::prefill_stage::fast_dequant();
let native = |commands: &mut Vec<DeviceCommand>,
format: GdnNativeFormat,
input,
weight,
output,
n: usize,
k: usize|
-> Result<()> {
if fast_dequant {
let total = n * k;
commands.push(DeviceCommand::Stage {
index: crate::prefill_stage::DEQUANT_FIRST
+ match format {
GdnNativeFormat::Q8_0 => 0,
GdnNativeFormat::Q4K => 1,
GdnNativeFormat::Q5K => 2,
GdnNativeFormat::Q6K => 3,
GdnNativeFormat::Iq4Nl => 4,
GdnNativeFormat::Iq4Xs => 5,
},
grid: u32::try_from(total.div_ceil(256)).map_err(|_| Error::InvalidQwenShape)?,
block: 256,
args: KernelArguments::new(vec![
A::Address(weight),
A::I64((k / format.block().0 * format.block().1) as i64),
A::I64(total as i64),
A::I64((k / 32) as i64),
A::Address(scratch),
]),
});
} else {
add_kernel(
commands,
format.kernel(),
linear(n * (k / 32))?,
&[
ffi::KernelArg::Pointer(weight),
ffi::KernelArg::I64((k / format.block().0 * format.block().1) as i64),
ffi::KernelArg::I64(0),
ffi::KernelArg::I64(n as i64),
ffi::KernelArg::I64((k / 32) as i64),
ffi::KernelArg::Pointer(scratch),
],
)?;
}
commands.push(DeviceCommand::Gemm {
bf16: false,
x: input,
w: scratch,
y: output,
n: n as i32,
k: k as i32,
ldy: n as i32,
offset: 0,
beta: 0.,
});
Ok(())
};
scan(&mut commands, GdnBatchStage::MixedH, mixed)?;
// t > 64 with fused guards: the guards of qkv, the convolution output, the normalised q/k, z, the readout, y and its
// FP16 image ride on the kernels that read or write those tensors (same status words)
let fused = crate::prefill_stage::fused_scans() && t > 64;
let word = |stage: GdnBatchStage| status.checked_subspan(STATUS_BYTES, stage.slot() * 4, 4);
native(&mut commands, weights.formats[0], mixed, w[0], qkv, C, N)?;
if !fused {
scan(&mut commands, GdnBatchStage::Qkv, qkv)?;
}
native(&mut commands, weights.formats[1], mixed, w[1], z, ZV, N)?;
if !fused {
scan(&mut commands, GdnBatchStage::Z, z)?;
}
for (i, offset) in [(3, 0), (4, HV)] {
commands.push(DeviceCommand::Gemm {
bf16: true,
x: high,
w: w[i],
y: ab,
n: HV as i32,
k: N as i32,
ldy: 96,
offset,
beta: 0.,
});
if let Some(lo) = lower {
commands.push(DeviceCommand::Gemm {
bf16: true,
x: lo,
w: w[i],
y: ab,
n: HV as i32,
k: N as i32,
ldy: 96,
offset,
beta: 1.,
})
}
}
scan(&mut commands, GdnBatchStage::Ab, ab)?;
add_kernel(
&mut commands,
Kernel::Gates,
linear(t * HV)?,
&[
ffi::KernelArg::Pointer(ab),
ffi::KernelArg::Pointer(a[1]),
ffi::KernelArg::Pointer(a[2]),
ffi::KernelArg::Pointer(gate),
ffi::KernelArg::Pointer(beta),
ffi::KernelArg::I64(t as i64),
],
)?;
scan(&mut commands, GdnBatchStage::Gate, gate)?;
scan(&mut commands, GdnBatchStage::Beta, beta)?;
if t <= 64 {
add_kernel(
&mut commands,
Kernel::Conv,
([80, 1, 1], [128, 1, 1]),
&[
ffi::KernelArg::Pointer(hin),
ffi::KernelArg::Pointer(hout),
ffi::KernelArg::Pointer(qkv),
ffi::KernelArg::Pointer(a[0]),
ffi::KernelArg::Pointer(h),
ffi::KernelArg::I64(t as i64),
],
)?
} else {
if fused {
commands.push(DeviceCommand::Stage {
index: crate::prefill_stage::GDN_CONV_TILED,
grid: 40 * t.div_ceil(64) as u32,
block: 256,
args: KernelArguments::new(vec![
A::Address(hin),
A::Address(qkv),
A::Address(a[0]),
A::Address(h),
A::I64(t as i64),
A::Address(word(GdnBatchStage::Qkv)?),
A::Address(word(GdnBatchStage::ConvH)?),
]),
});
} else {
add_kernel(
&mut commands,
Kernel::ConvTiled,
([80, t.div_ceil(64) as u32, 1], [128, 1, 1]),
&[
ffi::KernelArg::Pointer(hin),
ffi::KernelArg::Pointer(qkv),
ffi::KernelArg::Pointer(a[0]),
ffi::KernelArg::Pointer(h),
ffi::KernelArg::I64(t as i64),
],
)?;
}
add_kernel(
&mut commands,
Kernel::ConvHist,
([80, 1, 1], [128, 1, 1]),
&[
ffi::KernelArg::Pointer(hout),
ffi::KernelArg::Pointer(hin),
ffi::KernelArg::Pointer(qkv),
ffi::KernelArg::I64(t as i64),
],
)?;
}
if !fused {
scan(&mut commands, GdnBatchStage::ConvH, h)?;
}
scan(&mut commands, GdnBatchStage::NextHistory, hout)?;
if fused {
commands.push(DeviceCommand::Stage {
index: crate::prefill_stage::GDN_L2,
grid: (32 * t).div_ceil(2) as u32,
block: 256,
args: KernelArguments::new(vec![
A::Address(h),
A::F32(GDN_BATCH_EPSILON),
A::I64(t as i64),
A::Address(word(GdnBatchStage::Qk)?),
]),
});
} else {
add_kernel(
&mut commands,
Kernel::L2,
([32, t as u32, 1], [128, 1, 1]),
&[ffi::KernelArg::Pointer(h), ffi::KernelArg::F32(GDN_BATCH_EPSILON)],
)?;
scan(&mut commands, GdnBatchStage::Qk, h)?;
}
let witness = status.checked_subspan(STATUS_BYTES, GdnBatchStage::StateSteps.slot() * 4, 4)?;
if crate::prefill_stage::fast_rec() || crate::prefill_stage::gdn_kh_usable(self.context) {
let kh = !crate::prefill_stage::fast_rec();
commands.push(DeviceCommand::Stage {
index: if kh { crate::prefill_stage::GDN_REC_KH } else { crate::prefill_stage::GDN_REC },
grid: if kh { 64 } else { 192 },
block: 128,
args: KernelArguments::new(vec![
A::Address(sin),
A::Address(sout),
A::Address(h),
A::Address(gate),
A::Address(beta),
A::Address(y),
A::I64(t as i64),
A::Address(witness),
]),
});
} else {
add_kernel(
&mut commands,
Kernel::RecColsPipe,
([192, 1, 1], [32, 4, 1]),
&[
ffi::KernelArg::Pointer(sin),
ffi::KernelArg::Pointer(sout),
ffi::KernelArg::Pointer(h),
ffi::KernelArg::Pointer(gate),
ffi::KernelArg::Pointer(beta),
ffi::KernelArg::Pointer(y),
ffi::KernelArg::I64(t as i64),
ffi::KernelArg::Pointer(witness),
],
)?;
}
scan(&mut commands, GdnBatchStage::NextState, sout)?;
if fused {
commands.push(DeviceCommand::Stage {
index: if crate::prefill_stage::gdn_nostore() {
crate::prefill_stage::GDN_OUT_NORM_Y16
} else {
crate::prefill_stage::GDN_OUT_NORM
},
grid: (48 * t).div_ceil(2) as u32,
block: 256,
args: KernelArguments::new(vec![
A::Address(z),
A::Address(a[3]),
A::F32(GDN_BATCH_EPSILON),
A::Address(y),
A::Address(yh),
A::I64(t as i64),
A::Address(word(GdnBatchStage::Z)?),
A::Address(word(GdnBatchStage::Readout)?),
A::Address(word(GdnBatchStage::Y)?),
A::Address(word(GdnBatchStage::Y16)?),
]),
});
} else {
scan(&mut commands, GdnBatchStage::Readout, y)?;
add_kernel(
&mut commands,
Kernel::OutNorm,
([t as u32, 48, 1], [128, 1, 1]),
&[
ffi::KernelArg::Pointer(z),
ffi::KernelArg::Pointer(a[3]),
ffi::KernelArg::F32(GDN_BATCH_EPSILON),
ffi::KernelArg::Pointer(y),
ffi::KernelArg::Pointer(yh),
],
)?;
scan(&mut commands, GdnBatchStage::Y, y)?;
scan(&mut commands, GdnBatchStage::Y16, yh)?;
}
native(&mut commands, weights.formats[2], yh, w[2], bo, N, ZV)?;
scan(&mut commands, GdnBatchStage::Bo, bo)?;
let mut history_bytes = staging(HISTORY)?;
for (x, b) in history.iter().zip(history_bytes.as_chunks_mut::<4>().0) {
b.copy_from_slice(&x.to_le_bytes())
}
let mut flags = staging(STATUS_BYTES)?;
let mut final_history = staging(HISTORY)?;
let mut values = Vec::new();
values.try_reserve_exact(HISTORY_WORDS).map_err(|_| Error::HostAllocation)?;
let context = self.context;
let blas = workspace.blas()?;
let guard = match context.enter() {
Ok(g) => g,
Err(e) => {
self.failed = true;
context.poison();
context.retain_driver();
return Err(e);
}
};
if self.stage.is_none() {
match KernelModule::load(crate::prefill_stage::PTX, crate::prefill_stage::ENTRIES) {
Ok(m) => self.stage = Some(m),
Err(e) => {
let pop = guard.finish();
self.failed = true;
return combine(Err(e), pop).map(|()| unreachable!("stage module"));
}
}
}
let timed = crate::command_profile::enabled();
let started = std::time::Instant::now();
let mut operation =
context.driver.api.copy_from(hin, &history_bytes).and_then(|()| context.driver.api.synchronize());
if timed {
crate::command_profile::add("gdn", 0, "history upload", started.elapsed());
}
for (index, cmd) in commands.iter_mut().enumerate() {
if operation.is_err() {
break;
}
let started = std::time::Instant::now();
let label = match cmd {
DeviceCommand::Kernel { .. } => "kernel",
DeviceCommand::Gemm { .. } => "gemm",
DeviceCommand::Stage { .. } => "stage",
};
operation = match cmd {
DeviceCommand::Kernel { function, grid, block, args } => context.driver.api.launch_gdn_native(
*function,
GdnStream::from_raw(blas.stream()),
*grid,
*block,
args,
),
DeviceCommand::Gemm { bf16, x, w, y, n, k, ldy, offset, beta } => {
blas.gemm_gdn(*bf16, *x, *w, *y, t as i32, *n, *k, *ldy, *offset, beta)
}
DeviceCommand::Stage { index, grid, block, args } => match self.stage.as_ref() {
Some(module) => module.launch(*index, *grid, *block, blas.stream(), args),
None => Err(Error::ContextPoisoned),
},
};
if timed && operation.is_ok() {
operation = blas.synchronize();
crate::command_profile::add("gdn", index + 1, label, started.elapsed());
}
}
let started = std::time::Instant::now();
let sync = blas.synchronize();
if operation.is_ok() && sync.is_ok() {
operation = context
.driver
.api
.copy_to(status, &mut flags)
.and_then(|()| context.driver.api.copy_to(hout, &mut final_history))
}
let all = context.driver.api.synchronize();
if timed {
crate::command_profile::add("gdn", 999, "drain+readback", started.elapsed());
}
let pop = guard.finish();
let result = combine(combine(combine(operation, sync), all), pop);
if result.is_err() {
// A failed drain has no trustworthy completion boundary. Retain the
// command and host buffers before returning, so none can be freed
// while driver work may still reference them.
self.failed = true;
context.poison();
context.retain_driver();
std::mem::forget((commands, history_bytes, flags, final_history));
workspace.mark_failed();
return result.map(|()| unreachable!("failed GDN drain"));
}
let refusal = match decode_statuses(&flags, SLOTS) {
Ok(r) => r,
Err(e) => {
self.failed = true;
context.poison();
context.retain_driver();
return Err(e);
}
};
if let Some(stage) = refusal {
return Err(Error::NonFiniteMmqOutput(match stage {
GdnBatchStage::Bo => "GDN block",
_ => "GDN prompt stage",
}));
}
values.extend(final_history.as_chunks::<4>().0.iter().map(|x| f32::from_le_bytes(*x)));
if values.iter().any(|x| !x.is_finite()) {
return Err(Error::NonFiniteMmqOutput("GDN final history"));
}
Ok((read.from_completed_block(), values.into_boxed_slice()))
Ok((mixed, high, lower))
}
fn admit_phase(binder: &mut Binder<'_, 'ctx>, lease: &OriginalPromptRows<'_, '_, '_>) -> Result<Phase> {
Ok(Phase {
qkv: binder.carved(lease, Role::Qkv, Carve::Phase("qkv", C * 4))?,
z: binder.carved(lease, Role::Z, Carve::Phase("z", ZV * 4))?,
ab: binder.carved(lease, Role::Ab, Carve::Phase("ab", HV * 8))?,
gate: binder.carved(lease, Role::Gate, Carve::Phase("gate", HV * 4))?,
beta: binder.carved(lease, Role::Beta, Carve::Phase("beta", HV * 4))?,
h: binder.carved(lease, Role::H, Carve::Phase("hbuf", C * 4))?,
y: binder.carved(lease, Role::Y, Carve::Phase("y", ZV * 4))?,
yh: binder.carved(lease, Role::Y16, Carve::Phase("y_h", ZV * 2))?,
})
}
}
@@ -0,0 +1,345 @@
//! Command list of `OriginalGdnPromptDevice::produce` (STRA-338): the kernels, GEMMs and prefill-stage launches of one
//! run, recorded in the order of the former single function. Nothing is submitted here.
#[allow(unused_imports)]
use super::*;
/// The commands of one run under construction.
struct Cmds<'f, 'ctx> {
funcs: &'f Functions,
context: &'ctx Context<'ctx>,
hd: Handles,
t: usize,
/// t > 64 with fused guards: the guards of qkv, the convolution output, the normalised q/k, z, the readout, y and
/// its FP16 image ride on the kernels that read or write those tensors (same status words).
fused: bool,
fast_dequant: bool,
list: Vec<DeviceCommand>,
}
/// Index offset of the element-parallel dequantization kernel of a format.
fn dequant_offset(format: GdnNativeFormat) -> usize {
match format {
GdnNativeFormat::Q8_0 => 0,
GdnNativeFormat::Q4K => 1,
GdnNativeFormat::Q5K => 2,
GdnNativeFormat::Q6K => 3,
GdnNativeFormat::Iq4Nl => 4,
GdnNativeFormat::Iq4Xs => 5,
}
}
impl<'ctx> OriginalGdnPromptDevice<'ctx> {
pub(in super::super) fn build_commands(
&self,
hd: &Handles,
formats: [GdnNativeFormat; 3],
t: usize,
) -> Result<Vec<DeviceCommand>> {
let mut list = Vec::new();
list.try_reserve_exact(48).map_err(|_| Error::HostAllocation)?;
let funcs = self.batch.as_ref().ok_or(Error::ContextPoisoned)?.functions.as_ref();
let funcs = funcs.ok_or(Error::ContextPoisoned)?;
let mut c = Cmds::new(funcs, self.context, (*hd, t), list);
c.begin()?;
c.projections(formats)?;
c.gates()?;
c.convolution_l2()?;
c.recurrence()?;
c.output(formats[2])?;
Ok(c.list)
}
}
impl<'f, 'ctx> Cmds<'f, 'ctx> {
fn new(
funcs: &'f Functions,
context: &'ctx Context<'ctx>,
run: (Handles, usize),
list: Vec<DeviceCommand>,
) -> Self {
let (hd, t) = run;
let fused = crate::prefill_stage::fused_scans() && t > 64;
Self { funcs, context, hd, t, fused, fast_dequant: crate::prefill_stage::fast_dequant(), list }
}
fn kernel(&mut self, kernel: Kernel, geometry: ([u32; 3], [u32; 3]), args: &[ffi::KernelArg]) -> Result<()> {
self.list.push(DeviceCommand::Kernel {
function: self.funcs.get(kernel),
grid: geometry.0,
block: geometry.1,
args: ffi::GdnPrefillArguments::new(args)?,
});
Ok(())
}
/// A `prefill_stage` kernel (1-D grid).
fn stage(&mut self, index: usize, grid: u32, block: u32, args: Vec<A>) {
self.list.push(DeviceCommand::Stage { index, grid, block, args: KernelArguments::new(args) });
}
fn word(&self, stage: GdnBatchStage) -> Result<ffi::BufferHandle> {
self.hd.status.checked_subspan(STATUS_BYTES, stage.slot() * 4, 4)
}
/// The finite guard of `data` into the status word of `stage`.
fn scan(&mut self, stage: GdnBatchStage, data: ffi::BufferHandle) -> Result<()> {
let word = self.word(stage)?;
let kernel = if stage.is_half() { Kernel::FiniteF16 } else { Kernel::FiniteF32 };
let count = stage.elements(self.t);
let args = [ffi::KernelArg::Pointer(data), ffi::KernelArg::Pointer(word), ffi::KernelArg::U32(count as u32)];
self.kernel(kernel, linear(count)?, &args)
}
/// Dequantizes `weight` into the scratch and multiplies it with `input`.
fn native(
&mut self,
format: GdnNativeFormat,
input: ffi::BufferHandle,
weight: ffi::BufferHandle,
output: ffi::BufferHandle,
shape: (usize, usize),
) -> Result<()> {
let (n, k) = shape;
if self.fast_dequant {
self.dequant_stage(format, weight, shape)?;
} else {
self.dequant_kernel(format, weight, shape)?;
}
let (x, w, y, n, k) = (input, self.hd.scratch, output, n as i32, k as i32);
self.list.push(DeviceCommand::Gemm { bf16: false, x, w, y, n, k, ldy: n, offset: 0, beta: 0. });
Ok(())
}
fn dequant_stage(
&mut self,
format: GdnNativeFormat,
weight: ffi::BufferHandle,
shape: (usize, usize),
) -> Result<()> {
let (n, k) = shape;
let total = n * k;
let index = crate::prefill_stage::DEQUANT_FIRST + dequant_offset(format);
let grid = u32::try_from(total.div_ceil(256)).map_err(|_| Error::InvalidQwenShape)?;
let args = vec![
A::Address(weight),
A::I64((k / format.block().0 * format.block().1) as i64),
A::I64(total as i64),
A::I64((k / 32) as i64),
A::Address(self.hd.scratch),
];
self.stage(index, grid, 256, args);
Ok(())
}
fn dequant_kernel(
&mut self,
format: GdnNativeFormat,
weight: ffi::BufferHandle,
shape: (usize, usize),
) -> Result<()> {
let (n, k) = shape;
let args = [
ffi::KernelArg::Pointer(weight),
ffi::KernelArg::I64((k / format.block().0 * format.block().1) as i64),
ffi::KernelArg::I64(0),
ffi::KernelArg::I64(n as i64),
ffi::KernelArg::I64((k / 32) as i64),
ffi::KernelArg::Pointer(self.hd.scratch),
];
self.kernel(format.kernel(), linear(n * (k / 32))?, &args)
}
fn begin(&mut self) -> Result<()> {
let status = ffi::KernelArg::Pointer(self.hd.status);
self.kernel(Kernel::Zero, linear(SLOTS)?, &[status, ffi::KernelArg::U32(SLOTS as u32)])?;
self.scan(GdnBatchStage::MixedH, self.hd.c.mixed)
}
fn projections(&mut self, formats: [GdnNativeFormat; 3]) -> Result<()> {
let (hd, fused) = (self.hd, self.fused);
self.native(formats[0], hd.c.mixed, hd.w[0], hd.c.p.qkv, (C, N))?;
if !fused {
self.scan(GdnBatchStage::Qkv, hd.c.p.qkv)?;
}
self.native(formats[1], hd.c.mixed, hd.w[1], hd.c.p.z, (ZV, N))?;
if !fused {
self.scan(GdnBatchStage::Z, hd.c.p.z)?;
}
Ok(())
}
/// The alpha and beta GEMMs (high, and low when the profile has it), their gates and guards.
fn gates(&mut self) -> Result<()> {
let hd = self.hd;
for (i, offset) in [(3, 0), (4, HV)] {
self.gemm_ab(hd.c.high, hd.w[i], offset, 0.);
if let Some(lo) = hd.c.lower {
self.gemm_ab(lo, hd.w[i], offset, 1.);
}
}
self.scan(GdnBatchStage::Ab, hd.c.p.ab)?;
let args = [
ffi::KernelArg::Pointer(hd.c.p.ab),
ffi::KernelArg::Pointer(hd.a[1]),
ffi::KernelArg::Pointer(hd.a[2]),
ffi::KernelArg::Pointer(hd.c.p.gate),
ffi::KernelArg::Pointer(hd.c.p.beta),
ffi::KernelArg::I64(self.t as i64),
];
self.kernel(Kernel::Gates, linear(self.t * HV)?, &args)?;
self.scan(GdnBatchStage::Gate, hd.c.p.gate)?;
self.scan(GdnBatchStage::Beta, hd.c.p.beta)
}
fn gemm_ab(&mut self, x: ffi::BufferHandle, w: ffi::BufferHandle, offset: usize, beta: f32) {
let (n, k, y) = (HV as i32, N as i32, self.hd.c.p.ab);
self.list.push(DeviceCommand::Gemm { bf16: true, x, w, y, n, k, ldy: 96, offset, beta });
}
fn convolution_l2(&mut self) -> Result<()> {
self.convolution()?;
self.l2()
}
fn convolution(&mut self) -> Result<()> {
let (hd, t) = (self.hd, self.t);
let (qkv, h, geometry) = (hd.c.p.qkv, hd.c.p.h, ([80, 1, 1], [128, 1, 1]));
if t <= 64 {
let args = [
ffi::KernelArg::Pointer(hd.hin),
ffi::KernelArg::Pointer(hd.hout),
ffi::KernelArg::Pointer(qkv),
ffi::KernelArg::Pointer(hd.a[0]),
ffi::KernelArg::Pointer(h),
ffi::KernelArg::I64(t as i64),
];
self.kernel(Kernel::Conv, geometry, &args)?;
} else {
self.conv_tiled()?;
let args = [
ffi::KernelArg::Pointer(hd.hout),
ffi::KernelArg::Pointer(hd.hin),
ffi::KernelArg::Pointer(qkv),
ffi::KernelArg::I64(t as i64),
];
self.kernel(Kernel::ConvHist, geometry, &args)?;
}
if !self.fused {
self.scan(GdnBatchStage::ConvH, h)?;
}
self.scan(GdnBatchStage::NextHistory, hd.hout)
}
fn conv_tiled(&mut self) -> Result<()> {
let (hd, t) = (self.hd, self.t);
if self.fused {
let args = vec![
A::Address(hd.hin),
A::Address(hd.c.p.qkv),
A::Address(hd.a[0]),
A::Address(hd.c.p.h),
A::I64(t as i64),
A::Address(self.word(GdnBatchStage::Qkv)?),
A::Address(self.word(GdnBatchStage::ConvH)?),
];
self.stage(crate::prefill_stage::GDN_CONV_TILED, 40 * t.div_ceil(64) as u32, 256, args);
return Ok(());
}
let args = [
ffi::KernelArg::Pointer(hd.hin),
ffi::KernelArg::Pointer(hd.c.p.qkv),
ffi::KernelArg::Pointer(hd.a[0]),
ffi::KernelArg::Pointer(hd.c.p.h),
ffi::KernelArg::I64(t as i64),
];
self.kernel(Kernel::ConvTiled, ([80, t.div_ceil(64) as u32, 1], [128, 1, 1]), &args)
}
fn l2(&mut self) -> Result<()> {
let (h, t) = (self.hd.c.p.h, self.t);
if self.fused {
let word = self.word(GdnBatchStage::Qk)?;
let args = vec![A::Address(h), A::F32(GDN_BATCH_EPSILON), A::I64(t as i64), A::Address(word)];
self.stage(crate::prefill_stage::GDN_L2, (32 * t).div_ceil(2) as u32, 256, args);
return Ok(());
}
let args = [ffi::KernelArg::Pointer(h), ffi::KernelArg::F32(GDN_BATCH_EPSILON)];
self.kernel(Kernel::L2, ([32, t as u32, 1], [128, 1, 1]), &args)?;
self.scan(GdnBatchStage::Qk, h)
}
/// The state recurrence: the staged kernel when requested or usable, the original pipe kernel otherwise.
fn recurrence(&mut self) -> Result<()> {
let witness = self.word(GdnBatchStage::StateSteps)?;
if crate::prefill_stage::fast_rec() || crate::prefill_stage::gdn_kh_usable(self.context) {
self.recurrence_staged(witness);
} else {
self.recurrence_pipe(witness)?;
}
self.scan(GdnBatchStage::NextState, self.hd.sout)
}
fn recurrence_staged(&mut self, witness: ffi::BufferHandle) {
let kh = !crate::prefill_stage::fast_rec();
let index = if kh { crate::prefill_stage::GDN_REC_KH } else { crate::prefill_stage::GDN_REC };
let (p, sin, sout) = (self.hd.c.p, self.hd.sin, self.hd.sout);
let args = vec![
A::Address(sin),
A::Address(sout),
A::Address(p.h),
A::Address(p.gate),
A::Address(p.beta),
A::Address(p.y),
A::I64(self.t as i64),
A::Address(witness),
];
self.stage(index, if kh { 64 } else { 192 }, 128, args);
}
fn recurrence_pipe(&mut self, witness: ffi::BufferHandle) -> Result<()> {
let (p, sin, sout) = (self.hd.c.p, self.hd.sin, self.hd.sout);
let args = [
ffi::KernelArg::Pointer(sin),
ffi::KernelArg::Pointer(sout),
ffi::KernelArg::Pointer(p.h),
ffi::KernelArg::Pointer(p.gate),
ffi::KernelArg::Pointer(p.beta),
ffi::KernelArg::Pointer(p.y),
ffi::KernelArg::I64(self.t as i64),
ffi::KernelArg::Pointer(witness),
];
self.kernel(Kernel::RecColsPipe, ([192, 1, 1], [32, 4, 1]), &args)
}
/// The output norm and the projection of the block output.
fn output(&mut self, format: GdnNativeFormat) -> Result<()> {
let hd = self.hd;
if self.fused {
self.out_norm_fused()?;
} else {
self.out_norm()?;
}
self.native(format, hd.c.p.yh, hd.w[2], hd.c.bo, (N, ZV))?;
self.scan(GdnBatchStage::Bo, hd.c.bo)
}
fn out_norm_fused(&mut self) -> Result<()> {
let (hd, t) = (self.hd, self.t);
let index = if crate::prefill_stage::gdn_nostore() {
crate::prefill_stage::GDN_OUT_NORM_Y16
} else {
crate::prefill_stage::GDN_OUT_NORM
};
let (p, gamma) = (hd.c.p, hd.a[3]);
let args = vec![
A::Address(p.z),
A::Address(gamma),
A::F32(GDN_BATCH_EPSILON),
A::Address(p.y),
A::Address(p.yh),
A::I64(t as i64),
A::Address(self.word(GdnBatchStage::Z)?),
A::Address(self.word(GdnBatchStage::Readout)?),
A::Address(self.word(GdnBatchStage::Y)?),
A::Address(self.word(GdnBatchStage::Y16)?),
];
self.stage(index, (48 * t).div_ceil(2) as u32, 256, args);
Ok(())
}
fn out_norm(&mut self) -> Result<()> {
let (hd, t) = (self.hd, self.t);
let p = hd.c.p;
self.scan(GdnBatchStage::Readout, p.y)?;
let args = [
ffi::KernelArg::Pointer(p.z),
ffi::KernelArg::Pointer(hd.a[3]),
ffi::KernelArg::F32(GDN_BATCH_EPSILON),
ffi::KernelArg::Pointer(p.y),
ffi::KernelArg::Pointer(p.yh),
];
self.kernel(Kernel::OutNorm, ([t as u32, 48, 1], [128, 1, 1]), &args)?;
self.scan(GdnBatchStage::Y, p.y)?;
self.scan(GdnBatchStage::Y16, p.yh)
}
}
@@ -0,0 +1,199 @@
//! Drain of `OriginalGdnPromptDevice::produce` (STRA-338): submits the command list on the batch stream, reads the
//! status words and the final history back, and decides whether the run was clean. A failed drain retains the command
//! and host buffers, because driver work may still reference them.
#[allow(unused_imports)]
use super::*;
use crate::CurrentGuard;
/// Host buffers of one run: the history upload, the status words and final history read back, and the decoded history.
struct Host {
history_bytes: Vec<u8>,
flags: Vec<u8>,
final_history: Vec<u8>,
values: Vec<f32>,
}
impl Host {
fn new(history: &[f32]) -> Result<Self> {
let mut history_bytes = staging(HISTORY)?;
for (x, b) in history.iter().zip(history_bytes.as_chunks_mut::<4>().0) {
b.copy_from_slice(&x.to_le_bytes())
}
let flags = staging(STATUS_BYTES)?;
let final_history = staging(HISTORY)?;
let mut values = Vec::new();
values.try_reserve_exact(HISTORY_WORDS).map_err(|_| Error::HostAllocation)?;
Ok(Self { history_bytes, flags, final_history, values })
}
/// Retains the command and host staging buffers of a failed drain; the decoded values are released normally.
fn retain(self, commands: Vec<DeviceCommand>) {
let Self { history_bytes, flags, final_history, values } = self;
std::mem::forget((commands, history_bytes, flags, final_history));
drop(values);
}
}
fn command_label(cmd: &DeviceCommand) -> &'static str {
match cmd {
DeviceCommand::Kernel { .. } => "kernel",
DeviceCommand::Gemm { .. } => "gemm",
DeviceCommand::Stage { .. } => "stage",
}
}
impl<'ctx> OriginalGdnPromptDevice<'ctx> {
/// Runs the commands and returns the final history, or the refusal of the first stage that was not finite.
pub(in super::super) fn drain(
&mut self,
workspace: &mut NativeBatchWorkspace<'ctx>,
commands: Vec<DeviceCommand>,
history: &[f32],
run: (&Handles, usize),
) -> Result<Box<[f32]>> {
let host = Host::new(history)?;
let host = self.execute(workspace, (commands, host), run)?;
self.decode_run(host)
}
fn fail_context(&mut self) {
self.failed = true;
self.context.poison();
self.context.retain_driver();
}
fn execute(
&mut self,
workspace: &mut NativeBatchWorkspace<'ctx>,
owned: (Vec<DeviceCommand>, Host),
run: (&Handles, usize),
) -> Result<Host> {
let ((mut commands, mut host), (hd, t)) = (owned, run);
let blas = workspace.blas()?;
let guard = match self.context.enter() {
Ok(g) => g,
Err(e) => {
self.fail_context();
return Err(e);
}
};
let guard = self.ensure_stage(guard)?;
let outcome = self.stream_run(blas, (&mut commands, &mut host), (hd, t));
let pop = guard.finish();
let result = combine(outcome, pop);
if result.is_err() {
// A failed drain has no trustworthy completion boundary. Retain the
// command and host buffers before returning, so none can be freed
// while driver work may still reference them.
self.fail_context();
host.retain(commands);
workspace.mark_failed();
return result.map(|()| unreachable!("failed GDN drain"));
}
Ok(host)
}
/// Submits the commands, drains the stream and reads the status words and final history back.
fn stream_run(
&self,
blas: &crate::ple_batch_ffi::Blas,
buffers: (&mut [DeviceCommand], &mut Host),
run: (&Handles, usize),
) -> Result<()> {
let ((commands, host), (hd, t)) = (buffers, run);
let timed = crate::command_profile::enabled();
let mut operation = self.submit(blas, commands, (&host.history_bytes, hd.hin, t), timed);
let started = std::time::Instant::now();
let sync = blas.synchronize();
if operation.is_ok() && sync.is_ok() {
operation = self.read_back(hd, host);
}
let all = self.context.driver.api.synchronize();
if timed {
crate::command_profile::add("gdn", 999, "drain+readback", started.elapsed());
}
combine(combine(operation, sync), all)
}
fn ensure_stage(&mut self, guard: CurrentGuard<'ctx, 'ctx>) -> Result<CurrentGuard<'ctx, 'ctx>> {
if self.stage.is_none() {
match KernelModule::load(crate::prefill_stage::PTX, crate::prefill_stage::ENTRIES) {
Ok(m) => self.stage = Some(m),
Err(e) => {
let pop = guard.finish();
self.failed = true;
return combine(Err(e), pop).map(|()| unreachable!("stage module"));
}
}
}
Ok(guard)
}
/// Uploads the history and launches the commands in order; stops at the first failure.
fn submit(
&self,
blas: &crate::ple_batch_ffi::Blas,
commands: &mut [DeviceCommand],
upload: (&[u8], ffi::BufferHandle, usize),
timed: bool,
) -> Result<()> {
let (bytes, hin, t) = upload;
let api = &self.context.driver.api;
let started = std::time::Instant::now();
let mut operation = api.copy_from(hin, bytes).and_then(|()| api.synchronize());
if timed {
crate::command_profile::add("gdn", 0, "history upload", started.elapsed());
}
for (index, cmd) in commands.iter_mut().enumerate() {
if operation.is_err() {
break;
}
let started = std::time::Instant::now();
let label = command_label(cmd);
operation = self.launch(blas, cmd, t);
if timed && operation.is_ok() {
operation = blas.synchronize();
crate::command_profile::add("gdn", index + 1, label, started.elapsed());
}
}
operation
}
fn launch(&self, blas: &crate::ple_batch_ffi::Blas, cmd: &mut DeviceCommand, t: usize) -> Result<()> {
match cmd {
DeviceCommand::Kernel { function, grid, block, args } => self.context.driver.api.launch_gdn_native(
*function,
GdnStream::from_raw(blas.stream()),
*grid,
*block,
args,
),
DeviceCommand::Gemm { bf16, x, w, y, n, k, ldy, offset, beta } => {
blas.gemm_gdn(*bf16, *x, *w, *y, t as i32, *n, *k, *ldy, *offset, beta)
}
DeviceCommand::Stage { index, grid, block, args } => match self.stage.as_ref() {
Some(module) => module.launch(*index, *grid, *block, blas.stream(), args),
None => Err(Error::ContextPoisoned),
},
}
}
fn read_back(&self, hd: &Handles, host: &mut Host) -> Result<()> {
let api = &self.context.driver.api;
api.copy_to(hd.status, &mut host.flags).and_then(|()| api.copy_to(hd.hout, &mut host.final_history))
}
/// The first refused stage, or the final history when every guard stayed clean.
fn decode_run(&mut self, mut host: Host) -> Result<Box<[f32]>> {
let refusal = match decode_statuses(&host.flags, SLOTS) {
Ok(r) => r,
Err(e) => {
self.fail_context();
return Err(e);
}
};
if let Some(stage) = refusal {
return Err(Error::NonFiniteMmqOutput(match stage {
GdnBatchStage::Bo => "GDN block",
_ => "GDN prompt stage",
}));
}
host.values.extend(host.final_history.as_chunks::<4>().0.iter().map(|x| f32::from_le_bytes(*x)));
if host.values.iter().any(|x| !x.is_finite()) {
return Err(Error::NonFiniteMmqOutput("GDN final history"));
}
Ok(host.values.into_boxed_slice())
}
}
@@ -0,0 +1,107 @@
//! Buffers of `OriginalGdnPromptDevice::produce` (STRA-338): the admitted handles of a run and the binder that admits
//! them (owner, extent, alias and role checks) in the order of the former single function.
#[allow(unused_imports)]
use super::*;
use crate::OriginalPromptRows;
/// How a span is carved out of the prompt arena: a phase span of the GDN layout or a common span, with its row width.
pub(in super::super) enum Carve {
Phase(&'static str, usize),
Common(OriginalPromptSpan, usize),
}
/// The phase buffers of the GDN prompt kernels.
#[derive(Clone, Copy)]
pub(in super::super) struct Phase {
pub(in super::super) qkv: ffi::BufferHandle,
pub(in super::super) z: ffi::BufferHandle,
pub(in super::super) ab: ffi::BufferHandle,
pub(in super::super) gate: ffi::BufferHandle,
pub(in super::super) beta: ffi::BufferHandle,
pub(in super::super) h: ffi::BufferHandle,
pub(in super::super) y: ffi::BufferHandle,
pub(in super::super) yh: ffi::BufferHandle,
}
/// The spans carved out of the arena.
#[derive(Clone, Copy)]
pub(in super::super) struct Carved {
pub(in super::super) mixed: ffi::BufferHandle,
pub(in super::super) high: ffi::BufferHandle,
pub(in super::super) lower: Option<ffi::BufferHandle>,
pub(in super::super) p: Phase,
pub(in super::super) bo: ffi::BufferHandle,
}
/// Every buffer one run reads or writes, after admission.
#[derive(Clone, Copy)]
pub(in super::super) struct Handles {
pub(in super::super) status: ffi::BufferHandle,
pub(in super::super) scratch: ffi::BufferHandle,
pub(in super::super) hin: ffi::BufferHandle,
pub(in super::super) hout: ffi::BufferHandle,
pub(in super::super) sin: ffi::BufferHandle,
pub(in super::super) sout: ffi::BufferHandle,
pub(in super::super) w: [ffi::BufferHandle; 5],
pub(in super::super) a: [ffi::BufferHandle; 4],
pub(in super::super) c: Carved,
}
/// Admits buffers of one run: each is bound to a role and may not overlap the status words or another role.
pub(in super::super) struct Binder<'a, 'ctx> {
pub(in super::super) context: &'ctx Context<'ctx>,
pub(in super::super) workspace: &'a NativeBatchWorkspace<'ctx>,
pub(in super::super) status: ffi::BufferHandle,
pub(in super::super) bindings: Bindings,
pub(in super::super) t: usize,
}
impl Binder<'_, '_> {
pub(in super::super) fn buffer(
&mut self,
role: Role,
b: &DeviceBuffer<'_>,
bytes: usize,
) -> Result<ffi::BufferHandle> {
if !std::ptr::eq(b.context, self.context) {
return Err(Error::ContextMismatch);
}
if b.len() != bytes {
return Err(Error::InvalidQwenShape);
}
let h = b.handle.ok_or(Error::ContextPoisoned)?;
h.validate_projection_extent(bytes, 4)?;
self.workspace.reject_alias(h, bytes)?;
if h.overlaps(bytes, self.status, STATUS_BYTES) {
return Err(Error::OutputAliasesInput);
}
self.bindings.bind(role, h, bytes)?;
Ok(h)
}
pub(in super::super) fn carved(
&mut self,
lease: &OriginalPromptRows<'_, '_, '_>,
role: Role,
carve: Carve,
) -> Result<ffi::BufferHandle> {
let (h, capacity, bytes) = match carve {
Carve::Phase(name, width) => {
let (h, n) = lease.span(PrefillPhase::Gdn, name)?;
(h, n, self.t * width)
}
Carve::Common(span, width) => {
let (h, n) = lease.common_span(span)?;
(h, n, self.t * width)
}
};
let h = h.checked_subspan(capacity, 0, bytes)?;
h.validate_projection_extent(bytes, 2)?;
self.workspace.reject_alias(h, bytes)?;
if h.overlaps(bytes, self.status, STATUS_BYTES) {
return Err(Error::OutputAliasesInput);
}
self.bindings.bind(role, h, bytes)?;
Ok(h)
}
}
+29 -310
View File
@@ -28,50 +28,32 @@ use std::{
rc::Rc,
};
// STRA-338: the plain `pub use` re-exports of the crate root live in `root_exports.rs`.
mod root_exports;
pub use root_exports::*;
pub mod compute_drain;
mod deferred_status;
mod device_slab;
#[allow(unsafe_code)]
mod ffi;
pub mod vram_ledger;
pub use device_slab::{DeviceSlice, SlabAllocator, SlabPolicy, SlabStats};
mod deferred_status;
pub mod nvml;
#[allow(unsafe_code)]
mod original_gpu_schedule;
pub use original_gpu_schedule::{
OriginalCapture, OriginalCapturePolicy, OriginalEventKind, OriginalGpuEvent, OriginalGpuGraph, OriginalGpuStream,
OriginalGraphFlight, OriginalGraphKey, OriginalGraphRegistry, OriginalGraphResources, OriginalStreamKind,
OriginalWait,
};
mod original_expert_cache;
mod original_expert_slots;
pub use original_expert_cache::OriginalExpertCache;
mod original_moe_prompt_device;
pub use original_moe_prompt_device::{OriginalMoePromptDevice, OriginalMoePromptLayer};
mod original_prefill_arena;
pub use original_prefill_arena::{OriginalPrefillArena, OriginalPromptLeaseIdentity, OriginalPromptRows};
mod original_prefill_layout;
pub use original_prefill_layout::{
OriginalPrefillLayout, PrefillKvStage, PrefillLayoutOptions, PrefillPhase, PrefillSpan,
};
mod head_greedy;
pub use head_greedy::{HEAD_GREEDY_WORKSPACE_BYTES, HeadGreedySelection, HeadGreedyWorkspace};
mod gdn_state_finite_guard;
pub use gdn_state_finite_guard::GdnStateFiniteGuard;
mod routed_group_workspace;
mod routed_stage_finite_guard;
pub use routed_group_workspace::RoutedColumnsLoan;
pub use routed_group_workspace::RoutedGroupWorkspace;
pub use routed_stage_finite_guard::{RoutedFiniteStage, RoutedStageFiniteGuard};
mod gr_read_guard;
mod head_greedy;
mod mmq;
mod mmq_native;
pub mod nvml;
mod original_expert_cache;
mod original_expert_slots;
#[allow(unsafe_code)]
mod original_gpu_schedule;
mod original_moe_prompt_device;
mod original_prefill_arena;
mod original_prefill_layout;
mod routed_group_workspace;
mod routed_stage_finite_guard;
pub mod vram_ledger;
pub(crate) use mmq::resident::original_group::prefetch_point;
pub use mmq::resident::original_group::{
OriginalMmqCopySchedule, OriginalMmqLayer, OriginalMmqOutput, original_mmq_group_bank_bytes,
};
pub use mmq::resident::{FiniteMmqOutput, MmqChunkActivation, MmqGroupActivation, MmqHidden, MmqWorkspace};
pub use mmq::{MmqExperiment, MmqFormat, MmqProfile, MmqWeights};
use mmq_native::NativeWeights;
mod moe_group_down_columns;
mod moe_group_projection;
@@ -79,47 +61,17 @@ mod mtp_dense_kv;
mod original_mtp_actor;
mod original_mtp_bank;
mod original_mtp_coupled;
mod original_mtp_loader;
mod original_mtp_rt;
pub use original_mtp_actor::{ActorRefusal as OriginalMtpActorRefusal, DraftSettings as OriginalMtpDraftSettings};
#[cfg(all(feature = "cuda-driver", any(target_os = "linux", target_os = "windows"), target_pointer_width = "64"))]
pub use original_mtp_actor::{OriginalMtpActor, OriginalMtpLoadEvidence, OriginalMtpLoadMeter};
pub use original_mtp_bank::{
OriginalMtpLoadFailure, OriginalMtpRtBank, OriginalMtpRtTensor, OriginalMtpTensorKind,
original_mtp_draft_vocab_bytes,
};
pub use original_mtp_loader::{
CoupledPlan as OriginalMtpCoupledPlan, KvFormat as OriginalMtpKvFormat, KvMode as OriginalMtpKvMode,
KvPlan as OriginalMtpKvPlan, LoaderError as OriginalMtpPlanError, OriginalMtpCapture, OriginalMtpKvStartup,
OriginalMtpLoadPlan, WeightBankPlan as OriginalMtpWeightBankPlan, original_mtp_bind_reserve,
};
#[cfg(all(feature = "cuda-driver", any(target_os = "linux", target_os = "windows"), target_pointer_width = "64"))]
mod original_mtp_draft_head;
mod original_mtp_draft_vocab;
#[cfg(all(feature = "cuda-driver", any(target_os = "linux", target_os = "windows"), target_pointer_width = "64"))]
pub use original_mtp_draft_head::OriginalMtpDraftHead;
mod original_mtp_loader;
mod original_mtp_rt;
mod original_session_state;
pub use original_session_state::{
OriginalGeometryFacts, OriginalHostKv, OriginalIdxKind, OriginalKvLayer, OriginalKvPool, OriginalQsaFacts,
OriginalRegion, OriginalSessionBytes, OriginalSessionControl, OriginalSessionFacts,
};
mod qwen_dispatch;
pub use qwen_dispatch::gr_batch_read::{GrMicroValues, GrMicrobatchRead};
mod qsa_selected_kv;
mod serving_context;
pub use mtp_dense_kv::MTP_ORIGINAL_WINDOW;
pub use mtp_dense_kv::MtpDenseKvRing;
pub use mtp_dense_kv::{
CompletedMtpAttention, CompletedMtpKvReplay, MtpInt8OwnerId, MtpInt8Snapshot, MtpOriginalInt8, MtpOriginalMixed,
MtpOriginalQuery,
};
pub use qsa_selected_kv::{QsaSelectedKvProducts, QsaSelectedKvWorkspace};
pub use serving_context::{
KV_RESIDENT_DEFAULT_CELLS, KV_RESIDENT_MIN_CELLS, MAX_CONTEXT_CELLS, ServingContext, TRAINED_CONTEXT_CELLS,
configure_kv_resident, configure_serving_context, kv_resident_cells, serving_context,
};
mod qwen_dispatch;
#[allow(unsafe_code)]
mod qwen_ffi;
mod serving_context;
/// Per-command timing of the batched prompt producers (bring-up profiling only).
pub mod command_profile;
@@ -186,9 +138,6 @@ mod family_tests;
#[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64", feature = "cuda-driver"))]
pub mod q6_layer_preview;
#[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64", feature = "cuda-driver"))]
pub use qwen_dispatch::batch_gr_preview::GrBatchModule;
#[cfg(all(
test,
feature = "cuda-driver",
@@ -198,76 +147,27 @@ pub use qwen_dispatch::batch_gr_preview::GrBatchModule;
#[path = "grouped_down_columns_gpu.rs"]
mod grouped_down_columns_gpu;
pub use qwen_dispatch::qwen_shared_tail::{
SharedDownKind, SharedExpertWeights, SharedExpertWorkspace, SharedGuKind, SharedTailCompletion, SharedTailRefusal,
};
// Additive closed MTP input transport owners.
pub use qwen_dispatch::gdn_closed_queue::{GdnQueueStage, GdnRowCompletion, GdnRowPrefix, GdnRowQueue};
#[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64", feature = "cuda-driver"))]
pub use qwen_dispatch::gdn_fused_t1::{
GDN_FUSED_T1_PERSISTENT_BYTES, GDN_FUSED_T1_STATE_BYTES, GdnFusedCompletion, GdnFusedPrefix, GdnFusedStage,
GdnFusedT1,
};
#[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64", feature = "cuda-driver"))]
pub use qwen_dispatch::gdn_native_batch::{
GDN_BATCH_EPSILON, GDN_BATCH_MAX_TOKENS, GdnBatchCompletion, GdnBatchPrefix, GdnBatchStage, GdnGemm,
GdnNativeFormat, GdnPrefillBatch, GdnStream, GemmShape, OriginalGdnPromptDevice, OriginalGdnPromptWeights,
};
#[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64", feature = "cuda-driver"))]
pub use qwen_dispatch::moe_prefill_batch::{
MOE_BATCH_MAX_TOKENS, MOE_BATCH_SCRATCH_BYTES, MoeBatchCompletion, MoeBatchPrefix, MoeBatchStage, MoePrefillBatch,
MoeRouteBatch,
};
pub use qwen_dispatch::mtp_input_workspace::{MtpInputCompletion, MtpInputPrefix, MtpInputRefusal, MtpInputWorkspace};
#[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64", feature = "cuda-driver"))]
pub use qwen_dispatch::gr_batch_inject_workspace::{
GR_BATCH_INJECT_WORKSPACE_BYTES, GrBatchInjectShape, GrBatchInjectWorkspace,
};
// Separately selected asynchronous owned-copy adapter; original APIs unchanged.
#[allow(unsafe_code)]
mod api;
mod async_owned_copy;
pub use async_owned_copy::{CompletedOwnedCopy, MAX_ASYNC_COPY_PAIRS, OwnedCopyPairs, OwnedCopyPoll, PendingOwnedCopy};
// Explicit experimental resident pipeline; original entry bodies remain unchanged.
mod routed_resident_queue;
pub use routed_resident_queue::{
RoutedResidentCompletion, RoutedResidentQueue, RoutedResidentRefusal, RoutedResidentWeights,
};
pub use qwen_dispatch::ple_closed_queue::{
PleClosedCompletion, PleClosedParts, PleClosedQueue, PleClosedRefusal, PleClosedWeights,
};
mod mapped_expert_bank;
pub use mapped_expert_bank::{
MappedExpertBank, MappedExpertCopyCompletion, MappedExpertCopyScratch, PendingMappedExpertCopy,
};
pub use qwen_dispatch::gr_native_batch::{GrNativeBatch, GrNativeProfile};
// Explicit Original prefill transport; no default selection or public raw spans.
#[allow(unsafe_code)]
pub(crate) mod ple_batch_ffi;
mod ple_batch_queue;
pub use ple_batch_queue::{PLE_BATCH_QUEUE_BYTES, PleBatchCompletion, PleBatchQueue, PleBatchRow, PleBf16Mode};
mod native_batch_workspace;
pub use native_batch_workspace::{NATIVE_BATCH_WORKSPACE_BYTES, NativeBatchWorkspace};
#[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))]
mod gdn_batch_gemm;
#[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))]
pub use gdn_batch_gemm::NativeGdnGemm;
mod native_batch_workspace;
#[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))]
mod qsa_native_batch;
#[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))]
pub use qsa_native_batch::{
QSA_NATIVE_BATCH_BYTES, QsaNativeBatchWorkspace, QsaNativeKind, QsaNativePacking, QsaNativeProjections,
};
// Literal Original QSA prompt index assets share the admitted native stream.
#[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))]
@@ -275,15 +175,15 @@ pub use qsa_native_batch::{
mod qsa_index_ffi;
#[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))]
mod qsa_prompt_index;
#[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))]
pub use qsa_prompt_index::{
OriginalQsaDeviceSelection, OriginalQsaPromptDevice, OriginalQsaPromptWeights, QSA_PROMPT_INDEX_BYTES,
QsaPromptIndexPrefix, QsaPromptIndexState, QsaPromptIndexWorkspace, QsaPromptSelection,
};
// Genuine page4 INT8 owners and literal Original prompt/decode programs.
#[cfg(all(test, any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))]
mod kv_stream_gpu;
#[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))]
mod moe_prompt_packet_copy;
#[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))]
mod qsa_native_decode;
mod qsa_native_gate;
#[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))]
mod qsa_prompt_attention;
#[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))]
@@ -296,181 +196,47 @@ mod qsa_prompt_host_ffi;
mod qsa_prompt_kv;
#[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))]
mod qsa_prompt_resolver;
pub use qsa_prompt_resolver::KvStreamCounters;
#[cfg(all(test, any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))]
mod kv_stream_gpu;
#[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))]
pub use qsa_native_decode::{QSA_NATIVE_DECODE_BYTES, QsaNativeDecode, QsaNativeDecodeCompletion};
#[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))]
pub use qsa_prompt_attention::{
QSA_PROMPT_ATTENTION_BYTES, QsaAttentionInputs, QsaPromptAttention, QsaPromptAttentionCompletion,
};
#[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))]
pub use qsa_prompt_kv::{
CompletedQsaKvAppend, QSA_PROMPT_MAPPED_HOST_BYTES, QSA_PROMPT_MAX_SNAPSHOT_METADATA_BYTES,
QSA_PROMPT_MAX_SNAPSHOT_PAYLOAD_BYTES, QSA_PROMPT_RESIDENT_BYTES, QSA_PROMPT_STAGE_BYTES, QsaKvInputs,
QsaKvOwnerId, QsaKvSnapshot, QsaPromptKv, QsaPromptStage,
};
#[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))]
pub use qsa_native_decode::OriginalQsaResidentDecodeCompletion;
#[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))]
pub use qsa_prompt_attention::OriginalQsaResidentAttention;
#[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))]
pub use qsa_prompt_index::{
OriginalQsaIndexBatch, OriginalQsaIndexCheckpoint, OriginalQsaResidentIndex, OriginalQsaResidentPromptDevice,
OriginalQsaResidentScalarIndex, OriginalQsaResidentScalarSelection, OriginalQsaResidentSelection,
};
#[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))]
pub use qsa_prompt_kv::{
OriginalQsaMappedAppend, OriginalQsaMappedJournal, OriginalQsaMappedPrefix, OriginalQsaResidentTransport,
};
#[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))]
mod moe_prompt_packet_copy;
mod qsa_native_gate;
pub use qsa_native_gate::QsaNativeGate;
#[allow(unsafe_code)]
mod arch_ptx;
mod gpu_report;
mod original_sampler;
mod original_sampler_params;
mod sealed_ptx;
pub use gpu_report::gpu_kernel_report;
#[allow(unsafe_code)]
mod original_sampler_ffi;
#[allow(unsafe_code)]
mod original_sampler_mapped;
mod original_sampler_params;
mod sealed_ptx;
#[cfg(feature = "sm86")]
mod sm86_table;
pub use original_sampler::{OriginalSampler, SamplerParams, SamplerPath};
mod launch_ex;
mod native_prompt_device;
mod prefill_stage;
mod qsa_cluster;
mod qsa_late;
pub use native_prompt_device::{
OriginalDeviceBlock, OriginalDeviceGrRead, OriginalDeviceNormedResidual, OriginalDeviceResidual,
OriginalPleHistory, OriginalPromptDevice, PromptInputStage,
};
pub use prefill_stage::{
set_gdn_nostore_override as set_prefill_gdn_nostore_override, set_gdn_override as set_prefill_gdn_override,
};
pub use qsa_cluster::{requested as qsa_cluster_requested, set_override as set_qsa_cluster_override};
pub use qsa_late::set_override as set_qsa_late_override;
pub use qsa_late::set_topk_override as set_qsa_topk_override;
pub use qsa_prompt_kv::set_qsa_prefetch_override;
#[cfg(all(feature = "cuda-driver", any(target_os = "linux", target_os = "windows"), target_pointer_width = "64"))]
pub use mtp_dense_kv::OriginalMtpSkippedPrefix;
pub use mtp_dense_kv::{
CompletedDraftKv, DraftKvFallback, DraftKvOutcome, DraftKvPolicy, OriginalMtpEmbedding, OriginalMtpPrefill,
OriginalMtpPrefillWeights,
};
#[cfg(all(feature = "cuda-driver", any(target_os = "linux", target_os = "windows"), target_pointer_width = "64"))]
pub use mtp_dense_kv::{
CompletedOriginalMtpDraft, OriginalMtpDraftProgram, OriginalMtpDrafter, OriginalMtpForwardProgram,
OriginalMtpFullForward, OriginalMtpFullPolicy, OriginalMtpRetainedFullWeights, OriginalMtpRetainedPrefix,
OriginalMtpStepOutput,
};
#[cfg(all(feature = "cuda-driver", any(target_os = "linux", target_os = "windows"), target_pointer_width = "64"))]
mod original_expert_stager;
#[cfg(all(feature = "cuda-driver", any(target_os = "linux", target_os = "windows"), target_pointer_width = "64"))]
pub use original_expert_stager::{
OriginalExpertStager, OriginalFileExpertBlob, OriginalStagerBatch, OriginalStagerCompleted, OriginalStagerJob,
OriginalStagerOptions, OriginalStreamAll, OriginalStreamAllCompleted, OriginalStreamAllForward,
OriginalStreamAllOptions,
};
#[cfg(all(feature = "cuda-driver", any(target_os = "linux", target_os = "windows"), target_pointer_width = "64"))]
mod native_parity;
#[cfg(all(feature = "cuda-driver", any(target_os = "linux", target_os = "windows"), target_pointer_width = "64"))]
#[allow(unsafe_code)]
mod native_parity_ffi;
#[cfg(all(feature = "cuda-driver", any(target_os = "linux", target_os = "windows"), target_pointer_width = "64"))]
pub use native_parity::{
NativeParity, NativeParityExpert, native_parity_embed_supported, native_parity_iq_supported,
native_parity_row_bytes,
};
#[cfg(all(feature = "cuda-driver", any(target_os = "linux", target_os = "windows"), target_pointer_width = "64"))]
pub use mtp_dense_kv::{
OriginalMtpGrVariant, OriginalMtpRetainedScalarWeights, OriginalMtpScalarPolicy, OriginalMtpScalarPrefill,
};
#[cfg(all(feature = "cuda-driver", any(target_os = "linux", target_os = "windows"), target_pointer_width = "64"))]
pub use original_gpu_schedule::OriginalStreamDrained;
pub use original_gpu_schedule::capture_timing as original_capture_timing;
#[cfg(all(feature = "cuda-driver", any(target_os = "linux", target_os = "windows"), target_pointer_width = "64"))]
mod native_head;
#[cfg(all(feature = "cuda-driver", any(target_os = "linux", target_os = "windows"), target_pointer_width = "64"))]
pub use native_head::{
NativeEmbedFlight, NativeHeadDispatch, NativeHeadFlight, NativeHeadProjectionFlight, NativeHeadSampling,
NativeHeadSelection, OriginalNativeEmbed, OriginalNativeEmbedRows, OriginalNativeHead,
OriginalNativeHeadGraphResources, OriginalNativeHeadRows, native_embed_supported, native_head_row_bytes,
native_head_supported,
};
#[cfg(all(feature = "cuda-driver", any(target_os = "linux", target_os = "windows"), target_pointer_width = "64"))]
mod original_file_expert_source;
#[cfg(all(feature = "cuda-driver", any(target_os = "linux", target_os = "windows"), target_pointer_width = "64"))]
pub use original_file_expert_source::{
OriginalFileExpertSource, OriginalFileSourceBlob, OriginalFileSourceCounters, OriginalResidentOptions,
OriginalSourceSwap,
};
#[cfg(all(feature = "cuda-driver", any(target_os = "linux", target_os = "windows"), target_pointer_width = "64"))]
pub(crate) mod original_verify;
#[cfg(all(feature = "cuda-driver", any(target_os = "linux", target_os = "windows"), target_pointer_width = "64"))]
pub use original_verify::chain::set_down_override as set_chain_down_override;
pub use original_verify::sm120::set_overrides as set_sm120_overrides;
#[cfg(all(feature = "cuda-driver", any(target_os = "linux", target_os = "windows"), target_pointer_width = "64"))]
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,
};
// Live verifier release/diagnostic owner, profile report and completed-logit readout.
#[cfg(all(feature = "cuda-driver", any(target_os = "linux", target_os = "windows"), target_pointer_width = "64"))]
pub use original_verify::{
ExpertTier, HcHalf, OriginalVerifyDiag, OriginalVerifyExpertLayout, OriginalVerifyProfile,
OriginalVerifyWindowResources, PROFILE_STAMPS_PER_LAYER, PlanLayout, Projection, QuantSource, RowLogprob,
Rows as OriginalVerifyRows, UNBOUND_PRODUCERS, WINDOW_LAYERS, WindowOps as OriginalVerifyWindowOps,
WindowPolicy as OriginalVerifyWindowPolicy, analyse_row, logpos_topk_from_environment, original_verify_diagnostics,
original_verify_live_count, original_verify_release_live, profile_stamp_slot, profile_stamp_words,
record_window as record_original_verify_window, top_k, write_original_verify_diagnostics, write_row_line,
write_window_logprobs,
};
#[cfg(all(feature = "cuda-driver", any(target_os = "linux", target_os = "windows"), target_pointer_width = "64"))]
pub use original_verify::{
HcHalfBuffers, HcLayerBuffers, HcOutputBuffers, OriginalVerifyExpertFormats, OriginalVerifyGdnProjections,
OriginalVerifyGrBinding, OriginalVerifyMoeBinding, OriginalVerifyMoeLayerWeights, OriginalVerifyNativeMatrix,
OriginalVerifyProjBinding, OriginalVerifyQsaBinding, OriginalVerifyQsaKvBinding, OriginalVerifyQsaLayerWeights,
OriginalVerifyQsaPolicy, OriginalVerifyQsaProjections, PLE_SCRATCH_BYTES, PleBuffers, PleKeyBuffer, QsaRope,
unsealed_window_assets,
};
#[cfg(all(
feature = "cuda-driver",
feature = "expert-tier-probe",
any(target_os = "linux", target_os = "windows"),
target_pointer_width = "64"
))]
pub use original_verify::{OriginalExpertTierProbe, expert_probe_geometry};
#[cfg(all(feature = "cuda-driver", any(target_os = "linux", target_os = "windows"), target_pointer_width = "64"))]
pub use qsa_prompt_index::{OriginalVerifyQsaJournal, OriginalVerifyRope};
// Which compiled assets the Original serve stack needs, and which of them are sealed in this build.
#[cfg(all(feature = "cuda-driver", any(target_os = "linux", target_os = "windows"), target_pointer_width = "64"))]
mod original_serve_assets;
#[cfg(all(feature = "cuda-driver", any(target_os = "linux", target_os = "windows"), target_pointer_width = "64"))]
pub use original_serve_assets::{
OriginalAssetKind, OriginalAssetStatus, original_serve_asset_status, original_serve_assets_sealed,
unsealed_original_serve_assets,
};
// Session-lineage reads over the verifier QSA journal (see the file header).
#[cfg(all(feature = "cuda-driver", any(target_os = "linux", target_os = "windows"), target_pointer_width = "64"))]
mod original_serve_access;
@@ -507,38 +273,9 @@ mod impl_context_4;
mod impl_context_5;
mod impl_context_6;
mod impl_devicebuffer;
#[cfg(all(feature = "cuda-driver", any(target_os = "linux", target_os = "windows"), target_pointer_width = "64"))]
#[allow(unused_imports)]
pub use impl_devicebuffer::chain_selects_mtp;
#[cfg(not(all(
feature = "cuda-driver",
any(target_os = "linux", target_os = "windows"),
target_pointer_width = "64"
)))]
#[allow(unused_imports)]
pub use impl_devicebuffer::chain_selects_mtp;
#[cfg(not(all(
feature = "cuda-driver",
any(target_os = "linux", target_os = "windows"),
target_pointer_width = "64"
)))]
#[allow(unused_imports)]
pub use impl_devicebuffer::set_chain_down_override;
mod prompt_sync_trace_types;
#[allow(unused_imports)]
pub use prompt_sync_trace_types::Bf16ProjectionShape;
#[allow(unused_imports)]
pub use prompt_sync_trace_types::Context;
#[allow(unused_imports)]
pub use prompt_sync_trace_types::DenseFormat;
#[allow(unused_imports)]
pub use prompt_sync_trace_types::Device;
#[allow(unused_imports)]
pub use prompt_sync_trace_types::Driver;
#[allow(unused_imports)]
pub use prompt_sync_trace_types::Error;
#[allow(unused_imports)]
use prompt_sync_trace_types::FixedKernel;
#[allow(unused_imports)]
use prompt_sync_trace_types::FixedOperation;
@@ -549,29 +286,11 @@ pub(crate) use prompt_sync_trace_types::PoisonCell;
#[allow(unused_imports)]
use prompt_sync_trace_types::ProjectionKernels;
#[allow(unused_imports)]
pub use prompt_sync_trace_types::ProjectionKind;
#[allow(unused_imports)]
use prompt_sync_trace_types::ProjectionShape;
#[allow(unused_imports)]
pub use prompt_sync_trace_types::ProjectionSpec;
#[allow(unused_imports)]
pub use prompt_sync_trace_types::PromptSyncTrace;
#[allow(unused_imports)]
pub use prompt_sync_trace_types::Q5KProjectionShape;
#[allow(unused_imports)]
pub use prompt_sync_trace_types::Q6KProjectionShape;
#[allow(unused_imports)]
pub use prompt_sync_trace_types::Result;
#[allow(unused_imports)]
pub use prompt_sync_trace_types::RoutedFormat;
#[allow(unused_imports)]
pub use prompt_sync_trace_types::RoutedGateUpQ8;
mod q5_kshape_types;
#[allow(unused_imports)]
use q5_kshape_types::CurrentGuard;
#[allow(unused_imports)]
pub use q5_kshape_types::DeviceBuffer;
#[allow(unused_imports)]
use q5_kshape_types::MatvecShape;
#[allow(unused_imports)]
use q5_kshape_types::Q5KShape;
@@ -9,3 +9,5 @@ mod impl_originalmtpfullforward;
mod impl_originalmtpfullforward_2_2;
#[path = "impl_originalmtpfullforward_2/impl_originalmtpfullforward_3.rs"]
mod impl_originalmtpfullforward_3;
#[path = "impl_originalmtpfullforward_2/impl_originalmtpfullforward_4.rs"]
mod impl_originalmtpfullforward_4;
@@ -1,62 +1,90 @@
//! Moved out of the parent module by STRA-338: impl OriginalMtpFullForward.
//! Moved out of the parent module by STRA-338: impl OriginalMtpFullForward. `plan` records the commands of one draft
//! step in the order of the former single function; the attention block is here, the MoE and the tail blocks are in
//! `impl_originalmtpfullforward_4.rs`.
#[allow(unused_imports)]
use super::*;
/// The scratch addresses the attention block shares.
struct PlanBufs {
qfull: u64,
qcur: u64,
attn: u64,
gated: u64,
bo: u64,
}
impl OriginalMtpFullForward<'_> {
pub(in super::super) fn plan(
&self,
p: &ForwardPrefix<'_, '_>,
policy: &OriginalMtpFullPolicy,
) -> Result<Vec<FullCommand>> {
self.validate_plan(p, policy)?;
let mut v = Vec::new();
v.try_reserve_exact(110).map_err(|_| Error::HostAllocation)?;
self.plan_attention_block(&mut v, p, policy)?;
self.plan_moe_block(&mut v, p, policy)?;
self.plan_tail_block(&mut v, p, policy)?;
Ok(v)
}
fn validate_plan(&self, p: &ForwardPrefix<'_, '_>, policy: &OriginalMtpFullPolicy) -> Result<()> {
self.inner.validate(p.scalar.context)?;
validate_scalar_prefix(p.scalar)?;
p.ring.validate_context(p.scalar.context)?;
if policy.legacy_router_mode > 2 {
return Err(Error::InvalidProjectionShape);
}
let o = &self.inner;
let w = &o.weights;
let wa = |i: usize| -> Result<u64> { Ok(w.roles[i].handle.ok_or(Error::ContextPoisoned)?.qwen_address()) };
let a = |i| o.address(i);
let mut v = Vec::new();
v.try_reserve_exact(110).map_err(|_| Error::HostAllocation)?;
// Prefix quantized mixed remains live: Q uses same Q8 image as K and V.
// Original Q split is 24 distinct width256 rows, equivalent to its 2D D2D.
let qfull = a(0)?;
let qcur = a(1)?;
let attn = a(2)?;
let gated = a(3)?;
let bo = a(4)?;
Ok(())
}
pub(in super::super) fn slot(&self, i: usize) -> Result<u64> {
self.inner.address(i)
}
/// The addresses of several scratch slots, resolved in the order given.
pub(in super::super) fn slots<const N: usize>(&self, ids: [usize; N]) -> Result<[u64; N]> {
let mut out = [0; N];
for (k, i) in ids.into_iter().enumerate() {
out[k] = self.inner.address(i)?;
}
Ok(out)
}
pub(in super::super) fn role_address(&self, i: usize) -> Result<u64> {
Ok(self.inner.weights.roles[i].handle.ok_or(Error::ContextPoisoned)?.qwen_address())
}
fn plan_attention_block(
&self,
v: &mut Vec<FullCommand>,
p: &ForwardPrefix<'_, '_>,
policy: &OriginalMtpFullPolicy,
) -> Result<()> {
let b = self.plan_q(v, p)?;
self.plan_rope(v, &b, p.pos, &policy.kv)?;
self.plan_attention(v, p, &b)?;
self.plan_gate_out(v, p, &b)?;
self.plan_residual(v, p, policy, &b)
}
/// Prefix quantized mixed remains live: Q uses same Q8 image as K and V. Original Q split is 24 distinct width256
/// rows, equivalent to its 2D D2D.
fn plan_q(&self, v: &mut Vec<FullCommand>, p: &ForwardPrefix<'_, '_>) -> Result<PlanBufs> {
let [qfull, qcur, attn, gated, bo] = self.slots([0, 1, 2, 3, 4])?;
let b = PlanBufs { qfull, qcur, attn, gated, bo };
// Native Q8_0 body is shared with prefix's literal MMVQ module; its command
// is retained in ForwardProgram, not submitted through an old default API.
// Slot0 below is a full native MMVQ asset; explicit input/output geometry.
let qweight = wa(0)?;
let qweight = self.role_address(0)?;
let qentry = fixed_entry(13, "head_n8_s0")?;
push(
&mut v,
13,
qentry,
[12288, 1, 1],
[32, 4, 1],
0,
vec![F::U64(qweight), F::U64(p.q), F::U64(qfull), F::I32(2560), F::I32(12288)],
)?;
self.finite_tail(&mut v, qfull, 12288, 0)?;
let q = vec![F::U64(qweight), F::U64(p.q), F::U64(qfull), F::I32(2560), F::I32(12288)];
push(v, 13, qentry, [12288, 1, 1], [32, 4, 1], 0, q)?;
self.finite_tail(v, qfull, 12288, 0)?;
// Copy commands remain distinct byte transports (24 literal rows); their
// execution is interleaved in ForwardProgram immediately before Q norm.
let norm_entry = 0;
push(
&mut v,
16,
norm_entry,
[24, 1, 1],
[256, 1, 1],
0,
vec![F::U64(qcur), F::U64(wa(1)?), F::U64(qcur), F::I32(256), F::F32(1e-6)],
)?;
self.finite_tail(&mut v, qcur, 6144, 1)?;
let kv = &policy.kv;
let norm = vec![F::U64(qcur), F::U64(self.role_address(1)?), F::U64(qcur), F::I32(256), F::F32(1e-6)];
push(v, 16, norm_entry, [24, 1, 1], [256, 1, 1], 0, norm)?;
self.finite_tail(v, qcur, 6144, 1)?;
Ok(b)
}
fn reject_unsupported_kv(kv: &DraftKvPolicy) -> Result<()> {
if kv.disabled
|| kv.hybrid
|| kv.rotated
@@ -68,453 +96,113 @@ impl OriginalMtpFullForward<'_> {
{
return Err(Error::UnsupportedQwenOperation);
}
push(
&mut v,
16,
1,
[4, 24, 1],
[32, 1, 1],
0,
vec![
F::U64(qcur),
F::U64(qcur),
F::I32(24),
F::I32(256),
F::I32(64),
F::F32(kv.theta_scale),
F::F32(kv.freq_scale),
F::F32(kv.corr_low),
F::F32(kv.corr_high),
F::F32(kv.ext_factor),
F::F32(kv.mscale),
F::U64(p.pos),
F::U64(0),
F::Words3([0; 3]),
],
)?;
self.finite_tail(&mut v, qcur, 6144, 2)?;
// Original window_ids on actual private step, followed by same INT8 decode
// chunk and merge entries. Ring owns pools/table/ident/scratch throughout.
// window command uses ring's actual KV module in the captured program.
let (pa, pm, pl, ident) = o.attention(p.ring)?;
Ok(())
}
fn plan_rope(&self, v: &mut Vec<FullCommand>, b: &PlanBufs, pos: u64, kv: &DraftKvPolicy) -> Result<()> {
Self::reject_unsupported_kv(kv)?;
let qcur = b.qcur;
let rope = vec![
F::U64(qcur),
F::U64(qcur),
F::I32(24),
F::I32(256),
F::I32(64),
F::F32(kv.theta_scale),
F::F32(kv.freq_scale),
F::F32(kv.corr_low),
F::F32(kv.corr_high),
F::F32(kv.ext_factor),
F::F32(kv.mscale),
F::U64(pos),
F::U64(0),
F::Words3([0; 3]),
];
push(v, 16, 1, [4, 24, 1], [32, 1, 1], 0, rope)?;
self.finite_tail(v, qcur, 6144, 2)
}
/// Original window_ids on actual private step, followed by same INT8 decode chunk and merge entries. Ring owns
/// pools/table/ident/scratch throughout. The window command uses the ring's actual KV module in the captured
/// program.
fn plan_attention(&self, v: &mut Vec<FullCommand>, p: &ForwardPrefix<'_, '_>, b: &PlanBufs) -> Result<()> {
let (pa, pm, pl, ident) = self.inner.attention(p.ring)?;
let chain_mtp = crate::original_verify::chain::flags().mtp;
// the Original's chunk kernel in both modes (the load-hoisted variant measured no faster); only the merge changes
let daily = daily_mtp();
push(
&mut v,
if daily { symbols::DAILY_ASSET } else { 19 },
if daily { symbols::DAILY_CHUNK } else { 0 },
[CHUNKS as u32, 2, 1],
[256, 1, 1],
0,
vec![
F::U64(qcur),
F::U64(p.ring.address(0)?),
F::U64(p.ring.address(1)?),
F::U64(p.ring.address(2)?),
F::U64(p.ring.address(3)?),
F::U64(p.ring.address(4)?),
F::U64(ident),
F::U64(p.step),
F::I32(2),
F::I32(4),
F::F32(1.0 / 16.0),
F::U64(pa),
F::U64(pm),
F::U64(pl),
F::I32(CHUNKS as i32),
F::I32(32768),
F::I64(SCRATCH_FLOATS as i64),
],
)?;
let mut merge_args = vec![
self.push_chunk(v, p, (b.qcur, [pa, pm, pl, ident], daily))?;
Self::push_merge(v, p.step, b.attn, [pa, pm, pl], (daily, chain_mtp))?;
self.finite_tail(v, b.attn, 6144, 3)
}
fn push_chunk(&self, v: &mut Vec<FullCommand>, p: &ForwardPrefix<'_, '_>, io: (u64, [u64; 4], bool)) -> Result<()> {
let (qcur, window, daily) = io;
let [pa, pm, pl, ident] = window;
let ring = [p.ring.address(0)?, p.ring.address(1)?, p.ring.address(2)?, p.ring.address(3)?, p.ring.address(4)?];
let args = vec![
F::U64(qcur),
F::U64(ring[0]),
F::U64(ring[1]),
F::U64(ring[2]),
F::U64(ring[3]),
F::U64(ring[4]),
F::U64(ident),
F::U64(p.step),
F::I32(2),
F::I32(4),
F::F32(1.0 / 16.0),
F::U64(pa),
F::U64(pm),
F::U64(pl),
F::I32(CHUNKS as i32),
F::U64(attn),
F::I32(32768),
F::I64(SCRATCH_FLOATS as i64),
];
if daily {
// merge_v2 takes the step words after n_chunks: (acc, m, l, n_chunks, steps, attn, stride)
merge_args = vec![
F::U64(pa),
F::U64(pm),
F::U64(pl),
F::I32(CHUNKS as i32),
F::U64(p.step),
F::U64(attn),
F::I64(SCRATCH_FLOATS as i64),
];
let (asset, index) = if daily { (symbols::DAILY_ASSET, symbols::DAILY_CHUNK) } else { (19, 0) };
push(v, asset, index, [CHUNKS as u32, 2, 1], [256, 1, 1], 0, args)
}
fn push_merge(v: &mut Vec<FullCommand>, step: u64, attn: u64, window: [u64; 3], flags: (bool, bool)) -> Result<()> {
let (daily, chain_mtp) = flags;
let (asset, index) = if daily {
(symbols::DAILY_ASSET, symbols::DAILY_MERGE_V2)
} else if chain_mtp {
merge_args.push(F::U64(p.step)); // the row's step words: n_ids bounds the merge to the chunks that hold cells
}
push(
&mut v,
if daily {
symbols::DAILY_ASSET
} else if chain_mtp {
symbols::CHAIN_ASSET
} else {
19
},
if daily {
symbols::DAILY_MERGE_V2
} else if chain_mtp {
symbols::CHAIN_QSA_MERGE_N
} else {
1
},
[24, 1, 1],
[256, 1, 1],
0,
merge_args,
)?;
self.finite_tail(&mut v, attn, 6144, 3)?;
push(
&mut v,
11,
0,
[24, 1, 1],
[256, 1, 1],
0,
vec![F::U64(attn), F::U64(qfull), F::U64(gated), F::I32(24), F::I32(256)],
)?;
self.finite_tail(&mut v, gated, 6144, 4)?;
self.quant(&mut v, gated, p.q, 6144)?;
self.q8_tail(&mut v, p.q, 6144, 5)?;
self.mmvq(&mut v, wa(2)?, p.q, bo, 6144, 2560)?;
self.finite_tail(&mut v, bo, 2560, 6)?;
self.mlp_gr(&mut v, p, bo, policy)?;
self.finite_tail(&mut v, p.r, 10240, 7)?;
self.finite_tail(&mut v, p.scalar.address(7, p.scalar.max_t * 40960)?, 10240, 8)?;
self.finite_tail(&mut v, p.scalar.address(8, p.scalar.max_t * 1280)?, 320, 9)?;
self.finite_tail(&mut v, a(20)?, 4, 10)?;
self.finite_tail(&mut v, p.mixed, 2560, 11)?;
let router = a(5)?;
self.mmvf(&mut v, p.mixed, wa(7)?, router, 2560, 512)?;
self.finite_tail(&mut v, router, 512, 12)?;
if policy.native_router {
push(&mut v, 3, 0, [1, 1, 1], [32, 8, 1], 0, vec![F::U64(router), F::U64(a(7)?), F::U64(a(6)?)])?;
(symbols::CHAIN_ASSET, symbols::CHAIN_QSA_MERGE_N)
} else {
push(
&mut v,
4,
policy.legacy_router_mode as usize,
[1, 1, 1],
[512, 1, 1],
(512 + 512 * 8 + 512 * 4) as u32,
vec![F::U64(router), F::I32(1), F::I32(512), F::I32(10), F::U64(a(7)?), F::U64(a(6)?)],
)?;
(19, 1)
};
push(v, asset, index, [24, 1, 1], [256, 1, 1], 0, Self::merge_args(step, attn, window, flags))
}
fn merge_args(step: u64, attn: u64, window: [u64; 3], flags: (bool, bool)) -> Vec<F> {
let [pa, pm, pl] = window;
let (n, scratch) = (F::I32(CHUNKS as i32), F::I64(SCRATCH_FLOATS as i64));
if flags.0 {
// merge_v2 takes the step words after n_chunks: (acc, m, l, n_chunks, steps, attn, stride)
return vec![F::U64(pa), F::U64(pm), F::U64(pl), n, F::U64(step), F::U64(attn), scratch];
}
self.finite_tail(&mut v, a(6)?, 10, 13)?;
let expert = w.experts.handle.ok_or(Error::ContextPoisoned)?.qwen_address();
push(
&mut v,
0,
0,
[1, 1, 1],
[128, 1, 1],
0,
vec![
F::U64(a(7)?),
F::I32(10),
F::I32(10),
F::U64(expert),
F::I64(1382400),
F::U64(a(12)?),
F::U64(a(13)?),
F::U64(a(14)?),
F::U64(a(8)?),
F::U64(a(10)?),
],
)?;
push(
&mut v,
1,
0,
[1, 1, 1],
[128, 1, 1],
0,
vec![F::U64(p.mixed), F::U64(a(15)?), F::U64(a(16)?), F::I64(80)],
)?;
let s2 = a(17)?;
let hiddenq = s2 + 51200;
let hscale = hiddenq + 6816;
push(
&mut v,
0,
if policy.old_grouped_s2 { 1 } else { 2 },
[40, 10, 1],
[256, 1, 1],
0,
vec![
F::U64(a(12)?),
F::U64(a(13)?),
F::U64(a(14)?),
F::U64(a(10)?),
F::U64(a(15)?),
F::U64(a(16)?),
F::U64(s2),
F::I32(10),
],
)?;
self.finite_tail(&mut v, s2, 12800, 14)?;
push(&mut v, 0, 3, [6400usize.div_ceil(256) as u32, 1, 1], [256, 1, 1], 0, vec![F::U64(s2), F::I64(6400)])?;
self.finite_tail(&mut v, s2, 6400, 15)?;
push(
&mut v,
1,
0,
[200usize.div_ceil(128) as u32, 1, 1],
[128, 1, 1],
0,
vec![F::U64(s2), F::U64(hiddenq), F::U64(hscale), F::I64(200)],
)?;
push(
&mut v,
0,
if policy.old_grouped_s2 { 4 } else { 5 },
[40, 10, 1],
[256, 1, 1],
0,
vec![
F::U64(a(12)?),
F::U64(a(13)?),
F::U64(a(14)?),
F::U64(a(8)?),
F::U64(hiddenq),
F::U64(hscale),
F::U64(a(9)?),
],
)?;
self.finite_tail(&mut v, a(9)?, 25600, 16)?;
// Shared projection consumes original mixed, not its unconditional BF16 image.
push(&mut v, 10, 0, [10, 1, 1], [256, 1, 1], 0, vec![F::U64(p.mixed), F::U64(a(23)?), F::I64(2560)])?;
self.quant(&mut v, p.mixed, p.q, 2560)?;
self.q8_tail(&mut v, p.q, 2560, 17)?;
self.mmvq(&mut v, wa(8)?, p.q, a(18)?, 2560, 640)?;
self.mmvq(&mut v, wa(9)?, p.q, a(19)?, 2560, 640)?;
self.finite_tail(&mut v, a(18)?, 640, 18)?;
self.finite_tail(&mut v, a(19)?, 640, 19)?;
push(
&mut v,
2,
0,
[5, 1, 1],
[128, 1, 1],
0,
vec![F::U64(a(18)?), F::U64(a(19)?), F::U64(a(18)?), F::I32(640)],
)?;
self.finite_tail(&mut v, a(18)?, 640, 20)?;
self.quant(&mut v, a(18)?, p.q, 640)?;
self.q8_tail(&mut v, p.q, 640, 21)?;
self.mmvq(&mut v, wa(10)?, p.q, a(11)?, 640, 2560)?;
self.finite_tail(&mut v, a(11)?, 2560, 22)?;
if policy.native_shared_scalar {
self.mmvf(&mut v, p.mixed, wa(11)?, a(22)?, 2560, 1)?;
push(&mut v, 2, 2, [1, 1, 1], [1, 1, 1], 0, vec![F::U64(a(22)?)])?;
} else {
push(
&mut v,
2,
1,
[1, 1, 1],
[256, 1, 1],
0,
vec![F::U64(a(23)?), F::U64(wa(11)?), F::U64(a(22)?), F::I32(2560)],
)?;
let mut args = vec![F::U64(pa), F::U64(pm), F::U64(pl), n, F::U64(attn), scratch];
if flags.1 {
args.push(F::U64(step)); // the row's step words: n_ids bounds the merge to the chunks that hold cells
}
self.finite_tail(&mut v, a(22)?, 1, 23)?;
push(&mut v, 2, 3, [20, 1, 1], [128, 1, 1], 0, vec![F::U64(a(11)?), F::U64(a(22)?), F::I32(2560)])?;
self.finite_tail(&mut v, a(11)?, 2560, 24)?;
let mut combine_args = vec![F::U64(a(9)?), F::U64(a(6)?), F::U64(a(11)?), F::U64(o.combined()?)];
if policy.native_combine {
combine_args.extend([F::I64(2560), F::I32(10)]);
} else {
combine_args.extend([F::I32(2560), F::I32(10), F::I32(1)]);
}
push(
&mut v,
if policy.native_combine { 5 } else { 2 },
if policy.native_combine { 0 } else { 4 },
[if policy.native_combine { 10 } else { 20 }, 1, 1],
[if policy.native_combine { 256 } else { 128 }, 1, 1],
0,
combine_args,
)?;
self.finite_tail(&mut v, o.combined()?, 2560, 25)?;
if policy.native_final_gr {
push(
&mut v,
8,
2,
[40, 1, 1],
[256, 1, 1],
0,
vec![
F::U64(p.r),
F::U64(o.combined()?),
F::U64(a(20)?),
F::U64(p.r),
F::I32(2560),
F::I32(4),
F::F32(0.25),
],
)?;
} else {
push(
&mut v,
9,
0,
[40, 1, 1],
[256, 1, 1],
16,
vec![F::U64(p.r), F::U64(o.combined()?), F::U64(a(20)?), F::I32(2560), F::I32(4), F::U64(p.r)],
)?;
}
self.finite_tail(&mut v, p.r, 10240, 26)?;
self.final_gr(&mut v, p, policy)?;
self.finite_tail(&mut v, a(24)?, 2560, 27)?;
self.quant(&mut v, a(24)?, p.q, 2560)?;
self.q8_tail(&mut v, p.q, 2560, 28)?;
let (name, grid, block, iq) = head_dispatch::head_dispatch(w.head_kind, 2560, w.vocab, 1, w.dispatch)?;
let asset = if iq { 14 } else { 13 };
let index = fixed_entry(asset, name)?;
let mut args = vec![F::U64(w.head.handle.ok_or(Error::ContextPoisoned)?.qwen_address())];
if iq {
args.push(F::U64(crate::native_head_row_bytes(w.head_kind, 2560)? as u64));
}
args.extend([F::U64(p.q), F::U64(o.logits()?), F::I32(2560), F::I32(w.vocab as i32)]);
if iq {
args.push(F::I32(1));
}
push(&mut v, asset, index, grid, block, 0, args)?;
self.finite_tail(&mut v, o.logits()?, w.vocab, 29)?;
if let Some(j) = policy.coupled_j {
if !o.coupled || j >= 8 {
return Err(Error::InvalidQwenShape);
}
let blocks = w.vocab.div_ceil(4096);
let kpart = w.vocab.min(64);
let sub = w
.subset
.as_ref()
.map(|(f, _)| f.handle.ok_or(Error::ContextPoisoned).map(|h| h.qwen_address()))
.transpose()?
.unwrap_or(0);
let inv = w
.subset
.as_ref()
.map(|(_, i)| i.handle.ok_or(Error::ContextPoisoned).map(|h| h.qwen_address()))
.transpose()?
.unwrap_or(0);
push(
&mut v,
20,
2,
[1, 1, 1],
[1024, 1, 1],
(w.vocab.div_ceil(32) * 4) as u32,
vec![
F::U64(o.logits()?),
F::I32(w.vocab as i32),
F::U64(inv),
F::I32(w.id_vocab as i32),
F::U64(a(28)?),
F::U64(a(29)?),
F::I32(4096),
F::I32(j as i32),
],
)?;
push(
&mut v,
20,
0,
[blocks as u32, 1, 1],
[128, 1, 1],
0,
vec![
F::U64(o.logits()?),
F::I32(w.vocab as i32),
F::U64(0),
F::I32(0),
F::Params(SamplerParams::default()),
F::I32(kpart as i32),
F::I32(blocks as i32),
F::U64(a(30)?),
],
)?;
push(
&mut v,
20,
3,
[1, 1, 1],
[32, 1, 1],
0,
vec![
F::U64(a(30)?),
F::I32(blocks as i32),
F::I32(w.vocab as i32),
F::I32(kpart as i32),
F::U64(a(28)?),
F::U64(p.step),
F::U64(sub),
F::U64(a(29)?),
F::I32(4096),
F::I32(j as i32),
F::U64(o.address(34)?),
F::U64(o.address(35)?),
],
)?;
} else {
let mut greedy = SamplerParams::default();
greedy.greedy = true;
greedy.temperature = 0.0;
let chain_head = crate::original_verify::chain::flags().head;
push(
&mut v,
if chain_head { symbols::CHAIN_ASSET } else { 15 },
if chain_head { symbols::CHAIN_SAMPLER_GREEDY } else { 0 },
[1, 1, 1],
[1024, 1, 1],
0,
vec![
F::U64(o.logits()?),
F::I32(w.vocab as i32),
F::U64(0),
F::I32(0),
F::Params(greedy),
F::I32(0),
F::I32(0),
F::U64(o.address(34)?),
],
)?;
push(
&mut v,
if chain_head { symbols::CHAIN_ASSET } else { 12 },
if chain_head { symbols::CHAIN_ROW_TOP_PROB } else { 0 },
[1, 1, 1],
[1024, 1, 1],
0,
vec![F::U64(o.logits()?), F::I32(w.vocab as i32), F::U64(o.address(34)?), F::U64(o.address(35)?)],
)?;
if let Some((forward, _)) = &w.subset {
push(
&mut v,
12,
1,
[1, 1, 1],
[64, 1, 1],
0,
vec![
F::U64(o.address(34)?),
F::U64(forward.handle.ok_or(Error::ContextPoisoned)?.qwen_address()),
F::I32(1),
],
)?;
}
}
Ok(v)
args
}
fn plan_gate_out(&self, v: &mut Vec<FullCommand>, p: &ForwardPrefix<'_, '_>, b: &PlanBufs) -> Result<()> {
let gate = vec![F::U64(b.attn), F::U64(b.qfull), F::U64(b.gated), F::I32(24), F::I32(256)];
push(v, 11, 0, [24, 1, 1], [256, 1, 1], 0, gate)?;
self.finite_tail(v, b.gated, 6144, 4)?;
self.quant(v, b.gated, p.q, 6144)?;
self.q8_tail(v, p.q, 6144, 5)?;
self.mmvq(v, self.role_address(2)?, p.q, b.bo, 6144, 2560)?;
self.finite_tail(v, b.bo, 2560, 6)
}
fn plan_residual(
&self,
v: &mut Vec<FullCommand>,
p: &ForwardPrefix<'_, '_>,
policy: &OriginalMtpFullPolicy,
b: &PlanBufs,
) -> Result<()> {
self.mlp_gr(v, p, b.bo, policy)?;
self.finite_tail(v, p.r, 10240, 7)?;
self.finite_tail(v, p.scalar.address(7, p.scalar.max_t * 40960)?, 10240, 8)?;
self.finite_tail(v, p.scalar.address(8, p.scalar.max_t * 1280)?, 320, 9)?;
self.finite_tail(v, self.slot(20)?, 4, 10)?;
self.finite_tail(v, p.mixed, 2560, 11)
}
}
@@ -0,0 +1,313 @@
//! The MoE and tail blocks of `OriginalMtpFullForward::plan` (STRA-338), recorded in the order of the former single
//! function: router, experts, shared expert and combine; then the final GR, the head and the sampler.
#[allow(unused_imports)]
use super::*;
/// What the coupled sampler needs besides the logits.
struct Coupled {
logits: u64,
sub: u64,
inv: u64,
j: u8,
slots: [u64; 5],
}
impl OriginalMtpFullForward<'_> {
pub(in super::super) fn plan_moe_block(
&self,
v: &mut Vec<FullCommand>,
p: &ForwardPrefix<'_, '_>,
policy: &OriginalMtpFullPolicy,
) -> Result<()> {
self.plan_router(v, p, policy)?;
self.plan_experts(v, p.mixed, policy)?;
self.plan_shared(v, p, policy)?;
self.plan_combine(v, policy)
}
pub(in super::super) fn plan_tail_block(
&self,
v: &mut Vec<FullCommand>,
p: &ForwardPrefix<'_, '_>,
policy: &OriginalMtpFullPolicy,
) -> Result<()> {
self.plan_final_gr(v, p, policy)?;
self.plan_head(v, p)?;
self.plan_sampler(v, p.step, policy)
}
fn plan_router(
&self,
v: &mut Vec<FullCommand>,
p: &ForwardPrefix<'_, '_>,
policy: &OriginalMtpFullPolicy,
) -> Result<()> {
let router = self.slot(5)?;
self.mmvf(v, p.mixed, self.role_address(7)?, router, 2560, 512)?;
self.finite_tail(v, router, 512, 12)?;
let [ids, probs] = self.slots([7, 6])?;
Self::push_router(v, router, [ids, probs], policy)?;
self.finite_tail(v, probs, 10, 13)
}
fn push_router(
v: &mut Vec<FullCommand>,
router: u64,
outputs: [u64; 2],
policy: &OriginalMtpFullPolicy,
) -> Result<()> {
let [ids, probs] = outputs;
if policy.native_router {
return push(v, 3, 0, [1, 1, 1], [32, 8, 1], 0, vec![F::U64(router), F::U64(ids), F::U64(probs)]);
}
let shared = (512 + 512 * 8 + 512 * 4) as u32;
let args = vec![F::U64(router), F::I32(1), F::I32(512), F::I32(10), F::U64(ids), F::U64(probs)];
push(v, 4, policy.legacy_router_mode as usize, [1, 1, 1], [512, 1, 1], shared, args)
}
fn plan_experts(&self, v: &mut Vec<FullCommand>, mixed: u64, policy: &OriginalMtpFullPolicy) -> Result<()> {
let expert = self.inner.weights.experts.handle.ok_or(Error::ContextPoisoned)?.qwen_address();
let [a7, a8, a10, a12, a13, a14, a15, a16] = self.slots([7, 8, 10, 12, 13, 14, 15, 16])?;
let select = vec![
F::U64(a7),
F::I32(10),
F::I32(10),
F::U64(expert),
F::I64(1382400),
F::U64(a12),
F::U64(a13),
F::U64(a14),
F::U64(a8),
F::U64(a10),
];
push(v, 0, 0, [1, 1, 1], [128, 1, 1], 0, select)?;
push(v, 1, 0, [1, 1, 1], [128, 1, 1], 0, vec![F::U64(mixed), F::U64(a15), F::U64(a16), F::I64(80)])?;
self.plan_s2(v, policy, [a8, a10, a12, a13, a14, a15, a16])?;
self.plan_expert_down(v, policy, [a8, a12, a13, a14])
}
/// The grouped S2 matrix products of the selected experts and their requantization.
fn plan_s2(&self, v: &mut Vec<FullCommand>, policy: &OriginalMtpFullPolicy, a: [u64; 7]) -> Result<()> {
let [_, a10, a12, a13, a14, a15, a16] = a;
let s2 = self.slot(17)?;
let hiddenq = s2 + 51200;
let hscale = hiddenq + 6816;
let index = if policy.old_grouped_s2 { 1 } else { 2 };
let args =
vec![F::U64(a12), F::U64(a13), F::U64(a14), F::U64(a10), F::U64(a15), F::U64(a16), F::U64(s2), F::I32(10)];
push(v, 0, index, [40, 10, 1], [256, 1, 1], 0, args)?;
self.finite_tail(v, s2, 12800, 14)?;
push(v, 0, 3, [6400usize.div_ceil(256) as u32, 1, 1], [256, 1, 1], 0, vec![F::U64(s2), F::I64(6400)])?;
self.finite_tail(v, s2, 6400, 15)?;
let requant = vec![F::U64(s2), F::U64(hiddenq), F::U64(hscale), F::I64(200)];
push(v, 1, 0, [200usize.div_ceil(128) as u32, 1, 1], [128, 1, 1], 0, requant)
}
fn plan_expert_down(&self, v: &mut Vec<FullCommand>, policy: &OriginalMtpFullPolicy, a: [u64; 4]) -> Result<()> {
let [a8, a12, a13, a14] = a;
let hiddenq = self.slot(17)? + 51200;
let hscale = hiddenq + 6816;
let a9 = self.slot(9)?;
let index = if policy.old_grouped_s2 { 4 } else { 5 };
let args = vec![F::U64(a12), F::U64(a13), F::U64(a14), F::U64(a8), F::U64(hiddenq), F::U64(hscale), F::U64(a9)];
push(v, 0, index, [40, 10, 1], [256, 1, 1], 0, args)?;
self.finite_tail(v, a9, 25600, 16)
}
fn plan_shared(
&self,
v: &mut Vec<FullCommand>,
p: &ForwardPrefix<'_, '_>,
policy: &OriginalMtpFullPolicy,
) -> Result<()> {
self.plan_shared_input(v, p)?;
self.plan_shared_gate_up(v, p)?;
self.plan_shared_down(v, p)?;
self.plan_shared_scalar(v, p.mixed, policy)
}
/// Shared projection consumes original mixed, not its unconditional BF16 image.
fn plan_shared_input(&self, v: &mut Vec<FullCommand>, p: &ForwardPrefix<'_, '_>) -> Result<()> {
let a23 = self.slot(23)?;
push(v, 10, 0, [10, 1, 1], [256, 1, 1], 0, vec![F::U64(p.mixed), F::U64(a23), F::I64(2560)])?;
self.quant(v, p.mixed, p.q, 2560)?;
self.q8_tail(v, p.q, 2560, 17)
}
fn plan_shared_gate_up(&self, v: &mut Vec<FullCommand>, p: &ForwardPrefix<'_, '_>) -> Result<()> {
let [a18, a19] = self.slots([18, 19])?;
self.mmvq(v, self.role_address(8)?, p.q, a18, 2560, 640)?;
self.mmvq(v, self.role_address(9)?, p.q, a19, 2560, 640)?;
self.finite_tail(v, a18, 640, 18)?;
self.finite_tail(v, a19, 640, 19)?;
push(v, 2, 0, [5, 1, 1], [128, 1, 1], 0, vec![F::U64(a18), F::U64(a19), F::U64(a18), F::I32(640)])?;
self.finite_tail(v, a18, 640, 20)
}
fn plan_shared_down(&self, v: &mut Vec<FullCommand>, p: &ForwardPrefix<'_, '_>) -> Result<()> {
let [a18, a11] = self.slots([18, 11])?;
self.quant(v, a18, p.q, 640)?;
self.q8_tail(v, p.q, 640, 21)?;
self.mmvq(v, self.role_address(10)?, p.q, a11, 640, 2560)?;
self.finite_tail(v, a11, 2560, 22)
}
fn plan_shared_scalar(&self, v: &mut Vec<FullCommand>, mixed: u64, policy: &OriginalMtpFullPolicy) -> Result<()> {
let [a11, a22, a23] = self.slots([11, 22, 23])?;
if policy.native_shared_scalar {
self.mmvf(v, mixed, self.role_address(11)?, a22, 2560, 1)?;
push(v, 2, 2, [1, 1, 1], [1, 1, 1], 0, vec![F::U64(a22)])?;
} else {
let args = vec![F::U64(a23), F::U64(self.role_address(11)?), F::U64(a22), F::I32(2560)];
push(v, 2, 1, [1, 1, 1], [256, 1, 1], 0, args)?;
}
self.finite_tail(v, a22, 1, 23)?;
push(v, 2, 3, [20, 1, 1], [128, 1, 1], 0, vec![F::U64(a11), F::U64(a22), F::I32(2560)])?;
self.finite_tail(v, a11, 2560, 24)
}
fn plan_combine(&self, v: &mut Vec<FullCommand>, policy: &OriginalMtpFullPolicy) -> Result<()> {
let [a9, a6, a11] = self.slots([9, 6, 11])?;
let combined = self.inner.combined()?;
let mut args = vec![F::U64(a9), F::U64(a6), F::U64(a11), F::U64(combined)];
let native = policy.native_combine;
if native {
args.extend([F::I64(2560), F::I32(10)]);
} else {
args.extend([F::I32(2560), F::I32(10), F::I32(1)]);
}
let (asset, index) = if native { (5, 0) } else { (2, 4) };
let (grid, block) = if native { (10, 256) } else { (20, 128) };
push(v, asset, index, [grid, 1, 1], [block, 1, 1], 0, args)?;
self.finite_tail(v, combined, 2560, 25)
}
fn plan_final_gr(
&self,
v: &mut Vec<FullCommand>,
p: &ForwardPrefix<'_, '_>,
policy: &OriginalMtpFullPolicy,
) -> Result<()> {
self.push_final_gr(v, p.r, policy.native_final_gr)?;
self.finite_tail(v, p.r, 10240, 26)?;
self.final_gr(v, p, policy)?;
let a24 = self.slot(24)?;
self.finite_tail(v, a24, 2560, 27)?;
self.quant(v, a24, p.q, 2560)?;
self.q8_tail(v, p.q, 2560, 28)
}
fn push_final_gr(&self, v: &mut Vec<FullCommand>, r: u64, native: bool) -> Result<()> {
let combined = self.inner.combined()?;
let a20 = self.slot(20)?;
if native {
let args = vec![F::U64(r), F::U64(combined), F::U64(a20), F::U64(r), F::I32(2560), F::I32(4), F::F32(0.25)];
return push(v, 8, 2, [40, 1, 1], [256, 1, 1], 0, args);
}
let args = vec![F::U64(r), F::U64(combined), F::U64(a20), F::I32(2560), F::I32(4), F::U64(r)];
push(v, 9, 0, [40, 1, 1], [256, 1, 1], 16, args)
}
fn plan_head(&self, v: &mut Vec<FullCommand>, p: &ForwardPrefix<'_, '_>) -> Result<()> {
let w = &self.inner.weights;
let (name, grid, block, iq) = head_dispatch::head_dispatch(w.head_kind, 2560, w.vocab, 1, w.dispatch)?;
let asset = if iq { 14 } else { 13 };
let index = fixed_entry(asset, name)?;
push(v, asset, index, grid, block, 0, self.head_args(p.q, iq)?)?;
self.finite_tail(v, self.inner.logits()?, w.vocab, 29)
}
fn head_args(&self, q: u64, iq: bool) -> Result<Vec<F>> {
let w = &self.inner.weights;
let mut args = vec![F::U64(w.head.handle.ok_or(Error::ContextPoisoned)?.qwen_address())];
if iq {
args.push(F::U64(crate::native_head_row_bytes(w.head_kind, 2560)? as u64));
}
args.extend([F::U64(q), F::U64(self.inner.logits()?), F::I32(2560), F::I32(w.vocab as i32)]);
if iq {
args.push(F::I32(1));
}
Ok(args)
}
fn plan_sampler(&self, v: &mut Vec<FullCommand>, step: u64, policy: &OriginalMtpFullPolicy) -> Result<()> {
match policy.coupled_j {
Some(j) => self.plan_coupled(v, step, j),
None => self.plan_greedy(v),
}
}
fn plan_coupled(&self, v: &mut Vec<FullCommand>, step: u64, j: u8) -> Result<()> {
let o = &self.inner;
if !o.coupled || j >= 8 {
return Err(Error::InvalidQwenShape);
}
let w = &o.weights;
let handle = |f: &DeviceBuffer<'_>| f.handle.ok_or(Error::ContextPoisoned).map(|h| h.qwen_address());
let sub = w.subset.as_ref().map(|(f, _)| handle(f)).transpose()?.unwrap_or(0);
let inv = w.subset.as_ref().map(|(_, i)| handle(i)).transpose()?.unwrap_or(0);
let slots = self.slots([28, 29, 30, 34, 35])?;
let coupled = Coupled { logits: o.logits()?, sub, inv, j, slots };
self.push_coupled_filter(v, &coupled)?;
self.push_coupled_blocks(v, &coupled)?;
self.push_coupled_merge(v, &coupled, step)
}
fn push_coupled_filter(&self, v: &mut Vec<FullCommand>, c: &Coupled) -> Result<()> {
let w = &self.inner.weights;
let args = vec![
F::U64(c.logits),
F::I32(w.vocab as i32),
F::U64(c.inv),
F::I32(w.id_vocab as i32),
F::U64(c.slots[0]),
F::U64(c.slots[1]),
F::I32(4096),
F::I32(c.j as i32),
];
push(v, 20, 2, [1, 1, 1], [1024, 1, 1], (w.vocab.div_ceil(32) * 4) as u32, args)
}
fn push_coupled_blocks(&self, v: &mut Vec<FullCommand>, c: &Coupled) -> Result<()> {
let w = &self.inner.weights;
let blocks = w.vocab.div_ceil(4096);
let kpart = w.vocab.min(64);
let args = vec![
F::U64(c.logits),
F::I32(w.vocab as i32),
F::U64(0),
F::I32(0),
F::Params(SamplerParams::default()),
F::I32(kpart as i32),
F::I32(blocks as i32),
F::U64(c.slots[2]),
];
push(v, 20, 0, [blocks as u32, 1, 1], [128, 1, 1], 0, args)
}
fn push_coupled_merge(&self, v: &mut Vec<FullCommand>, c: &Coupled, step: u64) -> Result<()> {
let w = &self.inner.weights;
let blocks = w.vocab.div_ceil(4096);
let kpart = w.vocab.min(64);
let args = vec![
F::U64(c.slots[2]),
F::I32(blocks as i32),
F::I32(w.vocab as i32),
F::I32(kpart as i32),
F::U64(c.slots[0]),
F::U64(step),
F::U64(c.sub),
F::U64(c.slots[1]),
F::I32(4096),
F::I32(c.j as i32),
F::U64(c.slots[3]),
F::U64(c.slots[4]),
];
push(v, 20, 3, [1, 1, 1], [32, 1, 1], 0, args)
}
fn plan_greedy(&self, v: &mut Vec<FullCommand>) -> Result<()> {
let o = &self.inner;
let mut greedy = SamplerParams::default();
greedy.greedy = true;
greedy.temperature = 0.0;
let chain_head = crate::original_verify::chain::flags().head;
let logits = o.logits()?;
let [top, prob] = self.slots([34, 35])?;
let vocab = F::I32(o.weights.vocab as i32);
let (asset, index) = if chain_head { (symbols::CHAIN_ASSET, symbols::CHAIN_SAMPLER_GREEDY) } else { (15, 0) };
let sample =
vec![F::U64(logits), vocab, F::U64(0), F::I32(0), F::Params(greedy), F::I32(0), F::I32(0), F::U64(top)];
push(v, asset, index, [1, 1, 1], [1024, 1, 1], 0, sample)?;
let (asset, index) = if chain_head { (symbols::CHAIN_ASSET, symbols::CHAIN_ROW_TOP_PROB) } else { (12, 0) };
let rows = vec![F::U64(logits), F::I32(o.weights.vocab as i32), F::U64(top), F::U64(prob)];
push(v, asset, index, [1, 1, 1], [1024, 1, 1], 0, rows)?;
self.push_subset_map(v, top)
}
fn push_subset_map(&self, v: &mut Vec<FullCommand>, top: u64) -> Result<()> {
let Some((forward, _)) = &self.inner.weights.subset else {
return Ok(());
};
let forward = forward.handle.ok_or(Error::ContextPoisoned)?.qwen_address();
push(v, 12, 1, [1, 1, 1], [64, 1, 1], 0, vec![F::U64(top), F::U64(forward), F::I32(1)])
}
}
@@ -13,3 +13,9 @@ mod impl_originalmtpprefill_3;
mod impl_originalmtpprefill_4;
#[path = "impl_originalmtpprefill/impl_originalmtpprefill_5.rs"]
mod impl_originalmtpprefill_5;
#[path = "impl_originalmtpprefill/impl_originalmtpprefill_6.rs"]
mod impl_originalmtpprefill_6;
#[path = "impl_originalmtpprefill/impl_originalmtpprefill_7.rs"]
mod impl_originalmtpprefill_7;
#[allow(unused_imports)]
use impl_originalmtpprefill_7::{Admit, Block, Call, GrBufs, PageRuns, Stage, Staged, WEIGHT_EXTENTS};
@@ -1,8 +1,25 @@
//! Moved out of the parent module by STRA-338: impl OriginalMtpPrefill (4).
//! Moved out of the parent module by STRA-338: impl OriginalMtpPrefill (4). `record` admits the call, stages the
//! weights and walks the blocks; the commands of one block are recorded in `impl_originalmtpprefill_6.rs`.
#[allow(unused_imports)]
use super::*;
/// The weights in the order of `WEIGHT_EXTENTS`.
fn weight_refs<'a, 'c>(w: &OriginalMtpPrefillWeights<'a, 'c>) -> [&'a DeviceBuffer<'c>; 10] {
[
w.embedding_norm,
w.embedding_fc,
w.hidden_norm,
w.hidden_fc,
w.gr_norm,
w.gr_down,
w.gr_up,
w.key,
w.value,
w.key_norm,
]
}
impl<'ctx> OriginalMtpPrefill<'ctx> {
#[allow(clippy::too_many_arguments)]
pub fn record<'arena, 'loan>(
@@ -19,87 +36,147 @@ impl<'ctx> OriginalMtpPrefill<'ctx> {
policy: &DraftKvPolicy,
mut cancelled: impl FnMut() -> bool,
) -> Result<DraftKvOutcome> {
let call = Call { prior, tokens, cell0, first_needed, policy };
self.record_call(residual, workspace, ring, &call, (&weights, &embedding), &mut cancelled)
}
fn record_call(
&mut self,
residual: &mut OriginalDeviceResidual<'_, '_, 'ctx>,
workspace: &mut NativeBatchWorkspace<'ctx>,
ring: &mut MtpOriginalInt8<'ctx>,
call: &Call<'_>,
operands: (&OriginalMtpPrefillWeights<'_, '_>, &OriginalMtpEmbedding<'_, '_>),
cancelled: &mut impl FnMut() -> bool,
) -> Result<DraftKvOutcome> {
let (weights, embedding) = operands;
let r0 = match self.admit(residual, workspace, ring, call, embedding)? {
Admit::Run(r0) => r0,
Admit::Done(outcome) => return Ok(outcome),
};
let rows = residual.lease_mut();
let staged = match self.stage(rows, workspace, ring, (call, r0), (weights, embedding))? {
Stage::Ready(staged) => staged,
Stage::Done(outcome) => return Ok(outcome),
};
self.record_blocks(rows, workspace, ring, call, (&staged, embedding), cancelled)
}
/// The fallbacks and refusals that precede any device work.
fn admit(
&self,
residual: &OriginalDeviceResidual<'_, '_, 'ctx>,
workspace: &NativeBatchWorkspace<'ctx>,
ring: &MtpOriginalInt8<'ctx>,
call: &Call<'_>,
embedding: &OriginalMtpEmbedding<'_, '_>,
) -> Result<Admit> {
if let Some(fallback) = Self::fallback_for(call.policy, call.tokens) {
return Ok(Admit::Done(DraftKvOutcome::Fallback(fallback)));
}
Self::reject_bad_rope(call.policy)?;
self.validate_inputs(residual, workspace, ring, call, embedding)?;
let r0 = call.first_needed.saturating_sub(call.cell0);
if r0 >= call.tokens.len() {
return Ok(Admit::Done(DraftKvOutcome::Skipped));
}
Ok(Admit::Run(r0))
}
pub(in super::super) fn fallback_for(policy: &DraftKvPolicy, tokens: &[i32]) -> Option<DraftKvFallback> {
if policy.disabled {
return Ok(DraftKvOutcome::Fallback(DraftKvFallback::Disabled));
return Some(DraftKvFallback::Disabled);
}
if tokens.is_empty() {
return Ok(DraftKvOutcome::Fallback(DraftKvFallback::Empty));
return Some(DraftKvFallback::Empty);
}
if policy.mode != 0 || policy.hybrid || policy.rotated || policy.q4 {
return Ok(DraftKvOutcome::Fallback(DraftKvFallback::UnsupportedStorage));
return Some(DraftKvFallback::UnsupportedStorage);
}
if policy.alternate_f16 {
return Ok(DraftKvOutcome::Fallback(DraftKvFallback::AlternateF16));
return Some(DraftKvFallback::AlternateF16);
}
if policy.rope_table_enabled || policy.multimodal_positions {
return Ok(DraftKvOutcome::Fallback(DraftKvFallback::UnsupportedRopeTable));
return Some(DraftKvFallback::UnsupportedRopeTable);
}
if [policy.theta_scale, policy.freq_scale, policy.corr_low, policy.corr_high, policy.ext_factor, policy.mscale]
.iter()
.any(|x| !x.is_finite())
None
}
pub(in super::super) fn reject_bad_rope(policy: &DraftKvPolicy) -> Result<()> {
let scales = [policy.theta_scale, policy.freq_scale, policy.corr_low, policy.corr_high, policy.ext_factor];
if scales.iter().chain([&policy.mscale]).any(|x| !x.is_finite())
|| policy.theta_scale <= 0.0
|| policy.freq_scale <= 0.0
|| policy.mscale <= 0.0
{
return Err(Error::InvalidProjectionShape);
}
ring.validate_snapshot(prior)?;
Ok(())
}
fn validate_inputs(
&self,
residual: &OriginalDeviceResidual<'_, '_, 'ctx>,
workspace: &NativeBatchWorkspace<'ctx>,
ring: &MtpOriginalInt8<'ctx>,
call: &Call<'_>,
embedding: &OriginalMtpEmbedding<'_, '_>,
) -> Result<()> {
ring.validate_snapshot(call.prior)?;
workspace.validate_context(self.context)?;
ring.validate_context(self.context)?;
if self.is_failed()
if self.shape_rejected(residual, call) {
return Err(Error::InvalidProjectionShape);
}
if call.tokens.iter().any(|t| *t < 0 || *t as usize >= embedding.vocab()) {
return Err(Error::InvalidProjectionShape);
}
Ok(())
}
fn shape_rejected(&self, residual: &OriginalDeviceResidual<'_, '_, 'ctx>, call: &Call<'_>) -> bool {
let len = call.tokens.len();
self.is_failed()
|| !residual.context_matches(self.context)
|| tokens.len() != residual.rows()
|| tokens.len() > 8192
|| cell0.checked_add(tokens.len()).is_none_or(|n| n > MTP_ORIGINAL_MAX_CELLS)
{
return Err(Error::InvalidProjectionShape);
}
if tokens.iter().any(|t| *t < 0 || *t as usize >= embedding.vocab()) {
return Err(Error::InvalidProjectionShape);
}
let r0 = first_needed.saturating_sub(cell0);
if r0 >= tokens.len() {
return Ok(DraftKvOutcome::Skipped);
}
let rows = residual.lease_mut();
|| len != residual.rows()
|| len > 8192
|| call.cell0.checked_add(len).is_none_or(|n| n > MTP_ORIGINAL_MAX_CELLS)
}
/// Q8 tile widths that fit the shared-memory limit of the device.
fn has_q8_tile(&self) -> bool {
WIDTHS.into_iter().any(|j| 128 * 76 * 4 + j * 4 + (j * 144).div_ceil(1024) * 1024 <= self.shared_limit as usize)
}
/// The region, the staged weights and embedding table, and the proof that none of them alias.
fn stage(
&self,
rows: &OriginalPromptRows<'_, '_, '_>,
workspace: &NativeBatchWorkspace<'ctx>,
ring: &MtpOriginalInt8<'ctx>,
first: (&Call<'_>, usize),
operands: (&OriginalMtpPrefillWeights<'_, '_>, &OriginalMtpEmbedding<'_, '_>),
) -> Result<Stage> {
let ((call, r0), (weights, embedding)) = (first, operands);
let (region, region_bytes) = rows.draft_kv_region()?;
let Some(r) = Region::new(region, region_bytes, tokens.len(), r0)? else {
return Ok(DraftKvOutcome::Fallback(DraftKvFallback::RegionTooSmall));
let Some(r) = Region::new(region, region_bytes, call.tokens.len(), r0)? else {
return Ok(Stage::Done(DraftKvOutcome::Fallback(DraftKvFallback::RegionTooSmall)));
};
crate::bringup_trace!("DBG prefill.record: region ok b={} tokens={} r0={r0}", r.b, tokens.len());
if !WIDTHS
.into_iter()
.any(|j| 128 * 76 * 4 + j * 4 + (j * 144).div_ceil(1024) * 1024 <= self.shared_limit as usize)
{
return Ok(DraftKvOutcome::Fallback(DraftKvFallback::NoQ8Tile));
crate::bringup_trace!("DBG prefill.record: region ok b={} tokens={} r0={r0}", r.b, call.tokens.len());
if !self.has_q8_tile() {
return Ok(Stage::Done(DraftKvOutcome::Fallback(DraftKvFallback::NoQ8Tile)));
}
let weight_refs = [
weights.embedding_norm,
weights.embedding_fc,
weights.hidden_norm,
weights.hidden_fc,
weights.gr_norm,
weights.gr_down,
weights.gr_up,
weights.key,
weights.value,
weights.key_norm,
];
let extents = [
10240,
2560 * 80 * 34,
40960,
2560 * 80 * 34,
40960,
320 * 10240 * 2,
10240 * 320 * 2,
512 * 80 * 34,
512 * 80 * 34,
1024,
];
let refs = weight_refs(weights);
let (wh, eh) = self.stage_operands(rows, workspace, &refs, embedding, region)?;
let (rh, rbytes) = Self::input_span(rows, region, region_bytes)?;
let staged = Staged { r, r0, wh, eh, rh, rbytes, table_bytes: embedding.table.bytes };
staged.check_ring(ring, region, region_bytes)?;
crate::bringup_trace!("DBG prefill.record: overlap checks ok");
Ok(Stage::Ready(staged))
}
fn stage_operands(
&self,
rows: &OriginalPromptRows<'_, '_, '_>,
workspace: &NativeBatchWorkspace<'ctx>,
refs: &[&DeviceBuffer<'_>; 10],
embedding: &OriginalMtpEmbedding<'_, '_>,
region: BufferHandle,
) -> Result<([BufferHandle; 10], BufferHandle)> {
let mut wh = [region; 10];
for i in 0..10 {
wh[i] = self.weight(rows, workspace, weight_refs[i], extents[i]).map_err(|e| {
wh[i] = self.weight(rows, workspace, refs[i], WEIGHT_EXTENTS[i]).map_err(|e| {
crate::bringup_trace!("DBG prefill.record: weight {i} err {e:?}");
e
})?;
@@ -110,8 +187,13 @@ impl<'ctx> OriginalMtpPrefill<'ctx> {
e
})?;
crate::bringup_trace!("DBG prefill.record: embedding table staged");
for (i, a) in weight_refs.iter().enumerate() {
for b in weight_refs.iter().take(i) {
Self::check_weights_disjoint(refs)?;
Self::check_embedding_disjoint(refs, eh, embedding.table.bytes)?;
Ok((wh, eh))
}
fn check_weights_disjoint(refs: &[&DeviceBuffer<'_>; 10]) -> Result<()> {
for (i, a) in refs.iter().enumerate() {
for b in refs.iter().take(i) {
let ah = a.handle.ok_or_else(|| {
crate::bringup_trace!("DBG prefill.record: weight_ref a.handle is None (i={i})");
Error::ContextPoisoned
@@ -126,18 +208,28 @@ impl<'ctx> OriginalMtpPrefill<'ctx> {
}
}
}
for b in weight_refs {
Ok(())
}
fn check_embedding_disjoint(refs: &[&DeviceBuffer<'_>; 10], eh: BufferHandle, table_bytes: usize) -> Result<()> {
for b in refs {
let h = b.handle.ok_or_else(|| {
crate::bringup_trace!("DBG prefill.record: weight b.handle is None (embedding overlap)");
Error::ContextPoisoned
})?;
if eh.overlaps(embedding.table.bytes, h, b.bytes)
&& !(eh.qwen_address() == h.qwen_address() && embedding.table.bytes == b.bytes)
if eh.overlaps(table_bytes, h, b.bytes)
&& !(eh.qwen_address() == h.qwen_address() && table_bytes == b.bytes)
{
return Err(Error::OutputAliasesInput);
}
}
// Actual input residual lies outside the region being overwritten.
Ok(())
}
/// Actual input residual lies outside the region being overwritten.
fn input_span(
rows: &OriginalPromptRows<'_, '_, '_>,
region: BufferHandle,
region_bytes: usize,
) -> Result<(BufferHandle, usize)> {
let (rh, rbytes) = rows.common_span(OriginalPromptSpan::R).map_err(|e| {
crate::bringup_trace!("DBG prefill.record: common_span(R) err {e:?}");
e
@@ -146,25 +238,67 @@ impl<'ctx> OriginalMtpPrefill<'ctx> {
if rh.overlaps(rbytes, region, region_bytes) {
return Err(Error::OutputAliasesInput);
}
// The serve ring is built from prepared spans of the drafter's shared region, so buffers 0..5 are not
// separately owned DeviceBuffers; compare by address (ring.address works for both layouts).
for i in 0..5 {
let hv = ring.address(i)?;
let n = ring.sizes[i];
let ov = |o: u64, on: usize| hv < o.saturating_add(on as u64) && o < hv.saturating_add(n as u64);
if ov(region.qwen_address(), region_bytes)
|| ov(rh.qwen_address(), rbytes)
|| wh.iter().zip(extents).any(|(w, n2)| ov(w.qwen_address(), n2))
|| ov(eh.qwen_address(), embedding.table.bytes)
{
return Err(Error::OutputAliasesInput);
Ok((rh, rbytes))
}
/// Walks the blocks and publishes the completed range (or the cancellation).
fn record_blocks(
&mut self,
rows: &mut OriginalPromptRows<'_, '_, '_>,
workspace: &mut NativeBatchWorkspace<'ctx>,
ring: &mut MtpOriginalInt8<'ctx>,
call: &Call<'_>,
operands: (&Staged, &OriginalMtpEmbedding<'_, '_>),
cancelled: &mut impl FnMut() -> bool,
) -> Result<DraftKvOutcome> {
let (staged, embedding) = operands;
let generation = ring.generation.checked_add(1).ok_or(Error::InvalidQwenShape)?;
let (end, first) = (call.cell0 + call.tokens.len(), call.cell0 + staged.r0);
let first_page = first / 4;
let (pages, mut changed) = Self::prepare_pages(call.prior, end, first_page)?;
if cancelled() {
return Ok(DraftKvOutcome::Cancelled);
}
Self::restore_ring(workspace, ring, call.prior)?;
if let Some(outcome) = self.record_each(rows, workspace, ring, call, (staged, embedding), cancelled)? {
return Ok(outcome);
}
Self::read_back(ring, &mut changed, first_page)?;
Ok(Self::finish(ring, pages, changed, (first, end, generation)))
}
fn record_each(
&mut self,
rows: &mut OriginalPromptRows<'_, '_, '_>,
workspace: &mut NativeBatchWorkspace<'ctx>,
ring: &mut MtpOriginalInt8<'ctx>,
call: &Call<'_>,
operands: (&Staged, &OriginalMtpEmbedding<'_, '_>),
cancelled: &mut impl FnMut() -> bool,
) -> Result<Option<DraftKvOutcome>> {
let (staged, embedding) = operands;
let len = call.tokens.len();
for b0 in (staged.r0..len).step_by(staged.r.b) {
let blk = Block { st: staged, nb: staged.r.b.min(len - b0), b0, c0: call.cell0 + b0 };
crate::bringup_trace!("DBG prefill.record: block b0={b0} nb={} c0={}", blk.nb, blk.c0);
if cancelled() {
return Ok(Some(DraftKvOutcome::Cancelled));
}
let (kc, vc) = self.compute_block(rows, workspace, &blk, (call, embedding))?;
if cancelled() {
return Ok(Some(DraftKvOutcome::Cancelled));
}
self.append_block(rows, workspace, ring, &blk, (kc, vc))?;
if cancelled() {
return Ok(Some(DraftKvOutcome::Cancelled));
}
}
crate::bringup_trace!("DBG prefill.record: overlap checks ok");
let generation = ring.generation.checked_add(1).ok_or(Error::InvalidQwenShape)?;
let end = cell0 + tokens.len();
let first = cell0 + r0;
let first_page = first / 4;
Ok(None)
}
/// The pages below the first needed cell are shared with `prior`; the others are zeroed and filled by the blocks.
pub(in super::super) fn prepare_pages(
prior: &MtpInt8Snapshot,
end: usize,
first_page: usize,
) -> Result<(Vec<Rc<Page>>, Vec<PageRuns>)> {
let page_count = end.div_ceil(4);
let mut pages = Vec::new();
pages.try_reserve_exact(page_count).map_err(|_| Error::HostAllocation)?;
@@ -177,20 +311,28 @@ impl<'ctx> OriginalMtpPrefill<'ctx> {
continue;
}
}
let mut runs: [Vec<u8>; 4] = std::array::from_fn(|_| Vec::new());
for (i, n) in PAGE_BYTES.into_iter().enumerate() {
runs[i] = zero_bytes(n)?;
}
let runs = Self::zero_runs()?;
if p < first_page {
pages.push(Rc::new(Page { runs: runs.map(Vec::into_boxed_slice) }));
} else {
changed.push(runs);
}
}
if cancelled() {
return Ok(DraftKvOutcome::Cancelled);
Ok((pages, changed))
}
fn zero_runs() -> Result<PageRuns> {
let mut runs: PageRuns = std::array::from_fn(|_| Vec::new());
for (i, n) in PAGE_BYTES.into_iter().enumerate() {
runs[i] = zero_bytes(n)?;
}
// Genuine idle dependency before this stream can mutate the real drafter KV.
Ok(runs)
}
/// Genuine idle dependency before this stream can mutate the real drafter KV.
fn restore_ring(
workspace: &mut NativeBatchWorkspace<'ctx>,
ring: &mut MtpOriginalInt8<'ctx>,
prior: &MtpInt8Snapshot,
) -> Result<()> {
crate::bringup_trace!("DBG prefill.record: pages ready, ring.execute(idle)");
ring.execute(workspace, Vec::new()).map_err(|e| {
crate::bringup_trace!("DBG prefill.record: ring.execute err {e:?}");
@@ -202,345 +344,24 @@ impl<'ctx> OriginalMtpPrefill<'ctx> {
})?;
crate::bringup_trace!("DBG prefill.record: ring restored");
ring.current = None;
for b0 in (r0..tokens.len()).step_by(r.b) {
let nb = r.b.min(tokens.len() - b0);
let c0 = cell0 + b0;
crate::bringup_trace!("DBG prefill.record: block b0={b0} nb={nb} c0={c0}");
if cancelled() {
return Ok(DraftKvOutcome::Cancelled);
}
let mut commands = Vec::new();
commands.try_reserve_exact(80).map_err(|_| Error::HostAllocation)?;
let mut tk = zero_bytes(nb * 4)?;
for (dst, t) in tk.chunks_exact_mut(4).zip(&tokens[b0..b0 + nb]) {
dst.copy_from_slice(&t.to_le_bytes());
}
let mut bounds = zero_bytes(16)?;
for (dst, v) in bounds.chunks_exact_mut(4).zip([0, nb as i32, 0, (nb * 4) as i32]) {
dst.copy_from_slice(&v.to_le_bytes());
}
Self::kernel(
&mut commands,
0,
9,
[(nb * 4).div_ceil(256) as u32, 1, 1],
[256, 1, 1],
0,
vec![A::U64(r.address(18, nb * 16)?), A::I32((nb * 4) as i32)],
)?;
let emb = r.address(0, nb * 10240)?;
let tok = r.address(16, nb * 4)?;
match embedding.kind {
EmbeddingKind::Native { kind, row_bytes, .. } => Self::kernel(
&mut commands,
1,
0,
[10, nb as u32, 1],
[32, 1, 1],
0,
vec![
A::I32(kind),
A::U64(eh.qwen_address()),
A::U64(row_bytes as u64),
A::U64(tok),
A::I64(2560),
A::U64(emb),
],
)?,
EmbeddingKind::Compressed { bits, bias, group, codes, scales, offsets, .. } => Self::kernel(
&mut commands,
0,
5,
[10, nb as u32, 1],
[256, 1, 1],
0,
vec![
A::U64(eh.qwen_address()),
A::U64(eh.qwen_address() + codes as u64),
A::U64(if offsets { eh.qwen_address() + (codes + scales) as u64 } else { 0 }),
A::U64(tok),
A::I64(2560),
A::I32(bits),
A::I32(bias),
A::I32(group as i32),
A::U64((2560 / (8 / bits)) as u64),
A::U64((2560 / group) as u64),
A::U64(emb),
],
)?,
}
self.finite(&mut commands, emb, nb * 2560, 0)?;
Self::kernel(
&mut commands,
0,
0,
[nb as u32, 1, 1],
[256, 1, 1],
0,
vec![A::U64(emb), A::U64(wh[0].qwen_address()), A::I64(2560), A::I64(2560), A::F32(1e-6)],
)?;
self.finite(&mut commands, emb, nb * 2560, 1)?;
let e2 = r.address(1, nb * 10240)?;
self.project(&mut commands, &r, emb, wh[1].qwen_address(), e2, nb, 2560, 0, 2)?;
self.finite(&mut commands, e2, nb * 2560, 2)?;
let hn = r.address(3, nb * 40960)?;
let h2 = r.address(4, nb * 40960)?;
commands.push(Cmd::Copy {
dst: hn,
src: rh.checked_subspan(rbytes, b0 * 40960, nb * 40960)?.qwen_address(),
bytes: nb * 40960,
});
Self::kernel(
&mut commands,
0,
0,
[nb as u32, 1, 1],
[256, 1, 1],
0,
vec![A::U64(hn), A::U64(wh[2].qwen_address()), A::I64(10240), A::I64(10240), A::F32(1e-6)],
)?;
self.finite(&mut commands, hn, nb * 10240, 3)?;
self.project(&mut commands, &r, hn, wh[3].qwen_address(), h2, nb * 4, 2560, 1, 4)?;
self.finite(&mut commands, h2, nb * 10240, 4)?;
let rm = r.address(5, nb * 40960)?;
let gated = r.address(6, nb * 40960)?;
let xn = r.address(8, nb * 20480)?;
let lo = r.address(9, nb * 1280)?;
let lo16 = r.address(10, nb * 640)?;
let grs = r.address(11, nb * 16)?;
let mixed = r.address(12, nb * 10240)?;
let mixedh = r.address(13, nb * 5120)?;
Self::kernel(
&mut commands,
0,
4,
[40, nb as u32, 1],
[256, 1, 1],
0,
vec![A::U64(h2), A::U64(e2), A::U64(rm), A::I64(2560), A::I32(4)],
)?;
self.finite(&mut commands, rm, nb * 10240, 5)?;
Self::kernel(
&mut commands,
0,
1,
[(nb * 4) as u32, 1, 1],
[256, 1, 1],
0,
vec![A::U64(rm), A::U64(wh[4].qwen_address()), A::F32(1e-6), A::U64(grs), A::U64(xn), A::U64(0)],
)?;
self.finite(&mut commands, grs, nb * 4, 6)?;
Self::kernel(
&mut commands,
0,
12,
[(nb * 10240).div_ceil(256) as u32, 1, 1],
[256, 1, 1],
0,
vec![
A::U64(rm),
A::U64(grs),
A::U64(wh[4].qwen_address()),
A::U64(self.status(6)?.qwen_address()),
A::I64(nb as i64),
],
)?;
Self::kernel(
&mut commands,
0,
14,
[(nb * 10240).div_ceil(256) as u32, 1, 1],
[256, 1, 1],
0,
vec![A::U64(xn), A::I32((nb * 10240) as i32), A::U64(self.status(6)?.qwen_address())],
)?;
commands.push(Cmd::Gemm {
x: r.handle(8, nb * 20480)?,
w: wh[5],
y: r.handle(9, nb * 1280)?,
rows: nb as i32,
n: 320,
k: 10240,
alpha: 1.0,
beta: 0.0,
});
self.finite(&mut commands, lo, nb * 320, 7)?;
Self::kernel(
&mut commands,
0,
2,
[(nb * 320).div_ceil(256) as u32, 1, 1],
[256, 1, 1],
0,
vec![A::U64(lo), A::U64(lo16), A::U64(0), A::I64((nb * 320) as i64)],
)?;
Self::kernel(
&mut commands,
0,
13,
[(nb * 320).div_ceil(256) as u32, 1, 1],
[256, 1, 1],
0,
vec![A::U64(lo), A::U64(self.status(8)?.qwen_address()), A::I64(nb as i64)],
)?;
Self::kernel(
&mut commands,
0,
14,
[(nb * 320).div_ceil(256) as u32, 1, 1],
[256, 1, 1],
0,
vec![A::U64(lo16), A::I32((nb * 320) as i32), A::U64(self.status(8)?.qwen_address())],
)?;
commands.push(Cmd::Gemm {
x: r.handle(10, nb * 640)?,
w: wh[6],
y: r.handle(6, nb * 40960)?,
rows: nb as i32,
n: 10240,
k: 320,
alpha: 1.0,
beta: 0.0,
});
self.finite(&mut commands, gated, nb * 10240, 9)?;
Self::kernel(
&mut commands,
0,
3,
[(nb * 2560).div_ceil(256) as u32, 1, 1],
[256, 1, 1],
0,
vec![
A::U64(rm),
A::U64(grs),
A::U64(wh[4].qwen_address()),
A::U64(gated),
A::U64(mixed),
A::U64(0),
A::I64(nb as i64),
A::U64(mixedh),
A::U64(0),
],
)?;
Self::kernel(
&mut commands,
0,
15,
[(nb * 10240).div_ceil(256) as u32, 1, 1],
[256, 1, 1],
0,
vec![
A::U64(rm),
A::U64(grs),
A::U64(wh[4].qwen_address()),
A::U64(gated),
A::U64(self.status(10)?.qwen_address()),
A::I64(nb as i64),
],
)?;
self.finite(&mut commands, mixed, nb * 2560, 10)?;
let kc = r.address(14, nb * 2048)?;
let vc = r.address(15, nb * 2048)?;
self.project(&mut commands, &r, mixed, wh[7].qwen_address(), kc, nb, 512, 0, 11)?;
self.finite(&mut commands, kc, nb * 512, 11)?;
self.project(&mut commands, &r, mixed, wh[8].qwen_address(), vc, nb, 512, 0, 12)?;
self.finite(&mut commands, vc, nb * 512, 12)?;
Self::kernel(
&mut commands,
0,
0,
[(nb * 2) as u32, 1, 1],
[256, 1, 1],
0,
vec![A::U64(kc), A::U64(wh[9].qwen_address()), A::I64(256), A::I64(256), A::F32(1e-6)],
)?;
self.finite(&mut commands, kc, nb * 512, 13)?;
Self::kernel(
&mut commands,
0,
6,
[(nb * 2) as u32, 1, 1],
[32, 1, 1],
0,
vec![
A::U64(kc),
A::I64(2),
A::I64(256),
A::I64(512),
A::I64(c0 as i64),
A::F32(policy.theta_scale),
A::F32(policy.freq_scale),
A::F32(policy.corr_low),
A::F32(policy.corr_high),
A::F32(policy.ext_factor),
A::F32(policy.mscale),
A::U64(0),
A::Words3([0; 3]),
],
)?;
self.finite(&mut commands, kc, nb * 512, 14)?;
self.run(rows, workspace, commands, vec![(r.handle(16, nb * 4)?, tk), (r.handle(19, 16)?, bounds)])?;
if cancelled() {
return Ok(DraftKvOutcome::Cancelled);
}
let mapped = ring.mapped()?;
let mut host = [0u64; 8];
for (i, n) in HOST_RUNS.into_iter().enumerate() {
host[i + 2] = mapped.address(HOST_OFFSETS[i], n)?;
}
let mut append = Vec::new();
append.try_reserve_exact(2).map_err(|_| Error::HostAllocation)?;
Self::kernel(
&mut append,
0,
7,
[nb as u32, 2, 8],
[64, 1, 1],
0,
vec![
A::U64(kc),
A::U64(vc),
A::I64(c0 as i64),
A::U64(ring.address(4)?),
A::I64(4),
A::U64(0),
A::U64(0),
A::U64(ring.address(0)?),
A::U64(ring.address(1)?),
A::U64(ring.address(2)?),
A::U64(ring.address(3)?),
A::Words8(host),
A::Words8([0; 8]),
],
)?;
Self::kernel(
&mut append,
0,
10,
[64, 1, 1],
[256, 1, 1],
0,
vec![
A::U64(ring.address(2)?),
A::U64(ring.address(3)?),
A::U64(ring.address(4)?),
A::I64(c0 as i64),
A::I32(nb as i32),
A::U64(self.status(15)?.qwen_address()),
],
)?;
self.run(rows, workspace, append, Vec::new())?;
if cancelled() {
return Ok(DraftKvOutcome::Cancelled);
}
}
Ok(())
}
fn read_back(ring: &MtpOriginalInt8<'ctx>, changed: &mut [PageRuns], first_page: usize) -> Result<()> {
let mapped = ring.mapped()?;
for (p, runs) in changed.iter_mut().enumerate() {
for (i, n) in PAGE_BYTES.into_iter().enumerate() {
mapped.read_into(HOST_OFFSETS[i] + (first_page + p) * n, &mut runs[i])?;
}
}
drop(mapped);
Ok(())
}
pub(in super::super) fn finish(
ring: &mut MtpOriginalInt8<'ctx>,
mut pages: Vec<Rc<Page>>,
changed: Vec<PageRuns>,
range: (usize, usize, u64),
) -> DraftKvOutcome {
let (first, end, generation) = range;
for runs in changed {
pages.push(Rc::new(Page { runs: runs.map(Vec::into_boxed_slice) }));
}
@@ -552,6 +373,6 @@ impl<'ctx> OriginalMtpPrefill<'ctx> {
}));
ring.current = Some(snapshot.clone());
ring.generation = generation;
Ok(DraftKvOutcome::Completed(CompletedDraftKv { snapshot, first_materialized: first, end, generation }))
DraftKvOutcome::Completed(CompletedDraftKv { snapshot, first_materialized: first, end, generation })
}
}
@@ -0,0 +1,284 @@
//! Commands of one block of `OriginalMtpPrefill::record` (STRA-338): the embedding, hidden, GR and K/V phases are
//! recorded in the order of the former single function, then run; the append kernels follow in `append_block`.
#[allow(unused_imports)]
use super::*;
impl<'ctx> OriginalMtpPrefill<'ctx> {
/// `Self::kernel` for this program: no dynamic shared memory and `block` threads in x.
fn kernel1(
cmds: &mut Vec<Cmd>,
asset: usize,
index: usize,
grid: [u32; 3],
block: u32,
args: Vec<A>,
) -> Result<()> {
Self::kernel(cmds, asset, index, grid, [block, 1, 1], 0, args)
}
fn gemm(x: BufferHandle, w: BufferHandle, y: BufferHandle, shape: [usize; 3]) -> Cmd {
let [rows, n, k] = shape;
Cmd::Gemm { x, w, y, rows: rows as i32, n: n as i32, k: k as i32, alpha: 1.0, beta: 0.0 }
}
/// Records the block, uploads its token ids and bounds, and runs it; returns the K and V addresses.
pub(in super::super) fn compute_block(
&mut self,
rows: &mut OriginalPromptRows<'_, '_, '_>,
workspace: &mut NativeBatchWorkspace<'ctx>,
blk: &Block<'_>,
operands: (&Call<'_>, &OriginalMtpEmbedding<'_, '_>),
) -> Result<(u64, u64)> {
let (call, embedding) = operands;
let mut commands = Vec::new();
commands.try_reserve_exact(80).map_err(|_| Error::HostAllocation)?;
let (tk, bounds) = Self::block_inputs(blk, call.tokens)?;
let e2 = self.embed_phase(&mut commands, blk, embedding)?;
let h2 = self.hidden_phase(&mut commands, blk)?;
let mixed = self.gr_phase(&mut commands, blk, (h2, e2))?;
let (kc, vc) = self.kv_phase(&mut commands, blk, mixed, call.policy)?;
let (r, nb) = (&blk.st.r, blk.nb);
let staging = vec![(r.handle(16, nb * 4)?, tk), (r.handle(19, 16)?, bounds)];
self.run(rows, workspace, commands, staging)?;
Ok((kc, vc))
}
fn block_inputs(blk: &Block<'_>, tokens: &[i32]) -> Result<(Vec<u8>, Vec<u8>)> {
let nb = blk.nb;
let mut tk = zero_bytes(nb * 4)?;
for (dst, t) in tk.chunks_exact_mut(4).zip(&tokens[blk.b0..blk.b0 + nb]) {
dst.copy_from_slice(&t.to_le_bytes());
}
let mut bounds = zero_bytes(16)?;
for (dst, v) in bounds.chunks_exact_mut(4).zip([0, nb as i32, 0, (nb * 4) as i32]) {
dst.copy_from_slice(&v.to_le_bytes());
}
Ok((tk, bounds))
}
/// Token ids, embedding rows, their RMS norm and the projection of the embedding half; returns that projection.
fn embed_phase(
&self,
cmds: &mut Vec<Cmd>,
blk: &Block<'_>,
embedding: &OriginalMtpEmbedding<'_, '_>,
) -> Result<u64> {
let (r, nb, wh) = (&blk.st.r, blk.nb, &blk.st.wh);
let emb = self.embed_rows(cmds, blk, embedding)?;
let e2 = r.address(1, nb * 10240)?;
self.project(cmds, r, emb, wh[1].qwen_address(), e2, nb, 2560, 0, 2)?;
self.finite(cmds, e2, nb * 2560, 2)?;
Ok(e2)
}
fn embed_rows(
&self,
cmds: &mut Vec<Cmd>,
blk: &Block<'_>,
embedding: &OriginalMtpEmbedding<'_, '_>,
) -> Result<u64> {
let (r, nb, wh) = (&blk.st.r, blk.nb, &blk.st.wh);
let iota = vec![A::U64(r.address(18, nb * 16)?), A::I32((nb * 4) as i32)];
Self::kernel1(cmds, 0, 9, [(nb * 4).div_ceil(256) as u32, 1, 1], 256, iota)?;
let emb = r.address(0, nb * 10240)?;
let tok = r.address(16, nb * 4)?;
Self::lookup(cmds, blk, &embedding.kind, (tok, emb))?;
self.finite(cmds, emb, nb * 2560, 0)?;
let norm = vec![A::U64(emb), A::U64(wh[0].qwen_address()), A::I64(2560), A::I64(2560), A::F32(1e-6)];
Self::kernel1(cmds, 0, 0, [nb as u32, 1, 1], 256, norm)?;
self.finite(cmds, emb, nb * 2560, 1)?;
Ok(emb)
}
fn lookup(cmds: &mut Vec<Cmd>, blk: &Block<'_>, kind: &EmbeddingKind, io: (u64, u64)) -> Result<()> {
let (eh, nb) = (blk.st.eh.qwen_address(), blk.nb);
match *kind {
EmbeddingKind::Native { kind, row_bytes, .. } => Self::lookup_native(cmds, nb, (kind, row_bytes), (eh, io)),
EmbeddingKind::Compressed { bits, bias, group, codes, scales, offsets, .. } => {
let (tok, emb) = io;
let offsets = if offsets { eh + (codes + scales) as u64 } else { 0 };
let args = vec![
A::U64(eh),
A::U64(eh + codes as u64),
A::U64(offsets),
A::U64(tok),
A::I64(2560),
A::I32(bits),
A::I32(bias),
A::I32(group as i32),
A::U64((2560 / (8 / bits)) as u64),
A::U64((2560 / group) as u64),
A::U64(emb),
];
Self::kernel1(cmds, 0, 5, [10, nb as u32, 1], 256, args)
}
}
}
fn lookup_native(cmds: &mut Vec<Cmd>, nb: usize, format: (i32, usize), at: (u64, (u64, u64))) -> Result<()> {
let ((kind, row_bytes), (eh, (tok, emb))) = (format, at);
let args = vec![A::I32(kind), A::U64(eh), A::U64(row_bytes as u64), A::U64(tok), A::I64(2560), A::U64(emb)];
Self::kernel1(cmds, 1, 0, [10, nb as u32, 1], 32, args)
}
/// The hidden state of the main model: copied from the residual, normed and projected; returns the projection.
fn hidden_phase(&self, cmds: &mut Vec<Cmd>, blk: &Block<'_>) -> Result<u64> {
let (st, r, nb) = (blk.st, &blk.st.r, blk.nb);
let hn = r.address(3, nb * 40960)?;
let h2 = r.address(4, nb * 40960)?;
let src = st.rh.checked_subspan(st.rbytes, blk.b0 * 40960, nb * 40960)?.qwen_address();
cmds.push(Cmd::Copy { dst: hn, src, bytes: nb * 40960 });
let norm = vec![A::U64(hn), A::U64(st.wh[2].qwen_address()), A::I64(10240), A::I64(10240), A::F32(1e-6)];
Self::kernel1(cmds, 0, 0, [nb as u32, 1, 1], 256, norm)?;
self.finite(cmds, hn, nb * 10240, 3)?;
self.project(cmds, r, hn, st.wh[3].qwen_address(), h2, nb * 4, 2560, 1, 4)?;
self.finite(cmds, h2, nb * 10240, 4)?;
Ok(h2)
}
/// The GR branch over the mixed state; returns the address of its mixed output.
fn gr_phase(&self, cmds: &mut Vec<Cmd>, blk: &Block<'_>, hidden: (u64, u64)) -> Result<u64> {
let g = GrBufs::new(&blk.st.r, blk.nb)?;
self.gr_norm(cmds, blk, &g, hidden)?;
self.gr_down(cmds, blk, &g)?;
self.gr_up(cmds, blk, &g)?;
Ok(g.mixed)
}
fn gr_norm(&self, cmds: &mut Vec<Cmd>, blk: &Block<'_>, g: &GrBufs, hidden: (u64, u64)) -> Result<()> {
let (nb, wh4) = (blk.nb, blk.st.wh[4].qwen_address());
let broadcast = vec![A::U64(hidden.0), A::U64(hidden.1), A::U64(g.rm), A::I64(2560), A::I32(4)];
Self::kernel1(cmds, 0, 4, [40, nb as u32, 1], 256, broadcast)?;
self.finite(cmds, g.rm, nb * 10240, 5)?;
let norm = vec![A::U64(g.rm), A::U64(wh4), A::F32(1e-6), A::U64(g.grs), A::U64(g.xn), A::U64(0)];
Self::kernel1(cmds, 0, 1, [(nb * 4) as u32, 1, 1], 256, norm)?;
self.finite(cmds, g.grs, nb * 4, 6)?;
let grid = [(nb * 10240).div_ceil(256) as u32, 1, 1];
let scan =
vec![A::U64(g.rm), A::U64(g.grs), A::U64(wh4), A::U64(self.status(6)?.qwen_address()), A::I64(nb as i64)];
Self::kernel1(cmds, 0, 12, grid, 256, scan)?;
let args = vec![A::U64(g.xn), A::I32((nb * 10240) as i32), A::U64(self.status(6)?.qwen_address())];
Self::kernel1(cmds, 0, 14, grid, 256, args)
}
fn gr_down(&self, cmds: &mut Vec<Cmd>, blk: &Block<'_>, g: &GrBufs) -> Result<()> {
let (r, nb) = (&blk.st.r, blk.nb);
cmds.push(Self::gemm(r.handle(8, nb * 20480)?, blk.st.wh[5], r.handle(9, nb * 1280)?, [nb, 320, 10240]));
self.finite(cmds, g.lo, nb * 320, 7)?;
let grid = [(nb * 320).div_ceil(256) as u32, 1, 1];
let round = vec![A::U64(g.lo), A::U64(g.lo16), A::U64(0), A::I64((nb * 320) as i64)];
Self::kernel1(cmds, 0, 2, grid, 256, round)?;
let scan = vec![A::U64(g.lo), A::U64(self.status(8)?.qwen_address()), A::I64(nb as i64)];
Self::kernel1(cmds, 0, 13, grid, 256, scan)?;
let args = vec![A::U64(g.lo16), A::I32((nb * 320) as i32), A::U64(self.status(8)?.qwen_address())];
Self::kernel1(cmds, 0, 14, grid, 256, args)
}
fn gr_up(&self, cmds: &mut Vec<Cmd>, blk: &Block<'_>, g: &GrBufs) -> Result<()> {
let (r, nb, wh4) = (&blk.st.r, blk.nb, blk.st.wh[4].qwen_address());
cmds.push(Self::gemm(r.handle(10, nb * 640)?, blk.st.wh[6], r.handle(6, nb * 40960)?, [nb, 10240, 320]));
self.finite(cmds, g.gated, nb * 10240, 9)?;
let mix = vec![
A::U64(g.rm),
A::U64(g.grs),
A::U64(wh4),
A::U64(g.gated),
A::U64(g.mixed),
A::U64(0),
A::I64(nb as i64),
A::U64(g.mixedh),
A::U64(0),
];
Self::kernel1(cmds, 0, 3, [(nb * 2560).div_ceil(256) as u32, 1, 1], 256, mix)?;
let grid = [(nb * 10240).div_ceil(256) as u32, 1, 1];
let status = A::U64(self.status(10)?.qwen_address());
let scan = vec![A::U64(g.rm), A::U64(g.grs), A::U64(wh4), A::U64(g.gated), status, A::I64(nb as i64)];
Self::kernel1(cmds, 0, 15, grid, 256, scan)?;
self.finite(cmds, g.mixed, nb * 2560, 10)
}
/// K and V projections of the mixed state, K norm and rope; returns their addresses.
fn kv_phase(&self, cmds: &mut Vec<Cmd>, blk: &Block<'_>, mixed: u64, policy: &DraftKvPolicy) -> Result<(u64, u64)> {
let (r, nb, wh) = (&blk.st.r, blk.nb, &blk.st.wh);
let kc = r.address(14, nb * 2048)?;
let vc = r.address(15, nb * 2048)?;
self.project(cmds, r, mixed, wh[7].qwen_address(), kc, nb, 512, 0, 11)?;
self.finite(cmds, kc, nb * 512, 11)?;
self.project(cmds, r, mixed, wh[8].qwen_address(), vc, nb, 512, 0, 12)?;
self.finite(cmds, vc, nb * 512, 12)?;
self.k_norm_rope(cmds, blk, kc, policy)?;
Ok((kc, vc))
}
fn k_norm_rope(&self, cmds: &mut Vec<Cmd>, blk: &Block<'_>, kc: u64, policy: &DraftKvPolicy) -> Result<()> {
let nb = blk.nb;
let norm = vec![A::U64(kc), A::U64(blk.st.wh[9].qwen_address()), A::I64(256), A::I64(256), A::F32(1e-6)];
Self::kernel1(cmds, 0, 0, [(nb * 2) as u32, 1, 1], 256, norm)?;
self.finite(cmds, kc, nb * 512, 13)?;
let rope = vec![
A::U64(kc),
A::I64(2),
A::I64(256),
A::I64(512),
A::I64(blk.c0 as i64),
A::F32(policy.theta_scale),
A::F32(policy.freq_scale),
A::F32(policy.corr_low),
A::F32(policy.corr_high),
A::F32(policy.ext_factor),
A::F32(policy.mscale),
A::U64(0),
A::Words3([0; 3]),
];
Self::kernel1(cmds, 0, 6, [(nb * 2) as u32, 1, 1], 32, rope)?;
self.finite(cmds, kc, nb * 512, 14)
}
/// Appends the block's K and V to the real drafter KV ring and runs the append kernels.
pub(in super::super) fn append_block(
&mut self,
rows: &mut OriginalPromptRows<'_, '_, '_>,
workspace: &mut NativeBatchWorkspace<'ctx>,
ring: &MtpOriginalInt8<'ctx>,
blk: &Block<'_>,
kv: (u64, u64),
) -> Result<()> {
let mapped = ring.mapped()?;
let mut host = [0u64; 8];
for (i, n) in HOST_RUNS.into_iter().enumerate() {
host[i + 2] = mapped.address(HOST_OFFSETS[i], n)?;
}
let ra = Self::ring_addresses(ring)?;
let mut append = Vec::new();
append.try_reserve_exact(2).map_err(|_| Error::HostAllocation)?;
self.append_kernels(&mut append, blk, (kv, ra, host))?;
self.run(rows, workspace, append, Vec::new())
}
fn append_kernels(
&self,
append: &mut Vec<Cmd>,
blk: &Block<'_>,
operands: ((u64, u64), [u64; 5], [u64; 8]),
) -> Result<()> {
let (kv, ra, host) = operands;
let args = Self::append_args(blk, kv, ra, host);
Self::kernel(append, 0, 7, [blk.nb as u32, 2, 8], [64, 1, 1], 0, args)?;
let status = self.status(15)?.qwen_address();
let commit = vec![
A::U64(ra[2]),
A::U64(ra[3]),
A::U64(ra[4]),
A::I64(blk.c0 as i64),
A::I32(blk.nb as i32),
A::U64(status),
];
Self::kernel1(append, 0, 10, [64, 1, 1], 256, commit)
}
fn ring_addresses(ring: &MtpOriginalInt8<'ctx>) -> Result<[u64; 5]> {
Ok([ring.address(0)?, ring.address(1)?, ring.address(2)?, ring.address(3)?, ring.address(4)?])
}
/// Literal step append kernel and actual private step record, not batched prompt arithmetic.
fn append_args(blk: &Block<'_>, kv: (u64, u64), ra: [u64; 5], host: [u64; 8]) -> Vec<A> {
vec![
A::U64(kv.0),
A::U64(kv.1),
A::I64(blk.c0 as i64),
A::U64(ra[4]),
A::I64(4),
A::U64(0),
A::U64(0),
A::U64(ra[0]),
A::U64(ra[1]),
A::U64(ra[2]),
A::U64(ra[3]),
A::Words8(host),
A::Words8([0; 8]),
]
}
}
@@ -0,0 +1,115 @@
//! Operands of `OriginalMtpPrefill::record` (STRA-338): the call, the admission and staging results, and the block.
#[allow(unused_imports)]
use super::*;
/// Host copies of the four runs of one 4-cell page.
pub(in super::super) type PageRuns = [Vec<u8>; 4];
/// Byte extents of the ten weights, in the order of `weight_refs`: embedding norm and fc, hidden norm and fc, GR norm,
/// down and up, key, value and key norm.
pub(in super::super) const WEIGHT_EXTENTS: [usize; 10] = [
10240,
2560 * 80 * 34,
40960,
2560 * 80 * 34,
40960,
320 * 10240 * 2,
10240 * 320 * 2,
512 * 80 * 34,
512 * 80 * 34,
1024,
];
/// What the caller of `record` supplies besides the buffers.
#[derive(Clone, Copy)]
pub(in super::super) struct Call<'a> {
pub(in super::super) prior: &'a MtpInt8Snapshot,
pub(in super::super) tokens: &'a [i32],
pub(in super::super) cell0: usize,
pub(in super::super) first_needed: usize,
pub(in super::super) policy: &'a DraftKvPolicy,
}
/// The outcome of the checks that precede any device work: run from row `r0`, or finish with an outcome.
pub(in super::super) enum Admit {
Run(usize),
Done(DraftKvOutcome),
}
/// The staged operands, or the outcome that ends the call before the first block.
pub(in super::super) enum Stage {
Ready(Staged),
Done(DraftKvOutcome),
}
/// The prompt region and the device operands every block reads.
pub(in super::super) struct Staged {
pub(in super::super) r: Region,
pub(in super::super) r0: usize,
pub(in super::super) wh: [BufferHandle; 10],
pub(in super::super) eh: BufferHandle,
pub(in super::super) rh: BufferHandle,
pub(in super::super) rbytes: usize,
pub(in super::super) table_bytes: usize,
}
/// One block of `nb` tokens from token `b0`, whose first cell is `c0`.
pub(in super::super) struct Block<'a> {
pub(in super::super) st: &'a Staged,
pub(in super::super) nb: usize,
pub(in super::super) b0: usize,
pub(in super::super) c0: usize,
}
/// The GR scratch addresses of a block.
pub(in super::super) struct GrBufs {
pub(in super::super) rm: u64,
pub(in super::super) gated: u64,
pub(in super::super) xn: u64,
pub(in super::super) lo: u64,
pub(in super::super) lo16: u64,
pub(in super::super) grs: u64,
pub(in super::super) mixed: u64,
pub(in super::super) mixedh: u64,
}
impl GrBufs {
pub(in super::super) fn new(r: &Region, nb: usize) -> Result<Self> {
Ok(Self {
rm: r.address(5, nb * 40960)?,
gated: r.address(6, nb * 40960)?,
xn: r.address(8, nb * 20480)?,
lo: r.address(9, nb * 1280)?,
lo16: r.address(10, nb * 640)?,
grs: r.address(11, nb * 16)?,
mixed: r.address(12, nb * 10240)?,
mixedh: r.address(13, nb * 5120)?,
})
}
}
impl Staged {
/// The serve ring is built from prepared spans of the drafter's shared region, so buffers 0..5 are not separately
/// owned DeviceBuffers; compare by address (ring.address works for both layouts).
pub(in super::super) fn check_ring(
&self,
ring: &MtpOriginalInt8<'_>,
region: BufferHandle,
region_bytes: usize,
) -> Result<()> {
for i in 0..5 {
let hv = ring.address(i)?;
let n = ring.sizes[i];
let ov = |o: u64, on: usize| hv < o.saturating_add(on as u64) && o < hv.saturating_add(n as u64);
if ov(region.qwen_address(), region_bytes)
|| ov(self.rh.qwen_address(), self.rbytes)
|| self.wh.iter().zip(WEIGHT_EXTENTS).any(|(w, n2)| ov(w.qwen_address(), n2))
|| ov(self.eh.qwen_address(), self.table_bytes)
{
return Err(Error::OutputAliasesInput);
}
}
Ok(())
}
}
@@ -13,3 +13,11 @@ mod impl_originalmtpscalarprefill_3;
mod impl_originalmtpscalarprefill_4;
#[path = "impl_originalmtpscalarprefill/impl_originalmtpscalarprefill_5.rs"]
mod impl_originalmtpscalarprefill_5;
#[path = "impl_originalmtpscalarprefill/impl_originalmtpscalarprefill_6.rs"]
mod impl_originalmtpscalarprefill_6;
#[path = "impl_originalmtpscalarprefill/impl_originalmtpscalarprefill_7.rs"]
mod impl_originalmtpscalarprefill_7;
#[path = "impl_originalmtpscalarprefill/impl_originalmtpscalarprefill_8.rs"]
mod impl_originalmtpscalarprefill_8;
#[allow(unused_imports)]
use impl_originalmtpscalarprefill_6::{Cap, GroupIo, ScalarCall, ScalarStaged};
@@ -1,8 +1,25 @@
//! Moved out of the parent module by STRA-338: impl OriginalMtpScalarPrefill (4).
//! Moved out of the parent module by STRA-338: impl OriginalMtpScalarPrefill (4). `record_impl` admits the call,
//! stages the weights and claims the policy; the group loop is in `impl_originalmtpscalarprefill_7.rs` and the capture
//! of one group in `impl_originalmtpscalarprefill_8.rs`.
#[allow(unused_imports)]
use super::*;
/// Byte extents of the eleven weights: the ten of the MTP prefill and the GR inject matrix.
const SCALAR_EXTENTS: [usize; 11] = [
10240,
2560 * 80 * 34,
40960,
2560 * 80 * 34,
40960,
320 * 10240 * 2,
10240 * 320 * 2,
512 * 80 * 34,
512 * 80 * 34,
1024,
4 * 10240 * 2,
];
impl<'ctx> OriginalMtpScalarPrefill<'ctx> {
/// Literal cached device-input or mapped-input per-T graph scheduling.
/// Unsupported storage/math branches return explicit fallback, never completion.
@@ -20,74 +37,125 @@ impl<'ctx> OriginalMtpScalarPrefill<'ctx> {
policy: &OriginalMtpScalarPolicy,
mut cancelled: impl FnMut() -> bool,
) -> Result<DraftKvOutcome> {
let kv = &policy.kv;
if kv.disabled {
return Ok(DraftKvOutcome::Fallback(DraftKvFallback::Disabled));
}
if tokens.is_empty() {
return Ok(DraftKvOutcome::Fallback(DraftKvFallback::Empty));
}
if kv.mode != 0 || kv.hybrid || kv.rotated || kv.q4 {
return Ok(DraftKvOutcome::Fallback(DraftKvFallback::UnsupportedStorage));
}
if kv.alternate_f16 {
return Ok(DraftKvOutcome::Fallback(DraftKvFallback::AlternateF16));
}
if kv.rope_table_enabled || kv.multimodal_positions {
return Ok(DraftKvOutcome::Fallback(DraftKvFallback::UnsupportedRopeTable));
}
if [kv.theta_scale, kv.freq_scale, kv.corr_low, kv.corr_high, kv.ext_factor, kv.mscale]
.iter()
.any(|x| !x.is_finite())
|| kv.theta_scale <= 0.0
|| kv.freq_scale <= 0.0
|| kv.mscale <= 0.0
{
return Err(Error::InvalidProjectionShape);
let call = ScalarCall { prior, tokens, cell0, first_needed, policy };
self.record_scalar(residual, workspace, ring, &call, retained, &mut cancelled)
}
fn record_scalar(
&mut self,
residual: &mut OriginalDeviceResidual<'_, '_, 'ctx>,
workspace: &mut NativeBatchWorkspace<'ctx>,
ring: &mut MtpOriginalInt8<'ctx>,
call: &ScalarCall<'_>,
retained: Rc<OriginalMtpRetainedScalarWeights<'ctx>>,
cancelled: &mut impl FnMut() -> bool,
) -> Result<DraftKvOutcome> {
if let Some(outcome) = Self::early_outcome(call.policy, call.tokens)? {
return Ok(outcome);
}
let (weights, embedding) = retained.loans(self.context)?;
self.validate()?;
ring.validate_original_main(self.scratch.as_ref().ok_or(Error::ContextPoisoned)?)?;
ring.validate_snapshot(prior)?;
workspace.validate_context(self.context)?;
ring.validate_context(self.context)?;
if !residual.context_matches(self.context)
|| tokens.len() != residual.rows()
|| tokens.len() > self.prompt_cap
|| cell0.checked_add(tokens.len()).is_none_or(|n| n > MTP_ORIGINAL_MAX_CELLS)
|| ring.max_t < self.max_t
{
return Err(Error::InvalidProjectionShape);
}
if tokens.iter().any(|t| *t < 0 || *t as usize >= embedding.vocab()) {
return Err(Error::InvalidProjectionShape);
}
// Original skips WHOLE groups whose end<=first_needed, not individual rows.
let first_group = (0..tokens.len())
.step_by(self.max_t)
.find(|c| cell0 + *c + self.max_t.min(tokens.len() - *c) > first_needed);
let Some(first_group) = first_group else {
self.validate_scalar(residual, workspace, ring, call, &embedding)?;
let Some(first_group) = self.first_group(call) else {
return Ok(DraftKvOutcome::Skipped);
};
let first = cell0 + first_group;
let end = cell0 + tokens.len();
let rows = residual.lease_mut();
let staged = self.stage_scalar(rows, workspace, ring, (&weights, &embedding))?;
self.claim_policy(&retained, call.prior, call.policy)?;
let operands = (&staged, &retained, &embedding);
self.record_groups(rows, workspace, ring, (call, first_group), operands, cancelled)
}
fn early_outcome(policy: &OriginalMtpScalarPolicy, tokens: &[i32]) -> Result<Option<DraftKvOutcome>> {
if let Some(fallback) = OriginalMtpPrefill::fallback_for(&policy.kv, tokens) {
return Ok(Some(DraftKvOutcome::Fallback(fallback)));
}
OriginalMtpPrefill::reject_bad_rope(&policy.kv)?;
Ok(None)
}
fn validate_scalar(
&self,
residual: &OriginalDeviceResidual<'_, '_, 'ctx>,
workspace: &NativeBatchWorkspace<'ctx>,
ring: &MtpOriginalInt8<'ctx>,
call: &ScalarCall<'_>,
embedding: &OriginalMtpEmbedding<'_, 'ctx>,
) -> Result<()> {
self.validate()?;
ring.validate_original_main(self.scratch.as_ref().ok_or(Error::ContextPoisoned)?)?;
ring.validate_snapshot(call.prior)?;
workspace.validate_context(self.context)?;
ring.validate_context(self.context)?;
if self.shape_rejected(residual, ring, call) {
return Err(Error::InvalidProjectionShape);
}
if call.tokens.iter().any(|t| *t < 0 || *t as usize >= embedding.vocab()) {
return Err(Error::InvalidProjectionShape);
}
Ok(())
}
fn shape_rejected(
&self,
residual: &OriginalDeviceResidual<'_, '_, 'ctx>,
ring: &MtpOriginalInt8<'ctx>,
call: &ScalarCall<'_>,
) -> bool {
let len = call.tokens.len();
!residual.context_matches(self.context)
|| len != residual.rows()
|| len > self.prompt_cap
|| call.cell0.checked_add(len).is_none_or(|n| n > MTP_ORIGINAL_MAX_CELLS)
|| ring.max_t < self.max_t
}
/// Original skips WHOLE groups whose end<=first_needed, not individual rows.
fn first_group(&self, call: &ScalarCall<'_>) -> Option<usize> {
let len = call.tokens.len();
(0..len).step_by(self.max_t).find(|c| call.cell0 + *c + self.max_t.min(len - *c) > call.first_needed)
}
fn stage_scalar(
&self,
rows: &OriginalPromptRows<'_, '_, '_>,
workspace: &NativeBatchWorkspace<'ctx>,
ring: &MtpOriginalInt8<'ctx>,
operands: (&OriginalMtpScalarWeights<'_, 'ctx>, &OriginalMtpEmbedding<'_, 'ctx>),
) -> Result<ScalarStaged> {
let (rh, rbytes) = rows.common_span(OriginalPromptSpan::R)?;
self.reject_input_alias(rh, rbytes)?;
self.reject_state_aliases(workspace, ring)?;
let (wh, eh) = self.stage_weights(rows, workspace, ring, operands, rh)?;
Ok(ScalarStaged { wh, eh, rh, rbytes })
}
fn reject_input_alias(&self, rh: BufferHandle, rbytes: usize) -> Result<()> {
for own in [&self.scratch, &self.records, &self.status].into_iter().flatten() {
if rh.overlaps(rbytes, own.handle.ok_or(Error::ContextPoisoned)?, own.bytes) {
return Err(Error::OutputAliasesInput);
}
}
Ok(())
}
fn reject_state_aliases(&self, workspace: &NativeBatchWorkspace<'ctx>, ring: &MtpOriginalInt8<'ctx>) -> Result<()> {
for own in [&self.scratch, &self.records, &self.status].into_iter().flatten() {
ring.reject_state_alias(own)?;
let h = own.handle.ok_or(Error::ContextPoisoned)?;
workspace.reject_alias(h, own.bytes)?;
for other in ring.buffers()?.iter().flatten() {
if h.overlaps(own.bytes, other.handle.ok_or(Error::ContextPoisoned)?, other.bytes) {
return Err(Error::OutputAliasesInput);
}
Self::reject_ring_overlap(ring, h, own.bytes)?;
}
Ok(())
}
fn reject_ring_overlap(ring: &MtpOriginalInt8<'ctx>, h: BufferHandle, bytes: usize) -> Result<()> {
for other in ring.buffers()?.iter().flatten() {
if h.overlaps(bytes, other.handle.ok_or(Error::ContextPoisoned)?, other.bytes) {
return Err(Error::OutputAliasesInput);
}
}
Ok(())
}
fn stage_weights(
&self,
rows: &OriginalPromptRows<'_, '_, '_>,
workspace: &NativeBatchWorkspace<'ctx>,
ring: &MtpOriginalInt8<'ctx>,
operands: (&OriginalMtpScalarWeights<'_, 'ctx>, &OriginalMtpEmbedding<'_, 'ctx>),
rh: BufferHandle,
) -> Result<([BufferHandle; 11], BufferHandle)> {
let (weights, embedding) = operands;
let wr = [
weights.input.embedding_norm,
weights.input.embedding_fc,
@@ -101,25 +169,17 @@ impl<'ctx> OriginalMtpScalarPrefill<'ctx> {
weights.input.key_norm,
weights.gr_inject,
];
let extents = [
10240,
2560 * 80 * 34,
40960,
2560 * 80 * 34,
40960,
320 * 10240 * 2,
10240 * 320 * 2,
512 * 80 * 34,
512 * 80 * 34,
1024,
4 * 10240 * 2,
];
let mut wh = [rh; 11];
for i in 0..11 {
wh[i] = self.external(rows, workspace, ring, wr[i], extents[i])?;
wh[i] = self.external(rows, workspace, ring, wr[i], SCALAR_EXTENTS[i])?;
}
let eh = self.external(rows, workspace, ring, embedding.table, embedding.table.bytes)?;
for i in 0..wr.len() {
Self::reject_overlapping_weights(&wh)?;
Ok((wh, eh))
}
fn reject_overlapping_weights(wh: &[BufferHandle; 11]) -> Result<()> {
let extents = SCALAR_EXTENTS;
for i in 0..wh.len() {
for j in 0..i {
if wh[i].overlaps(extents[i], wh[j], extents[j])
&& !(wh[i].qwen_address() == wh[j].qwen_address() && extents[i] == extents[j])
@@ -128,6 +188,16 @@ impl<'ctx> OriginalMtpScalarPrefill<'ctx> {
}
}
}
Ok(())
}
/// The first call pins the weights, the ring and the rope/GR policy; later calls must use the same.
fn claim_policy(
&mut self,
retained: &Rc<OriginalMtpRetainedScalarWeights<'ctx>>,
prior: &MtpInt8Snapshot,
policy: &OriginalMtpScalarPolicy,
) -> Result<()> {
let kv = &policy.kv;
let key = [
policy.gr as u32,
policy.per_group_sync as u32,
@@ -139,7 +209,7 @@ impl<'ctx> OriginalMtpScalarPrefill<'ctx> {
kv.mscale.to_bits(),
0,
];
if self.retained.as_ref().is_some_and(|old| !Rc::ptr_eq(old, &retained))
if self.retained.as_ref().is_some_and(|old| !Rc::ptr_eq(old, retained))
|| self.ring_id.as_ref().is_some_and(|id| !id.same_owner(&prior.owner_id()))
|| self.policy_key.is_some_and(|old| old != key)
{
@@ -148,340 +218,6 @@ impl<'ctx> OriginalMtpScalarPrefill<'ctx> {
self.retained = Some(retained.clone());
self.ring_id = Some(prior.owner_id());
self.policy_key = Some(key);
let generation = ring.generation.checked_add(1).ok_or(Error::InvalidQwenShape)?;
let first_page = first / 4;
let count = end.div_ceil(4);
let mut pages = Vec::new();
pages.try_reserve_exact(count).map_err(|_| Error::HostAllocation)?;
let mut changed = Vec::new();
changed.try_reserve_exact(count - first_page).map_err(|_| Error::HostAllocation)?;
for p in 0..count {
if p < first_page {
if let Some(old) = prior.0.pages.get(p) {
pages.push(old.clone());
continue;
}
}
let mut runs: [Vec<u8>; 4] = std::array::from_fn(|_| Vec::new());
for (i, n) in PAGE_BYTES.into_iter().enumerate() {
runs[i] = zero_bytes(n)?;
}
if p < first_page {
pages.push(Rc::new(Page { runs: runs.map(Vec::into_boxed_slice) }));
} else {
changed.push(runs);
}
}
// Literal prefill records [tokens n][steps4*n][positions24*n], one upload.
let mut rec = zero_bytes(tokens.len() * 29 * 4)?;
let n = tokens.len();
for (i, token) in tokens.iter().enumerate() {
let cell = cell0 + i;
rec[i * 4..i * 4 + 4].copy_from_slice(&token.to_le_bytes());
for (j, v) in [cell, cell + 1, (cell + 1) / 4, cell + 1].into_iter().enumerate() {
let off = (n + i * 4 + j) * 4;
rec[off..off + 4].copy_from_slice(&(v as i32).to_le_bytes());
}
for h in 0..24 {
let off = (n * 5 + i * 24 + h) * 4;
rec[off..off + 4].copy_from_slice(&(cell as i32).to_le_bytes());
}
}
let rb = self.records.as_ref().ok_or(Error::ContextPoisoned)?;
let rec_h = rb.handle.ok_or(Error::ContextPoisoned)?.checked_subspan(rb.bytes, 0, rec.len())?;
let mut staging = vec![(rec_h, rec)];
let mut cmds = Vec::new();
cmds.try_reserve(128).map_err(|_| Error::HostAllocation)?;
if cancelled() {
return Ok(DraftKvOutcome::Cancelled);
}
ring.execute(workspace, Vec::new())?;
ring.restore(workspace, prior)?;
ring.current = None;
if !policy.per_group_sync {
self.upload_records(&mut staging)?;
} else {
self.upload_records(&mut Vec::new())?;
}
staging.clear();
for (group, c) in (0..n).step_by(self.max_t).enumerate() {
let t = self.max_t.min(n - c);
if cell0 + c + t <= first_needed {
continue;
}
let rin = self.address(0, t * 40960)?;
let emb = self.address(2, t * 10240)?;
let en = self.address(3, t * 10240)?;
let e2 = self.address(4, t * 10240)?;
let hn = self.address(5, t * 40960)?;
let h2 = self.address(6, t * 40960)?;
let r = self.address(1, t * 40960)?;
let mixed = self.address(11, t * 10240)?;
let tok = self.address(12, t * 4)?;
let step = self.address(13, t * 16)?;
let pos = self.address(14, t * 96)?;
let mut copies = [
(tok, rec_h.qwen_address() + (c * 4) as u64, t * 4),
(step, rec_h.qwen_address() + ((n + c * 4) * 4) as u64, t * 16),
(pos, rec_h.qwen_address() + ((n * 5 + c * 24) * 4) as u64, t * 96),
(rin, rh.checked_subspan(rbytes, c * 40960, t * 40960)?.qwen_address(), t * 40960),
]
.map(|(dst, src, bytes)| ScalarCommand::Copy { dst, src, bytes });
let needs_capture = self
.graphs
.as_mut()
.ok_or(Error::ContextPoisoned)?
.find_mut(OriginalGraphKey::MtpPrefill { rows: t as u8, device_inputs: !policy.per_group_sync })?
.is_none();
if needs_capture {
// Captured per-T forward owns fixed whole scratch/status and stable arguments.
Self::kernel(
&mut cmds,
0,
11,
[1, 1, 1],
[256, 1, 1],
0,
vec![Arg::U64(self.flag(0, 0)?), Arg::I32(64)],
)?;
if policy.per_group_sync {
let mapped = self.mapped.try_borrow().map_err(|_| Error::InvalidQwenShape)?;
let m = mapped.as_ref().ok_or(Error::ContextPoisoned)?;
for (dst, offset, count) in
[(tok, 0, t), (step, self.max_t * 4, t * 4), (pos, self.max_t * 20, t * 24)]
{
Self::kernel(
&mut cmds,
3,
2,
[1, 1, 1],
[128, 1, 1],
0,
vec![Arg::U64(dst), Arg::U64(m.address(offset, count * 4)?), Arg::I32(count as i32)],
)?;
}
}
match embedding.kind {
EmbeddingKind::Native { kind, row_bytes, .. } => Self::kernel(
&mut cmds,
1,
0,
[10, t as u32, 1],
[32, 1, 1],
0,
vec![
Arg::I32(kind),
Arg::U64(eh.qwen_address()),
Arg::U64(row_bytes as u64),
Arg::U64(tok),
Arg::I64(2560),
Arg::U64(emb),
],
)?,
EmbeddingKind::Compressed { bits, bias, group, codes, scales, offsets, .. } => Self::kernel(
&mut cmds,
0,
5,
[10, t as u32, 1],
[256, 1, 1],
0,
vec![
Arg::U64(eh.qwen_address()),
Arg::U64(eh.qwen_address() + codes as u64),
Arg::U64(if offsets { eh.qwen_address() + (codes + scales) as u64 } else { 0 }),
Arg::U64(tok),
Arg::I64(2560),
Arg::I32(bits),
Arg::I32(bias),
Arg::I32(group as i32),
Arg::U64((2560 / (8 / bits)) as u64),
Arg::U64((2560 / group) as u64),
Arg::U64(emb),
],
)?,
}
self.finite(&mut cmds, emb, t * 2560, group, 0)?;
Self::kernel(
&mut cmds,
3,
0,
[t as u32, 1, 1],
[1024, 1, 1],
0,
vec![Arg::U64(emb), Arg::U64(wh[0].qwen_address()), Arg::U64(en), Arg::I32(2560), Arg::F32(1e-6)],
)?;
self.finite(&mut cmds, en, t * 2560, group, 1)?;
let q = self.address(15, 8 * 80 * 36)?;
Self::quant(&mut cmds, en, q, t)?;
self.q8_guard(&mut cmds, q, t, group, 2)?;
Self::project(&mut cmds, wh[1].qwen_address(), q, e2, t, 2560)?;
self.finite(&mut cmds, e2, t * 2560, group, 2)?;
Self::kernel(
&mut cmds,
3,
0,
[t as u32, 1, 1],
[1024, 1, 1],
0,
vec![Arg::U64(rin), Arg::U64(wh[2].qwen_address()), Arg::U64(hn), Arg::I32(10240), Arg::F32(1e-6)],
)?;
self.finite(&mut cmds, hn, t * 10240, group, 3)?;
for hc in (0..t * 4).step_by(8) {
let cols = 8.min(t * 4 - hc);
Self::quant(&mut cmds, hn + (hc * 10240) as u64, q, cols)?;
self.q8_guard(&mut cmds, q, cols, group, 4)?;
Self::project(&mut cmds, wh[3].qwen_address(), q, h2 + (hc * 10240) as u64, cols, 2560)?;
}
self.finite(&mut cmds, h2, t * 10240, group, 4)?;
Self::kernel(
&mut cmds,
0,
4,
[40, t as u32, 1],
[256, 1, 1],
0,
vec![Arg::U64(h2), Arg::U64(e2), Arg::U64(r), Arg::I64(2560), Arg::I32(4)],
)?;
self.finite(&mut cmds, r, t * 10240, group, 5)?;
self.gr(&mut cmds, t, &wh, policy)?;
self.finite(&mut cmds, self.address(9, t * 16)?, t * 4, group, 6)?;
self.finite(&mut cmds, self.address(7, t * 40960)?, t * 10240, group, 6)?;
self.finite(&mut cmds, self.address(8, t * 1280)?, t * 320, group, 7)?;
self.finite(&mut cmds, self.address(10, t * 16)?, t * 4, group, 7)?;
self.finite(&mut cmds, mixed, t * 2560, group, 8)?;
Self::quant(&mut cmds, mixed, q, t)?;
self.q8_guard(&mut cmds, q, t, group, 9)?;
let (kc, vc) = self.current_kv(ring)?;
Self::project(&mut cmds, wh[7].qwen_address(), q, kc, t, 512)?;
self.finite(&mut cmds, kc, t * 512, group, 10)?;
Self::project(&mut cmds, wh[8].qwen_address(), q, vc, t, 512)?;
self.finite(&mut cmds, vc, t * 512, group, 11)?;
for row in 0..t {
let k = kc + (row * 2048) as u64;
Self::kernel(
&mut cmds,
2,
9,
[2, 1, 1],
[256, 1, 1],
0,
vec![Arg::U64(k), Arg::U64(wh[9].qwen_address()), Arg::U64(k), Arg::I32(256), Arg::F32(1e-6)],
)?;
self.finite(&mut cmds, k, 512, group, 12)?;
Self::kernel(
&mut cmds,
3,
1,
[4, 2, 1],
[32, 1, 1],
0,
vec![
Arg::U64(k),
Arg::U64(k),
Arg::I32(2),
Arg::I32(256),
Arg::I32(64),
Arg::F32(kv.theta_scale),
Arg::F32(kv.freq_scale),
Arg::F32(kv.corr_low),
Arg::F32(kv.corr_high),
Arg::F32(kv.ext_factor),
Arg::F32(kv.mscale),
Arg::U64(pos + (row * 96) as u64),
Arg::U64(0),
Arg::Words3([0; 3]),
],
)?;
self.finite(&mut cmds, k, 512, group, 13)?;
let mut host = [0u64; 8];
host[2..6].copy_from_slice(&ring.host_addresses()?);
// Literal step append kernel and actual private step record, not batched prompt arithmetic.
Self::kernel(
&mut cmds,
5,
0,
[2, 4, 2],
[64, 1, 1],
0,
vec![
Arg::U64(ring.address(0)?),
Arg::U64(ring.address(1)?),
Arg::U64(ring.address(2)?),
Arg::U64(ring.address(3)?),
Arg::U64(ring.address(4)?),
Arg::U64(step + (row * 16) as u64),
Arg::U64(k),
Arg::U64(vc + (row * 2048) as u64),
Arg::I32(2),
Arg::I32(256),
Arg::I32(4),
Arg::U64(host[2]),
Arg::U64(host[3]),
Arg::U64(host[4]),
Arg::U64(host[5]),
],
)?;
}
Self::kernel(
&mut cmds,
3,
3,
[64, 1, 1],
[256, 1, 1],
0,
vec![
Arg::U64(ring.address(2)?),
Arg::U64(ring.address(3)?),
Arg::U64(ring.address(4)?),
Arg::U64(step),
Arg::I32(t as i32),
Arg::U64(self.flag(0, 14)?),
],
)?;
}
if cancelled() {
self.drain_graphs(rows, workspace)?;
return Ok(DraftKvOutcome::Cancelled);
}
if let Err(primary) = self.enqueue_group(
t,
group,
policy.per_group_sync,
&retained,
ring,
&mut cmds,
if policy.per_group_sync { &mut copies[3..] } else { &mut copies[..] },
&tokens[c..c + t],
cell0 + c,
) {
let drained = self.drain_graphs(rows, workspace);
return combine(Err(primary), drained);
}
cmds.clear();
if policy.per_group_sync {
self.drain_graphs(rows, workspace)?;
}
}
if !policy.per_group_sync {
self.drain_graphs(rows, workspace)?;
}
if cancelled() {
return Ok(DraftKvOutcome::Cancelled);
}
for (p, runs) in changed.iter_mut().enumerate() {
ring.read_encoded_page(first_page + p, runs)?;
}
for runs in changed {
pages.push(Rc::new(Page { runs: runs.map(Vec::into_boxed_slice) }));
}
let snapshot = MtpInt8Snapshot(Rc::new(Snapshot {
origin: ring.origin.clone(),
pages: Pages::from_vec(pages),
end,
checked: std::cell::Cell::new(false),
}));
ring.current = Some(snapshot.clone());
ring.generation = generation;
Ok(DraftKvOutcome::Completed(CompletedDraftKv { snapshot, first_materialized: first, end, generation }))
Ok(())
}
}
@@ -0,0 +1,95 @@
//! Operands of `OriginalMtpScalarPrefill::record_impl` (STRA-338): the call, the staged weights and the addresses of
//! one group of rows.
#[allow(unused_imports)]
use super::*;
/// What the caller of `record_impl` supplies besides the buffers.
pub(in super::super) struct ScalarCall<'a> {
pub(in super::super) prior: &'a MtpInt8Snapshot,
pub(in super::super) tokens: &'a [i32],
pub(in super::super) cell0: usize,
pub(in super::super) first_needed: usize,
pub(in super::super) policy: &'a OriginalMtpScalarPolicy,
}
/// The weights, embedding table and prompt residual after the alias admission.
pub(in super::super) struct ScalarStaged {
pub(in super::super) wh: [BufferHandle; 11],
pub(in super::super) eh: BufferHandle,
pub(in super::super) rh: BufferHandle,
pub(in super::super) rbytes: usize,
}
/// The scratch addresses of one group of `t` rows.
#[derive(Clone, Copy)]
pub(in super::super) struct GroupIo {
pub(in super::super) rin: u64,
pub(in super::super) emb: u64,
pub(in super::super) en: u64,
pub(in super::super) e2: u64,
pub(in super::super) hn: u64,
pub(in super::super) h2: u64,
pub(in super::super) r: u64,
pub(in super::super) mixed: u64,
pub(in super::super) tok: u64,
pub(in super::super) step: u64,
pub(in super::super) pos: u64,
}
/// Everything the capture of one group reads.
pub(in super::super) struct Cap<'a, 'ctx> {
pub(in super::super) io: GroupIo,
pub(in super::super) wh: &'a [BufferHandle; 11],
pub(in super::super) eh: BufferHandle,
pub(in super::super) t: usize,
pub(in super::super) group: usize,
pub(in super::super) policy: &'a OriginalMtpScalarPolicy,
pub(in super::super) ring: &'a MtpOriginalInt8<'ctx>,
pub(in super::super) embedding: &'a OriginalMtpEmbedding<'a, 'ctx>,
}
impl<'ctx> OriginalMtpScalarPrefill<'ctx> {
/// The addresses of several scratch slots, resolved in the order given.
pub(in super::super) fn addresses<const N: usize>(&self, specs: [(usize, usize); N]) -> Result<[u64; N]> {
let mut out = [0; N];
for (k, (i, n)) in specs.into_iter().enumerate() {
out[k] = self.address(i, n)?;
}
Ok(out)
}
pub(in super::super) fn group_io(&self, t: usize) -> Result<GroupIo> {
let [rin, emb, en, e2, hn, h2, r, mixed, tok, step, pos] = self.addresses([
(0, t * 40960),
(2, t * 10240),
(3, t * 10240),
(4, t * 10240),
(5, t * 40960),
(6, t * 40960),
(1, t * 40960),
(11, t * 10240),
(12, t * 4),
(13, t * 16),
(14, t * 96),
])?;
Ok(GroupIo { rin, emb, en, e2, hn, h2, r, mixed, tok, step, pos })
}
/// The four copies that stage the token, step and position records and the residual into the group's scratch.
pub(in super::super) fn group_copies(
io: &GroupIo,
rec_h: BufferHandle,
residual: (BufferHandle, usize),
at: (usize, usize, usize),
) -> Result<[ScalarCommand; 4]> {
let (n, c, t) = at;
let rec = rec_h.qwen_address();
let rin = residual.0.checked_subspan(residual.1, c * 40960, t * 40960)?.qwen_address();
Ok([
(io.tok, rec + (c * 4) as u64, t * 4),
(io.step, rec + ((n + c * 4) * 4) as u64, t * 16),
(io.pos, rec + ((n * 5 + c * 24) * 4) as u64, t * 96),
(io.rin, rin, t * 40960),
]
.map(|(dst, src, bytes)| ScalarCommand::Copy { dst, src, bytes }))
}
}
@@ -0,0 +1,192 @@
//! The group loop of `OriginalMtpScalarPrefill::record_impl` (STRA-338): the page and record staging, the per-group
//! graph capture and enqueue, and the publication of the completed range.
#[allow(unused_imports)]
use super::*;
/// Fills the `[tokens n][steps4*n][positions24*n]` records of a prompt.
fn fill_records(rec: &mut [u8], tokens: &[i32], cell0: usize) {
let n = tokens.len();
for (i, token) in tokens.iter().enumerate() {
let cell = cell0 + i;
rec[i * 4..i * 4 + 4].copy_from_slice(&token.to_le_bytes());
for (j, v) in [cell, cell + 1, (cell + 1) / 4, cell + 1].into_iter().enumerate() {
let off = (n + i * 4 + j) * 4;
rec[off..off + 4].copy_from_slice(&(v as i32).to_le_bytes());
}
for h in 0..24 {
let off = (n * 5 + i * 24 + h) * 4;
rec[off..off + 4].copy_from_slice(&(cell as i32).to_le_bytes());
}
}
}
impl<'ctx> OriginalMtpScalarPrefill<'ctx> {
/// Stages the pages and records, restores the ring and records every group; publishes the completed range.
#[allow(clippy::too_many_arguments)]
pub(in super::super) fn record_groups(
&mut self,
rows: &mut OriginalPromptRows<'_, '_, '_>,
workspace: &mut NativeBatchWorkspace<'ctx>,
ring: &mut MtpOriginalInt8<'ctx>,
at: (&ScalarCall<'_>, usize),
operands: (&ScalarStaged, &Rc<OriginalMtpRetainedScalarWeights<'ctx>>, &OriginalMtpEmbedding<'_, 'ctx>),
cancelled: &mut impl FnMut() -> bool,
) -> Result<DraftKvOutcome> {
let (call, first_group) = at;
let generation = ring.generation.checked_add(1).ok_or(Error::InvalidQwenShape)?;
let (first, end) = (call.cell0 + first_group, call.cell0 + call.tokens.len());
let first_page = first / 4;
let (pages, changed) = OriginalMtpPrefill::prepare_pages(call.prior, end, first_page)?;
// Literal prefill records [tokens n][steps4*n][positions24*n], one upload.
let (rec_h, rec) = self.build_records(call)?;
let mut staging = vec![(rec_h, rec)];
let mut cmds = Vec::new();
cmds.try_reserve(128).map_err(|_| Error::HostAllocation)?;
if cancelled() {
return Ok(DraftKvOutcome::Cancelled);
}
self.restore_and_upload(workspace, ring, call, &mut staging)?;
if let Some(outcome) =
self.run_groups(rows, workspace, ring, (call, operands), (rec_h, &mut cmds), cancelled)?
{
return Ok(outcome);
}
self.complete(rows, workspace, ring, call, (pages, changed), (first_page, first, end, generation), cancelled)
}
fn build_records(&self, call: &ScalarCall<'_>) -> Result<(BufferHandle, Vec<u8>)> {
let mut rec = zero_bytes(call.tokens.len() * 29 * 4)?;
fill_records(&mut rec, call.tokens, call.cell0);
let rb = self.records.as_ref().ok_or(Error::ContextPoisoned)?;
let rec_h = rb.handle.ok_or(Error::ContextPoisoned)?.checked_subspan(rb.bytes, 0, rec.len())?;
Ok((rec_h, rec))
}
fn restore_and_upload(
&mut self,
workspace: &mut NativeBatchWorkspace<'ctx>,
ring: &mut MtpOriginalInt8<'ctx>,
call: &ScalarCall<'_>,
staging: &mut Vec<(BufferHandle, Vec<u8>)>,
) -> Result<()> {
ring.execute(workspace, Vec::new())?;
ring.restore(workspace, call.prior)?;
ring.current = None;
if !call.policy.per_group_sync {
self.upload_records(staging)?;
} else {
self.upload_records(&mut Vec::new())?;
}
staging.clear();
Ok(())
}
#[allow(clippy::too_many_arguments)]
fn run_groups(
&mut self,
rows: &mut OriginalPromptRows<'_, '_, '_>,
workspace: &mut NativeBatchWorkspace<'ctx>,
ring: &MtpOriginalInt8<'ctx>,
ctx: (
&ScalarCall<'_>,
(&ScalarStaged, &Rc<OriginalMtpRetainedScalarWeights<'ctx>>, &OriginalMtpEmbedding<'_, 'ctx>),
),
buf: (BufferHandle, &mut Vec<ScalarCommand>),
cancelled: &mut impl FnMut() -> bool,
) -> Result<Option<DraftKvOutcome>> {
let (call, operands) = ctx;
let (rec_h, cmds) = buf;
let n = call.tokens.len();
for (group, c) in (0..n).step_by(self.max_t).enumerate() {
let t = self.max_t.min(n - c);
if call.cell0 + c + t <= call.first_needed {
continue;
}
let at = (group, c, t);
if let Some(o) =
self.run_group(rows, workspace, ring, (call, operands), (at, rec_h, &mut *cmds), cancelled)?
{
return Ok(Some(o));
}
}
Ok(None)
}
#[allow(clippy::too_many_arguments)]
fn run_group(
&mut self,
rows: &mut OriginalPromptRows<'_, '_, '_>,
workspace: &mut NativeBatchWorkspace<'ctx>,
ring: &MtpOriginalInt8<'ctx>,
ctx: (
&ScalarCall<'_>,
(&ScalarStaged, &Rc<OriginalMtpRetainedScalarWeights<'ctx>>, &OriginalMtpEmbedding<'_, 'ctx>),
),
buf: ((usize, usize, usize), BufferHandle, &mut Vec<ScalarCommand>),
cancelled: &mut impl FnMut() -> bool,
) -> Result<Option<DraftKvOutcome>> {
let (call, (st, retained, embedding)) = ctx;
let (at, rec_h, cmds) = buf;
let (group, c, t) = at;
let io = self.group_io(t)?;
let mut copies = Self::group_copies(&io, rec_h, (st.rh, st.rbytes), (call.tokens.len(), c, t))?;
if self.needs_capture(t, call.policy.per_group_sync)? {
let cap = Cap { io, wh: &st.wh, eh: st.eh, t, group, policy: call.policy, ring, embedding };
self.capture_group(cmds, &cap)?;
}
if cancelled() {
self.drain_graphs(rows, workspace)?;
return Ok(Some(DraftKvOutcome::Cancelled));
}
self.submit_group(rows, workspace, ring, (call, retained), (at, cmds, &mut copies))?;
Ok(None)
}
fn needs_capture(&mut self, t: usize, per_group_sync: bool) -> Result<bool> {
let key = OriginalGraphKey::MtpPrefill { rows: t as u8, device_inputs: !per_group_sync };
Ok(self.graphs.as_mut().ok_or(Error::ContextPoisoned)?.find_mut(key)?.is_none())
}
fn submit_group(
&mut self,
rows: &mut OriginalPromptRows<'_, '_, '_>,
workspace: &mut NativeBatchWorkspace<'ctx>,
ring: &MtpOriginalInt8<'ctx>,
ctx: (&ScalarCall<'_>, &Rc<OriginalMtpRetainedScalarWeights<'ctx>>),
run: ((usize, usize, usize), &mut Vec<ScalarCommand>, &mut [ScalarCommand; 4]),
) -> Result<()> {
let (call, retained) = ctx;
let ((group, c, t), cmds, copies) = run;
let sync = call.policy.per_group_sync;
let copies = if sync { &mut copies[3..] } else { &mut copies[..] };
let tokens = &call.tokens[c..c + t];
if let Err(primary) = self.enqueue_group(t, group, sync, retained, ring, cmds, copies, tokens, call.cell0 + c) {
let drained = self.drain_graphs(rows, workspace);
return combine(Err(primary), drained);
}
cmds.clear();
if sync {
self.drain_graphs(rows, workspace)?;
}
Ok(())
}
/// Drains the last graphs, reads the encoded pages back and publishes the completed range.
#[allow(clippy::too_many_arguments)]
fn complete(
&mut self,
rows: &mut OriginalPromptRows<'_, '_, '_>,
workspace: &mut NativeBatchWorkspace<'ctx>,
ring: &mut MtpOriginalInt8<'ctx>,
call: &ScalarCall<'_>,
pages: (Vec<Rc<Page>>, Vec<[Vec<u8>; 4]>),
range: (usize, usize, usize, u64),
cancelled: &mut impl FnMut() -> bool,
) -> Result<DraftKvOutcome> {
let ((pages, mut changed), (first_page, first, end, generation)) = (pages, range);
if !call.policy.per_group_sync {
self.drain_graphs(rows, workspace)?;
}
if cancelled() {
return Ok(DraftKvOutcome::Cancelled);
}
for (p, runs) in changed.iter_mut().enumerate() {
ring.read_encoded_page(first_page + p, runs)?;
}
Ok(OriginalMtpPrefill::finish(ring, pages, changed, (first, end, generation)))
}
}
@@ -0,0 +1,199 @@
//! Capture of one group of `OriginalMtpScalarPrefill::record_impl` (STRA-338): the per-T forward owns fixed whole
//! scratch/status and stable arguments; its commands are recorded in the order of the former single function.
#[allow(unused_imports)]
use super::*;
impl<'ctx> OriginalMtpScalarPrefill<'ctx> {
/// Captured per-T forward owns fixed whole scratch/status and stable arguments.
pub(in super::super) fn capture_group(&self, cmds: &mut Vec<ScalarCommand>, cap: &Cap<'_, 'ctx>) -> Result<()> {
self.cap_inputs(cmds, cap)?;
self.cap_embedding(cmds, cap)?;
let q = self.cap_embed_chain(cmds, cap)?;
self.cap_hidden(cmds, cap, q)?;
self.cap_gr(cmds, cap)?;
let kv = self.cap_kv(cmds, cap, q)?;
for row in 0..cap.t {
self.cap_row(cmds, cap, row, kv)?;
}
self.cap_commit(cmds, cap)
}
fn cap_inputs(&self, cmds: &mut Vec<ScalarCommand>, cap: &Cap<'_, 'ctx>) -> Result<()> {
Self::kernel(cmds, 0, 11, [1, 1, 1], [256, 1, 1], 0, vec![Arg::U64(self.flag(0, 0)?), Arg::I32(64)])?;
if cap.policy.per_group_sync {
self.cap_map_inputs(cmds, cap)?;
}
Ok(())
}
fn cap_map_inputs(&self, cmds: &mut Vec<ScalarCommand>, cap: &Cap<'_, 'ctx>) -> Result<()> {
let (io, t, max_t) = (&cap.io, cap.t, self.max_t);
let mapped = self.mapped.try_borrow().map_err(|_| Error::InvalidQwenShape)?;
let m = mapped.as_ref().ok_or(Error::ContextPoisoned)?;
for (dst, offset, count) in [(io.tok, 0, t), (io.step, max_t * 4, t * 4), (io.pos, max_t * 20, t * 24)] {
let args = vec![Arg::U64(dst), Arg::U64(m.address(offset, count * 4)?), Arg::I32(count as i32)];
Self::kernel(cmds, 3, 2, [1, 1, 1], [128, 1, 1], 0, args)?;
}
Ok(())
}
fn cap_embedding(&self, cmds: &mut Vec<ScalarCommand>, cap: &Cap<'_, 'ctx>) -> Result<()> {
match cap.embedding.kind {
EmbeddingKind::Native { kind, row_bytes, .. } => Self::lookup_native(cmds, cap, kind, row_bytes),
EmbeddingKind::Compressed { bits, bias, group, codes, scales, offsets, .. } => {
let eh = cap.eh.qwen_address();
let offsets = if offsets { eh + (codes + scales) as u64 } else { 0 };
let args = vec![
Arg::U64(eh),
Arg::U64(eh + codes as u64),
Arg::U64(offsets),
Arg::U64(cap.io.tok),
Arg::I64(2560),
Arg::I32(bits),
Arg::I32(bias),
Arg::I32(group as i32),
Arg::U64((2560 / (8 / bits)) as u64),
Arg::U64((2560 / group) as u64),
Arg::U64(cap.io.emb),
];
Self::kernel(cmds, 0, 5, [10, cap.t as u32, 1], [256, 1, 1], 0, args)
}
}
}
fn lookup_native(cmds: &mut Vec<ScalarCommand>, cap: &Cap<'_, 'ctx>, kind: i32, row_bytes: usize) -> Result<()> {
let eh = cap.eh.qwen_address();
let args = vec![
Arg::I32(kind),
Arg::U64(eh),
Arg::U64(row_bytes as u64),
Arg::U64(cap.io.tok),
Arg::I64(2560),
Arg::U64(cap.io.emb),
];
Self::kernel(cmds, 1, 0, [10, cap.t as u32, 1], [32, 1, 1], 0, args)
}
/// The embedding half: finite guard, RMS norm and the Q8 projection into `e2`; returns the Q8 scratch.
fn cap_embed_chain(&self, cmds: &mut Vec<ScalarCommand>, cap: &Cap<'_, 'ctx>) -> Result<u64> {
let (io, wh, t, g) = (&cap.io, cap.wh, cap.t, cap.group);
self.finite(cmds, io.emb, t * 2560, g, 0)?;
let norm =
vec![Arg::U64(io.emb), Arg::U64(wh[0].qwen_address()), Arg::U64(io.en), Arg::I32(2560), Arg::F32(1e-6)];
Self::kernel(cmds, 3, 0, [t as u32, 1, 1], [1024, 1, 1], 0, norm)?;
self.finite(cmds, io.en, t * 2560, g, 1)?;
let q = self.address(15, 8 * 80 * 36)?;
Self::quant(cmds, io.en, q, t)?;
self.q8_guard(cmds, q, t, g, 2)?;
Self::project(cmds, wh[1].qwen_address(), q, io.e2, t, 2560)?;
self.finite(cmds, io.e2, t * 2560, g, 2)?;
Ok(q)
}
/// The hidden half: RMS norm of the residual and the Q8 projection into `h2`, eight columns at a time.
fn cap_hidden(&self, cmds: &mut Vec<ScalarCommand>, cap: &Cap<'_, 'ctx>, q: u64) -> Result<()> {
let (io, wh, t, g) = (&cap.io, cap.wh, cap.t, cap.group);
let norm =
vec![Arg::U64(io.rin), Arg::U64(wh[2].qwen_address()), Arg::U64(io.hn), Arg::I32(10240), Arg::F32(1e-6)];
Self::kernel(cmds, 3, 0, [t as u32, 1, 1], [1024, 1, 1], 0, norm)?;
self.finite(cmds, io.hn, t * 10240, g, 3)?;
for hc in (0..t * 4).step_by(8) {
let cols = 8.min(t * 4 - hc);
Self::quant(cmds, io.hn + (hc * 10240) as u64, q, cols)?;
self.q8_guard(cmds, q, cols, g, 4)?;
Self::project(cmds, wh[3].qwen_address(), q, io.h2 + (hc * 10240) as u64, cols, 2560)?;
}
self.finite(cmds, io.h2, t * 10240, g, 4)
}
fn cap_gr(&self, cmds: &mut Vec<ScalarCommand>, cap: &Cap<'_, 'ctx>) -> Result<()> {
let (io, t, g) = (&cap.io, cap.t, cap.group);
let args = vec![Arg::U64(io.h2), Arg::U64(io.e2), Arg::U64(io.r), Arg::I64(2560), Arg::I32(4)];
Self::kernel(cmds, 0, 4, [40, t as u32, 1], [256, 1, 1], 0, args)?;
self.finite(cmds, io.r, t * 10240, g, 5)?;
self.gr(cmds, t, cap.wh, cap.policy)?;
self.cap_gr_guards(cmds, cap)
}
fn cap_gr_guards(&self, cmds: &mut Vec<ScalarCommand>, cap: &Cap<'_, 'ctx>) -> Result<()> {
let (t, g) = (cap.t, cap.group);
self.finite(cmds, self.address(9, t * 16)?, t * 4, g, 6)?;
self.finite(cmds, self.address(7, t * 40960)?, t * 10240, g, 6)?;
self.finite(cmds, self.address(8, t * 1280)?, t * 320, g, 7)?;
self.finite(cmds, self.address(10, t * 16)?, t * 4, g, 7)?;
self.finite(cmds, cap.io.mixed, t * 2560, g, 8)
}
/// The K and V projections of the mixed state into the current KV; returns their addresses.
fn cap_kv(&self, cmds: &mut Vec<ScalarCommand>, cap: &Cap<'_, 'ctx>, q: u64) -> Result<(u64, u64)> {
let (io, wh, t, g) = (&cap.io, cap.wh, cap.t, cap.group);
Self::quant(cmds, io.mixed, q, t)?;
self.q8_guard(cmds, q, t, g, 9)?;
let (kc, vc) = self.current_kv(cap.ring)?;
Self::project(cmds, wh[7].qwen_address(), q, kc, t, 512)?;
self.finite(cmds, kc, t * 512, g, 10)?;
Self::project(cmds, wh[8].qwen_address(), q, vc, t, 512)?;
self.finite(cmds, vc, t * 512, g, 11)?;
Ok((kc, vc))
}
/// K norm and rope, then the step append kernel for one row.
fn cap_row(&self, cmds: &mut Vec<ScalarCommand>, cap: &Cap<'_, 'ctx>, row: usize, kv: (u64, u64)) -> Result<()> {
let (kc, vc) = kv;
let k = kc + (row * 2048) as u64;
let norm = vec![Arg::U64(k), Arg::U64(cap.wh[9].qwen_address()), Arg::U64(k), Arg::I32(256), Arg::F32(1e-6)];
Self::kernel(cmds, 2, 9, [2, 1, 1], [256, 1, 1], 0, norm)?;
self.finite(cmds, k, 512, cap.group, 12)?;
Self::cap_rope(cmds, cap, row, k)?;
self.finite(cmds, k, 512, cap.group, 13)?;
self.cap_append(cmds, cap, row, (k, vc))
}
fn cap_rope(cmds: &mut Vec<ScalarCommand>, cap: &Cap<'_, 'ctx>, row: usize, k: u64) -> Result<()> {
let kv = &cap.policy.kv;
let args = vec![
Arg::U64(k),
Arg::U64(k),
Arg::I32(2),
Arg::I32(256),
Arg::I32(64),
Arg::F32(kv.theta_scale),
Arg::F32(kv.freq_scale),
Arg::F32(kv.corr_low),
Arg::F32(kv.corr_high),
Arg::F32(kv.ext_factor),
Arg::F32(kv.mscale),
Arg::U64(cap.io.pos + (row * 96) as u64),
Arg::U64(0),
Arg::Words3([0; 3]),
];
Self::kernel(cmds, 3, 1, [4, 2, 1], [32, 1, 1], 0, args)
}
/// Literal step append kernel and actual private step record, not batched prompt arithmetic.
fn cap_append(&self, cmds: &mut Vec<ScalarCommand>, cap: &Cap<'_, 'ctx>, row: usize, kv: (u64, u64)) -> Result<()> {
let (k, vc) = kv;
let ring = cap.ring;
let mut host = [0u64; 8];
host[2..6].copy_from_slice(&ring.host_addresses()?);
let args = vec![
Arg::U64(ring.address(0)?),
Arg::U64(ring.address(1)?),
Arg::U64(ring.address(2)?),
Arg::U64(ring.address(3)?),
Arg::U64(ring.address(4)?),
Arg::U64(cap.io.step + (row * 16) as u64),
Arg::U64(k),
Arg::U64(vc + (row * 2048) as u64),
Arg::I32(2),
Arg::I32(256),
Arg::I32(4),
Arg::U64(host[2]),
Arg::U64(host[3]),
Arg::U64(host[4]),
Arg::U64(host[5]),
];
Self::kernel(cmds, 5, 0, [2, 4, 2], [64, 1, 1], 0, args)
}
fn cap_commit(&self, cmds: &mut Vec<ScalarCommand>, cap: &Cap<'_, 'ctx>) -> Result<()> {
let ring = cap.ring;
let args = vec![
Arg::U64(ring.address(2)?),
Arg::U64(ring.address(3)?),
Arg::U64(ring.address(4)?),
Arg::U64(cap.io.step),
Arg::I32(cap.t as i32),
Arg::U64(self.flag(0, 14)?),
];
Self::kernel(cmds, 3, 3, [64, 1, 1], [256, 1, 1], 0, args)
}
}
+5 -586
View File
@@ -4,592 +4,6 @@
use super::*;
use crate::ple_batch_ffi::{BatchArg as A, KernelArguments, KernelModule};
#[test]
#[ignore = "Root-only: needs a CUDA device"]
fn gdn_stage_kernels_equal_the_originals_bit_for_bit() {
assert_eq!(std::env::var(ENABLE).ok().as_deref(), Some("yes"));
let driver = crate::Driver::load().expect("driver");
let device = driver.device(0).expect("device");
let context = device.create_context(6usize << 30).expect("context");
let workspace = context.native_batch_workspace().expect("workspace");
let stream = workspace.blas().expect("blas").stream();
let batch = context.gdn_prefill_batch_for_prompt(512).expect("gdn batch");
let funcs = batch.functions.as_ref().expect("functions");
let old = Old { context: &context, stream, funcs };
let guard = context.enter().expect("enter");
let stage = KernelModule::load(crate::prefill_stage::PTX, crate::prefill_stage::ENTRIES).expect("stage module");
guard.finish().expect("finish");
let mut rng = Rng(0x1234567890abcdef);
let t = 200usize; // four tiles, the last one partial
// ------------------------------------------------------------------ dequantization, six formats
for (format, k) in [
(GdnNativeFormat::Q8_0, 2560usize),
(GdnNativeFormat::Q4K, 2560),
(GdnNativeFormat::Q5K, 2560),
(GdnNativeFormat::Q6K, 2560),
(GdnNativeFormat::Iq4Nl, 2560),
(GdnNativeFormat::Iq4Xs, 2560),
] {
let n = 100usize;
let (elements, block_bytes) = format.block();
let row_bytes = k / elements * block_bytes;
let mut blocks = vec![0u8; n * row_bytes];
blocks.iter_mut().for_each(|b| *b = rng.next() as u8);
// finite f16 scale fields
for block in blocks.chunks_mut(block_bytes) {
let fields: &[usize] = match format {
GdnNativeFormat::Q8_0 | GdnNativeFormat::Iq4Nl | GdnNativeFormat::Iq4Xs => &[0],
GdnNativeFormat::Q4K | GdnNativeFormat::Q5K => &[0, 2],
GdnNativeFormat::Q6K => &[208],
};
for f in fields {
block[*f..*f + 2].copy_from_slice(&rng.f16().to_le_bytes());
}
}
let weight = upload(&context, &blocks);
let out_old = upload(&context, &vec![0u8; n * k * 2]);
let out_new = upload(&context, &vec![0u8; n * k * 2]);
let groups = (n * (k / 32)).div_ceil(256) as u32;
old.run(vec![(
format.kernel(),
[groups, 1, 1],
[256, 1, 1],
vec![
ffi::KernelArg::Pointer(hd(&weight)),
ffi::KernelArg::I64(row_bytes as i64),
ffi::KernelArg::I64(0),
ffi::KernelArg::I64(n as i64),
ffi::KernelArg::I64((k / 32) as i64),
ffi::KernelArg::Pointer(hd(&out_old)),
],
)]);
let index = crate::prefill_stage::DEQUANT_FIRST
+ match format {
GdnNativeFormat::Q8_0 => 0,
GdnNativeFormat::Q4K => 1,
GdnNativeFormat::Q5K => 2,
GdnNativeFormat::Q6K => 3,
GdnNativeFormat::Iq4Nl => 4,
GdnNativeFormat::Iq4Xs => 5,
};
run_stage(
&context,
stream,
&stage,
vec![(
index,
(n * k).div_ceil(256) as u32,
vec![
A::Address(hd(&weight)),
A::I64(row_bytes as i64),
A::I64((n * k) as i64),
A::I64((k / 32) as i64),
A::Address(hd(&out_new)),
],
)],
);
assert_eq!(
download(&out_old, n * k * 2),
download(&out_new, n * k * 2),
"{format:?}: dequantized FP16 weights"
);
eprintln!("PREFILL-GDN dequant {format:?}: {} FP16 values equal", n * k);
}
// ------------------------------------------------------------------ convolution + L2 + output norm
for case in 0..4 {
let hist = f32_bytes(&(0..10240 * 3).map(|_| rng.f(2.0)).collect::<Vec<_>>());
let mut qkv: Vec<f32> = (0..t * 10240).map(|_| rng.f(3.0)).collect();
let w = f32_bytes(&(0..10240 * 4).map(|_| rng.f(1.0)).collect::<Vec<_>>());
match case {
1 => qkv[150 * 10240 + 77] = f32::NAN,
2 => qkv[3 * 10240 + 9000] = 3.0e38,
_ => {}
}
let (hist_d, qkv_d, w_d) = (upload(&context, &hist), upload(&context, &f32_bytes(&qkv)), upload(&context, &w));
let zero = vec![0u8; t * 10240 * 4];
let (h_old, h_new) = (upload(&context, &zero), upload(&context, &zero));
let status_old = upload(&context, &[0u8; 64]);
let status_new = upload(&context, &[0u8; 64]);
let word = |b: &DeviceBuffer<'_>, i: usize| hd(b).checked_subspan(64, i * 4, 4).expect("word");
let scan = |data: &DeviceBuffer<'_>, count: usize, slot: usize| {
(
Kernel::FiniteF32,
linear(count).unwrap().0,
[256, 1, 1],
vec![
ffi::KernelArg::Pointer(hd(data)),
ffi::KernelArg::Pointer(word(&status_old, slot)),
ffi::KernelArg::U32(count as u32),
],
)
};
old.run(vec![
(
Kernel::ConvTiled,
[80, t.div_ceil(64) as u32, 1],
[128, 1, 1],
vec![
ffi::KernelArg::Pointer(hd(&hist_d)),
ffi::KernelArg::Pointer(hd(&qkv_d)),
ffi::KernelArg::Pointer(hd(&w_d)),
ffi::KernelArg::Pointer(hd(&h_old)),
ffi::KernelArg::I64(t as i64),
],
),
scan(&qkv_d, t * 10240, 0),
scan(&h_old, t * 10240, 1),
]);
run_stage(
&context,
stream,
&stage,
vec![(
crate::prefill_stage::GDN_CONV_TILED,
40 * t.div_ceil(64) as u32,
vec![
A::Address(hd(&hist_d)),
A::Address(hd(&qkv_d)),
A::Address(hd(&w_d)),
A::Address(hd(&h_new)),
A::I64(t as i64),
A::Address(word(&status_new, 0)),
A::Address(word(&status_new, 1)),
],
)],
);
assert_eq!(download(&h_old, t * 10240 * 4), download(&h_new, t * 10240 * 4), "case {case}: conv output");
assert_eq!(words(&status_old, 2), words(&status_new, 2), "case {case}: conv status words (qkv, conv)");
// L2 over the first 4096 channels of every row, in place
let eps = 1e-6f32;
let status_l2_old = upload(&context, &[0u8; 64]);
let status_l2_new = upload(&context, &[0u8; 64]);
old.run(vec![
(
Kernel::L2,
[32, t as u32, 1],
[128, 1, 1],
vec![ffi::KernelArg::Pointer(hd(&h_old)), ffi::KernelArg::F32(eps)],
),
(
Kernel::FiniteF32,
linear(t * 10240).unwrap().0,
[256, 1, 1],
vec![
ffi::KernelArg::Pointer(hd(&h_old)),
ffi::KernelArg::Pointer(hd(&status_l2_old)),
ffi::KernelArg::U32((t * 10240) as u32),
],
),
]);
run_stage(
&context,
stream,
&stage,
vec![(
crate::prefill_stage::GDN_L2,
(32 * t).div_ceil(2) as u32,
vec![A::Address(hd(&h_new)), A::F32(eps), A::I64(t as i64), A::Address(hd(&status_l2_new))],
)],
);
assert_eq!(download(&h_old, t * 10240 * 4), download(&h_new, t * 10240 * 4), "case {case}: L2 output");
// the original scans the whole row (including the V channels the convolution guard already covers)
assert_eq!(words(&status_l2_old, 1), words(&status_l2_new, 1), "case {case}: L2 status");
// output norm
let z: Vec<f32> = (0..t * 6144).map(|_| rng.f(4.0)).collect();
let mut oc: Vec<f32> = (0..t * 6144).map(|_| rng.f(2.0)).collect();
let gamma: Vec<f32> = (0..128).map(|_| rng.f(1.5)).collect();
match case {
1 => oc[10 * 6144 + 5] = f32::INFINITY,
2 => oc[199 * 6144 + 6143] = 3.0e38,
_ => {}
}
let (z_d, g_d) = (upload(&context, &f32_bytes(&z)), upload(&context, &f32_bytes(&gamma)));
let (y_old, y_new) = (upload(&context, &f32_bytes(&oc)), upload(&context, &f32_bytes(&oc)));
let (yh_old, yh_new) = (upload(&context, &vec![0u8; t * 6144 * 2]), upload(&context, &vec![0u8; t * 6144 * 2]));
let (so, sn) = (upload(&context, &[0u8; 64]), upload(&context, &[0u8; 64]));
let wo = |i: usize| word(&so, i);
old.run(vec![
(
Kernel::FiniteF32,
linear(t * 6144).unwrap().0,
[256, 1, 1],
vec![
ffi::KernelArg::Pointer(hd(&y_old)),
ffi::KernelArg::Pointer(wo(1)),
ffi::KernelArg::U32((t * 6144) as u32),
],
),
(
Kernel::OutNorm,
[t as u32, 48, 1],
[128, 1, 1],
vec![
ffi::KernelArg::Pointer(hd(&z_d)),
ffi::KernelArg::Pointer(hd(&g_d)),
ffi::KernelArg::F32(eps),
ffi::KernelArg::Pointer(hd(&y_old)),
ffi::KernelArg::Pointer(hd(&yh_old)),
],
),
(
Kernel::FiniteF32,
linear(t * 6144).unwrap().0,
[256, 1, 1],
vec![
ffi::KernelArg::Pointer(hd(&y_old)),
ffi::KernelArg::Pointer(wo(2)),
ffi::KernelArg::U32((t * 6144) as u32),
],
),
(
Kernel::FiniteF16,
linear(t * 6144).unwrap().0,
[256, 1, 1],
vec![
ffi::KernelArg::Pointer(hd(&yh_old)),
ffi::KernelArg::Pointer(wo(3)),
ffi::KernelArg::U32((t * 6144) as u32),
],
),
(
Kernel::FiniteF32,
linear(t * 6144).unwrap().0,
[256, 1, 1],
vec![
ffi::KernelArg::Pointer(hd(&z_d)),
ffi::KernelArg::Pointer(wo(0)),
ffi::KernelArg::U32((t * 6144) as u32),
],
),
]);
run_stage(
&context,
stream,
&stage,
vec![(
crate::prefill_stage::GDN_OUT_NORM,
(48 * t).div_ceil(2) as u32,
vec![
A::Address(hd(&z_d)),
A::Address(hd(&g_d)),
A::F32(eps),
A::Address(hd(&y_new)),
A::Address(hd(&yh_new)),
A::I64(t as i64),
A::Address(word(&sn, 0)),
A::Address(word(&sn, 1)),
A::Address(word(&sn, 2)),
A::Address(word(&sn, 3)),
],
)],
);
assert_eq!(download(&y_old, t * 6144 * 4), download(&y_new, t * 6144 * 4), "case {case}: y");
assert_eq!(download(&yh_old, t * 6144 * 2), download(&yh_new, t * 6144 * 2), "case {case}: y16");
assert_eq!(words(&so, 4), words(&sn, 4), "case {case}: out-norm status words (z, readout, y, y16)");
// row 2.4: the variant without the dead FP32 store writes the same y16 and status words and leaves y holding the readout
let (y_ns, yh_ns, sns) = (
upload(&context, &f32_bytes(&oc)),
upload(&context, &vec![0u8; t * 6144 * 2]),
upload(&context, &[0u8; 64]),
);
run_stage(
&context,
stream,
&stage,
vec![(
crate::prefill_stage::GDN_OUT_NORM_Y16,
(48 * t).div_ceil(2) as u32,
vec![
A::Address(hd(&z_d)),
A::Address(hd(&g_d)),
A::F32(eps),
A::Address(hd(&y_ns)),
A::Address(hd(&yh_ns)),
A::I64(t as i64),
A::Address(word(&sns, 0)),
A::Address(word(&sns, 1)),
A::Address(word(&sns, 2)),
A::Address(word(&sns, 3)),
],
)],
);
assert_eq!(
download(&yh_old, t * 6144 * 2),
download(&yh_ns, t * 6144 * 2),
"case {case}: y16 of the no-store variant"
);
assert_eq!(words(&so, 4), words(&sns, 4), "case {case}: status words of the no-store variant");
assert_eq!(
download(&y_ns, t * 6144 * 4),
f32_bytes(&oc),
"case {case}: the no-store variant leaves y untouched"
);
eprintln!(
"PREFILL-GDN case {case}: conv/L2/out-norm equal; statuses conv {:?} l2 {:?} norm {:?}",
words(&status_new, 2),
words(&status_l2_new, 1),
words(&sn, 4)
);
}
}
#[test]
#[ignore = "Root-only: needs a CUDA device"]
fn gdn_recurrence_equals_the_original_bit_for_bit() {
assert_eq!(std::env::var(ENABLE).ok().as_deref(), Some("yes"));
let driver = crate::Driver::load().expect("driver");
let device = driver.device(0).expect("device");
let context = device.create_context(6usize << 30).expect("context");
let workspace = context.native_batch_workspace().expect("workspace");
let stream = workspace.blas().expect("blas").stream();
let batch = context.gdn_prefill_batch_for_prompt(2048).expect("gdn batch");
let funcs = batch.functions.as_ref().expect("functions");
let old = Old { context: &context, stream, funcs };
let guard = context.enter().expect("enter");
let stage = KernelModule::load(crate::prefill_stage::PTX, crate::prefill_stage::ENTRIES).expect("stage module");
guard.finish().expect("finish");
let mut rng = Rng(0xfeedfacecafebeef);
let state_len = 128 * 48 * 128;
for (case, t) in [(0, 1usize), (1, 7), (2, 200), (3, 1500), (4, 200)] {
let mut state: Vec<f32> = (0..state_len).map(|_| rng.f(0.05)).collect();
// q/k rows are L2-normalised in the real chain; keep them O(1/sqrt(S)) so the state stays bounded over the chunk
let mut h: Vec<f32> = (0..t * 10240).map(|_| rng.f(0.2)).collect();
let gate: Vec<f32> = (0..t * 48).map(|_| -rng.f(0.6).abs()).collect();
let beta: Vec<f32> = (0..t * 48).map(|_| (rng.f(0.5) + 0.5).abs()).collect();
if case == 4 {
// a state that overflows: both kernels must raise the witness
state[1234] = 3.0e38;
h[5 * 10240 + 4096 + 300] = 3.0e38;
}
let (sin, h_d, gate_d, beta_d) = (
upload(&context, &f32_bytes(&state)),
upload(&context, &f32_bytes(&h)),
upload(&context, &f32_bytes(&gate)),
upload(&context, &f32_bytes(&beta)),
);
let (sout_o, sout_n) =
(upload(&context, &vec![0u8; state_len * 4]), upload(&context, &vec![0u8; state_len * 4]));
let (oc_o, oc_n) = (upload(&context, &vec![0u8; t * 6144 * 4]), upload(&context, &vec![0u8; t * 6144 * 4]));
let (wo, wn) = (upload(&context, &[0u8; 16]), upload(&context, &[0u8; 16]));
old.run(vec![(
Kernel::RecColsPipe,
[192, 1, 1],
[32, 4, 1],
vec![
ffi::KernelArg::Pointer(hd(&sin)),
ffi::KernelArg::Pointer(hd(&sout_o)),
ffi::KernelArg::Pointer(hd(&h_d)),
ffi::KernelArg::Pointer(hd(&gate_d)),
ffi::KernelArg::Pointer(hd(&beta_d)),
ffi::KernelArg::Pointer(hd(&oc_o)),
ffi::KernelArg::I64(t as i64),
ffi::KernelArg::Pointer(hd(&wo)),
],
)]);
let guard = context.enter().expect("enter");
let mut args = KernelArguments::new(vec![
A::Address(hd(&sin)),
A::Address(hd(&sout_n)),
A::Address(hd(&h_d)),
A::Address(hd(&gate_d)),
A::Address(hd(&beta_d)),
A::Address(hd(&oc_n)),
A::I64(t as i64),
A::Address(hd(&wn)),
]);
let started = std::time::Instant::now();
stage.launch(crate::prefill_stage::GDN_REC, 192, 128, stream, &mut args).expect("launch");
context.driver.api.synchronize().expect("sync");
let new_ms = started.elapsed().as_secs_f64() * 1e3;
guard.finish().expect("finish");
assert_eq!(download(&oc_o, t * 6144 * 4), download(&oc_n, t * 6144 * 4), "case {case} (t={t}): readout");
assert_eq!(
download(&sout_o, state_len * 4),
download(&sout_n, state_len * 4),
"case {case} (t={t}): next state"
);
assert_eq!(words(&wo, 1), words(&wn, 1), "case {case}: state witness");
// timing of both, drained
let started = std::time::Instant::now();
old.run(vec![(
Kernel::RecColsPipe,
[192, 1, 1],
[32, 4, 1],
vec![
ffi::KernelArg::Pointer(hd(&sin)),
ffi::KernelArg::Pointer(hd(&sout_o)),
ffi::KernelArg::Pointer(hd(&h_d)),
ffi::KernelArg::Pointer(hd(&gate_d)),
ffi::KernelArg::Pointer(hd(&beta_d)),
ffi::KernelArg::Pointer(hd(&oc_o)),
ffi::KernelArg::I64(t as i64),
ffi::KernelArg::Pointer(hd(&wo)),
],
)]);
let old_ms = started.elapsed().as_secs_f64() * 1e3;
eprintln!(
"PREFILL-GDN rec case {case} t={t}: equal (state {} floats, witness {:?}); original {old_ms:.3} ms, new {new_ms:.3} ms",
state_len,
words(&wn, 1)
);
}
}
/// Row 2.4 (upstream 4e69f974): the recurrence with one thread for the three value heads of a key head
/// (`leleka_prefill_gdn_rec_kh`, grid 64 x 128) equals the Original's `gdn_rec_cols_pipe` (state out, readout, witness) bit for bit,
/// for token counts around the staging block (8) and the real chunk sizes, with a state that overflows; and the timing of the three
/// recurrences on warm data (`PREFILL-GDN rec-kh timing`).
#[test]
#[ignore = "Root-only: needs a CUDA device"]
fn gdn_recurrence_kh_equals_the_original_bit_for_bit() {
assert_eq!(std::env::var(ENABLE).ok().as_deref(), Some("yes"));
let driver = crate::Driver::load().expect("driver");
let device = driver.device(0).expect("device");
let context = device.create_context(10usize << 30).expect("context");
let workspace = context.native_batch_workspace().expect("workspace");
let stream = workspace.blas().expect("blas").stream();
let batch = context.gdn_prefill_batch_for_prompt(2048).expect("gdn batch");
let funcs = batch.functions.as_ref().expect("functions");
let old = Old { context: &context, stream, funcs };
let guard = context.enter().expect("enter");
let stage = KernelModule::load(crate::prefill_stage::PTX, crate::prefill_stage::ENTRIES).expect("stage module");
guard.finish().expect("finish");
let mut rng = Rng(0x0badc0ffee0ddf00);
let state_len = 128 * 48 * 128;
// (token count, variant): 0 clean, 1 an infinite state value, 2 a NaN in the input, 3 products that overflow
for (case, (t, variant)) in [
(1usize, 0u8),
(2, 0),
(7, 0),
(8, 0),
(9, 0),
(200, 0),
(200, 1),
(201, 2),
(200, 3),
(1500, 0),
(2048, 0),
(8192, 0),
]
.into_iter()
.enumerate()
{
let mut state: Vec<f32> = (0..state_len).map(|_| rng.f(0.05)).collect();
let mut h: Vec<f32> = (0..t * 10240).map(|_| rng.f(0.2)).collect();
let gate: Vec<f32> = (0..t * 48).map(|_| -rng.f(0.6).abs()).collect();
let beta: Vec<f32> = (0..t * 48).map(|_| (rng.f(0.5) + 0.5).abs()).collect();
if variant == 1 {
state[1234] = f32::INFINITY;
}
if variant == 3 {
state[1234] = 3.0e38;
h[5 * 10240 + 4096 + 300] = 3.0e38;
}
if variant == 2 {
h[100 * 10240 + 2 * 2048 + 777] = f32::NAN;
}
let (sin, h_d, gate_d, beta_d) = (
upload(&context, &f32_bytes(&state)),
upload(&context, &f32_bytes(&h)),
upload(&context, &f32_bytes(&gate)),
upload(&context, &f32_bytes(&beta)),
);
let (sout_o, sout_k) =
(upload(&context, &vec![0u8; state_len * 4]), upload(&context, &vec![0u8; state_len * 4]));
let (oc_o, oc_k) = (upload(&context, &vec![0u8; t * 6144 * 4]), upload(&context, &vec![0u8; t * 6144 * 4]));
let (wo, wk) = (upload(&context, &[0u8; 16]), upload(&context, &[0u8; 16]));
let old_launch = |sout: &DeviceBuffer<'_>, oc: &DeviceBuffer<'_>, w: &DeviceBuffer<'_>| {
(
Kernel::RecColsPipe,
[192u32, 1, 1],
[32u32, 4, 1],
vec![
ffi::KernelArg::Pointer(hd(&sin)),
ffi::KernelArg::Pointer(hd(sout)),
ffi::KernelArg::Pointer(hd(&h_d)),
ffi::KernelArg::Pointer(hd(&gate_d)),
ffi::KernelArg::Pointer(hd(&beta_d)),
ffi::KernelArg::Pointer(hd(oc)),
ffi::KernelArg::I64(t as i64),
ffi::KernelArg::Pointer(hd(w)),
],
)
};
let kh_args = |sout: &DeviceBuffer<'_>, oc: &DeviceBuffer<'_>, w: &DeviceBuffer<'_>| {
KernelArguments::new(vec![
A::Address(hd(&sin)),
A::Address(hd(sout)),
A::Address(hd(&h_d)),
A::Address(hd(&gate_d)),
A::Address(hd(&beta_d)),
A::Address(hd(oc)),
A::I64(t as i64),
A::Address(hd(w)),
])
};
old.run(vec![old_launch(&sout_o, &oc_o, &wo)]);
let guard = context.enter().expect("enter");
let mut args = kh_args(&sout_k, &oc_k, &wk);
stage.launch(crate::prefill_stage::GDN_REC_KH, 64, 128, stream, &mut args).expect("launch kh");
context.driver.api.synchronize().expect("sync");
guard.finish().expect("finish");
// compare the bytes as words: a NaN payload is a value too
assert_eq!(
download(&oc_o, t * 6144 * 4),
download(&oc_k, t * 6144 * 4),
"case {case} (t={t}, variant {variant}): readout"
);
assert_eq!(
download(&sout_o, state_len * 4),
download(&sout_k, state_len * 4),
"case {case} (t={t}, variant {variant}): next state"
);
assert_eq!(words(&wo, 1), words(&wk, 1), "case {case}: state witness");
let w = words(&wk, 1)[0];
if variant == 1 || variant == 2 {
assert_ne!(w, 0, "case {case}: the witness must be raised for a non-finite state / input");
} else if variant == 0 {
assert_eq!(w, 0, "case {case}: a clean chunk must not raise the witness");
}
if t >= 1500 && variant == 0 {
// timing on warm data: 20 launches of each, drained once
let reps = 20;
let t0 = std::time::Instant::now();
old.run((0..reps).map(|_| old_launch(&sout_o, &oc_o, &wo)).collect());
let old_ms = t0.elapsed().as_secs_f64() * 1e3 / reps as f64;
let guard = context.enter().expect("enter");
let mut keep = Vec::new();
let t1b = std::time::Instant::now();
for _ in 0..reps {
let mut a = kh_args(&sout_k, &oc_k, &wk);
stage.launch(crate::prefill_stage::GDN_REC_KH, 64, 128, stream, &mut a).expect("launch kh");
keep.push(a);
}
context.driver.api.synchronize().expect("sync");
let kh_ms = t1b.elapsed().as_secs_f64() * 1e3 / reps as f64;
let t2 = std::time::Instant::now();
for _ in 0..reps {
let mut a = kh_args(&sout_k, &oc_k, &wk);
stage.launch(crate::prefill_stage::GDN_REC, 192, 128, stream, &mut a).expect("launch rec");
keep.push(a);
}
context.driver.api.synchronize().expect("sync");
let rec_ms = t2.elapsed().as_secs_f64() * 1e3 / reps as f64;
guard.finish().expect("finish");
eprintln!(
"PREFILL-GDN rec-kh timing t={t}: original gdn_rec_cols_pipe {old_ms:.3} ms, leleka_prefill_gdn_rec {rec_ms:.3} ms, kh {kh_ms:.3} ms per launch (mean of {reps}, warm)"
);
}
eprintln!(
"PREFILL-GDN rec-kh case {case} t={t} variant {variant}: readout, state and witness ({w}) equal the original"
);
}
}
#[path = "prefill_stage_gdn_gpu/impl_rng.rs"]
mod impl_rng;
#[allow(unused_imports)]
@@ -613,3 +27,8 @@ use enable_types::ENABLE;
use enable_types::Old;
#[allow(unused_imports)]
use enable_types::Rng;
#[path = "prefill_stage_gdn_gpu/gdn_recurrence_equals_the_original.rs"]
mod gdn_recurrence_equals_the_original;
#[path = "prefill_stage_gdn_gpu/gdn_stage_kernels_equal.rs"]
mod gdn_stage_kernels_equal;
@@ -0,0 +1,263 @@
//! Tests of prefill_stage_gdn_gpu by topic (moved out of the test file by STRA-338):
//! gdn_recurrence_equals_the_original_bit_for_bit, gdn_recurrence_kh_equals_the_original_bit_for_bit.
#[allow(unused_imports)]
use super::*;
#[test]
#[ignore = "Root-only: needs a CUDA device"]
fn gdn_recurrence_equals_the_original_bit_for_bit() {
assert_eq!(std::env::var(ENABLE).ok().as_deref(), Some("yes"));
let driver = crate::Driver::load().expect("driver");
let device = driver.device(0).expect("device");
let context = device.create_context(6usize << 30).expect("context");
let workspace = context.native_batch_workspace().expect("workspace");
let stream = workspace.blas().expect("blas").stream();
let batch = context.gdn_prefill_batch_for_prompt(2048).expect("gdn batch");
let funcs = batch.functions.as_ref().expect("functions");
let old = Old { context: &context, stream, funcs };
let guard = context.enter().expect("enter");
let stage = KernelModule::load(crate::prefill_stage::PTX, crate::prefill_stage::ENTRIES).expect("stage module");
guard.finish().expect("finish");
let mut rng = Rng(0xfeedfacecafebeef);
let state_len = 128 * 48 * 128;
for (case, t) in [(0, 1usize), (1, 7), (2, 200), (3, 1500), (4, 200)] {
let mut state: Vec<f32> = (0..state_len).map(|_| rng.f(0.05)).collect();
// q/k rows are L2-normalised in the real chain; keep them O(1/sqrt(S)) so the state stays bounded over the
// chunk
let mut h: Vec<f32> = (0..t * 10240).map(|_| rng.f(0.2)).collect();
let gate: Vec<f32> = (0..t * 48).map(|_| -rng.f(0.6).abs()).collect();
let beta: Vec<f32> = (0..t * 48).map(|_| (rng.f(0.5) + 0.5).abs()).collect();
if case == 4 {
// a state that overflows: both kernels must raise the witness
state[1234] = 3.0e38;
h[5 * 10240 + 4096 + 300] = 3.0e38;
}
let (sin, h_d, gate_d, beta_d) = (
upload(&context, &f32_bytes(&state)),
upload(&context, &f32_bytes(&h)),
upload(&context, &f32_bytes(&gate)),
upload(&context, &f32_bytes(&beta)),
);
let (sout_o, sout_n) =
(upload(&context, &vec![0u8; state_len * 4]), upload(&context, &vec![0u8; state_len * 4]));
let (oc_o, oc_n) = (upload(&context, &vec![0u8; t * 6144 * 4]), upload(&context, &vec![0u8; t * 6144 * 4]));
let (wo, wn) = (upload(&context, &[0u8; 16]), upload(&context, &[0u8; 16]));
old.run(vec![(
Kernel::RecColsPipe,
[192, 1, 1],
[32, 4, 1],
vec![
ffi::KernelArg::Pointer(hd(&sin)),
ffi::KernelArg::Pointer(hd(&sout_o)),
ffi::KernelArg::Pointer(hd(&h_d)),
ffi::KernelArg::Pointer(hd(&gate_d)),
ffi::KernelArg::Pointer(hd(&beta_d)),
ffi::KernelArg::Pointer(hd(&oc_o)),
ffi::KernelArg::I64(t as i64),
ffi::KernelArg::Pointer(hd(&wo)),
],
)]);
let guard = context.enter().expect("enter");
let mut args = KernelArguments::new(vec![
A::Address(hd(&sin)),
A::Address(hd(&sout_n)),
A::Address(hd(&h_d)),
A::Address(hd(&gate_d)),
A::Address(hd(&beta_d)),
A::Address(hd(&oc_n)),
A::I64(t as i64),
A::Address(hd(&wn)),
]);
let started = std::time::Instant::now();
stage.launch(crate::prefill_stage::GDN_REC, 192, 128, stream, &mut args).expect("launch");
context.driver.api.synchronize().expect("sync");
let new_ms = started.elapsed().as_secs_f64() * 1e3;
guard.finish().expect("finish");
assert_eq!(download(&oc_o, t * 6144 * 4), download(&oc_n, t * 6144 * 4), "case {case} (t={t}): readout");
assert_eq!(
download(&sout_o, state_len * 4),
download(&sout_n, state_len * 4),
"case {case} (t={t}): next state"
);
assert_eq!(words(&wo, 1), words(&wn, 1), "case {case}: state witness");
// timing of both, drained
let started = std::time::Instant::now();
old.run(vec![(
Kernel::RecColsPipe,
[192, 1, 1],
[32, 4, 1],
vec![
ffi::KernelArg::Pointer(hd(&sin)),
ffi::KernelArg::Pointer(hd(&sout_o)),
ffi::KernelArg::Pointer(hd(&h_d)),
ffi::KernelArg::Pointer(hd(&gate_d)),
ffi::KernelArg::Pointer(hd(&beta_d)),
ffi::KernelArg::Pointer(hd(&oc_o)),
ffi::KernelArg::I64(t as i64),
ffi::KernelArg::Pointer(hd(&wo)),
],
)]);
let old_ms = started.elapsed().as_secs_f64() * 1e3;
eprintln!(
"PREFILL-GDN rec case {case} t={t}: equal (state {} floats, witness {:?}); \
original {old_ms:.3} ms, new {new_ms:.3} ms",
state_len,
words(&wn, 1)
);
}
}
/// Row 2.4 (upstream 4e69f974): the recurrence with one thread for the three value heads of a key head
/// (`leleka_prefill_gdn_rec_kh`, grid 64 x 128) equals the Original's `gdn_rec_cols_pipe` (state out, readout,
/// witness) bit for bit, for token counts around the staging block (8) and the real chunk sizes, with a state that
/// overflows; and the timing of the three
/// recurrences on warm data (`PREFILL-GDN rec-kh timing`).
#[test]
#[ignore = "Root-only: needs a CUDA device"]
fn gdn_recurrence_kh_equals_the_original_bit_for_bit() {
assert_eq!(std::env::var(ENABLE).ok().as_deref(), Some("yes"));
let driver = crate::Driver::load().expect("driver");
let device = driver.device(0).expect("device");
let context = device.create_context(10usize << 30).expect("context");
let workspace = context.native_batch_workspace().expect("workspace");
let stream = workspace.blas().expect("blas").stream();
let batch = context.gdn_prefill_batch_for_prompt(2048).expect("gdn batch");
let funcs = batch.functions.as_ref().expect("functions");
let old = Old { context: &context, stream, funcs };
let guard = context.enter().expect("enter");
let stage = KernelModule::load(crate::prefill_stage::PTX, crate::prefill_stage::ENTRIES).expect("stage module");
guard.finish().expect("finish");
let mut rng = Rng(0x0badc0ffee0ddf00);
let state_len = 128 * 48 * 128;
// (token count, variant): 0 clean, 1 an infinite state value, 2 a NaN in the input, 3 products that overflow
for (case, (t, variant)) in [
(1usize, 0u8),
(2, 0),
(7, 0),
(8, 0),
(9, 0),
(200, 0),
(200, 1),
(201, 2),
(200, 3),
(1500, 0),
(2048, 0),
(8192, 0),
]
.into_iter()
.enumerate()
{
let mut state: Vec<f32> = (0..state_len).map(|_| rng.f(0.05)).collect();
let mut h: Vec<f32> = (0..t * 10240).map(|_| rng.f(0.2)).collect();
let gate: Vec<f32> = (0..t * 48).map(|_| -rng.f(0.6).abs()).collect();
let beta: Vec<f32> = (0..t * 48).map(|_| (rng.f(0.5) + 0.5).abs()).collect();
if variant == 1 {
state[1234] = f32::INFINITY;
}
if variant == 3 {
state[1234] = 3.0e38;
h[5 * 10240 + 4096 + 300] = 3.0e38;
}
if variant == 2 {
h[100 * 10240 + 2 * 2048 + 777] = f32::NAN;
}
let (sin, h_d, gate_d, beta_d) = (
upload(&context, &f32_bytes(&state)),
upload(&context, &f32_bytes(&h)),
upload(&context, &f32_bytes(&gate)),
upload(&context, &f32_bytes(&beta)),
);
let (sout_o, sout_k) =
(upload(&context, &vec![0u8; state_len * 4]), upload(&context, &vec![0u8; state_len * 4]));
let (oc_o, oc_k) = (upload(&context, &vec![0u8; t * 6144 * 4]), upload(&context, &vec![0u8; t * 6144 * 4]));
let (wo, wk) = (upload(&context, &[0u8; 16]), upload(&context, &[0u8; 16]));
let old_launch = |sout: &DeviceBuffer<'_>, oc: &DeviceBuffer<'_>, w: &DeviceBuffer<'_>| {
(
Kernel::RecColsPipe,
[192u32, 1, 1],
[32u32, 4, 1],
vec![
ffi::KernelArg::Pointer(hd(&sin)),
ffi::KernelArg::Pointer(hd(sout)),
ffi::KernelArg::Pointer(hd(&h_d)),
ffi::KernelArg::Pointer(hd(&gate_d)),
ffi::KernelArg::Pointer(hd(&beta_d)),
ffi::KernelArg::Pointer(hd(oc)),
ffi::KernelArg::I64(t as i64),
ffi::KernelArg::Pointer(hd(w)),
],
)
};
let kh_args = |sout: &DeviceBuffer<'_>, oc: &DeviceBuffer<'_>, w: &DeviceBuffer<'_>| {
KernelArguments::new(vec![
A::Address(hd(&sin)),
A::Address(hd(sout)),
A::Address(hd(&h_d)),
A::Address(hd(&gate_d)),
A::Address(hd(&beta_d)),
A::Address(hd(oc)),
A::I64(t as i64),
A::Address(hd(w)),
])
};
old.run(vec![old_launch(&sout_o, &oc_o, &wo)]);
let guard = context.enter().expect("enter");
let mut args = kh_args(&sout_k, &oc_k, &wk);
stage.launch(crate::prefill_stage::GDN_REC_KH, 64, 128, stream, &mut args).expect("launch kh");
context.driver.api.synchronize().expect("sync");
guard.finish().expect("finish");
// compare the bytes as words: a NaN payload is a value too
assert_eq!(
download(&oc_o, t * 6144 * 4),
download(&oc_k, t * 6144 * 4),
"case {case} (t={t}, variant {variant}): readout"
);
assert_eq!(
download(&sout_o, state_len * 4),
download(&sout_k, state_len * 4),
"case {case} (t={t}, variant {variant}): next state"
);
assert_eq!(words(&wo, 1), words(&wk, 1), "case {case}: state witness");
let w = words(&wk, 1)[0];
if variant == 1 || variant == 2 {
assert_ne!(w, 0, "case {case}: the witness must be raised for a non-finite state / input");
} else if variant == 0 {
assert_eq!(w, 0, "case {case}: a clean chunk must not raise the witness");
}
if t >= 1500 && variant == 0 {
// timing on warm data: 20 launches of each, drained once
let reps = 20;
let t0 = std::time::Instant::now();
old.run((0..reps).map(|_| old_launch(&sout_o, &oc_o, &wo)).collect());
let old_ms = t0.elapsed().as_secs_f64() * 1e3 / reps as f64;
let guard = context.enter().expect("enter");
let mut keep = Vec::new();
let t1b = std::time::Instant::now();
for _ in 0..reps {
let mut a = kh_args(&sout_k, &oc_k, &wk);
stage.launch(crate::prefill_stage::GDN_REC_KH, 64, 128, stream, &mut a).expect("launch kh");
keep.push(a);
}
context.driver.api.synchronize().expect("sync");
let kh_ms = t1b.elapsed().as_secs_f64() * 1e3 / reps as f64;
let t2 = std::time::Instant::now();
for _ in 0..reps {
let mut a = kh_args(&sout_k, &oc_k, &wk);
stage.launch(crate::prefill_stage::GDN_REC, 192, 128, stream, &mut a).expect("launch rec");
keep.push(a);
}
context.driver.api.synchronize().expect("sync");
let rec_ms = t2.elapsed().as_secs_f64() * 1e3 / reps as f64;
guard.finish().expect("finish");
eprintln!(
"PREFILL-GDN rec-kh timing t={t}: original gdn_rec_cols_pipe {old_ms:.3} ms, \
leleka_prefill_gdn_rec {rec_ms:.3} ms, kh {kh_ms:.3} ms per launch (mean of {reps}, warm)"
);
}
eprintln!(
"PREFILL-GDN rec-kh case {case} t={t} variant {variant}: readout, state and witness ({w}) equal the \
original"
);
}
}
@@ -0,0 +1,339 @@
//! Tests of prefill_stage_gdn_gpu by topic (moved out of the test file by STRA-338):
//! gdn_stage_kernels_equal_the_originals_bit_for_bit.
#[allow(unused_imports)]
use super::*;
#[test]
#[ignore = "Root-only: needs a CUDA device"]
fn gdn_stage_kernels_equal_the_originals_bit_for_bit() {
assert_eq!(std::env::var(ENABLE).ok().as_deref(), Some("yes"));
let driver = crate::Driver::load().expect("driver");
let device = driver.device(0).expect("device");
let context = device.create_context(6usize << 30).expect("context");
let workspace = context.native_batch_workspace().expect("workspace");
let stream = workspace.blas().expect("blas").stream();
let batch = context.gdn_prefill_batch_for_prompt(512).expect("gdn batch");
let funcs = batch.functions.as_ref().expect("functions");
let old = Old { context: &context, stream, funcs };
let guard = context.enter().expect("enter");
let stage = KernelModule::load(crate::prefill_stage::PTX, crate::prefill_stage::ENTRIES).expect("stage module");
guard.finish().expect("finish");
let mut rng = Rng(0x1234567890abcdef);
let t = 200usize; // four tiles, the last one partial
// ------------------------------------------------------------------ dequantization, six formats
for (format, k) in [
(GdnNativeFormat::Q8_0, 2560usize),
(GdnNativeFormat::Q4K, 2560),
(GdnNativeFormat::Q5K, 2560),
(GdnNativeFormat::Q6K, 2560),
(GdnNativeFormat::Iq4Nl, 2560),
(GdnNativeFormat::Iq4Xs, 2560),
] {
let n = 100usize;
let (elements, block_bytes) = format.block();
let row_bytes = k / elements * block_bytes;
let mut blocks = vec![0u8; n * row_bytes];
blocks.iter_mut().for_each(|b| *b = rng.next() as u8);
// finite f16 scale fields
for block in blocks.chunks_mut(block_bytes) {
let fields: &[usize] = match format {
GdnNativeFormat::Q8_0 | GdnNativeFormat::Iq4Nl | GdnNativeFormat::Iq4Xs => &[0],
GdnNativeFormat::Q4K | GdnNativeFormat::Q5K => &[0, 2],
GdnNativeFormat::Q6K => &[208],
};
for f in fields {
block[*f..*f + 2].copy_from_slice(&rng.f16().to_le_bytes());
}
}
let weight = upload(&context, &blocks);
let out_old = upload(&context, &vec![0u8; n * k * 2]);
let out_new = upload(&context, &vec![0u8; n * k * 2]);
let groups = (n * (k / 32)).div_ceil(256) as u32;
old.run(vec![(
format.kernel(),
[groups, 1, 1],
[256, 1, 1],
vec![
ffi::KernelArg::Pointer(hd(&weight)),
ffi::KernelArg::I64(row_bytes as i64),
ffi::KernelArg::I64(0),
ffi::KernelArg::I64(n as i64),
ffi::KernelArg::I64((k / 32) as i64),
ffi::KernelArg::Pointer(hd(&out_old)),
],
)]);
let index = crate::prefill_stage::DEQUANT_FIRST
+ match format {
GdnNativeFormat::Q8_0 => 0,
GdnNativeFormat::Q4K => 1,
GdnNativeFormat::Q5K => 2,
GdnNativeFormat::Q6K => 3,
GdnNativeFormat::Iq4Nl => 4,
GdnNativeFormat::Iq4Xs => 5,
};
run_stage(
&context,
stream,
&stage,
vec![(
index,
(n * k).div_ceil(256) as u32,
vec![
A::Address(hd(&weight)),
A::I64(row_bytes as i64),
A::I64((n * k) as i64),
A::I64((k / 32) as i64),
A::Address(hd(&out_new)),
],
)],
);
assert_eq!(
download(&out_old, n * k * 2),
download(&out_new, n * k * 2),
"{format:?}: dequantized FP16 weights"
);
eprintln!("PREFILL-GDN dequant {format:?}: {} FP16 values equal", n * k);
}
// ------------------------------------------------------------------ convolution + L2 + output norm
for case in 0..4 {
let hist = f32_bytes(&(0..10240 * 3).map(|_| rng.f(2.0)).collect::<Vec<_>>());
let mut qkv: Vec<f32> = (0..t * 10240).map(|_| rng.f(3.0)).collect();
let w = f32_bytes(&(0..10240 * 4).map(|_| rng.f(1.0)).collect::<Vec<_>>());
match case {
1 => qkv[150 * 10240 + 77] = f32::NAN,
2 => qkv[3 * 10240 + 9000] = 3.0e38,
_ => {}
}
let (hist_d, qkv_d, w_d) = (upload(&context, &hist), upload(&context, &f32_bytes(&qkv)), upload(&context, &w));
let zero = vec![0u8; t * 10240 * 4];
let (h_old, h_new) = (upload(&context, &zero), upload(&context, &zero));
let status_old = upload(&context, &[0u8; 64]);
let status_new = upload(&context, &[0u8; 64]);
let word = |b: &DeviceBuffer<'_>, i: usize| hd(b).checked_subspan(64, i * 4, 4).expect("word");
let scan = |data: &DeviceBuffer<'_>, count: usize, slot: usize| {
(
Kernel::FiniteF32,
linear(count).unwrap().0,
[256, 1, 1],
vec![
ffi::KernelArg::Pointer(hd(data)),
ffi::KernelArg::Pointer(word(&status_old, slot)),
ffi::KernelArg::U32(count as u32),
],
)
};
old.run(vec![
(
Kernel::ConvTiled,
[80, t.div_ceil(64) as u32, 1],
[128, 1, 1],
vec![
ffi::KernelArg::Pointer(hd(&hist_d)),
ffi::KernelArg::Pointer(hd(&qkv_d)),
ffi::KernelArg::Pointer(hd(&w_d)),
ffi::KernelArg::Pointer(hd(&h_old)),
ffi::KernelArg::I64(t as i64),
],
),
scan(&qkv_d, t * 10240, 0),
scan(&h_old, t * 10240, 1),
]);
run_stage(
&context,
stream,
&stage,
vec![(
crate::prefill_stage::GDN_CONV_TILED,
40 * t.div_ceil(64) as u32,
vec![
A::Address(hd(&hist_d)),
A::Address(hd(&qkv_d)),
A::Address(hd(&w_d)),
A::Address(hd(&h_new)),
A::I64(t as i64),
A::Address(word(&status_new, 0)),
A::Address(word(&status_new, 1)),
],
)],
);
assert_eq!(download(&h_old, t * 10240 * 4), download(&h_new, t * 10240 * 4), "case {case}: conv output");
assert_eq!(words(&status_old, 2), words(&status_new, 2), "case {case}: conv status words (qkv, conv)");
// L2 over the first 4096 channels of every row, in place
let eps = 1e-6f32;
let status_l2_old = upload(&context, &[0u8; 64]);
let status_l2_new = upload(&context, &[0u8; 64]);
old.run(vec![
(
Kernel::L2,
[32, t as u32, 1],
[128, 1, 1],
vec![ffi::KernelArg::Pointer(hd(&h_old)), ffi::KernelArg::F32(eps)],
),
(
Kernel::FiniteF32,
linear(t * 10240).unwrap().0,
[256, 1, 1],
vec![
ffi::KernelArg::Pointer(hd(&h_old)),
ffi::KernelArg::Pointer(hd(&status_l2_old)),
ffi::KernelArg::U32((t * 10240) as u32),
],
),
]);
run_stage(
&context,
stream,
&stage,
vec![(
crate::prefill_stage::GDN_L2,
(32 * t).div_ceil(2) as u32,
vec![A::Address(hd(&h_new)), A::F32(eps), A::I64(t as i64), A::Address(hd(&status_l2_new))],
)],
);
assert_eq!(download(&h_old, t * 10240 * 4), download(&h_new, t * 10240 * 4), "case {case}: L2 output");
// the original scans the whole row (including the V channels the convolution guard already covers)
assert_eq!(words(&status_l2_old, 1), words(&status_l2_new, 1), "case {case}: L2 status");
// output norm
let z: Vec<f32> = (0..t * 6144).map(|_| rng.f(4.0)).collect();
let mut oc: Vec<f32> = (0..t * 6144).map(|_| rng.f(2.0)).collect();
let gamma: Vec<f32> = (0..128).map(|_| rng.f(1.5)).collect();
match case {
1 => oc[10 * 6144 + 5] = f32::INFINITY,
2 => oc[199 * 6144 + 6143] = 3.0e38,
_ => {}
}
let (z_d, g_d) = (upload(&context, &f32_bytes(&z)), upload(&context, &f32_bytes(&gamma)));
let (y_old, y_new) = (upload(&context, &f32_bytes(&oc)), upload(&context, &f32_bytes(&oc)));
let (yh_old, yh_new) = (upload(&context, &vec![0u8; t * 6144 * 2]), upload(&context, &vec![0u8; t * 6144 * 2]));
let (so, sn) = (upload(&context, &[0u8; 64]), upload(&context, &[0u8; 64]));
let wo = |i: usize| word(&so, i);
old.run(vec![
(
Kernel::FiniteF32,
linear(t * 6144).unwrap().0,
[256, 1, 1],
vec![
ffi::KernelArg::Pointer(hd(&y_old)),
ffi::KernelArg::Pointer(wo(1)),
ffi::KernelArg::U32((t * 6144) as u32),
],
),
(
Kernel::OutNorm,
[t as u32, 48, 1],
[128, 1, 1],
vec![
ffi::KernelArg::Pointer(hd(&z_d)),
ffi::KernelArg::Pointer(hd(&g_d)),
ffi::KernelArg::F32(eps),
ffi::KernelArg::Pointer(hd(&y_old)),
ffi::KernelArg::Pointer(hd(&yh_old)),
],
),
(
Kernel::FiniteF32,
linear(t * 6144).unwrap().0,
[256, 1, 1],
vec![
ffi::KernelArg::Pointer(hd(&y_old)),
ffi::KernelArg::Pointer(wo(2)),
ffi::KernelArg::U32((t * 6144) as u32),
],
),
(
Kernel::FiniteF16,
linear(t * 6144).unwrap().0,
[256, 1, 1],
vec![
ffi::KernelArg::Pointer(hd(&yh_old)),
ffi::KernelArg::Pointer(wo(3)),
ffi::KernelArg::U32((t * 6144) as u32),
],
),
(
Kernel::FiniteF32,
linear(t * 6144).unwrap().0,
[256, 1, 1],
vec![
ffi::KernelArg::Pointer(hd(&z_d)),
ffi::KernelArg::Pointer(wo(0)),
ffi::KernelArg::U32((t * 6144) as u32),
],
),
]);
run_stage(
&context,
stream,
&stage,
vec![(
crate::prefill_stage::GDN_OUT_NORM,
(48 * t).div_ceil(2) as u32,
vec![
A::Address(hd(&z_d)),
A::Address(hd(&g_d)),
A::F32(eps),
A::Address(hd(&y_new)),
A::Address(hd(&yh_new)),
A::I64(t as i64),
A::Address(word(&sn, 0)),
A::Address(word(&sn, 1)),
A::Address(word(&sn, 2)),
A::Address(word(&sn, 3)),
],
)],
);
assert_eq!(download(&y_old, t * 6144 * 4), download(&y_new, t * 6144 * 4), "case {case}: y");
assert_eq!(download(&yh_old, t * 6144 * 2), download(&yh_new, t * 6144 * 2), "case {case}: y16");
assert_eq!(words(&so, 4), words(&sn, 4), "case {case}: out-norm status words (z, readout, y, y16)");
// row 2.4: the variant without the dead FP32 store writes the same y16 and status words and leaves y holding
// the readout
let (y_ns, yh_ns, sns) = (
upload(&context, &f32_bytes(&oc)),
upload(&context, &vec![0u8; t * 6144 * 2]),
upload(&context, &[0u8; 64]),
);
run_stage(
&context,
stream,
&stage,
vec![(
crate::prefill_stage::GDN_OUT_NORM_Y16,
(48 * t).div_ceil(2) as u32,
vec![
A::Address(hd(&z_d)),
A::Address(hd(&g_d)),
A::F32(eps),
A::Address(hd(&y_ns)),
A::Address(hd(&yh_ns)),
A::I64(t as i64),
A::Address(word(&sns, 0)),
A::Address(word(&sns, 1)),
A::Address(word(&sns, 2)),
A::Address(word(&sns, 3)),
],
)],
);
assert_eq!(
download(&yh_old, t * 6144 * 2),
download(&yh_ns, t * 6144 * 2),
"case {case}: y16 of the no-store variant"
);
assert_eq!(words(&so, 4), words(&sns, 4), "case {case}: status words of the no-store variant");
assert_eq!(
download(&y_ns, t * 6144 * 4),
f32_bytes(&oc),
"case {case}: the no-store variant leaves y untouched"
);
eprintln!(
"PREFILL-GDN case {case}: conv/L2/out-norm equal; statuses conv {:?} l2 {:?} norm {:?}",
words(&status_new, 2),
words(&status_l2_new, 1),
words(&sn, 4)
);
}
}
+5 -421
View File
@@ -4,427 +4,6 @@
use super::*;
use crate::ple_batch_ffi::{BatchArg as A, KernelArguments, KernelModule};
#[test]
#[ignore = "Root-only: needs a CUDA device"]
fn gr_fused_guards_equal_the_separate_guard_kernels_bit_for_bit() {
assert_eq!(std::env::var(ENABLE).ok().as_deref(), Some("yes"));
let driver = crate::Driver::load().expect("driver");
let device = driver.device(0).expect("device");
let context = device.create_context(4usize << 30).expect("context");
let workspace = context.native_batch_workspace().expect("workspace");
let guard = context.enter().expect("enter");
let gr = KernelModule::load(GR_PTX, GR_ENTRIES).expect("gr module");
let stage = KernelModule::load(crate::prefill_stage::PTX, crate::prefill_stage::ENTRIES).expect("stage module");
guard.finish().expect("finish");
let t = 77usize;
let mut rng = Rng(0x2545f4914f6cdd1d);
let rnd = |rng: &mut Rng, n: usize, scale: f32| -> Vec<f32> {
(0..n).map(|_| ((rng.next() % 20001) as f32 / 10000.0 - 1.0) * scale).collect()
};
let eps = 1e-6f32;
// cases: clean, a non-finite R word, a non-finite gate word, an overflowing product
for case in 0..4 {
let mut r = rnd(&mut rng, t * 10240, 3.0);
let gamma = rnd(&mut rng, 10240, 2.0);
let mut g = rnd(&mut rng, t * 10240, 4.0);
let bo = rnd(&mut rng, t * 2560, 1.0);
let inj = rnd(&mut rng, t * 4, 2.0);
match case {
1 => r[5 * 10240 + 777] = f32::INFINITY,
2 => g[9 * 10240 + 3000] = f32::NAN,
3 => r[11 * 10240 + 100] = 3.0e38,
_ => {}
}
let flags_len = t * 8 * 4;
let (rb, wb, gb, bob, injb) =
(f32_bytes(&r), f32_bytes(&gamma), f32_bytes(&g), f32_bytes(&bo), f32_bytes(&inj));
let mk = |n: usize| upload(&context, &vec![0u8; n]);
// ---- norm
let (r_old, r_new) = (upload(&context, &rb), upload(&context, &rb));
let w = upload(&context, &wb);
let (rs_o, rs_n, xn_o, xn_n, fl_o, fl_n) =
(mk(t * 16), mk(t * 16), mk(t * 20480), mk(t * 20480), mk(flags_len), mk(flags_len));
run_all(
&context,
&workspace,
vec![
(
&gr,
0,
t * 4,
256,
vec![
A::Address(h(&r_old)),
A::Address(h(&w)),
A::F32(eps),
A::Address(h(&rs_o)),
A::Address(h(&xn_o)),
A::NullAddress,
],
),
(
&gr,
5,
(t * 10240).div_ceil(256),
256,
vec![
A::Address(h(&r_old)),
A::Address(h(&rs_o)),
A::Address(h(&w)),
A::Address(h(&fl_o)),
A::I64(t as i64),
],
),
(
&stage,
3,
t * 4,
256,
vec![
A::Address(h(&r_new)),
A::Address(h(&w)),
A::F32(eps),
A::Address(h(&rs_n)),
A::Address(h(&xn_n)),
A::NullAddress,
A::Address(h(&fl_n)),
],
),
],
);
assert_eq!(download(&rs_o)[..t * 16], download(&rs_n)[..t * 16], "case {case}: rs");
assert_eq!(download(&xn_o)[..t * 20480], download(&xn_n)[..t * 20480], "case {case}: xn16");
assert_eq!(download(&fl_o)[..flags_len], download(&fl_n)[..flags_len], "case {case}: norm flags");
// ---- mix (uses the rs above)
let g_dev = upload(&context, &gb);
let (mx_o, mx_n, m16_o, m16_n, mh_o, mh_n) =
(mk(t * 10240), mk(t * 10240), mk(t * 5120), mk(t * 5120), mk(t * 5120), mk(t * 5120));
let (fl2_o, fl2_n) = (mk(flags_len), mk(flags_len));
run_all(
&context,
&workspace,
vec![
(
&gr,
2,
(t * 2560).div_ceil(256),
256,
vec![
A::Address(h(&r_old)),
A::Address(h(&rs_o)),
A::Address(h(&w)),
A::Address(h(&g_dev)),
A::Address(h(&mx_o)),
A::Address(h(&m16_o)),
A::I64(t as i64),
A::Address(h(&mh_o)),
A::NullAddress,
],
),
(
&gr,
7,
(t * 10240).div_ceil(256),
256,
vec![
A::Address(h(&r_old)),
A::Address(h(&rs_o)),
A::Address(h(&w)),
A::Address(h(&g_dev)),
A::Address(h(&fl2_o)),
A::I64(t as i64),
],
),
(
&gr,
4,
(t * 10240).div_ceil(256),
256,
vec![A::Address(h(&g_dev)), A::Address(h(&fl2_o)), A::I64(10240), A::I64(t as i64), A::U32(3)],
),
(
&gr,
4,
(t * 2560).div_ceil(256),
256,
vec![A::Address(h(&mx_o)), A::Address(h(&fl2_o)), A::I64(2560), A::I64(t as i64), A::U32(5)],
),
(
&stage,
4,
(t * 2560).div_ceil(256),
256,
vec![
A::Address(h(&r_new)),
A::Address(h(&rs_n)),
A::Address(h(&w)),
A::Address(h(&g_dev)),
A::Address(h(&mx_n)),
A::Address(h(&m16_n)),
A::I64(t as i64),
A::Address(h(&mh_n)),
A::NullAddress,
A::Address(h(&fl2_n)),
],
),
],
);
assert_eq!(download(&mx_o)[..t * 10240], download(&mx_n)[..t * 10240], "case {case}: mixed");
assert_eq!(download(&m16_o)[..t * 5120], download(&m16_n)[..t * 5120], "case {case}: mixed bf16");
assert_eq!(download(&mh_o)[..t * 5120], download(&mh_n)[..t * 5120], "case {case}: mixed f16");
assert_eq!(download(&fl2_o)[..flags_len], download(&fl2_n)[..flags_len], "case {case}: mix flags");
// ---- fused write + next norm
let (rw_o, rw_n) = (upload(&context, &rb), upload(&context, &rb));
let (bo_d, inj_d) = (upload(&context, &bob), upload(&context, &injb));
let (rs2_o, rs2_n, xn2_o, xn2_n, fl3_o, fl3_n) =
(mk(t * 16), mk(t * 16), mk(t * 20480), mk(t * 20480), mk(flags_len), mk(flags_len));
run_all(
&context,
&workspace,
vec![
(
&gr,
8,
t * 4,
256,
vec![
A::Address(h(&rw_o)),
A::Address(h(&bo_d)),
A::Address(h(&inj_d)),
A::I64(4),
A::Address(h(&w)),
A::F32(eps),
A::Address(h(&rs2_o)),
A::Address(h(&xn2_o)),
A::NullAddress,
],
),
(
&gr,
4,
(t * 10240).div_ceil(256),
256,
vec![A::Address(h(&rw_o)), A::Address(h(&fl3_o)), A::I64(10240), A::I64(t as i64), A::U32(7)],
),
(
&gr,
5,
(t * 10240).div_ceil(256),
256,
vec![
A::Address(h(&rw_o)),
A::Address(h(&rs2_o)),
A::Address(h(&w)),
A::Address(h(&fl3_o)),
A::I64(t as i64),
],
),
(
&stage,
5,
t * 4,
256,
vec![
A::Address(h(&rw_n)),
A::Address(h(&bo_d)),
A::Address(h(&inj_d)),
A::I64(4),
A::Address(h(&w)),
A::F32(eps),
A::Address(h(&rs2_n)),
A::Address(h(&xn2_n)),
A::NullAddress,
A::Address(h(&fl3_n)),
],
),
],
);
assert_eq!(download(&rw_o)[..t * 40960], download(&rw_n)[..t * 40960], "case {case}: R after fused write");
assert_eq!(download(&rs2_o)[..t * 16], download(&rs2_n)[..t * 16], "case {case}: rs after write");
assert_eq!(download(&xn2_o)[..t * 20480], download(&xn2_n)[..t * 20480], "case {case}: xn16 after write");
assert_eq!(download(&fl3_o)[..flags_len], download(&fl3_n)[..flags_len], "case {case}: write flags");
// ---- plain write
let (rp_o, rp_n) = (upload(&context, &rb), upload(&context, &rb));
let (fl4_o, fl4_n) = (mk(flags_len), mk(flags_len));
run_all(
&context,
&workspace,
vec![
(
&gr,
3,
(t * 10240).div_ceil(256),
256,
vec![
A::Address(h(&rp_o)),
A::Address(h(&bo_d)),
A::Address(h(&inj_d)),
A::I64(4),
A::I64(t as i64),
],
),
(
&gr,
4,
(t * 10240).div_ceil(256),
256,
vec![A::Address(h(&rp_o)), A::Address(h(&fl4_o)), A::I64(10240), A::I64(t as i64), A::U32(7)],
),
(
&stage,
6,
(t * 10240).div_ceil(256),
256,
vec![
A::Address(h(&rp_n)),
A::Address(h(&bo_d)),
A::Address(h(&inj_d)),
A::I64(4),
A::I64(t as i64),
A::Address(h(&fl4_n)),
],
),
],
);
assert_eq!(download(&rp_o)[..t * 40960], download(&rp_n)[..t * 40960], "case {case}: R after write");
assert_eq!(download(&fl4_o)[..flags_len], download(&fl4_n)[..flags_len], "case {case}: plain write flags");
let raised = [&fl_n, &fl2_n, &fl3_n, &fl4_n].iter().any(|f| download(f).iter().any(|b| *b != 0));
eprintln!("PREFILL-GR case {case}: outputs and flags equal (flags raised: {raised})");
if case == 0 {
assert!(!raised, "the clean case must raise nothing");
} else if case < 3 {
assert!(raised, "case {case} must raise a flag in both arms");
}
}
}
/// Timing only (row "256k prefill gap"): the three hyper-connection kernels of the prompt at the real chunk size (T = 8192 rows, a 335.5 MB residual
/// R) against the bytes they must move, as achieved GB/s. Prints `PREFILL-GR-TRAFFIC`. The RTX 5090's DRAM peak is 1.79 TB/s (about 1.5 TB/s is what a copy sustains).
#[test]
#[ignore = "Root-only: needs a CUDA device"]
fn gr_kernels_run_near_their_traffic_floor_at_chunk_size() {
assert_eq!(std::env::var(ENABLE).ok().as_deref(), Some("yes"));
let driver = crate::Driver::load().expect("driver");
let device = driver.device(0).expect("device");
let context = device.create_context(6usize << 30).expect("context");
let workspace = context.native_batch_workspace().expect("workspace");
let guard = context.enter().expect("enter");
let stage = KernelModule::load(crate::prefill_stage::PTX, crate::prefill_stage::ENTRIES).expect("stage module");
guard.finish().expect("finish");
let t = 8192usize;
let mut rng = Rng(0x1234_5678_9abc_def0);
let rnd = |rng: &mut Rng, n: usize, scale: f32| -> Vec<f32> {
(0..n).map(|_| ((rng.next() % 20001) as f32 / 10000.0 - 1.0) * scale).collect()
};
let (r, gamma, g, bo, inj) = (
rnd(&mut rng, t * 10240, 3.0),
rnd(&mut rng, 10240, 2.0),
rnd(&mut rng, t * 10240, 4.0),
rnd(&mut rng, t * 2560, 1.0),
rnd(&mut rng, t * 4, 2.0),
);
let mk = |n: usize| upload(&context, &vec![0u8; n]);
let (r_d, w_d, g_d, bo_d, inj_d) = (
upload(&context, &f32_bytes(&r)),
upload(&context, &f32_bytes(&gamma)),
upload(&context, &f32_bytes(&g)),
upload(&context, &f32_bytes(&bo)),
upload(&context, &f32_bytes(&inj)),
);
let (rs, xn, mx, m16, mh, fl) =
(mk(t * 16), mk(t * 20480), mk(t * 10240), mk(t * 5120), mk(t * 5120), mk(t * 8 * 4));
let eps = 1e-6f32;
let blas = workspace.blas().expect("blas");
let time = |what: &str, bytes: f64, launch: &mut dyn FnMut()| {
let guard = context.enter().expect("enter");
launch();
blas.synchronize().expect("sync");
let started = std::time::Instant::now();
for _ in 0..20 {
launch();
}
blas.synchronize().expect("sync");
let us = started.elapsed().as_secs_f64() * 1e6 / 20.0;
guard.finish().expect("finish");
eprintln!(
"PREFILL-GR-TRAFFIC {what}: {us:.0} us per call, {:.0} MB moved, {:.2} TB/s",
bytes / 1e6,
bytes / us / 1e6
);
};
let r_bytes = (t * 40960) as f64;
let mut keep = Vec::new();
let mut run = |index: usize, grid: usize, args: Vec<A>| {
let mut a = KernelArguments::new(args);
stage.launch(index, grid as u32, 256, blas.stream(), &mut a).expect("launch");
keep.push(a);
};
time("norm_rs (R in, xn16 out)", r_bytes + (t * 20480) as f64, &mut || {
run(
3,
t * 4,
vec![
A::Address(h(&r_d)),
A::Address(h(&w_d)),
A::F32(eps),
A::Address(h(&rs)),
A::Address(h(&xn)),
A::NullAddress,
A::Address(h(&fl)),
],
)
});
time(
"mix_r (R, g in; mixed f32 + bf16 + f16 out)",
2.0 * r_bytes + (t * (10240 + 5120 + 5120)) as f64,
&mut || {
run(
4,
(t * 2560).div_ceil(256),
vec![
A::Address(h(&r_d)),
A::Address(h(&rs)),
A::Address(h(&w_d)),
A::Address(h(&g_d)),
A::Address(h(&mx)),
A::Address(h(&m16)),
A::I64(t as i64),
A::Address(h(&mh)),
A::NullAddress,
A::Address(h(&fl)),
],
)
},
);
time(
"write_norm_rs (R in+out, bo in, xn16 out)",
2.0 * r_bytes + (t * 10240) as f64 + (t * 20480) as f64,
&mut || {
run(
5,
t * 4,
vec![
A::Address(h(&r_d)),
A::Address(h(&bo_d)),
A::Address(h(&inj_d)),
A::I64(4),
A::Address(h(&w_d)),
A::F32(eps),
A::Address(h(&rs)),
A::Address(h(&xn)),
A::NullAddress,
A::Address(h(&fl)),
],
)
},
);
}
#[path = "prefill_stage_gr_gpu/impl_rng.rs"]
mod impl_rng;
#[allow(unused_imports)]
@@ -446,3 +25,8 @@ use enable_types::ENABLE;
use enable_types::Launch;
#[allow(unused_imports)]
use enable_types::Rng;
#[path = "prefill_stage_gr_gpu/gr_fused_guards_equal.rs"]
mod gr_fused_guards_equal;
#[path = "prefill_stage_gr_gpu/gr_kernels_run_near_their.rs"]
mod gr_kernels_run_near_their;
@@ -0,0 +1,304 @@
//! Tests of prefill_stage_gr_gpu by topic (moved out of the test file by STRA-338):
//! gr_fused_guards_equal_the_separate_guard_kernels_bit_for_bit.
#[allow(unused_imports)]
use super::*;
#[test]
#[ignore = "Root-only: needs a CUDA device"]
fn gr_fused_guards_equal_the_separate_guard_kernels_bit_for_bit() {
assert_eq!(std::env::var(ENABLE).ok().as_deref(), Some("yes"));
let driver = crate::Driver::load().expect("driver");
let device = driver.device(0).expect("device");
let context = device.create_context(4usize << 30).expect("context");
let workspace = context.native_batch_workspace().expect("workspace");
let guard = context.enter().expect("enter");
let gr = KernelModule::load(GR_PTX, GR_ENTRIES).expect("gr module");
let stage = KernelModule::load(crate::prefill_stage::PTX, crate::prefill_stage::ENTRIES).expect("stage module");
guard.finish().expect("finish");
let t = 77usize;
let mut rng = Rng(0x2545f4914f6cdd1d);
let rnd = |rng: &mut Rng, n: usize, scale: f32| -> Vec<f32> {
(0..n).map(|_| ((rng.next() % 20001) as f32 / 10000.0 - 1.0) * scale).collect()
};
let eps = 1e-6f32;
// cases: clean, a non-finite R word, a non-finite gate word, an overflowing product
for case in 0..4 {
let mut r = rnd(&mut rng, t * 10240, 3.0);
let gamma = rnd(&mut rng, 10240, 2.0);
let mut g = rnd(&mut rng, t * 10240, 4.0);
let bo = rnd(&mut rng, t * 2560, 1.0);
let inj = rnd(&mut rng, t * 4, 2.0);
match case {
1 => r[5 * 10240 + 777] = f32::INFINITY,
2 => g[9 * 10240 + 3000] = f32::NAN,
3 => r[11 * 10240 + 100] = 3.0e38,
_ => {}
}
let flags_len = t * 8 * 4;
let (rb, wb, gb, bob, injb) =
(f32_bytes(&r), f32_bytes(&gamma), f32_bytes(&g), f32_bytes(&bo), f32_bytes(&inj));
let mk = |n: usize| upload(&context, &vec![0u8; n]);
// ---- norm
let (r_old, r_new) = (upload(&context, &rb), upload(&context, &rb));
let w = upload(&context, &wb);
let (rs_o, rs_n, xn_o, xn_n, fl_o, fl_n) =
(mk(t * 16), mk(t * 16), mk(t * 20480), mk(t * 20480), mk(flags_len), mk(flags_len));
run_all(
&context,
&workspace,
vec![
(
&gr,
0,
t * 4,
256,
vec![
A::Address(h(&r_old)),
A::Address(h(&w)),
A::F32(eps),
A::Address(h(&rs_o)),
A::Address(h(&xn_o)),
A::NullAddress,
],
),
(
&gr,
5,
(t * 10240).div_ceil(256),
256,
vec![
A::Address(h(&r_old)),
A::Address(h(&rs_o)),
A::Address(h(&w)),
A::Address(h(&fl_o)),
A::I64(t as i64),
],
),
(
&stage,
3,
t * 4,
256,
vec![
A::Address(h(&r_new)),
A::Address(h(&w)),
A::F32(eps),
A::Address(h(&rs_n)),
A::Address(h(&xn_n)),
A::NullAddress,
A::Address(h(&fl_n)),
],
),
],
);
assert_eq!(download(&rs_o)[..t * 16], download(&rs_n)[..t * 16], "case {case}: rs");
assert_eq!(download(&xn_o)[..t * 20480], download(&xn_n)[..t * 20480], "case {case}: xn16");
assert_eq!(download(&fl_o)[..flags_len], download(&fl_n)[..flags_len], "case {case}: norm flags");
// ---- mix (uses the rs above)
let g_dev = upload(&context, &gb);
let (mx_o, mx_n, m16_o, m16_n, mh_o, mh_n) =
(mk(t * 10240), mk(t * 10240), mk(t * 5120), mk(t * 5120), mk(t * 5120), mk(t * 5120));
let (fl2_o, fl2_n) = (mk(flags_len), mk(flags_len));
run_all(
&context,
&workspace,
vec![
(
&gr,
2,
(t * 2560).div_ceil(256),
256,
vec![
A::Address(h(&r_old)),
A::Address(h(&rs_o)),
A::Address(h(&w)),
A::Address(h(&g_dev)),
A::Address(h(&mx_o)),
A::Address(h(&m16_o)),
A::I64(t as i64),
A::Address(h(&mh_o)),
A::NullAddress,
],
),
(
&gr,
7,
(t * 10240).div_ceil(256),
256,
vec![
A::Address(h(&r_old)),
A::Address(h(&rs_o)),
A::Address(h(&w)),
A::Address(h(&g_dev)),
A::Address(h(&fl2_o)),
A::I64(t as i64),
],
),
(
&gr,
4,
(t * 10240).div_ceil(256),
256,
vec![A::Address(h(&g_dev)), A::Address(h(&fl2_o)), A::I64(10240), A::I64(t as i64), A::U32(3)],
),
(
&gr,
4,
(t * 2560).div_ceil(256),
256,
vec![A::Address(h(&mx_o)), A::Address(h(&fl2_o)), A::I64(2560), A::I64(t as i64), A::U32(5)],
),
(
&stage,
4,
(t * 2560).div_ceil(256),
256,
vec![
A::Address(h(&r_new)),
A::Address(h(&rs_n)),
A::Address(h(&w)),
A::Address(h(&g_dev)),
A::Address(h(&mx_n)),
A::Address(h(&m16_n)),
A::I64(t as i64),
A::Address(h(&mh_n)),
A::NullAddress,
A::Address(h(&fl2_n)),
],
),
],
);
assert_eq!(download(&mx_o)[..t * 10240], download(&mx_n)[..t * 10240], "case {case}: mixed");
assert_eq!(download(&m16_o)[..t * 5120], download(&m16_n)[..t * 5120], "case {case}: mixed bf16");
assert_eq!(download(&mh_o)[..t * 5120], download(&mh_n)[..t * 5120], "case {case}: mixed f16");
assert_eq!(download(&fl2_o)[..flags_len], download(&fl2_n)[..flags_len], "case {case}: mix flags");
// ---- fused write + next norm
let (rw_o, rw_n) = (upload(&context, &rb), upload(&context, &rb));
let (bo_d, inj_d) = (upload(&context, &bob), upload(&context, &injb));
let (rs2_o, rs2_n, xn2_o, xn2_n, fl3_o, fl3_n) =
(mk(t * 16), mk(t * 16), mk(t * 20480), mk(t * 20480), mk(flags_len), mk(flags_len));
run_all(
&context,
&workspace,
vec![
(
&gr,
8,
t * 4,
256,
vec![
A::Address(h(&rw_o)),
A::Address(h(&bo_d)),
A::Address(h(&inj_d)),
A::I64(4),
A::Address(h(&w)),
A::F32(eps),
A::Address(h(&rs2_o)),
A::Address(h(&xn2_o)),
A::NullAddress,
],
),
(
&gr,
4,
(t * 10240).div_ceil(256),
256,
vec![A::Address(h(&rw_o)), A::Address(h(&fl3_o)), A::I64(10240), A::I64(t as i64), A::U32(7)],
),
(
&gr,
5,
(t * 10240).div_ceil(256),
256,
vec![
A::Address(h(&rw_o)),
A::Address(h(&rs2_o)),
A::Address(h(&w)),
A::Address(h(&fl3_o)),
A::I64(t as i64),
],
),
(
&stage,
5,
t * 4,
256,
vec![
A::Address(h(&rw_n)),
A::Address(h(&bo_d)),
A::Address(h(&inj_d)),
A::I64(4),
A::Address(h(&w)),
A::F32(eps),
A::Address(h(&rs2_n)),
A::Address(h(&xn2_n)),
A::NullAddress,
A::Address(h(&fl3_n)),
],
),
],
);
assert_eq!(download(&rw_o)[..t * 40960], download(&rw_n)[..t * 40960], "case {case}: R after fused write");
assert_eq!(download(&rs2_o)[..t * 16], download(&rs2_n)[..t * 16], "case {case}: rs after write");
assert_eq!(download(&xn2_o)[..t * 20480], download(&xn2_n)[..t * 20480], "case {case}: xn16 after write");
assert_eq!(download(&fl3_o)[..flags_len], download(&fl3_n)[..flags_len], "case {case}: write flags");
// ---- plain write
let (rp_o, rp_n) = (upload(&context, &rb), upload(&context, &rb));
let (fl4_o, fl4_n) = (mk(flags_len), mk(flags_len));
run_all(
&context,
&workspace,
vec![
(
&gr,
3,
(t * 10240).div_ceil(256),
256,
vec![
A::Address(h(&rp_o)),
A::Address(h(&bo_d)),
A::Address(h(&inj_d)),
A::I64(4),
A::I64(t as i64),
],
),
(
&gr,
4,
(t * 10240).div_ceil(256),
256,
vec![A::Address(h(&rp_o)), A::Address(h(&fl4_o)), A::I64(10240), A::I64(t as i64), A::U32(7)],
),
(
&stage,
6,
(t * 10240).div_ceil(256),
256,
vec![
A::Address(h(&rp_n)),
A::Address(h(&bo_d)),
A::Address(h(&inj_d)),
A::I64(4),
A::I64(t as i64),
A::Address(h(&fl4_n)),
],
),
],
);
assert_eq!(download(&rp_o)[..t * 40960], download(&rp_n)[..t * 40960], "case {case}: R after write");
assert_eq!(download(&fl4_o)[..flags_len], download(&fl4_n)[..flags_len], "case {case}: plain write flags");
let raised = [&fl_n, &fl2_n, &fl3_n, &fl4_n].iter().any(|f| download(f).iter().any(|b| *b != 0));
eprintln!("PREFILL-GR case {case}: outputs and flags equal (flags raised: {raised})");
if case == 0 {
assert!(!raised, "the clean case must raise nothing");
} else if case < 3 {
assert!(raised, "case {case} must raise a flag in both arms");
}
}
}
@@ -0,0 +1,128 @@
//! Tests of prefill_stage_gr_gpu by topic (moved out of the test file by STRA-338):
//! gr_kernels_run_near_their_traffic_floor_at_chunk_size.
#[allow(unused_imports)]
use super::*;
/// Timing only (row "256k prefill gap"): the three hyper-connection kernels of the prompt at the real chunk size
/// (T = 8192 rows, a 335.5 MB residual R) against the bytes they must move, as achieved GB/s. Prints
/// `PREFILL-GR-TRAFFIC`. The RTX 5090's DRAM peak is 1.79 TB/s (about 1.5 TB/s is what a copy sustains).
#[test]
#[ignore = "Root-only: needs a CUDA device"]
fn gr_kernels_run_near_their_traffic_floor_at_chunk_size() {
assert_eq!(std::env::var(ENABLE).ok().as_deref(), Some("yes"));
let driver = crate::Driver::load().expect("driver");
let device = driver.device(0).expect("device");
let context = device.create_context(6usize << 30).expect("context");
let workspace = context.native_batch_workspace().expect("workspace");
let guard = context.enter().expect("enter");
let stage = KernelModule::load(crate::prefill_stage::PTX, crate::prefill_stage::ENTRIES).expect("stage module");
guard.finish().expect("finish");
let t = 8192usize;
let mut rng = Rng(0x1234_5678_9abc_def0);
let rnd = |rng: &mut Rng, n: usize, scale: f32| -> Vec<f32> {
(0..n).map(|_| ((rng.next() % 20001) as f32 / 10000.0 - 1.0) * scale).collect()
};
let (r, gamma, g, bo, inj) = (
rnd(&mut rng, t * 10240, 3.0),
rnd(&mut rng, 10240, 2.0),
rnd(&mut rng, t * 10240, 4.0),
rnd(&mut rng, t * 2560, 1.0),
rnd(&mut rng, t * 4, 2.0),
);
let mk = |n: usize| upload(&context, &vec![0u8; n]);
let (r_d, w_d, g_d, bo_d, inj_d) = (
upload(&context, &f32_bytes(&r)),
upload(&context, &f32_bytes(&gamma)),
upload(&context, &f32_bytes(&g)),
upload(&context, &f32_bytes(&bo)),
upload(&context, &f32_bytes(&inj)),
);
let (rs, xn, mx, m16, mh, fl) =
(mk(t * 16), mk(t * 20480), mk(t * 10240), mk(t * 5120), mk(t * 5120), mk(t * 8 * 4));
let eps = 1e-6f32;
let blas = workspace.blas().expect("blas");
let time = |what: &str, bytes: f64, launch: &mut dyn FnMut()| {
let guard = context.enter().expect("enter");
launch();
blas.synchronize().expect("sync");
let started = std::time::Instant::now();
for _ in 0..20 {
launch();
}
blas.synchronize().expect("sync");
let us = started.elapsed().as_secs_f64() * 1e6 / 20.0;
guard.finish().expect("finish");
eprintln!(
"PREFILL-GR-TRAFFIC {what}: {us:.0} us per call, {:.0} MB moved, {:.2} TB/s",
bytes / 1e6,
bytes / us / 1e6
);
};
let r_bytes = (t * 40960) as f64;
let mut keep = Vec::new();
let mut run = |index: usize, grid: usize, args: Vec<A>| {
let mut a = KernelArguments::new(args);
stage.launch(index, grid as u32, 256, blas.stream(), &mut a).expect("launch");
keep.push(a);
};
time("norm_rs (R in, xn16 out)", r_bytes + (t * 20480) as f64, &mut || {
run(
3,
t * 4,
vec![
A::Address(h(&r_d)),
A::Address(h(&w_d)),
A::F32(eps),
A::Address(h(&rs)),
A::Address(h(&xn)),
A::NullAddress,
A::Address(h(&fl)),
],
)
});
time(
"mix_r (R, g in; mixed f32 + bf16 + f16 out)",
2.0 * r_bytes + (t * (10240 + 5120 + 5120)) as f64,
&mut || {
run(
4,
(t * 2560).div_ceil(256),
vec![
A::Address(h(&r_d)),
A::Address(h(&rs)),
A::Address(h(&w_d)),
A::Address(h(&g_d)),
A::Address(h(&mx)),
A::Address(h(&m16)),
A::I64(t as i64),
A::Address(h(&mh)),
A::NullAddress,
A::Address(h(&fl)),
],
)
},
);
time(
"write_norm_rs (R in+out, bo in, xn16 out)",
2.0 * r_bytes + (t * 10240) as f64 + (t * 20480) as f64,
&mut || {
run(
5,
t * 4,
vec![
A::Address(h(&r_d)),
A::Address(h(&bo_d)),
A::Address(h(&inj_d)),
A::I64(4),
A::Address(h(&w_d)),
A::F32(eps),
A::Address(h(&rs)),
A::Address(h(&xn)),
A::NullAddress,
A::Address(h(&fl)),
],
)
},
);
}
@@ -6,5 +6,9 @@ use super::*;
mod impl_qsapromptindexworkspace;
#[path = "qsa_resident_index_program/impl_qsapromptindexworkspace_2.rs"]
mod impl_qsapromptindexworkspace_2;
#[path = "qsa_resident_index_program/impl_qsapromptindexworkspace_3.rs"]
mod impl_qsapromptindexworkspace_3;
#[allow(unused_imports)]
use impl_qsapromptindexworkspace_2::launch_label;
#[allow(unused_imports)]
use impl_qsapromptindexworkspace_3::{ArenaCall, ArenaIo, ArenaPlan, LateLaunch};
@@ -17,10 +17,47 @@ impl<'ctx> QsaPromptIndexWorkspace<'ctx> {
ws: &mut NativeBatchWorkspace<'ctx>,
decode: bool,
) -> Result<()> {
let n = t as usize;
let p = p0 as usize;
let end = p + n;
let nb = end / 4;
let call = ArenaCall { p0, t, raw: raw_h, qfull: qfull_h, iq: iq_h, gamma, out, decode };
self.run_arena(call, ws)
}
fn run_arena(&mut self, call: ArenaCall, ws: &mut NativeBatchWorkspace<'ctx>) -> Result<()> {
let n = call.t as usize;
let steps = Self::arena_steps(call.p0 as usize, n)?;
let status = self.handle(10, 64)?;
let mut plan = ArenaPlan::new(n)?;
let fast_select = !call.decode && crate::qsa_late::usable(self.context);
let (io, decode_positions) = self.arena_io(call, status)?;
self.plan_arena(&mut plan, &io, fast_select)?;
self.submit_arena(ws, plan, &io, (steps, decode_positions))
}
/// Runs the recorded program on the batch stream and checks its status words.
fn submit_arena(
&mut self,
ws: &mut NativeBatchWorkspace<'ctx>,
mut plan: ArenaPlan,
io: &ArenaIo,
host: (Vec<u8>, Vec<u8>),
) -> Result<()> {
let (steps, decode_positions) = host;
let zero = vec![0u8; 64];
let mut flags = vec![0u8; 64];
let context = self.context;
let guard = self.enter_arena(ws)?;
let blas = ws.blas()?;
let operation = self.launch_arena(blas, &mut plan, io, [&zero, &steps, &decode_positions]);
let sync = blas.synchronize();
let read = if sync.is_ok() { context.driver.api.copy_to(io.status, &mut flags) } else { Ok(()) };
let pop = guard.finish();
let result = combine(combine(combine(operation, sync), read), pop);
if result.is_err() {
self.fail_arena(ws);
std::mem::forget((plan.commands, steps, zero, flags, decode_positions));
return result;
}
self.check_arena_flags(&flags)
}
/// The step words of every row: position, position + 1, block of the next position, and the capped length.
fn arena_steps(p: usize, n: usize) -> Result<Vec<u8>> {
let mut steps = Vec::new();
steps.try_reserve_exact(n * 16).map_err(|_| Error::HostAllocation)?;
for row in 0..n {
@@ -29,374 +66,25 @@ impl<'ctx> QsaPromptIndexWorkspace<'ctx> {
steps.extend((x as i32).to_le_bytes());
}
}
let zero = vec![0u8; 64];
let mut flags = vec![0u8; 64];
let status = self.handle(10, 64)?;
let mut commands: Vec<(Launch, Arguments)> = Vec::new();
commands.try_reserve_exact(32 + 4 * n.div_ceil(256)).map_err(|_| Error::HostAllocation)?;
// (position in `commands` it runs before, grid, qsa_late entry, arguments)
let mut late: Vec<(usize, u32, usize, u32, crate::ple_batch_ffi::KernelArguments)> = Vec::new();
let fast_select = !decode && crate::qsa_late::usable(self.context);
let pushed = std::cell::Cell::new(0usize);
let mut push = |shape, args| -> Result<()> {
commands.push((shape, Arguments::for_launch(shape, args)?));
pushed.set(pushed.get() + 1);
Ok(())
};
let theta = crate::qsa_index_ffi::theta();
if !theta.is_finite() || theta <= 0.0 {
return Err(Error::InvalidDriverValue("QSA theta"));
}
let mut decode_positions = Vec::new();
let positions = if decode {
decode_positions.try_reserve_exact(24 * 4).map_err(|_| Error::HostAllocation)?;
for _ in 0..24 {
decode_positions.extend((p0 as i32).to_le_bytes());
}
let b = self.buffers[4].as_ref().ok_or(Error::ContextPoisoned)?;
let full = self.handle(4, self.sizes[4])?;
let h = full.checked_subspan(b.len(), self.sizes[4] - 24 * 4, 24 * 4)?;
h.validate_projection_extent(24 * 4, 4)?;
if h.overlaps(24 * 4, self.handle(4, n * 128 * 4)?, n * 128 * 4) {
return Err(Error::OutputAliasesInput);
}
Some(h)
} else {
None
};
let k_h = out[0];
let pooled_h = self.handle(0, self.sizes[0])?;
let tail_h = self.handle(1, self.sizes[1])?;
let dead_h = self.handle(2, self.sizes[2])?;
if let Some(positions) = positions {
push(
Launch::DecodeRms(2),
vec![A::Address(k_h), A::Address(gamma[1]), A::Address(k_h), A::I32(256), A::F32(1e-6)],
)?;
push(
Launch::DecodeRope(2),
vec![A::Address(k_h), A::Address(k_h), A::I32(2), A::I32(256), A::F32(theta), A::Address(positions)],
)?;
} else {
push(
Launch::Rms(t * 2),
vec![A::Address(k_h), A::Address(gamma[1]), A::I64(256), A::I64(256), A::F32(1e-6)],
)?;
push(
Launch::Rope(t * 2),
vec![A::Address(k_h), A::I64(2), A::I64(256), A::I64(512), A::I64(p0 as i64), A::F32(theta)],
)?;
}
push(
Launch::Scan((n * 512) as u32),
vec![A::Address(k_h), A::I64((n * 512) as i64), A::Address(status), A::U32(0)],
)?;
push(Launch::Split((n * 6144) as u32), vec![A::Address(qfull_h), A::Address(out[2]), A::I64(t as i64)])?;
if let Some(positions) = positions {
push(
Launch::DecodeRms(24),
vec![A::Address(out[2]), A::Address(gamma[0]), A::Address(out[2]), A::I32(256), A::F32(1e-6)],
)?;
push(
Launch::DecodeRope(24),
vec![
A::Address(out[2]),
A::Address(out[2]),
A::I32(24),
A::I32(256),
A::F32(theta),
A::Address(positions),
],
)?;
} else {
push(
Launch::Rms(t * 24),
vec![A::Address(out[2]), A::Address(gamma[0]), A::I64(256), A::I64(256), A::F32(1e-6)],
)?;
push(
Launch::Rope(t * 24),
vec![A::Address(out[2]), A::I64(24), A::I64(256), A::I64(6144), A::I64(p0 as i64), A::F32(theta)],
)?;
}
push(
Launch::Scan((n * 6144) as u32),
vec![A::Address(out[2]), A::I64((n * 6144) as i64), A::Address(status), A::U32(1)],
)?;
if let Some(positions) = positions {
push(
Launch::DecodeRms(4),
vec![A::Address(iq_h), A::Address(gamma[2]), A::Address(iq_h), A::I32(128), A::F32(1e-6)],
)?;
push(
Launch::DecodeRope(4),
vec![A::Address(iq_h), A::Address(iq_h), A::I32(4), A::I32(128), A::F32(theta), A::Address(positions)],
)?;
} else {
push(
Launch::Rms(t * 4),
vec![A::Address(iq_h), A::Address(gamma[2]), A::I64(128), A::I64(128), A::F32(1e-6)],
)?;
push(
Launch::Rope(t * 4),
vec![A::Address(iq_h), A::I64(4), A::I64(128), A::I64(512), A::I64(p0 as i64), A::F32(theta)],
)?;
}
push(
Launch::Scan((n * 512) as u32),
vec![A::Address(iq_h), A::I64((n * 512) as i64), A::Address(status), A::U32(2)],
)?;
if decode {
push(
Launch::DecodeAppend,
vec![
A::Address(raw_h),
A::Address(out[4]),
A::I32(0),
A::Address(gamma[3]),
A::F32(1e-6),
A::Address(tail_h),
A::Address(dead_h),
A::Address(pooled_h),
A::Address(self.handle(3, 4)?),
A::I32(crate::serving_context::geometry().cells() as i32),
A::F32(theta),
],
)?;
} else {
if p == 0 {
push(
Launch::First,
vec![
A::Address(raw_h),
A::Address(gamma[3]),
A::F32(1e-6),
A::Address(dead_h),
A::Address(pooled_h),
A::F32(theta),
],
)?;
}
let first = if p <= 3 { 0 } else { (p - 3).div_ceil(4) };
let hi = if end - 1 >= 3 { Some((end - 4) / 4) } else { None };
if let Some(hi) = hi.filter(|hi| *hi >= first) {
push(
Launch::Blocks((hi - first + 1) as u32),
vec![
A::Address(raw_h),
A::I64(t as i64),
A::I64(p0 as i64),
A::I32(0),
A::Address(gamma[3]),
A::F32(1e-6),
A::Address(tail_h),
A::Address(dead_h),
A::Address(pooled_h),
A::Address(self.handle(3, 4)?),
A::I64(first as i64),
A::I64(hi as i64),
A::F32(theta),
],
)?;
}
push(Launch::Tail, vec![A::Address(raw_h), A::I64(t as i64), A::I64(p0 as i64), A::Address(tail_h)])?;
}
for (h, count) in [(pooled_h, (nb + 1) * 128), (tail_h, 384), (dead_h, 128)] {
push(Launch::Scan(count as u32), vec![A::Address(h), A::I64(count as i64), A::Address(status), A::U32(3)])?;
}
// Original prompt selection reuses one 256-row score tile. Every
// offset is checked against the actual whole producer allocation.
let tile_rows = if decode { 1 } else { n.min(256) };
let scores = self.handle(9, tile_rows * max_blocks() * 4)?;
for first_row in (0..n).step_by(256) {
let count = (n - first_row).min(256);
let ct = count as u32;
let iq_tile = iq_h.checked_subspan(n * 512 * 4, first_row * 512 * 4, count * 512 * 4)?;
let steps_tile = out[4].checked_subspan(n * 16, first_row * 16, count * 16)?;
let ids_tile = out[3].checked_subspan(n * CAP * 4, first_row * CAP * 4, count * CAP * 4)?;
let tile_reach = (p + first_row + count) / 4 + 1;
if decode {
push(
Launch::DecodeScores,
vec![
A::Address(pooled_h),
A::Address(dead_h),
A::Address(iq_tile),
A::Address(steps_tile),
A::I32(1),
A::I64(max_blocks() as i64),
A::Address(scores),
],
)?;
} else {
push(
Launch::Tc { t: ct, reach: tile_reach as u32 },
vec![
A::Address(pooled_h),
A::Address(iq_tile),
A::Address(steps_tile),
A::I64(count as i64),
A::I64(max_blocks() as i64),
A::I64(tile_reach as i64),
A::Address(scores),
],
)?;
push(
Launch::ScoreTail(ct),
vec![
A::Address(dead_h),
A::Address(iq_tile),
A::Address(steps_tile),
A::I64(max_blocks() as i64),
A::Address(scores),
],
)?;
}
if fast_select && !decode {
// qsa_late.cu: the same flag over the blocks the tile can hold, and the same ids from coalesced reads
late.push((
pushed.get(),
(count * tile_reach).div_ceil(256) as u32,
crate::qsa_late::SCORE_SCAN_FAST,
256,
crate::ple_batch_ffi::KernelArguments::new(vec![
crate::ple_batch_ffi::BatchArg::Address(scores),
crate::ple_batch_ffi::BatchArg::Address(steps_tile),
crate::ple_batch_ffi::BatchArg::I32(count as i32),
crate::ple_batch_ffi::BatchArg::I64(max_blocks() as i64),
crate::ple_batch_ffi::BatchArg::I64(tile_reach as i64),
crate::ple_batch_ffi::BatchArg::Address(status),
crate::ple_batch_ffi::BatchArg::U32(4),
]),
));
let (topk_entry, topk_block) = crate::qsa_late::topk_entry(tile_reach);
late.push((
pushed.get(),
ct,
topk_entry,
topk_block,
crate::ple_batch_ffi::KernelArguments::new(vec![
crate::ple_batch_ffi::BatchArg::Address(scores),
crate::ple_batch_ffi::BatchArg::Address(steps_tile),
crate::ple_batch_ffi::BatchArg::I64(max_blocks() as i64),
crate::ple_batch_ffi::BatchArg::I64(CAP as i64),
crate::ple_batch_ffi::BatchArg::Address(ids_tile),
]),
));
} else {
push(
Launch::ScoreScan((count * max_blocks()) as u32),
vec![
A::Address(scores),
A::Address(steps_tile),
A::I32(count as i32),
A::I64(max_blocks() as i64),
A::Address(status),
A::U32(4),
],
)?;
push(
Launch::Topk(ct),
vec![
A::Address(scores),
A::Address(steps_tile),
A::I64(max_blocks() as i64),
A::I64(CAP as i64),
A::Address(ids_tile),
],
)?;
}
}
push(
Launch::Scan((n * 128) as u32),
vec![A::Address(raw_h), A::I64((n * 128) as i64), A::Address(status), A::U32(5)],
)?;
Ok(steps)
}
fn enter_arena(&mut self, ws: &mut NativeBatchWorkspace<'ctx>) -> Result<CurrentGuard<'ctx, 'ctx>> {
let context = self.context;
let guard = match context.enter() {
Ok(guard) => guard,
match context.enter() {
Ok(guard) => Ok(guard),
Err(error) => {
self.failed = true;
ws.mark_failed();
context.poison();
context.retain_driver();
return Err(error);
self.fail_arena(ws);
Err(error)
}
};
let blas = ws.blas()?;
let operation = (|| {
context.driver.api.copy_from(status, &zero)?;
context.driver.api.copy_from(out[4], &steps)?;
if let Some(positions) = positions {
context.driver.api.copy_from(positions, &decode_positions)?;
}
// Pageable uploads/status have a real dependency before the nonblocking shared stream.
context.driver.api.synchronize()?;
// LELEKA_PREFILL_PROFILE_SYNC: every launch drained on its own and charged to its kind (qsa-index#kind)
let timed = crate::command_profile::enabled();
if !late.is_empty() && self.late.is_none() {
self.late =
Some(crate::ple_batch_ffi::KernelModule::load(crate::qsa_late::PTX, crate::qsa_late::ENTRIES)?);
}
let module = self.module.as_ref().ok_or(Error::ContextPoisoned)?;
let mut next = 0usize;
let mut run_late = |upto: usize,
late: &mut Vec<(usize, u32, usize, u32, crate::ple_batch_ffi::KernelArguments)>,
next: &mut usize|
-> Result<()> {
while *next < late.len() && late[*next].0 <= upto {
let started = std::time::Instant::now();
let (_, grid, entry, block, args) = &mut late[*next];
self.late.as_ref().ok_or(Error::ContextPoisoned)?.launch(
*entry,
*grid,
*block,
blas.stream(),
args,
)?;
if timed {
blas.synchronize()?;
let topk = *entry != crate::qsa_late::SCORE_SCAN_FAST;
crate::command_profile::add(
"qsa-index",
if topk { 22 } else { 21 },
if *entry == crate::qsa_late::TOPK_WIDE {
"topk (wide)"
} else if topk {
"topk (fast)"
} else {
"score scan (fast)"
},
started.elapsed(),
);
}
*next += 1;
}
Ok(())
};
for (i, (shape, args)) in commands.iter_mut().enumerate() {
run_late(i, &mut late, &mut next)?;
let started = std::time::Instant::now();
module.launch(*shape, blas.stream(), args)?;
if timed {
blas.synchronize()?;
let (i, l) = launch_label(shape);
crate::command_profile::add("qsa-index", i, l, started.elapsed());
}
}
run_late(usize::MAX, &mut late, &mut next)?;
Ok(())
})();
let sync = blas.synchronize();
let read = if sync.is_ok() { context.driver.api.copy_to(status, &mut flags) } else { Ok(()) };
let pop = guard.finish();
if operation.is_err() || sync.is_err() || read.is_err() || pop.is_err() {
self.failed = true;
ws.mark_failed();
context.poison();
context.retain_driver();
std::mem::forget((commands, steps, zero, flags, decode_positions));
return combine(combine(combine(operation, sync), read), pop);
}
combine(combine(combine(operation, sync), read), pop)?;
}
fn fail_arena(&mut self, ws: &mut NativeBatchWorkspace<'ctx>) {
self.failed = true;
ws.mark_failed();
self.context.poison();
self.context.retain_driver();
}
fn check_arena_flags(&mut self, flags: &[u8]) -> Result<()> {
for flag in flags.as_chunks::<4>().0 {
if u32::from_le_bytes(*flag) > 1 {
self.failed = true;
@@ -412,4 +100,80 @@ impl<'ctx> QsaPromptIndexWorkspace<'ctx> {
}
Ok(())
}
/// Uploads the status, step words and decode positions, then submits the plan on the batch stream.
fn launch_arena(
&mut self,
blas: &crate::ple_batch_ffi::Blas,
plan: &mut ArenaPlan,
io: &ArenaIo,
uploads: [&[u8]; 3],
) -> Result<()> {
self.upload_arena(io, uploads)?;
// LELEKA_PREFILL_PROFILE_SYNC: every launch drained on its own and charged to its kind (qsa-index#kind)
let timed = crate::command_profile::enabled();
self.ensure_late(!plan.late.is_empty())?;
let module = self.module.as_ref().ok_or(Error::ContextPoisoned)?;
let mut next = 0usize;
for (i, (shape, args)) in plan.commands.iter_mut().enumerate() {
self.run_late(blas, &mut plan.late, &mut next, i, timed)?;
let started = std::time::Instant::now();
module.launch(*shape, blas.stream(), args)?;
if timed {
blas.synchronize()?;
let (i, l) = launch_label(shape);
crate::command_profile::add("qsa-index", i, l, started.elapsed());
}
}
self.run_late(blas, &mut plan.late, &mut next, usize::MAX, timed)
}
fn upload_arena(&self, io: &ArenaIo, uploads: [&[u8]; 3]) -> Result<()> {
let [zero, steps, decode_positions] = uploads;
let api = &self.context.driver.api;
api.copy_from(io.status, zero)?;
api.copy_from(io.out[4], steps)?;
if let Some(positions) = io.positions {
api.copy_from(positions, decode_positions)?;
}
// Pageable uploads/status have a real dependency before the nonblocking shared stream.
api.synchronize()
}
fn ensure_late(&mut self, wanted: bool) -> Result<()> {
if wanted && self.late.is_none() {
self.late = Some(crate::ple_batch_ffi::KernelModule::load(crate::qsa_late::PTX, crate::qsa_late::ENTRIES)?);
}
Ok(())
}
/// Launches the `qsa_late.cu` kernels that are due before command `upto`.
fn run_late(
&self,
blas: &crate::ple_batch_ffi::Blas,
late: &mut [LateLaunch],
next: &mut usize,
upto: usize,
timed: bool,
) -> Result<()> {
while *next < late.len() && late[*next].0 <= upto {
let started = std::time::Instant::now();
let (_, grid, entry, block, args) = &mut late[*next];
self.late.as_ref().ok_or(Error::ContextPoisoned)?.launch(*entry, *grid, *block, blas.stream(), args)?;
if timed {
blas.synchronize()?;
let topk = *entry != crate::qsa_late::SCORE_SCAN_FAST;
let label = late_label(*entry, topk);
crate::command_profile::add("qsa-index", if topk { 22 } else { 21 }, label, started.elapsed());
}
*next += 1;
}
Ok(())
}
}
fn late_label(entry: usize, topk: bool) -> &'static str {
if entry == crate::qsa_late::TOPK_WIDE {
"topk (wide)"
} else if topk {
"topk (fast)"
} else {
"score scan (fast)"
}
}
@@ -0,0 +1,327 @@
//! Launch plan of `run_resident_arena` (STRA-338): the program is recorded here in the order of the former single
//! function; the submission and the checks stay in `impl_qsapromptindexworkspace.rs`.
#[allow(unused_imports)]
use super::*;
/// A launch of `qsa_late.cu`: (position in `commands` it runs before, grid, entry, block, arguments).
pub(super) type LateLaunch = (usize, u32, usize, u32, crate::ple_batch_ffi::KernelArguments);
/// The arguments of `run_resident_arena`.
#[derive(Clone, Copy)]
pub(super) struct ArenaCall {
pub(super) p0: u32,
pub(super) t: u32,
pub(super) raw: ffi::BufferHandle,
pub(super) qfull: ffi::BufferHandle,
pub(super) iq: ffi::BufferHandle,
pub(super) gamma: [ffi::BufferHandle; 4],
pub(super) out: [ffi::BufferHandle; 5],
pub(super) decode: bool,
}
/// The call plus the buffers and scalars every launch of the program reads.
#[derive(Clone, Copy)]
pub(super) struct ArenaIo {
call: ArenaCall,
pub(super) status: ffi::BufferHandle,
pub(super) theta: f32,
pub(super) positions: Option<ffi::BufferHandle>,
pub(super) pooled: ffi::BufferHandle,
pub(super) tail: ffi::BufferHandle,
pub(super) dead: ffi::BufferHandle,
}
impl std::ops::Deref for ArenaIo {
type Target = ArenaCall;
fn deref(&self) -> &ArenaCall {
&self.call
}
}
/// The launches of one resident arena run, in submission order.
pub(super) struct ArenaPlan {
pub(super) commands: Vec<(Launch, Arguments)>,
pub(super) late: Vec<LateLaunch>,
pushed: usize,
}
/// One 256-row tile of the score selection.
struct Tile {
count: usize,
ct: u32,
iq: ffi::BufferHandle,
steps: ffi::BufferHandle,
ids: ffi::BufferHandle,
reach: usize,
scores: ffi::BufferHandle,
}
impl ArenaPlan {
pub(super) fn new(n: usize) -> Result<Self> {
let mut commands = Vec::new();
commands.try_reserve_exact(32 + 4 * n.div_ceil(256)).map_err(|_| Error::HostAllocation)?;
Ok(Self { commands, late: Vec::new(), pushed: 0 })
}
fn push(&mut self, shape: Launch, args: Vec<A>) -> Result<()> {
self.commands.push((shape, Arguments::for_launch(shape, args)?));
self.pushed += 1;
Ok(())
}
fn defer(&mut self, grid: u32, entry: usize, block: u32, args: crate::ple_batch_ffi::KernelArguments) {
self.late.push((self.pushed, grid, entry, block, args));
}
fn scan(&mut self, io: &ArenaIo, data: ffi::BufferHandle, count: usize, slot: u32) -> Result<()> {
let args = vec![A::Address(data), A::I64(count as i64), A::Address(io.status), A::U32(slot)];
self.push(Launch::Scan(count as u32), args)
}
fn norm_rope(
&mut self,
io: &ArenaIo,
data: ffi::BufferHandle,
gamma: ffi::BufferHandle,
shape: [i64; 3],
) -> Result<()> {
match io.positions {
Some(positions) => self.norm_rope_decode(io.theta, data, gamma, positions, shape),
None => self.norm_rope_prompt(io, data, gamma, shape),
}
}
fn norm_rope_decode(
&mut self,
theta: f32,
data: ffi::BufferHandle,
gamma: ffi::BufferHandle,
positions: ffi::BufferHandle,
shape: [i64; 3],
) -> Result<()> {
let [heads, width, _] = shape;
let (d, g, w) = (A::Address(data), A::Address(gamma), width as i32);
self.push(Launch::DecodeRms(heads as u32), vec![d, g, A::Address(data), A::I32(w), A::F32(1e-6)])?;
let args = vec![
A::Address(data),
A::Address(data),
A::I32(heads as i32),
A::I32(w),
A::F32(theta),
A::Address(positions),
];
self.push(Launch::DecodeRope(heads as u32), args)
}
fn norm_rope_prompt(
&mut self,
io: &ArenaIo,
data: ffi::BufferHandle,
gamma: ffi::BufferHandle,
shape: [i64; 3],
) -> Result<()> {
let [heads, width, stride] = shape;
let (d, g) = (A::Address(data), A::Address(gamma));
self.push(Launch::Rms(io.t * heads as u32), vec![d, g, A::I64(width), A::I64(width), A::F32(1e-6)])?;
let args = vec![
A::Address(data),
A::I64(heads),
A::I64(width),
A::I64(stride),
A::I64(io.p0 as i64),
A::F32(io.theta),
];
self.push(Launch::Rope(io.t * heads as u32), args)
}
}
impl<'ctx> QsaPromptIndexWorkspace<'ctx> {
pub(super) fn arena_io(&self, call: ArenaCall, status: ffi::BufferHandle) -> Result<(ArenaIo, Vec<u8>)> {
let theta = crate::qsa_index_ffi::theta();
if !theta.is_finite() || theta <= 0.0 {
return Err(Error::InvalidDriverValue("QSA theta"));
}
let (bytes, positions) = self.decode_positions(&call)?;
let pooled = self.handle(0, self.sizes[0])?;
let tail = self.handle(1, self.sizes[1])?;
let dead = self.handle(2, self.sizes[2])?;
Ok((ArenaIo { call, status, theta, positions, pooled, tail, dead }, bytes))
}
fn decode_positions(&self, call: &ArenaCall) -> Result<(Vec<u8>, Option<ffi::BufferHandle>)> {
let mut bytes = Vec::new();
if !call.decode {
return Ok((bytes, None));
}
bytes.try_reserve_exact(24 * 4).map_err(|_| Error::HostAllocation)?;
for _ in 0..24 {
bytes.extend((call.p0 as i32).to_le_bytes());
}
let n = call.t as usize;
let b = self.buffers[4].as_ref().ok_or(Error::ContextPoisoned)?;
let full = self.handle(4, self.sizes[4])?;
let h = full.checked_subspan(b.len(), self.sizes[4] - 24 * 4, 24 * 4)?;
h.validate_projection_extent(24 * 4, 4)?;
if h.overlaps(24 * 4, self.handle(4, n * 128 * 4)?, n * 128 * 4) {
return Err(Error::OutputAliasesInput);
}
Ok((bytes, Some(h)))
}
/// Records the whole index program of the call (the order of the former single function).
pub(super) fn plan_arena(&self, plan: &mut ArenaPlan, io: &ArenaIo, fast_select: bool) -> Result<()> {
let n = io.t as usize;
self.plan_projections(plan, io)?;
if io.decode {
self.plan_decode_append(plan, io)?;
} else {
self.plan_prompt_append(plan, io)?;
}
let nb = (io.p0 as usize + n) / 4;
for (h, count) in [(io.pooled, (nb + 1) * 128), (io.tail, 384), (io.dead, 128)] {
plan.scan(io, h, count, 3)?;
}
self.plan_tiles(plan, io, fast_select)?;
plan.scan(io, io.raw, n * 128, 5)
}
fn plan_projections(&self, plan: &mut ArenaPlan, io: &ArenaIo) -> Result<()> {
let n = io.t as usize;
plan.norm_rope(io, io.out[0], io.gamma[1], [2, 256, 512])?;
plan.scan(io, io.out[0], n * 512, 0)?;
plan.push(
Launch::Split((n * 6144) as u32),
vec![A::Address(io.qfull), A::Address(io.out[2]), A::I64(io.t as i64)],
)?;
plan.norm_rope(io, io.out[2], io.gamma[0], [24, 256, 6144])?;
plan.scan(io, io.out[2], n * 6144, 1)?;
plan.norm_rope(io, io.iq, io.gamma[2], [4, 128, 512])?;
plan.scan(io, io.iq, n * 512, 2)
}
fn plan_decode_append(&self, plan: &mut ArenaPlan, io: &ArenaIo) -> Result<()> {
plan.push(
Launch::DecodeAppend,
vec![
A::Address(io.raw),
A::Address(io.out[4]),
A::I32(0),
A::Address(io.gamma[3]),
A::F32(1e-6),
A::Address(io.tail),
A::Address(io.dead),
A::Address(io.pooled),
A::Address(self.handle(3, 4)?),
A::I32(crate::serving_context::geometry().cells() as i32),
A::F32(io.theta),
],
)
}
fn plan_prompt_append(&self, plan: &mut ArenaPlan, io: &ArenaIo) -> Result<()> {
let (p, t) = (io.p0 as usize, io.t as i64);
if p == 0 {
let (raw, gamma, dead, pooled) = (io.raw, io.gamma[3], io.dead, io.pooled);
let (raw, gamma, dead, pooled) = (A::Address(raw), A::Address(gamma), A::Address(dead), A::Address(pooled));
plan.push(Launch::First, vec![raw, gamma, A::F32(1e-6), dead, pooled, A::F32(io.theta)])?;
}
self.plan_blocks(plan, io)?;
plan.push(Launch::Tail, vec![A::Address(io.raw), A::I64(t), A::I64(p as i64), A::Address(io.tail)])
}
fn plan_blocks(&self, plan: &mut ArenaPlan, io: &ArenaIo) -> Result<()> {
let p = io.p0 as usize;
let end = p + io.t as usize;
let first = if p <= 3 { 0 } else { (p - 3).div_ceil(4) };
let hi = if end - 1 >= 3 { Some((end - 4) / 4) } else { None };
let Some(hi) = hi.filter(|hi| *hi >= first) else {
return Ok(());
};
plan.push(
Launch::Blocks((hi - first + 1) as u32),
vec![
A::Address(io.raw),
A::I64(io.t as i64),
A::I64(p as i64),
A::I32(0),
A::Address(io.gamma[3]),
A::F32(1e-6),
A::Address(io.tail),
A::Address(io.dead),
A::Address(io.pooled),
A::Address(self.handle(3, 4)?),
A::I64(first as i64),
A::I64(hi as i64),
A::F32(io.theta),
],
)
}
/// Original prompt selection reuses one 256-row score tile. Every offset is checked against the actual whole
/// producer allocation.
fn plan_tiles(&self, plan: &mut ArenaPlan, io: &ArenaIo, fast_select: bool) -> Result<()> {
let n = io.t as usize;
let tile_rows = if io.decode { 1 } else { n.min(256) };
let scores = self.handle(9, tile_rows * max_blocks() * 4)?;
for first_row in (0..n).step_by(256) {
let tile = Tile::new(io, scores, first_row)?;
self.plan_scores(plan, io, &tile)?;
if fast_select && !io.decode {
Self::plan_late_select(plan, io, &tile);
} else {
Self::plan_scan_select(plan, io, &tile)?;
}
}
Ok(())
}
fn plan_scores(&self, plan: &mut ArenaPlan, io: &ArenaIo, tile: &Tile) -> Result<()> {
let mb = max_blocks() as i64;
let (pooled, dead, iq, steps, scores) = (io.pooled, io.dead, tile.iq, tile.steps, tile.scores);
let (pooled, dead, iq, steps, scores) =
(A::Address(pooled), A::Address(dead), A::Address(iq), A::Address(steps), A::Address(scores));
if io.decode {
return plan.push(Launch::DecodeScores, vec![pooled, dead, iq, steps, A::I32(1), A::I64(mb), scores]);
}
let (count, reach) = (A::I64(tile.count as i64), A::I64(tile.reach as i64));
let tc = Launch::Tc { t: tile.ct, reach: tile.reach as u32 };
plan.push(tc, vec![pooled, iq, steps, count, A::I64(mb), reach, scores])?;
let (iq, steps, scores) = (A::Address(tile.iq), A::Address(tile.steps), A::Address(tile.scores));
plan.push(Launch::ScoreTail(tile.ct), vec![dead, iq, steps, A::I64(mb), scores])
}
/// qsa_late.cu: the same flag over the blocks the tile can hold, and the same ids from coalesced reads.
fn plan_late_select(plan: &mut ArenaPlan, io: &ArenaIo, tile: &Tile) {
use crate::ple_batch_ffi::{BatchArg as B, KernelArguments as Args};
let mb = max_blocks() as i64;
let (scores, steps) = (B::Address(tile.scores), B::Address(tile.steps));
plan.defer(
(tile.count * tile.reach).div_ceil(256) as u32,
crate::qsa_late::SCORE_SCAN_FAST,
256,
Args::new(vec![
scores,
steps,
B::I32(tile.count as i32),
B::I64(mb),
B::I64(tile.reach as i64),
B::Address(io.status),
B::U32(4),
]),
);
let (topk_entry, topk_block) = crate::qsa_late::topk_entry(tile.reach);
let (scores, steps) = (B::Address(tile.scores), B::Address(tile.steps));
let args = Args::new(vec![scores, steps, B::I64(mb), B::I64(CAP as i64), B::Address(tile.ids)]);
plan.defer(tile.ct, topk_entry, topk_block, args);
}
fn plan_scan_select(plan: &mut ArenaPlan, io: &ArenaIo, tile: &Tile) -> Result<()> {
let mb = max_blocks() as i64;
let (scores, steps) = (A::Address(tile.scores), A::Address(tile.steps));
plan.push(
Launch::ScoreScan((tile.count * max_blocks()) as u32),
vec![scores, steps, A::I32(tile.count as i32), A::I64(mb), A::Address(io.status), A::U32(4)],
)?;
let (scores, steps) = (A::Address(tile.scores), A::Address(tile.steps));
let args = vec![scores, steps, A::I64(mb), A::I64(CAP as i64), A::Address(tile.ids)];
plan.push(Launch::Topk(tile.ct), args)
}
}
impl Tile {
fn new(io: &ArenaIo, scores: ffi::BufferHandle, first_row: usize) -> Result<Self> {
let n = io.t as usize;
let count = (n - first_row).min(256);
let ct = count as u32;
let iq = io.iq.checked_subspan(n * 512 * 4, first_row * 512 * 4, count * 512 * 4)?;
let steps = io.out[4].checked_subspan(n * 16, first_row * 16, count * 16)?;
let ids = io.out[3].checked_subspan(n * CAP * 4, first_row * CAP * 4, count * CAP * 4)?;
let reach = (io.p0 as usize + first_row + count) / 4 + 1;
Ok(Self { count, ct, iq, steps, ids, reach, scores })
}
}
+290
View File
@@ -0,0 +1,290 @@
//! Plain `pub use` re-exports of the crate root, moved out of `lib.rs` by STRA-338 (the public paths are unchanged).
#[allow(unused_imports)]
use super::*;
pub use device_slab::{DeviceSlice, SlabAllocator, SlabPolicy, SlabStats};
pub use gdn_state_finite_guard::GdnStateFiniteGuard;
pub use head_greedy::{HEAD_GREEDY_WORKSPACE_BYTES, HeadGreedySelection, HeadGreedyWorkspace};
pub use mmq::resident::original_group::{
OriginalMmqCopySchedule, OriginalMmqLayer, OriginalMmqOutput, original_mmq_group_bank_bytes,
};
pub use mmq::resident::{FiniteMmqOutput, MmqChunkActivation, MmqGroupActivation, MmqHidden, MmqWorkspace};
pub use mmq::{MmqExperiment, MmqFormat, MmqProfile, MmqWeights};
pub use mtp_dense_kv::MTP_ORIGINAL_WINDOW;
pub use mtp_dense_kv::MtpDenseKvRing;
pub use mtp_dense_kv::{
CompletedMtpAttention, CompletedMtpKvReplay, MtpInt8OwnerId, MtpInt8Snapshot, MtpOriginalInt8, MtpOriginalMixed,
MtpOriginalQuery,
};
pub use original_expert_cache::OriginalExpertCache;
pub use original_gpu_schedule::{
OriginalCapture, OriginalCapturePolicy, OriginalEventKind, OriginalGpuEvent, OriginalGpuGraph, OriginalGpuStream,
OriginalGraphFlight, OriginalGraphKey, OriginalGraphRegistry, OriginalGraphResources, OriginalStreamKind,
OriginalWait,
};
pub use original_moe_prompt_device::{OriginalMoePromptDevice, OriginalMoePromptLayer};
pub use original_mtp_actor::{ActorRefusal as OriginalMtpActorRefusal, DraftSettings as OriginalMtpDraftSettings};
#[cfg(all(feature = "cuda-driver", any(target_os = "linux", target_os = "windows"), target_pointer_width = "64"))]
pub use original_mtp_actor::{OriginalMtpActor, OriginalMtpLoadEvidence, OriginalMtpLoadMeter};
pub use original_mtp_bank::{
OriginalMtpLoadFailure, OriginalMtpRtBank, OriginalMtpRtTensor, OriginalMtpTensorKind,
original_mtp_draft_vocab_bytes,
};
#[cfg(all(feature = "cuda-driver", any(target_os = "linux", target_os = "windows"), target_pointer_width = "64"))]
pub use original_mtp_draft_head::OriginalMtpDraftHead;
pub use original_mtp_loader::{
CoupledPlan as OriginalMtpCoupledPlan, KvFormat as OriginalMtpKvFormat, KvMode as OriginalMtpKvMode,
KvPlan as OriginalMtpKvPlan, LoaderError as OriginalMtpPlanError, OriginalMtpCapture, OriginalMtpKvStartup,
OriginalMtpLoadPlan, WeightBankPlan as OriginalMtpWeightBankPlan, original_mtp_bind_reserve,
};
pub use original_prefill_arena::{OriginalPrefillArena, OriginalPromptLeaseIdentity, OriginalPromptRows};
pub use original_prefill_layout::{
OriginalPrefillLayout, PrefillKvStage, PrefillLayoutOptions, PrefillPhase, PrefillSpan,
};
pub use original_session_state::{
OriginalGeometryFacts, OriginalHostKv, OriginalIdxKind, OriginalKvLayer, OriginalKvPool, OriginalQsaFacts,
OriginalRegion, OriginalSessionBytes, OriginalSessionControl, OriginalSessionFacts,
};
pub use qsa_selected_kv::{QsaSelectedKvProducts, QsaSelectedKvWorkspace};
pub use qwen_dispatch::gr_batch_read::{GrMicroValues, GrMicrobatchRead};
pub use routed_group_workspace::RoutedColumnsLoan;
pub use routed_group_workspace::RoutedGroupWorkspace;
pub use routed_stage_finite_guard::{RoutedFiniteStage, RoutedStageFiniteGuard};
pub use serving_context::{
KV_RESIDENT_DEFAULT_CELLS, KV_RESIDENT_MIN_CELLS, MAX_CONTEXT_CELLS, ServingContext, TRAINED_CONTEXT_CELLS,
configure_kv_resident, configure_serving_context, kv_resident_cells, serving_context,
};
#[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64", feature = "cuda-driver"))]
pub use qwen_dispatch::batch_gr_preview::GrBatchModule;
pub use qwen_dispatch::qwen_shared_tail::{
SharedDownKind, SharedExpertWeights, SharedExpertWorkspace, SharedGuKind, SharedTailCompletion, SharedTailRefusal,
};
// Additive closed MTP input transport owners.
pub use qwen_dispatch::gdn_closed_queue::{GdnQueueStage, GdnRowCompletion, GdnRowPrefix, GdnRowQueue};
#[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64", feature = "cuda-driver"))]
pub use qwen_dispatch::gdn_fused_t1::{
GDN_FUSED_T1_PERSISTENT_BYTES, GDN_FUSED_T1_STATE_BYTES, GdnFusedCompletion, GdnFusedPrefix, GdnFusedStage,
GdnFusedT1,
};
#[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64", feature = "cuda-driver"))]
pub use qwen_dispatch::gdn_native_batch::{
GDN_BATCH_EPSILON, GDN_BATCH_MAX_TOKENS, GdnBatchCompletion, GdnBatchPrefix, GdnBatchStage, GdnGemm,
GdnNativeFormat, GdnPrefillBatch, GdnStream, GemmShape, OriginalGdnPromptDevice, OriginalGdnPromptWeights,
};
#[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64", feature = "cuda-driver"))]
pub use qwen_dispatch::moe_prefill_batch::{
MOE_BATCH_MAX_TOKENS, MOE_BATCH_SCRATCH_BYTES, MoeBatchCompletion, MoeBatchPrefix, MoeBatchStage, MoePrefillBatch,
MoeRouteBatch,
};
pub use qwen_dispatch::mtp_input_workspace::{MtpInputCompletion, MtpInputPrefix, MtpInputRefusal, MtpInputWorkspace};
pub use async_owned_copy::{CompletedOwnedCopy, MAX_ASYNC_COPY_PAIRS, OwnedCopyPairs, OwnedCopyPoll, PendingOwnedCopy};
#[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64", feature = "cuda-driver"))]
pub use qwen_dispatch::gr_batch_inject_workspace::{
GR_BATCH_INJECT_WORKSPACE_BYTES, GrBatchInjectShape, GrBatchInjectWorkspace,
};
pub use routed_resident_queue::{
RoutedResidentCompletion, RoutedResidentQueue, RoutedResidentRefusal, RoutedResidentWeights,
};
pub use mapped_expert_bank::{
MappedExpertBank, MappedExpertCopyCompletion, MappedExpertCopyScratch, PendingMappedExpertCopy,
};
pub use qwen_dispatch::ple_closed_queue::{
PleClosedCompletion, PleClosedParts, PleClosedQueue, PleClosedRefusal, PleClosedWeights,
};
#[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))]
pub use gdn_batch_gemm::NativeGdnGemm;
pub use native_batch_workspace::{NATIVE_BATCH_WORKSPACE_BYTES, NativeBatchWorkspace};
pub use ple_batch_queue::{PLE_BATCH_QUEUE_BYTES, PleBatchCompletion, PleBatchQueue, PleBatchRow, PleBf16Mode};
#[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))]
pub use qsa_native_batch::{
QSA_NATIVE_BATCH_BYTES, QsaNativeBatchWorkspace, QsaNativeKind, QsaNativePacking, QsaNativeProjections,
};
#[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))]
pub use qsa_native_decode::{QSA_NATIVE_DECODE_BYTES, QsaNativeDecode, QsaNativeDecodeCompletion};
#[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))]
pub use qsa_prompt_attention::{
QSA_PROMPT_ATTENTION_BYTES, QsaAttentionInputs, QsaPromptAttention, QsaPromptAttentionCompletion,
};
#[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))]
pub use qsa_prompt_index::{
OriginalQsaDeviceSelection, OriginalQsaPromptDevice, OriginalQsaPromptWeights, QSA_PROMPT_INDEX_BYTES,
QsaPromptIndexPrefix, QsaPromptIndexState, QsaPromptIndexWorkspace, QsaPromptSelection,
};
#[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))]
pub use qsa_prompt_kv::{
CompletedQsaKvAppend, QSA_PROMPT_MAPPED_HOST_BYTES, QSA_PROMPT_MAX_SNAPSHOT_METADATA_BYTES,
QSA_PROMPT_MAX_SNAPSHOT_PAYLOAD_BYTES, QSA_PROMPT_RESIDENT_BYTES, QSA_PROMPT_STAGE_BYTES, QsaKvInputs,
QsaKvOwnerId, QsaKvSnapshot, QsaPromptKv, QsaPromptStage,
};
pub use qsa_prompt_resolver::KvStreamCounters;
pub use qwen_dispatch::gr_native_batch::{GrNativeBatch, GrNativeProfile};
pub use gpu_report::gpu_kernel_report;
pub use native_prompt_device::{
OriginalDeviceBlock, OriginalDeviceGrRead, OriginalDeviceNormedResidual, OriginalDeviceResidual,
OriginalPleHistory, OriginalPromptDevice, PromptInputStage,
};
pub use original_sampler::{OriginalSampler, SamplerParams, SamplerPath};
pub use prefill_stage::{
set_gdn_nostore_override as set_prefill_gdn_nostore_override, set_gdn_override as set_prefill_gdn_override,
};
pub use qsa_cluster::{requested as qsa_cluster_requested, set_override as set_qsa_cluster_override};
pub use qsa_late::set_override as set_qsa_late_override;
pub use qsa_late::set_topk_override as set_qsa_topk_override;
#[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))]
pub use qsa_native_decode::OriginalQsaResidentDecodeCompletion;
pub use qsa_native_gate::QsaNativeGate;
#[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))]
pub use qsa_prompt_attention::OriginalQsaResidentAttention;
#[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))]
pub use qsa_prompt_index::{
OriginalQsaIndexBatch, OriginalQsaIndexCheckpoint, OriginalQsaResidentIndex, OriginalQsaResidentPromptDevice,
OriginalQsaResidentScalarIndex, OriginalQsaResidentScalarSelection, OriginalQsaResidentSelection,
};
pub use qsa_prompt_kv::set_qsa_prefetch_override;
#[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))]
pub use qsa_prompt_kv::{
OriginalQsaMappedAppend, OriginalQsaMappedJournal, OriginalQsaMappedPrefix, OriginalQsaResidentTransport,
};
#[cfg(all(feature = "cuda-driver", any(target_os = "linux", target_os = "windows"), target_pointer_width = "64"))]
pub use mtp_dense_kv::OriginalMtpSkippedPrefix;
pub use mtp_dense_kv::{
CompletedDraftKv, DraftKvFallback, DraftKvOutcome, DraftKvPolicy, OriginalMtpEmbedding, OriginalMtpPrefill,
OriginalMtpPrefillWeights,
};
#[cfg(all(feature = "cuda-driver", any(target_os = "linux", target_os = "windows"), target_pointer_width = "64"))]
pub use mtp_dense_kv::{
CompletedOriginalMtpDraft, OriginalMtpDraftProgram, OriginalMtpDrafter, OriginalMtpForwardProgram,
OriginalMtpFullForward, OriginalMtpFullPolicy, OriginalMtpRetainedFullWeights, OriginalMtpRetainedPrefix,
OriginalMtpStepOutput,
};
#[cfg(all(feature = "cuda-driver", any(target_os = "linux", target_os = "windows"), target_pointer_width = "64"))]
pub use native_parity::{
NativeParity, NativeParityExpert, native_parity_embed_supported, native_parity_iq_supported,
native_parity_row_bytes,
};
#[cfg(all(feature = "cuda-driver", any(target_os = "linux", target_os = "windows"), target_pointer_width = "64"))]
pub use original_expert_stager::{
OriginalExpertStager, OriginalFileExpertBlob, OriginalStagerBatch, OriginalStagerCompleted, OriginalStagerJob,
OriginalStagerOptions, OriginalStreamAll, OriginalStreamAllCompleted, OriginalStreamAllForward,
OriginalStreamAllOptions,
};
#[cfg(all(feature = "cuda-driver", any(target_os = "linux", target_os = "windows"), target_pointer_width = "64"))]
pub use mtp_dense_kv::{
OriginalMtpGrVariant, OriginalMtpRetainedScalarWeights, OriginalMtpScalarPolicy, OriginalMtpScalarPrefill,
};
#[cfg(all(feature = "cuda-driver", any(target_os = "linux", target_os = "windows"), target_pointer_width = "64"))]
pub use native_head::{
NativeEmbedFlight, NativeHeadDispatch, NativeHeadFlight, NativeHeadProjectionFlight, NativeHeadSampling,
NativeHeadSelection, OriginalNativeEmbed, OriginalNativeEmbedRows, OriginalNativeHead,
OriginalNativeHeadGraphResources, OriginalNativeHeadRows, native_embed_supported, native_head_row_bytes,
native_head_supported,
};
#[cfg(all(feature = "cuda-driver", any(target_os = "linux", target_os = "windows"), target_pointer_width = "64"))]
pub use original_file_expert_source::{
OriginalFileExpertSource, OriginalFileSourceBlob, OriginalFileSourceCounters, OriginalResidentOptions,
OriginalSourceSwap,
};
#[cfg(all(feature = "cuda-driver", any(target_os = "linux", target_os = "windows"), target_pointer_width = "64"))]
pub use original_gpu_schedule::OriginalStreamDrained;
pub use original_gpu_schedule::capture_timing as original_capture_timing;
#[cfg(all(feature = "cuda-driver", any(target_os = "linux", target_os = "windows"), target_pointer_width = "64"))]
pub use original_verify::chain::set_down_override as set_chain_down_override;
pub use original_verify::sm120::set_overrides as set_sm120_overrides;
#[cfg(all(feature = "cuda-driver", any(target_os = "linux", target_os = "windows"), target_pointer_width = "64"))]
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,
};
// Live verifier release/diagnostic owner, profile report and completed-logit readout.
#[cfg(all(feature = "cuda-driver", any(target_os = "linux", target_os = "windows"), target_pointer_width = "64"))]
#[allow(unused_imports)]
pub use impl_devicebuffer::chain_selects_mtp;
#[cfg(not(all(
feature = "cuda-driver",
any(target_os = "linux", target_os = "windows"),
target_pointer_width = "64"
)))]
#[allow(unused_imports)]
pub use impl_devicebuffer::chain_selects_mtp;
#[cfg(not(all(
feature = "cuda-driver",
any(target_os = "linux", target_os = "windows"),
target_pointer_width = "64"
)))]
#[allow(unused_imports)]
pub use impl_devicebuffer::set_chain_down_override;
#[cfg(all(feature = "cuda-driver", any(target_os = "linux", target_os = "windows"), target_pointer_width = "64"))]
pub use original_serve_assets::{
OriginalAssetKind, OriginalAssetStatus, original_serve_asset_status, original_serve_assets_sealed,
unsealed_original_serve_assets,
};
#[cfg(all(feature = "cuda-driver", any(target_os = "linux", target_os = "windows"), target_pointer_width = "64"))]
pub use original_verify::{
ExpertTier, HcHalf, OriginalVerifyDiag, OriginalVerifyExpertLayout, OriginalVerifyProfile,
OriginalVerifyWindowResources, PROFILE_STAMPS_PER_LAYER, PlanLayout, Projection, QuantSource, RowLogprob,
Rows as OriginalVerifyRows, UNBOUND_PRODUCERS, WINDOW_LAYERS, WindowOps as OriginalVerifyWindowOps,
WindowPolicy as OriginalVerifyWindowPolicy, analyse_row, logpos_topk_from_environment, original_verify_diagnostics,
original_verify_live_count, original_verify_release_live, profile_stamp_slot, profile_stamp_words,
record_window as record_original_verify_window, top_k, write_original_verify_diagnostics, write_row_line,
write_window_logprobs,
};
#[cfg(all(feature = "cuda-driver", any(target_os = "linux", target_os = "windows"), target_pointer_width = "64"))]
pub use original_verify::{
HcHalfBuffers, HcLayerBuffers, HcOutputBuffers, OriginalVerifyExpertFormats, OriginalVerifyGdnProjections,
OriginalVerifyGrBinding, OriginalVerifyMoeBinding, OriginalVerifyMoeLayerWeights, OriginalVerifyNativeMatrix,
OriginalVerifyProjBinding, OriginalVerifyQsaBinding, OriginalVerifyQsaKvBinding, OriginalVerifyQsaLayerWeights,
OriginalVerifyQsaPolicy, OriginalVerifyQsaProjections, PLE_SCRATCH_BYTES, PleBuffers, PleKeyBuffer, QsaRope,
unsealed_window_assets,
};
#[cfg(all(
feature = "cuda-driver",
feature = "expert-tier-probe",
any(target_os = "linux", target_os = "windows"),
target_pointer_width = "64"
))]
pub use original_verify::{OriginalExpertTierProbe, expert_probe_geometry};
#[allow(unused_imports)]
pub use prompt_sync_trace_types::Bf16ProjectionShape;
#[allow(unused_imports)]
pub use prompt_sync_trace_types::Context;
#[allow(unused_imports)]
pub use prompt_sync_trace_types::DenseFormat;
#[allow(unused_imports)]
pub use prompt_sync_trace_types::Device;
#[allow(unused_imports)]
pub use prompt_sync_trace_types::Driver;
#[allow(unused_imports)]
pub use prompt_sync_trace_types::Error;
#[allow(unused_imports)]
pub use prompt_sync_trace_types::ProjectionKind;
#[allow(unused_imports)]
pub use prompt_sync_trace_types::ProjectionSpec;
#[allow(unused_imports)]
pub use prompt_sync_trace_types::PromptSyncTrace;
#[allow(unused_imports)]
pub use prompt_sync_trace_types::Q5KProjectionShape;
#[allow(unused_imports)]
pub use prompt_sync_trace_types::Q6KProjectionShape;
#[allow(unused_imports)]
pub use prompt_sync_trace_types::Result;
#[allow(unused_imports)]
pub use prompt_sync_trace_types::RoutedFormat;
#[allow(unused_imports)]
pub use prompt_sync_trace_types::RoutedGateUpQ8;
#[allow(unused_imports)]
pub use q5_kshape_types::DeviceBuffer;
#[cfg(all(feature = "cuda-driver", any(target_os = "linux", target_os = "windows"), target_pointer_width = "64"))]
pub use qsa_prompt_index::{OriginalVerifyQsaJournal, OriginalVerifyRope};
+63 -920
View File
@@ -2,7 +2,11 @@
// Table of the sm_86 companions of the sealed sm_120 PTX (see docs/sm86-assets.md).
// `key` = SHA-256 of the sealed sm_120 body (file without its terminal NUL); `len` = companion length
// including the terminal NUL that is appended here; `sha` = SHA-256 of the companion body.
//
// STRA-338: the rows live in `sm86_table/part_1..5.rs` (each file stays under the 400-line limit); `COMPANIONS` is
// their concatenation, built at compile time, so the content and the order are those of the former single table.
#[derive(Clone, Copy)]
pub(crate) struct Companion {
pub name: &'static str,
pub key: [u8; 32],
@@ -11,924 +15,63 @@ pub(crate) struct Companion {
pub ptx: &'static [u8],
}
mod part_1;
mod part_2;
mod part_3;
mod part_4;
mod part_5;
/// Number of rows over all parts.
const ROWS: usize = 131;
const fn join(parts: [&[Companion]; 5]) -> [Companion; ROWS] {
let mut out = [Companion { name: "", key: [0; 32], len: 0, sha: [0; 32], ptx: &[] }; ROWS];
let (mut at, mut part) = (0, 0);
while part < parts.len() {
let mut row = 0;
while row < parts[part].len() {
out[at] = parts[part][row];
at += 1;
row += 1;
}
part += 1;
}
assert!(at == ROWS);
out
}
const JOINED: [Companion; ROWS] = join([part_1::ROWS, part_2::ROWS, part_3::ROWS, part_4::ROWS, part_5::ROWS]);
/// Sorted by `key`.
#[rustfmt::skip]
pub(crate) static COMPANIONS: &[Companion] = &[
Companion {
name: "ple_bf16_pack.ptx",
key: [0x01, 0x59, 0x28, 0xed, 0xe2, 0x02, 0x42, 0xc6, 0x31, 0x51, 0x30, 0x7b, 0xd5, 0x02, 0xbf, 0x98, 0xf4, 0xfb, 0x58, 0x0b, 0xad, 0x2b, 0x7d, 0x34, 0x72, 0xee, 0xbb, 0xa1, 0x12, 0x95, 0x30, 0xb3],
len: 8276,
sha: [0xb5, 0xe9, 0x9b, 0x53, 0x10, 0xcf, 0x1c, 0x92, 0x11, 0x67, 0x45, 0x06, 0x42, 0x6e, 0xe8, 0x99, 0x68, 0xd1, 0x4a, 0xb7, 0x71, 0x80, 0x55, 0x3d, 0x94, 0xd5, 0xbd, 0xb8, 0x8e, 0x3c, 0x9c, 0x09],
ptx: concat!(include_str!("../ptx-sm86/ple_bf16_pack.ptx"), "\0").as_bytes(),
},
Companion {
name: "offline_native_dequant_f16.ptx",
key: [0x02, 0x0b, 0xc7, 0x97, 0xfc, 0x5a, 0x8f, 0x36, 0x23, 0x07, 0x54, 0x36, 0xb4, 0x4e, 0x02, 0x1a, 0x2e, 0x97, 0xff, 0xba, 0xaa, 0xbf, 0x54, 0xd2, 0x73, 0xea, 0xce, 0xc1, 0x31, 0x32, 0xeb, 0x2a],
len: 58080,
sha: [0x24, 0x31, 0xc2, 0x8a, 0x19, 0x52, 0x5c, 0x64, 0xb7, 0xf9, 0x75, 0x30, 0x6e, 0x01, 0x99, 0xce, 0x0f, 0x0d, 0x68, 0xf5, 0x5d, 0x22, 0x39, 0xe4, 0xb4, 0x72, 0x80, 0x9f, 0x1e, 0x17, 0x36, 0x70],
ptx: concat!(include_str!("../ptx-sm86/offline_native_dequant_f16.ptx"), "\0").as_bytes(),
},
Companion {
name: "kar_ple_fixed.ptx",
key: [0x03, 0xc9, 0xf6, 0x63, 0x49, 0x5b, 0xea, 0xf1, 0xdd, 0x42, 0x02, 0x5f, 0x14, 0x80, 0x9b, 0x7b, 0xfb, 0x8c, 0xd7, 0xad, 0x4c, 0x7f, 0xb5, 0x5e, 0x17, 0x3a, 0x79, 0xb1, 0xa9, 0x72, 0x0c, 0x3b],
len: 5210,
sha: [0x76, 0xda, 0x12, 0x64, 0x39, 0xb0, 0x93, 0xf3, 0x9e, 0xda, 0x77, 0x14, 0x29, 0x9b, 0x6d, 0xf9, 0xc9, 0xa6, 0x0f, 0xaf, 0x43, 0xcb, 0x75, 0x8f, 0x49, 0xf3, 0x12, 0x42, 0x75, 0xce, 0xcf, 0x56],
ptx: concat!(include_str!("../ptx-sm86/kar_ple_fixed.ptx"), "\0").as_bytes(),
},
Companion {
name: "bf16_f32_mmvf.ptx",
key: [0x04, 0x45, 0x43, 0xf6, 0x81, 0xbb, 0x23, 0xeb, 0x9c, 0xae, 0x60, 0x2b, 0x1a, 0x16, 0xaa, 0x7b, 0x23, 0x86, 0xd6, 0xd5, 0xc3, 0xb1, 0x5c, 0xc4, 0x19, 0x87, 0x33, 0x8b, 0xd6, 0x13, 0xb1, 0xc3],
len: 5875,
sha: [0x54, 0xa3, 0x31, 0x46, 0x55, 0x8e, 0xf7, 0x6c, 0x81, 0x7f, 0xc8, 0xe5, 0x56, 0xf7, 0x09, 0x22, 0x8f, 0x90, 0xe2, 0xcc, 0xd6, 0x56, 0x5f, 0x57, 0xc4, 0xf8, 0xec, 0x46, 0x46, 0xe6, 0xc4, 0x42],
ptx: concat!(include_str!("../ptx-sm86/bf16_f32_mmvf.ptx"), "\0").as_bytes(),
},
Companion {
name: "moe_group_iq4_xs_nc4.ptx",
key: [0x06, 0x11, 0xaa, 0x38, 0x6b, 0x2b, 0x36, 0x6e, 0x99, 0x42, 0xd5, 0x37, 0x17, 0x5b, 0xe5, 0xb1, 0xd9, 0x6e, 0x9c, 0x33, 0xbe, 0x5e, 0x12, 0x36, 0xc8, 0xb4, 0x6a, 0x83, 0x18, 0xf6, 0xb6, 0xc1],
len: 74210,
sha: [0x7c, 0xf9, 0x63, 0x32, 0x59, 0x2e, 0x39, 0x9b, 0x49, 0xe8, 0x4e, 0x53, 0x40, 0xff, 0xbb, 0xab, 0x26, 0xdb, 0x49, 0x25, 0x9a, 0x9b, 0x5e, 0x03, 0x04, 0x79, 0x4c, 0x1c, 0x0f, 0x54, 0x79, 0x41],
ptx: concat!(include_str!("../ptx-sm86/moe_group_iq4_xs_nc4.ptx"), "\0").as_bytes(),
},
Companion {
name: "q8_1_quantize.ptx",
key: [0x06, 0x40, 0x3c, 0x31, 0xe0, 0x94, 0x4b, 0x39, 0xc6, 0x8f, 0x3a, 0xf6, 0x37, 0xe3, 0x3d, 0xaa, 0x5f, 0x3d, 0x4c, 0x07, 0x26, 0x8f, 0x6b, 0xce, 0x15, 0x0c, 0x89, 0x1b, 0x9c, 0xf2, 0x33, 0xb0],
len: 7200,
sha: [0xbb, 0x46, 0xb0, 0x53, 0xaf, 0x13, 0x94, 0xc4, 0x62, 0x17, 0x39, 0x3b, 0x4f, 0x7e, 0xff, 0xc1, 0xc9, 0x5f, 0xc4, 0x8a, 0xa5, 0x54, 0x68, 0x2a, 0xfb, 0xa5, 0xea, 0xeb, 0x0c, 0xd9, 0xc0, 0x6a],
ptx: concat!(include_str!("../ptx-sm86/q8_1_quantize.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_full_gr_norm.ptx",
key: [0x06, 0xd6, 0x17, 0x7b, 0x48, 0x2c, 0xb6, 0x74, 0x13, 0xc6, 0x59, 0x6a, 0x02, 0x91, 0xb4, 0xda, 0xb1, 0x85, 0x03, 0x32, 0x16, 0x4a, 0x92, 0x12, 0xaf, 0xf6, 0x7b, 0x9e, 0xfd, 0xf2, 0x11, 0x20],
len: 29069,
sha: [0xaa, 0x51, 0x98, 0x13, 0x94, 0xa9, 0x4a, 0xe2, 0x22, 0xf4, 0x4c, 0x23, 0x9d, 0xff, 0x1e, 0xf2, 0x3c, 0xa7, 0xab, 0xda, 0x2a, 0xb0, 0x8f, 0x17, 0x95, 0x43, 0xd6, 0x2e, 0x71, 0x19, 0xd2, 0x1a],
ptx: concat!(include_str!("../ptx-sm86/mtp_original_full_gr_norm.ptx"), "\0").as_bytes(),
},
Companion {
name: "offline_moe_prefill.ptx",
key: [0x07, 0x5e, 0xf4, 0x38, 0xcd, 0xb6, 0x21, 0x15, 0x05, 0x46, 0xdb, 0xef, 0xf8, 0xf5, 0xe6, 0xfd, 0xc4, 0xaa, 0xeb, 0xc2, 0xe7, 0xfa, 0x10, 0x99, 0xe6, 0xcc, 0x6e, 0xff, 0x3f, 0x5b, 0x6f, 0x34],
len: 71011,
sha: [0xe1, 0x5e, 0x02, 0x23, 0xec, 0x1d, 0x55, 0x5a, 0x3b, 0x89, 0xd7, 0xcb, 0xe3, 0xa6, 0xe9, 0xa0, 0xfe, 0x45, 0xb6, 0x5d, 0x39, 0x02, 0x90, 0x10, 0xd5, 0x19, 0xc7, 0x31, 0x32, 0x48, 0xcc, 0x7f],
ptx: concat!(include_str!("../ptx-sm86/offline_moe_prefill.ptx"), "\0").as_bytes(),
},
Companion {
name: "moe_group_down_iq4_nl.ptx",
key: [0x0b, 0x7b, 0xa2, 0xb0, 0x0b, 0x91, 0xb6, 0x64, 0x50, 0x51, 0x82, 0xbe, 0xf3, 0x2c, 0xac, 0xad, 0x06, 0x3f, 0x11, 0xee, 0x37, 0xed, 0x93, 0x13, 0x29, 0x64, 0x8d, 0x3e, 0xe4, 0xa0, 0x4d, 0x5a],
len: 8620,
sha: [0x7d, 0xcf, 0xdb, 0x60, 0x83, 0x16, 0xcb, 0x28, 0xf0, 0x77, 0x6a, 0x10, 0xf8, 0x40, 0xb1, 0x98, 0x81, 0x43, 0x5c, 0x75, 0xb7, 0xf4, 0xf2, 0x2b, 0xa2, 0xc3, 0xfe, 0xf9, 0xe5, 0xbb, 0x89, 0xcb],
ptx: concat!(include_str!("../ptx-sm86/moe_group_down_iq4_nl.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_s2_fixed.ptx",
key: [0x0b, 0xf7, 0xb8, 0x12, 0x8c, 0x2d, 0x59, 0x0e, 0x36, 0xc8, 0xc5, 0x55, 0x97, 0xb4, 0xd0, 0x2f, 0x3c, 0x50, 0x7e, 0x12, 0x0f, 0x3d, 0x09, 0x1c, 0xb3, 0x54, 0xea, 0xee, 0x9e, 0x09, 0x74, 0xf7],
len: 103812,
sha: [0x97, 0xef, 0x26, 0x18, 0x0d, 0x6c, 0xa0, 0xa6, 0xc3, 0xb4, 0xe2, 0x8c, 0x55, 0x5b, 0xf4, 0x94, 0x12, 0x17, 0x5b, 0x7c, 0x65, 0x2d, 0x71, 0xa3, 0x1d, 0xc4, 0xee, 0x09, 0x7d, 0xc2, 0xc1, 0xb2],
ptx: concat!(include_str!("../ptx-sm86/mtp_s2_fixed.ptx"), "\0").as_bytes(),
},
Companion {
name: "mmq-adaptive-selected.ptx",
key: [0x0c, 0x7f, 0xa1, 0x08, 0x28, 0x02, 0x0b, 0x9e, 0xc8, 0x9b, 0x8b, 0x2f, 0xe5, 0x85, 0x50, 0x2c, 0x84, 0x89, 0xbe, 0x92, 0xf1, 0xf8, 0x25, 0x18, 0x7d, 0x4c, 0x6b, 0x90, 0xf1, 0x06, 0x49, 0x48],
len: 3249625,
sha: [0x3f, 0x3c, 0xbc, 0x5f, 0x2d, 0x2d, 0xc8, 0x23, 0x83, 0xb1, 0x5a, 0x0d, 0xaf, 0xf0, 0x7f, 0xb6, 0x77, 0xcc, 0x4e, 0x45, 0xfb, 0x35, 0x73, 0x7d, 0xdc, 0x61, 0x41, 0x2f, 0xff, 0x3f, 0x79, 0x2c],
ptx: concat!(include_str!("../ptx-sm86/mmq-adaptive-selected.ptx"), "\0").as_bytes(),
},
Companion {
name: "mapped_expert_copy.ptx",
key: [0x10, 0x51, 0x98, 0x85, 0xee, 0x9d, 0xab, 0xb6, 0x00, 0x10, 0x15, 0x4e, 0x2f, 0x80, 0x9b, 0x39, 0x73, 0x61, 0x86, 0xba, 0x1c, 0x0d, 0xac, 0x11, 0xa2, 0x40, 0x96, 0x5d, 0x05, 0x77, 0x62, 0x57],
len: 5620,
sha: [0x11, 0xda, 0x70, 0xf0, 0x16, 0x18, 0xa2, 0xa6, 0xf9, 0xd6, 0x59, 0xa6, 0xda, 0x03, 0xbb, 0x90, 0x48, 0x0d, 0x4c, 0xbd, 0x14, 0x1d, 0x3c, 0x36, 0x6c, 0xfe, 0x90, 0xc2, 0x65, 0x9d, 0x11, 0xb0],
ptx: concat!(include_str!("../ptx-sm86/mapped_expert_copy.ptx"), "\0").as_bytes(),
},
Companion {
name: "original_verify_window_qsa_gate.ptx",
key: [0x10, 0x80, 0x7c, 0x4c, 0x62, 0xd8, 0xbf, 0x4b, 0xe7, 0x5c, 0xfb, 0x1a, 0x50, 0x77, 0xfc, 0x3e, 0x00, 0xdc, 0x8f, 0x40, 0xea, 0x66, 0x9b, 0x22, 0xdc, 0xff, 0x7b, 0x78, 0x53, 0xab, 0x79, 0x49],
len: 2232,
sha: [0x0c, 0x13, 0xa5, 0xf2, 0x95, 0x3f, 0x70, 0x7b, 0xb2, 0x87, 0xbc, 0x53, 0x25, 0x83, 0xf3, 0xfd, 0x69, 0xae, 0x8e, 0x80, 0xa7, 0x6e, 0x61, 0xdc, 0x88, 0x27, 0xe1, 0x3f, 0x00, 0x6b, 0x48, 0x49],
ptx: concat!(include_str!("../ptx-sm86/original_verify_window_qsa_gate.ptx"), "\0").as_bytes(),
},
Companion {
name: "gr_native_batch.ptx",
key: [0x10, 0xa3, 0xe8, 0x36, 0xb9, 0x02, 0xe9, 0xa3, 0x87, 0x05, 0x5e, 0x98, 0x0c, 0x3e, 0xd0, 0x45, 0xe9, 0x0b, 0xdc, 0x25, 0x1e, 0xe1, 0xe6, 0xbe, 0x57, 0x66, 0x81, 0x61, 0x8f, 0x62, 0x1d, 0xb2],
len: 29664,
sha: [0xda, 0xec, 0x53, 0x68, 0x4c, 0x0c, 0xc3, 0x08, 0x8d, 0x46, 0xe9, 0x24, 0x14, 0x2d, 0xd3, 0x61, 0x32, 0xa5, 0x9f, 0xb7, 0x87, 0x16, 0x56, 0x94, 0xd1, 0x48, 0x27, 0xaf, 0xd3, 0x10, 0xd9, 0xc9],
ptx: concat!(include_str!("../ptx-sm86/gr_native_batch.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_full_checks.ptx",
key: [0x16, 0xcb, 0x9f, 0x01, 0xe5, 0x4b, 0x05, 0x33, 0x43, 0x99, 0x37, 0xdd, 0x09, 0xae, 0xa4, 0xcc, 0xf9, 0x8d, 0xf7, 0x36, 0x76, 0xeb, 0x2b, 0x79, 0x62, 0x98, 0xac, 0x72, 0xe1, 0x27, 0xa5, 0x91],
len: 115865,
sha: [0x70, 0x7a, 0xd0, 0xce, 0x70, 0xa3, 0x2b, 0x33, 0x34, 0x8b, 0x26, 0x48, 0xfd, 0xfe, 0x44, 0xaa, 0xe0, 0xd1, 0xfa, 0x1c, 0x43, 0x0a, 0x97, 0xe7, 0x39, 0x64, 0x2e, 0x4b, 0xc3, 0x38, 0x1e, 0x62],
ptx: concat!(include_str!("../ptx-sm86/mtp_original_full_checks.ptx"), "\0").as_bytes(),
},
Companion {
name: "iq4_nl_q8_1.ptx",
key: [0x18, 0x9b, 0x02, 0xce, 0xe8, 0x18, 0x63, 0x79, 0xfb, 0x7b, 0x0b, 0xd0, 0x7a, 0x83, 0x1e, 0x1f, 0xb2, 0x76, 0x4d, 0x29, 0xa9, 0x8a, 0x17, 0xfd, 0x2b, 0x51, 0x6c, 0x54, 0x59, 0xf9, 0xd4, 0xce],
len: 38554,
sha: [0xeb, 0x57, 0xbb, 0xff, 0x87, 0x55, 0x63, 0x75, 0xe2, 0xf9, 0x84, 0x95, 0x5b, 0x7d, 0x28, 0x9d, 0xf1, 0xfc, 0xab, 0xf8, 0xca, 0x20, 0x84, 0x88, 0xfa, 0x73, 0xbb, 0x3d, 0xc2, 0xe8, 0x11, 0x76],
ptx: concat!(include_str!("../ptx-sm86/iq4_nl_q8_1.ptx"), "\0").as_bytes(),
},
Companion {
name: "experimental_cvec.ptx",
key: [0x19, 0x3a, 0xdd, 0x5c, 0xb4, 0x48, 0xf5, 0xe1, 0x93, 0xf2, 0x0f, 0xf2, 0x48, 0xca, 0x44, 0x59, 0xab, 0xb9, 0x62, 0xb4, 0x72, 0x66, 0x3c, 0x00, 0xd1, 0x89, 0x41, 0x31, 0x3b, 0xfa, 0x3e, 0xbc],
len: 28943,
sha: [0x09, 0x43, 0xc5, 0xc0, 0x4e, 0xf8, 0x63, 0x4b, 0x8e, 0xb6, 0x11, 0x33, 0x32, 0x9a, 0xd7, 0x30, 0xf6, 0xbc, 0x39, 0xdc, 0x4e, 0x55, 0xce, 0x9a, 0xc6, 0x25, 0x87, 0x1f, 0xa1, 0x62, 0x58, 0x78],
ptx: concat!(include_str!("../ptx-sm86/experimental_cvec.ptx"), "\0").as_bytes(),
},
Companion {
name: "experimental_keyless.ptx",
key: [0x1a, 0xb8, 0xb8, 0x15, 0x6e, 0x8c, 0x82, 0x41, 0x31, 0xc0, 0x0c, 0xec, 0xda, 0x17, 0x7f, 0xe5, 0x7d, 0x74, 0xb2, 0x86, 0xa0, 0x2b, 0x7e, 0x5a, 0xfd, 0xfa, 0x39, 0xac, 0xad, 0xaa, 0x33, 0xe6],
len: 3760,
sha: [0x0a, 0x16, 0xc1, 0x19, 0x5e, 0x25, 0x74, 0x7c, 0xb0, 0x7b, 0x18, 0x34, 0xf7, 0xc4, 0x52, 0xb8, 0x91, 0x0c, 0x27, 0xac, 0x2b, 0x7d, 0x30, 0xb9, 0xf6, 0x68, 0x7d, 0x28, 0xcc, 0x76, 0xb8, 0xb9],
ptx: concat!(include_str!("../ptx-sm86/experimental_keyless.ptx"), "\0").as_bytes(),
},
Companion {
name: "qsa_prompt_attention.ptx",
key: [0x1c, 0x89, 0xe6, 0xcb, 0xc8, 0xbb, 0x52, 0xb4, 0x64, 0x96, 0xa1, 0xca, 0xe3, 0x14, 0x3a, 0x8a, 0xd6, 0xcb, 0x8e, 0x8d, 0xb7, 0x0f, 0x4e, 0x6d, 0x5a, 0x87, 0x4d, 0x59, 0xfd, 0xdd, 0x4a, 0x07],
len: 96184,
sha: [0xf3, 0x2c, 0x26, 0xe3, 0xdf, 0x42, 0xa4, 0xa2, 0xda, 0x00, 0xf2, 0xa9, 0x79, 0x1e, 0x1a, 0xb8, 0x98, 0x41, 0x61, 0xe8, 0x9e, 0x20, 0x3e, 0xdf, 0x88, 0x0a, 0xdc, 0xc8, 0x30, 0xe2, 0x43, 0x5c],
ptx: concat!(include_str!("../ptx-sm86/qsa_prompt_attention.ptx"), "\0").as_bytes(),
},
Companion {
name: "qsa_prompt_select.ptx",
key: [0x1e, 0x35, 0x51, 0x47, 0x44, 0x21, 0x62, 0x29, 0xb0, 0xcf, 0xfb, 0x4f, 0x45, 0xd2, 0xf1, 0x3f, 0x25, 0xcb, 0x95, 0xf3, 0x77, 0xa3, 0x0c, 0x1c, 0x01, 0x25, 0x43, 0xdb, 0xf5, 0x3a, 0x1c, 0x2d],
len: 97179,
sha: [0x38, 0xef, 0x04, 0x0e, 0xff, 0x7b, 0x93, 0xe2, 0xaf, 0x2c, 0x15, 0x3f, 0xb1, 0xd9, 0x35, 0x24, 0xbd, 0xf1, 0x65, 0x42, 0x8a, 0xa2, 0xf8, 0xcf, 0xbd, 0xa5, 0x08, 0x3e, 0xc4, 0x07, 0x1d, 0xf3],
ptx: concat!(include_str!("../ptx-sm86/qsa_prompt_select.ptx"), "\0").as_bytes(),
},
Companion {
name: "moe_group_iq2_s.ptx",
key: [0x1e, 0x5c, 0x05, 0x7c, 0xfb, 0x36, 0xd3, 0x51, 0xcc, 0xb2, 0xba, 0x54, 0x6c, 0xf2, 0x95, 0xd1, 0x3b, 0xfa, 0x00, 0x30, 0x65, 0xeb, 0x9b, 0x41, 0x5b, 0xf0, 0xc0, 0x11, 0x8b, 0xd4, 0x80, 0x4a],
len: 42048,
sha: [0xe8, 0xcb, 0x46, 0x20, 0xf1, 0xe2, 0xcf, 0x38, 0xd5, 0x6b, 0x87, 0x55, 0x33, 0xc3, 0x9e, 0x27, 0x95, 0x94, 0x86, 0x2f, 0x77, 0x9e, 0x73, 0x1e, 0x50, 0x1d, 0xed, 0x50, 0xb2, 0xf8, 0xf5, 0x92],
ptx: concat!(include_str!("../ptx-sm86/moe_group_iq2_s.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_full_qsa_gate.ptx",
key: [0x21, 0xf1, 0xa0, 0x14, 0xbf, 0xa0, 0x59, 0x74, 0x3a, 0x7c, 0x9d, 0x55, 0x3a, 0x46, 0x15, 0xf5, 0x48, 0x82, 0x0b, 0xb4, 0xe7, 0xc4, 0x8f, 0x4e, 0xf1, 0xd7, 0x1f, 0x05, 0x07, 0x7b, 0x4b, 0x25],
len: 26053,
sha: [0xb4, 0x22, 0x8c, 0x01, 0x5b, 0xb0, 0xb0, 0x62, 0x6d, 0x31, 0x40, 0x62, 0x77, 0x20, 0x94, 0x39, 0x0a, 0xd3, 0xba, 0xa6, 0x86, 0x64, 0xd7, 0x29, 0x9b, 0x2a, 0x17, 0x11, 0x80, 0xa4, 0x7c, 0x64],
ptx: concat!(include_str!("../ptx-sm86/mtp_original_full_qsa_gate.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_full_combine.ptx",
key: [0x22, 0x53, 0xfe, 0x2d, 0x64, 0x13, 0x50, 0xf4, 0x44, 0x5a, 0x0a, 0x69, 0xc4, 0xa0, 0xfc, 0x22, 0xb8, 0x5c, 0x2f, 0xff, 0xca, 0x7c, 0xbd, 0x53, 0x6f, 0xfe, 0x5d, 0x29, 0x12, 0xf8, 0x1f, 0xb7],
len: 12958,
sha: [0x6e, 0x0f, 0xba, 0x41, 0xea, 0x8b, 0x0f, 0xe6, 0x0b, 0x1f, 0xc5, 0x1e, 0xb3, 0xe7, 0x0f, 0x5f, 0xc9, 0xb3, 0x51, 0x63, 0xce, 0xff, 0x1d, 0xb4, 0x36, 0xd6, 0x2e, 0xf6, 0x7e, 0x9a, 0xbd, 0xfe],
ptx: concat!(include_str!("../ptx-sm86/mtp_original_full_combine.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_scalar_gr.ptx",
key: [0x24, 0x01, 0x60, 0x6b, 0x7e, 0xb4, 0x4a, 0xf8, 0x2a, 0x8b, 0x57, 0x48, 0x48, 0x6c, 0x72, 0xae, 0xc9, 0xc4, 0x7a, 0x4c, 0x7d, 0xb0, 0x6e, 0x5a, 0xbf, 0xd3, 0x7d, 0xb3, 0x75, 0x64, 0x88, 0x6d],
len: 387485,
sha: [0x89, 0xf9, 0xe9, 0x1d, 0xc7, 0xe3, 0x28, 0xa6, 0x7a, 0xd8, 0x7e, 0x02, 0xde, 0xae, 0x1c, 0x7a, 0x25, 0x56, 0xe7, 0x4d, 0x05, 0x98, 0x40, 0xd8, 0xe0, 0x94, 0x2d, 0x8e, 0x85, 0xe2, 0xe5, 0xcb],
ptx: concat!(include_str!("../ptx-sm86/mtp_original_scalar_gr.ptx"), "\0").as_bytes(),
},
Companion {
name: "original_verify_window_moe_experts.ptx",
key: [0x24, 0xd2, 0x8c, 0xcd, 0x9c, 0x3a, 0x5b, 0xbe, 0xdb, 0xeb, 0x93, 0x3b, 0x4f, 0xeb, 0x37, 0x6f, 0x84, 0x0a, 0x74, 0xe2, 0x1a, 0x44, 0x82, 0x17, 0x48, 0x8c, 0x06, 0xee, 0x23, 0x82, 0x11, 0x57],
len: 991906,
sha: [0xf6, 0xbe, 0xc9, 0xbb, 0x67, 0xe4, 0x5a, 0xa8, 0x40, 0x4f, 0xaa, 0xfd, 0x44, 0xdc, 0x30, 0xb7, 0x90, 0xbf, 0x29, 0x08, 0xf4, 0x5f, 0x0c, 0x7b, 0xb0, 0xef, 0x86, 0xa0, 0x4e, 0xad, 0x97, 0x23],
ptx: concat!(include_str!("../ptx-sm86/original_verify_window_moe_experts.ptx"), "\0").as_bytes(),
},
Companion {
name: "q4_k_q8_1.ptx",
key: [0x29, 0x4f, 0x3a, 0xd5, 0xfd, 0xdd, 0xf7, 0x96, 0x94, 0x13, 0x46, 0xc9, 0x14, 0x4f, 0xc4, 0x9d, 0x4c, 0xff, 0x54, 0x78, 0xa8, 0x8d, 0xaa, 0xd6, 0xb8, 0x94, 0x1f, 0xbd, 0x4b, 0xb2, 0x40, 0xcb],
len: 28282,
sha: [0x7c, 0xb5, 0xfa, 0x63, 0x73, 0x59, 0x81, 0x41, 0x7d, 0x57, 0x45, 0x76, 0xcf, 0xd8, 0x7e, 0x86, 0x43, 0xcf, 0xea, 0xd8, 0x1b, 0x84, 0x75, 0x44, 0xf9, 0xf1, 0x4c, 0x09, 0x70, 0x2b, 0x3b, 0x60],
ptx: concat!(include_str!("../ptx-sm86/q4_k_q8_1.ptx"), "\0").as_bytes(),
},
Companion {
name: "mmq-original-formats.ptx",
key: [0x29, 0xd9, 0x2d, 0xea, 0x14, 0x09, 0x95, 0x86, 0xc5, 0x7c, 0x97, 0x0a, 0x36, 0x46, 0xa7, 0x8e, 0x63, 0x1a, 0x49, 0x9a, 0x71, 0x57, 0xd5, 0x6a, 0xa0, 0xe2, 0x0a, 0xc1, 0xe0, 0xb4, 0x01, 0x36],
len: 2072448,
sha: [0xe0, 0x6d, 0xad, 0xbb, 0x57, 0xa9, 0xf0, 0xdc, 0x0b, 0x20, 0xd8, 0xb4, 0x7f, 0xdd, 0x62, 0xa4, 0xc8, 0x46, 0x75, 0xcc, 0xd4, 0x17, 0x0d, 0x42, 0x48, 0x95, 0x6c, 0x09, 0xb4, 0xfb, 0xd2, 0x1e],
ptx: concat!(include_str!("../ptx-sm86/mmq-original-formats.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_prefill_fixup.ptx",
key: [0x29, 0xfd, 0x3f, 0x75, 0x98, 0x64, 0x39, 0x75, 0x7c, 0x3a, 0x6e, 0xb1, 0x7d, 0x93, 0xe3, 0xed, 0x12, 0x4c, 0xc4, 0x18, 0x51, 0x97, 0xa2, 0xb4, 0x45, 0x84, 0x10, 0xd1, 0xe7, 0xf7, 0xec, 0x4b],
len: 325813,
sha: [0x43, 0xa2, 0xa5, 0x24, 0x43, 0xcf, 0x7a, 0x2e, 0x2e, 0xe6, 0x58, 0xf5, 0x93, 0xb0, 0xfe, 0xb3, 0x93, 0x3d, 0xb7, 0x37, 0x93, 0x69, 0xef, 0x19, 0x15, 0xfe, 0x23, 0x99, 0x6a, 0xca, 0xda, 0x84],
ptx: concat!(include_str!("../ptx-sm86/mtp_original_prefill_fixup.ptx"), "\0").as_bytes(),
},
Companion {
name: "iq4_xs_q8_1.ptx",
key: [0x2c, 0x85, 0x3b, 0xad, 0xe2, 0xbb, 0x62, 0xb6, 0x71, 0x67, 0xb7, 0xcb, 0xe0, 0x03, 0x24, 0x61, 0x6c, 0x72, 0x87, 0xc6, 0x0a, 0xb5, 0xfb, 0x8a, 0x41, 0xd2, 0xb5, 0x69, 0x01, 0x97, 0xf1, 0xb4],
len: 62854,
sha: [0x49, 0xbf, 0x1b, 0x11, 0x6a, 0xd9, 0xa8, 0x42, 0x7d, 0x7b, 0x64, 0x01, 0xae, 0x41, 0x4a, 0x2b, 0xd7, 0x81, 0x3c, 0x74, 0x4d, 0x96, 0x8a, 0x99, 0x26, 0xb9, 0xcc, 0x4a, 0x22, 0x3e, 0x96, 0xd6],
ptx: concat!(include_str!("../ptx-sm86/iq4_xs_q8_1.ptx"), "\0").as_bytes(),
},
Companion {
name: "mmq-fixup-selected.ptx",
key: [0x32, 0xa0, 0xc8, 0xc5, 0x45, 0x8b, 0xce, 0x5f, 0x2e, 0x07, 0xc7, 0x95, 0x7e, 0x39, 0xaa, 0x97, 0xbe, 0xac, 0x8d, 0x79, 0xbf, 0xad, 0x4a, 0x95, 0x4c, 0x91, 0xdc, 0xe3, 0x97, 0xa4, 0x79, 0x71],
len: 183342,
sha: [0xbd, 0x2a, 0x21, 0xaa, 0x98, 0x59, 0xc3, 0x1d, 0x70, 0x97, 0x9d, 0x89, 0x7c, 0xe7, 0xb7, 0x9c, 0xd4, 0x48, 0x3c, 0xde, 0xd8, 0x0a, 0x3b, 0x11, 0xbc, 0x24, 0x24, 0xdc, 0x13, 0xbc, 0x67, 0x0c],
ptx: concat!(include_str!("../ptx-sm86/mmq-fixup-selected.ptx"), "\0").as_bytes(),
},
Companion {
name: "q8_0_q8_1.ptx",
key: [0x34, 0x1a, 0xbb, 0xd0, 0x11, 0x39, 0x19, 0xd5, 0x73, 0x24, 0x1b, 0x1d, 0xc4, 0x78, 0x86, 0x51, 0x4e, 0xa7, 0xaa, 0x1d, 0x4d, 0x3f, 0x1a, 0x86, 0x70, 0x24, 0xe7, 0x66, 0x4b, 0x50, 0x1a, 0x0a],
len: 21418,
sha: [0x5b, 0x7e, 0x7d, 0x2c, 0xd3, 0x17, 0xfd, 0x3b, 0x1a, 0x5b, 0xea, 0x40, 0x01, 0x32, 0xf0, 0x38, 0x6b, 0x06, 0x9c, 0xa7, 0xdb, 0x60, 0x97, 0x45, 0x93, 0xe9, 0x02, 0x27, 0x66, 0xb3, 0x95, 0xb2],
ptx: concat!(include_str!("../ptx-sm86/q8_0_q8_1.ptx"), "\0").as_bytes(),
},
Companion {
name: "gr_prompt_device.ptx",
key: [0x39, 0xc4, 0xea, 0xcc, 0x21, 0x1f, 0xa4, 0x5f, 0xe3, 0x68, 0xee, 0x50, 0x2d, 0x3d, 0x3f, 0xf2, 0x12, 0x41, 0xe6, 0xfe, 0x24, 0xd5, 0xd1, 0x21, 0x1c, 0x6e, 0x18, 0xef, 0x0d, 0x37, 0x28, 0x70],
len: 46298,
sha: [0x1c, 0xcf, 0xf9, 0xa5, 0xce, 0x9f, 0x1a, 0xb7, 0x9c, 0xf8, 0xf5, 0xc8, 0x1d, 0xfd, 0x2a, 0x77, 0x5a, 0xd8, 0x38, 0x11, 0x5c, 0x09, 0x41, 0x4e, 0x0e, 0x1c, 0xdb, 0x3f, 0x34, 0x7f, 0x35, 0x6b],
ptx: concat!(include_str!("../ptx-sm86/gr_prompt_device.ptx"), "\0").as_bytes(),
},
Companion {
name: "s_gemv_legacy.ptx",
key: [0x3a, 0xb4, 0xd1, 0x2a, 0x5e, 0x97, 0xc4, 0xe2, 0xf4, 0x60, 0x2c, 0x6c, 0x87, 0x23, 0x72, 0xc5, 0xc0, 0x68, 0x5d, 0x8c, 0xf1, 0xa2, 0x02, 0x60, 0xaf, 0x6e, 0x0f, 0x52, 0x05, 0xac, 0x76, 0xd5],
len: 303521,
sha: [0x97, 0x47, 0xc1, 0xbe, 0x0d, 0xb5, 0x20, 0x66, 0xf1, 0xef, 0xe8, 0xef, 0xa9, 0xad, 0xdf, 0x14, 0x23, 0xc5, 0xfd, 0x12, 0xe3, 0x17, 0x47, 0x99, 0xdf, 0x85, 0x3b, 0x0f, 0x71, 0x55, 0x76, 0x55],
ptx: concat!(include_str!("../ptx-sm86/s_gemv_legacy.ptx"), "\0").as_bytes(),
},
Companion {
name: "iq3_native_integer_mma.ptx",
key: [0x3b, 0xfb, 0x20, 0xc5, 0x31, 0xd0, 0xd5, 0x74, 0xcd, 0xd0, 0x12, 0xda, 0x9f, 0xd0, 0xca, 0xe0, 0x63, 0xf6, 0x16, 0xd1, 0xa0, 0x70, 0xe0, 0x20, 0x17, 0x99, 0xab, 0x11, 0xd7, 0x36, 0x8e, 0x63],
len: 17927,
sha: [0x71, 0x0e, 0xda, 0x43, 0xa5, 0x42, 0x8c, 0x1f, 0xbe, 0xcc, 0xc6, 0x76, 0x82, 0x08, 0x93, 0x98, 0x0e, 0xa3, 0xcf, 0x1d, 0xf1, 0x22, 0x47, 0x17, 0xea, 0x95, 0x19, 0xb2, 0xe1, 0x39, 0xe3, 0x76],
ptx: concat!(include_str!("../ptx-sm86/iq3_native_integer_mma.ptx"), "\0").as_bytes(),
},
Companion {
name: "mmq_original_prefill_misc.ptx",
key: [0x3e, 0x57, 0x32, 0x6d, 0x0d, 0xd6, 0xae, 0xc8, 0x14, 0x7e, 0x6c, 0xf8, 0x37, 0xce, 0xca, 0x9d, 0x77, 0x9b, 0xa0, 0x6e, 0xa6, 0x7b, 0xf4, 0x31, 0x1b, 0x3c, 0xe0, 0xba, 0xa6, 0xd0, 0x4d, 0x69],
len: 5267,
sha: [0x7f, 0xb7, 0x4e, 0x54, 0xb7, 0xaf, 0x58, 0xdd, 0x65, 0x0d, 0x17, 0xaa, 0xa4, 0x0c, 0xa2, 0x31, 0x57, 0xd7, 0xb9, 0x88, 0x6b, 0xba, 0xf7, 0x0f, 0x8b, 0x71, 0x09, 0xc5, 0xa7, 0xa9, 0x74, 0xf2],
ptx: concat!(include_str!("../ptx-sm86/mmq_original_prefill_misc.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_prefill_mmq.ptx",
key: [0x3e, 0x67, 0x46, 0x7d, 0x41, 0x2d, 0xbf, 0x18, 0x12, 0x00, 0xd3, 0xca, 0x10, 0xf2, 0xb6, 0x69, 0x95, 0xaf, 0xe3, 0x16, 0xcb, 0xe4, 0x02, 0x60, 0xde, 0xa2, 0x1d, 0x97, 0x31, 0x8b, 0x61, 0xe1],
len: 1850087,
sha: [0x2f, 0xde, 0xe9, 0xf3, 0xc3, 0x06, 0x7e, 0x27, 0x64, 0x30, 0xc6, 0xb6, 0x15, 0x45, 0xb1, 0xf8, 0x59, 0x22, 0x60, 0xd4, 0x62, 0x64, 0x98, 0x89, 0xa8, 0xc9, 0x3b, 0xaa, 0xdf, 0x46, 0x92, 0xaa],
ptx: concat!(include_str!("../ptx-sm86/mtp_original_prefill_mmq.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_full_attention.ptx",
key: [0x3f, 0xb2, 0x35, 0xca, 0x40, 0x5d, 0x24, 0xc3, 0xb8, 0xd0, 0xec, 0x46, 0x61, 0x1d, 0x9d, 0x64, 0x01, 0x03, 0xb7, 0x1a, 0x65, 0x85, 0x99, 0x23, 0x19, 0x4f, 0x02, 0xf0, 0x6b, 0x48, 0x2f, 0x6c],
len: 54452,
sha: [0xdc, 0x1a, 0xcb, 0x71, 0x2c, 0x99, 0x3b, 0x09, 0xaa, 0x87, 0x86, 0x72, 0x13, 0xd5, 0x23, 0xd8, 0x6d, 0x34, 0x2c, 0x91, 0xe7, 0x33, 0xf2, 0xdb, 0x80, 0x49, 0x7b, 0x85, 0xdc, 0xdd, 0x0b, 0x41],
ptx: concat!(include_str!("../ptx-sm86/mtp_original_full_attention.ptx"), "\0").as_bytes(),
},
Companion {
name: "ple_prompt_device.ptx",
key: [0x41, 0x2e, 0xd1, 0xdc, 0xcd, 0x1f, 0xc6, 0x2c, 0x5c, 0xf6, 0xc7, 0x50, 0xad, 0x8d, 0x2f, 0x45, 0x20, 0x5f, 0x6d, 0x19, 0xfa, 0xfc, 0x00, 0x23, 0xd6, 0x4a, 0x33, 0xd3, 0x12, 0x95, 0x09, 0x34],
len: 19418,
sha: [0xdb, 0x53, 0x73, 0x24, 0x8a, 0x30, 0x34, 0xea, 0x29, 0xc1, 0xd3, 0x65, 0xae, 0x26, 0x78, 0x5e, 0x4c, 0x46, 0x6f, 0x3d, 0xdc, 0x9b, 0x26, 0x48, 0x43, 0xca, 0x58, 0xaf, 0x47, 0xc9, 0xc2, 0x03],
ptx: concat!(include_str!("../ptx-sm86/ple_prompt_device.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_s2_full_fixed.ptx",
key: [0x43, 0x81, 0x4a, 0x9c, 0x17, 0x9a, 0xba, 0xba, 0x8f, 0xe0, 0xa8, 0x0b, 0x88, 0xa3, 0x15, 0xbc, 0x94, 0xc4, 0x38, 0xf3, 0x9b, 0x38, 0x42, 0xf4, 0xe4, 0x30, 0x1e, 0x96, 0xa0, 0x32, 0xf7, 0x8d],
len: 142044,
sha: [0x48, 0x41, 0xdf, 0x97, 0x8e, 0x70, 0x2a, 0xd9, 0x1a, 0xdf, 0xd6, 0xb1, 0x7f, 0xd3, 0x1e, 0x53, 0xa4, 0x12, 0x04, 0xf8, 0x0c, 0xbc, 0xa0, 0xdf, 0x2b, 0x6f, 0xad, 0xef, 0xf3, 0x5a, 0x3b, 0x78],
ptx: concat!(include_str!("../ptx-sm86/mtp_s2_full_fixed.ptx"), "\0").as_bytes(),
},
Companion {
name: "experimental_kv_q8.ptx",
key: [0x43, 0xc3, 0x08, 0x96, 0x08, 0x30, 0x83, 0x3e, 0x29, 0x32, 0x99, 0x07, 0xe2, 0x7b, 0xe5, 0x20, 0x3e, 0xf3, 0xbc, 0x89, 0xcc, 0x7d, 0x0a, 0x91, 0x76, 0x27, 0x0d, 0xc1, 0x87, 0x32, 0xd6, 0x00],
len: 32973,
sha: [0x4b, 0xe6, 0xeb, 0xa3, 0xae, 0x08, 0xf2, 0x12, 0xeb, 0x89, 0x60, 0x7c, 0xea, 0x56, 0x63, 0x8c, 0x10, 0xfa, 0x12, 0xee, 0x40, 0x98, 0x5b, 0xeb, 0xee, 0x99, 0x75, 0x44, 0xae, 0xd7, 0xad, 0xc7],
ptx: concat!(include_str!("../ptx-sm86/experimental_kv_q8.ptx"), "\0").as_bytes(),
},
Companion {
name: "q6_k_q8_1.ptx",
key: [0x45, 0x40, 0xf6, 0x7f, 0x72, 0xe3, 0xb3, 0x5b, 0xf2, 0x1c, 0xfb, 0xde, 0x0b, 0xfd, 0xf7, 0x85, 0x1e, 0xbe, 0x90, 0xe4, 0x15, 0x40, 0x5c, 0x0c, 0x16, 0x16, 0x6d, 0x09, 0x33, 0xd5, 0x47, 0x97],
len: 26986,
sha: [0x56, 0xb6, 0x06, 0xf4, 0x0b, 0x9a, 0xdd, 0xb9, 0x14, 0xed, 0x01, 0x83, 0x5e, 0x77, 0x87, 0x44, 0x22, 0xca, 0x26, 0xc5, 0xff, 0x32, 0x09, 0x94, 0x3d, 0x1d, 0xe1, 0x22, 0xfc, 0x79, 0x69, 0x58],
ptx: concat!(include_str!("../ptx-sm86/q6_k_q8_1.ptx"), "\0").as_bytes(),
},
Companion {
name: "moe_route_top10.ptx",
key: [0x48, 0x04, 0xcc, 0xad, 0xee, 0x77, 0xaa, 0xbd, 0xa8, 0x80, 0xfb, 0xc0, 0xa5, 0xb3, 0x4f, 0x10, 0xe8, 0x58, 0x51, 0xc1, 0x69, 0xea, 0xa8, 0x96, 0xf3, 0x31, 0x4b, 0xed, 0x64, 0x78, 0xe2, 0x25],
len: 61900,
sha: [0xe3, 0x29, 0x7c, 0x8c, 0x54, 0x4c, 0xe8, 0x40, 0x15, 0xb5, 0xba, 0x73, 0x45, 0x57, 0xd5, 0x1e, 0xd7, 0x77, 0xed, 0x40, 0x46, 0xf7, 0x4f, 0x09, 0x33, 0x1b, 0x63, 0x56, 0x9e, 0x01, 0xb5, 0x83],
ptx: concat!(include_str!("../ptx-sm86/moe_route_top10.ptx"), "\0").as_bytes(),
},
Companion {
name: "qsa_prompt_postops.ptx",
key: [0x48, 0x6a, 0x73, 0xb0, 0x6b, 0x3a, 0x34, 0xf2, 0x98, 0xf5, 0x7e, 0x92, 0xc2, 0x0c, 0xc8, 0x39, 0x4d, 0xc5, 0x9d, 0x7b, 0xd8, 0x4b, 0x5c, 0xcc, 0xf8, 0xda, 0x53, 0xaa, 0x50, 0x81, 0xac, 0x9f],
len: 21830,
sha: [0x34, 0x00, 0x50, 0x40, 0x42, 0xb6, 0x9f, 0x98, 0x8b, 0x9a, 0x13, 0x3c, 0x2a, 0xea, 0xf8, 0x67, 0x69, 0xc7, 0xf3, 0x99, 0xfa, 0xaf, 0x94, 0xc6, 0x38, 0x7e, 0xbc, 0x6b, 0x46, 0xd3, 0x5d, 0xa9],
ptx: concat!(include_str!("../ptx-sm86/qsa_prompt_postops.ptx"), "\0").as_bytes(),
},
Companion {
name: "qsa_selected_kv.ptx",
key: [0x4f, 0x2a, 0xd2, 0x04, 0x10, 0x9b, 0xdd, 0x97, 0x4a, 0x7c, 0x96, 0x5d, 0x08, 0xd9, 0x06, 0x4a, 0xf5, 0x27, 0x56, 0xb1, 0xf6, 0xfc, 0x15, 0x02, 0x7f, 0x47, 0x7d, 0xe2, 0xfd, 0x88, 0x3f, 0x92],
len: 3842,
sha: [0x74, 0x02, 0x25, 0x5f, 0xdb, 0xe1, 0x21, 0xe0, 0x36, 0xaf, 0x74, 0x20, 0x3d, 0xb6, 0x0f, 0x61, 0xd9, 0xe2, 0xe4, 0xe1, 0x08, 0xbf, 0xbe, 0xdf, 0x17, 0xc4, 0xc3, 0x9f, 0xc0, 0x4e, 0xbf, 0x62],
ptx: concat!(include_str!("../ptx-sm86/qsa_selected_kv.ptx"), "\0").as_bytes(),
},
Companion {
name: "experimental_kv_stream.ptx",
key: [0x4f, 0x71, 0xe7, 0x20, 0xe0, 0xca, 0x95, 0x0d, 0x32, 0x1b, 0xa3, 0xcb, 0xb2, 0x00, 0x82, 0xca, 0x47, 0x3e, 0x98, 0x39, 0xb7, 0x6d, 0x08, 0x89, 0x8e, 0x95, 0xb6, 0x62, 0x3b, 0xff, 0xfe, 0x50],
len: 34329,
sha: [0x9f, 0x99, 0x20, 0x44, 0x70, 0x2d, 0x0c, 0xa2, 0xf8, 0xcc, 0x0b, 0xfd, 0xfd, 0xb7, 0x55, 0x47, 0x59, 0x9f, 0x91, 0x26, 0x15, 0xff, 0xdb, 0x7c, 0xdb, 0x56, 0xcc, 0x06, 0x3c, 0xe8, 0xd6, 0xcf],
ptx: concat!(include_str!("../ptx-sm86/experimental_kv_stream.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_full_coupled.ptx",
key: [0x55, 0x47, 0x41, 0x61, 0x1c, 0xc0, 0x3e, 0x2c, 0x35, 0xb7, 0xab, 0x1d, 0xfc, 0xa9, 0xc6, 0xd6, 0xc0, 0x1b, 0x37, 0xc1, 0x7d, 0xd4, 0x91, 0x00, 0x0c, 0xcf, 0x0a, 0x23, 0xc3, 0xbb, 0xcb, 0xf9],
len: 482063,
sha: [0xee, 0x6c, 0x57, 0x9d, 0x55, 0x15, 0x6e, 0x90, 0x3a, 0xf6, 0xc1, 0x8e, 0x6a, 0x47, 0x32, 0x95, 0x5f, 0xc1, 0x26, 0xd4, 0x8a, 0x02, 0x86, 0x04, 0xdb, 0x99, 0xa4, 0xcc, 0x2f, 0xcf, 0x4d, 0x80],
ptx: concat!(include_str!("../ptx-sm86/mtp_original_full_coupled.ptx"), "\0").as_bytes(),
},
Companion {
name: "experimental_qsa_attn.ptx",
key: [0x56, 0x23, 0xa5, 0xae, 0x9b, 0x2e, 0xbd, 0x2f, 0xa0, 0x10, 0xc3, 0x34, 0x36, 0x7f, 0xfc, 0x54, 0x87, 0x9a, 0xc6, 0xdf, 0x76, 0xae, 0xf0, 0x83, 0x81, 0xdb, 0xd3, 0x2b, 0x0f, 0x7e, 0xf3, 0x11],
len: 128247,
sha: [0x2d, 0xe6, 0x09, 0xa4, 0xbf, 0x6e, 0xb8, 0x80, 0xbe, 0x59, 0x4d, 0x47, 0xc0, 0x7f, 0xe4, 0x0a, 0x78, 0xd2, 0x5d, 0x70, 0xc7, 0x4e, 0xcd, 0xa7, 0x95, 0x82, 0xbd, 0x61, 0x21, 0x74, 0x99, 0xe2],
ptx: concat!(include_str!("../ptx-sm86/experimental_qsa_attn.ptx"), "\0").as_bytes(),
},
Companion {
name: "device_poison.ptx",
key: [0x58, 0x7b, 0x09, 0x7a, 0x20, 0x1a, 0x67, 0x30, 0xe8, 0xfe, 0x55, 0x43, 0x29, 0x19, 0x87, 0xbb, 0xf8, 0x07, 0xda, 0x72, 0xda, 0x12, 0xb8, 0xe0, 0xa1, 0x69, 0xf9, 0xe5, 0xe8, 0xf6, 0xa6, 0x58],
len: 870,
sha: [0xab, 0x97, 0x01, 0x5f, 0xd4, 0x7e, 0x02, 0xe2, 0xbf, 0xde, 0x42, 0x49, 0x25, 0x62, 0xa5, 0x52, 0xef, 0x78, 0xb6, 0x0b, 0x99, 0xf0, 0xf1, 0xf3, 0xbb, 0x43, 0x5a, 0x3c, 0x0c, 0x82, 0x59, 0xa9],
ptx: concat!(include_str!("../ptx-sm86/device_poison.ptx"), "\0").as_bytes(),
},
Companion {
name: "moe_group_iq3_s.ptx",
key: [0x58, 0xd0, 0x68, 0xff, 0x3a, 0xcc, 0x42, 0x11, 0x61, 0x4f, 0x70, 0xab, 0x04, 0x70, 0x3a, 0x40, 0x85, 0x8e, 0x14, 0x8f, 0x9a, 0xef, 0x85, 0x03, 0xed, 0x66, 0xf7, 0x64, 0x0a, 0xe2, 0xe2, 0xaa],
len: 25114,
sha: [0x36, 0xc2, 0xf6, 0x8c, 0x0d, 0x3a, 0x3c, 0x52, 0x47, 0x87, 0xec, 0xf0, 0x3a, 0x1f, 0x33, 0xe2, 0xda, 0x93, 0x0a, 0x49, 0x17, 0x41, 0x9e, 0xa5, 0x89, 0x3c, 0xca, 0xa2, 0x8c, 0x33, 0xa8, 0x8c],
ptx: concat!(include_str!("../ptx-sm86/moe_group_iq3_s.ptx"), "\0").as_bytes(),
},
Companion {
name: "original_sampler.ptx",
key: [0x59, 0x1a, 0xa3, 0xdd, 0xa5, 0x2f, 0x41, 0xf0, 0xd1, 0x95, 0x41, 0x6c, 0xf0, 0x93, 0x96, 0x25, 0x68, 0xd2, 0xf8, 0x3d, 0x6f, 0x76, 0x2a, 0x96, 0x78, 0xbe, 0x61, 0x94, 0x6c, 0xec, 0xb7, 0x5b],
len: 475837,
sha: [0x3c, 0xf7, 0xa3, 0x0f, 0x81, 0x6f, 0x9f, 0x27, 0xa2, 0x2f, 0xf8, 0x21, 0x11, 0x7e, 0x9b, 0xff, 0x7c, 0xbc, 0xc3, 0x19, 0x69, 0xac, 0x25, 0x5d, 0x32, 0xb4, 0x0d, 0xdd, 0x4d, 0xda, 0xdc, 0x40],
ptx: concat!(include_str!("../ptx-sm86/original_sampler.ptx"), "\0").as_bytes(),
},
Companion {
name: "mmq-selected.ptx",
key: [0x5a, 0x56, 0xd8, 0xeb, 0x66, 0xf1, 0xf9, 0x8e, 0x3c, 0xb3, 0xab, 0x75, 0x18, 0x1e, 0x0f, 0x26, 0x3e, 0x4d, 0x51, 0xc4, 0xe7, 0x1e, 0x27, 0xab, 0x2b, 0xc9, 0x9a, 0x1a, 0x3b, 0x7c, 0x01, 0xcb],
len: 955352,
sha: [0xc1, 0x5b, 0x58, 0x0a, 0x9f, 0xdc, 0x85, 0x67, 0x39, 0xfc, 0xa0, 0xa5, 0x68, 0x57, 0xfc, 0x7e, 0x7e, 0xc0, 0x1b, 0x4f, 0x1c, 0x99, 0x3f, 0xfb, 0x2e, 0xde, 0x04, 0x66, 0x01, 0x04, 0x86, 0x28],
ptx: concat!(include_str!("../ptx-sm86/mmq-selected.ptx"), "\0").as_bytes(),
},
Companion {
name: "offline_gdn_prefill.ptx",
key: [0x5c, 0xc3, 0xa0, 0x28, 0x5d, 0xb9, 0x83, 0xce, 0xbe, 0x9e, 0x35, 0xfa, 0xc2, 0xd5, 0x3e, 0x57, 0x32, 0x68, 0xaf, 0x81, 0x7f, 0x13, 0x1b, 0x23, 0x40, 0xbd, 0x00, 0x3a, 0xe3, 0xe1, 0x64, 0xce],
len: 52304,
sha: [0x12, 0x71, 0xac, 0x05, 0x6e, 0xa0, 0x13, 0x2b, 0xda, 0x7d, 0x11, 0x57, 0x0a, 0x29, 0x6d, 0x00, 0x81, 0x1d, 0x82, 0xe3, 0x90, 0x1d, 0x6c, 0x5d, 0x77, 0x14, 0x77, 0xf8, 0xd9, 0x60, 0x6c, 0x37],
ptx: concat!(include_str!("../ptx-sm86/offline_gdn_prefill.ptx"), "\0").as_bytes(),
},
Companion {
name: "ple_native_batch.ptx",
key: [0x5f, 0xa5, 0xc9, 0x30, 0xf4, 0x0c, 0xb4, 0x9d, 0x9e, 0x79, 0xa3, 0x5e, 0x19, 0x11, 0xc6, 0x85, 0x81, 0xf9, 0x2c, 0x09, 0x77, 0x50, 0xef, 0xf2, 0x8c, 0x24, 0x5e, 0x28, 0x70, 0x96, 0x4a, 0x40],
len: 19699,
sha: [0xf9, 0xa3, 0x97, 0x01, 0xe2, 0xcc, 0xf0, 0xf6, 0xf7, 0x2d, 0x5e, 0xce, 0x56, 0x6b, 0x78, 0x09, 0x33, 0xea, 0xdd, 0xe6, 0x89, 0xe7, 0xff, 0x50, 0x2a, 0xcf, 0x87, 0xdb, 0x63, 0xf5, 0xd8, 0x5f],
ptx: concat!(include_str!("../ptx-sm86/ple_native_batch.ptx"), "\0").as_bytes(),
},
Companion {
name: "ple_value_full_fixed.ptx",
key: [0x61, 0x80, 0xf3, 0xde, 0xbc, 0x74, 0x34, 0x9d, 0x62, 0xe2, 0x9c, 0x17, 0xe0, 0x75, 0x17, 0xac, 0x6c, 0x15, 0x1e, 0x71, 0xea, 0xe6, 0x72, 0x97, 0x85, 0x66, 0x49, 0x58, 0x84, 0x23, 0x25, 0xd0],
len: 5199,
sha: [0xbf, 0xcd, 0x7c, 0x88, 0x44, 0x62, 0xc1, 0xe1, 0xe2, 0x8e, 0x3f, 0x73, 0xc7, 0x25, 0x0f, 0xbb, 0xa5, 0x1b, 0xc0, 0xc9, 0x5f, 0x03, 0x7d, 0xba, 0x18, 0x4f, 0x32, 0x24, 0x75, 0x8f, 0xaa, 0x33],
ptx: concat!(include_str!("../ptx-sm86/ple_value_full_fixed.ptx"), "\0").as_bytes(),
},
Companion {
name: "q5_k_q8_1.ptx",
key: [0x65, 0xcd, 0x98, 0x13, 0x8e, 0x2a, 0xd9, 0xd1, 0xc2, 0x71, 0x1f, 0xf7, 0xfc, 0x27, 0x28, 0x0f, 0x07, 0xf1, 0xa2, 0x24, 0xfc, 0xdd, 0x2a, 0xbe, 0xea, 0x9b, 0xed, 0xf9, 0xd9, 0xd3, 0xff, 0xfc],
len: 33608,
sha: [0x24, 0x64, 0xea, 0x04, 0x0f, 0xfa, 0x4d, 0xa2, 0x03, 0xe7, 0xde, 0xe9, 0x14, 0x5a, 0x1e, 0xa9, 0x88, 0xdb, 0x90, 0x2d, 0xff, 0xe7, 0xa1, 0x6d, 0x4f, 0x2c, 0xf1, 0x77, 0xcd, 0x7d, 0x32, 0xd6],
ptx: concat!(include_str!("../ptx-sm86/q5_k_q8_1.ptx"), "\0").as_bytes(),
},
Companion {
name: "native_head_iq.ptx",
key: [0x66, 0xd3, 0xe6, 0x22, 0xee, 0x4f, 0xb8, 0xb6, 0x71, 0x92, 0x8a, 0x73, 0xda, 0xe7, 0x03, 0x85, 0xe4, 0x41, 0x5d, 0xb4, 0x7a, 0xd5, 0x34, 0x2d, 0x5e, 0xb0, 0xd2, 0x50, 0x7b, 0xea, 0xb5, 0xe4],
len: 753628,
sha: [0x90, 0xda, 0x63, 0x69, 0xf0, 0x50, 0x9e, 0x6c, 0xa6, 0x41, 0xb0, 0xa4, 0x7d, 0xce, 0x03, 0x81, 0xe8, 0x8c, 0x27, 0xf0, 0x0e, 0xb4, 0x18, 0x19, 0x82, 0xd9, 0x42, 0x22, 0x16, 0x97, 0x2a, 0x2c],
ptx: concat!(include_str!("../ptx-sm86/native_head_iq.ptx"), "\0").as_bytes(),
},
Companion {
name: "qsa_prompt_device_gate.ptx",
key: [0x69, 0xf0, 0x3b, 0xe1, 0x7d, 0xb1, 0x7a, 0xba, 0x2f, 0x82, 0x8c, 0xf4, 0x37, 0x91, 0x0a, 0x4d, 0xb6, 0x63, 0x23, 0x97, 0x3d, 0xaa, 0x8b, 0x1a, 0x45, 0x9c, 0x24, 0x18, 0xf9, 0x11, 0x45, 0xd4],
len: 2382,
sha: [0x3b, 0xca, 0x8a, 0x59, 0x4f, 0x37, 0xdd, 0x80, 0xff, 0x12, 0xbd, 0x9b, 0x2c, 0x45, 0x4b, 0x76, 0x68, 0xf2, 0x26, 0x57, 0x1a, 0x2f, 0x2c, 0x5d, 0x33, 0x89, 0xd7, 0xa5, 0xa9, 0x81, 0xba, 0xa7],
ptx: concat!(include_str!("../ptx-sm86/qsa_prompt_device_gate.ptx"), "\0").as_bytes(),
},
Companion {
name: "q6_batch_preview.ptx",
key: [0x6a, 0x4d, 0x43, 0xe4, 0x1a, 0x45, 0xd9, 0x9f, 0xbb, 0xaa, 0xe3, 0x91, 0x70, 0x38, 0xe2, 0x81, 0xf1, 0x1d, 0x04, 0x37, 0x0e, 0x02, 0x59, 0xea, 0x70, 0x26, 0x81, 0x14, 0x42, 0x96, 0xde, 0x79],
len: 28112,
sha: [0xf5, 0x4e, 0xea, 0xa6, 0xeb, 0x53, 0xa4, 0xd5, 0x02, 0x34, 0x4f, 0x90, 0x8f, 0x97, 0x65, 0xaa, 0xdf, 0x44, 0x53, 0x77, 0xd4, 0x3a, 0x70, 0x53, 0x23, 0x59, 0xfe, 0xe2, 0x33, 0xa0, 0x06, 0x73],
ptx: concat!(include_str!("../ptx-sm86/q6_batch_preview.ptx"), "\0").as_bytes(),
},
Companion {
name: "prefill_stage.ptx",
key: [0x6f, 0x8f, 0xb3, 0xbb, 0xd1, 0x11, 0x71, 0xc9, 0x39, 0x02, 0x97, 0xd5, 0xd2, 0xc9, 0xcb, 0x90, 0x76, 0xd4, 0xb6, 0x51, 0xf2, 0xa7, 0x04, 0x2b, 0xf1, 0x6f, 0x4c, 0xaf, 0x89, 0xa5, 0xb3, 0x84],
len: 161928,
sha: [0xd8, 0x1a, 0x87, 0x43, 0x7b, 0x72, 0x6b, 0xcf, 0x1a, 0x9d, 0xf0, 0xca, 0x6d, 0x5e, 0xbe, 0xdf, 0x5c, 0x06, 0xda, 0xce, 0xe6, 0x88, 0xbd, 0xc8, 0xfe, 0x91, 0x78, 0x91, 0xcc, 0x0c, 0xda, 0x4b],
ptx: concat!(include_str!("../ptx-sm86/prefill_stage.ptx"), "\0").as_bytes(),
},
Companion {
name: "original_verify_window_pcie_fast.ptx",
key: [0x74, 0x07, 0x85, 0x9f, 0x8d, 0x88, 0x81, 0x66, 0x3f, 0x3a, 0x64, 0x6e, 0xbe, 0x28, 0x8c, 0x31, 0x13, 0x8c, 0xce, 0x32, 0x27, 0xc1, 0xc5, 0xd9, 0xe2, 0xe5, 0x92, 0x64, 0x8e, 0xd7, 0x7a, 0xea],
len: 71051,
sha: [0x23, 0x48, 0x1b, 0x50, 0xaf, 0x2c, 0x50, 0x1b, 0x04, 0xed, 0xc1, 0xe9, 0xd4, 0xa3, 0x85, 0x35, 0xcf, 0x83, 0x88, 0x46, 0xaa, 0x57, 0xd4, 0x4f, 0x0b, 0xcf, 0x2c, 0x2d, 0xc7, 0xf3, 0xd1, 0xa3],
ptx: concat!(include_str!("../ptx-sm86/original_verify_window_pcie_fast.ptx"), "\0").as_bytes(),
},
Companion {
name: "experimental_kv_q4.ptx",
key: [0x74, 0x66, 0x5b, 0x01, 0x6f, 0xde, 0x9d, 0xc4, 0xf5, 0x0a, 0x36, 0xe6, 0x2c, 0xbf, 0x2e, 0x57, 0x8c, 0x73, 0x5e, 0x48, 0xe3, 0xbe, 0x51, 0xb7, 0x07, 0x34, 0xe9, 0xe5, 0x39, 0x42, 0xcd, 0xe7],
len: 36319,
sha: [0x36, 0x1d, 0xb3, 0xe8, 0x47, 0x1e, 0x42, 0x77, 0x8a, 0x4b, 0x7d, 0x45, 0x9a, 0xf7, 0x28, 0x9a, 0xa8, 0xe8, 0x01, 0x7b, 0xb3, 0xa7, 0x45, 0x5e, 0x6a, 0xa2, 0xe0, 0x49, 0xb2, 0x2a, 0xd0, 0x93],
ptx: concat!(include_str!("../ptx-sm86/experimental_kv_q4.ptx"), "\0").as_bytes(),
},
Companion {
name: "qwen_qsa_attention_native.ptx",
key: [0x77, 0x72, 0xe4, 0xe7, 0x5d, 0x78, 0xa9, 0x91, 0x01, 0x44, 0xca, 0x10, 0x85, 0x51, 0x80, 0x0f, 0xd4, 0x29, 0x69, 0x55, 0x78, 0x15, 0x40, 0xaf, 0xb6, 0x5f, 0x53, 0xd6, 0x12, 0xd7, 0xe1, 0xf3],
len: 3139,
sha: [0xda, 0xb3, 0xfd, 0x1c, 0xe3, 0xde, 0x7e, 0xfc, 0x94, 0x1e, 0xcb, 0x26, 0x84, 0x33, 0x6d, 0xea, 0x26, 0xe3, 0x61, 0xd6, 0xc5, 0x0a, 0xbd, 0x45, 0xdc, 0xf2, 0x0f, 0x2e, 0x1e, 0x8f, 0x86, 0xdd],
ptx: concat!(include_str!("../ptx-sm86/qwen_qsa_attention_native.ptx"), "\0").as_bytes(),
},
Companion {
name: "moe_group_iq3_xxs.ptx",
key: [0x78, 0x82, 0x05, 0x48, 0x65, 0xe5, 0x55, 0x01, 0x0d, 0x4d, 0x60, 0xfc, 0x21, 0xf1, 0xae, 0xbb, 0x97, 0xb1, 0x0d, 0xc0, 0x6a, 0xf1, 0xaf, 0xe3, 0xd0, 0x9f, 0xce, 0x21, 0x96, 0xac, 0x37, 0x67],
len: 16161,
sha: [0xd7, 0x67, 0xad, 0x5a, 0x01, 0x05, 0x0a, 0x8e, 0xc6, 0x8b, 0x73, 0xc3, 0xb5, 0x30, 0x05, 0x09, 0x40, 0x2a, 0x5f, 0x25, 0x14, 0xd6, 0x72, 0xf1, 0x93, 0x01, 0x71, 0xa5, 0xef, 0x98, 0x65, 0xbc],
ptx: concat!(include_str!("../ptx-sm86/moe_group_iq3_xxs.ptx"), "\0").as_bytes(),
},
Companion {
name: "head_greedy.ptx",
key: [0x78, 0x9f, 0xb7, 0xfc, 0xd5, 0x56, 0x4d, 0xea, 0xac, 0x9e, 0xbd, 0x24, 0x79, 0x7d, 0x3a, 0x15, 0xcd, 0xbb, 0x7c, 0x45, 0xf3, 0x97, 0xa7, 0x72, 0x05, 0x7a, 0x6c, 0x5e, 0xd3, 0xf5, 0x2e, 0xb1],
len: 4291,
sha: [0x00, 0xa5, 0xe1, 0x17, 0x6c, 0xc8, 0x95, 0x28, 0x19, 0x41, 0x5f, 0x62, 0x2b, 0x88, 0x6e, 0xea, 0xc3, 0xd6, 0x7b, 0x1f, 0x2b, 0xd5, 0xa4, 0xf9, 0xc7, 0x2e, 0xde, 0x97, 0x85, 0xdf, 0xd8, 0x6e],
ptx: concat!(include_str!("../ptx-sm86/head_greedy.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_gr_fixed.ptx",
key: [0x7a, 0xba, 0x70, 0x01, 0x45, 0xb1, 0x9a, 0x09, 0x1d, 0x1c, 0xa2, 0x77, 0x44, 0x62, 0x01, 0xff, 0x47, 0x69, 0xba, 0xa3, 0x66, 0xe7, 0xd5, 0xa0, 0x29, 0x4a, 0x91, 0xe7, 0x6b, 0xa6, 0x09, 0xd4],
len: 103348,
sha: [0xcf, 0xa8, 0x85, 0xcd, 0x69, 0xf9, 0x51, 0xd3, 0x61, 0x67, 0x31, 0x9a, 0xb0, 0x5b, 0x5a, 0x6b, 0xbd, 0xce, 0x95, 0x98, 0xc9, 0x13, 0x3c, 0xd4, 0x30, 0x0d, 0x18, 0xa1, 0x92, 0x8f, 0x24, 0xdd],
ptx: concat!(include_str!("../ptx-sm86/mtp_gr_fixed.ptx"), "\0").as_bytes(),
},
Companion {
name: "gdn_fixed.ptx",
key: [0x7b, 0x2f, 0x20, 0x3c, 0xe1, 0xb1, 0xb4, 0xc7, 0xe6, 0x3b, 0xb5, 0x6a, 0x1f, 0x7c, 0x35, 0x1a, 0x21, 0x3e, 0x1f, 0x5d, 0xf9, 0x71, 0x1a, 0xd2, 0xd8, 0xdb, 0x30, 0x47, 0xae, 0xad, 0x9e, 0x25],
len: 35268,
sha: [0x09, 0x82, 0x29, 0x8e, 0xa9, 0xf8, 0xe4, 0xbf, 0xa7, 0x0e, 0xef, 0xb1, 0xde, 0xe0, 0xa4, 0x30, 0x73, 0x74, 0x38, 0x9b, 0x3d, 0x60, 0x4d, 0xf5, 0xea, 0x50, 0x7f, 0x35, 0xb5, 0x2f, 0xe4, 0x10],
ptx: concat!(include_str!("../ptx-sm86/gdn_fixed.ptx"), "\0").as_bytes(),
},
Companion {
name: "offline_gdn_fused_t1.ptx",
key: [0x7b, 0xd0, 0x09, 0x09, 0x27, 0x3c, 0x41, 0x06, 0x55, 0xc3, 0xe1, 0x78, 0x1e, 0x58, 0xd2, 0x1a, 0xe1, 0x54, 0x18, 0x1f, 0xbd, 0x74, 0xc6, 0xb2, 0x11, 0x55, 0x74, 0x8c, 0x97, 0x03, 0x5d, 0xd3],
len: 51663,
sha: [0x5d, 0x2d, 0xa8, 0x20, 0xdb, 0xc9, 0x31, 0x38, 0xe6, 0xa7, 0xce, 0x85, 0x92, 0xc7, 0x1e, 0xc3, 0xd6, 0xa2, 0xb1, 0x0d, 0x57, 0xd1, 0x89, 0xa2, 0xab, 0x50, 0x7d, 0xce, 0x5b, 0x20, 0xd0, 0x1c],
ptx: concat!(include_str!("../ptx-sm86/offline_gdn_fused_t1.ptx"), "\0").as_bytes(),
},
Companion {
name: "qsa_native_decode.ptx",
key: [0x7c, 0x98, 0xe8, 0xf0, 0x08, 0x92, 0x14, 0x23, 0xe3, 0x05, 0x9f, 0x81, 0xf9, 0xf4, 0xe3, 0x17, 0xeb, 0x40, 0x7d, 0x15, 0xd6, 0xb9, 0x81, 0x5a, 0xe6, 0xda, 0xd7, 0x92, 0x08, 0x83, 0xb0, 0xda],
len: 55720,
sha: [0xde, 0x1e, 0x3c, 0x7a, 0xe0, 0x3c, 0x7e, 0x7f, 0x57, 0x47, 0x2e, 0xbd, 0xe7, 0x58, 0x1f, 0xf0, 0x51, 0x62, 0xb5, 0x45, 0xb1, 0x00, 0x27, 0xf9, 0x6b, 0x2b, 0x36, 0xc4, 0x10, 0xd1, 0xa3, 0x65],
ptx: concat!(include_str!("../ptx-sm86/qsa_native_decode.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_prefill_embedding.ptx",
key: [0x7e, 0x49, 0xc0, 0x3b, 0x93, 0x3c, 0xdf, 0x6a, 0x4a, 0x79, 0x37, 0x6f, 0xfa, 0x97, 0xf0, 0x61, 0x88, 0x7a, 0x54, 0x92, 0x46, 0x77, 0x43, 0xd0, 0x8e, 0x28, 0x5a, 0x13, 0x95, 0x58, 0x0f, 0xc8],
len: 847405,
sha: [0x2c, 0xe1, 0xd3, 0xe9, 0xaa, 0x97, 0x2f, 0x1f, 0xd0, 0xc1, 0x34, 0x27, 0x21, 0x66, 0xd2, 0x72, 0x22, 0xe9, 0x3b, 0xae, 0x18, 0xda, 0x19, 0xfc, 0x11, 0x97, 0x41, 0x6f, 0x26, 0x4a, 0xe5, 0x54],
ptx: concat!(include_str!("../ptx-sm86/mtp_original_prefill_embedding.ptx"), "\0").as_bytes(),
},
Companion {
name: "native_head_native.ptx",
key: [0x81, 0xa3, 0x99, 0x0c, 0x14, 0x3e, 0x45, 0x1d, 0xac, 0x79, 0x48, 0x62, 0xcf, 0x73, 0x3f, 0x5f, 0x41, 0x21, 0xf5, 0x2a, 0xa0, 0x70, 0x50, 0xc5, 0x6e, 0x06, 0x1c, 0x17, 0x63, 0xd1, 0x47, 0x9a],
len: 7398533,
sha: [0xe5, 0x44, 0x90, 0xc3, 0x6e, 0x5c, 0xd5, 0xbf, 0x1f, 0x3c, 0x77, 0xc1, 0xaa, 0xf0, 0xdb, 0x21, 0x1c, 0x06, 0x0d, 0x53, 0xfa, 0x93, 0x0a, 0x7a, 0xd0, 0xd4, 0xe9, 0xa5, 0x1c, 0xb9, 0x33, 0x89],
ptx: concat!(include_str!("../ptx-sm86/native_head_native.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_session_native_rope.ptx",
key: [0x85, 0xb7, 0xef, 0x7c, 0xa5, 0x94, 0x3d, 0xbd, 0x71, 0x07, 0x10, 0x6b, 0x30, 0x29, 0xd5, 0x02, 0x7b, 0x46, 0x44, 0x14, 0x8d, 0x70, 0x05, 0xa4, 0x7d, 0xef, 0x7f, 0xa9, 0x01, 0xa3, 0xd7, 0x0a],
len: 10518,
sha: [0x8e, 0x24, 0xc9, 0xe8, 0x0e, 0xe3, 0x11, 0xc7, 0x82, 0x77, 0x00, 0x77, 0x70, 0x3c, 0x7c, 0x11, 0x2a, 0x16, 0x3b, 0xb1, 0x12, 0x3c, 0x95, 0xb8, 0xc3, 0x12, 0x38, 0x0d, 0xf7, 0x14, 0x03, 0x25],
ptx: concat!(include_str!("../ptx-sm86/mtp_original_session_native_rope.ptx"), "\0").as_bytes(),
},
Companion {
name: "native_head_sampler.ptx",
key: [0x86, 0x3d, 0xb1, 0x3d, 0xc6, 0x50, 0x23, 0x20, 0x6e, 0xb1, 0xa4, 0x5f, 0x29, 0xd4, 0xb9, 0x90, 0xa6, 0x59, 0x57, 0xba, 0x15, 0xd7, 0x83, 0xc2, 0x32, 0x9b, 0xbd, 0x88, 0xec, 0x61, 0x33, 0x3f],
len: 497973,
sha: [0xe8, 0x64, 0x39, 0x00, 0x9f, 0x42, 0xe6, 0xbf, 0x64, 0xbf, 0xfa, 0xe8, 0x1c, 0xdc, 0x7e, 0xef, 0x69, 0x3f, 0xac, 0x9c, 0x09, 0x32, 0x80, 0x3f, 0xf0, 0x20, 0x8f, 0x85, 0x07, 0x1a, 0x86, 0x49],
ptx: concat!(include_str!("../ptx-sm86/native_head_sampler.ptx"), "\0").as_bytes(),
},
Companion {
name: "mmq_resident_helpers.ptx",
key: [0x87, 0x0c, 0x6b, 0xc8, 0xa6, 0xec, 0x32, 0x0a, 0x05, 0x9c, 0x50, 0xbe, 0x9d, 0x5c, 0x96, 0x2f, 0xed, 0xec, 0x86, 0x63, 0x4d, 0x98, 0x8f, 0xc0, 0xe6, 0xb9, 0xd7, 0xed, 0xea, 0x11, 0x8d, 0x89],
len: 4045,
sha: [0x66, 0x8f, 0x35, 0x95, 0xce, 0x0d, 0xc7, 0x12, 0x77, 0x2b, 0x80, 0xbd, 0xa3, 0xb8, 0x5b, 0x5f, 0x05, 0xdd, 0x89, 0x23, 0x2a, 0x0a, 0x15, 0x00, 0x46, 0xff, 0x1f, 0xc4, 0xb1, 0x37, 0x90, 0x94],
ptx: concat!(include_str!("../ptx-sm86/mmq_resident_helpers.ptx"), "\0").as_bytes(),
},
Companion {
name: "qsa_prompt_kv.ptx",
key: [0x87, 0xfd, 0x96, 0x69, 0xca, 0x28, 0x05, 0xe3, 0xaf, 0x3f, 0x97, 0x26, 0xb9, 0xd6, 0x92, 0x66, 0xda, 0xea, 0xc4, 0x17, 0x25, 0x31, 0x6a, 0x38, 0x23, 0x63, 0xc9, 0x56, 0xfd, 0x51, 0x04, 0x65],
len: 12143,
sha: [0xad, 0xce, 0x0f, 0xc9, 0xb8, 0x5a, 0x2f, 0x60, 0x52, 0xcc, 0xd1, 0x13, 0x55, 0xf9, 0x11, 0x8b, 0x88, 0x63, 0x4e, 0x52, 0x31, 0x46, 0xe9, 0xfa, 0x8e, 0x1f, 0x86, 0xf0, 0xe8, 0xdb, 0x5b, 0x6c],
ptx: concat!(include_str!("../ptx-sm86/qsa_prompt_kv.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_full_gr_write.ptx",
key: [0x88, 0x1e, 0x38, 0xf0, 0xc9, 0x78, 0x6c, 0xed, 0x23, 0x8b, 0x7a, 0x00, 0x14, 0x8a, 0x2e, 0x16, 0xac, 0xff, 0x92, 0x7f, 0x7b, 0x8d, 0xe6, 0x6a, 0x1d, 0xd5, 0x83, 0xab, 0xf8, 0x1c, 0xf5, 0xb1],
len: 133910,
sha: [0x3b, 0xb1, 0x46, 0x0d, 0xe3, 0x5d, 0xa4, 0x42, 0x21, 0x7f, 0xf0, 0x35, 0x38, 0x7c, 0xaf, 0xc5, 0x33, 0x3a, 0x7d, 0x6b, 0x6c, 0x31, 0x16, 0xc5, 0x8a, 0xb3, 0x0a, 0xce, 0xd9, 0x62, 0x0c, 0xd1],
ptx: concat!(include_str!("../ptx-sm86/mtp_original_full_gr_write.ptx"), "\0").as_bytes(),
},
Companion {
name: "qsa_prompt_indexer.ptx",
key: [0x89, 0x15, 0x70, 0x0d, 0xd8, 0x1c, 0x99, 0x08, 0x3d, 0xe3, 0xcf, 0xf4, 0xed, 0x5d, 0x1a, 0x8b, 0x9a, 0x0c, 0x5d, 0xb1, 0x8c, 0x4d, 0x6d, 0xef, 0x9d, 0x49, 0xb3, 0xbb, 0xc8, 0xf2, 0x82, 0x30],
len: 30560,
sha: [0x51, 0x62, 0x2e, 0x4f, 0x08, 0xa7, 0xe1, 0xfb, 0x52, 0x0f, 0xac, 0x0d, 0x0d, 0x8d, 0x2c, 0x3b, 0x61, 0xdc, 0xa1, 0x22, 0x70, 0x51, 0xaa, 0x14, 0xf6, 0xf7, 0x7d, 0xfc, 0x0a, 0xdf, 0x57, 0xad],
ptx: concat!(include_str!("../ptx-sm86/qsa_prompt_indexer.ptx"), "\0").as_bytes(),
},
Companion {
name: "qsa_prompt_resolver.ptx",
key: [0x8d, 0x3e, 0xcb, 0xae, 0xcb, 0xf2, 0x84, 0x45, 0xba, 0x64, 0x48, 0x5b, 0xdf, 0xf3, 0xd9, 0x1a, 0x21, 0xd8, 0x7b, 0x85, 0xd5, 0x93, 0x9a, 0x01, 0x52, 0xef, 0x2f, 0x24, 0x14, 0x48, 0x0e, 0x22],
len: 23915,
sha: [0x32, 0xd9, 0x6c, 0xa6, 0xa7, 0x2f, 0x40, 0xed, 0xa2, 0x1d, 0x51, 0xd9, 0xf4, 0xd4, 0xd3, 0x77, 0xc3, 0x73, 0xc6, 0x37, 0x83, 0xcc, 0x42, 0x29, 0x10, 0x88, 0x3b, 0xb8, 0xd8, 0xd8, 0xb0, 0x8d],
ptx: concat!(include_str!("../ptx-sm86/qsa_prompt_resolver.ptx"), "\0").as_bytes(),
},
Companion {
name: "q2_0_q8_1.ptx",
key: [0x8e, 0x81, 0xdb, 0xba, 0xa7, 0x6d, 0x85, 0x16, 0x47, 0x63, 0x39, 0xc1, 0x68, 0xf1, 0xd9, 0xc1, 0x72, 0x34, 0x1a, 0x78, 0xcc, 0xec, 0xda, 0x08, 0x71, 0x4a, 0x13, 0xa5, 0x68, 0x7e, 0x3b, 0x6e],
len: 18542,
sha: [0x8a, 0x25, 0x1c, 0x65, 0x02, 0x31, 0xac, 0x07, 0xa0, 0xce, 0xa8, 0xdd, 0xa2, 0x12, 0xbb, 0x84, 0xd1, 0xcf, 0x5c, 0xa3, 0x72, 0xf6, 0x30, 0xce, 0x03, 0x23, 0x81, 0xe0, 0x18, 0xce, 0x59, 0xf5],
ptx: concat!(include_str!("../ptx-sm86/q2_0_q8_1.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_full_element.ptx",
key: [0x8f, 0xdf, 0xdf, 0x8e, 0xf6, 0x16, 0x69, 0x8c, 0x12, 0x30, 0x1f, 0x7d, 0xf4, 0x71, 0x6f, 0xc0, 0x22, 0xbf, 0x34, 0xb4, 0x19, 0x09, 0x9e, 0x4c, 0x97, 0x27, 0x29, 0x92, 0x0b, 0xd5, 0xf4, 0xa7],
len: 54956,
sha: [0xe3, 0xd7, 0x50, 0x63, 0x73, 0xa9, 0x30, 0x1c, 0x4d, 0x0e, 0xbd, 0x40, 0x13, 0x17, 0x2c, 0xce, 0x60, 0x91, 0xfc, 0xd5, 0x87, 0xb2, 0xad, 0xc3, 0x54, 0x1b, 0x6a, 0x55, 0xb9, 0xd5, 0xf1, 0xfd],
ptx: concat!(include_str!("../ptx-sm86/mtp_original_full_element.ptx"), "\0").as_bytes(),
},
Companion {
name: "qsa_prompt_attention_variants.ptx",
key: [0x90, 0x41, 0xe2, 0x50, 0xf6, 0xff, 0xca, 0x2f, 0x84, 0x9c, 0x20, 0x60, 0x5a, 0x3f, 0x75, 0x8c, 0x54, 0xf7, 0x85, 0x6e, 0x7c, 0xd0, 0x15, 0xc8, 0xa1, 0xda, 0x66, 0x25, 0x04, 0x8d, 0x6a, 0xac],
len: 216290,
sha: [0xa3, 0xe4, 0xd6, 0x97, 0x57, 0x88, 0xd1, 0x26, 0x72, 0xe3, 0x85, 0x5e, 0x5e, 0x9f, 0x16, 0x56, 0x0d, 0x3d, 0x82, 0x63, 0xb7, 0x52, 0x16, 0xaa, 0xf0, 0x89, 0x5c, 0x57, 0x98, 0x70, 0xbb, 0x7d],
ptx: concat!(include_str!("../ptx-sm86/qsa_prompt_attention_variants.ptx"), "\0").as_bytes(),
},
Companion {
name: "qwen_qsa_attention.ptx",
key: [0x91, 0x21, 0x9c, 0xfb, 0xc1, 0xa7, 0x7c, 0x4b, 0xb6, 0x66, 0x61, 0x06, 0x0a, 0xc9, 0x39, 0xa5, 0x0d, 0xc4, 0xc4, 0xd7, 0xd4, 0xdb, 0x8d, 0x50, 0xbc, 0x59, 0xfb, 0xcd, 0x16, 0x75, 0x62, 0xb2],
len: 26737,
sha: [0xc1, 0x11, 0xc6, 0x12, 0x6a, 0x3a, 0x67, 0x5e, 0xc8, 0x87, 0x20, 0x88, 0x1d, 0x46, 0x99, 0xa6, 0xe7, 0x21, 0x84, 0xd2, 0xf4, 0x55, 0x87, 0x9a, 0xe0, 0x85, 0x5c, 0x56, 0xb8, 0x48, 0xbe, 0xa1],
ptx: concat!(include_str!("../ptx-sm86/qwen_qsa_attention.ptx"), "\0").as_bytes(),
},
Companion {
name: "moe_group_down_q2_0.ptx",
key: [0x94, 0x7d, 0x08, 0xc4, 0x10, 0x9a, 0x19, 0x7a, 0xa1, 0xfa, 0xfc, 0xa4, 0xe8, 0xc9, 0x82, 0x3c, 0x91, 0xa8, 0xbd, 0xa0, 0x34, 0xb1, 0x62, 0x79, 0x2c, 0x83, 0x9a, 0x67, 0x97, 0x55, 0x19, 0xda],
len: 13458,
sha: [0xfc, 0x1a, 0xfa, 0x0b, 0x72, 0x43, 0x38, 0xd9, 0x31, 0x48, 0x1f, 0x41, 0x61, 0x6b, 0x8d, 0x25, 0x1f, 0x15, 0x0d, 0x06, 0x5d, 0x91, 0x15, 0x1a, 0x77, 0x12, 0xf9, 0xa9, 0x41, 0xce, 0x25, 0x4f],
ptx: concat!(include_str!("../ptx-sm86/moe_group_down_q2_0.ptx"), "\0").as_bytes(),
},
Companion {
name: "iq3_s_q8_1.ptx",
key: [0x94, 0xf7, 0x98, 0xc0, 0x08, 0x13, 0xc2, 0xfb, 0x86, 0x0b, 0x4b, 0xf7, 0x7b, 0xe9, 0x22, 0x57, 0x67, 0xd4, 0x08, 0x95, 0x5e, 0x34, 0x21, 0x33, 0x0a, 0xc3, 0x4a, 0x4e, 0xbd, 0x43, 0x97, 0x8f],
len: 24712,
sha: [0xb1, 0x98, 0x60, 0x07, 0x0e, 0x69, 0xdc, 0xcd, 0x5e, 0x98, 0xd1, 0xe6, 0xbc, 0x7c, 0xdd, 0xcd, 0xa2, 0x92, 0x8e, 0xfb, 0xd3, 0xf0, 0xbd, 0x21, 0x56, 0x8f, 0xd1, 0xae, 0x7d, 0x4a, 0xe9, 0x27],
ptx: concat!(include_str!("../ptx-sm86/iq3_s_q8_1.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_full_gr_post.ptx",
key: [0x9b, 0x47, 0x9c, 0x0f, 0x41, 0x2a, 0xe0, 0x07, 0x73, 0x81, 0x5c, 0x9a, 0x6d, 0x89, 0xd7, 0xf4, 0xc3, 0xf7, 0xa9, 0xf0, 0xf6, 0x91, 0x87, 0x6d, 0xe8, 0x05, 0xeb, 0x38, 0x17, 0x8d, 0x97, 0x90],
len: 35821,
sha: [0x77, 0x93, 0x32, 0x2e, 0x19, 0x00, 0x2f, 0xe8, 0x19, 0x97, 0xbc, 0xab, 0x03, 0xb9, 0xf4, 0xce, 0xd6, 0xce, 0x07, 0x62, 0xde, 0x88, 0x6b, 0xed, 0xe9, 0xbb, 0x11, 0xa9, 0xd3, 0x80, 0xf6, 0x4c],
ptx: concat!(include_str!("../ptx-sm86/mtp_original_full_gr_post.ptx"), "\0").as_bytes(),
},
Companion {
name: "qsa_native_batch.ptx",
key: [0x9b, 0xa6, 0x85, 0x23, 0xb6, 0x7a, 0x0e, 0x3b, 0x80, 0xfc, 0x16, 0x7b, 0x97, 0x30, 0x19, 0x63, 0xcf, 0x15, 0x98, 0x12, 0xcd, 0x15, 0x7f, 0x03, 0xc5, 0xa0, 0x2b, 0x69, 0xfd, 0xa2, 0x2f, 0xc7],
len: 4566,
sha: [0xcb, 0xf1, 0x3c, 0x31, 0x7b, 0x78, 0x84, 0x54, 0x28, 0xc9, 0x86, 0xe9, 0xa9, 0xbf, 0xc0, 0x47, 0x53, 0x30, 0x29, 0x55, 0x51, 0x3a, 0x4a, 0xfd, 0x11, 0xf1, 0x39, 0xf2, 0x62, 0x22, 0xb6, 0xff],
ptx: concat!(include_str!("../ptx-sm86/qsa_native_batch.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_session_legacy_rope.ptx",
key: [0x9b, 0xba, 0x3b, 0x35, 0x85, 0x0c, 0xe3, 0x86, 0x9e, 0x32, 0xc5, 0x6c, 0x9d, 0xe6, 0x6a, 0x06, 0x52, 0x69, 0x11, 0x88, 0xf4, 0xc7, 0xff, 0x1d, 0xc4, 0xb1, 0xee, 0x9b, 0x2f, 0x9d, 0x0d, 0x9f],
len: 12202,
sha: [0x25, 0x7e, 0x32, 0x1a, 0xbe, 0xa3, 0x30, 0x92, 0x6b, 0x29, 0x9a, 0x6a, 0x03, 0x03, 0x0d, 0x4c, 0xd2, 0xdf, 0x98, 0xe1, 0xf9, 0x7f, 0xfe, 0x07, 0x2d, 0xc1, 0x83, 0xc1, 0x1c, 0x5b, 0x9d, 0xe7],
ptx: concat!(include_str!("../ptx-sm86/mtp_original_session_legacy_rope.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_full_qnorm.ptx",
key: [0xa0, 0xbc, 0xfe, 0xbd, 0x6b, 0xf4, 0x77, 0xcd, 0x3a, 0xd1, 0x36, 0x07, 0xe2, 0xf0, 0x1f, 0x3c, 0x0a, 0x9e, 0x4c, 0x70, 0x22, 0x87, 0x21, 0x36, 0x20, 0xd9, 0x1c, 0x89, 0xb9, 0x29, 0x8e, 0xb1],
len: 36079,
sha: [0x0f, 0x71, 0xc4, 0x60, 0xd4, 0x0a, 0x3e, 0xfb, 0xc4, 0x68, 0xba, 0xc3, 0x4b, 0xb9, 0x3f, 0x62, 0xa7, 0x17, 0x37, 0xd7, 0x28, 0x31, 0x92, 0x17, 0x5c, 0xff, 0x7e, 0x13, 0x32, 0x38, 0x20, 0x7f],
ptx: concat!(include_str!("../ptx-sm86/mtp_original_full_qnorm.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_full_bf16.ptx",
key: [0xa1, 0x6d, 0xfc, 0xfc, 0x9a, 0x49, 0xcc, 0xab, 0x25, 0xd8, 0x03, 0x02, 0x93, 0xd5, 0x82, 0x6f, 0x8f, 0x75, 0xe2, 0x86, 0x8f, 0xae, 0x1b, 0x6c, 0x4c, 0xef, 0x70, 0x6b, 0x6d, 0xfc, 0x3d, 0x08],
len: 461120,
sha: [0x07, 0xf4, 0xde, 0x80, 0xcb, 0xb0, 0xdc, 0x7d, 0xc2, 0xb7, 0x5f, 0x75, 0x6e, 0x24, 0x1b, 0x30, 0x89, 0xd3, 0xcd, 0x97, 0xc7, 0x33, 0x6a, 0xe5, 0xf6, 0xbe, 0x0f, 0xa6, 0x42, 0x78, 0x3d, 0x81],
ptx: concat!(include_str!("../ptx-sm86/mtp_original_full_bf16.ptx"), "\0").as_bytes(),
},
Companion {
name: "iq2_s_q8_1.ptx",
key: [0xa3, 0x1e, 0x65, 0x3d, 0xa8, 0xc2, 0x22, 0xe1, 0x67, 0x1c, 0xf2, 0x5e, 0xd1, 0x90, 0x17, 0xee, 0xb0, 0xb3, 0xef, 0x4d, 0x89, 0x0c, 0x01, 0x42, 0xb1, 0x81, 0xf3, 0xd5, 0xbc, 0xfc, 0xfb, 0x2c],
len: 46912,
sha: [0xc6, 0xca, 0xe7, 0xc0, 0x39, 0x61, 0x79, 0x04, 0x0b, 0x0c, 0x88, 0xf3, 0xce, 0xbd, 0x24, 0x70, 0xdf, 0x92, 0x69, 0xad, 0x5d, 0xc6, 0x6e, 0x9e, 0x22, 0x7f, 0x60, 0x0d, 0x1e, 0x79, 0xed, 0x9b],
ptx: concat!(include_str!("../ptx-sm86/iq2_s_q8_1.ptx"), "\0").as_bytes(),
},
Companion {
name: "chain_window.ptx",
key: [0xa3, 0xab, 0xdc, 0x41, 0x86, 0xb6, 0x6d, 0x51, 0xa8, 0x0c, 0x8e, 0xf5, 0x2f, 0x63, 0x6f, 0x18, 0x93, 0xa2, 0x13, 0x6b, 0x88, 0x7c, 0xd6, 0x54, 0x87, 0x86, 0xfe, 0xa2, 0x79, 0xef, 0x71, 0xba],
len: 2336938,
sha: [0x36, 0x1e, 0x11, 0x00, 0xad, 0x58, 0xb9, 0xa2, 0x1b, 0xe3, 0xd9, 0x58, 0xef, 0x55, 0x59, 0xe7, 0x0b, 0x72, 0xf2, 0xd0, 0x4e, 0x15, 0xdb, 0x5e, 0x9d, 0xbc, 0x14, 0xd1, 0x21, 0xe0, 0xee, 0x43],
ptx: concat!(include_str!("../ptx-sm86/chain_window.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_full_router_legacy.ptx",
key: [0xa5, 0x84, 0x12, 0x24, 0x97, 0x57, 0xcc, 0x35, 0x1e, 0xb8, 0x33, 0x2e, 0x80, 0x7e, 0x79, 0xf1, 0xb3, 0xda, 0x58, 0x65, 0x57, 0x4d, 0x0f, 0xb7, 0x17, 0x9e, 0xf5, 0x58, 0xdf, 0x70, 0xaf, 0x24],
len: 159038,
sha: [0xa9, 0x2b, 0xf0, 0xc3, 0xfc, 0x4c, 0xc5, 0x31, 0x2c, 0x14, 0xa5, 0x52, 0xf7, 0x24, 0x4d, 0x4a, 0x7e, 0x10, 0x26, 0xbb, 0x79, 0x32, 0xb0, 0x56, 0x1d, 0x73, 0x57, 0xd8, 0xec, 0x41, 0x72, 0x7f],
ptx: concat!(include_str!("../ptx-sm86/mtp_original_full_router_legacy.ptx"), "\0").as_bytes(),
},
Companion {
name: "mmq-original-formats-fixup.ptx",
key: [0xa6, 0x6a, 0x85, 0x6c, 0xe4, 0x97, 0x82, 0x20, 0xbb, 0xb0, 0x12, 0x57, 0xf3, 0x34, 0xe4, 0x48, 0x46, 0xce, 0xb3, 0x4d, 0x5d, 0xc3, 0x06, 0xdf, 0xbe, 0xba, 0x95, 0x65, 0x7e, 0x05, 0x0b, 0xf3],
len: 309892,
sha: [0xd2, 0x16, 0x69, 0x31, 0xf0, 0x54, 0x52, 0xde, 0x65, 0xed, 0x06, 0xd1, 0xb0, 0x60, 0xa9, 0x4c, 0x27, 0xa8, 0x68, 0x8e, 0xf5, 0x9b, 0x5f, 0xfc, 0x96, 0x08, 0x69, 0x64, 0x7a, 0x44, 0x84, 0x8b],
ptx: concat!(include_str!("../ptx-sm86/mmq-original-formats-fixup.ptx"), "\0").as_bytes(),
},
Companion {
name: "mmq_original_group_fixup.ptx",
key: [0xa8, 0xc7, 0x51, 0x91, 0xba, 0x8e, 0xf7, 0xa4, 0x57, 0x20, 0x82, 0x48, 0x50, 0xd6, 0x4c, 0xf4, 0x43, 0x45, 0x9b, 0x30, 0xbc, 0x53, 0x79, 0xab, 0x80, 0x7e, 0xb8, 0x3e, 0x26, 0x14, 0x88, 0x3f],
len: 1455508,
sha: [0x18, 0xc9, 0x1c, 0x0f, 0x77, 0x48, 0x36, 0xd9, 0xcd, 0xc6, 0xee, 0x49, 0x8f, 0x3f, 0x3d, 0x66, 0x2b, 0x40, 0x07, 0x77, 0x39, 0x95, 0x29, 0xa4, 0x38, 0xf7, 0xae, 0x27, 0x67, 0x10, 0xf2, 0x04],
ptx: concat!(include_str!("../ptx-sm86/mmq_original_group_fixup.ptx"), "\0").as_bytes(),
},
Companion {
name: "mmq_original_group_swiglu.ptx",
key: [0xa9, 0x13, 0x99, 0x36, 0x00, 0x87, 0x8c, 0xed, 0xd1, 0x28, 0xbe, 0xe0, 0xf7, 0x76, 0x89, 0x51, 0x19, 0xe5, 0x56, 0xe3, 0x3f, 0x2a, 0xd7, 0x0d, 0xad, 0xf0, 0x8e, 0x9e, 0x1a, 0x7e, 0xb9, 0xbd],
len: 6090,
sha: [0x7a, 0x34, 0x2b, 0xa9, 0x78, 0x1d, 0x0f, 0xdb, 0x63, 0x66, 0xc1, 0xb5, 0xbf, 0xd0, 0x65, 0xaa, 0x40, 0x05, 0xfd, 0x3f, 0x3d, 0x19, 0x5d, 0xaf, 0x0f, 0x2f, 0x0f, 0x64, 0x7d, 0x71, 0xe9, 0xec],
ptx: concat!(include_str!("../ptx-sm86/mmq_original_group_swiglu.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_full_fused_gr.ptx",
key: [0xac, 0x54, 0x00, 0xa7, 0x97, 0x2b, 0x3f, 0x24, 0x26, 0x48, 0xc2, 0xde, 0x71, 0xef, 0x4f, 0x17, 0x84, 0x66, 0xd3, 0x8b, 0x13, 0x92, 0xa8, 0x3a, 0x95, 0x91, 0xb3, 0xb2, 0x4e, 0x92, 0xc5, 0x9b],
len: 422848,
sha: [0xe4, 0xc8, 0xcc, 0xbb, 0xfb, 0x68, 0x26, 0x7c, 0xa0, 0xba, 0xc4, 0xfd, 0xbd, 0x91, 0x04, 0x22, 0xa3, 0x16, 0x87, 0x0b, 0x0f, 0x79, 0x9c, 0x48, 0x52, 0x9c, 0x8a, 0x9d, 0xb9, 0xea, 0xa8, 0xe6],
ptx: concat!(include_str!("../ptx-sm86/mtp_original_full_fused_gr.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_fixed.ptx",
key: [0xad, 0xa8, 0x7a, 0x1b, 0xd6, 0xff, 0x2f, 0x60, 0x13, 0xd2, 0xbd, 0x64, 0x1a, 0x37, 0x86, 0xeb, 0x46, 0xb9, 0xc9, 0xfc, 0xf3, 0x58, 0x6c, 0x66, 0x60, 0x9c, 0x8e, 0xee, 0xa4, 0xb1, 0x07, 0xe8],
len: 15190,
sha: [0x62, 0xd0, 0x43, 0x0e, 0x9e, 0xaf, 0x35, 0xd2, 0x1b, 0x95, 0xad, 0xc8, 0x18, 0xd5, 0x7b, 0xb8, 0x5e, 0xaf, 0x0a, 0x74, 0x66, 0x06, 0x87, 0x0d, 0xd5, 0xf1, 0xf2, 0xed, 0x25, 0xc1, 0xf7, 0x27],
ptx: concat!(include_str!("../ptx-sm86/mtp_fixed.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_full_head_sampler.ptx",
key: [0xb0, 0x48, 0xca, 0x90, 0xf9, 0x7e, 0x6e, 0x6f, 0x2c, 0x0d, 0x93, 0xe5, 0xc1, 0x24, 0xe5, 0xd4, 0xad, 0xbc, 0x7b, 0x34, 0x09, 0x74, 0xe4, 0x5a, 0x4f, 0x98, 0xdc, 0x15, 0xd0, 0xb1, 0xbc, 0x59],
len: 504479,
sha: [0xa2, 0x45, 0xc8, 0x5c, 0x87, 0xbd, 0xf2, 0x03, 0x13, 0xbf, 0xf4, 0x22, 0x07, 0xbb, 0xd6, 0xfb, 0xa6, 0xda, 0x14, 0x8a, 0xd3, 0xa0, 0x89, 0x4d, 0x6a, 0x5e, 0xbf, 0xa3, 0x39, 0x8e, 0xca, 0xc7],
ptx: concat!(include_str!("../ptx-sm86/mtp_original_full_head_sampler.ptx"), "\0").as_bytes(),
},
Companion {
name: "ple_fixed.ptx",
key: [0xb1, 0x4c, 0x64, 0x24, 0xb3, 0x4a, 0x4f, 0xba, 0xc6, 0x8a, 0xe3, 0x33, 0xad, 0xf9, 0x77, 0xe1, 0xa3, 0xff, 0x93, 0xe5, 0x0a, 0xe9, 0x97, 0x52, 0x8b, 0xb9, 0xa2, 0x33, 0xdf, 0xe7, 0x04, 0x86],
len: 30868,
sha: [0x32, 0xbc, 0x7b, 0xc0, 0xcb, 0x88, 0x9b, 0x30, 0xaf, 0xc2, 0x02, 0x88, 0x51, 0x8b, 0x90, 0xa4, 0x13, 0x7a, 0x05, 0xb0, 0x5d, 0xaf, 0x3d, 0x4f, 0xee, 0xde, 0xcc, 0x02, 0xe5, 0x66, 0xce, 0x0a],
ptx: concat!(include_str!("../ptx-sm86/ple_fixed.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_full_shared.ptx",
key: [0xb3, 0x6f, 0x43, 0x26, 0x92, 0xe4, 0x3f, 0x79, 0x48, 0xa2, 0x53, 0x8c, 0x22, 0xca, 0xb5, 0x5e, 0xf6, 0x7c, 0x62, 0x5b, 0x8d, 0x44, 0x61, 0xc6, 0x7c, 0xa2, 0xa2, 0x75, 0x19, 0xb9, 0xe0, 0xf0],
len: 45827,
sha: [0xe9, 0x22, 0x49, 0x6b, 0x44, 0xdd, 0xb0, 0xde, 0x69, 0x00, 0xb5, 0xbe, 0xec, 0x4b, 0x35, 0x09, 0xf2, 0xfa, 0x7e, 0x2a, 0x17, 0x2c, 0x3f, 0xe1, 0x76, 0xc1, 0x6e, 0xdd, 0x10, 0x18, 0x52, 0x90],
ptx: concat!(include_str!("../ptx-sm86/mtp_original_full_shared.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_scalar_norm.ptx",
key: [0xbb, 0x78, 0x4f, 0xd8, 0xa5, 0x74, 0xeb, 0x38, 0xcc, 0x3f, 0xdb, 0x92, 0x64, 0xb6, 0x9b, 0x72, 0xcd, 0xf3, 0x40, 0x78, 0x85, 0x91, 0x88, 0x5c, 0x9b, 0x7f, 0x96, 0xa0, 0x5a, 0x6a, 0x81, 0x07],
len: 16691,
sha: [0x56, 0xab, 0x10, 0x69, 0x20, 0x71, 0x2b, 0x92, 0x7c, 0xe8, 0x94, 0xb7, 0x22, 0x7d, 0x7c, 0xb4, 0x7c, 0x7a, 0xda, 0x9f, 0x07, 0x90, 0xc3, 0x65, 0x08, 0xf5, 0xc9, 0x8f, 0x74, 0x0d, 0x7c, 0xdc],
ptx: concat!(include_str!("../ptx-sm86/mtp_original_scalar_norm.ptx"), "\0").as_bytes(),
},
Companion {
name: "native_flash_attn.ptx",
key: [0xbe, 0x35, 0x3e, 0x61, 0x9a, 0x15, 0xa5, 0x66, 0xe5, 0x7b, 0xae, 0x12, 0xa0, 0xbf, 0x30, 0xcc, 0x17, 0x12, 0xa2, 0x81, 0xbc, 0xe6, 0x92, 0x8f, 0x3b, 0xb7, 0x6c, 0x14, 0xe5, 0x11, 0x4b, 0xba],
len: 208590,
sha: [0x6e, 0xaf, 0xd5, 0x7d, 0x2f, 0xcf, 0x68, 0x71, 0xb8, 0x22, 0x4f, 0xe9, 0x48, 0x52, 0x59, 0xd1, 0xec, 0x75, 0x0f, 0xb1, 0x76, 0xa2, 0x68, 0x96, 0x6b, 0x1d, 0xe4, 0x3f, 0xfa, 0x75, 0x62, 0x97],
ptx: concat!(include_str!("../ptx-sm86/native_flash_attn.ptx"), "\0").as_bytes(),
},
Companion {
name: "quantize-d4-selected.ptx",
key: [0xbe, 0x3b, 0x9f, 0x55, 0xff, 0x60, 0x69, 0xde, 0x50, 0x52, 0xc8, 0x3e, 0xf2, 0x2d, 0xa8, 0xfe, 0x88, 0xcd, 0x65, 0xe3, 0xe4, 0xfb, 0x1b, 0x13, 0xa7, 0xf9, 0x3d, 0xd1, 0x4f, 0x69, 0x9c, 0x1b],
len: 102215,
sha: [0x15, 0xe3, 0xb0, 0xb1, 0x95, 0x03, 0x41, 0x3b, 0x7f, 0x7d, 0x97, 0x21, 0xaf, 0x05, 0x11, 0xbb, 0x5a, 0xb9, 0xf5, 0xe5, 0x9a, 0x7c, 0xf9, 0x16, 0x77, 0xa3, 0x13, 0xc2, 0x79, 0xc6, 0xa6, 0x9a],
ptx: concat!(include_str!("../ptx-sm86/quantize-d4-selected.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_full_router.ptx",
key: [0xbe, 0x6e, 0x3c, 0x91, 0xe4, 0xf6, 0x83, 0x14, 0x64, 0xf5, 0x99, 0x37, 0x87, 0xf0, 0xbf, 0xf9, 0x69, 0xbc, 0x5d, 0x28, 0x39, 0x5f, 0x24, 0x22, 0x6b, 0x88, 0x67, 0x6b, 0x30, 0x69, 0xa8, 0xcb],
len: 107477,
sha: [0x17, 0xa9, 0x4f, 0xd3, 0xc2, 0xa1, 0xe2, 0x8c, 0x56, 0xbd, 0x85, 0x10, 0xba, 0xd4, 0xb1, 0xda, 0xa3, 0xdb, 0x39, 0xec, 0x01, 0x36, 0xdb, 0xc0, 0x33, 0x4a, 0x00, 0xfa, 0xad, 0xaf, 0x0c, 0x47],
ptx: concat!(include_str!("../ptx-sm86/mtp_original_full_router.ptx"), "\0").as_bytes(),
},
Companion {
name: "moe_group_iq3_s_nc4.ptx",
key: [0xbe, 0x6e, 0xe9, 0x07, 0xc0, 0xb3, 0x70, 0xcb, 0x99, 0x89, 0x4a, 0x03, 0x41, 0x94, 0x66, 0xf1, 0xaa, 0x46, 0x5b, 0xa9, 0xb8, 0xe2, 0xe8, 0xcf, 0x60, 0x38, 0x87, 0xf5, 0x34, 0x45, 0x0d, 0x0c],
len: 36382,
sha: [0x23, 0xb7, 0x02, 0xaa, 0xf1, 0x27, 0x8d, 0xd3, 0xd4, 0x36, 0x14, 0x2b, 0x9c, 0x27, 0x32, 0x19, 0x21, 0xf3, 0x6d, 0xda, 0x76, 0x06, 0xd1, 0xf7, 0x56, 0x97, 0x3e, 0x5d, 0xfc, 0xbd, 0x45, 0x37],
ptx: concat!(include_str!("../ptx-sm86/moe_group_iq3_s_nc4.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_full_verify.ptx",
key: [0xbe, 0xbb, 0xef, 0xc6, 0x5c, 0x2c, 0xc2, 0x1c, 0x54, 0x84, 0x71, 0xf6, 0x90, 0xce, 0x02, 0xc6, 0x73, 0x41, 0x8e, 0x8a, 0xc0, 0x66, 0xd4, 0x9f, 0x94, 0x8d, 0x0e, 0x6e, 0x35, 0xcf, 0xa2, 0x03],
len: 179130,
sha: [0x8e, 0x19, 0x61, 0xf3, 0x6f, 0x40, 0x9d, 0xea, 0x38, 0x60, 0x66, 0x6b, 0xc8, 0xd7, 0x67, 0x95, 0x1c, 0x50, 0xbb, 0xac, 0x96, 0x36, 0x6a, 0x9e, 0xc5, 0xd9, 0x9d, 0x87, 0xbe, 0xc4, 0xe9, 0x30],
ptx: concat!(include_str!("../ptx-sm86/mtp_original_full_verify.ptx"), "\0").as_bytes(),
},
Companion {
name: "gr_batch_preview.ptx",
key: [0xc8, 0x56, 0xb6, 0xf5, 0x2d, 0x41, 0xd7, 0xe8, 0xf8, 0x8d, 0x7c, 0x63, 0xed, 0x68, 0x3b, 0x94, 0x73, 0x10, 0x08, 0x87, 0x10, 0xf6, 0x62, 0xbc, 0xad, 0x0a, 0xfc, 0xed, 0x3e, 0xf6, 0x5c, 0xac],
len: 24666,
sha: [0x8b, 0x51, 0xd3, 0x67, 0x3b, 0xce, 0x01, 0x8b, 0x58, 0x7e, 0xa8, 0x1c, 0x5a, 0xb2, 0xe9, 0xd7, 0xdd, 0x4d, 0x75, 0xd0, 0x01, 0x4f, 0x6c, 0xfd, 0x4f, 0x7c, 0xf5, 0xfc, 0x17, 0xcd, 0x4c, 0xb3],
ptx: concat!(include_str!("../ptx-sm86/gr_batch_preview.ptx"), "\0").as_bytes(),
},
Companion {
name: "moe_group_iq4_xs.ptx",
key: [0xc8, 0x88, 0x0e, 0xf0, 0x8d, 0xcc, 0x6b, 0xfa, 0x4a, 0xcc, 0xc9, 0x89, 0x87, 0xc4, 0x5c, 0x64, 0x1e, 0x47, 0x2c, 0x52, 0x06, 0xad, 0x9d, 0x38, 0x9f, 0x5e, 0x94, 0x38, 0x5c, 0xd8, 0xc9, 0x84],
len: 63256,
sha: [0x72, 0x2e, 0xff, 0xee, 0x93, 0x55, 0xd3, 0xe1, 0x39, 0x73, 0xd8, 0xec, 0x9e, 0x77, 0xde, 0x98, 0xfe, 0xc0, 0xfd, 0x4a, 0x97, 0xea, 0xfe, 0xbb, 0x55, 0x0c, 0xf9, 0xdd, 0xfd, 0x55, 0xc0, 0x2b],
ptx: concat!(include_str!("../ptx-sm86/moe_group_iq4_xs.ptx"), "\0").as_bytes(),
},
Companion {
name: "original_verify_window_pcie.ptx",
key: [0xcb, 0xeb, 0x32, 0x3f, 0x76, 0x47, 0x68, 0x2f, 0xee, 0x9e, 0xd3, 0xf1, 0x2f, 0xb7, 0xb7, 0xa5, 0xb3, 0xeb, 0x19, 0x2f, 0x21, 0x66, 0xc6, 0xec, 0x96, 0xb8, 0x1d, 0x55, 0xc3, 0xba, 0xb9, 0xd1],
len: 7687,
sha: [0x98, 0x5b, 0xbf, 0xc8, 0x77, 0x91, 0xbd, 0x96, 0xa2, 0xcf, 0x61, 0x32, 0xce, 0x7e, 0x49, 0x9b, 0x90, 0xeb, 0xfe, 0x7a, 0x31, 0x0e, 0xe1, 0xc5, 0x78, 0x1c, 0x49, 0xaf, 0xd1, 0x96, 0x4f, 0x67],
ptx: concat!(include_str!("../ptx-sm86/original_verify_window_pcie.ptx"), "\0").as_bytes(),
},
Companion {
name: "original_verify.ptx",
key: [0xd0, 0xda, 0xda, 0x67, 0x15, 0xfb, 0x80, 0x8b, 0xb3, 0x28, 0x82, 0x91, 0xfd, 0x4a, 0x5c, 0x29, 0xe7, 0x8f, 0xd7, 0xfa, 0x6e, 0x70, 0xf2, 0xb9, 0x4d, 0x22, 0x0f, 0x86, 0x0b, 0xb4, 0x33, 0x53],
len: 154200,
sha: [0xba, 0x92, 0xfe, 0x4e, 0x9b, 0x5a, 0xe0, 0x48, 0x86, 0x4a, 0x1c, 0xcb, 0xa8, 0x64, 0x50, 0x22, 0x4a, 0x07, 0x83, 0x67, 0x2c, 0x0c, 0x2b, 0x99, 0xe4, 0xec, 0x32, 0x02, 0xe1, 0x66, 0x03, 0x55],
ptx: concat!(include_str!("../ptx-sm86/original_verify.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_full_quant80.ptx",
key: [0xd1, 0xae, 0x17, 0xce, 0xcc, 0x24, 0xe2, 0x4e, 0x0e, 0x1f, 0xc9, 0x5a, 0x73, 0x52, 0x79, 0x89, 0x71, 0x9b, 0x94, 0x5d, 0xfe, 0xed, 0x68, 0x9e, 0x80, 0x67, 0xa5, 0x8f, 0x10, 0x18, 0x11, 0x90],
len: 96194,
sha: [0x33, 0x98, 0x0b, 0x2a, 0xd2, 0x18, 0xeb, 0x46, 0xb6, 0x4c, 0x3f, 0xf0, 0xf2, 0xe7, 0x3e, 0xba, 0x2d, 0xde, 0x43, 0xed, 0xa7, 0xbf, 0x12, 0x8c, 0x62, 0xc4, 0x08, 0xad, 0xe0, 0x2b, 0xbd, 0x83],
ptx: concat!(include_str!("../ptx-sm86/mtp_original_full_quant80.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_prefill_quant.ptx",
key: [0xd5, 0xa6, 0x7b, 0x91, 0xe2, 0xbd, 0x30, 0x8b, 0x6c, 0x5b, 0x3c, 0xf3, 0x80, 0xf4, 0xb1, 0x40, 0x00, 0x43, 0x28, 0xbd, 0x26, 0x4c, 0x98, 0x83, 0x70, 0xb7, 0x14, 0x37, 0xf9, 0x6b, 0x86, 0x4c],
len: 217573,
sha: [0xcb, 0xa7, 0x20, 0xbb, 0x6b, 0xfb, 0x98, 0x41, 0xfa, 0xc5, 0x71, 0x6f, 0x84, 0x88, 0x6c, 0x94, 0x7f, 0x36, 0xf4, 0xf0, 0x21, 0x0d, 0xe9, 0x10, 0xd3, 0x99, 0x5c, 0x1d, 0x8e, 0x62, 0x0d, 0xd7],
ptx: concat!(include_str!("../ptx-sm86/mtp_original_prefill_quant.ptx"), "\0").as_bytes(),
},
Companion {
name: "qwen_qsa_native.ptx",
key: [0xd6, 0x04, 0x89, 0xfb, 0x70, 0xce, 0x43, 0x70, 0x04, 0x7b, 0xf5, 0x4f, 0xae, 0x8d, 0xd4, 0x6d, 0xfb, 0x53, 0xbb, 0x73, 0xb1, 0x61, 0x8c, 0x58, 0x94, 0x29, 0x32, 0xa7, 0x89, 0xd0, 0x64, 0xc5],
len: 31598,
sha: [0x91, 0x8c, 0x74, 0x1a, 0xb3, 0xde, 0x0c, 0x8e, 0x3a, 0x4d, 0xb0, 0xf4, 0x54, 0xbc, 0xfc, 0x73, 0x9b, 0x9b, 0xad, 0xcd, 0x58, 0xdd, 0x04, 0x7c, 0xc5, 0xfd, 0x87, 0x2e, 0x99, 0xc0, 0x1e, 0xf0],
ptx: concat!(include_str!("../ptx-sm86/qwen_qsa_native.ptx"), "\0").as_bytes(),
},
Companion {
name: "gr_fixed.ptx",
key: [0xde, 0xaa, 0x95, 0xe6, 0x1d, 0x25, 0xff, 0x87, 0xfd, 0x53, 0x1b, 0x62, 0xd5, 0xc2, 0x93, 0x09, 0xb6, 0x9a, 0x37, 0x71, 0x18, 0x20, 0x4e, 0xef, 0xae, 0xe3, 0x10, 0xaf, 0x4e, 0xcf, 0xfa, 0x8b],
len: 22704,
sha: [0x89, 0x18, 0x62, 0xf3, 0xd1, 0x04, 0x0d, 0x14, 0xbf, 0xd3, 0x8f, 0xf0, 0x0e, 0x19, 0xea, 0x42, 0xf4, 0xc6, 0x30, 0xdd, 0xcc, 0xfd, 0xa1, 0x69, 0x9f, 0xf5, 0xc6, 0x8f, 0xa1, 0x26, 0xd9, 0x66],
ptx: concat!(include_str!("../ptx-sm86/gr_fixed.ptx"), "\0").as_bytes(),
},
Companion {
name: "qwen_qsa_select.ptx",
key: [0xe0, 0x94, 0xe1, 0x0f, 0x84, 0xcc, 0xa6, 0x12, 0xca, 0x28, 0x59, 0x6a, 0xa3, 0x94, 0xee, 0x99, 0x9e, 0x33, 0xfe, 0x7b, 0xc8, 0x4b, 0x35, 0x9b, 0xfa, 0xb6, 0xda, 0x07, 0x30, 0xd4, 0xa5, 0x19],
len: 41468,
sha: [0xe8, 0xad, 0xf4, 0x5c, 0x34, 0x90, 0x8f, 0xa7, 0xf1, 0x58, 0x3d, 0x1d, 0xa0, 0xc5, 0x83, 0x04, 0xfa, 0x02, 0x29, 0xbc, 0x2e, 0x37, 0x43, 0xc2, 0xaa, 0x30, 0x58, 0xf9, 0xe2, 0x6f, 0xf2, 0x7b],
ptx: concat!(include_str!("../ptx-sm86/qwen_qsa_select.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_kv.ptx",
key: [0xe0, 0xc1, 0xff, 0x10, 0xd3, 0xd4, 0xbc, 0xf8, 0xfd, 0x33, 0x69, 0x71, 0x30, 0x79, 0xb2, 0x32, 0xe6, 0x2c, 0xdb, 0x2c, 0x3a, 0x34, 0x5f, 0xae, 0xc4, 0x9d, 0x1e, 0x66, 0x76, 0x3f, 0x91, 0x1f],
len: 16734,
sha: [0xb9, 0x61, 0xa6, 0xbc, 0xaf, 0x30, 0x9b, 0xca, 0x67, 0xab, 0xf6, 0xc3, 0x7b, 0x8e, 0x30, 0x3b, 0x16, 0x5f, 0xcd, 0x8f, 0x51, 0xc6, 0x8f, 0x63, 0x11, 0xc5, 0xa0, 0xe1, 0x3f, 0x86, 0x1f, 0x8b],
ptx: concat!(include_str!("../ptx-sm86/mtp_original_kv.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_attention_fixed.ptx",
key: [0xe1, 0x1a, 0xc4, 0xde, 0x66, 0xc9, 0x9c, 0x31, 0xec, 0x95, 0x37, 0x27, 0xbd, 0xac, 0x91, 0xca, 0xc9, 0x7d, 0x58, 0xd8, 0x2a, 0x3d, 0xcb, 0xe0, 0x6e, 0xf4, 0xc6, 0xe8, 0xdc, 0x2a, 0x4c, 0x66],
len: 75847,
sha: [0xa0, 0x5c, 0xff, 0x97, 0xbd, 0x7e, 0x4e, 0x0a, 0xc9, 0x24, 0xad, 0xb9, 0xf0, 0x1f, 0x7b, 0x6c, 0xa8, 0xe9, 0x67, 0x11, 0x3f, 0x84, 0xa1, 0x68, 0x7e, 0x09, 0x76, 0xb5, 0x64, 0x13, 0xa8, 0x37],
ptx: concat!(include_str!("../ptx-sm86/mtp_attention_fixed.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_full_head_iq.ptx",
key: [0xe5, 0x74, 0x52, 0xcc, 0xac, 0x77, 0x2a, 0x8a, 0x8a, 0x77, 0x25, 0x3b, 0xc6, 0xc9, 0x64, 0xeb, 0xb7, 0xbc, 0x61, 0xfd, 0xb2, 0xe9, 0x75, 0x27, 0xa9, 0x77, 0x5f, 0x8c, 0xcf, 0x3c, 0x3b, 0x9f],
len: 792488,
sha: [0xea, 0x98, 0x3e, 0x2b, 0x8f, 0xce, 0xae, 0xbb, 0xa0, 0xad, 0xdb, 0x29, 0x62, 0x84, 0xa1, 0xf2, 0xfa, 0x54, 0x6e, 0x26, 0x04, 0xfe, 0x8d, 0x6a, 0x10, 0x17, 0x02, 0x9a, 0xaf, 0x7e, 0x18, 0xae],
ptx: concat!(include_str!("../ptx-sm86/mtp_original_full_head_iq.ptx"), "\0").as_bytes(),
},
Companion {
name: "mmq-adaptive-fixup.ptx",
key: [0xe8, 0x14, 0xd7, 0x50, 0x21, 0xa7, 0x3c, 0x38, 0x31, 0x02, 0x3d, 0x29, 0x81, 0x84, 0x72, 0x23, 0x2d, 0xb4, 0x47, 0x29, 0x21, 0x3d, 0xf1, 0x0d, 0x60, 0xc4, 0x78, 0x63, 0xaa, 0x47, 0x72, 0x78],
len: 445570,
sha: [0xa5, 0x0b, 0x8a, 0x99, 0x40, 0x09, 0xa3, 0xc6, 0x0e, 0xd8, 0x29, 0xaa, 0x45, 0xf7, 0xb1, 0x71, 0x23, 0x40, 0x12, 0x95, 0xbd, 0xaa, 0x4e, 0x03, 0xe8, 0x71, 0xb4, 0x39, 0x3c, 0x2a, 0xf9, 0x1c],
ptx: concat!(include_str!("../ptx-sm86/mmq-adaptive-fixup.ptx"), "\0").as_bytes(),
},
Companion {
name: "mmq_original_group_mul.ptx",
key: [0xea, 0x0d, 0xb7, 0x85, 0x05, 0x28, 0x9e, 0x8e, 0x74, 0x3a, 0x55, 0x2e, 0xf2, 0x3d, 0xed, 0x98, 0xd6, 0x68, 0xa4, 0x89, 0xc6, 0x79, 0xa0, 0xe4, 0x48, 0x93, 0xb0, 0x00, 0x44, 0x5b, 0x48, 0xc7],
len: 13083403,
sha: [0x8a, 0x80, 0x90, 0xb4, 0x00, 0xf4, 0x08, 0x8f, 0x3d, 0x45, 0x0a, 0x70, 0xca, 0x0f, 0x83, 0x60, 0x8f, 0xfe, 0x44, 0x73, 0xf4, 0x49, 0xd7, 0x9c, 0x69, 0xf8, 0x8c, 0x7c, 0x12, 0x2a, 0x26, 0x4a],
ptx: concat!(include_str!("../ptx-sm86/mmq_original_group_mul.ptx"), "\0").as_bytes(),
},
Companion {
name: "mmq_native_resident_d4.ptx",
key: [0xea, 0x33, 0xd3, 0xd1, 0xdb, 0xc3, 0xc6, 0x39, 0x81, 0x55, 0xef, 0xa1, 0x92, 0xb5, 0xbb, 0x4d, 0x5a, 0x25, 0xf7, 0x3f, 0x6e, 0x8a, 0xf6, 0x5f, 0x2d, 0xdc, 0x1b, 0x91, 0x95, 0xbb, 0x3e, 0xeb],
len: 5199,
sha: [0x95, 0x4e, 0x26, 0x5c, 0x1d, 0x6a, 0x60, 0x53, 0x6c, 0x93, 0x6d, 0x3e, 0x01, 0x24, 0x02, 0x13, 0xc5, 0x0d, 0xf2, 0xae, 0xc8, 0x8c, 0x5f, 0x42, 0x88, 0xa5, 0xd5, 0xf6, 0xe3, 0xb7, 0xc1, 0x14],
ptx: concat!(include_str!("../ptx-sm86/mmq_native_resident_d4.ptx"), "\0").as_bytes(),
},
Companion {
name: "moe_fixed.ptx",
key: [0xeb, 0x25, 0xf4, 0x5f, 0x2b, 0xf1, 0xcd, 0x3b, 0xe5, 0x7e, 0x0b, 0x5f, 0x32, 0x6a, 0x63, 0xf6, 0x66, 0x05, 0x9a, 0x58, 0x70, 0x6d, 0x7a, 0x2b, 0xd4, 0x70, 0x52, 0x6c, 0x22, 0xc0, 0xf6, 0x7a],
len: 24983,
sha: [0x67, 0x25, 0x8f, 0xde, 0x60, 0xe2, 0xe5, 0xd0, 0xe5, 0x0b, 0xe8, 0xcb, 0xd6, 0x3b, 0x0d, 0xe4, 0x2e, 0x33, 0xf7, 0x22, 0xb1, 0x61, 0x40, 0xe1, 0xb0, 0x71, 0x85, 0x7b, 0x47, 0xaa, 0xa8, 0xbe],
ptx: concat!(include_str!("../ptx-sm86/moe_fixed.ptx"), "\0").as_bytes(),
},
Companion {
name: "qsa_late.ptx",
key: [0xeb, 0xc8, 0xbc, 0x0a, 0xac, 0x1b, 0xd4, 0xa7, 0x45, 0x40, 0xed, 0x24, 0x6c, 0x00, 0x96, 0x0d, 0x10, 0x15, 0x96, 0x30, 0x20, 0x11, 0x33, 0xe6, 0xd2, 0x1f, 0x30, 0x6e, 0xfe, 0xb1, 0xba, 0x2f],
len: 213285,
sha: [0x11, 0x8d, 0x23, 0x00, 0xe6, 0x7d, 0x15, 0x42, 0x0b, 0x7e, 0xbd, 0xb4, 0xee, 0x82, 0x3d, 0x91, 0xbe, 0x58, 0x55, 0x62, 0x07, 0x23, 0x85, 0x3f, 0xe9, 0xda, 0x8d, 0xef, 0x8a, 0xe5, 0xe9, 0x8b],
ptx: concat!(include_str!("../ptx-sm86/qsa_late.ptx"), "\0").as_bytes(),
},
Companion {
name: "kar_decode_levels.ptx",
key: [0xec, 0x69, 0x77, 0x87, 0xe0, 0x00, 0x53, 0x10, 0x00, 0x5e, 0xb1, 0x69, 0xa7, 0x58, 0x31, 0x5e, 0xb5, 0x50, 0x3a, 0xc7, 0x67, 0x1a, 0x38, 0x49, 0x5e, 0xea, 0xea, 0xf4, 0xfb, 0x2a, 0x8e, 0xc9],
len: 18428,
sha: [0xb9, 0x41, 0xaf, 0xb1, 0x17, 0xd7, 0x7a, 0x57, 0x32, 0xc1, 0x66, 0x6a, 0x25, 0x29, 0x1a, 0xb9, 0xbf, 0xd6, 0x17, 0x25, 0x28, 0xbd, 0x6b, 0x52, 0x7c, 0x37, 0x39, 0x7f, 0x24, 0xfd, 0x77, 0xc4],
ptx: concat!(include_str!("../ptx-sm86/kar_decode_levels.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_prefill.ptx",
key: [0xf0, 0xa0, 0x67, 0x3d, 0x72, 0xe2, 0xaf, 0x9b, 0xaa, 0x48, 0x14, 0x64, 0xbd, 0x2f, 0x07, 0x04, 0x2a, 0x66, 0x98, 0xd4, 0x64, 0x13, 0xfe, 0x6a, 0x85, 0x4c, 0xc8, 0x30, 0x1d, 0xba, 0x67, 0x5a],
len: 68280,
sha: [0xc3, 0xba, 0x39, 0xe3, 0xc2, 0xbe, 0x4e, 0xfb, 0x0a, 0xca, 0x00, 0x19, 0xe2, 0xaa, 0xe7, 0x47, 0xff, 0x00, 0x1d, 0x13, 0x63, 0x10, 0x16, 0xe5, 0xcc, 0x9f, 0xef, 0x86, 0x7e, 0x9a, 0xc1, 0xaf],
ptx: concat!(include_str!("../ptx-sm86/mtp_original_prefill.ptx"), "\0").as_bytes(),
},
Companion {
name: "original_verify_qsa.ptx",
key: [0xf5, 0x7b, 0x41, 0x82, 0xe2, 0x19, 0x2b, 0xe7, 0xf5, 0xd3, 0x19, 0xe7, 0xa5, 0xe0, 0x2f, 0xaa, 0x5f, 0xc2, 0x45, 0xc0, 0x61, 0x42, 0x6c, 0xd2, 0xbf, 0xc1, 0x39, 0xcf, 0x45, 0x3a, 0xdc, 0x05],
len: 19585,
sha: [0x22, 0xd6, 0x9a, 0x56, 0xf3, 0x88, 0xc1, 0xb3, 0x83, 0xc7, 0xb1, 0x25, 0xeb, 0x11, 0xcb, 0x36, 0xb5, 0xb0, 0xe8, 0x02, 0x6e, 0x95, 0x7b, 0x87, 0xad, 0x06, 0xce, 0x07, 0xc8, 0x02, 0x52, 0x40],
ptx: concat!(include_str!("../ptx-sm86/original_verify_qsa.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_full_head_native.ptx",
key: [0xf8, 0x20, 0x9e, 0x1c, 0x9f, 0xbf, 0x97, 0x8b, 0xc5, 0x7b, 0x60, 0xb0, 0xb5, 0xf6, 0xed, 0xca, 0xb1, 0x90, 0x5e, 0x49, 0xa4, 0xab, 0x3a, 0xa9, 0x82, 0x60, 0x4e, 0x3e, 0x68, 0x0f, 0xa4, 0x37],
len: 7459176,
sha: [0x6b, 0x0a, 0x23, 0x33, 0x72, 0xb7, 0x51, 0x3f, 0x8c, 0x6e, 0xef, 0xd7, 0xaa, 0x7e, 0x66, 0x34, 0x99, 0xb7, 0xe2, 0x38, 0x6c, 0xd8, 0x7c, 0x82, 0x73, 0xde, 0x22, 0xd7, 0x26, 0xa9, 0x84, 0xe5],
ptx: concat!(include_str!("../ptx-sm86/mtp_original_full_head_native.ptx"), "\0").as_bytes(),
},
Companion {
name: "iq3_xxs_q8_1.ptx",
key: [0xf9, 0xc1, 0x08, 0x14, 0xf3, 0x7b, 0x75, 0xba, 0xbc, 0xae, 0xe1, 0x02, 0x8b, 0x4a, 0x13, 0x75, 0xe5, 0x30, 0x22, 0x0f, 0x86, 0x3a, 0xb3, 0x80, 0x1b, 0xeb, 0x8f, 0xcb, 0x5a, 0x19, 0x73, 0x3f],
len: 15564,
sha: [0x94, 0x65, 0x5f, 0x22, 0x89, 0x15, 0xdd, 0x3d, 0x0a, 0xe5, 0xdc, 0x3a, 0xde, 0xde, 0xf8, 0xfc, 0xeb, 0x06, 0x98, 0x20, 0xae, 0x17, 0xe1, 0x5d, 0xb9, 0x49, 0x44, 0x42, 0x79, 0x48, 0xaf, 0xda],
ptx: concat!(include_str!("../ptx-sm86/iq3_xxs_q8_1.ptx"), "\0").as_bytes(),
},
Companion {
name: "qsa_native_gate.ptx",
key: [0xf9, 0xf7, 0x78, 0x15, 0x44, 0xa4, 0xa0, 0xb0, 0xb2, 0xf0, 0x73, 0x3f, 0xe0, 0x0f, 0x36, 0xb8, 0x19, 0x49, 0x54, 0x33, 0x3b, 0x9b, 0xca, 0x99, 0x95, 0x91, 0x40, 0x45, 0xd8, 0x6b, 0xaf, 0x1e],
len: 1356,
sha: [0x20, 0x00, 0x36, 0x45, 0x64, 0x34, 0x00, 0x9b, 0x96, 0x1c, 0x37, 0x1d, 0xa8, 0xa1, 0x44, 0x0d, 0xb1, 0x5a, 0x7b, 0xe9, 0x53, 0x19, 0xa8, 0xc8, 0x15, 0xe1, 0xbf, 0xe8, 0x00, 0x95, 0xf2, 0x1c],
ptx: concat!(include_str!("../ptx-sm86/qsa_native_gate.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_full_s2.ptx",
key: [0xfb, 0xb9, 0x17, 0xd5, 0x90, 0xea, 0x80, 0x33, 0x8a, 0x7b, 0xdf, 0x07, 0xb2, 0xca, 0x6d, 0x45, 0x8f, 0xa7, 0x27, 0x63, 0xba, 0x27, 0x9e, 0x57, 0x6b, 0xcc, 0x1e, 0xec, 0x88, 0x36, 0xfd, 0x55],
len: 408620,
sha: [0x84, 0xfc, 0xa0, 0x77, 0x1f, 0xef, 0x37, 0x13, 0x49, 0xc7, 0x2a, 0xdd, 0xaf, 0x76, 0x73, 0x8a, 0xe9, 0xb7, 0x55, 0x39, 0x89, 0xb5, 0xab, 0xf6, 0x60, 0x0a, 0x22, 0x35, 0x93, 0x95, 0xae, 0x83],
ptx: concat!(include_str!("../ptx-sm86/mtp_original_full_s2.ptx"), "\0").as_bytes(),
},
Companion {
name: "qsa_decode_postops.ptx",
key: [0xfd, 0x76, 0xe6, 0xf8, 0x45, 0x57, 0xd7, 0xf2, 0xa6, 0x2a, 0xc5, 0x6e, 0x16, 0xd5, 0xe4, 0xf7, 0x88, 0x62, 0xe7, 0x56, 0xef, 0x98, 0x52, 0xb0, 0x4d, 0x59, 0x19, 0x99, 0x21, 0x3a, 0x51, 0x19],
len: 12390,
sha: [0x5f, 0xf2, 0x93, 0x19, 0x01, 0x09, 0x9c, 0x2c, 0xfd, 0xb6, 0x03, 0x94, 0x56, 0x52, 0x2a, 0x1e, 0x1c, 0x26, 0xae, 0x32, 0xb6, 0x1f, 0xdf, 0x69, 0xfb, 0xee, 0xd9, 0xc2, 0xca, 0x02, 0xdd, 0x1e],
ptx: concat!(include_str!("../ptx-sm86/qsa_decode_postops.ptx"), "\0").as_bytes(),
},
Companion {
name: "moe_group_swiglu.ptx",
key: [0xfe, 0x6f, 0xba, 0x86, 0x65, 0x4b, 0x64, 0x65, 0x1f, 0xee, 0xe8, 0x43, 0x91, 0xba, 0x77, 0xb2, 0xb0, 0xab, 0xff, 0x8b, 0x06, 0x23, 0xcd, 0xad, 0x41, 0x69, 0x76, 0x95, 0x44, 0x39, 0x7a, 0xea],
len: 4684,
sha: [0xbe, 0x94, 0x9a, 0x3e, 0xf8, 0xc4, 0x3c, 0x2f, 0xa1, 0x1a, 0x73, 0x63, 0x7d, 0x2d, 0x2b, 0x9c, 0x8d, 0x83, 0xdf, 0x56, 0xc2, 0x78, 0x49, 0x21, 0xeb, 0x7b, 0xc2, 0xb4, 0xf0, 0xb5, 0x72, 0x26],
ptx: concat!(include_str!("../ptx-sm86/moe_group_swiglu.ptx"), "\0").as_bytes(),
},
];
pub(crate) static COMPANIONS: &[Companion] = &JOINED;
#[cfg(test)]
mod tests {
use super::{COMPANIONS, ROWS};
/// SHA-256 over the per-row digests of (name NUL, key, len as u64 LE, sha, ptx) in table order: the value computed
/// from the single 934-line table that this layout replaced.
const FORMER_TABLE_DIGEST: &str = "803b3cb0fd174a73d78bb727989f0c08066b3d052b647c052cc26bd6e84de3fc";
fn hex(bytes: &[u8]) -> String {
bytes.iter().map(|b| format!("{b:02x}")).collect()
}
#[test]
fn split_table_equals_the_former_single_table() {
assert_eq!(COMPANIONS.len(), ROWS);
assert_eq!(COMPANIONS.len(), 131);
let mut outer = Vec::with_capacity(COMPANIONS.len() * 32);
for c in COMPANIONS {
let mut row = Vec::with_capacity(c.name.len() + 1 + 32 + 8 + 32 + c.ptx.len());
row.extend_from_slice(c.name.as_bytes());
row.push(0);
row.extend_from_slice(&c.key);
row.extend_from_slice(&(c.len as u64).to_le_bytes());
row.extend_from_slice(&c.sha);
row.extend_from_slice(c.ptx);
outer.extend_from_slice(&crate::qwen_ffi::sha256(&row));
}
assert_eq!(hex(&crate::qwen_ffi::sha256(&outer)), FORMER_TABLE_DIGEST);
}
}
+358
View File
@@ -0,0 +1,358 @@
// @generated shape of scripts/gpu-bringup/sm86_assets.py build: rows 1..27 of the sorted sm_86 table.
use super::Companion;
/// Sorted by `key`; concatenated with the other parts by `super::COMPANIONS`.
#[rustfmt::skip]
pub(super) const ROWS: &[Companion] = &[
Companion {
name: "ple_bf16_pack.ptx",
key: [
0x01, 0x59, 0x28, 0xed, 0xe2, 0x02, 0x42, 0xc6, 0x31, 0x51, 0x30, 0x7b, 0xd5, 0x02, 0xbf, 0x98,
0xf4, 0xfb, 0x58, 0x0b, 0xad, 0x2b, 0x7d, 0x34, 0x72, 0xee, 0xbb, 0xa1, 0x12, 0x95, 0x30, 0xb3,
],
len: 8276,
sha: [
0xb5, 0xe9, 0x9b, 0x53, 0x10, 0xcf, 0x1c, 0x92, 0x11, 0x67, 0x45, 0x06, 0x42, 0x6e, 0xe8, 0x99,
0x68, 0xd1, 0x4a, 0xb7, 0x71, 0x80, 0x55, 0x3d, 0x94, 0xd5, 0xbd, 0xb8, 0x8e, 0x3c, 0x9c, 0x09,
],
ptx: concat!(include_str!("../../ptx-sm86/ple_bf16_pack.ptx"), "\0").as_bytes(),
},
Companion {
name: "offline_native_dequant_f16.ptx",
key: [
0x02, 0x0b, 0xc7, 0x97, 0xfc, 0x5a, 0x8f, 0x36, 0x23, 0x07, 0x54, 0x36, 0xb4, 0x4e, 0x02, 0x1a,
0x2e, 0x97, 0xff, 0xba, 0xaa, 0xbf, 0x54, 0xd2, 0x73, 0xea, 0xce, 0xc1, 0x31, 0x32, 0xeb, 0x2a,
],
len: 58080,
sha: [
0x24, 0x31, 0xc2, 0x8a, 0x19, 0x52, 0x5c, 0x64, 0xb7, 0xf9, 0x75, 0x30, 0x6e, 0x01, 0x99, 0xce,
0x0f, 0x0d, 0x68, 0xf5, 0x5d, 0x22, 0x39, 0xe4, 0xb4, 0x72, 0x80, 0x9f, 0x1e, 0x17, 0x36, 0x70,
],
ptx: concat!(include_str!("../../ptx-sm86/offline_native_dequant_f16.ptx"), "\0").as_bytes(),
},
Companion {
name: "kar_ple_fixed.ptx",
key: [
0x03, 0xc9, 0xf6, 0x63, 0x49, 0x5b, 0xea, 0xf1, 0xdd, 0x42, 0x02, 0x5f, 0x14, 0x80, 0x9b, 0x7b,
0xfb, 0x8c, 0xd7, 0xad, 0x4c, 0x7f, 0xb5, 0x5e, 0x17, 0x3a, 0x79, 0xb1, 0xa9, 0x72, 0x0c, 0x3b,
],
len: 5210,
sha: [
0x76, 0xda, 0x12, 0x64, 0x39, 0xb0, 0x93, 0xf3, 0x9e, 0xda, 0x77, 0x14, 0x29, 0x9b, 0x6d, 0xf9,
0xc9, 0xa6, 0x0f, 0xaf, 0x43, 0xcb, 0x75, 0x8f, 0x49, 0xf3, 0x12, 0x42, 0x75, 0xce, 0xcf, 0x56,
],
ptx: concat!(include_str!("../../ptx-sm86/kar_ple_fixed.ptx"), "\0").as_bytes(),
},
Companion {
name: "bf16_f32_mmvf.ptx",
key: [
0x04, 0x45, 0x43, 0xf6, 0x81, 0xbb, 0x23, 0xeb, 0x9c, 0xae, 0x60, 0x2b, 0x1a, 0x16, 0xaa, 0x7b,
0x23, 0x86, 0xd6, 0xd5, 0xc3, 0xb1, 0x5c, 0xc4, 0x19, 0x87, 0x33, 0x8b, 0xd6, 0x13, 0xb1, 0xc3,
],
len: 5875,
sha: [
0x54, 0xa3, 0x31, 0x46, 0x55, 0x8e, 0xf7, 0x6c, 0x81, 0x7f, 0xc8, 0xe5, 0x56, 0xf7, 0x09, 0x22,
0x8f, 0x90, 0xe2, 0xcc, 0xd6, 0x56, 0x5f, 0x57, 0xc4, 0xf8, 0xec, 0x46, 0x46, 0xe6, 0xc4, 0x42,
],
ptx: concat!(include_str!("../../ptx-sm86/bf16_f32_mmvf.ptx"), "\0").as_bytes(),
},
Companion {
name: "moe_group_iq4_xs_nc4.ptx",
key: [
0x06, 0x11, 0xaa, 0x38, 0x6b, 0x2b, 0x36, 0x6e, 0x99, 0x42, 0xd5, 0x37, 0x17, 0x5b, 0xe5, 0xb1,
0xd9, 0x6e, 0x9c, 0x33, 0xbe, 0x5e, 0x12, 0x36, 0xc8, 0xb4, 0x6a, 0x83, 0x18, 0xf6, 0xb6, 0xc1,
],
len: 74210,
sha: [
0x7c, 0xf9, 0x63, 0x32, 0x59, 0x2e, 0x39, 0x9b, 0x49, 0xe8, 0x4e, 0x53, 0x40, 0xff, 0xbb, 0xab,
0x26, 0xdb, 0x49, 0x25, 0x9a, 0x9b, 0x5e, 0x03, 0x04, 0x79, 0x4c, 0x1c, 0x0f, 0x54, 0x79, 0x41,
],
ptx: concat!(include_str!("../../ptx-sm86/moe_group_iq4_xs_nc4.ptx"), "\0").as_bytes(),
},
Companion {
name: "q8_1_quantize.ptx",
key: [
0x06, 0x40, 0x3c, 0x31, 0xe0, 0x94, 0x4b, 0x39, 0xc6, 0x8f, 0x3a, 0xf6, 0x37, 0xe3, 0x3d, 0xaa,
0x5f, 0x3d, 0x4c, 0x07, 0x26, 0x8f, 0x6b, 0xce, 0x15, 0x0c, 0x89, 0x1b, 0x9c, 0xf2, 0x33, 0xb0,
],
len: 7200,
sha: [
0xbb, 0x46, 0xb0, 0x53, 0xaf, 0x13, 0x94, 0xc4, 0x62, 0x17, 0x39, 0x3b, 0x4f, 0x7e, 0xff, 0xc1,
0xc9, 0x5f, 0xc4, 0x8a, 0xa5, 0x54, 0x68, 0x2a, 0xfb, 0xa5, 0xea, 0xeb, 0x0c, 0xd9, 0xc0, 0x6a,
],
ptx: concat!(include_str!("../../ptx-sm86/q8_1_quantize.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_full_gr_norm.ptx",
key: [
0x06, 0xd6, 0x17, 0x7b, 0x48, 0x2c, 0xb6, 0x74, 0x13, 0xc6, 0x59, 0x6a, 0x02, 0x91, 0xb4, 0xda,
0xb1, 0x85, 0x03, 0x32, 0x16, 0x4a, 0x92, 0x12, 0xaf, 0xf6, 0x7b, 0x9e, 0xfd, 0xf2, 0x11, 0x20,
],
len: 29069,
sha: [
0xaa, 0x51, 0x98, 0x13, 0x94, 0xa9, 0x4a, 0xe2, 0x22, 0xf4, 0x4c, 0x23, 0x9d, 0xff, 0x1e, 0xf2,
0x3c, 0xa7, 0xab, 0xda, 0x2a, 0xb0, 0x8f, 0x17, 0x95, 0x43, 0xd6, 0x2e, 0x71, 0x19, 0xd2, 0x1a,
],
ptx: concat!(include_str!("../../ptx-sm86/mtp_original_full_gr_norm.ptx"), "\0").as_bytes(),
},
Companion {
name: "offline_moe_prefill.ptx",
key: [
0x07, 0x5e, 0xf4, 0x38, 0xcd, 0xb6, 0x21, 0x15, 0x05, 0x46, 0xdb, 0xef, 0xf8, 0xf5, 0xe6, 0xfd,
0xc4, 0xaa, 0xeb, 0xc2, 0xe7, 0xfa, 0x10, 0x99, 0xe6, 0xcc, 0x6e, 0xff, 0x3f, 0x5b, 0x6f, 0x34,
],
len: 71011,
sha: [
0xe1, 0x5e, 0x02, 0x23, 0xec, 0x1d, 0x55, 0x5a, 0x3b, 0x89, 0xd7, 0xcb, 0xe3, 0xa6, 0xe9, 0xa0,
0xfe, 0x45, 0xb6, 0x5d, 0x39, 0x02, 0x90, 0x10, 0xd5, 0x19, 0xc7, 0x31, 0x32, 0x48, 0xcc, 0x7f,
],
ptx: concat!(include_str!("../../ptx-sm86/offline_moe_prefill.ptx"), "\0").as_bytes(),
},
Companion {
name: "moe_group_down_iq4_nl.ptx",
key: [
0x0b, 0x7b, 0xa2, 0xb0, 0x0b, 0x91, 0xb6, 0x64, 0x50, 0x51, 0x82, 0xbe, 0xf3, 0x2c, 0xac, 0xad,
0x06, 0x3f, 0x11, 0xee, 0x37, 0xed, 0x93, 0x13, 0x29, 0x64, 0x8d, 0x3e, 0xe4, 0xa0, 0x4d, 0x5a,
],
len: 8620,
sha: [
0x7d, 0xcf, 0xdb, 0x60, 0x83, 0x16, 0xcb, 0x28, 0xf0, 0x77, 0x6a, 0x10, 0xf8, 0x40, 0xb1, 0x98,
0x81, 0x43, 0x5c, 0x75, 0xb7, 0xf4, 0xf2, 0x2b, 0xa2, 0xc3, 0xfe, 0xf9, 0xe5, 0xbb, 0x89, 0xcb,
],
ptx: concat!(include_str!("../../ptx-sm86/moe_group_down_iq4_nl.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_s2_fixed.ptx",
key: [
0x0b, 0xf7, 0xb8, 0x12, 0x8c, 0x2d, 0x59, 0x0e, 0x36, 0xc8, 0xc5, 0x55, 0x97, 0xb4, 0xd0, 0x2f,
0x3c, 0x50, 0x7e, 0x12, 0x0f, 0x3d, 0x09, 0x1c, 0xb3, 0x54, 0xea, 0xee, 0x9e, 0x09, 0x74, 0xf7,
],
len: 103812,
sha: [
0x97, 0xef, 0x26, 0x18, 0x0d, 0x6c, 0xa0, 0xa6, 0xc3, 0xb4, 0xe2, 0x8c, 0x55, 0x5b, 0xf4, 0x94,
0x12, 0x17, 0x5b, 0x7c, 0x65, 0x2d, 0x71, 0xa3, 0x1d, 0xc4, 0xee, 0x09, 0x7d, 0xc2, 0xc1, 0xb2,
],
ptx: concat!(include_str!("../../ptx-sm86/mtp_s2_fixed.ptx"), "\0").as_bytes(),
},
Companion {
name: "mmq-adaptive-selected.ptx",
key: [
0x0c, 0x7f, 0xa1, 0x08, 0x28, 0x02, 0x0b, 0x9e, 0xc8, 0x9b, 0x8b, 0x2f, 0xe5, 0x85, 0x50, 0x2c,
0x84, 0x89, 0xbe, 0x92, 0xf1, 0xf8, 0x25, 0x18, 0x7d, 0x4c, 0x6b, 0x90, 0xf1, 0x06, 0x49, 0x48,
],
len: 3249625,
sha: [
0x3f, 0x3c, 0xbc, 0x5f, 0x2d, 0x2d, 0xc8, 0x23, 0x83, 0xb1, 0x5a, 0x0d, 0xaf, 0xf0, 0x7f, 0xb6,
0x77, 0xcc, 0x4e, 0x45, 0xfb, 0x35, 0x73, 0x7d, 0xdc, 0x61, 0x41, 0x2f, 0xff, 0x3f, 0x79, 0x2c,
],
ptx: concat!(include_str!("../../ptx-sm86/mmq-adaptive-selected.ptx"), "\0").as_bytes(),
},
Companion {
name: "mapped_expert_copy.ptx",
key: [
0x10, 0x51, 0x98, 0x85, 0xee, 0x9d, 0xab, 0xb6, 0x00, 0x10, 0x15, 0x4e, 0x2f, 0x80, 0x9b, 0x39,
0x73, 0x61, 0x86, 0xba, 0x1c, 0x0d, 0xac, 0x11, 0xa2, 0x40, 0x96, 0x5d, 0x05, 0x77, 0x62, 0x57,
],
len: 5620,
sha: [
0x11, 0xda, 0x70, 0xf0, 0x16, 0x18, 0xa2, 0xa6, 0xf9, 0xd6, 0x59, 0xa6, 0xda, 0x03, 0xbb, 0x90,
0x48, 0x0d, 0x4c, 0xbd, 0x14, 0x1d, 0x3c, 0x36, 0x6c, 0xfe, 0x90, 0xc2, 0x65, 0x9d, 0x11, 0xb0,
],
ptx: concat!(include_str!("../../ptx-sm86/mapped_expert_copy.ptx"), "\0").as_bytes(),
},
Companion {
name: "original_verify_window_qsa_gate.ptx",
key: [
0x10, 0x80, 0x7c, 0x4c, 0x62, 0xd8, 0xbf, 0x4b, 0xe7, 0x5c, 0xfb, 0x1a, 0x50, 0x77, 0xfc, 0x3e,
0x00, 0xdc, 0x8f, 0x40, 0xea, 0x66, 0x9b, 0x22, 0xdc, 0xff, 0x7b, 0x78, 0x53, 0xab, 0x79, 0x49,
],
len: 2232,
sha: [
0x0c, 0x13, 0xa5, 0xf2, 0x95, 0x3f, 0x70, 0x7b, 0xb2, 0x87, 0xbc, 0x53, 0x25, 0x83, 0xf3, 0xfd,
0x69, 0xae, 0x8e, 0x80, 0xa7, 0x6e, 0x61, 0xdc, 0x88, 0x27, 0xe1, 0x3f, 0x00, 0x6b, 0x48, 0x49,
],
ptx: concat!(include_str!("../../ptx-sm86/original_verify_window_qsa_gate.ptx"), "\0").as_bytes(),
},
Companion {
name: "gr_native_batch.ptx",
key: [
0x10, 0xa3, 0xe8, 0x36, 0xb9, 0x02, 0xe9, 0xa3, 0x87, 0x05, 0x5e, 0x98, 0x0c, 0x3e, 0xd0, 0x45,
0xe9, 0x0b, 0xdc, 0x25, 0x1e, 0xe1, 0xe6, 0xbe, 0x57, 0x66, 0x81, 0x61, 0x8f, 0x62, 0x1d, 0xb2,
],
len: 29664,
sha: [
0xda, 0xec, 0x53, 0x68, 0x4c, 0x0c, 0xc3, 0x08, 0x8d, 0x46, 0xe9, 0x24, 0x14, 0x2d, 0xd3, 0x61,
0x32, 0xa5, 0x9f, 0xb7, 0x87, 0x16, 0x56, 0x94, 0xd1, 0x48, 0x27, 0xaf, 0xd3, 0x10, 0xd9, 0xc9,
],
ptx: concat!(include_str!("../../ptx-sm86/gr_native_batch.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_full_checks.ptx",
key: [
0x16, 0xcb, 0x9f, 0x01, 0xe5, 0x4b, 0x05, 0x33, 0x43, 0x99, 0x37, 0xdd, 0x09, 0xae, 0xa4, 0xcc,
0xf9, 0x8d, 0xf7, 0x36, 0x76, 0xeb, 0x2b, 0x79, 0x62, 0x98, 0xac, 0x72, 0xe1, 0x27, 0xa5, 0x91,
],
len: 115865,
sha: [
0x70, 0x7a, 0xd0, 0xce, 0x70, 0xa3, 0x2b, 0x33, 0x34, 0x8b, 0x26, 0x48, 0xfd, 0xfe, 0x44, 0xaa,
0xe0, 0xd1, 0xfa, 0x1c, 0x43, 0x0a, 0x97, 0xe7, 0x39, 0x64, 0x2e, 0x4b, 0xc3, 0x38, 0x1e, 0x62,
],
ptx: concat!(include_str!("../../ptx-sm86/mtp_original_full_checks.ptx"), "\0").as_bytes(),
},
Companion {
name: "iq4_nl_q8_1.ptx",
key: [
0x18, 0x9b, 0x02, 0xce, 0xe8, 0x18, 0x63, 0x79, 0xfb, 0x7b, 0x0b, 0xd0, 0x7a, 0x83, 0x1e, 0x1f,
0xb2, 0x76, 0x4d, 0x29, 0xa9, 0x8a, 0x17, 0xfd, 0x2b, 0x51, 0x6c, 0x54, 0x59, 0xf9, 0xd4, 0xce,
],
len: 38554,
sha: [
0xeb, 0x57, 0xbb, 0xff, 0x87, 0x55, 0x63, 0x75, 0xe2, 0xf9, 0x84, 0x95, 0x5b, 0x7d, 0x28, 0x9d,
0xf1, 0xfc, 0xab, 0xf8, 0xca, 0x20, 0x84, 0x88, 0xfa, 0x73, 0xbb, 0x3d, 0xc2, 0xe8, 0x11, 0x76,
],
ptx: concat!(include_str!("../../ptx-sm86/iq4_nl_q8_1.ptx"), "\0").as_bytes(),
},
Companion {
name: "experimental_cvec.ptx",
key: [
0x19, 0x3a, 0xdd, 0x5c, 0xb4, 0x48, 0xf5, 0xe1, 0x93, 0xf2, 0x0f, 0xf2, 0x48, 0xca, 0x44, 0x59,
0xab, 0xb9, 0x62, 0xb4, 0x72, 0x66, 0x3c, 0x00, 0xd1, 0x89, 0x41, 0x31, 0x3b, 0xfa, 0x3e, 0xbc,
],
len: 28943,
sha: [
0x09, 0x43, 0xc5, 0xc0, 0x4e, 0xf8, 0x63, 0x4b, 0x8e, 0xb6, 0x11, 0x33, 0x32, 0x9a, 0xd7, 0x30,
0xf6, 0xbc, 0x39, 0xdc, 0x4e, 0x55, 0xce, 0x9a, 0xc6, 0x25, 0x87, 0x1f, 0xa1, 0x62, 0x58, 0x78,
],
ptx: concat!(include_str!("../../ptx-sm86/experimental_cvec.ptx"), "\0").as_bytes(),
},
Companion {
name: "experimental_keyless.ptx",
key: [
0x1a, 0xb8, 0xb8, 0x15, 0x6e, 0x8c, 0x82, 0x41, 0x31, 0xc0, 0x0c, 0xec, 0xda, 0x17, 0x7f, 0xe5,
0x7d, 0x74, 0xb2, 0x86, 0xa0, 0x2b, 0x7e, 0x5a, 0xfd, 0xfa, 0x39, 0xac, 0xad, 0xaa, 0x33, 0xe6,
],
len: 3760,
sha: [
0x0a, 0x16, 0xc1, 0x19, 0x5e, 0x25, 0x74, 0x7c, 0xb0, 0x7b, 0x18, 0x34, 0xf7, 0xc4, 0x52, 0xb8,
0x91, 0x0c, 0x27, 0xac, 0x2b, 0x7d, 0x30, 0xb9, 0xf6, 0x68, 0x7d, 0x28, 0xcc, 0x76, 0xb8, 0xb9,
],
ptx: concat!(include_str!("../../ptx-sm86/experimental_keyless.ptx"), "\0").as_bytes(),
},
Companion {
name: "qsa_prompt_attention.ptx",
key: [
0x1c, 0x89, 0xe6, 0xcb, 0xc8, 0xbb, 0x52, 0xb4, 0x64, 0x96, 0xa1, 0xca, 0xe3, 0x14, 0x3a, 0x8a,
0xd6, 0xcb, 0x8e, 0x8d, 0xb7, 0x0f, 0x4e, 0x6d, 0x5a, 0x87, 0x4d, 0x59, 0xfd, 0xdd, 0x4a, 0x07,
],
len: 96184,
sha: [
0xf3, 0x2c, 0x26, 0xe3, 0xdf, 0x42, 0xa4, 0xa2, 0xda, 0x00, 0xf2, 0xa9, 0x79, 0x1e, 0x1a, 0xb8,
0x98, 0x41, 0x61, 0xe8, 0x9e, 0x20, 0x3e, 0xdf, 0x88, 0x0a, 0xdc, 0xc8, 0x30, 0xe2, 0x43, 0x5c,
],
ptx: concat!(include_str!("../../ptx-sm86/qsa_prompt_attention.ptx"), "\0").as_bytes(),
},
Companion {
name: "qsa_prompt_select.ptx",
key: [
0x1e, 0x35, 0x51, 0x47, 0x44, 0x21, 0x62, 0x29, 0xb0, 0xcf, 0xfb, 0x4f, 0x45, 0xd2, 0xf1, 0x3f,
0x25, 0xcb, 0x95, 0xf3, 0x77, 0xa3, 0x0c, 0x1c, 0x01, 0x25, 0x43, 0xdb, 0xf5, 0x3a, 0x1c, 0x2d,
],
len: 97179,
sha: [
0x38, 0xef, 0x04, 0x0e, 0xff, 0x7b, 0x93, 0xe2, 0xaf, 0x2c, 0x15, 0x3f, 0xb1, 0xd9, 0x35, 0x24,
0xbd, 0xf1, 0x65, 0x42, 0x8a, 0xa2, 0xf8, 0xcf, 0xbd, 0xa5, 0x08, 0x3e, 0xc4, 0x07, 0x1d, 0xf3,
],
ptx: concat!(include_str!("../../ptx-sm86/qsa_prompt_select.ptx"), "\0").as_bytes(),
},
Companion {
name: "moe_group_iq2_s.ptx",
key: [
0x1e, 0x5c, 0x05, 0x7c, 0xfb, 0x36, 0xd3, 0x51, 0xcc, 0xb2, 0xba, 0x54, 0x6c, 0xf2, 0x95, 0xd1,
0x3b, 0xfa, 0x00, 0x30, 0x65, 0xeb, 0x9b, 0x41, 0x5b, 0xf0, 0xc0, 0x11, 0x8b, 0xd4, 0x80, 0x4a,
],
len: 42048,
sha: [
0xe8, 0xcb, 0x46, 0x20, 0xf1, 0xe2, 0xcf, 0x38, 0xd5, 0x6b, 0x87, 0x55, 0x33, 0xc3, 0x9e, 0x27,
0x95, 0x94, 0x86, 0x2f, 0x77, 0x9e, 0x73, 0x1e, 0x50, 0x1d, 0xed, 0x50, 0xb2, 0xf8, 0xf5, 0x92,
],
ptx: concat!(include_str!("../../ptx-sm86/moe_group_iq2_s.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_full_qsa_gate.ptx",
key: [
0x21, 0xf1, 0xa0, 0x14, 0xbf, 0xa0, 0x59, 0x74, 0x3a, 0x7c, 0x9d, 0x55, 0x3a, 0x46, 0x15, 0xf5,
0x48, 0x82, 0x0b, 0xb4, 0xe7, 0xc4, 0x8f, 0x4e, 0xf1, 0xd7, 0x1f, 0x05, 0x07, 0x7b, 0x4b, 0x25,
],
len: 26053,
sha: [
0xb4, 0x22, 0x8c, 0x01, 0x5b, 0xb0, 0xb0, 0x62, 0x6d, 0x31, 0x40, 0x62, 0x77, 0x20, 0x94, 0x39,
0x0a, 0xd3, 0xba, 0xa6, 0x86, 0x64, 0xd7, 0x29, 0x9b, 0x2a, 0x17, 0x11, 0x80, 0xa4, 0x7c, 0x64,
],
ptx: concat!(include_str!("../../ptx-sm86/mtp_original_full_qsa_gate.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_full_combine.ptx",
key: [
0x22, 0x53, 0xfe, 0x2d, 0x64, 0x13, 0x50, 0xf4, 0x44, 0x5a, 0x0a, 0x69, 0xc4, 0xa0, 0xfc, 0x22,
0xb8, 0x5c, 0x2f, 0xff, 0xca, 0x7c, 0xbd, 0x53, 0x6f, 0xfe, 0x5d, 0x29, 0x12, 0xf8, 0x1f, 0xb7,
],
len: 12958,
sha: [
0x6e, 0x0f, 0xba, 0x41, 0xea, 0x8b, 0x0f, 0xe6, 0x0b, 0x1f, 0xc5, 0x1e, 0xb3, 0xe7, 0x0f, 0x5f,
0xc9, 0xb3, 0x51, 0x63, 0xce, 0xff, 0x1d, 0xb4, 0x36, 0xd6, 0x2e, 0xf6, 0x7e, 0x9a, 0xbd, 0xfe,
],
ptx: concat!(include_str!("../../ptx-sm86/mtp_original_full_combine.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_scalar_gr.ptx",
key: [
0x24, 0x01, 0x60, 0x6b, 0x7e, 0xb4, 0x4a, 0xf8, 0x2a, 0x8b, 0x57, 0x48, 0x48, 0x6c, 0x72, 0xae,
0xc9, 0xc4, 0x7a, 0x4c, 0x7d, 0xb0, 0x6e, 0x5a, 0xbf, 0xd3, 0x7d, 0xb3, 0x75, 0x64, 0x88, 0x6d,
],
len: 387485,
sha: [
0x89, 0xf9, 0xe9, 0x1d, 0xc7, 0xe3, 0x28, 0xa6, 0x7a, 0xd8, 0x7e, 0x02, 0xde, 0xae, 0x1c, 0x7a,
0x25, 0x56, 0xe7, 0x4d, 0x05, 0x98, 0x40, 0xd8, 0xe0, 0x94, 0x2d, 0x8e, 0x85, 0xe2, 0xe5, 0xcb,
],
ptx: concat!(include_str!("../../ptx-sm86/mtp_original_scalar_gr.ptx"), "\0").as_bytes(),
},
Companion {
name: "original_verify_window_moe_experts.ptx",
key: [
0x24, 0xd2, 0x8c, 0xcd, 0x9c, 0x3a, 0x5b, 0xbe, 0xdb, 0xeb, 0x93, 0x3b, 0x4f, 0xeb, 0x37, 0x6f,
0x84, 0x0a, 0x74, 0xe2, 0x1a, 0x44, 0x82, 0x17, 0x48, 0x8c, 0x06, 0xee, 0x23, 0x82, 0x11, 0x57,
],
len: 991906,
sha: [
0xf6, 0xbe, 0xc9, 0xbb, 0x67, 0xe4, 0x5a, 0xa8, 0x40, 0x4f, 0xaa, 0xfd, 0x44, 0xdc, 0x30, 0xb7,
0x90, 0xbf, 0x29, 0x08, 0xf4, 0x5f, 0x0c, 0x7b, 0xb0, 0xef, 0x86, 0xa0, 0x4e, 0xad, 0x97, 0x23,
],
ptx: concat!(include_str!("../../ptx-sm86/original_verify_window_moe_experts.ptx"), "\0").as_bytes(),
},
Companion {
name: "q4_k_q8_1.ptx",
key: [
0x29, 0x4f, 0x3a, 0xd5, 0xfd, 0xdd, 0xf7, 0x96, 0x94, 0x13, 0x46, 0xc9, 0x14, 0x4f, 0xc4, 0x9d,
0x4c, 0xff, 0x54, 0x78, 0xa8, 0x8d, 0xaa, 0xd6, 0xb8, 0x94, 0x1f, 0xbd, 0x4b, 0xb2, 0x40, 0xcb,
],
len: 28282,
sha: [
0x7c, 0xb5, 0xfa, 0x63, 0x73, 0x59, 0x81, 0x41, 0x7d, 0x57, 0x45, 0x76, 0xcf, 0xd8, 0x7e, 0x86,
0x43, 0xcf, 0xea, 0xd8, 0x1b, 0x84, 0x75, 0x44, 0xf9, 0xf1, 0x4c, 0x09, 0x70, 0x2b, 0x3b, 0x60,
],
ptx: concat!(include_str!("../../ptx-sm86/q4_k_q8_1.ptx"), "\0").as_bytes(),
},
Companion {
name: "mmq-original-formats.ptx",
key: [
0x29, 0xd9, 0x2d, 0xea, 0x14, 0x09, 0x95, 0x86, 0xc5, 0x7c, 0x97, 0x0a, 0x36, 0x46, 0xa7, 0x8e,
0x63, 0x1a, 0x49, 0x9a, 0x71, 0x57, 0xd5, 0x6a, 0xa0, 0xe2, 0x0a, 0xc1, 0xe0, 0xb4, 0x01, 0x36,
],
len: 2072448,
sha: [
0xe0, 0x6d, 0xad, 0xbb, 0x57, 0xa9, 0xf0, 0xdc, 0x0b, 0x20, 0xd8, 0xb4, 0x7f, 0xdd, 0x62, 0xa4,
0xc8, 0x46, 0x75, 0xcc, 0xd4, 0x17, 0x0d, 0x42, 0x48, 0x95, 0x6c, 0x09, 0xb4, 0xfb, 0xd2, 0x1e,
],
ptx: concat!(include_str!("../../ptx-sm86/mmq-original-formats.ptx"), "\0").as_bytes(),
},
];
+358
View File
@@ -0,0 +1,358 @@
// @generated shape of scripts/gpu-bringup/sm86_assets.py build: rows 28..54 of the sorted sm_86 table.
use super::Companion;
/// Sorted by `key`; concatenated with the other parts by `super::COMPANIONS`.
#[rustfmt::skip]
pub(super) const ROWS: &[Companion] = &[
Companion {
name: "mtp_original_prefill_fixup.ptx",
key: [
0x29, 0xfd, 0x3f, 0x75, 0x98, 0x64, 0x39, 0x75, 0x7c, 0x3a, 0x6e, 0xb1, 0x7d, 0x93, 0xe3, 0xed,
0x12, 0x4c, 0xc4, 0x18, 0x51, 0x97, 0xa2, 0xb4, 0x45, 0x84, 0x10, 0xd1, 0xe7, 0xf7, 0xec, 0x4b,
],
len: 325813,
sha: [
0x43, 0xa2, 0xa5, 0x24, 0x43, 0xcf, 0x7a, 0x2e, 0x2e, 0xe6, 0x58, 0xf5, 0x93, 0xb0, 0xfe, 0xb3,
0x93, 0x3d, 0xb7, 0x37, 0x93, 0x69, 0xef, 0x19, 0x15, 0xfe, 0x23, 0x99, 0x6a, 0xca, 0xda, 0x84,
],
ptx: concat!(include_str!("../../ptx-sm86/mtp_original_prefill_fixup.ptx"), "\0").as_bytes(),
},
Companion {
name: "iq4_xs_q8_1.ptx",
key: [
0x2c, 0x85, 0x3b, 0xad, 0xe2, 0xbb, 0x62, 0xb6, 0x71, 0x67, 0xb7, 0xcb, 0xe0, 0x03, 0x24, 0x61,
0x6c, 0x72, 0x87, 0xc6, 0x0a, 0xb5, 0xfb, 0x8a, 0x41, 0xd2, 0xb5, 0x69, 0x01, 0x97, 0xf1, 0xb4,
],
len: 62854,
sha: [
0x49, 0xbf, 0x1b, 0x11, 0x6a, 0xd9, 0xa8, 0x42, 0x7d, 0x7b, 0x64, 0x01, 0xae, 0x41, 0x4a, 0x2b,
0xd7, 0x81, 0x3c, 0x74, 0x4d, 0x96, 0x8a, 0x99, 0x26, 0xb9, 0xcc, 0x4a, 0x22, 0x3e, 0x96, 0xd6,
],
ptx: concat!(include_str!("../../ptx-sm86/iq4_xs_q8_1.ptx"), "\0").as_bytes(),
},
Companion {
name: "mmq-fixup-selected.ptx",
key: [
0x32, 0xa0, 0xc8, 0xc5, 0x45, 0x8b, 0xce, 0x5f, 0x2e, 0x07, 0xc7, 0x95, 0x7e, 0x39, 0xaa, 0x97,
0xbe, 0xac, 0x8d, 0x79, 0xbf, 0xad, 0x4a, 0x95, 0x4c, 0x91, 0xdc, 0xe3, 0x97, 0xa4, 0x79, 0x71,
],
len: 183342,
sha: [
0xbd, 0x2a, 0x21, 0xaa, 0x98, 0x59, 0xc3, 0x1d, 0x70, 0x97, 0x9d, 0x89, 0x7c, 0xe7, 0xb7, 0x9c,
0xd4, 0x48, 0x3c, 0xde, 0xd8, 0x0a, 0x3b, 0x11, 0xbc, 0x24, 0x24, 0xdc, 0x13, 0xbc, 0x67, 0x0c,
],
ptx: concat!(include_str!("../../ptx-sm86/mmq-fixup-selected.ptx"), "\0").as_bytes(),
},
Companion {
name: "q8_0_q8_1.ptx",
key: [
0x34, 0x1a, 0xbb, 0xd0, 0x11, 0x39, 0x19, 0xd5, 0x73, 0x24, 0x1b, 0x1d, 0xc4, 0x78, 0x86, 0x51,
0x4e, 0xa7, 0xaa, 0x1d, 0x4d, 0x3f, 0x1a, 0x86, 0x70, 0x24, 0xe7, 0x66, 0x4b, 0x50, 0x1a, 0x0a,
],
len: 21418,
sha: [
0x5b, 0x7e, 0x7d, 0x2c, 0xd3, 0x17, 0xfd, 0x3b, 0x1a, 0x5b, 0xea, 0x40, 0x01, 0x32, 0xf0, 0x38,
0x6b, 0x06, 0x9c, 0xa7, 0xdb, 0x60, 0x97, 0x45, 0x93, 0xe9, 0x02, 0x27, 0x66, 0xb3, 0x95, 0xb2,
],
ptx: concat!(include_str!("../../ptx-sm86/q8_0_q8_1.ptx"), "\0").as_bytes(),
},
Companion {
name: "gr_prompt_device.ptx",
key: [
0x39, 0xc4, 0xea, 0xcc, 0x21, 0x1f, 0xa4, 0x5f, 0xe3, 0x68, 0xee, 0x50, 0x2d, 0x3d, 0x3f, 0xf2,
0x12, 0x41, 0xe6, 0xfe, 0x24, 0xd5, 0xd1, 0x21, 0x1c, 0x6e, 0x18, 0xef, 0x0d, 0x37, 0x28, 0x70,
],
len: 46298,
sha: [
0x1c, 0xcf, 0xf9, 0xa5, 0xce, 0x9f, 0x1a, 0xb7, 0x9c, 0xf8, 0xf5, 0xc8, 0x1d, 0xfd, 0x2a, 0x77,
0x5a, 0xd8, 0x38, 0x11, 0x5c, 0x09, 0x41, 0x4e, 0x0e, 0x1c, 0xdb, 0x3f, 0x34, 0x7f, 0x35, 0x6b,
],
ptx: concat!(include_str!("../../ptx-sm86/gr_prompt_device.ptx"), "\0").as_bytes(),
},
Companion {
name: "s_gemv_legacy.ptx",
key: [
0x3a, 0xb4, 0xd1, 0x2a, 0x5e, 0x97, 0xc4, 0xe2, 0xf4, 0x60, 0x2c, 0x6c, 0x87, 0x23, 0x72, 0xc5,
0xc0, 0x68, 0x5d, 0x8c, 0xf1, 0xa2, 0x02, 0x60, 0xaf, 0x6e, 0x0f, 0x52, 0x05, 0xac, 0x76, 0xd5,
],
len: 303521,
sha: [
0x97, 0x47, 0xc1, 0xbe, 0x0d, 0xb5, 0x20, 0x66, 0xf1, 0xef, 0xe8, 0xef, 0xa9, 0xad, 0xdf, 0x14,
0x23, 0xc5, 0xfd, 0x12, 0xe3, 0x17, 0x47, 0x99, 0xdf, 0x85, 0x3b, 0x0f, 0x71, 0x55, 0x76, 0x55,
],
ptx: concat!(include_str!("../../ptx-sm86/s_gemv_legacy.ptx"), "\0").as_bytes(),
},
Companion {
name: "iq3_native_integer_mma.ptx",
key: [
0x3b, 0xfb, 0x20, 0xc5, 0x31, 0xd0, 0xd5, 0x74, 0xcd, 0xd0, 0x12, 0xda, 0x9f, 0xd0, 0xca, 0xe0,
0x63, 0xf6, 0x16, 0xd1, 0xa0, 0x70, 0xe0, 0x20, 0x17, 0x99, 0xab, 0x11, 0xd7, 0x36, 0x8e, 0x63,
],
len: 17927,
sha: [
0x71, 0x0e, 0xda, 0x43, 0xa5, 0x42, 0x8c, 0x1f, 0xbe, 0xcc, 0xc6, 0x76, 0x82, 0x08, 0x93, 0x98,
0x0e, 0xa3, 0xcf, 0x1d, 0xf1, 0x22, 0x47, 0x17, 0xea, 0x95, 0x19, 0xb2, 0xe1, 0x39, 0xe3, 0x76,
],
ptx: concat!(include_str!("../../ptx-sm86/iq3_native_integer_mma.ptx"), "\0").as_bytes(),
},
Companion {
name: "mmq_original_prefill_misc.ptx",
key: [
0x3e, 0x57, 0x32, 0x6d, 0x0d, 0xd6, 0xae, 0xc8, 0x14, 0x7e, 0x6c, 0xf8, 0x37, 0xce, 0xca, 0x9d,
0x77, 0x9b, 0xa0, 0x6e, 0xa6, 0x7b, 0xf4, 0x31, 0x1b, 0x3c, 0xe0, 0xba, 0xa6, 0xd0, 0x4d, 0x69,
],
len: 5267,
sha: [
0x7f, 0xb7, 0x4e, 0x54, 0xb7, 0xaf, 0x58, 0xdd, 0x65, 0x0d, 0x17, 0xaa, 0xa4, 0x0c, 0xa2, 0x31,
0x57, 0xd7, 0xb9, 0x88, 0x6b, 0xba, 0xf7, 0x0f, 0x8b, 0x71, 0x09, 0xc5, 0xa7, 0xa9, 0x74, 0xf2,
],
ptx: concat!(include_str!("../../ptx-sm86/mmq_original_prefill_misc.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_prefill_mmq.ptx",
key: [
0x3e, 0x67, 0x46, 0x7d, 0x41, 0x2d, 0xbf, 0x18, 0x12, 0x00, 0xd3, 0xca, 0x10, 0xf2, 0xb6, 0x69,
0x95, 0xaf, 0xe3, 0x16, 0xcb, 0xe4, 0x02, 0x60, 0xde, 0xa2, 0x1d, 0x97, 0x31, 0x8b, 0x61, 0xe1,
],
len: 1850087,
sha: [
0x2f, 0xde, 0xe9, 0xf3, 0xc3, 0x06, 0x7e, 0x27, 0x64, 0x30, 0xc6, 0xb6, 0x15, 0x45, 0xb1, 0xf8,
0x59, 0x22, 0x60, 0xd4, 0x62, 0x64, 0x98, 0x89, 0xa8, 0xc9, 0x3b, 0xaa, 0xdf, 0x46, 0x92, 0xaa,
],
ptx: concat!(include_str!("../../ptx-sm86/mtp_original_prefill_mmq.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_full_attention.ptx",
key: [
0x3f, 0xb2, 0x35, 0xca, 0x40, 0x5d, 0x24, 0xc3, 0xb8, 0xd0, 0xec, 0x46, 0x61, 0x1d, 0x9d, 0x64,
0x01, 0x03, 0xb7, 0x1a, 0x65, 0x85, 0x99, 0x23, 0x19, 0x4f, 0x02, 0xf0, 0x6b, 0x48, 0x2f, 0x6c,
],
len: 54452,
sha: [
0xdc, 0x1a, 0xcb, 0x71, 0x2c, 0x99, 0x3b, 0x09, 0xaa, 0x87, 0x86, 0x72, 0x13, 0xd5, 0x23, 0xd8,
0x6d, 0x34, 0x2c, 0x91, 0xe7, 0x33, 0xf2, 0xdb, 0x80, 0x49, 0x7b, 0x85, 0xdc, 0xdd, 0x0b, 0x41,
],
ptx: concat!(include_str!("../../ptx-sm86/mtp_original_full_attention.ptx"), "\0").as_bytes(),
},
Companion {
name: "ple_prompt_device.ptx",
key: [
0x41, 0x2e, 0xd1, 0xdc, 0xcd, 0x1f, 0xc6, 0x2c, 0x5c, 0xf6, 0xc7, 0x50, 0xad, 0x8d, 0x2f, 0x45,
0x20, 0x5f, 0x6d, 0x19, 0xfa, 0xfc, 0x00, 0x23, 0xd6, 0x4a, 0x33, 0xd3, 0x12, 0x95, 0x09, 0x34,
],
len: 19418,
sha: [
0xdb, 0x53, 0x73, 0x24, 0x8a, 0x30, 0x34, 0xea, 0x29, 0xc1, 0xd3, 0x65, 0xae, 0x26, 0x78, 0x5e,
0x4c, 0x46, 0x6f, 0x3d, 0xdc, 0x9b, 0x26, 0x48, 0x43, 0xca, 0x58, 0xaf, 0x47, 0xc9, 0xc2, 0x03,
],
ptx: concat!(include_str!("../../ptx-sm86/ple_prompt_device.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_s2_full_fixed.ptx",
key: [
0x43, 0x81, 0x4a, 0x9c, 0x17, 0x9a, 0xba, 0xba, 0x8f, 0xe0, 0xa8, 0x0b, 0x88, 0xa3, 0x15, 0xbc,
0x94, 0xc4, 0x38, 0xf3, 0x9b, 0x38, 0x42, 0xf4, 0xe4, 0x30, 0x1e, 0x96, 0xa0, 0x32, 0xf7, 0x8d,
],
len: 142044,
sha: [
0x48, 0x41, 0xdf, 0x97, 0x8e, 0x70, 0x2a, 0xd9, 0x1a, 0xdf, 0xd6, 0xb1, 0x7f, 0xd3, 0x1e, 0x53,
0xa4, 0x12, 0x04, 0xf8, 0x0c, 0xbc, 0xa0, 0xdf, 0x2b, 0x6f, 0xad, 0xef, 0xf3, 0x5a, 0x3b, 0x78,
],
ptx: concat!(include_str!("../../ptx-sm86/mtp_s2_full_fixed.ptx"), "\0").as_bytes(),
},
Companion {
name: "experimental_kv_q8.ptx",
key: [
0x43, 0xc3, 0x08, 0x96, 0x08, 0x30, 0x83, 0x3e, 0x29, 0x32, 0x99, 0x07, 0xe2, 0x7b, 0xe5, 0x20,
0x3e, 0xf3, 0xbc, 0x89, 0xcc, 0x7d, 0x0a, 0x91, 0x76, 0x27, 0x0d, 0xc1, 0x87, 0x32, 0xd6, 0x00,
],
len: 32973,
sha: [
0x4b, 0xe6, 0xeb, 0xa3, 0xae, 0x08, 0xf2, 0x12, 0xeb, 0x89, 0x60, 0x7c, 0xea, 0x56, 0x63, 0x8c,
0x10, 0xfa, 0x12, 0xee, 0x40, 0x98, 0x5b, 0xeb, 0xee, 0x99, 0x75, 0x44, 0xae, 0xd7, 0xad, 0xc7,
],
ptx: concat!(include_str!("../../ptx-sm86/experimental_kv_q8.ptx"), "\0").as_bytes(),
},
Companion {
name: "q6_k_q8_1.ptx",
key: [
0x45, 0x40, 0xf6, 0x7f, 0x72, 0xe3, 0xb3, 0x5b, 0xf2, 0x1c, 0xfb, 0xde, 0x0b, 0xfd, 0xf7, 0x85,
0x1e, 0xbe, 0x90, 0xe4, 0x15, 0x40, 0x5c, 0x0c, 0x16, 0x16, 0x6d, 0x09, 0x33, 0xd5, 0x47, 0x97,
],
len: 26986,
sha: [
0x56, 0xb6, 0x06, 0xf4, 0x0b, 0x9a, 0xdd, 0xb9, 0x14, 0xed, 0x01, 0x83, 0x5e, 0x77, 0x87, 0x44,
0x22, 0xca, 0x26, 0xc5, 0xff, 0x32, 0x09, 0x94, 0x3d, 0x1d, 0xe1, 0x22, 0xfc, 0x79, 0x69, 0x58,
],
ptx: concat!(include_str!("../../ptx-sm86/q6_k_q8_1.ptx"), "\0").as_bytes(),
},
Companion {
name: "moe_route_top10.ptx",
key: [
0x48, 0x04, 0xcc, 0xad, 0xee, 0x77, 0xaa, 0xbd, 0xa8, 0x80, 0xfb, 0xc0, 0xa5, 0xb3, 0x4f, 0x10,
0xe8, 0x58, 0x51, 0xc1, 0x69, 0xea, 0xa8, 0x96, 0xf3, 0x31, 0x4b, 0xed, 0x64, 0x78, 0xe2, 0x25,
],
len: 61900,
sha: [
0xe3, 0x29, 0x7c, 0x8c, 0x54, 0x4c, 0xe8, 0x40, 0x15, 0xb5, 0xba, 0x73, 0x45, 0x57, 0xd5, 0x1e,
0xd7, 0x77, 0xed, 0x40, 0x46, 0xf7, 0x4f, 0x09, 0x33, 0x1b, 0x63, 0x56, 0x9e, 0x01, 0xb5, 0x83,
],
ptx: concat!(include_str!("../../ptx-sm86/moe_route_top10.ptx"), "\0").as_bytes(),
},
Companion {
name: "qsa_prompt_postops.ptx",
key: [
0x48, 0x6a, 0x73, 0xb0, 0x6b, 0x3a, 0x34, 0xf2, 0x98, 0xf5, 0x7e, 0x92, 0xc2, 0x0c, 0xc8, 0x39,
0x4d, 0xc5, 0x9d, 0x7b, 0xd8, 0x4b, 0x5c, 0xcc, 0xf8, 0xda, 0x53, 0xaa, 0x50, 0x81, 0xac, 0x9f,
],
len: 21830,
sha: [
0x34, 0x00, 0x50, 0x40, 0x42, 0xb6, 0x9f, 0x98, 0x8b, 0x9a, 0x13, 0x3c, 0x2a, 0xea, 0xf8, 0x67,
0x69, 0xc7, 0xf3, 0x99, 0xfa, 0xaf, 0x94, 0xc6, 0x38, 0x7e, 0xbc, 0x6b, 0x46, 0xd3, 0x5d, 0xa9,
],
ptx: concat!(include_str!("../../ptx-sm86/qsa_prompt_postops.ptx"), "\0").as_bytes(),
},
Companion {
name: "qsa_selected_kv.ptx",
key: [
0x4f, 0x2a, 0xd2, 0x04, 0x10, 0x9b, 0xdd, 0x97, 0x4a, 0x7c, 0x96, 0x5d, 0x08, 0xd9, 0x06, 0x4a,
0xf5, 0x27, 0x56, 0xb1, 0xf6, 0xfc, 0x15, 0x02, 0x7f, 0x47, 0x7d, 0xe2, 0xfd, 0x88, 0x3f, 0x92,
],
len: 3842,
sha: [
0x74, 0x02, 0x25, 0x5f, 0xdb, 0xe1, 0x21, 0xe0, 0x36, 0xaf, 0x74, 0x20, 0x3d, 0xb6, 0x0f, 0x61,
0xd9, 0xe2, 0xe4, 0xe1, 0x08, 0xbf, 0xbe, 0xdf, 0x17, 0xc4, 0xc3, 0x9f, 0xc0, 0x4e, 0xbf, 0x62,
],
ptx: concat!(include_str!("../../ptx-sm86/qsa_selected_kv.ptx"), "\0").as_bytes(),
},
Companion {
name: "experimental_kv_stream.ptx",
key: [
0x4f, 0x71, 0xe7, 0x20, 0xe0, 0xca, 0x95, 0x0d, 0x32, 0x1b, 0xa3, 0xcb, 0xb2, 0x00, 0x82, 0xca,
0x47, 0x3e, 0x98, 0x39, 0xb7, 0x6d, 0x08, 0x89, 0x8e, 0x95, 0xb6, 0x62, 0x3b, 0xff, 0xfe, 0x50,
],
len: 34329,
sha: [
0x9f, 0x99, 0x20, 0x44, 0x70, 0x2d, 0x0c, 0xa2, 0xf8, 0xcc, 0x0b, 0xfd, 0xfd, 0xb7, 0x55, 0x47,
0x59, 0x9f, 0x91, 0x26, 0x15, 0xff, 0xdb, 0x7c, 0xdb, 0x56, 0xcc, 0x06, 0x3c, 0xe8, 0xd6, 0xcf,
],
ptx: concat!(include_str!("../../ptx-sm86/experimental_kv_stream.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_full_coupled.ptx",
key: [
0x55, 0x47, 0x41, 0x61, 0x1c, 0xc0, 0x3e, 0x2c, 0x35, 0xb7, 0xab, 0x1d, 0xfc, 0xa9, 0xc6, 0xd6,
0xc0, 0x1b, 0x37, 0xc1, 0x7d, 0xd4, 0x91, 0x00, 0x0c, 0xcf, 0x0a, 0x23, 0xc3, 0xbb, 0xcb, 0xf9,
],
len: 482063,
sha: [
0xee, 0x6c, 0x57, 0x9d, 0x55, 0x15, 0x6e, 0x90, 0x3a, 0xf6, 0xc1, 0x8e, 0x6a, 0x47, 0x32, 0x95,
0x5f, 0xc1, 0x26, 0xd4, 0x8a, 0x02, 0x86, 0x04, 0xdb, 0x99, 0xa4, 0xcc, 0x2f, 0xcf, 0x4d, 0x80,
],
ptx: concat!(include_str!("../../ptx-sm86/mtp_original_full_coupled.ptx"), "\0").as_bytes(),
},
Companion {
name: "experimental_qsa_attn.ptx",
key: [
0x56, 0x23, 0xa5, 0xae, 0x9b, 0x2e, 0xbd, 0x2f, 0xa0, 0x10, 0xc3, 0x34, 0x36, 0x7f, 0xfc, 0x54,
0x87, 0x9a, 0xc6, 0xdf, 0x76, 0xae, 0xf0, 0x83, 0x81, 0xdb, 0xd3, 0x2b, 0x0f, 0x7e, 0xf3, 0x11,
],
len: 128247,
sha: [
0x2d, 0xe6, 0x09, 0xa4, 0xbf, 0x6e, 0xb8, 0x80, 0xbe, 0x59, 0x4d, 0x47, 0xc0, 0x7f, 0xe4, 0x0a,
0x78, 0xd2, 0x5d, 0x70, 0xc7, 0x4e, 0xcd, 0xa7, 0x95, 0x82, 0xbd, 0x61, 0x21, 0x74, 0x99, 0xe2,
],
ptx: concat!(include_str!("../../ptx-sm86/experimental_qsa_attn.ptx"), "\0").as_bytes(),
},
Companion {
name: "device_poison.ptx",
key: [
0x58, 0x7b, 0x09, 0x7a, 0x20, 0x1a, 0x67, 0x30, 0xe8, 0xfe, 0x55, 0x43, 0x29, 0x19, 0x87, 0xbb,
0xf8, 0x07, 0xda, 0x72, 0xda, 0x12, 0xb8, 0xe0, 0xa1, 0x69, 0xf9, 0xe5, 0xe8, 0xf6, 0xa6, 0x58,
],
len: 870,
sha: [
0xab, 0x97, 0x01, 0x5f, 0xd4, 0x7e, 0x02, 0xe2, 0xbf, 0xde, 0x42, 0x49, 0x25, 0x62, 0xa5, 0x52,
0xef, 0x78, 0xb6, 0x0b, 0x99, 0xf0, 0xf1, 0xf3, 0xbb, 0x43, 0x5a, 0x3c, 0x0c, 0x82, 0x59, 0xa9,
],
ptx: concat!(include_str!("../../ptx-sm86/device_poison.ptx"), "\0").as_bytes(),
},
Companion {
name: "moe_group_iq3_s.ptx",
key: [
0x58, 0xd0, 0x68, 0xff, 0x3a, 0xcc, 0x42, 0x11, 0x61, 0x4f, 0x70, 0xab, 0x04, 0x70, 0x3a, 0x40,
0x85, 0x8e, 0x14, 0x8f, 0x9a, 0xef, 0x85, 0x03, 0xed, 0x66, 0xf7, 0x64, 0x0a, 0xe2, 0xe2, 0xaa,
],
len: 25114,
sha: [
0x36, 0xc2, 0xf6, 0x8c, 0x0d, 0x3a, 0x3c, 0x52, 0x47, 0x87, 0xec, 0xf0, 0x3a, 0x1f, 0x33, 0xe2,
0xda, 0x93, 0x0a, 0x49, 0x17, 0x41, 0x9e, 0xa5, 0x89, 0x3c, 0xca, 0xa2, 0x8c, 0x33, 0xa8, 0x8c,
],
ptx: concat!(include_str!("../../ptx-sm86/moe_group_iq3_s.ptx"), "\0").as_bytes(),
},
Companion {
name: "original_sampler.ptx",
key: [
0x59, 0x1a, 0xa3, 0xdd, 0xa5, 0x2f, 0x41, 0xf0, 0xd1, 0x95, 0x41, 0x6c, 0xf0, 0x93, 0x96, 0x25,
0x68, 0xd2, 0xf8, 0x3d, 0x6f, 0x76, 0x2a, 0x96, 0x78, 0xbe, 0x61, 0x94, 0x6c, 0xec, 0xb7, 0x5b,
],
len: 475837,
sha: [
0x3c, 0xf7, 0xa3, 0x0f, 0x81, 0x6f, 0x9f, 0x27, 0xa2, 0x2f, 0xf8, 0x21, 0x11, 0x7e, 0x9b, 0xff,
0x7c, 0xbc, 0xc3, 0x19, 0x69, 0xac, 0x25, 0x5d, 0x32, 0xb4, 0x0d, 0xdd, 0x4d, 0xda, 0xdc, 0x40,
],
ptx: concat!(include_str!("../../ptx-sm86/original_sampler.ptx"), "\0").as_bytes(),
},
Companion {
name: "mmq-selected.ptx",
key: [
0x5a, 0x56, 0xd8, 0xeb, 0x66, 0xf1, 0xf9, 0x8e, 0x3c, 0xb3, 0xab, 0x75, 0x18, 0x1e, 0x0f, 0x26,
0x3e, 0x4d, 0x51, 0xc4, 0xe7, 0x1e, 0x27, 0xab, 0x2b, 0xc9, 0x9a, 0x1a, 0x3b, 0x7c, 0x01, 0xcb,
],
len: 955352,
sha: [
0xc1, 0x5b, 0x58, 0x0a, 0x9f, 0xdc, 0x85, 0x67, 0x39, 0xfc, 0xa0, 0xa5, 0x68, 0x57, 0xfc, 0x7e,
0x7e, 0xc0, 0x1b, 0x4f, 0x1c, 0x99, 0x3f, 0xfb, 0x2e, 0xde, 0x04, 0x66, 0x01, 0x04, 0x86, 0x28,
],
ptx: concat!(include_str!("../../ptx-sm86/mmq-selected.ptx"), "\0").as_bytes(),
},
Companion {
name: "offline_gdn_prefill.ptx",
key: [
0x5c, 0xc3, 0xa0, 0x28, 0x5d, 0xb9, 0x83, 0xce, 0xbe, 0x9e, 0x35, 0xfa, 0xc2, 0xd5, 0x3e, 0x57,
0x32, 0x68, 0xaf, 0x81, 0x7f, 0x13, 0x1b, 0x23, 0x40, 0xbd, 0x00, 0x3a, 0xe3, 0xe1, 0x64, 0xce,
],
len: 52304,
sha: [
0x12, 0x71, 0xac, 0x05, 0x6e, 0xa0, 0x13, 0x2b, 0xda, 0x7d, 0x11, 0x57, 0x0a, 0x29, 0x6d, 0x00,
0x81, 0x1d, 0x82, 0xe3, 0x90, 0x1d, 0x6c, 0x5d, 0x77, 0x14, 0x77, 0xf8, 0xd9, 0x60, 0x6c, 0x37,
],
ptx: concat!(include_str!("../../ptx-sm86/offline_gdn_prefill.ptx"), "\0").as_bytes(),
},
Companion {
name: "ple_native_batch.ptx",
key: [
0x5f, 0xa5, 0xc9, 0x30, 0xf4, 0x0c, 0xb4, 0x9d, 0x9e, 0x79, 0xa3, 0x5e, 0x19, 0x11, 0xc6, 0x85,
0x81, 0xf9, 0x2c, 0x09, 0x77, 0x50, 0xef, 0xf2, 0x8c, 0x24, 0x5e, 0x28, 0x70, 0x96, 0x4a, 0x40,
],
len: 19699,
sha: [
0xf9, 0xa3, 0x97, 0x01, 0xe2, 0xcc, 0xf0, 0xf6, 0xf7, 0x2d, 0x5e, 0xce, 0x56, 0x6b, 0x78, 0x09,
0x33, 0xea, 0xdd, 0xe6, 0x89, 0xe7, 0xff, 0x50, 0x2a, 0xcf, 0x87, 0xdb, 0x63, 0xf5, 0xd8, 0x5f,
],
ptx: concat!(include_str!("../../ptx-sm86/ple_native_batch.ptx"), "\0").as_bytes(),
},
Companion {
name: "ple_value_full_fixed.ptx",
key: [
0x61, 0x80, 0xf3, 0xde, 0xbc, 0x74, 0x34, 0x9d, 0x62, 0xe2, 0x9c, 0x17, 0xe0, 0x75, 0x17, 0xac,
0x6c, 0x15, 0x1e, 0x71, 0xea, 0xe6, 0x72, 0x97, 0x85, 0x66, 0x49, 0x58, 0x84, 0x23, 0x25, 0xd0,
],
len: 5199,
sha: [
0xbf, 0xcd, 0x7c, 0x88, 0x44, 0x62, 0xc1, 0xe1, 0xe2, 0x8e, 0x3f, 0x73, 0xc7, 0x25, 0x0f, 0xbb,
0xa5, 0x1b, 0xc0, 0xc9, 0x5f, 0x03, 0x7d, 0xba, 0x18, 0x4f, 0x32, 0x24, 0x75, 0x8f, 0xaa, 0x33,
],
ptx: concat!(include_str!("../../ptx-sm86/ple_value_full_fixed.ptx"), "\0").as_bytes(),
},
];
+358
View File
@@ -0,0 +1,358 @@
// @generated shape of scripts/gpu-bringup/sm86_assets.py build: rows 55..81 of the sorted sm_86 table.
use super::Companion;
/// Sorted by `key`; concatenated with the other parts by `super::COMPANIONS`.
#[rustfmt::skip]
pub(super) const ROWS: &[Companion] = &[
Companion {
name: "q5_k_q8_1.ptx",
key: [
0x65, 0xcd, 0x98, 0x13, 0x8e, 0x2a, 0xd9, 0xd1, 0xc2, 0x71, 0x1f, 0xf7, 0xfc, 0x27, 0x28, 0x0f,
0x07, 0xf1, 0xa2, 0x24, 0xfc, 0xdd, 0x2a, 0xbe, 0xea, 0x9b, 0xed, 0xf9, 0xd9, 0xd3, 0xff, 0xfc,
],
len: 33608,
sha: [
0x24, 0x64, 0xea, 0x04, 0x0f, 0xfa, 0x4d, 0xa2, 0x03, 0xe7, 0xde, 0xe9, 0x14, 0x5a, 0x1e, 0xa9,
0x88, 0xdb, 0x90, 0x2d, 0xff, 0xe7, 0xa1, 0x6d, 0x4f, 0x2c, 0xf1, 0x77, 0xcd, 0x7d, 0x32, 0xd6,
],
ptx: concat!(include_str!("../../ptx-sm86/q5_k_q8_1.ptx"), "\0").as_bytes(),
},
Companion {
name: "native_head_iq.ptx",
key: [
0x66, 0xd3, 0xe6, 0x22, 0xee, 0x4f, 0xb8, 0xb6, 0x71, 0x92, 0x8a, 0x73, 0xda, 0xe7, 0x03, 0x85,
0xe4, 0x41, 0x5d, 0xb4, 0x7a, 0xd5, 0x34, 0x2d, 0x5e, 0xb0, 0xd2, 0x50, 0x7b, 0xea, 0xb5, 0xe4,
],
len: 753628,
sha: [
0x90, 0xda, 0x63, 0x69, 0xf0, 0x50, 0x9e, 0x6c, 0xa6, 0x41, 0xb0, 0xa4, 0x7d, 0xce, 0x03, 0x81,
0xe8, 0x8c, 0x27, 0xf0, 0x0e, 0xb4, 0x18, 0x19, 0x82, 0xd9, 0x42, 0x22, 0x16, 0x97, 0x2a, 0x2c,
],
ptx: concat!(include_str!("../../ptx-sm86/native_head_iq.ptx"), "\0").as_bytes(),
},
Companion {
name: "qsa_prompt_device_gate.ptx",
key: [
0x69, 0xf0, 0x3b, 0xe1, 0x7d, 0xb1, 0x7a, 0xba, 0x2f, 0x82, 0x8c, 0xf4, 0x37, 0x91, 0x0a, 0x4d,
0xb6, 0x63, 0x23, 0x97, 0x3d, 0xaa, 0x8b, 0x1a, 0x45, 0x9c, 0x24, 0x18, 0xf9, 0x11, 0x45, 0xd4,
],
len: 2382,
sha: [
0x3b, 0xca, 0x8a, 0x59, 0x4f, 0x37, 0xdd, 0x80, 0xff, 0x12, 0xbd, 0x9b, 0x2c, 0x45, 0x4b, 0x76,
0x68, 0xf2, 0x26, 0x57, 0x1a, 0x2f, 0x2c, 0x5d, 0x33, 0x89, 0xd7, 0xa5, 0xa9, 0x81, 0xba, 0xa7,
],
ptx: concat!(include_str!("../../ptx-sm86/qsa_prompt_device_gate.ptx"), "\0").as_bytes(),
},
Companion {
name: "q6_batch_preview.ptx",
key: [
0x6a, 0x4d, 0x43, 0xe4, 0x1a, 0x45, 0xd9, 0x9f, 0xbb, 0xaa, 0xe3, 0x91, 0x70, 0x38, 0xe2, 0x81,
0xf1, 0x1d, 0x04, 0x37, 0x0e, 0x02, 0x59, 0xea, 0x70, 0x26, 0x81, 0x14, 0x42, 0x96, 0xde, 0x79,
],
len: 28112,
sha: [
0xf5, 0x4e, 0xea, 0xa6, 0xeb, 0x53, 0xa4, 0xd5, 0x02, 0x34, 0x4f, 0x90, 0x8f, 0x97, 0x65, 0xaa,
0xdf, 0x44, 0x53, 0x77, 0xd4, 0x3a, 0x70, 0x53, 0x23, 0x59, 0xfe, 0xe2, 0x33, 0xa0, 0x06, 0x73,
],
ptx: concat!(include_str!("../../ptx-sm86/q6_batch_preview.ptx"), "\0").as_bytes(),
},
Companion {
name: "prefill_stage.ptx",
key: [
0x6f, 0x8f, 0xb3, 0xbb, 0xd1, 0x11, 0x71, 0xc9, 0x39, 0x02, 0x97, 0xd5, 0xd2, 0xc9, 0xcb, 0x90,
0x76, 0xd4, 0xb6, 0x51, 0xf2, 0xa7, 0x04, 0x2b, 0xf1, 0x6f, 0x4c, 0xaf, 0x89, 0xa5, 0xb3, 0x84,
],
len: 161928,
sha: [
0xd8, 0x1a, 0x87, 0x43, 0x7b, 0x72, 0x6b, 0xcf, 0x1a, 0x9d, 0xf0, 0xca, 0x6d, 0x5e, 0xbe, 0xdf,
0x5c, 0x06, 0xda, 0xce, 0xe6, 0x88, 0xbd, 0xc8, 0xfe, 0x91, 0x78, 0x91, 0xcc, 0x0c, 0xda, 0x4b,
],
ptx: concat!(include_str!("../../ptx-sm86/prefill_stage.ptx"), "\0").as_bytes(),
},
Companion {
name: "original_verify_window_pcie_fast.ptx",
key: [
0x74, 0x07, 0x85, 0x9f, 0x8d, 0x88, 0x81, 0x66, 0x3f, 0x3a, 0x64, 0x6e, 0xbe, 0x28, 0x8c, 0x31,
0x13, 0x8c, 0xce, 0x32, 0x27, 0xc1, 0xc5, 0xd9, 0xe2, 0xe5, 0x92, 0x64, 0x8e, 0xd7, 0x7a, 0xea,
],
len: 71051,
sha: [
0x23, 0x48, 0x1b, 0x50, 0xaf, 0x2c, 0x50, 0x1b, 0x04, 0xed, 0xc1, 0xe9, 0xd4, 0xa3, 0x85, 0x35,
0xcf, 0x83, 0x88, 0x46, 0xaa, 0x57, 0xd4, 0x4f, 0x0b, 0xcf, 0x2c, 0x2d, 0xc7, 0xf3, 0xd1, 0xa3,
],
ptx: concat!(include_str!("../../ptx-sm86/original_verify_window_pcie_fast.ptx"), "\0").as_bytes(),
},
Companion {
name: "experimental_kv_q4.ptx",
key: [
0x74, 0x66, 0x5b, 0x01, 0x6f, 0xde, 0x9d, 0xc4, 0xf5, 0x0a, 0x36, 0xe6, 0x2c, 0xbf, 0x2e, 0x57,
0x8c, 0x73, 0x5e, 0x48, 0xe3, 0xbe, 0x51, 0xb7, 0x07, 0x34, 0xe9, 0xe5, 0x39, 0x42, 0xcd, 0xe7,
],
len: 36319,
sha: [
0x36, 0x1d, 0xb3, 0xe8, 0x47, 0x1e, 0x42, 0x77, 0x8a, 0x4b, 0x7d, 0x45, 0x9a, 0xf7, 0x28, 0x9a,
0xa8, 0xe8, 0x01, 0x7b, 0xb3, 0xa7, 0x45, 0x5e, 0x6a, 0xa2, 0xe0, 0x49, 0xb2, 0x2a, 0xd0, 0x93,
],
ptx: concat!(include_str!("../../ptx-sm86/experimental_kv_q4.ptx"), "\0").as_bytes(),
},
Companion {
name: "qwen_qsa_attention_native.ptx",
key: [
0x77, 0x72, 0xe4, 0xe7, 0x5d, 0x78, 0xa9, 0x91, 0x01, 0x44, 0xca, 0x10, 0x85, 0x51, 0x80, 0x0f,
0xd4, 0x29, 0x69, 0x55, 0x78, 0x15, 0x40, 0xaf, 0xb6, 0x5f, 0x53, 0xd6, 0x12, 0xd7, 0xe1, 0xf3,
],
len: 3139,
sha: [
0xda, 0xb3, 0xfd, 0x1c, 0xe3, 0xde, 0x7e, 0xfc, 0x94, 0x1e, 0xcb, 0x26, 0x84, 0x33, 0x6d, 0xea,
0x26, 0xe3, 0x61, 0xd6, 0xc5, 0x0a, 0xbd, 0x45, 0xdc, 0xf2, 0x0f, 0x2e, 0x1e, 0x8f, 0x86, 0xdd,
],
ptx: concat!(include_str!("../../ptx-sm86/qwen_qsa_attention_native.ptx"), "\0").as_bytes(),
},
Companion {
name: "moe_group_iq3_xxs.ptx",
key: [
0x78, 0x82, 0x05, 0x48, 0x65, 0xe5, 0x55, 0x01, 0x0d, 0x4d, 0x60, 0xfc, 0x21, 0xf1, 0xae, 0xbb,
0x97, 0xb1, 0x0d, 0xc0, 0x6a, 0xf1, 0xaf, 0xe3, 0xd0, 0x9f, 0xce, 0x21, 0x96, 0xac, 0x37, 0x67,
],
len: 16161,
sha: [
0xd7, 0x67, 0xad, 0x5a, 0x01, 0x05, 0x0a, 0x8e, 0xc6, 0x8b, 0x73, 0xc3, 0xb5, 0x30, 0x05, 0x09,
0x40, 0x2a, 0x5f, 0x25, 0x14, 0xd6, 0x72, 0xf1, 0x93, 0x01, 0x71, 0xa5, 0xef, 0x98, 0x65, 0xbc,
],
ptx: concat!(include_str!("../../ptx-sm86/moe_group_iq3_xxs.ptx"), "\0").as_bytes(),
},
Companion {
name: "head_greedy.ptx",
key: [
0x78, 0x9f, 0xb7, 0xfc, 0xd5, 0x56, 0x4d, 0xea, 0xac, 0x9e, 0xbd, 0x24, 0x79, 0x7d, 0x3a, 0x15,
0xcd, 0xbb, 0x7c, 0x45, 0xf3, 0x97, 0xa7, 0x72, 0x05, 0x7a, 0x6c, 0x5e, 0xd3, 0xf5, 0x2e, 0xb1,
],
len: 4291,
sha: [
0x00, 0xa5, 0xe1, 0x17, 0x6c, 0xc8, 0x95, 0x28, 0x19, 0x41, 0x5f, 0x62, 0x2b, 0x88, 0x6e, 0xea,
0xc3, 0xd6, 0x7b, 0x1f, 0x2b, 0xd5, 0xa4, 0xf9, 0xc7, 0x2e, 0xde, 0x97, 0x85, 0xdf, 0xd8, 0x6e,
],
ptx: concat!(include_str!("../../ptx-sm86/head_greedy.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_gr_fixed.ptx",
key: [
0x7a, 0xba, 0x70, 0x01, 0x45, 0xb1, 0x9a, 0x09, 0x1d, 0x1c, 0xa2, 0x77, 0x44, 0x62, 0x01, 0xff,
0x47, 0x69, 0xba, 0xa3, 0x66, 0xe7, 0xd5, 0xa0, 0x29, 0x4a, 0x91, 0xe7, 0x6b, 0xa6, 0x09, 0xd4,
],
len: 103348,
sha: [
0xcf, 0xa8, 0x85, 0xcd, 0x69, 0xf9, 0x51, 0xd3, 0x61, 0x67, 0x31, 0x9a, 0xb0, 0x5b, 0x5a, 0x6b,
0xbd, 0xce, 0x95, 0x98, 0xc9, 0x13, 0x3c, 0xd4, 0x30, 0x0d, 0x18, 0xa1, 0x92, 0x8f, 0x24, 0xdd,
],
ptx: concat!(include_str!("../../ptx-sm86/mtp_gr_fixed.ptx"), "\0").as_bytes(),
},
Companion {
name: "gdn_fixed.ptx",
key: [
0x7b, 0x2f, 0x20, 0x3c, 0xe1, 0xb1, 0xb4, 0xc7, 0xe6, 0x3b, 0xb5, 0x6a, 0x1f, 0x7c, 0x35, 0x1a,
0x21, 0x3e, 0x1f, 0x5d, 0xf9, 0x71, 0x1a, 0xd2, 0xd8, 0xdb, 0x30, 0x47, 0xae, 0xad, 0x9e, 0x25,
],
len: 35268,
sha: [
0x09, 0x82, 0x29, 0x8e, 0xa9, 0xf8, 0xe4, 0xbf, 0xa7, 0x0e, 0xef, 0xb1, 0xde, 0xe0, 0xa4, 0x30,
0x73, 0x74, 0x38, 0x9b, 0x3d, 0x60, 0x4d, 0xf5, 0xea, 0x50, 0x7f, 0x35, 0xb5, 0x2f, 0xe4, 0x10,
],
ptx: concat!(include_str!("../../ptx-sm86/gdn_fixed.ptx"), "\0").as_bytes(),
},
Companion {
name: "offline_gdn_fused_t1.ptx",
key: [
0x7b, 0xd0, 0x09, 0x09, 0x27, 0x3c, 0x41, 0x06, 0x55, 0xc3, 0xe1, 0x78, 0x1e, 0x58, 0xd2, 0x1a,
0xe1, 0x54, 0x18, 0x1f, 0xbd, 0x74, 0xc6, 0xb2, 0x11, 0x55, 0x74, 0x8c, 0x97, 0x03, 0x5d, 0xd3,
],
len: 51663,
sha: [
0x5d, 0x2d, 0xa8, 0x20, 0xdb, 0xc9, 0x31, 0x38, 0xe6, 0xa7, 0xce, 0x85, 0x92, 0xc7, 0x1e, 0xc3,
0xd6, 0xa2, 0xb1, 0x0d, 0x57, 0xd1, 0x89, 0xa2, 0xab, 0x50, 0x7d, 0xce, 0x5b, 0x20, 0xd0, 0x1c,
],
ptx: concat!(include_str!("../../ptx-sm86/offline_gdn_fused_t1.ptx"), "\0").as_bytes(),
},
Companion {
name: "qsa_native_decode.ptx",
key: [
0x7c, 0x98, 0xe8, 0xf0, 0x08, 0x92, 0x14, 0x23, 0xe3, 0x05, 0x9f, 0x81, 0xf9, 0xf4, 0xe3, 0x17,
0xeb, 0x40, 0x7d, 0x15, 0xd6, 0xb9, 0x81, 0x5a, 0xe6, 0xda, 0xd7, 0x92, 0x08, 0x83, 0xb0, 0xda,
],
len: 55720,
sha: [
0xde, 0x1e, 0x3c, 0x7a, 0xe0, 0x3c, 0x7e, 0x7f, 0x57, 0x47, 0x2e, 0xbd, 0xe7, 0x58, 0x1f, 0xf0,
0x51, 0x62, 0xb5, 0x45, 0xb1, 0x00, 0x27, 0xf9, 0x6b, 0x2b, 0x36, 0xc4, 0x10, 0xd1, 0xa3, 0x65,
],
ptx: concat!(include_str!("../../ptx-sm86/qsa_native_decode.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_prefill_embedding.ptx",
key: [
0x7e, 0x49, 0xc0, 0x3b, 0x93, 0x3c, 0xdf, 0x6a, 0x4a, 0x79, 0x37, 0x6f, 0xfa, 0x97, 0xf0, 0x61,
0x88, 0x7a, 0x54, 0x92, 0x46, 0x77, 0x43, 0xd0, 0x8e, 0x28, 0x5a, 0x13, 0x95, 0x58, 0x0f, 0xc8,
],
len: 847405,
sha: [
0x2c, 0xe1, 0xd3, 0xe9, 0xaa, 0x97, 0x2f, 0x1f, 0xd0, 0xc1, 0x34, 0x27, 0x21, 0x66, 0xd2, 0x72,
0x22, 0xe9, 0x3b, 0xae, 0x18, 0xda, 0x19, 0xfc, 0x11, 0x97, 0x41, 0x6f, 0x26, 0x4a, 0xe5, 0x54,
],
ptx: concat!(include_str!("../../ptx-sm86/mtp_original_prefill_embedding.ptx"), "\0").as_bytes(),
},
Companion {
name: "native_head_native.ptx",
key: [
0x81, 0xa3, 0x99, 0x0c, 0x14, 0x3e, 0x45, 0x1d, 0xac, 0x79, 0x48, 0x62, 0xcf, 0x73, 0x3f, 0x5f,
0x41, 0x21, 0xf5, 0x2a, 0xa0, 0x70, 0x50, 0xc5, 0x6e, 0x06, 0x1c, 0x17, 0x63, 0xd1, 0x47, 0x9a,
],
len: 7398533,
sha: [
0xe5, 0x44, 0x90, 0xc3, 0x6e, 0x5c, 0xd5, 0xbf, 0x1f, 0x3c, 0x77, 0xc1, 0xaa, 0xf0, 0xdb, 0x21,
0x1c, 0x06, 0x0d, 0x53, 0xfa, 0x93, 0x0a, 0x7a, 0xd0, 0xd4, 0xe9, 0xa5, 0x1c, 0xb9, 0x33, 0x89,
],
ptx: concat!(include_str!("../../ptx-sm86/native_head_native.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_session_native_rope.ptx",
key: [
0x85, 0xb7, 0xef, 0x7c, 0xa5, 0x94, 0x3d, 0xbd, 0x71, 0x07, 0x10, 0x6b, 0x30, 0x29, 0xd5, 0x02,
0x7b, 0x46, 0x44, 0x14, 0x8d, 0x70, 0x05, 0xa4, 0x7d, 0xef, 0x7f, 0xa9, 0x01, 0xa3, 0xd7, 0x0a,
],
len: 10518,
sha: [
0x8e, 0x24, 0xc9, 0xe8, 0x0e, 0xe3, 0x11, 0xc7, 0x82, 0x77, 0x00, 0x77, 0x70, 0x3c, 0x7c, 0x11,
0x2a, 0x16, 0x3b, 0xb1, 0x12, 0x3c, 0x95, 0xb8, 0xc3, 0x12, 0x38, 0x0d, 0xf7, 0x14, 0x03, 0x25,
],
ptx: concat!(include_str!("../../ptx-sm86/mtp_original_session_native_rope.ptx"), "\0").as_bytes(),
},
Companion {
name: "native_head_sampler.ptx",
key: [
0x86, 0x3d, 0xb1, 0x3d, 0xc6, 0x50, 0x23, 0x20, 0x6e, 0xb1, 0xa4, 0x5f, 0x29, 0xd4, 0xb9, 0x90,
0xa6, 0x59, 0x57, 0xba, 0x15, 0xd7, 0x83, 0xc2, 0x32, 0x9b, 0xbd, 0x88, 0xec, 0x61, 0x33, 0x3f,
],
len: 497973,
sha: [
0xe8, 0x64, 0x39, 0x00, 0x9f, 0x42, 0xe6, 0xbf, 0x64, 0xbf, 0xfa, 0xe8, 0x1c, 0xdc, 0x7e, 0xef,
0x69, 0x3f, 0xac, 0x9c, 0x09, 0x32, 0x80, 0x3f, 0xf0, 0x20, 0x8f, 0x85, 0x07, 0x1a, 0x86, 0x49,
],
ptx: concat!(include_str!("../../ptx-sm86/native_head_sampler.ptx"), "\0").as_bytes(),
},
Companion {
name: "mmq_resident_helpers.ptx",
key: [
0x87, 0x0c, 0x6b, 0xc8, 0xa6, 0xec, 0x32, 0x0a, 0x05, 0x9c, 0x50, 0xbe, 0x9d, 0x5c, 0x96, 0x2f,
0xed, 0xec, 0x86, 0x63, 0x4d, 0x98, 0x8f, 0xc0, 0xe6, 0xb9, 0xd7, 0xed, 0xea, 0x11, 0x8d, 0x89,
],
len: 4045,
sha: [
0x66, 0x8f, 0x35, 0x95, 0xce, 0x0d, 0xc7, 0x12, 0x77, 0x2b, 0x80, 0xbd, 0xa3, 0xb8, 0x5b, 0x5f,
0x05, 0xdd, 0x89, 0x23, 0x2a, 0x0a, 0x15, 0x00, 0x46, 0xff, 0x1f, 0xc4, 0xb1, 0x37, 0x90, 0x94,
],
ptx: concat!(include_str!("../../ptx-sm86/mmq_resident_helpers.ptx"), "\0").as_bytes(),
},
Companion {
name: "qsa_prompt_kv.ptx",
key: [
0x87, 0xfd, 0x96, 0x69, 0xca, 0x28, 0x05, 0xe3, 0xaf, 0x3f, 0x97, 0x26, 0xb9, 0xd6, 0x92, 0x66,
0xda, 0xea, 0xc4, 0x17, 0x25, 0x31, 0x6a, 0x38, 0x23, 0x63, 0xc9, 0x56, 0xfd, 0x51, 0x04, 0x65,
],
len: 12143,
sha: [
0xad, 0xce, 0x0f, 0xc9, 0xb8, 0x5a, 0x2f, 0x60, 0x52, 0xcc, 0xd1, 0x13, 0x55, 0xf9, 0x11, 0x8b,
0x88, 0x63, 0x4e, 0x52, 0x31, 0x46, 0xe9, 0xfa, 0x8e, 0x1f, 0x86, 0xf0, 0xe8, 0xdb, 0x5b, 0x6c,
],
ptx: concat!(include_str!("../../ptx-sm86/qsa_prompt_kv.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_full_gr_write.ptx",
key: [
0x88, 0x1e, 0x38, 0xf0, 0xc9, 0x78, 0x6c, 0xed, 0x23, 0x8b, 0x7a, 0x00, 0x14, 0x8a, 0x2e, 0x16,
0xac, 0xff, 0x92, 0x7f, 0x7b, 0x8d, 0xe6, 0x6a, 0x1d, 0xd5, 0x83, 0xab, 0xf8, 0x1c, 0xf5, 0xb1,
],
len: 133910,
sha: [
0x3b, 0xb1, 0x46, 0x0d, 0xe3, 0x5d, 0xa4, 0x42, 0x21, 0x7f, 0xf0, 0x35, 0x38, 0x7c, 0xaf, 0xc5,
0x33, 0x3a, 0x7d, 0x6b, 0x6c, 0x31, 0x16, 0xc5, 0x8a, 0xb3, 0x0a, 0xce, 0xd9, 0x62, 0x0c, 0xd1,
],
ptx: concat!(include_str!("../../ptx-sm86/mtp_original_full_gr_write.ptx"), "\0").as_bytes(),
},
Companion {
name: "qsa_prompt_indexer.ptx",
key: [
0x89, 0x15, 0x70, 0x0d, 0xd8, 0x1c, 0x99, 0x08, 0x3d, 0xe3, 0xcf, 0xf4, 0xed, 0x5d, 0x1a, 0x8b,
0x9a, 0x0c, 0x5d, 0xb1, 0x8c, 0x4d, 0x6d, 0xef, 0x9d, 0x49, 0xb3, 0xbb, 0xc8, 0xf2, 0x82, 0x30,
],
len: 30560,
sha: [
0x51, 0x62, 0x2e, 0x4f, 0x08, 0xa7, 0xe1, 0xfb, 0x52, 0x0f, 0xac, 0x0d, 0x0d, 0x8d, 0x2c, 0x3b,
0x61, 0xdc, 0xa1, 0x22, 0x70, 0x51, 0xaa, 0x14, 0xf6, 0xf7, 0x7d, 0xfc, 0x0a, 0xdf, 0x57, 0xad,
],
ptx: concat!(include_str!("../../ptx-sm86/qsa_prompt_indexer.ptx"), "\0").as_bytes(),
},
Companion {
name: "qsa_prompt_resolver.ptx",
key: [
0x8d, 0x3e, 0xcb, 0xae, 0xcb, 0xf2, 0x84, 0x45, 0xba, 0x64, 0x48, 0x5b, 0xdf, 0xf3, 0xd9, 0x1a,
0x21, 0xd8, 0x7b, 0x85, 0xd5, 0x93, 0x9a, 0x01, 0x52, 0xef, 0x2f, 0x24, 0x14, 0x48, 0x0e, 0x22,
],
len: 23915,
sha: [
0x32, 0xd9, 0x6c, 0xa6, 0xa7, 0x2f, 0x40, 0xed, 0xa2, 0x1d, 0x51, 0xd9, 0xf4, 0xd4, 0xd3, 0x77,
0xc3, 0x73, 0xc6, 0x37, 0x83, 0xcc, 0x42, 0x29, 0x10, 0x88, 0x3b, 0xb8, 0xd8, 0xd8, 0xb0, 0x8d,
],
ptx: concat!(include_str!("../../ptx-sm86/qsa_prompt_resolver.ptx"), "\0").as_bytes(),
},
Companion {
name: "q2_0_q8_1.ptx",
key: [
0x8e, 0x81, 0xdb, 0xba, 0xa7, 0x6d, 0x85, 0x16, 0x47, 0x63, 0x39, 0xc1, 0x68, 0xf1, 0xd9, 0xc1,
0x72, 0x34, 0x1a, 0x78, 0xcc, 0xec, 0xda, 0x08, 0x71, 0x4a, 0x13, 0xa5, 0x68, 0x7e, 0x3b, 0x6e,
],
len: 18542,
sha: [
0x8a, 0x25, 0x1c, 0x65, 0x02, 0x31, 0xac, 0x07, 0xa0, 0xce, 0xa8, 0xdd, 0xa2, 0x12, 0xbb, 0x84,
0xd1, 0xcf, 0x5c, 0xa3, 0x72, 0xf6, 0x30, 0xce, 0x03, 0x23, 0x81, 0xe0, 0x18, 0xce, 0x59, 0xf5,
],
ptx: concat!(include_str!("../../ptx-sm86/q2_0_q8_1.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_full_element.ptx",
key: [
0x8f, 0xdf, 0xdf, 0x8e, 0xf6, 0x16, 0x69, 0x8c, 0x12, 0x30, 0x1f, 0x7d, 0xf4, 0x71, 0x6f, 0xc0,
0x22, 0xbf, 0x34, 0xb4, 0x19, 0x09, 0x9e, 0x4c, 0x97, 0x27, 0x29, 0x92, 0x0b, 0xd5, 0xf4, 0xa7,
],
len: 54956,
sha: [
0xe3, 0xd7, 0x50, 0x63, 0x73, 0xa9, 0x30, 0x1c, 0x4d, 0x0e, 0xbd, 0x40, 0x13, 0x17, 0x2c, 0xce,
0x60, 0x91, 0xfc, 0xd5, 0x87, 0xb2, 0xad, 0xc3, 0x54, 0x1b, 0x6a, 0x55, 0xb9, 0xd5, 0xf1, 0xfd,
],
ptx: concat!(include_str!("../../ptx-sm86/mtp_original_full_element.ptx"), "\0").as_bytes(),
},
Companion {
name: "qsa_prompt_attention_variants.ptx",
key: [
0x90, 0x41, 0xe2, 0x50, 0xf6, 0xff, 0xca, 0x2f, 0x84, 0x9c, 0x20, 0x60, 0x5a, 0x3f, 0x75, 0x8c,
0x54, 0xf7, 0x85, 0x6e, 0x7c, 0xd0, 0x15, 0xc8, 0xa1, 0xda, 0x66, 0x25, 0x04, 0x8d, 0x6a, 0xac,
],
len: 216290,
sha: [
0xa3, 0xe4, 0xd6, 0x97, 0x57, 0x88, 0xd1, 0x26, 0x72, 0xe3, 0x85, 0x5e, 0x5e, 0x9f, 0x16, 0x56,
0x0d, 0x3d, 0x82, 0x63, 0xb7, 0x52, 0x16, 0xaa, 0xf0, 0x89, 0x5c, 0x57, 0x98, 0x70, 0xbb, 0x7d,
],
ptx: concat!(include_str!("../../ptx-sm86/qsa_prompt_attention_variants.ptx"), "\0").as_bytes(),
},
Companion {
name: "qwen_qsa_attention.ptx",
key: [
0x91, 0x21, 0x9c, 0xfb, 0xc1, 0xa7, 0x7c, 0x4b, 0xb6, 0x66, 0x61, 0x06, 0x0a, 0xc9, 0x39, 0xa5,
0x0d, 0xc4, 0xc4, 0xd7, 0xd4, 0xdb, 0x8d, 0x50, 0xbc, 0x59, 0xfb, 0xcd, 0x16, 0x75, 0x62, 0xb2,
],
len: 26737,
sha: [
0xc1, 0x11, 0xc6, 0x12, 0x6a, 0x3a, 0x67, 0x5e, 0xc8, 0x87, 0x20, 0x88, 0x1d, 0x46, 0x99, 0xa6,
0xe7, 0x21, 0x84, 0xd2, 0xf4, 0x55, 0x87, 0x9a, 0xe0, 0x85, 0x5c, 0x56, 0xb8, 0x48, 0xbe, 0xa1,
],
ptx: concat!(include_str!("../../ptx-sm86/qwen_qsa_attention.ptx"), "\0").as_bytes(),
},
];
+358
View File
@@ -0,0 +1,358 @@
// @generated shape of scripts/gpu-bringup/sm86_assets.py build: rows 82..108 of the sorted sm_86 table.
use super::Companion;
/// Sorted by `key`; concatenated with the other parts by `super::COMPANIONS`.
#[rustfmt::skip]
pub(super) const ROWS: &[Companion] = &[
Companion {
name: "moe_group_down_q2_0.ptx",
key: [
0x94, 0x7d, 0x08, 0xc4, 0x10, 0x9a, 0x19, 0x7a, 0xa1, 0xfa, 0xfc, 0xa4, 0xe8, 0xc9, 0x82, 0x3c,
0x91, 0xa8, 0xbd, 0xa0, 0x34, 0xb1, 0x62, 0x79, 0x2c, 0x83, 0x9a, 0x67, 0x97, 0x55, 0x19, 0xda,
],
len: 13458,
sha: [
0xfc, 0x1a, 0xfa, 0x0b, 0x72, 0x43, 0x38, 0xd9, 0x31, 0x48, 0x1f, 0x41, 0x61, 0x6b, 0x8d, 0x25,
0x1f, 0x15, 0x0d, 0x06, 0x5d, 0x91, 0x15, 0x1a, 0x77, 0x12, 0xf9, 0xa9, 0x41, 0xce, 0x25, 0x4f,
],
ptx: concat!(include_str!("../../ptx-sm86/moe_group_down_q2_0.ptx"), "\0").as_bytes(),
},
Companion {
name: "iq3_s_q8_1.ptx",
key: [
0x94, 0xf7, 0x98, 0xc0, 0x08, 0x13, 0xc2, 0xfb, 0x86, 0x0b, 0x4b, 0xf7, 0x7b, 0xe9, 0x22, 0x57,
0x67, 0xd4, 0x08, 0x95, 0x5e, 0x34, 0x21, 0x33, 0x0a, 0xc3, 0x4a, 0x4e, 0xbd, 0x43, 0x97, 0x8f,
],
len: 24712,
sha: [
0xb1, 0x98, 0x60, 0x07, 0x0e, 0x69, 0xdc, 0xcd, 0x5e, 0x98, 0xd1, 0xe6, 0xbc, 0x7c, 0xdd, 0xcd,
0xa2, 0x92, 0x8e, 0xfb, 0xd3, 0xf0, 0xbd, 0x21, 0x56, 0x8f, 0xd1, 0xae, 0x7d, 0x4a, 0xe9, 0x27,
],
ptx: concat!(include_str!("../../ptx-sm86/iq3_s_q8_1.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_full_gr_post.ptx",
key: [
0x9b, 0x47, 0x9c, 0x0f, 0x41, 0x2a, 0xe0, 0x07, 0x73, 0x81, 0x5c, 0x9a, 0x6d, 0x89, 0xd7, 0xf4,
0xc3, 0xf7, 0xa9, 0xf0, 0xf6, 0x91, 0x87, 0x6d, 0xe8, 0x05, 0xeb, 0x38, 0x17, 0x8d, 0x97, 0x90,
],
len: 35821,
sha: [
0x77, 0x93, 0x32, 0x2e, 0x19, 0x00, 0x2f, 0xe8, 0x19, 0x97, 0xbc, 0xab, 0x03, 0xb9, 0xf4, 0xce,
0xd6, 0xce, 0x07, 0x62, 0xde, 0x88, 0x6b, 0xed, 0xe9, 0xbb, 0x11, 0xa9, 0xd3, 0x80, 0xf6, 0x4c,
],
ptx: concat!(include_str!("../../ptx-sm86/mtp_original_full_gr_post.ptx"), "\0").as_bytes(),
},
Companion {
name: "qsa_native_batch.ptx",
key: [
0x9b, 0xa6, 0x85, 0x23, 0xb6, 0x7a, 0x0e, 0x3b, 0x80, 0xfc, 0x16, 0x7b, 0x97, 0x30, 0x19, 0x63,
0xcf, 0x15, 0x98, 0x12, 0xcd, 0x15, 0x7f, 0x03, 0xc5, 0xa0, 0x2b, 0x69, 0xfd, 0xa2, 0x2f, 0xc7,
],
len: 4566,
sha: [
0xcb, 0xf1, 0x3c, 0x31, 0x7b, 0x78, 0x84, 0x54, 0x28, 0xc9, 0x86, 0xe9, 0xa9, 0xbf, 0xc0, 0x47,
0x53, 0x30, 0x29, 0x55, 0x51, 0x3a, 0x4a, 0xfd, 0x11, 0xf1, 0x39, 0xf2, 0x62, 0x22, 0xb6, 0xff,
],
ptx: concat!(include_str!("../../ptx-sm86/qsa_native_batch.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_session_legacy_rope.ptx",
key: [
0x9b, 0xba, 0x3b, 0x35, 0x85, 0x0c, 0xe3, 0x86, 0x9e, 0x32, 0xc5, 0x6c, 0x9d, 0xe6, 0x6a, 0x06,
0x52, 0x69, 0x11, 0x88, 0xf4, 0xc7, 0xff, 0x1d, 0xc4, 0xb1, 0xee, 0x9b, 0x2f, 0x9d, 0x0d, 0x9f,
],
len: 12202,
sha: [
0x25, 0x7e, 0x32, 0x1a, 0xbe, 0xa3, 0x30, 0x92, 0x6b, 0x29, 0x9a, 0x6a, 0x03, 0x03, 0x0d, 0x4c,
0xd2, 0xdf, 0x98, 0xe1, 0xf9, 0x7f, 0xfe, 0x07, 0x2d, 0xc1, 0x83, 0xc1, 0x1c, 0x5b, 0x9d, 0xe7,
],
ptx: concat!(include_str!("../../ptx-sm86/mtp_original_session_legacy_rope.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_full_qnorm.ptx",
key: [
0xa0, 0xbc, 0xfe, 0xbd, 0x6b, 0xf4, 0x77, 0xcd, 0x3a, 0xd1, 0x36, 0x07, 0xe2, 0xf0, 0x1f, 0x3c,
0x0a, 0x9e, 0x4c, 0x70, 0x22, 0x87, 0x21, 0x36, 0x20, 0xd9, 0x1c, 0x89, 0xb9, 0x29, 0x8e, 0xb1,
],
len: 36079,
sha: [
0x0f, 0x71, 0xc4, 0x60, 0xd4, 0x0a, 0x3e, 0xfb, 0xc4, 0x68, 0xba, 0xc3, 0x4b, 0xb9, 0x3f, 0x62,
0xa7, 0x17, 0x37, 0xd7, 0x28, 0x31, 0x92, 0x17, 0x5c, 0xff, 0x7e, 0x13, 0x32, 0x38, 0x20, 0x7f,
],
ptx: concat!(include_str!("../../ptx-sm86/mtp_original_full_qnorm.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_full_bf16.ptx",
key: [
0xa1, 0x6d, 0xfc, 0xfc, 0x9a, 0x49, 0xcc, 0xab, 0x25, 0xd8, 0x03, 0x02, 0x93, 0xd5, 0x82, 0x6f,
0x8f, 0x75, 0xe2, 0x86, 0x8f, 0xae, 0x1b, 0x6c, 0x4c, 0xef, 0x70, 0x6b, 0x6d, 0xfc, 0x3d, 0x08,
],
len: 461120,
sha: [
0x07, 0xf4, 0xde, 0x80, 0xcb, 0xb0, 0xdc, 0x7d, 0xc2, 0xb7, 0x5f, 0x75, 0x6e, 0x24, 0x1b, 0x30,
0x89, 0xd3, 0xcd, 0x97, 0xc7, 0x33, 0x6a, 0xe5, 0xf6, 0xbe, 0x0f, 0xa6, 0x42, 0x78, 0x3d, 0x81,
],
ptx: concat!(include_str!("../../ptx-sm86/mtp_original_full_bf16.ptx"), "\0").as_bytes(),
},
Companion {
name: "iq2_s_q8_1.ptx",
key: [
0xa3, 0x1e, 0x65, 0x3d, 0xa8, 0xc2, 0x22, 0xe1, 0x67, 0x1c, 0xf2, 0x5e, 0xd1, 0x90, 0x17, 0xee,
0xb0, 0xb3, 0xef, 0x4d, 0x89, 0x0c, 0x01, 0x42, 0xb1, 0x81, 0xf3, 0xd5, 0xbc, 0xfc, 0xfb, 0x2c,
],
len: 46912,
sha: [
0xc6, 0xca, 0xe7, 0xc0, 0x39, 0x61, 0x79, 0x04, 0x0b, 0x0c, 0x88, 0xf3, 0xce, 0xbd, 0x24, 0x70,
0xdf, 0x92, 0x69, 0xad, 0x5d, 0xc6, 0x6e, 0x9e, 0x22, 0x7f, 0x60, 0x0d, 0x1e, 0x79, 0xed, 0x9b,
],
ptx: concat!(include_str!("../../ptx-sm86/iq2_s_q8_1.ptx"), "\0").as_bytes(),
},
Companion {
name: "chain_window.ptx",
key: [
0xa3, 0xab, 0xdc, 0x41, 0x86, 0xb6, 0x6d, 0x51, 0xa8, 0x0c, 0x8e, 0xf5, 0x2f, 0x63, 0x6f, 0x18,
0x93, 0xa2, 0x13, 0x6b, 0x88, 0x7c, 0xd6, 0x54, 0x87, 0x86, 0xfe, 0xa2, 0x79, 0xef, 0x71, 0xba,
],
len: 2336938,
sha: [
0x36, 0x1e, 0x11, 0x00, 0xad, 0x58, 0xb9, 0xa2, 0x1b, 0xe3, 0xd9, 0x58, 0xef, 0x55, 0x59, 0xe7,
0x0b, 0x72, 0xf2, 0xd0, 0x4e, 0x15, 0xdb, 0x5e, 0x9d, 0xbc, 0x14, 0xd1, 0x21, 0xe0, 0xee, 0x43,
],
ptx: concat!(include_str!("../../ptx-sm86/chain_window.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_full_router_legacy.ptx",
key: [
0xa5, 0x84, 0x12, 0x24, 0x97, 0x57, 0xcc, 0x35, 0x1e, 0xb8, 0x33, 0x2e, 0x80, 0x7e, 0x79, 0xf1,
0xb3, 0xda, 0x58, 0x65, 0x57, 0x4d, 0x0f, 0xb7, 0x17, 0x9e, 0xf5, 0x58, 0xdf, 0x70, 0xaf, 0x24,
],
len: 159038,
sha: [
0xa9, 0x2b, 0xf0, 0xc3, 0xfc, 0x4c, 0xc5, 0x31, 0x2c, 0x14, 0xa5, 0x52, 0xf7, 0x24, 0x4d, 0x4a,
0x7e, 0x10, 0x26, 0xbb, 0x79, 0x32, 0xb0, 0x56, 0x1d, 0x73, 0x57, 0xd8, 0xec, 0x41, 0x72, 0x7f,
],
ptx: concat!(include_str!("../../ptx-sm86/mtp_original_full_router_legacy.ptx"), "\0").as_bytes(),
},
Companion {
name: "mmq-original-formats-fixup.ptx",
key: [
0xa6, 0x6a, 0x85, 0x6c, 0xe4, 0x97, 0x82, 0x20, 0xbb, 0xb0, 0x12, 0x57, 0xf3, 0x34, 0xe4, 0x48,
0x46, 0xce, 0xb3, 0x4d, 0x5d, 0xc3, 0x06, 0xdf, 0xbe, 0xba, 0x95, 0x65, 0x7e, 0x05, 0x0b, 0xf3,
],
len: 309892,
sha: [
0xd2, 0x16, 0x69, 0x31, 0xf0, 0x54, 0x52, 0xde, 0x65, 0xed, 0x06, 0xd1, 0xb0, 0x60, 0xa9, 0x4c,
0x27, 0xa8, 0x68, 0x8e, 0xf5, 0x9b, 0x5f, 0xfc, 0x96, 0x08, 0x69, 0x64, 0x7a, 0x44, 0x84, 0x8b,
],
ptx: concat!(include_str!("../../ptx-sm86/mmq-original-formats-fixup.ptx"), "\0").as_bytes(),
},
Companion {
name: "mmq_original_group_fixup.ptx",
key: [
0xa8, 0xc7, 0x51, 0x91, 0xba, 0x8e, 0xf7, 0xa4, 0x57, 0x20, 0x82, 0x48, 0x50, 0xd6, 0x4c, 0xf4,
0x43, 0x45, 0x9b, 0x30, 0xbc, 0x53, 0x79, 0xab, 0x80, 0x7e, 0xb8, 0x3e, 0x26, 0x14, 0x88, 0x3f,
],
len: 1455508,
sha: [
0x18, 0xc9, 0x1c, 0x0f, 0x77, 0x48, 0x36, 0xd9, 0xcd, 0xc6, 0xee, 0x49, 0x8f, 0x3f, 0x3d, 0x66,
0x2b, 0x40, 0x07, 0x77, 0x39, 0x95, 0x29, 0xa4, 0x38, 0xf7, 0xae, 0x27, 0x67, 0x10, 0xf2, 0x04,
],
ptx: concat!(include_str!("../../ptx-sm86/mmq_original_group_fixup.ptx"), "\0").as_bytes(),
},
Companion {
name: "mmq_original_group_swiglu.ptx",
key: [
0xa9, 0x13, 0x99, 0x36, 0x00, 0x87, 0x8c, 0xed, 0xd1, 0x28, 0xbe, 0xe0, 0xf7, 0x76, 0x89, 0x51,
0x19, 0xe5, 0x56, 0xe3, 0x3f, 0x2a, 0xd7, 0x0d, 0xad, 0xf0, 0x8e, 0x9e, 0x1a, 0x7e, 0xb9, 0xbd,
],
len: 6090,
sha: [
0x7a, 0x34, 0x2b, 0xa9, 0x78, 0x1d, 0x0f, 0xdb, 0x63, 0x66, 0xc1, 0xb5, 0xbf, 0xd0, 0x65, 0xaa,
0x40, 0x05, 0xfd, 0x3f, 0x3d, 0x19, 0x5d, 0xaf, 0x0f, 0x2f, 0x0f, 0x64, 0x7d, 0x71, 0xe9, 0xec,
],
ptx: concat!(include_str!("../../ptx-sm86/mmq_original_group_swiglu.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_full_fused_gr.ptx",
key: [
0xac, 0x54, 0x00, 0xa7, 0x97, 0x2b, 0x3f, 0x24, 0x26, 0x48, 0xc2, 0xde, 0x71, 0xef, 0x4f, 0x17,
0x84, 0x66, 0xd3, 0x8b, 0x13, 0x92, 0xa8, 0x3a, 0x95, 0x91, 0xb3, 0xb2, 0x4e, 0x92, 0xc5, 0x9b,
],
len: 422848,
sha: [
0xe4, 0xc8, 0xcc, 0xbb, 0xfb, 0x68, 0x26, 0x7c, 0xa0, 0xba, 0xc4, 0xfd, 0xbd, 0x91, 0x04, 0x22,
0xa3, 0x16, 0x87, 0x0b, 0x0f, 0x79, 0x9c, 0x48, 0x52, 0x9c, 0x8a, 0x9d, 0xb9, 0xea, 0xa8, 0xe6,
],
ptx: concat!(include_str!("../../ptx-sm86/mtp_original_full_fused_gr.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_fixed.ptx",
key: [
0xad, 0xa8, 0x7a, 0x1b, 0xd6, 0xff, 0x2f, 0x60, 0x13, 0xd2, 0xbd, 0x64, 0x1a, 0x37, 0x86, 0xeb,
0x46, 0xb9, 0xc9, 0xfc, 0xf3, 0x58, 0x6c, 0x66, 0x60, 0x9c, 0x8e, 0xee, 0xa4, 0xb1, 0x07, 0xe8,
],
len: 15190,
sha: [
0x62, 0xd0, 0x43, 0x0e, 0x9e, 0xaf, 0x35, 0xd2, 0x1b, 0x95, 0xad, 0xc8, 0x18, 0xd5, 0x7b, 0xb8,
0x5e, 0xaf, 0x0a, 0x74, 0x66, 0x06, 0x87, 0x0d, 0xd5, 0xf1, 0xf2, 0xed, 0x25, 0xc1, 0xf7, 0x27,
],
ptx: concat!(include_str!("../../ptx-sm86/mtp_fixed.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_full_head_sampler.ptx",
key: [
0xb0, 0x48, 0xca, 0x90, 0xf9, 0x7e, 0x6e, 0x6f, 0x2c, 0x0d, 0x93, 0xe5, 0xc1, 0x24, 0xe5, 0xd4,
0xad, 0xbc, 0x7b, 0x34, 0x09, 0x74, 0xe4, 0x5a, 0x4f, 0x98, 0xdc, 0x15, 0xd0, 0xb1, 0xbc, 0x59,
],
len: 504479,
sha: [
0xa2, 0x45, 0xc8, 0x5c, 0x87, 0xbd, 0xf2, 0x03, 0x13, 0xbf, 0xf4, 0x22, 0x07, 0xbb, 0xd6, 0xfb,
0xa6, 0xda, 0x14, 0x8a, 0xd3, 0xa0, 0x89, 0x4d, 0x6a, 0x5e, 0xbf, 0xa3, 0x39, 0x8e, 0xca, 0xc7,
],
ptx: concat!(include_str!("../../ptx-sm86/mtp_original_full_head_sampler.ptx"), "\0").as_bytes(),
},
Companion {
name: "ple_fixed.ptx",
key: [
0xb1, 0x4c, 0x64, 0x24, 0xb3, 0x4a, 0x4f, 0xba, 0xc6, 0x8a, 0xe3, 0x33, 0xad, 0xf9, 0x77, 0xe1,
0xa3, 0xff, 0x93, 0xe5, 0x0a, 0xe9, 0x97, 0x52, 0x8b, 0xb9, 0xa2, 0x33, 0xdf, 0xe7, 0x04, 0x86,
],
len: 30868,
sha: [
0x32, 0xbc, 0x7b, 0xc0, 0xcb, 0x88, 0x9b, 0x30, 0xaf, 0xc2, 0x02, 0x88, 0x51, 0x8b, 0x90, 0xa4,
0x13, 0x7a, 0x05, 0xb0, 0x5d, 0xaf, 0x3d, 0x4f, 0xee, 0xde, 0xcc, 0x02, 0xe5, 0x66, 0xce, 0x0a,
],
ptx: concat!(include_str!("../../ptx-sm86/ple_fixed.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_full_shared.ptx",
key: [
0xb3, 0x6f, 0x43, 0x26, 0x92, 0xe4, 0x3f, 0x79, 0x48, 0xa2, 0x53, 0x8c, 0x22, 0xca, 0xb5, 0x5e,
0xf6, 0x7c, 0x62, 0x5b, 0x8d, 0x44, 0x61, 0xc6, 0x7c, 0xa2, 0xa2, 0x75, 0x19, 0xb9, 0xe0, 0xf0,
],
len: 45827,
sha: [
0xe9, 0x22, 0x49, 0x6b, 0x44, 0xdd, 0xb0, 0xde, 0x69, 0x00, 0xb5, 0xbe, 0xec, 0x4b, 0x35, 0x09,
0xf2, 0xfa, 0x7e, 0x2a, 0x17, 0x2c, 0x3f, 0xe1, 0x76, 0xc1, 0x6e, 0xdd, 0x10, 0x18, 0x52, 0x90,
],
ptx: concat!(include_str!("../../ptx-sm86/mtp_original_full_shared.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_scalar_norm.ptx",
key: [
0xbb, 0x78, 0x4f, 0xd8, 0xa5, 0x74, 0xeb, 0x38, 0xcc, 0x3f, 0xdb, 0x92, 0x64, 0xb6, 0x9b, 0x72,
0xcd, 0xf3, 0x40, 0x78, 0x85, 0x91, 0x88, 0x5c, 0x9b, 0x7f, 0x96, 0xa0, 0x5a, 0x6a, 0x81, 0x07,
],
len: 16691,
sha: [
0x56, 0xab, 0x10, 0x69, 0x20, 0x71, 0x2b, 0x92, 0x7c, 0xe8, 0x94, 0xb7, 0x22, 0x7d, 0x7c, 0xb4,
0x7c, 0x7a, 0xda, 0x9f, 0x07, 0x90, 0xc3, 0x65, 0x08, 0xf5, 0xc9, 0x8f, 0x74, 0x0d, 0x7c, 0xdc,
],
ptx: concat!(include_str!("../../ptx-sm86/mtp_original_scalar_norm.ptx"), "\0").as_bytes(),
},
Companion {
name: "native_flash_attn.ptx",
key: [
0xbe, 0x35, 0x3e, 0x61, 0x9a, 0x15, 0xa5, 0x66, 0xe5, 0x7b, 0xae, 0x12, 0xa0, 0xbf, 0x30, 0xcc,
0x17, 0x12, 0xa2, 0x81, 0xbc, 0xe6, 0x92, 0x8f, 0x3b, 0xb7, 0x6c, 0x14, 0xe5, 0x11, 0x4b, 0xba,
],
len: 208590,
sha: [
0x6e, 0xaf, 0xd5, 0x7d, 0x2f, 0xcf, 0x68, 0x71, 0xb8, 0x22, 0x4f, 0xe9, 0x48, 0x52, 0x59, 0xd1,
0xec, 0x75, 0x0f, 0xb1, 0x76, 0xa2, 0x68, 0x96, 0x6b, 0x1d, 0xe4, 0x3f, 0xfa, 0x75, 0x62, 0x97,
],
ptx: concat!(include_str!("../../ptx-sm86/native_flash_attn.ptx"), "\0").as_bytes(),
},
Companion {
name: "quantize-d4-selected.ptx",
key: [
0xbe, 0x3b, 0x9f, 0x55, 0xff, 0x60, 0x69, 0xde, 0x50, 0x52, 0xc8, 0x3e, 0xf2, 0x2d, 0xa8, 0xfe,
0x88, 0xcd, 0x65, 0xe3, 0xe4, 0xfb, 0x1b, 0x13, 0xa7, 0xf9, 0x3d, 0xd1, 0x4f, 0x69, 0x9c, 0x1b,
],
len: 102215,
sha: [
0x15, 0xe3, 0xb0, 0xb1, 0x95, 0x03, 0x41, 0x3b, 0x7f, 0x7d, 0x97, 0x21, 0xaf, 0x05, 0x11, 0xbb,
0x5a, 0xb9, 0xf5, 0xe5, 0x9a, 0x7c, 0xf9, 0x16, 0x77, 0xa3, 0x13, 0xc2, 0x79, 0xc6, 0xa6, 0x9a,
],
ptx: concat!(include_str!("../../ptx-sm86/quantize-d4-selected.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_full_router.ptx",
key: [
0xbe, 0x6e, 0x3c, 0x91, 0xe4, 0xf6, 0x83, 0x14, 0x64, 0xf5, 0x99, 0x37, 0x87, 0xf0, 0xbf, 0xf9,
0x69, 0xbc, 0x5d, 0x28, 0x39, 0x5f, 0x24, 0x22, 0x6b, 0x88, 0x67, 0x6b, 0x30, 0x69, 0xa8, 0xcb,
],
len: 107477,
sha: [
0x17, 0xa9, 0x4f, 0xd3, 0xc2, 0xa1, 0xe2, 0x8c, 0x56, 0xbd, 0x85, 0x10, 0xba, 0xd4, 0xb1, 0xda,
0xa3, 0xdb, 0x39, 0xec, 0x01, 0x36, 0xdb, 0xc0, 0x33, 0x4a, 0x00, 0xfa, 0xad, 0xaf, 0x0c, 0x47,
],
ptx: concat!(include_str!("../../ptx-sm86/mtp_original_full_router.ptx"), "\0").as_bytes(),
},
Companion {
name: "moe_group_iq3_s_nc4.ptx",
key: [
0xbe, 0x6e, 0xe9, 0x07, 0xc0, 0xb3, 0x70, 0xcb, 0x99, 0x89, 0x4a, 0x03, 0x41, 0x94, 0x66, 0xf1,
0xaa, 0x46, 0x5b, 0xa9, 0xb8, 0xe2, 0xe8, 0xcf, 0x60, 0x38, 0x87, 0xf5, 0x34, 0x45, 0x0d, 0x0c,
],
len: 36382,
sha: [
0x23, 0xb7, 0x02, 0xaa, 0xf1, 0x27, 0x8d, 0xd3, 0xd4, 0x36, 0x14, 0x2b, 0x9c, 0x27, 0x32, 0x19,
0x21, 0xf3, 0x6d, 0xda, 0x76, 0x06, 0xd1, 0xf7, 0x56, 0x97, 0x3e, 0x5d, 0xfc, 0xbd, 0x45, 0x37,
],
ptx: concat!(include_str!("../../ptx-sm86/moe_group_iq3_s_nc4.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_full_verify.ptx",
key: [
0xbe, 0xbb, 0xef, 0xc6, 0x5c, 0x2c, 0xc2, 0x1c, 0x54, 0x84, 0x71, 0xf6, 0x90, 0xce, 0x02, 0xc6,
0x73, 0x41, 0x8e, 0x8a, 0xc0, 0x66, 0xd4, 0x9f, 0x94, 0x8d, 0x0e, 0x6e, 0x35, 0xcf, 0xa2, 0x03,
],
len: 179130,
sha: [
0x8e, 0x19, 0x61, 0xf3, 0x6f, 0x40, 0x9d, 0xea, 0x38, 0x60, 0x66, 0x6b, 0xc8, 0xd7, 0x67, 0x95,
0x1c, 0x50, 0xbb, 0xac, 0x96, 0x36, 0x6a, 0x9e, 0xc5, 0xd9, 0x9d, 0x87, 0xbe, 0xc4, 0xe9, 0x30,
],
ptx: concat!(include_str!("../../ptx-sm86/mtp_original_full_verify.ptx"), "\0").as_bytes(),
},
Companion {
name: "gr_batch_preview.ptx",
key: [
0xc8, 0x56, 0xb6, 0xf5, 0x2d, 0x41, 0xd7, 0xe8, 0xf8, 0x8d, 0x7c, 0x63, 0xed, 0x68, 0x3b, 0x94,
0x73, 0x10, 0x08, 0x87, 0x10, 0xf6, 0x62, 0xbc, 0xad, 0x0a, 0xfc, 0xed, 0x3e, 0xf6, 0x5c, 0xac,
],
len: 24666,
sha: [
0x8b, 0x51, 0xd3, 0x67, 0x3b, 0xce, 0x01, 0x8b, 0x58, 0x7e, 0xa8, 0x1c, 0x5a, 0xb2, 0xe9, 0xd7,
0xdd, 0x4d, 0x75, 0xd0, 0x01, 0x4f, 0x6c, 0xfd, 0x4f, 0x7c, 0xf5, 0xfc, 0x17, 0xcd, 0x4c, 0xb3,
],
ptx: concat!(include_str!("../../ptx-sm86/gr_batch_preview.ptx"), "\0").as_bytes(),
},
Companion {
name: "moe_group_iq4_xs.ptx",
key: [
0xc8, 0x88, 0x0e, 0xf0, 0x8d, 0xcc, 0x6b, 0xfa, 0x4a, 0xcc, 0xc9, 0x89, 0x87, 0xc4, 0x5c, 0x64,
0x1e, 0x47, 0x2c, 0x52, 0x06, 0xad, 0x9d, 0x38, 0x9f, 0x5e, 0x94, 0x38, 0x5c, 0xd8, 0xc9, 0x84,
],
len: 63256,
sha: [
0x72, 0x2e, 0xff, 0xee, 0x93, 0x55, 0xd3, 0xe1, 0x39, 0x73, 0xd8, 0xec, 0x9e, 0x77, 0xde, 0x98,
0xfe, 0xc0, 0xfd, 0x4a, 0x97, 0xea, 0xfe, 0xbb, 0x55, 0x0c, 0xf9, 0xdd, 0xfd, 0x55, 0xc0, 0x2b,
],
ptx: concat!(include_str!("../../ptx-sm86/moe_group_iq4_xs.ptx"), "\0").as_bytes(),
},
Companion {
name: "original_verify_window_pcie.ptx",
key: [
0xcb, 0xeb, 0x32, 0x3f, 0x76, 0x47, 0x68, 0x2f, 0xee, 0x9e, 0xd3, 0xf1, 0x2f, 0xb7, 0xb7, 0xa5,
0xb3, 0xeb, 0x19, 0x2f, 0x21, 0x66, 0xc6, 0xec, 0x96, 0xb8, 0x1d, 0x55, 0xc3, 0xba, 0xb9, 0xd1,
],
len: 7687,
sha: [
0x98, 0x5b, 0xbf, 0xc8, 0x77, 0x91, 0xbd, 0x96, 0xa2, 0xcf, 0x61, 0x32, 0xce, 0x7e, 0x49, 0x9b,
0x90, 0xeb, 0xfe, 0x7a, 0x31, 0x0e, 0xe1, 0xc5, 0x78, 0x1c, 0x49, 0xaf, 0xd1, 0x96, 0x4f, 0x67,
],
ptx: concat!(include_str!("../../ptx-sm86/original_verify_window_pcie.ptx"), "\0").as_bytes(),
},
];
+306
View File
@@ -0,0 +1,306 @@
// @generated shape of scripts/gpu-bringup/sm86_assets.py build: rows 109..131 of the sorted sm_86 table.
use super::Companion;
/// Sorted by `key`; concatenated with the other parts by `super::COMPANIONS`.
#[rustfmt::skip]
pub(super) const ROWS: &[Companion] = &[
Companion {
name: "original_verify.ptx",
key: [
0xd0, 0xda, 0xda, 0x67, 0x15, 0xfb, 0x80, 0x8b, 0xb3, 0x28, 0x82, 0x91, 0xfd, 0x4a, 0x5c, 0x29,
0xe7, 0x8f, 0xd7, 0xfa, 0x6e, 0x70, 0xf2, 0xb9, 0x4d, 0x22, 0x0f, 0x86, 0x0b, 0xb4, 0x33, 0x53,
],
len: 154200,
sha: [
0xba, 0x92, 0xfe, 0x4e, 0x9b, 0x5a, 0xe0, 0x48, 0x86, 0x4a, 0x1c, 0xcb, 0xa8, 0x64, 0x50, 0x22,
0x4a, 0x07, 0x83, 0x67, 0x2c, 0x0c, 0x2b, 0x99, 0xe4, 0xec, 0x32, 0x02, 0xe1, 0x66, 0x03, 0x55,
],
ptx: concat!(include_str!("../../ptx-sm86/original_verify.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_full_quant80.ptx",
key: [
0xd1, 0xae, 0x17, 0xce, 0xcc, 0x24, 0xe2, 0x4e, 0x0e, 0x1f, 0xc9, 0x5a, 0x73, 0x52, 0x79, 0x89,
0x71, 0x9b, 0x94, 0x5d, 0xfe, 0xed, 0x68, 0x9e, 0x80, 0x67, 0xa5, 0x8f, 0x10, 0x18, 0x11, 0x90,
],
len: 96194,
sha: [
0x33, 0x98, 0x0b, 0x2a, 0xd2, 0x18, 0xeb, 0x46, 0xb6, 0x4c, 0x3f, 0xf0, 0xf2, 0xe7, 0x3e, 0xba,
0x2d, 0xde, 0x43, 0xed, 0xa7, 0xbf, 0x12, 0x8c, 0x62, 0xc4, 0x08, 0xad, 0xe0, 0x2b, 0xbd, 0x83,
],
ptx: concat!(include_str!("../../ptx-sm86/mtp_original_full_quant80.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_prefill_quant.ptx",
key: [
0xd5, 0xa6, 0x7b, 0x91, 0xe2, 0xbd, 0x30, 0x8b, 0x6c, 0x5b, 0x3c, 0xf3, 0x80, 0xf4, 0xb1, 0x40,
0x00, 0x43, 0x28, 0xbd, 0x26, 0x4c, 0x98, 0x83, 0x70, 0xb7, 0x14, 0x37, 0xf9, 0x6b, 0x86, 0x4c,
],
len: 217573,
sha: [
0xcb, 0xa7, 0x20, 0xbb, 0x6b, 0xfb, 0x98, 0x41, 0xfa, 0xc5, 0x71, 0x6f, 0x84, 0x88, 0x6c, 0x94,
0x7f, 0x36, 0xf4, 0xf0, 0x21, 0x0d, 0xe9, 0x10, 0xd3, 0x99, 0x5c, 0x1d, 0x8e, 0x62, 0x0d, 0xd7,
],
ptx: concat!(include_str!("../../ptx-sm86/mtp_original_prefill_quant.ptx"), "\0").as_bytes(),
},
Companion {
name: "qwen_qsa_native.ptx",
key: [
0xd6, 0x04, 0x89, 0xfb, 0x70, 0xce, 0x43, 0x70, 0x04, 0x7b, 0xf5, 0x4f, 0xae, 0x8d, 0xd4, 0x6d,
0xfb, 0x53, 0xbb, 0x73, 0xb1, 0x61, 0x8c, 0x58, 0x94, 0x29, 0x32, 0xa7, 0x89, 0xd0, 0x64, 0xc5,
],
len: 31598,
sha: [
0x91, 0x8c, 0x74, 0x1a, 0xb3, 0xde, 0x0c, 0x8e, 0x3a, 0x4d, 0xb0, 0xf4, 0x54, 0xbc, 0xfc, 0x73,
0x9b, 0x9b, 0xad, 0xcd, 0x58, 0xdd, 0x04, 0x7c, 0xc5, 0xfd, 0x87, 0x2e, 0x99, 0xc0, 0x1e, 0xf0,
],
ptx: concat!(include_str!("../../ptx-sm86/qwen_qsa_native.ptx"), "\0").as_bytes(),
},
Companion {
name: "gr_fixed.ptx",
key: [
0xde, 0xaa, 0x95, 0xe6, 0x1d, 0x25, 0xff, 0x87, 0xfd, 0x53, 0x1b, 0x62, 0xd5, 0xc2, 0x93, 0x09,
0xb6, 0x9a, 0x37, 0x71, 0x18, 0x20, 0x4e, 0xef, 0xae, 0xe3, 0x10, 0xaf, 0x4e, 0xcf, 0xfa, 0x8b,
],
len: 22704,
sha: [
0x89, 0x18, 0x62, 0xf3, 0xd1, 0x04, 0x0d, 0x14, 0xbf, 0xd3, 0x8f, 0xf0, 0x0e, 0x19, 0xea, 0x42,
0xf4, 0xc6, 0x30, 0xdd, 0xcc, 0xfd, 0xa1, 0x69, 0x9f, 0xf5, 0xc6, 0x8f, 0xa1, 0x26, 0xd9, 0x66,
],
ptx: concat!(include_str!("../../ptx-sm86/gr_fixed.ptx"), "\0").as_bytes(),
},
Companion {
name: "qwen_qsa_select.ptx",
key: [
0xe0, 0x94, 0xe1, 0x0f, 0x84, 0xcc, 0xa6, 0x12, 0xca, 0x28, 0x59, 0x6a, 0xa3, 0x94, 0xee, 0x99,
0x9e, 0x33, 0xfe, 0x7b, 0xc8, 0x4b, 0x35, 0x9b, 0xfa, 0xb6, 0xda, 0x07, 0x30, 0xd4, 0xa5, 0x19,
],
len: 41468,
sha: [
0xe8, 0xad, 0xf4, 0x5c, 0x34, 0x90, 0x8f, 0xa7, 0xf1, 0x58, 0x3d, 0x1d, 0xa0, 0xc5, 0x83, 0x04,
0xfa, 0x02, 0x29, 0xbc, 0x2e, 0x37, 0x43, 0xc2, 0xaa, 0x30, 0x58, 0xf9, 0xe2, 0x6f, 0xf2, 0x7b,
],
ptx: concat!(include_str!("../../ptx-sm86/qwen_qsa_select.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_kv.ptx",
key: [
0xe0, 0xc1, 0xff, 0x10, 0xd3, 0xd4, 0xbc, 0xf8, 0xfd, 0x33, 0x69, 0x71, 0x30, 0x79, 0xb2, 0x32,
0xe6, 0x2c, 0xdb, 0x2c, 0x3a, 0x34, 0x5f, 0xae, 0xc4, 0x9d, 0x1e, 0x66, 0x76, 0x3f, 0x91, 0x1f,
],
len: 16734,
sha: [
0xb9, 0x61, 0xa6, 0xbc, 0xaf, 0x30, 0x9b, 0xca, 0x67, 0xab, 0xf6, 0xc3, 0x7b, 0x8e, 0x30, 0x3b,
0x16, 0x5f, 0xcd, 0x8f, 0x51, 0xc6, 0x8f, 0x63, 0x11, 0xc5, 0xa0, 0xe1, 0x3f, 0x86, 0x1f, 0x8b,
],
ptx: concat!(include_str!("../../ptx-sm86/mtp_original_kv.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_attention_fixed.ptx",
key: [
0xe1, 0x1a, 0xc4, 0xde, 0x66, 0xc9, 0x9c, 0x31, 0xec, 0x95, 0x37, 0x27, 0xbd, 0xac, 0x91, 0xca,
0xc9, 0x7d, 0x58, 0xd8, 0x2a, 0x3d, 0xcb, 0xe0, 0x6e, 0xf4, 0xc6, 0xe8, 0xdc, 0x2a, 0x4c, 0x66,
],
len: 75847,
sha: [
0xa0, 0x5c, 0xff, 0x97, 0xbd, 0x7e, 0x4e, 0x0a, 0xc9, 0x24, 0xad, 0xb9, 0xf0, 0x1f, 0x7b, 0x6c,
0xa8, 0xe9, 0x67, 0x11, 0x3f, 0x84, 0xa1, 0x68, 0x7e, 0x09, 0x76, 0xb5, 0x64, 0x13, 0xa8, 0x37,
],
ptx: concat!(include_str!("../../ptx-sm86/mtp_attention_fixed.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_full_head_iq.ptx",
key: [
0xe5, 0x74, 0x52, 0xcc, 0xac, 0x77, 0x2a, 0x8a, 0x8a, 0x77, 0x25, 0x3b, 0xc6, 0xc9, 0x64, 0xeb,
0xb7, 0xbc, 0x61, 0xfd, 0xb2, 0xe9, 0x75, 0x27, 0xa9, 0x77, 0x5f, 0x8c, 0xcf, 0x3c, 0x3b, 0x9f,
],
len: 792488,
sha: [
0xea, 0x98, 0x3e, 0x2b, 0x8f, 0xce, 0xae, 0xbb, 0xa0, 0xad, 0xdb, 0x29, 0x62, 0x84, 0xa1, 0xf2,
0xfa, 0x54, 0x6e, 0x26, 0x04, 0xfe, 0x8d, 0x6a, 0x10, 0x17, 0x02, 0x9a, 0xaf, 0x7e, 0x18, 0xae,
],
ptx: concat!(include_str!("../../ptx-sm86/mtp_original_full_head_iq.ptx"), "\0").as_bytes(),
},
Companion {
name: "mmq-adaptive-fixup.ptx",
key: [
0xe8, 0x14, 0xd7, 0x50, 0x21, 0xa7, 0x3c, 0x38, 0x31, 0x02, 0x3d, 0x29, 0x81, 0x84, 0x72, 0x23,
0x2d, 0xb4, 0x47, 0x29, 0x21, 0x3d, 0xf1, 0x0d, 0x60, 0xc4, 0x78, 0x63, 0xaa, 0x47, 0x72, 0x78,
],
len: 445570,
sha: [
0xa5, 0x0b, 0x8a, 0x99, 0x40, 0x09, 0xa3, 0xc6, 0x0e, 0xd8, 0x29, 0xaa, 0x45, 0xf7, 0xb1, 0x71,
0x23, 0x40, 0x12, 0x95, 0xbd, 0xaa, 0x4e, 0x03, 0xe8, 0x71, 0xb4, 0x39, 0x3c, 0x2a, 0xf9, 0x1c,
],
ptx: concat!(include_str!("../../ptx-sm86/mmq-adaptive-fixup.ptx"), "\0").as_bytes(),
},
Companion {
name: "mmq_original_group_mul.ptx",
key: [
0xea, 0x0d, 0xb7, 0x85, 0x05, 0x28, 0x9e, 0x8e, 0x74, 0x3a, 0x55, 0x2e, 0xf2, 0x3d, 0xed, 0x98,
0xd6, 0x68, 0xa4, 0x89, 0xc6, 0x79, 0xa0, 0xe4, 0x48, 0x93, 0xb0, 0x00, 0x44, 0x5b, 0x48, 0xc7,
],
len: 13083403,
sha: [
0x8a, 0x80, 0x90, 0xb4, 0x00, 0xf4, 0x08, 0x8f, 0x3d, 0x45, 0x0a, 0x70, 0xca, 0x0f, 0x83, 0x60,
0x8f, 0xfe, 0x44, 0x73, 0xf4, 0x49, 0xd7, 0x9c, 0x69, 0xf8, 0x8c, 0x7c, 0x12, 0x2a, 0x26, 0x4a,
],
ptx: concat!(include_str!("../../ptx-sm86/mmq_original_group_mul.ptx"), "\0").as_bytes(),
},
Companion {
name: "mmq_native_resident_d4.ptx",
key: [
0xea, 0x33, 0xd3, 0xd1, 0xdb, 0xc3, 0xc6, 0x39, 0x81, 0x55, 0xef, 0xa1, 0x92, 0xb5, 0xbb, 0x4d,
0x5a, 0x25, 0xf7, 0x3f, 0x6e, 0x8a, 0xf6, 0x5f, 0x2d, 0xdc, 0x1b, 0x91, 0x95, 0xbb, 0x3e, 0xeb,
],
len: 5199,
sha: [
0x95, 0x4e, 0x26, 0x5c, 0x1d, 0x6a, 0x60, 0x53, 0x6c, 0x93, 0x6d, 0x3e, 0x01, 0x24, 0x02, 0x13,
0xc5, 0x0d, 0xf2, 0xae, 0xc8, 0x8c, 0x5f, 0x42, 0x88, 0xa5, 0xd5, 0xf6, 0xe3, 0xb7, 0xc1, 0x14,
],
ptx: concat!(include_str!("../../ptx-sm86/mmq_native_resident_d4.ptx"), "\0").as_bytes(),
},
Companion {
name: "moe_fixed.ptx",
key: [
0xeb, 0x25, 0xf4, 0x5f, 0x2b, 0xf1, 0xcd, 0x3b, 0xe5, 0x7e, 0x0b, 0x5f, 0x32, 0x6a, 0x63, 0xf6,
0x66, 0x05, 0x9a, 0x58, 0x70, 0x6d, 0x7a, 0x2b, 0xd4, 0x70, 0x52, 0x6c, 0x22, 0xc0, 0xf6, 0x7a,
],
len: 24983,
sha: [
0x67, 0x25, 0x8f, 0xde, 0x60, 0xe2, 0xe5, 0xd0, 0xe5, 0x0b, 0xe8, 0xcb, 0xd6, 0x3b, 0x0d, 0xe4,
0x2e, 0x33, 0xf7, 0x22, 0xb1, 0x61, 0x40, 0xe1, 0xb0, 0x71, 0x85, 0x7b, 0x47, 0xaa, 0xa8, 0xbe,
],
ptx: concat!(include_str!("../../ptx-sm86/moe_fixed.ptx"), "\0").as_bytes(),
},
Companion {
name: "qsa_late.ptx",
key: [
0xeb, 0xc8, 0xbc, 0x0a, 0xac, 0x1b, 0xd4, 0xa7, 0x45, 0x40, 0xed, 0x24, 0x6c, 0x00, 0x96, 0x0d,
0x10, 0x15, 0x96, 0x30, 0x20, 0x11, 0x33, 0xe6, 0xd2, 0x1f, 0x30, 0x6e, 0xfe, 0xb1, 0xba, 0x2f,
],
len: 213285,
sha: [
0x11, 0x8d, 0x23, 0x00, 0xe6, 0x7d, 0x15, 0x42, 0x0b, 0x7e, 0xbd, 0xb4, 0xee, 0x82, 0x3d, 0x91,
0xbe, 0x58, 0x55, 0x62, 0x07, 0x23, 0x85, 0x3f, 0xe9, 0xda, 0x8d, 0xef, 0x8a, 0xe5, 0xe9, 0x8b,
],
ptx: concat!(include_str!("../../ptx-sm86/qsa_late.ptx"), "\0").as_bytes(),
},
Companion {
name: "kar_decode_levels.ptx",
key: [
0xec, 0x69, 0x77, 0x87, 0xe0, 0x00, 0x53, 0x10, 0x00, 0x5e, 0xb1, 0x69, 0xa7, 0x58, 0x31, 0x5e,
0xb5, 0x50, 0x3a, 0xc7, 0x67, 0x1a, 0x38, 0x49, 0x5e, 0xea, 0xea, 0xf4, 0xfb, 0x2a, 0x8e, 0xc9,
],
len: 18428,
sha: [
0xb9, 0x41, 0xaf, 0xb1, 0x17, 0xd7, 0x7a, 0x57, 0x32, 0xc1, 0x66, 0x6a, 0x25, 0x29, 0x1a, 0xb9,
0xbf, 0xd6, 0x17, 0x25, 0x28, 0xbd, 0x6b, 0x52, 0x7c, 0x37, 0x39, 0x7f, 0x24, 0xfd, 0x77, 0xc4,
],
ptx: concat!(include_str!("../../ptx-sm86/kar_decode_levels.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_prefill.ptx",
key: [
0xf0, 0xa0, 0x67, 0x3d, 0x72, 0xe2, 0xaf, 0x9b, 0xaa, 0x48, 0x14, 0x64, 0xbd, 0x2f, 0x07, 0x04,
0x2a, 0x66, 0x98, 0xd4, 0x64, 0x13, 0xfe, 0x6a, 0x85, 0x4c, 0xc8, 0x30, 0x1d, 0xba, 0x67, 0x5a,
],
len: 68280,
sha: [
0xc3, 0xba, 0x39, 0xe3, 0xc2, 0xbe, 0x4e, 0xfb, 0x0a, 0xca, 0x00, 0x19, 0xe2, 0xaa, 0xe7, 0x47,
0xff, 0x00, 0x1d, 0x13, 0x63, 0x10, 0x16, 0xe5, 0xcc, 0x9f, 0xef, 0x86, 0x7e, 0x9a, 0xc1, 0xaf,
],
ptx: concat!(include_str!("../../ptx-sm86/mtp_original_prefill.ptx"), "\0").as_bytes(),
},
Companion {
name: "original_verify_qsa.ptx",
key: [
0xf5, 0x7b, 0x41, 0x82, 0xe2, 0x19, 0x2b, 0xe7, 0xf5, 0xd3, 0x19, 0xe7, 0xa5, 0xe0, 0x2f, 0xaa,
0x5f, 0xc2, 0x45, 0xc0, 0x61, 0x42, 0x6c, 0xd2, 0xbf, 0xc1, 0x39, 0xcf, 0x45, 0x3a, 0xdc, 0x05,
],
len: 19585,
sha: [
0x22, 0xd6, 0x9a, 0x56, 0xf3, 0x88, 0xc1, 0xb3, 0x83, 0xc7, 0xb1, 0x25, 0xeb, 0x11, 0xcb, 0x36,
0xb5, 0xb0, 0xe8, 0x02, 0x6e, 0x95, 0x7b, 0x87, 0xad, 0x06, 0xce, 0x07, 0xc8, 0x02, 0x52, 0x40,
],
ptx: concat!(include_str!("../../ptx-sm86/original_verify_qsa.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_full_head_native.ptx",
key: [
0xf8, 0x20, 0x9e, 0x1c, 0x9f, 0xbf, 0x97, 0x8b, 0xc5, 0x7b, 0x60, 0xb0, 0xb5, 0xf6, 0xed, 0xca,
0xb1, 0x90, 0x5e, 0x49, 0xa4, 0xab, 0x3a, 0xa9, 0x82, 0x60, 0x4e, 0x3e, 0x68, 0x0f, 0xa4, 0x37,
],
len: 7459176,
sha: [
0x6b, 0x0a, 0x23, 0x33, 0x72, 0xb7, 0x51, 0x3f, 0x8c, 0x6e, 0xef, 0xd7, 0xaa, 0x7e, 0x66, 0x34,
0x99, 0xb7, 0xe2, 0x38, 0x6c, 0xd8, 0x7c, 0x82, 0x73, 0xde, 0x22, 0xd7, 0x26, 0xa9, 0x84, 0xe5,
],
ptx: concat!(include_str!("../../ptx-sm86/mtp_original_full_head_native.ptx"), "\0").as_bytes(),
},
Companion {
name: "iq3_xxs_q8_1.ptx",
key: [
0xf9, 0xc1, 0x08, 0x14, 0xf3, 0x7b, 0x75, 0xba, 0xbc, 0xae, 0xe1, 0x02, 0x8b, 0x4a, 0x13, 0x75,
0xe5, 0x30, 0x22, 0x0f, 0x86, 0x3a, 0xb3, 0x80, 0x1b, 0xeb, 0x8f, 0xcb, 0x5a, 0x19, 0x73, 0x3f,
],
len: 15564,
sha: [
0x94, 0x65, 0x5f, 0x22, 0x89, 0x15, 0xdd, 0x3d, 0x0a, 0xe5, 0xdc, 0x3a, 0xde, 0xde, 0xf8, 0xfc,
0xeb, 0x06, 0x98, 0x20, 0xae, 0x17, 0xe1, 0x5d, 0xb9, 0x49, 0x44, 0x42, 0x79, 0x48, 0xaf, 0xda,
],
ptx: concat!(include_str!("../../ptx-sm86/iq3_xxs_q8_1.ptx"), "\0").as_bytes(),
},
Companion {
name: "qsa_native_gate.ptx",
key: [
0xf9, 0xf7, 0x78, 0x15, 0x44, 0xa4, 0xa0, 0xb0, 0xb2, 0xf0, 0x73, 0x3f, 0xe0, 0x0f, 0x36, 0xb8,
0x19, 0x49, 0x54, 0x33, 0x3b, 0x9b, 0xca, 0x99, 0x95, 0x91, 0x40, 0x45, 0xd8, 0x6b, 0xaf, 0x1e,
],
len: 1356,
sha: [
0x20, 0x00, 0x36, 0x45, 0x64, 0x34, 0x00, 0x9b, 0x96, 0x1c, 0x37, 0x1d, 0xa8, 0xa1, 0x44, 0x0d,
0xb1, 0x5a, 0x7b, 0xe9, 0x53, 0x19, 0xa8, 0xc8, 0x15, 0xe1, 0xbf, 0xe8, 0x00, 0x95, 0xf2, 0x1c,
],
ptx: concat!(include_str!("../../ptx-sm86/qsa_native_gate.ptx"), "\0").as_bytes(),
},
Companion {
name: "mtp_original_full_s2.ptx",
key: [
0xfb, 0xb9, 0x17, 0xd5, 0x90, 0xea, 0x80, 0x33, 0x8a, 0x7b, 0xdf, 0x07, 0xb2, 0xca, 0x6d, 0x45,
0x8f, 0xa7, 0x27, 0x63, 0xba, 0x27, 0x9e, 0x57, 0x6b, 0xcc, 0x1e, 0xec, 0x88, 0x36, 0xfd, 0x55,
],
len: 408620,
sha: [
0x84, 0xfc, 0xa0, 0x77, 0x1f, 0xef, 0x37, 0x13, 0x49, 0xc7, 0x2a, 0xdd, 0xaf, 0x76, 0x73, 0x8a,
0xe9, 0xb7, 0x55, 0x39, 0x89, 0xb5, 0xab, 0xf6, 0x60, 0x0a, 0x22, 0x35, 0x93, 0x95, 0xae, 0x83,
],
ptx: concat!(include_str!("../../ptx-sm86/mtp_original_full_s2.ptx"), "\0").as_bytes(),
},
Companion {
name: "qsa_decode_postops.ptx",
key: [
0xfd, 0x76, 0xe6, 0xf8, 0x45, 0x57, 0xd7, 0xf2, 0xa6, 0x2a, 0xc5, 0x6e, 0x16, 0xd5, 0xe4, 0xf7,
0x88, 0x62, 0xe7, 0x56, 0xef, 0x98, 0x52, 0xb0, 0x4d, 0x59, 0x19, 0x99, 0x21, 0x3a, 0x51, 0x19,
],
len: 12390,
sha: [
0x5f, 0xf2, 0x93, 0x19, 0x01, 0x09, 0x9c, 0x2c, 0xfd, 0xb6, 0x03, 0x94, 0x56, 0x52, 0x2a, 0x1e,
0x1c, 0x26, 0xae, 0x32, 0xb6, 0x1f, 0xdf, 0x69, 0xfb, 0xee, 0xd9, 0xc2, 0xca, 0x02, 0xdd, 0x1e,
],
ptx: concat!(include_str!("../../ptx-sm86/qsa_decode_postops.ptx"), "\0").as_bytes(),
},
Companion {
name: "moe_group_swiglu.ptx",
key: [
0xfe, 0x6f, 0xba, 0x86, 0x65, 0x4b, 0x64, 0x65, 0x1f, 0xee, 0xe8, 0x43, 0x91, 0xba, 0x77, 0xb2,
0xb0, 0xab, 0xff, 0x8b, 0x06, 0x23, 0xcd, 0xad, 0x41, 0x69, 0x76, 0x95, 0x44, 0x39, 0x7a, 0xea,
],
len: 4684,
sha: [
0xbe, 0x94, 0x9a, 0x3e, 0xf8, 0xc4, 0x3c, 0x2f, 0xa1, 0x1a, 0x73, 0x63, 0x7d, 0x2d, 0x2b, 0x9c,
0x8d, 0x83, 0xdf, 0x56, 0xc2, 0x78, 0x49, 0x21, 0xeb, 0x7b, 0xc2, 0xb4, 0xf0, 0xb5, 0x72, 0x26,
],
ptx: concat!(include_str!("../../ptx-sm86/moe_group_swiglu.ptx"), "\0").as_bytes(),
},
];