Expand description
2026-09-25: The full-attention transformer layer, Qwen3AttentionLayer:
its construction, kernel requirements, decode and prefill attention, and
the call into the layer’s FFN.
Owner: model-layers (attention). Invariants: none beyond the types.
Re-exports§
pub use innerq_driver::InnerQDriver;pub use types::Qwen3AttentionLayer;
Modules§
- helpers
- 2026-09-25:
Qwen3AttentionLayersetters that model loaders call after construction, the YaRN mscale helper, and small per-layer helpers (apply_layer_scalar,effective_attn_scale,nvfp4_decode_gemv,qsa_seq_state). - innerq_
driver - 2026-09-25: Host-side driver for InnerQ, the per-channel K equalization of the WHT-rotated (turbo) KV dtypes.
- types
- 2026-09-25: The
Qwen3AttentionLayerstruct: its weights, per-layer settings and resolved kernel handles.
Structs§
- Compressor
Weights - 2026-09-25: DeepSeek-V4 compressed-attention compressor weights, one per layer
with a non-zero
compress_ratiosentry. CSA layers use a 2×ratio overlapping window, HCA layers a single window. - Fp8Twin
Set - 2026-09-25: Which of the four attention projections get an FP8
[K, N]transposed twin built byQwen3AttentionLayer::transpose_fp8_for_prefill. - HcHead
Weights - 2026-09-25: Model-level HC head parameters: the final stream collapse before the LM head. Only the last model layer uses them.
- HcLow
Rank - 2026-09-25: The low-rank hyper-connection parameters for one site (qwen4_exp).
- HcSite
Weights - 2026-09-25: Hyper-connection (mHC) parameters for one site (attention or FFN).
The Sinkhorn fields are FP32; with
lowrankset they are NULL. - HcWeights
- MlaWeights
- 2026-09-25: MLA (multi-head latent attention) weights. Q is projected in two
steps:
input × wq_a → latent, theq_a_normRMS norm, thenlatent × wq_b → Q.
Constants§
- W8A8_
PREFILL_ KERNELS - 2026-09-25: The two
(module, function)pairs the W8A8 block-scaled prefill arm needs: the activation quantizer andfp8_gemm_t_blockscaled.
Statics§
- ATTN_
PHASE_ US - 2026-09-25: Per-phase host time in µs for the prefill attention path, written
only by
prefill/cache_skip.rs: 0 = the Q/K/V projections, 1 = from the projections to the BR=64 attention call, 2 = that attention call. No code writes slot 3. Summed across layers; the layer loop takes them once per prefill whenMETRALE_PREFILL_HOST_TIMING=1. - FFN_
HOST_ US - 2026-09-25: Host time in µs spent in the FFN of prefill attention layers,
added when
METRALE_PREFILL_HOST_TIMING=1. Summed across layers; the layer loop takes it once per prefill and reports the attention remainder as the in-layer time minus this.
Functions§
- add_
attn_ phase_ us - add_
ffn_ host_ us - take_
attn_ phase_ us - take_
ffn_ host_ us - validate_
required_ kv_ kernels - 2026-09-25: Startup check for one
--kv-cache-dtype: resolves every kernel the dtype’s dispatch needs (the reshape/decode pair, the chunked-prefill kernel and, for a WHT-rotated side, the WHT bookends) and errors with the full missing list. The server calls it beforebuild_model. Seekernel_requirements.rs. - w8a8_
prefill_ kernels_ loaded - 2026-09-25: Whether both
W8A8_PREFILL_KERNELSresolve on this backend (throughtry_kernel), without a constructed layer.