pub struct Glm5NextKdaLayer {
pub layer_idx: usize,
pub cfg: Glm5NextKdaConfig,
pub weights: Glm5NextKdaWeights,
pub kernels: Glm5NextKdaKernels,
}Expand description
2026-09-25: One bound KDA attention block.
Fields§
§layer_idx: usize2026-09-25: The checkpoint layer index this block was bound from.
cfg: Glm5NextKdaConfig§weights: Glm5NextKdaWeights§kernels: Glm5NextKdaKernelsImplementations§
Source§impl Glm5NextKdaLayer
impl Glm5NextKdaLayer
Sourcepub fn decode(
&self,
gpu: &dyn GpuBackend,
hidden: DevicePtr,
state: &KdaSeqState,
ws: &Glm5NextKdaWorkspace,
stream: u64,
) -> Result<()>
pub fn decode( &self, gpu: &dyn GpuBackend, hidden: DevicePtr, state: &KdaSeqState, ws: &Glm5NextKdaWorkspace, stream: u64, ) -> Result<()>
2026-09-25: Single-token decode, carrying both states. The result lands in ws.final_out;
state is updated in place.
Sourcepub fn decode_k(
&self,
gpu: &dyn GpuBackend,
hidden: DevicePtr,
k: usize,
state: &KdaSeqState,
ws: &Glm5NextKdaWorkspace,
snapshots: &[(DevicePtr, DevicePtr)],
stream: u64,
) -> Result<()>
pub fn decode_k( &self, gpu: &dyn GpuBackend, hidden: DevicePtr, k: usize, state: &KdaSeqState, ws: &Glm5NextKdaWorkspace, snapshots: &[(DevicePtr, DevicePtr)], stream: u64, ) -> Result<()>
2026-09-25: k tokens of one sequence: the projections batched, the recurrence one row at a
time. Used for the speculative verify, and for prefill sub-chunks that do not take the
chunked arm (glm5next_layer/steps/forward.rs).
front_end and back_end run once over all k rows. For 2 <= k <= DENSE_GEMV_BATCHM_MAX_M on a target with dense_gemv_bf16_batchm, the output matches k
serial Self::decode calls bit for bit: the batched GEMV gives each row the bits of the
M = 1 GEMV, the pack, gate, sigmoid and o_norm kernels treat rows independently, and
stateful_row walks the state one row at a time as decode does.
snapshots[t], (h_dst, conv_dst), receives the state after row t; rows past
snapshots.len() take no snapshot. Refuses k == 0 or k above the workspace.
Source§impl Glm5NextKdaLayer
impl Glm5NextKdaLayer
Sourcepub fn prefill(
&self,
gpu: &dyn GpuBackend,
hidden: DevicePtr,
t: usize,
state: &KdaSeqState,
ws: &Glm5NextKdaWorkspace,
stream: u64,
) -> Result<()>
pub fn prefill( &self, gpu: &dyn GpuBackend, hidden: DevicePtr, t: usize, state: &KdaSeqState, ws: &Glm5NextKdaWorkspace, stream: u64, ) -> Result<()>
2026-09-25: Chunked prefill over t tokens, starting from the carried state.
Sourcepub fn prefill_with_pad_fill(
&self,
gpu: &dyn GpuBackend,
hidden: DevicePtr,
t: usize,
state: &KdaSeqState,
ws: &Glm5NextKdaWorkspace,
pad_fill: f32,
stream: u64,
) -> Result<()>
pub fn prefill_with_pad_fill( &self, gpu: &dyn GpuBackend, hidden: DevicePtr, t: usize, state: &KdaSeqState, ws: &Glm5NextKdaWorkspace, pad_fill: f32, stream: u64, ) -> Result<()>
2026-09-25: Self::prefill with the padded q/k/v tails filled with pad_fill.
Self::prefill passes zero. The layer harness passes other values to show that
kda_chunk_* ignores positions at or past t in-kernel, which a zeroed tail cannot show.