Skip to main content

Module forward_shim

Module forward_shim 

Source
Expand description

What the older compiled forward runs whole (compile_to_cuda_forward*): its answer to the shared optimizer.

A lifted op is the forward’s exactly when its kernels compute it (kernel_refusal says why they do not otherwise). Its fused kernels are the ones its emitter writes:

• a sum and the RMS norm of it that is the next stage, as one row kernel writing the sum on (add_norm), the norm without a residual of its own over the whole of the sum; • a weighted RMS norm as one row kernel; • a run of elementwise ops, each carrying the last one’s result, as one register-carried kernel — the runs taken before a norm takes a sum, so a sum a run carries stays in its run; • under the single-pass int8 numerics, the activation a Q8_0 projection reads quantized in its producer’s epilogue — a norm’s, a sum-then-norm’s, an attention’s; • a sparse mixture as a top-k router, a gate-up kernel and a down-and-combine kernel, its Q8_0 matrices (the forward’s mixture manifest) dequantized inside the kernels that read them; • the whole forward captured as one CUDA graph.

It reads no part of a tensor in place and writes none into rows of another: every stage reads and writes whole buffers.

Structs§

ForwardShim
The older forward under its numerics.

Functions§

kernel_refusal
Why the forward’s kernels do not compute a lifted op, or None when they do. The spec is the op’s meaning: a field of it the kernel does not implement is a refusal, never a field the kernel ignores.