Expand description
memra inference runtime. Correctness-first: every GPU op is validated against a CPU reference before any sm_120 fast-path replaces it.
Re-exports§
pub use memra_gguf;
Structs§
- Gpu
- GPU runtime handle: a context + stream + cuBLASLt.
- GpuMain
Override - A rank-local CUDA scope nested inside another engine’s PP stage scope.
- Rank0
Redirect Guard - RAII scope for the rank0 redirect: clears on drop (panic-safe).
- Stream
Override - RAII scope: while alive,
Gpu::stream()on THIS thread returns the pushed stream. Nest freely (stack). Popping on Drop keeps panic paths consistent.
Functions§
- cpu_
linear - CPU reference matmul for a linear layer y = x @ W^T.
Conventions (ggml/GGUF): a weight tensor with ne=[in, out] is stored row-major as
outrows ofincontiguous elements — i.e. W[oin + i]. A linear layer computes y[o] = sum_i x[i] * W[oin + i], for each ofoutoutputs. Batched overmtokens: x: [m, in] row-major (x[tin + i]); w: [out, in] row-major (w[oin + i]); y: [m, out]. - decode_
phase - push_
stream_ override - Push a matched stream/cuBLASLt binding for the current thread until the guard drops.
- rank0_
redirect_ scope - set_
decode_ phase - TOKEN-PIPELINE phase (step37 chain): while
Some(p),enter_mainbinds each gpu’s phase-p stream instead of its main stream, so alternate tokens’ rank-local work rides disjoint streams. Cross-stream ordering is the SETTER’s job (the multi-stream law above): the chain wires per-layer KV events between phases. - set_
rank0_ redirect - Install/clear the rank0 redirect (ctx ordinal + stream/blas of the model engine).