Module qwen3_5

Module qwen3_5 

Source
Expand description

2026-09-25: Single-token decode forward for one Qwen3.5 decoder layer, full attention or GDN, through &dyn GpuBackend and a QuantWeights impl.

Owner: model-layers. Invariants: none beyond the types.

forward_full_attention and forward_linear_attention each run norm, projections, attention or the GDN recurrence, the residual add with the post-attention norm, and the MLP with its residual. One token per call: the KV append writes position cache_pos, and attention is passed seq_len_attn as the cache length. Tokenizer, sampler and weight loading belong to the caller.

Structs§

FullAttentionLayer
FullAttentionScratch
2026-09-25: Scratch buffers for forward_full_attention.
LayerKvCache
2026-09-25: KV cache of one full-attention layer, for one sequence.
LinearAttentionLayer
LinearAttentionScratch
2026-09-25: Scratch buffers for forward_linear_attention.
LinearAttentionState
2026-09-25: Conv and GDN state of one linear-attention layer, carried from token to token. The caller allocates and zeroes it.
Qwen35ForwardConfig
2026-09-25: Dimensions of a Qwen3.5 checkpoint, read by both layer forwards.
Qwen35Kernels
2026-09-25: Kernel handles for both layer forwards, looked up once by Self::resolve.

Enums§

MetalKvDtype
2026-09-25: Storage format of the contiguous KV cache (LayerKvCache). Per-element sizes are what LayerKvCache::alloc allocates, scales included.

Functions§

forward_full_attention
2026-09-25: Runs one full-attention decoder layer for one token and returns scratch.x_out, which holds the layer’s output residual stream.
forward_linear_attention
2026-09-25: Runs one GDN decoder layer for one token and returns x_buf, into which the layer’s output residual stream (scratch.x_final) is copied. intra_dump, when given, receives named intermediate buffers after a stream synchronize.