leleka_qsa_topk_wide (also _sample/_wide_failed, measured and not used) in qsa_late.cu; leleka_qsa_topk_cluster in the new sealed asset qsa_cluster.cu (sm_90+, no sm_86 companion); cuLaunchKernelEx plumbing for KernelModule and the verifier window (Launch.cluster); policy.qsa.cluster_topk. Same ids as qsa_topk_ref in every model-free case (continuous, heavy tailed, tied, all equal; prompt tiles of 256 rows and decode calls of 1..5 rows up to 261,500 tokens). LELEKA_QSA_TOPK=wide (prompt, from 10,000 blocks) and LELEKA_QSA_CLUSTER=1 (decode window) switch them on; defaults off until their R gate. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
49 lines
1.8 KiB
Rust
49 lines
1.8 KiB
Rust
//! `cuLaunchKernelEx` ABI pieces shared by the module wrappers (thread-block clusters, sm_90+; docs/upstream-port-plan.md row 2.5).
|
|
//! `CUlaunchConfig` / `CUlaunchAttribute` of cuda.h (CUDA 12.x/13.x): the attribute is an enum id, padding to 8 bytes and a 64-byte union.
|
|
use std::ffi::{c_int, c_void};
|
|
|
|
/// `CU_LAUNCH_ATTRIBUTE_CLUSTER_DIMENSION`.
|
|
const ATTRIBUTE_CLUSTER_DIMENSION: u32 = 4;
|
|
/// `CU_FUNC_ATTRIBUTE_MAX_DYNAMIC_SHARED_SIZE_BYTES`.
|
|
pub(crate) const FUNC_ATTRIBUTE_MAX_DYNAMIC_SHARED: c_int = 8;
|
|
|
|
#[repr(C)]
|
|
pub(crate) struct LaunchAttribute {
|
|
id: u32,
|
|
_pad: u32,
|
|
value: [u64; 8],
|
|
}
|
|
impl LaunchAttribute {
|
|
/// A cluster of `x * 1 * 1` CTAs (`value.clusterDim = {x, 1, 1}`).
|
|
pub(crate) fn cluster_x(x: u32) -> Self {
|
|
let mut value = [0u64; 8];
|
|
value[0] = (x as u64) | (1u64 << 32);
|
|
value[1] = 1;
|
|
Self { id: ATTRIBUTE_CLUSTER_DIMENSION, _pad: 0, value }
|
|
}
|
|
}
|
|
#[repr(C)]
|
|
pub(crate) struct LaunchConfig {
|
|
pub(crate) grid: [u32; 3],
|
|
pub(crate) block: [u32; 3],
|
|
pub(crate) smem: u32,
|
|
pub(crate) stream: *mut c_void,
|
|
pub(crate) attrs: *mut LaunchAttribute,
|
|
pub(crate) num_attrs: u32,
|
|
}
|
|
pub(crate) type LaunchEx = unsafe extern "C" fn(*const LaunchConfig, *mut c_void, *mut *mut c_void, *mut *mut c_void) -> c_int;
|
|
pub(crate) type FuncSetAttribute = unsafe extern "C" fn(*mut c_void, c_int, c_int) -> c_int;
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
#[test]
|
|
fn the_structs_have_the_sizes_of_cuda_h() {
|
|
assert_eq!(std::mem::size_of::<LaunchAttribute>(), 72);
|
|
assert_eq!(std::mem::align_of::<LaunchAttribute>(), 8);
|
|
assert_eq!(std::mem::size_of::<LaunchConfig>(), 56);
|
|
let a = LaunchAttribute::cluster_x(8);
|
|
assert_eq!((a.id, a.value[0] as u32, (a.value[0] >> 32) as u32, a.value[1] as u32), (4, 8, 1, 1));
|
|
}
|
|
}
|