cuda-driver: explicit imports (571 -> 2 production globs); explicit_imports.py: prune by the non-test build plus the test tokens of the file

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Pavlo Ratushnyi
2026-11-14 16:48:12 +01:00
co-authored by Claude Sonnet 5.5
parent 7637c2f0c2
commit 2a6cb31542
649 changed files with 2402 additions and 1204 deletions
-3
View File
@@ -1,9 +1,6 @@
//! Methods of `AsyncApi`: `load`, `create_stream`, `create_event`, `register` and 12 more.
//! Methods of `MappedApi`: `load`, `register_bank`, `bank_alias`, `unregister_bank` and 12 more.
#[allow(unused_imports)]
use super::*;
#[cfg(not(all(
feature = "cuda-driver",
any(target_os = "linux", target_os = "windows"),
+1 -1
View File
@@ -3,7 +3,7 @@
//! Built only with the `cuda-driver` feature on 64-bit Linux and Windows; `api.rs` declares stub types for every other
//! build.
use super::*;
use super::{Error, Event, MappedCopyArguments, Result, Stream};
use libc::{c_int, c_uint, c_void};
type Create = unsafe extern "C" fn(*mut *mut c_void, c_uint) -> c_int;
type Destroy = unsafe extern "C" fn(*mut c_void) -> c_int;
@@ -1,6 +1,6 @@
//! The optional batch-copy entry of `AsyncApi` (the lent-slot refill's `LELEKA_REFILL_BATCH`): resolved only when the
//! driver exports both symbols; a missing one leaves the per-copy path.
use super::*;
use super::{AsyncApi, Error, Event, Library, Result, Stream, c_int, c_uint, c_void, check};
use crate::refill_batch_copy::BatchCall;
/// `cuMemcpyBatchAsync_v2` (CUDA 12.8+/13, the form without `failIdx`): dsts, srcs, sizes, count, attrs, attrsIdxs,
@@ -1,8 +1,9 @@
//! Functions: `stream_k_off`, `marker_files_present`, `forced_sms`, `chunk_drain` and 10 more.
//! Split out of `arch_ptx` to keep its files under the line limit.
#[allow(unused_imports)]
use super::*;
use super::STREAM_K_AVOIDED;
#[cfg(feature = "sm86")]
use super::imp;
/// STRA-235: the grouped / MTP / resident MMQ launch one block per tile instead of the stream-K grid of `sms` blocks
/// (no split of the K loop, no fixup kernel). On by default for an sm_86-class device (latched by
+4 -1
View File
@@ -1,6 +1,9 @@
//! First real chunk primitive: one launch over independent GR token columns.
//! Numerical experiment only; no production asset admission or session commit.
use super::*;
use super::{Context, DeviceBuffer, Error, Operation, Result, qwen_ffi};
// used only with some cargo features or targets of this crate
#[allow(unused_imports)]
use super::{Arguments, Backend, combine, ffi, ranges_layout};
/// The four device buffers of one batched residual-inject launch.
pub struct GrInjectBuffers<'a, 'b> {
pub residual: &'a DeviceBuffer<'b>,
@@ -1,8 +1,9 @@
//! Methods of `PromptSyncTrace`: `enter`. Methods of `Driver`: `load`, `version`, `device`.
//! Implements `Drop for PromptSyncTrace`, `Drop for RoutedGateUpQ8`. Functions: `combine`, `valid_size`.
#[allow(unused_imports)]
use super::*;
use super::{
Cell, Context, Device, Driver, Error, PoisonCell, PromptSyncTrace, Rc, Result, RoutedGateUpQ8, ffi, qwen_dispatch,
};
impl PromptSyncTrace {
pub fn enter() -> Self {
@@ -1,8 +1,11 @@
//! Methods of `Program`: `name`, `ptx`, `pin`, `source` and 1 more. Methods of `Slot`: `kind`.
//! Functions: `admit_ptx`, `admit`, `s_gemv_entry_index`, `conforms` and 5 more.
#[allow(unused_imports)]
use super::*;
use super::{
Arg, DEVICE_POISON_PTX, Entry, ExperimentalError, FLASH_ENTRIES, FlashBytes, Kernel, MAX_ENTRY_ARGUMENTS,
NATIVE_FLASH_ATTN_PTX, PINS, POISON_ENTRIES, Program, PtxPin, Result, Role, S_GEMV_ENTRIES, S_GEMV_LEGACY_PTX,
SBytes, SForm, Slot, flash, invalid, qwen_ffi,
};
impl Program {
pub const ALL: [Program; 3] = [Program::NativeFlashAttn, Program::SGemvLegacy, Program::DevicePoison];
@@ -1,8 +1,7 @@
//! Functions: `s_gemv_slots`, `head_slots`.
//! Split out of `closed_kernels` to keep its files under the line limit.
#[allow(unused_imports)]
use super::*;
use super::{Kernel, Plan, Role, SForm, Slot};
/// The kernel arguments of a planned S-form GEMV, in the entry's order. `offset_present` is `offset != nullptr`.
pub fn s_gemv_slots(plan: &Plan, form: &SForm, n_in: i64, n_out: i64, offset_present: bool) -> Vec<Slot> {
@@ -2,8 +2,11 @@
//! flash_and_poison_signatures_match_their_cuda_source, s_gemv_signatures_match_their_cuda_source,
//! index_constants_and_planners_point_at_the_named_entries, every_planned_launch_conforms_to_its_entry ....
#[allow(unused_imports)]
use super::*;
use super::{
FLASH_ENTRIES, FLASH_SHORT, Kernel, MAX_ENTRY_ARGUMENTS, POISON_ENTRIES, POISON_F32, Plan, Program, Role,
S_GEMV_ENTRIES, SForm, Slot, arg_kinds, conforms, flash, flash_bytes, flash_slots, kinds_in, macro_kinds,
poison_slots, s_gemv_entry_index, s_gemv_slots, s_operand_bytes, sg,
};
#[test]
fn flash_and_poison_signatures_match_their_cuda_source() {
@@ -1,8 +1,7 @@
//! Tests of tests by topic (moved out of the test file by STRA-338):
//! sealed_assets_match_their_pins_and_export_every_entry.
#[allow(unused_imports)]
use super::*;
use super::{ExperimentalError, Program, PtxPin, admit, admit_ptx, qwen_ffi};
fn assert_pin_is_the_sealed_ptx(program: Program) {
use crate::sealed_ptx::test_support::{assert_nvcc_13_2_86, assert_real_sm120_ptx};
@@ -1,8 +1,12 @@
//! Groups the submodules `closed_kernels_flash_and_s_gemv`, `closed_kernels_open_admit_run`.
//! Split out of `closed_kernels_gpu` to keep its files under the line limit.
#[allow(unused_imports)]
use super::*;
use super::{
Admitted, ClosedKernels, Context, DeviceBuffer, DriverResult, Error, ExperimentalError, FLASH_SHORT,
FlashStepBuffers, Geometry, Launch, Operand, POISON_F32, Plan, Program, Rc, Result, Role, SForm, SGemvBuffers,
SGemvDims, Slot, admit, combine, conforms, device_arena, failure, ffi, flash, flash_bytes, flash_slots, invalid,
poison_slots, s_gemv_entry_index, s_gemv_slots, s_operand_bytes,
};
mod closed_kernels_flash_and_s_gemv;
mod closed_kernels_open_admit_run;
@@ -1,8 +1,11 @@
//! Methods of `FlashBuffers`: `admit`, `operands`.
//! Methods of `ClosedKernels`: `native_flash_attn_short`, `poison_f32`, `s_gemv`, `s2_gemv`.
#[allow(unused_imports)]
use super::*;
use super::{
ClosedKernels, DeviceBuffer, Error, ExperimentalError, FLASH_SHORT, FlashStepBuffers, Geometry, Operand,
POISON_F32, Plan, Program, Result, Role, SForm, SGemvBuffers, SGemvDims, device_arena, flash, flash_bytes,
flash_slots, invalid, poison_slots, s_gemv_entry_index, s_gemv_slots, s_operand_bytes,
};
use crate::closed_kernels::FlashBytes;
@@ -1,8 +1,10 @@
//! Methods of `ClosedKernels`: `open`, `close`, `expect`, `build` and 4 more.
//! Functions: `resolve_functions`, `reject_aliasing`.
#[allow(unused_imports)]
use super::*;
use super::{
Admitted, ClosedKernels, Context, DriverResult, Error, Geometry, Launch, Operand, Program, Rc, Result, Role, Slot,
admit, combine, conforms, failure, ffi, invalid,
};
/// Resolves every entry of the program in order; the first failure is returned and nothing is kept.
fn resolve_functions(
@@ -1,8 +1,7 @@
//! Functions: `failure`.
//! Split out of `closed_kernels_gpu` to keep its files under the line limit.
#[allow(unused_imports)]
use super::*;
use super::{DriverResult, Error, ExperimentalError, combine};
/// A primary driver failure plus the outcome of the mandatory context restore.
pub(super) fn failure(primary: Error, restore: DriverResult<()>) -> ExperimentalError {
@@ -1,7 +1,9 @@
//! The cases of the closed-program smokes: one short FlashAttention case and one replayed S-form GEMV golden case.
#[allow(unused_imports)]
use super::*;
use super::{
ClosedKernels, Codebook, Context, DeviceBuffer, FlashStepBuffers, Kernel, Rng, SForm, SGemvBuffers, SGemvDims,
download, f16_bits, f32s, flash, json_bytes, json_f32, sg, upload, zero_kv,
};
const CAPACITY: usize = 256;
@@ -1,8 +1,7 @@
//! Methods of `Rng`: `next`, `normal`. Functions: `f16_bits`, `upload`, `download`, `f32s` and 4 more.
//! Split out of `closed_kernels_gpu_smoke` to keep its files under the line limit.
#[allow(unused_imports)]
use super::*;
use super::{ClosedKernels, Context, DeviceBuffer, Program, Rng};
impl Rng {
pub(super) fn next(&mut self) -> u32 {
+4 -2
View File
@@ -1,8 +1,10 @@
//! Methods of `Context`: `poison`, `retain_driver`, `budget_bytes`, `device_ordinal` and 16 more.
//! Split out of `crate` to keep its files under the line limit.
#[allow(unused_imports)]
use super::*;
use super::{
Context, CurrentGuard, DeviceBuffer, Error, FixedOperation, PhantomData, Rc, Result, combine, ffi, valid_size,
vector_shape, vram_ledger,
};
impl Context<'_> {
/// Private sticky failure primitive shared by native owners.
@@ -1,8 +1,11 @@
//! Methods of `Context`: `project_routed_gate_up_prepared_weight`, `prepared_scratch`, `gate_up_prepared_shape`, `ga...
//! Split out of `crate` to keep its files under the line limit.
#[allow(unused_imports)]
use super::*;
use super::{
Context, DeviceBuffer, Error, NativeWeights, ProjectionKind, ProjectionShape, ProjectionSpec, Q5KProjectionShape,
Q5KShape, Q6KProjectionShape, Q6KShape, Result, RoutedFormat, RoutedGateUpQ8, combine, ffi, projection_ranges,
projection_shape, q5_k_shape, q6_k_shape,
};
impl Context<'_> {
pub(super) fn project_routed_gate_up_prepared_weight(
@@ -1,8 +1,10 @@
//! Methods of `Context`: `matvec_f32`, `q5_k_q8_1`, `q5_k_operation`, `q6_k_q8_1` and 4 more. Defines `MatvecDims`.
//! Split out of `crate` to keep its files under the line limit.
#[allow(unused_imports)]
use super::*;
use super::{
Context, DeviceBuffer, Error, FixedOperation, NativeWeights, ProjectionSpec, Q5KProjectionShape, Q5KShape,
Q6KProjectionShape, Q6KShape, Result, combine, ffi,
};
/// The row and column counts of a matrix-vector product.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
@@ -1,8 +1,10 @@
//! Methods of `Context`: `matvec_admission`, `kernel_slot`, `kernel_slot_rest`, `fixed_kernel` and 10 more.
//! Split out of `crate` to keep its files under the line limit.
#[allow(unused_imports)]
use super::*;
use super::{
Cell, Context, DeviceBuffer, Error, FixedKernel, FixedOperation, FixedPairKernels, MatvecShape, ProjectionKernels,
ProjectionKind, Rc, Result, combine, ffi, matvec_allocations, matvec_shape,
};
impl Context<'_> {
pub(super) fn matvec_admission(
@@ -1,8 +1,10 @@
//! Methods of `Context`: `project_q8_1_weight`, `project_q8_1_operation`, `prepare_routed_gate_up_q8`, `gate_up_sour...
//! Split out of `crate` to keep its files under the line limit.
#[allow(unused_imports)]
use super::*;
use super::{
Context, DeviceBuffer, Error, FixedOperation, NativeWeights, ProjectionShape, ProjectionSpec, Result, RoutedFormat,
RoutedGateUpQ8, combine, ffi,
};
impl Context<'_> {
pub(super) fn project_q8_1_weight(
@@ -1,8 +1,7 @@
//! Methods of `Context`: `unload_projections`, `unload_projection_slot`, `unload_q5_kernels`, `unload_q6_kernels` an...
//! Methods of `CurrentGuard`: `finish`, `restore`. Implements `Drop for Context`, `Drop for CurrentGuard`.
#[allow(unused_imports)]
use super::*;
use super::{Context, CurrentGuard, Error, FixedOperation, ProjectionKernels, Rc, Result, combine};
impl Context<'_> {
pub(super) fn unload_projections(&self) -> Result<()> {
+3 -2
View File
@@ -1,8 +1,9 @@
//! Methods of `DeviceBuffer`: `len`, `is_empty`, `staging`, `copy_from` and 12 more.
//! Implements `Drop for DeviceBuffer`. Functions: `chain_selects_mtp`, `chain_selects_mtp`, `set_chain_down_override`.
#[allow(unused_imports)]
use super::*;
use super::{DeviceBuffer, Error, Result, combine, compute_drain, vram_ledger};
#[cfg(all(feature = "cuda-driver", any(target_os = "linux", target_os = "windows"), target_pointer_width = "64"))]
use super::original_verify;
impl DeviceBuffer<'_> {
pub fn len(&self) -> usize {
@@ -1,8 +1,10 @@
//! Methods of `KvShape`: `real`, `as_qsa`, `base`, `check_q4` and 8 more. Methods of `Context`: `unload_experimental`.
//! Functions: `fwht_grid`, `fwht_bytes`, `q4_step_grid`, `q4_batch_grid` and 12 more.
#[allow(unused_imports)]
use super::*;
use super::{
Context, ExperimentalError, Grid, KvShape, MAX_GRID_YZ, QsaShapes, Result, cvec, grid_x, grid_yz, invalid, keyless,
kv_q8, q4_0,
};
impl KvShape {
pub const fn real() -> Self {
+5 -2
View File
@@ -1,8 +1,11 @@
//! Methods of `Mode`: `name`, `bit`. Methods of `OptIn`: `with`, `is_enabled`, `is_empty`, `modes` and 2 more.
//! Implements `Display for ExperimentalError`, `Error for ExperimentalError` and 1 more.
#[allow(unused_imports)]
use super::*;
use super::{
CVEC_ENTRIES, CVEC_PTX, Entry, Error, ExperimentalError, KEYLESS_ENTRIES, KEYLESS_PTX, KV_Q4_ENTRIES, KV_Q4_PTX,
KV_Q8_ENTRIES, KV_Q8_PTX, KV_STREAM_ENTRIES, KV_STREAM_PTX, MAX_GRID_X, MAX_GRID_YZ, Mode, OptIn, PINS, Program,
PtxPin, QSA_ATTN_ENTRIES, QSA_ATTN_PTX, Result, fmt, qwen_ffi,
};
impl Mode {
pub const ALL: [Mode; 6] =
@@ -1,8 +1,9 @@
//! Methods of `Context`: `experimental_program`, `unload_failed`. Functions: `resolve_entries`, `i32_of`, `i64_of`.
//! Split out of `experimental_gpu` to keep its files under the line limit.
#[allow(unused_imports)]
use super::*;
use super::{
Context, DriverResult, Error, LoadedProgram, OptIn, Program, Rc, Result, admit, combine, failure, ffi, invalid,
};
impl Context<'_> {
/// Opt-in and pin gates, then load and cache the module once. Refuses without touching the driver while the
@@ -1,7 +1,13 @@
//! The launch methods of the `Experimental` facade, one module per program family.
#[allow(unused_imports)]
use super::*;
use super::{
ATTN_CHUNK_M2, ATTN_CHUNK_M3, ATTN_CHUNK_M4, ATTN_MERGE, AttendDestination, AttendKv, AttnPools, BatchRows,
COPY_U4, CTL_INTS, CVEC_APPLY, Call, CellSelection, Context, ControlVector, CvecDims, DeviceBuffer, Error,
Experimental, FWHT256, GatherIndex, KEYLESS_ROUTE, KvPair, KvShape, Launch, OptIn, PageStep, Paged, Program,
Q4_APPEND_BATCH, Q4_APPEND_STEP, Q4_GATHER_STEP, Q8_APPEND_STEP, Q8_GATHER_STEP, Q8Pool, Q8PoolAppend, QueryBatch,
RING_TABLE, ResolveDims, ResolveGeometry, ResolveIndex, Result, STEP_BYTES, STREAM_COPY, STREAM_RESET,
STREAM_RESOLVE, StreamArrays, StreamDims, StreamMap, attn, experimental, i32_of, i64_of, invalid, stream_runs,
};
mod attention_launch;
mod program_and_kv_pool_launches;
@@ -1,7 +1,10 @@
//! The attention launch of the experimental KV modes: the chunk kernel of the pool mode, then the merge.
#[allow(unused_imports)]
use super::*;
use super::{
ATTN_CHUNK_M2, ATTN_CHUNK_M3, ATTN_CHUNK_M4, ATTN_MERGE, AttendDestination, AttendKv, AttnPools, Call,
CellSelection, DeviceBuffer, Experimental, Paged, Program, QueryBatch, Result, STEP_BYTES, attn, experimental,
i32_of, i64_of,
};
mod attend_inputs;
use attend_inputs::Attend;
@@ -1,7 +1,9 @@
//! The inputs and derived sizes shared by the chunk and merge launches of `Experimental::attend`.
#[allow(unused_imports)]
use super::*;
use super::{
ATTN_CHUNK_M2, ATTN_CHUNK_M3, ATTN_CHUNK_M4, ATTN_MERGE, AttnPools, Call, DeviceBuffer, Experimental, Paged,
Result, STEP_BYTES, attn, experimental, i32_of, i64_of,
};
/// The inputs and the derived sizes of one `attend`.
pub(super) struct Attend<'a, 'b> {
@@ -1,7 +1,10 @@
//! Opening the program, the call builder entry, the FWHT launch and the Q4_0 / INT8 pool append and gather launches.
#[allow(unused_imports)]
use super::*;
use super::{
BatchRows, Call, Context, DeviceBuffer, Error, Experimental, FWHT256, GatherIndex, KvPair, KvShape, Launch, OptIn,
PageStep, Paged, Program, Q4_APPEND_BATCH, Q4_APPEND_STEP, Q4_GATHER_STEP, Q8_APPEND_STEP, Q8PoolAppend, Result,
STEP_BYTES, experimental, i64_of, invalid,
};
mod call_shape;
mod step_operands;
@@ -1,7 +1,6 @@
//! Argument groups that the experimental KV launches repeat: the page-shape scalars and runs of null pointers.
#[allow(unused_imports)]
use super::*;
use super::{Call, KvShape};
impl<'g, 'c> Call<'g, 'c> {
/// `kv_heads`, `head_dim` and `page_size` of the pool shape, as three i32 scalars.
@@ -1,8 +1,7 @@
//! The operands of the Q4 batch append, the Q4 gather and the INT8 step append, bundled so that each launch chain
//! lives in a method of its own.
#[allow(unused_imports)]
use super::*;
use super::{Call, DeviceBuffer, Experimental, Launch, Paged, Q4_APPEND_BATCH, Q4_GATHER_STEP, Result, STEP_BYTES};
/// The operands of one `kv_append_q4` (prefill) launch pair; `launch` builds the K (`is_v` 0) or V (`is_v` 1) pass.
pub(super) struct Q4Batch<'a, 'b> {
@@ -1,7 +1,11 @@
//! The INT8 gather, KV streaming (reset, resolve, ring restore), keyless routing and control-vector launches.
#[allow(unused_imports)]
use super::*;
use super::{
COPY_U4, CTL_INTS, CVEC_APPLY, Call, ControlVector, CvecDims, DeviceBuffer, Experimental, GatherIndex,
KEYLESS_ROUTE, KvPair, Launch, Paged, Program, Q8_GATHER_STEP, Q8Pool, RING_TABLE, ResolveDims, ResolveGeometry,
ResolveIndex, Result, STEP_BYTES, STREAM_COPY, STREAM_RESET, STREAM_RESOLVE, StreamArrays, StreamDims, StreamMap,
experimental, i32_of, i64_of, invalid, stream_runs,
};
mod q8_gather_and_resolve_launch;
use q8_gather_and_resolve_launch::Q8Gather;
@@ -1,8 +1,10 @@
//! The operands of the INT8 gather and the launch of the KV-stream resolve, bundled so that each launch chain lives
//! in a method of its own.
#[allow(unused_imports)]
use super::*;
use super::{
Call, DeviceBuffer, Experimental, Launch, Paged, Q8_GATHER_STEP, ResolveDims, ResolveGeometry, Result, STEP_BYTES,
STREAM_RESOLVE, StreamDims, StreamMap, experimental, i32_of, i64_of,
};
/// The operands of one `kv_gather_q8_step` launch.
pub(super) struct Q8Gather<'a, 'b> {
@@ -1,8 +1,7 @@
//! The domain groups of the public `Experimental` launches (K/V pairs, page-table and step records, gather indexes,
//! streaming geometry, control-vector and attention operands), so that no facade call takes more than five parameters.
#[allow(unused_imports)]
use super::*;
use super::{AttnPools, DeviceBuffer, KvShape, Paged, StreamFormat};
/// The K and V counterparts of one kind of operand (pools, current rows, scratch arrays).
pub struct KvPair<T> {
@@ -1,8 +1,10 @@
//! Methods of `StreamMap`: `bind`. Methods of `Call`: `pointer`, `ro`, `rw`, `ro_at` and 7 more. Functions: `failure`.
//! Split out of `experimental_gpu` to keep its files under the line limit.
#[allow(unused_imports)]
use super::*;
use super::{
Admitted, Arg, CTL_INTS, Call, DeviceBuffer, DriverResult, Entry, Error, ExperimentalError, Launch, Result,
StreamMap, combine, ffi, invalid,
};
impl StreamMap<'_, '_> {
/// The first five (or seven, for resolve) pointer arguments of `reset` / `resolve`.
-3
View File
@@ -1,9 +1,6 @@
//! Methods of `Api`: `memory_info`, `mmq_capabilities`, `load_mmq`, `mmq_function` and 56 more.
//! Split out of `ffi` to keep its files under the line limit.
#[allow(unused_imports)]
use super::*;
#[cfg(not(all(
feature = "cuda-driver",
any(target_os = "linux", target_os = "windows"),
+3 -1
View File
@@ -1,8 +1,10 @@
//! Methods of `ContextHandle`: `synthetic`.
//! Methods of `BufferHandle`: `registered_bank_alias`, `checked_subspan`, `qwen_address`, `validate_extent` and 7 more.
use super::{BufferHandle, DenseFormat, Error, ProjectionKind, Result, RoutedFormat};
// used only with some cargo features or targets of this crate
#[allow(unused_imports)]
use super::*;
use super::ModuleHandle;
#[cfg(all(
test,
+7 -1
View File
@@ -3,7 +3,13 @@
//! Built only with the `cuda-driver` feature on 64-bit Linux and Windows; `ffi.rs` declares stub types for every other
//! build.
use super::*;
use super::{
BufferHandle, ContextHandle, Error, FixedOperation, FunctionHandle, GdnPrefillArguments, GrReadGuardArguments,
HeadGreedyArguments, Iq3NativeIntegerArguments, LaunchArguments, MatvecArguments, MmqArguments, MmqFixupArguments,
MmqOriginalGatherArguments, MmqOriginalSwigluArguments, MmqQuantArguments, MmqResidentArguments, ModuleHandle,
ProjectionArguments, Q5ProjectionArguments, Q6ProjectionArguments, Q8QuantizeArguments, QsaSelectedArguments,
Result, projection_entry, projection_ptx, validate_projection_ptx,
};
use libc::{c_int, c_uint, c_void};
type CuResult = c_int;
@@ -1,8 +1,10 @@
//! Methods of `Api`: `memory_info`, `mmq_capabilities`, `load_mmq`, `mmq_function` and 9 more.
//! Split out of `enabled` to keep its files under the line limit.
#[allow(unused_imports)]
use super::*;
use super::{
Api, CuDevice, CuResult, Error, FunctionHandle, HeadGreedyArguments, Iq3NativeIntegerArguments, MemGetInfoV2,
ModuleHandle, Result, c_int, c_void, check,
};
impl Api {
/// The dynamic shared-memory sizes an MMQ kernel may be raised to: a closed list.
@@ -1,8 +1,7 @@
//! Methods of `Api`: `device`, `create`, `destroy`, `push` and 11 more.
//! Split out of `enabled` to keep its files under the line limit.
#[allow(unused_imports)]
use super::*;
use super::{Api, BufferHandle, ContextHandle, CuContext, Error, Result, c_void, check};
impl Api {
pub(crate) fn device(&self, ordinal: i32) -> Result<i32> {
@@ -1,8 +1,7 @@
//! Implements `Drop for Library`. Functions: `check`.
//! Split out of `enabled` to keep its files under the line limit.
#[allow(unused_imports)]
use super::*;
use super::{CuResult, Error, Library, Result};
impl Drop for Library {
fn drop(&mut self) {
@@ -1,8 +1,14 @@
//! Methods of `Api`: `launch_qwen`, `load`, `resolve`, `load_q6_batch_preview` and 4 more.
//! Functions: `is_projection_family`.
#[allow(unused_imports)]
use super::*;
use super::{
Api, COMMON_QUANTIZER_PTX, ContextCreateV2, ContextDestroyV2, ContextPopCurrentV2, ContextPushCurrentV2,
ContextSynchronize, DeviceGet, DriverGetVersion, Error, FIXED_PTX, FixedOperation, FunctionHandle, Init,
LaunchKernel, Library, MATVEC_PTX, MemAllocV2, MemFreeV2, MemcpyDtoDV2, MemcpyDtoHV2, MemcpyHtoDV2, MemsetD8V2,
ModuleGetFunction, ModuleHandle, ModuleLoadData, ModuleUnload, Q5_K_PTX, Q6_K_PTX, Q6ProjectionArguments,
Q8QuantizeArguments, Result, StreamSynchronizeRaw, c_void, check, projection_entry, projection_ptx,
validate_projection_ptx,
};
mod fixed_selectors;
use fixed_selectors::{fixed_entry, fixed_ptx};
@@ -1,7 +1,9 @@
//! The sealed PTX image and the C entry name of a fixed operation, one exhaustive match per group of operations.
#[allow(unused_imports)]
use super::*;
use super::{
COMMON_QUANTIZER_PTX, Error, FIXED_PTX, FixedOperation, MATVEC_PTX, Q5_K_PTX, Q6_K_PTX, Result, projection_entry,
projection_ptx,
};
/// The sealed PTX image of a fixed operation.
pub(super) fn fixed_ptx(operation: FixedOperation) -> Result<&'static [u8]> {
@@ -1,8 +1,10 @@
//! Methods of `Api`: `unload`, `launch`, `launch_gr_read_guard`, `launch_matvec` and 8 more.
//! Split out of `enabled` to keep its files under the line limit.
#[allow(unused_imports)]
use super::*;
use super::{
Api, FunctionHandle, GrReadGuardArguments, LaunchArguments, MatvecArguments, ModuleHandle, ProjectionArguments,
Q5ProjectionArguments, Q6ProjectionArguments, Q8QuantizeArguments, Result, c_void, check,
};
impl Api {
pub(crate) fn unload(&self, module: ModuleHandle) -> Result<()> {
@@ -1,8 +1,10 @@
//! Methods of `Api`: `mmq_original_group_shared_limit`, `load_mmq_original_group`, `mmq_original_group_function`, `l...
//! Split out of `enabled` to keep its files under the line limit.
#[allow(unused_imports)]
use super::*;
use super::{
Api, CuDevice, CuResult, Error, FunctionHandle, MMQ_ORIGINAL_GROUP_SYMBOLS, MmqOriginalGatherArguments,
MmqResidentArguments, ModuleHandle, Result, c_int, c_void, check,
};
impl Api {
pub(crate) fn mmq_original_group_shared_limit(&self) -> Result<u32> {
@@ -1,8 +1,10 @@
//! Methods of `Api`: `launch_mmq_original_swiglu`, `load_mmq_resident`, `mmq_resident_function`, `launch_mmq_residen...
//! Split out of `enabled` to keep its files under the line limit.
#[allow(unused_imports)]
use super::*;
use super::{
Api, Error, FunctionHandle, MmqArguments, MmqFixupArguments, MmqOriginalSwigluArguments, MmqQuantArguments,
MmqResidentArguments, ModuleHandle, QsaSelectedArguments, Result, c_void, check,
};
impl Api {
pub(crate) fn launch_mmq_original_swiglu(
@@ -1,8 +1,16 @@
//! Methods of `FunctionHandle`: `qwen_success`, `synthetic`. Methods of `LaunchArguments`: `new`.
//! Implements `Drop for LaunchArguments`, `Drop for GrReadGuardArguments` and 3 more.
use super::{
ArgumentStorage, BufferHandle, LaunchArguments, MatvecArguments, MatvecStorage, ProjectionArguments,
ProjectionStorage, Q5ProjectionArguments, Q5ProjectionStorage, Q6ProjectionArguments, Q6ProjectionStorage,
Q8QuantizeArguments, Q8QuantizeStorage,
};
#[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64", feature = "cuda-driver"))]
use super::{GrReadGuardArguments, GrReadGuardStorage};
// used only with some cargo features or targets of this crate
#[allow(unused_imports)]
use super::*;
use super::{Error, FunctionHandle, Result};
#[cfg(any(
test,
@@ -1,8 +1,7 @@
//! Implements `Drop for Q5ProjectionArguments`, `Drop for MatvecArguments`.
//! Split out of `ffi` to keep its files under the line limit.
#[allow(unused_imports)]
use super::*;
use super::{MatvecArguments, Q5ProjectionArguments};
impl Drop for Q5ProjectionArguments {
fn drop(&mut self) {
@@ -1,8 +1,7 @@
//! Methods of `QsaSelectedArguments`: `new`, `parameters`. Methods of `HeadGreedyArguments`: `new`, `parameters`.
//! Implements `Drop for QsaSelectedArguments`, `Drop for HeadGreedyArguments`.
#[allow(unused_imports)]
use super::*;
use super::{BufferHandle, HeadGreedyArguments, HeadGreedyStorage, QsaSelectedArguments, QsaSelectedStorage};
impl QsaSelectedArguments {
pub(crate) fn new(handles: [BufferHandle; 5], layer: u32, count: u32) -> Self {
+4 -1
View File
@@ -3,7 +3,10 @@
//! completion fence. It replaces only the discarded host intermediates of the
//! scalar chain; arithmetic assets, operand geometry and the causal recurrence
//! are the existing ones. It is not a certificate of source, role or row.
use super::*;
use super::{
Admission, Arguments, Context, DeviceBuffer, Error, Operation, Result, admission, combine, ffi, qwen_ffi,
ranges_layout, registered,
};
const SLOTS: usize = 13;
const STATUS_BYTES: usize = SLOTS * 4;
@@ -1,8 +1,10 @@
//! Methods of `GdnQueueStage`: `words`, `slot`. Methods of `Step`: `next`.
//! Functions: `decode_statuses`, `column_row_offset`.
#[allow(unused_imports)]
use super::*;
use super::{
Context, Error, GdnQueueStage, GdnRowCompletion, GdnRowPrefix, GdnRowQueue, Kernels, MAX_COLUMN_ROWS, OPS,
QKV_BYTES, Result, SLOTS, STAGES, STATUS_BYTES, Step, combine, ffi, qwen_ffi, registered,
};
impl GdnQueueStage {
/// Exact F32 word count of the whole buffer this stage scans.
@@ -1,8 +1,12 @@
//! Groups the submodules `convolution_stages`, `gdn_row_prefix_fenced_drain`, `recurrence_stages`.
//! Split out of `gdn_closed_queue` to keep its files under the line limit.
#[allow(unused_imports)]
use super::*;
use super::{
Admission, Arguments, BETA, CONV, Command, DeviceBuffer, Drained, Error, GATE, GdnConvBuffers, GdnOutNormBuffers,
GdnQueueStage, GdnRecurrenceBuffers, GdnRowCompletion, GdnRowPrefix, HISTORY_BYTES, OPS, OUT_NORM, Operation, QK,
QK_BYTES, QKV_BYTES, Result, SLOTS, STATE_BYTES, STATUS_BYTES, STEP, Step, admission, column_row_offset, combine,
decode_statuses, ffi, qwen_ffi, ranges_layout, staging,
};
#[path = "gdn_row_prefix/convolution_stages.rs"]
mod convolution_stages;
@@ -1,8 +1,10 @@
//! Methods of `GdnRowPrefix`: `ready`, `latch`, `handle_of`, `same` and 11 more.
//! Split out of `gdn_row_prefix` to keep its files under the line limit.
#[allow(unused_imports)]
use super::*;
use super::{
Admission, Arguments, CONV, Command, DeviceBuffer, Error, GdnConvBuffers, GdnQueueStage, GdnRowPrefix, OPS,
Operation, QKV_BYTES, Result, STATUS_BYTES, Step, admission, column_row_offset, ffi, qwen_ffi, ranges_layout,
};
impl<'lease, 'ctx> GdnRowPrefix<'lease, 'ctx> {
pub(in super::super) fn ready(&self, step: Step) -> Result<()> {
@@ -1,8 +1,10 @@
//! Methods of `GdnRowPrefix`: `drain`, `drain_buffers`, `decoded_refusal`, `fenced` and 2 more.
//! Functions: `fetched_history`, `history_words`. Defines `Fenced`.
#[allow(unused_imports)]
use super::*;
use super::{
Drained, Error, GdnQueueStage, GdnRowPrefix, HISTORY_BYTES, Result, SLOTS, STATUS_BYTES, combine, decode_statuses,
ffi, staging,
};
impl<'lease, 'ctx> GdnRowPrefix<'lease, 'ctx> {
pub(in super::super) fn drain(mut self, fetch: bool) -> Result<Drained> {
@@ -1,8 +1,11 @@
//! Methods of `GdnRowPrefix`: `qk_l2`, `beta_sigmoid`, `gate_softplus`, `recurrence` and 7 more.
//! Split out of `gdn_row_prefix` to keep its files under the line limit.
#[allow(unused_imports)]
use super::*;
use super::{
Admission, Arguments, BETA, Command, DeviceBuffer, Error, GATE, GdnOutNormBuffers, GdnQueueStage,
GdnRecurrenceBuffers, GdnRowCompletion, GdnRowPrefix, HISTORY_BYTES, OUT_NORM, Operation, QK, QK_BYTES, Result,
STATE_BYTES, STATUS_BYTES, STEP, Step, admission, ffi, qwen_ffi, ranges_layout,
};
impl<'lease, 'ctx> GdnRowPrefix<'lease, 'ctx> {
/// Original Q/K L2 kernel into the whole 10,240-word slot; the scan covers
@@ -1,8 +1,7 @@
//! Methods of `GdnRowQueue`: `close_inner`, `release_status`, `release_module`. Methods of `Command`: `launch`.
//! Implements `Drop for GdnRowQueue`. Functions: `staging`.
#[allow(unused_imports)]
use super::*;
use super::{Command, Context, DeviceBuffer, Error, GdnRowQueue, Result, combine, ffi};
impl GdnRowQueue<'_> {
pub(super) fn close_inner(&mut self) -> Result<()> {
@@ -1,8 +1,10 @@
//! Methods of `Row`: `conv_buffers`, `recurrence_buffers`, `out_norm_buffers`, `new` and 7 more.
//! Functions: `bytes`, `upload`, `blank`, `read` and 6 more.
#[allow(unused_imports)]
use super::*;
use super::{
CHANNELS, Context, DeviceBuffer, EPSILON, GdnConvBuffers, GdnOutNormBuffers, GdnRecurrenceBuffers,
GdnRowCompletion, GdnRowPrefix, GdnRowQueue, HISTORY, Poison, Result, Row, STATE, VALUES, combine,
};
use crate::{GdnConvResult, GdnGates, GdnOutNormInput, GdnStepProducts, GdnStepResult};
pub(super) fn bytes(values: &[f32]) -> Vec<u8> {
@@ -1,8 +1,10 @@
//! Functions: `columns_pair`, `poisoned_image`, `compare_columns`, `note_qkv_refusal` and 4 more.
//! Defines `ColumnsCase`, `ColumnsPoison`, `RetainedColumns`.
#[allow(unused_imports)]
use super::*;
use super::{
CHANNELS, Context, DeviceBuffer, Error, GdnQueueStage, GdnRowCompletion, GdnRowQueue, Poison, Report, Result, Row,
bytes, column_image, combine, queued, queued_columns, scalar, upload,
};
/// The batched image of one retained-row case: the salt, the number of rows and the used row.
#[derive(Clone, Copy)]
@@ -1,8 +1,11 @@
//! The scenarios of the changed GDN row queue proof: clean rows, ordered numerical refusals, retained batched
//! rows and the admission refusals, all on one queue.
#[allow(unused_imports)]
use super::*;
use super::{
CHANNELS, ColumnsCase, ColumnsPoison, Context, DeviceBuffer, EPSILON, Error, GdnQueueStage, GdnRowQueue, Poison,
Report, Result, Row, STATUS_BYTES, blank, clean_pair, column_image, columns_pair, combine, refusal_case, refuse,
upload,
};
/// The whole proof on one queue of `context`; `foreign` supplies the buffers of another Context.
pub(super) fn run(context: &Context<'_>, foreign: &Context<'_>, report: &mut Report) -> Result<()> {
+1 -1
View File
@@ -21,7 +21,7 @@
//! completion uncertainty poisons the context and leaks the owners. The candidate state/history reach the host only
//! after a clean complete drain.
use super::gdn_native_batch::GdnStream;
use super::*;
use super::{Context, DeviceBuffer, Error, Result, combine, ffi};
const C: usize = 10_240;
const HV: usize = 48;
@@ -1,8 +1,11 @@
//! Groups the submodules `fused_stage_binding`, `gdn_fused_prefix_step_norm_drain`.
//! Split out of `gdn_fused_t1` to keep its files under the line limit.
#[allow(unused_imports)]
use super::*;
use super::{
C, Command, DeviceBuffer, Drained, Error, F16, F32, FusedKernel, GDN_FUSED_T1_STATE_BYTES, GdnAbBuffers,
GdnFusedCompletion, GdnFusedPrefix, GdnFusedStage, GdnStream, HISTORY_WORDS, HV, N_EMBD, Result, Role, S,
STATE_WORDS, STATUS_BYTES, Step, combine, decode_statuses, ffi, linear, staging, words,
};
#[path = "gdn_fused_prefix/fused_stage_binding.rs"]
mod fused_stage_binding;
@@ -1,8 +1,10 @@
//! Methods of `GdnFusedPrefix`: `ready`, `latch`, `bind`, `push` and 10 more.
//! Split out of `gdn_fused_prefix` to keep its files under the line limit.
#[allow(unused_imports)]
use super::*;
use super::{
C, Command, DeviceBuffer, Error, F16, F32, FusedKernel, GDN_FUSED_T1_STATE_BYTES, GdnAbBuffers, GdnFusedPrefix,
GdnFusedStage, HV, N_EMBD, Result, Role, S, STATE_WORDS, STATUS_BYTES, Step, ffi, linear,
};
impl<'lease, 'ctx> GdnFusedPrefix<'lease, 'ctx> {
pub(in super::super) fn ready(&self, step: Step) -> Result<()> {
@@ -1,8 +1,11 @@
//! Methods of `GdnFusedPrefix`: `step_norm`, `step_norm_handles`, `push_step_norm`, `fetch_candidate` and 8 more.
//! Functions: `fetched_candidate`, `candidate_words`. Defines `DrainBuffers`, `Fenced`.
#[allow(unused_imports)]
use super::*;
use super::{
DeviceBuffer, Drained, Error, F32, FusedKernel, GDN_FUSED_T1_STATE_BYTES, GdnFusedCompletion, GdnFusedPrefix,
GdnFusedStage, GdnStream, HISTORY_WORDS, HV, Result, Role, S, STATUS_BYTES, Step, combine, decode_statuses, ffi,
staging, words,
};
impl<'lease, 'ctx> GdnFusedPrefix<'lease, 'ctx> {
/// `fused_gdn_step_norm`: the in-place state update, readout and per-head norm / ssm_norm / sigmoid(z) gate.
@@ -2,8 +2,10 @@
//! result.
//! Apart from `gdn_fused_t1.rs`, which holds the types and fields.
#[allow(unused_imports)]
use super::*;
use super::{
Bindings, Command, Context, Error, FUSED_KERNELS, FusedKernel, GdnFusedCompletion, GdnFusedPrefix, GdnFusedStage,
GdnFusedT1, RESERVE, Result, SLOTS, STATUS_BYTES, Step, combine, ffi, linear,
};
impl<'ctx> GdnFusedT1<'ctx> {
pub(super) fn new(context: &'ctx Context<'ctx>) -> Result<Self> {
@@ -1,8 +1,10 @@
//! Methods of `FusedKernel`: `entry`, `index`. Methods of `GdnFusedStage`: `slot`, `elements`, `bytes`.
//! Functions: `pinned`, `fused_asset`, `linear`, `decode_statuses`.
#[allow(unused_imports)]
use super::*;
use super::{
Bindings, C, Context, Error, F32, FUSED_PTX_LEN, FUSED_PTX_SHA256, FusedKernel, GdnFusedStage, GdnFusedT1,
HISTORY_WORDS, HV, ROLES, Result, Role, SLOTS, STATE_WORDS, STATUS_BYTES, Step, VALUES, ffi,
};
pub(super) fn pinned(ptx: &'static [u8], len: usize, digest: [u8; 32]) -> Result<&'static [u8]> {
if ptx.last() != Some(&0) || !ptx[..ptx.len() - 1].is_ascii() || ptx[..ptx.len() - 1].contains(&0) {
+4 -2
View File
@@ -1,8 +1,10 @@
//! Methods of `GdnFusedT1`: `close_inner`, `release_status`, `release_module`, `replay_state_from_products`.
//! Methods of `GdnFusedPrefix`: `bind_replay`, `finish_device`. Implements `Drop for GdnFusedT1`.
#[allow(unused_imports)]
use super::*;
use super::{
C, DeviceBuffer, Error, F32, FusedKernel, GdnFusedPrefix, GdnFusedStage, GdnFusedT1, GdnReplayBuffers, HV, Result,
Role, S, STATE_WORDS, Step, VALUES, combine, ffi,
};
pub(super) fn words<T>(bytes: &[u8], decode: fn([u8; 4]) -> T) -> Result<Box<[T]>> {
let mut values = Vec::new();
+1 -1
View File
@@ -18,7 +18,7 @@
//! earliest-stage refusal; completion uncertainty poisons the context and the
//! launch/staging owners are leaked on purpose. There is no per-row mid-chunk
//! publication: a refusal anywhere discards the whole chunk.
use super::*;
use super::{Context, DeviceBuffer, Error, Result, combine, ffi};
/// Most token rows of one chunk (largest scan stays below the 2^25-word helper limit).
pub const GDN_BATCH_MAX_TOKENS: usize = 2048;
@@ -1,8 +1,11 @@
//! Methods of `Context`: `gdn_prefill_batch`, `gdn_prefill_batch_for_prompt`.
//! Methods of `GdnPrefillBatch`: `new`, `new_capacity`, `open`, `load_functions` and 6 more. Functions: `reserved`.
#[allow(unused_imports)]
use super::*;
use super::{
Bindings, Command, Context, Error, Functions, GDN_BATCH_MAX_TOKENS, GdnBatchCompletion, GdnBatchPrefix,
GdnBatchStage, GdnGemm, GdnPrefillBatch, GdnStream, KERNELS, Kernel, Result, SLOTS, STATUS_BYTES, Step, combine,
ffi, linear,
};
/// An empty vector with room for `capacity` elements, or a typed host-allocation failure.
fn reserved<T>(capacity: usize) -> Result<Vec<T>> {
@@ -1,8 +1,11 @@
//! Groups the submodules `native_projection`, `qkv_and_z_projections`, `recurrence_and_output`.
//! Split out of `gdn_native_batch` to keep its files under the line limit.
#[allow(unused_imports)]
use super::*;
use super::{
C, CONV_TILE, Command, DeviceBuffer, Drained, Error, F16, F32, GDN_BATCH_EPSILON, GdnBatchCompletion,
GdnBatchPrefix, GdnBatchStage, GdnNativeFormat, GemmShape, HISTORY_WORDS, HV, Kernel, N, Result, Role, S,
STATE_WORDS, STATUS_BYTES, Step, ZV, combine, decode_statuses, ffi, linear, staging,
};
#[path = "gdn_batch_prefix/native_projection.rs"]
mod native_projection;
@@ -1,8 +1,10 @@
//! Methods of `GdnBatchPrefix`: `tokens`, `ready`, `latch`, `function` and 12 more. Functions: `size_admitted`.
//! Defines `NativeProjection`, `ProjectionOperands`.
#[allow(unused_imports)]
use super::*;
use super::{
Command, DeviceBuffer, Error, F16, F32, GdnBatchPrefix, GdnBatchStage, GdnNativeFormat, GemmShape, Kernel, N,
Result, Role, STATUS_BYTES, Step, ffi, linear,
};
/// The shape of one native projection: the GGUF `format`, the matrix `rows` x `depth` and the byte size of the f32
/// output.
@@ -2,8 +2,10 @@
//! Split out of `gdn_batch_prefix` to keep its files under the line limit.
use super::native_projection::{NativeProjection, ProjectionOperands};
#[allow(unused_imports)]
use super::*;
use super::{
C, CONV_TILE, Command, DeviceBuffer, F16, F32, GDN_BATCH_EPSILON, GdnBatchPrefix, GdnBatchStage, GdnNativeFormat,
GemmShape, HISTORY_WORDS, HV, Kernel, N, Result, Role, Step, ZV, ffi, linear,
};
impl<'lease, 'ctx> GdnBatchPrefix<'lease, 'ctx> {
/// Native `attn_qkv` projection: dequantize to FP16, `Y[T,10240] = X . W^T`
@@ -2,8 +2,11 @@
//! Functions: `fetched_history`, `history_words`. Defines `Fenced`.
use super::native_projection::{NativeProjection, ProjectionOperands};
#[allow(unused_imports)]
use super::*;
use super::{
DeviceBuffer, Drained, Error, F16, F32, GDN_BATCH_EPSILON, GdnBatchCompletion, GdnBatchPrefix, GdnBatchStage,
GdnNativeFormat, HISTORY_WORDS, HV, Kernel, N, Result, Role, S, STATE_WORDS, STATUS_BYTES, Step, ZV, combine,
decode_statuses, ffi, staging,
};
impl<'lease, 'ctx> GdnBatchPrefix<'lease, 'ctx> {
/// `gdn_rec_cols_pipe`: the whole-chunk recurrence. `state_in` is the
@@ -1,8 +1,11 @@
//! Methods of `Kernel`: `entry`, `is_dequant`, `index`.
//! Methods of `GdnNativeFormat`: `ggml_type`, `block`, `kernel`, `matrix_bytes`.
#[allow(unused_imports)]
use super::*;
use super::{
Bindings, C, DEQUANT_PTX_LEN, DEQUANT_PTX_SHA256, Error, F16, F32, Functions, GdnBatchStage, GdnNativeFormat,
GdnStream, HISTORY_WORDS, HV, Kernel, N, PREFILL_PTX_LEN, PREFILL_PTX_SHA256, ROLES, Result, Role, SLOTS, STAGES,
STATE_WORDS, STATUS_BYTES, Step, ZV, ffi,
};
pub(super) fn pinned(ptx: &'static [u8], len: usize, digest: [u8; 32], what: &'static str) -> Result<&'static [u8]> {
if ptx.last() != Some(&0) || !ptx[..ptx.len() - 1].is_ascii() || ptx[..ptx.len() - 1].contains(&0) {
@@ -1,8 +1,7 @@
//! Methods of `GdnPrefillBatch`: `close_inner`, `release_status`, `release_module`.
//! Implements `Drop for GdnPrefillBatch`. Functions: `staging`.
#[allow(unused_imports)]
use super::*;
use super::{DeviceBuffer, Error, GdnPrefillBatch, Result, combine, ffi};
pub(super) fn staging(bytes: usize) -> Result<Vec<u8>> {
let mut result = Vec::new();
@@ -2,7 +2,7 @@
//! native FP16 dequantization module. Every launch owns its own stable Box so
//! the pointees never move between enqueue and the single final synchronize.
//! Declared as a child of `ffi` (like `mmq_ffi.rs`) for access to `BufferHandle`.
use super::*;
use super::{BufferHandle, Error, Result};
use std::ffi::c_void;
/// Most parameters any kernel of the two modules takes.
@@ -1,8 +1,7 @@
//! Functions: `bytes_of`, `words_of`, `halves_of`, `f16_bits` and 15 more. Defines `Projections`.
//! Split out of `gpu` to keep its files under the line limit.
#[allow(unused_imports)]
use super::*;
use super::{C, EPS, HISTORY_WORDS, HV, HostInputs, Q8_0_BLOCK, Reference, S, ZV};
// ---------------------------------------------------------------- host numerics helpers
pub(super) fn bytes_of(values: &[f32]) -> Vec<u8> {
@@ -1,8 +1,11 @@
//! Methods of `HostGemm`: `run`, `poison_output`, `capture`. Methods of `Fixture`: `new`, `release`.
//! Implements `GdnGemm for HostGemm`. Functions: `host_gemm`, `upload`, `read`, `mismatch`.
#[allow(unused_imports)]
use super::*;
use super::{
C, Context, DeviceBuffer, Error, Fixture, FixtureInputs, FixtureOutputs, GdnGemm, GdnStream, GemmShape,
HISTORY_WORDS, HV, HostGemm, HostInputs, N, Poison, Result, S, STATE_WORDS, ZV, bf_bits, bf_value, bytes_of,
combine, f16_value, halves_of, pattern, q8_0, words_of,
};
impl HostGemm {
pub(super) fn run(&self, bf16: bool, [x, w, y]: [&DeviceBuffer<'_>; 3], shape: GemmShape) -> Result<()> {
@@ -1,8 +1,11 @@
//! Functions: `run_case`, `check_case`, `push_program`, `inputs_untouched` and 8 more.
//! Split out of `gpu` to keep its files under the line limit.
#[allow(unused_imports)]
use super::*;
use super::{
C, Captured, Cell, Context, Error, Fixture, GdnBatchPrefix, GdnBatchStage, GdnNativeFormat, GdnPrefillBatch, HV,
HostGemm, N, Poison, Projections, RefCell, Reference, Result, ZV, bf_bits, bf_value, bytes_of, close, combine,
f16_bits, f16_value, halves_of, mismatch, q8_0, read, reference, words_of,
};
/// One complete program for `tokens` rows; returns the completion and, when the
/// program finished clean, the checks against the host reference.
+5 -1
View File
@@ -1,6 +1,10 @@
//! Literal Original prompt GDN over the physical R/GR arena. No mixed or Block
//! payload roundtrip and no fabricated DeviceBuffer for a carved span.
use super::*;
use super::{
Bindings, C, Context, DeviceBuffer, Error, Functions, GDN_BATCH_EPSILON, GdnBatchStage, GdnNativeFormat,
GdnPrefillBatch, GdnStream, HISTORY_WORDS, HV, Kernel, N, Result, Role, S, SLOTS, STATE_WORDS, STATUS_BYTES, ZV,
combine, decode_statuses, ffi, linear, staging,
};
use crate::original_prefill_arena::OriginalPromptSpan;
use crate::original_prefill_layout::PrefillPhase;
use crate::ple_batch_ffi::{BatchArg as A, KernelArguments, KernelModule};
@@ -1,8 +1,7 @@
//! Methods of `Context`: `original_gdn_prompt_device`, `original_gdn_prompt_device_with`.
//! Split out of `prompt_device` to keep its files under the line limit.
#[allow(unused_imports)]
use super::*;
use super::{Context, GdnPromptOptions, OriginalGdnPromptDevice, Result};
impl<'ctx> Context<'ctx> {
pub fn original_gdn_prompt_device(
@@ -1,8 +1,13 @@
//! Groups the submodules `gdn_prompt_run_buffer_binder`, `original_gdn_prompt_device_admit_open`, `original_gdn_prom...
//! Split out of `prompt_device` to keep its files under the line limit.
#[allow(unused_imports)]
use super::*;
use super::{
A, Bindings, C, Context, DeviceBuffer, DeviceCommand, Error, Functions, GDN_BATCH_EPSILON, GdnBatchStage,
GdnNativeFormat, GdnPrefillBatch, GdnPromptOptions, GdnStream, HISTORY, HISTORY_WORDS, HV, Kernel, KernelArguments,
KernelModule, N, NativeBatchWorkspace, OriginalDeviceBlock, OriginalDeviceGrRead, OriginalGdnPromptDevice,
OriginalGdnPromptState, OriginalGdnPromptWeights, OriginalPromptSpan, PrefillPhase, RESERVE, Result, Role, S,
SCRATCH, SLOTS, STATE_WORDS, STATUS_BYTES, ZV, combine, decode_statuses, ffi, linear, staging,
};
#[path = "original_gdn_prompt_device/gdn_prompt_run_buffer_binder.rs"]
mod gdn_prompt_run_buffer_binder;
@@ -1,8 +1,10 @@
//! 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 super::{
Bindings, Context, DeviceBuffer, Error, NativeBatchWorkspace, OriginalPromptSpan, PrefillPhase, Result, Role,
STATUS_BYTES, ffi,
};
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.
@@ -1,8 +1,10 @@
//! Methods of `OriginalGdnPromptDevice`: `device_bytes`, `new`, `admit_budget`, `open` and 2 more.
//! Split out of `original_gdn_prompt_device` to keep its files under the line limit.
#[allow(unused_imports)]
use super::*;
use super::{
Context, DeviceBuffer, Error, GdnPrefillBatch, GdnPromptOptions, HISTORY, OriginalGdnPromptDevice, RESERVE, Result,
SCRATCH, STATUS_BYTES, TensorCoreState,
};
impl<'ctx> OriginalGdnPromptDevice<'ctx> {
pub fn device_bytes(capacity: usize) -> Result<usize> {
@@ -1,8 +1,7 @@
//! Methods of `OriginalGdnPromptDevice`: `close`, `close_inner`, `release_stage`, `release_batch`.
//! Functions: `release_buffer`.
#[allow(unused_imports)]
use super::*;
use super::{Context, DeviceBuffer, Error, GdnPrefillBatch, KernelModule, OriginalGdnPromptDevice, Result, combine};
/// Releases one buffer, or leaks it when the context is poisoned (nothing may be freed against an uncertain one).
fn release_buffer(context: &Context<'_>, b: DeviceBuffer<'_>) -> Result<()> {
@@ -2,8 +2,10 @@
//! 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 super::{
DeviceCommand, Error, GdnBatchStage, GdnStream, HISTORY, HISTORY_WORDS, Handles, KernelModule,
NativeBatchWorkspace, OriginalGdnPromptDevice, Result, SLOTS, STATUS_BYTES, combine, decode_statuses, ffi, staging,
};
use crate::CurrentGuard;
use crate::ple_batch_ffi::{GdnGemmLayout, GemmDims, GemmOperands, LinearLaunch};
@@ -1,8 +1,11 @@
//! Methods of `OriginalGdnPromptDevice`: `produce`, `admit`, `admit_handles`, `admit_state` and 4 more.
//! `produce` admits the buffers, records the command list (`prompt_command_list.rs`) and drains it (`original_gdn_pr...
#[allow(unused_imports)]
use super::*;
use super::{
Binder, Bindings, C, Carve, Carved, DeviceBuffer, Error, HISTORY, HISTORY_WORDS, HV, Handles, N,
NativeBatchWorkspace, OriginalDeviceBlock, OriginalDeviceGrRead, OriginalGdnPromptDevice, OriginalGdnPromptState,
OriginalGdnPromptWeights, OriginalPromptSpan, Phase, Result, Role, S, SCRATCH, STATE_WORDS, ZV, ffi,
};
use crate::OriginalPromptRows;
impl<'ctx> OriginalGdnPromptDevice<'ctx> {
@@ -1,8 +1,10 @@
//! 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::*;
use super::{
A, C, Context, DeviceCommand, Error, Functions, GDN_BATCH_EPSILON, GdnBatchStage, GdnNativeFormat, HV, Handles,
Kernel, KernelArguments, N, OriginalGdnPromptDevice, Result, SCRATCH, SLOTS, STATUS_BYTES, ZV, ffi, linear,
};
use crate::gdn_prefill_tc as tc;
/// The commands of one run under construction.
@@ -5,8 +5,9 @@
//! recurrence (every command of a run is on one stream; the projections' dequantization wrote it before and the
//! output projection's rewrites it after), so it costs no device memory and the prefill budget is unchanged.
#[allow(unused_imports)]
use super::*;
use super::{Error, KernelArguments, KernelModule, OriginalGdnPromptDevice, Result, SCRATCH, combine};
#[cfg(test)]
use super::GdnPromptOptions;
use crate::gdn_prefill_tc as tc;
use crate::ple_batch_ffi::LinearLaunch;
@@ -1,8 +1,7 @@
//! Implements `Drop for OriginalGdnPromptDevice`.
//! Split out of `prompt_device` to keep its files under the line limit.
#[allow(unused_imports)]
use super::*;
use super::OriginalGdnPromptDevice;
impl Drop for OriginalGdnPromptDevice<'_> {
fn drop(&mut self) {
@@ -1,6 +1,6 @@
//! Closed complete finite witness for the canonical GDN next-state allocation.
//! Reuses the pinned integer exponent scan; performs no floating-point arithmetic.
use super::*;
use super::{Context, DeviceBuffer, Error, Rc, Result, combine, ffi};
const STATE_BYTES: usize = 3_145_728;
const STATE_WORDS: u32 = 786_432;
@@ -1,6 +1,6 @@
//! Closed upload scheduling for the original BatchGrInject kernel.
//! Raw completed output is not a model, finite, row or publication certificate.
use super::*;
use super::{Arguments, Context, DeviceBuffer, Error, Operation, Result, combine, ffi, qwen_ffi, ranges_layout};
const ROW_BYTES: [usize; 4] = [40960, 10240, 16, 40960];
const RESERVE: usize = 128 * 1024 * 1024;
+4 -1
View File
@@ -2,7 +2,10 @@
//! loop: all actual row offsets are admitted before one queued completion.
//! This preserves MMVF F32 operands/reduction; it does not claim Strata GEMM
//! rounding equivalence or expose a model/row/finite capability.
use super::*;
use super::{
Arguments, Context, DeviceBuffer, Error, FixedKernel, Operation, Result, combine, ffi, qwen_ffi, ranges_layout,
registered,
};
const SIZES: [usize; 11] = [40960, 40960, 1280, 1280, 40960, 40960, 10240, 16, 10240, 40960, 32];
const OPS: [Operation; 6] = [
@@ -1,8 +1,7 @@
//! Methods of `Context`: `gr_microbatch_read`. Functions: `checked_row`, `encode`.
//! Split out of `gr_batch_read` to keep its files under the line limit.
#[allow(unused_imports)]
use super::*;
use super::{Context, Error, GrMicrobatchRead, Result};
impl Context<'_> {
pub fn gr_microbatch_read(&self, tokens: usize, streams: &[f32]) -> Result<GrMicrobatchRead<'_>> {
@@ -1,8 +1,10 @@
//! Groups the submodules `gr_microbatch_read_inject`, `gr_microbatch_read_open`, `micro_stage_launch`.
//! Split out of `gr_batch_read` to keep its files under the line limit.
#[allow(unused_imports)]
use super::*;
use super::{
Arguments, Context, DeviceBuffer, Error, FixedKernel, GrMicroValues, GrMicrobatchRead, OPS, Operation, RESERVE,
Result, SIZES, STAGES, checked_row, combine, decode, encode, ffi, qwen_ffi, ranges_layout, registered,
};
#[path = "gr_microbatch_read/gr_microbatch_read_inject.rs"]
mod gr_microbatch_read_inject;
@@ -1,8 +1,10 @@
//! Methods of `GrMicrobatchRead`: `inject`, `inject_handles`, `inject_admit`, `inject_arguments` and 11 more.
//! Split out of `gr_microbatch_read` to keep its files under the line limit.
#[allow(unused_imports)]
use super::*;
use super::{
Arguments, Error, FixedKernel, GrMicrobatchRead, Operation, Result, combine, decode, encode, ffi, qwen_ffi,
ranges_layout, registered,
};
impl<'ctx> GrMicrobatchRead<'ctx> {
/// Original residual write consumes retained real input and injection banks.
@@ -1,8 +1,10 @@
//! Methods of `GrMicrobatchRead`: `new`, `admit_inputs`, `open`, `load_finite` and 10 more.
//! Split out of `gr_microbatch_read` to keep its files under the line limit.
#[allow(unused_imports)]
use super::*;
use super::{
Arguments, Context, DeviceBuffer, Error, GrMicrobatchRead, OPS, Operation, RESERVE, Result, SIZES, checked_row,
combine, encode, ffi, qwen_ffi, ranges_layout,
};
impl<'ctx> GrMicrobatchRead<'ctx> {
pub(in super::super) fn new(context: &'ctx Context<'ctx>, tokens: usize, streams: &[f32]) -> Result<Self> {
@@ -1,8 +1,10 @@
//! Methods of `GrMicrobatchRead`: `read`, `micro_kernels_guarded`, `micro_enqueue`, `micro_complete` and 6 more.
//! Defines `MicroKernels`.
#[allow(unused_imports)]
use super::*;
use super::{
Arguments, DeviceBuffer, Error, FixedKernel, GrMicroValues, GrMicrobatchRead, OPS, Result, SIZES, STAGES, combine,
decode, ffi, qwen_ffi, registered,
};
/// The six registered GR kernels and the finite-scan function of one micro-batch launch.
#[derive(Clone, Copy)]
@@ -1,8 +1,7 @@
//! Implements `Drop for GrMicrobatchRead`. Functions: `decode`.
//! Split out of `gr_batch_read` to keep its files under the line limit.
#[allow(unused_imports)]
use super::*;
use super::{DeviceBuffer, Error, GrMicrobatchRead, Result};
impl Drop for GrMicrobatchRead<'_> {
fn drop(&mut self) {
+1 -1
View File
@@ -1,6 +1,6 @@
//! Explicit Original Strata whole-T GR norm/BF16 GEMM/mix/write owner.
//! No MMVF substitution and no env inference. Root-sealed asset required.
use super::*;
use super::{Context, DeviceBuffer, Error, Result, combine, ffi};
use crate::ple_batch_ffi::{BatchArg as A, Blas, KernelArguments, KernelModule};
use crate::{CurrentGuard, NativeBatchWorkspace};
use std::ffi::CStr;

Some files were not shown because too many files have changed in this diff Show More