90 lines
2.6 KiB
Rust
90 lines
2.6 KiB
Rust
//! Same whole PLE operators in one completed, ordered finite-checked queue.
|
|
//! Completion owns real final readbacks; it has no session/row/history authority.
|
|
use super::*;
|
|
|
|
const SIZES: [usize; 14] =
|
|
[10240, 40960, 368640, 40960, 10240, 40960, 40960, 16, 40960, 40960, 40960, 368640, 40960, 40];
|
|
const CHARGE: usize = 1_085_496;
|
|
const RESERVE: usize = 128 * 1024 * 1024;
|
|
const OPS: [Operation; 6] = [
|
|
Operation::Bf16,
|
|
Operation::PleNorm,
|
|
Operation::PleGate,
|
|
Operation::PleBroadcast,
|
|
Operation::PleConv,
|
|
Operation::PleResidual,
|
|
];
|
|
const OUTPUTS: [usize; 10] = [3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
|
|
|
|
pub struct PleClosedWeights<'a, 'buffer> {
|
|
pub key: &'a DeviceBuffer<'buffer>,
|
|
pub value: &'a DeviceBuffer<'buffer>,
|
|
pub aux: [&'a DeviceBuffer<'buffer>; 4],
|
|
}
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
pub enum PleClosedRefusal {
|
|
Key,
|
|
Value,
|
|
KeyNorm,
|
|
QueryNorm,
|
|
Gate,
|
|
Gated,
|
|
Normalized,
|
|
Conv,
|
|
History,
|
|
Streams,
|
|
}
|
|
const REFUSALS: [PleClosedRefusal; 10] = [
|
|
PleClosedRefusal::Key,
|
|
PleClosedRefusal::Value,
|
|
PleClosedRefusal::KeyNorm,
|
|
PleClosedRefusal::QueryNorm,
|
|
PleClosedRefusal::Gate,
|
|
PleClosedRefusal::Gated,
|
|
PleClosedRefusal::Normalized,
|
|
PleClosedRefusal::Conv,
|
|
PleClosedRefusal::History,
|
|
PleClosedRefusal::Streams,
|
|
];
|
|
|
|
/// Fourteen exact whole owners; each call overwrites every actual role/status.
|
|
pub struct PleClosedQueue<'ctx> {
|
|
context: &'ctx Context<'ctx>,
|
|
buffers: [Option<DeviceBuffer<'ctx>>; 14],
|
|
module: Option<ffi::ModuleHandle>,
|
|
functions: Option<[ffi::FunctionHandle; 6]>,
|
|
finite: Option<[ffi::FunctionHandle; 2]>,
|
|
failed: bool,
|
|
}
|
|
pub type PleClosedParts = (Box<[f32]>, Box<[f32]>);
|
|
|
|
pub struct PleClosedCompletion<'loan, 'ctx> {
|
|
owner: &'loan mut PleClosedQueue<'ctx>,
|
|
flags: [u32; 10],
|
|
streams: Box<[f32]>,
|
|
history: Box<[f32]>,
|
|
}
|
|
enum Command {
|
|
Qwen(ffi::FunctionHandle, Operation, Box<Arguments>),
|
|
Guard(ffi::FunctionHandle, u32, ffi::MmqResidentArguments),
|
|
}
|
|
|
|
#[cfg(all(test, feature = "cuda-driver", any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))]
|
|
#[path = "ple_closed_queue_gpu.rs"]
|
|
mod gpu;
|
|
|
|
#[path = "ple_closed_queue/compose_phases.rs"]
|
|
mod compose_phases;
|
|
#[path = "ple_closed_queue/impl_pleclosedcompletion.rs"]
|
|
mod impl_pleclosedcompletion;
|
|
#[path = "ple_closed_queue/impl_pleclosedqueue_2.rs"]
|
|
mod impl_pleclosedqueue_2;
|
|
#[allow(unused_imports)]
|
|
use impl_pleclosedqueue_2::float_staging;
|
|
#[allow(unused_imports)]
|
|
use impl_pleclosedqueue_2::staging;
|
|
#[path = "ple_closed_queue/float_owner_fn.rs"]
|
|
mod float_owner_fn;
|
|
#[allow(unused_imports)]
|
|
use float_owner_fn::float_owner;
|