Verace V0 Baseline
The lab's PyTorch implementation of the Kimi Team's hybrid linear-attention mixture-of-experts language model, from pretraining to serving.
- Fixed-size recurrent state: Kimi Delta Attention state, decayed per channel
- Gated NoPE latent attention: Used in every fourth layer and the last
- Delta-attention output: Passes a per-head norm and a sigmoid gate
- Delta-rule write: Write strength set per token by a sigmoid
Overview
Verace V0 Baseline is the lab's own code for the language model architecture described in a technical report by the Kimi Team (arXiv:2607.24653). The architecture is the Kimi Team's design. The implementation written from the report is the lab's. It is the starting point of the Verace V series, which builds on it in Verace V1 and later versions. The baseline addresses one question: can the full system in the report be reproduced as working code, covering the model, optimizer, data pipeline, post-training and serving path? The Kimi Team's own released tokenizer and reference model files sit alongside the code and are not the lab's work.
The model is a decoder that mixes two attention types. Most layers use Kimi Delta Attention, a linear attention whose fixed-size recurrent state decays per channel and is written with a delta rule. Every fourth layer, and the last, uses Gated NoPE Multi-Head Latent Attention. Block Attention Residuals replace the plain residual stream. Stable LatentMoE feed-forward layers route tokens with Quantile Balancing. These components, and SiTU-GLU, MoonViT, Per-Head Muon, the XTML chat template, MXFP quantization and MOPD distillation, are all the report's designs, implemented here by the lab.
The research implementation covers the configuration, every model module, a vision encoder, a draft model in the style of EAGLE-3, a speculative decoding method by other authors, for multi-token prediction and speculative decoding, the Per-Head Muon optimizer, streaming pretraining and SFT/RL dataloaders, a four-stage context curriculum, MOPD post-training, Triton kernels, a KDA prefix cache and a generation engine. The pretraining workspace holds a second copy of the same code. It also holds a copy of the BitNet b1.58 paper by other authors and a copy of a third-party GPT-2 fine-tuning codebase. The configuration records that its hyperparameters were cross-checked against the Kimi Team's released model.
The architecture, training loop, post-training step and serving path are implemented in code, and a single-device pretraining entry point with checkpointing exists. No training run, loss curve or benchmark score is recorded. The evaluator scores answers by substring match and ships only default toy samples. Several serving parts are reference stand-ins. The decode step has a pure PyTorch version of the fused kernel, and DRAM prefetch in the prefix cache only flips a flag. Whether the implementation matches the report's reported behaviour has not been measured.
Status
Prototype. The full architecture, training, post-training and serving code is implemented, but no training run or evaluation result is recorded.
Simulator
A row of tokens is read two ways at once: the newest token looks back at every earlier one, and every token is also written into one memory of fixed size that fades.
- looking back: one arc for every earlier token
- fixed memory: how much of each token it still holds
- newest token at the right
- Looking back, this token
- 23 comparisons
- Looking back, whole sequence
- 276 comparisons
- State kept: looking back / fixed
- 24 tokens / 1 state
- Fixed memory: a token is half faded after
- 4.3 tokens
Lengthen the sequence: the arcs multiply, the fixed memory stays one state. Lower the decay and it forgets sooner.
This simulator is an illustration of the principle, with made-up numbers. It does not run the lab's code or show the lab's data, and nothing in it is a measurement.
Architecture
Kimi Delta Attention layers
The report's linear attention layer, implemented with cached causal short convolutions, a delta-rule state update and lower-bounded per-channel decay. It has both a sequential path and a chunkwise path.
Gated NoPE latent attention
The report's Multi-Head Latent Attention variant without rotary position encoding. It uses low-rank query and key-value compression, FP32 attention and a sigmoid output gate, and caches the compressed latent.
Hybrid layer schedule
A configuration rule that sets every fourth layer and the final layer to latent attention and the rest to delta attention. The first layer uses a dense feed-forward block.
Block Attention Residuals
The report's residual scheme, implemented in
AttnResMixer. A layer's input is a learned softmax mixture of earlier block snapshots and the running residual.Stable LatentMoE
The report's mixture-of-experts layer in
StableLatentMoE, combining a full-width shared expert with 896 routed experts that run in a down-projected latent space. The code uses one shared expert of twice the expert width, while the report's table lists 2 shared experts.MoonViT vision encoder
The report's vision transformer for images and video. Its patch tokens are reduced and projected into placeholder positions in the language model's token sequence.
EAGLE-3 style draft model
A one-layer draft decoder,
EAGLE3DraftDecoderLayer, following EAGLE-3, a method by other authors, that fuses features from the backbone to predict tokens ahead. It is used for the multi-token prediction loss during training and for speculative acceptance at generation time.Per-Head Muon optimizer
The report's per-head variant of the Muon optimizer. Muon itself is by other authors. This variant orthogonalizes attention projection updates separately for each head.
Pretraining and context curriculum
A streaming domain-mixed dataloader, a pretraining step with cosine schedule, and
ProgressiveContextCurriculum. The curriculum raises sequence length in four stages from 8192 to 1048576 tokens.Post-training with MOPD
An SFT step and an on-policy RL step using the report's multi-teacher on-policy distillation reward. Data comes from conversations formatted in XTML with assistant-only action masks.
Serving stack
A generation engine with prefill and per-layer cache decoding, Triton kernels for SiTU-GLU and the KDA decode recurrence, and
KDAPrefixCacheManager, a prefix cache for delta-attention states.MXFP quantization
The report's block microscaling quantization, implemented as fake quantization in
MXLinearfor quantization-aware training.
Implementation
Mechanisms as they are implemented in the source code, with the constants the code uses.
- Delta-rule recurrence with decay
- Per token, the state of shape [b, h, d_k, d_v] is scaled row-wise by the decay , then updated as , and the output is . Queries and keys are L2-normalized SiLU outputs of a causal depthwise convolution with kernel 4. The write strength is .
- Lower-bounded channel-wise decay
- A low-rank projection plus bias produces the decay logit . The decay is with , and defaults to .
log_scale_Ais initialized per head to the log of a uniform draw between 1 and 16. - Chunkwise UT-transform form
- When
use_chunkwiseis set and the sequence length is divisible by 16, the sequence is split into 16-token chunks with cumulative decay . Each chunk solves the unit lower-triangular system . The output is . - Output gating and head norm
- The delta-attention output passes through a per-head RMSNorm, is multiplied by and is projected by .
GatedNoPEMLAapplies the same sigmoid gate before its output projection. - Latent attention projections
- Queries go from hidden to 1536, through RMSNorm, then to per-head widths of 128 plus 64. Keys and values come from a hidden-to-512-plus-64 projection. The 512 part is normalized and expanded per head, and the 64-wide slice is shared across heads with no rotary transform. Scores use scale in FP32 with a causal mask.
- Layer type assignment
is_mla_layerreturns true when or when is the last layer, withhybrid_kda_ratiodefaulting to 3. Layers with index belowfirst_k_dense_replace(default 1) use a dense SiTU-GLU feed-forward block of intermediate size 33792 instead of the MoE.- Attention residual mixing
- Each layer stacks committed block snapshots with the current prefix sum and scores each entry by a linear projection of its RMSNorm. The softmax-weighted sum is computed separately as the input to attention and to the feed-forward block. At layers where the index is a multiple of
attn_res_layers_per_block(default 12), the raw value is appended as a snapshot and the accumulator restarts. - SiTU-GLU activation
- The activation computes with , , and . The Triton kernel computes in fp32 with BLOCK_SIZE 1024.
- Normalized latent MoE
- The layer output is , where is the weighted sum of routed expert outputs on . Defaults are latent width 3584, expert hidden width 3072, 896 experts with 16 active, and a single shared feed-forward block of twice the expert hidden width. Only routed experts take
use_qat; the shared expert stays in full precision. - Quantile balancing router
- Scores are , and the router selects the top experts on score plus bias. The top-k weights are the unbiased scores normalized to sum to 1, and the -th biased score is the cutoff. In training, per-expert margins against the cutoff are sorted and . The bias is updated with a 0.9 weight on its previous value, with no auxiliary loss.
- Per-head Muon update
- Momentum is . The Newton-Schulz iteration normalizes and runs 5 steps of with and . Attention query, key and value projections are reshaped into heads and orthogonalized per head, while embeddings and the output head fall back to plain momentum.
- Draft fusion and LK loss
- Features from block snapshots 1 and 4 and the final hidden state are concatenated and mapped by
w_e3, which is initialized to , before the next-token embedding is added. The acceptance loss is , clamped at 1e-8 and averaged over at most 7 unroll steps. - Pretrain step and schedule
- The loss is shifted next-token cross-entropy plus 0.1 times a multi-token prediction cross-entropy against labels two positions ahead. Gradients are norm-clipped to 1.0, and after each step every 2D parameter is clamped to . The learning-rate factor warms up linearly, then follows for minimum ratio and progress .
- Domain-mixed data packing
- Domains are sampled with weights web 0.4, code 0.3, math 0.15 and knowledge 0.15, and documents end with EOS and are packed into fixed-length chunks. With synthetic long-range markers enabled and sequence length above 200, positions 100 and the hundredth from the end repeat the first token. Positions 128 to 191 become placeholder id 163605, paired with a random image tensor.
- MOPD reward and policy loss
- The per-token reward is times the action mask, computed without gradient. The teacher is chosen by a domain and effort key. The advantage is with verifier reward , and the loss is .
- MX block fake quantization
- The last dimension is padded to a multiple of 32 and split into blocks with shared scale . Values are clamped, rounded and rescaled, with of 448.0 for activations and 6.0 for weights.
MXLinearapplies this with a straight-through estimator wheneveruse_qatis set. - Prefix cache hashing
- A checkpoint stores the delta-attention state on CPU under a SHA-256 hash of the token prefix truncated to a multiple of 512. Lookup hashes prefixes at 512, 1024 and so on, keeps the last hit and stops at the first miss. The manager tracks a 6144-token page size and a pool of 1000 free pages; prefetching only clears a flag.
- Vision token reduction
- A 14x14 stride-14 convolution forms patches that pass through 27 blocks with residual width 1024 and QKV width 1536. Video adds one temporal attention block and averages frames in groups of 2. The patch grid is padded to even size, and each 2x2 neighbourhood is concatenated before an MLP projector.
- Speculative acceptance in generation
- After each target sample, the draft model proposes the next token from the current block features. If the target's next independent sample equals the draft, the token is emitted and one more target step runs in the same iteration. Sampling uses temperature with a 1e-5 floor.
Concepts
- Kimi Team technical report
- The source of the architecture the baseline implements (arXiv:2607.24653). Its named components are the Kimi Team's design; the code that implements them is the lab's.
- Linear attention
- An attention form that keeps a fixed-size state instead of a growing key-value cache, so each decode step costs the same regardless of context length. Kimi Delta Attention is the report's linear attention.
- Delta rule
- A state update that first removes what the state currently predicts for a key, then writes the new value. This lets the memory overwrite old associations instead of only adding to them.
- Hybrid attention
- Mixing cheap linear-attention layers with periodic full-attention layers. In the baseline, three delta-attention layers alternate with one latent-attention layer by default.
- Multi-Head Latent Attention
- Attention where keys and values are compressed into a small shared latent vector that is cached and expanded per head. This reduces cache memory. The report's variant drops rotary position encoding, hence NoPE.
- Block Attention Residuals
- The report's replacement for the plain residual sum. Each layer reads a learned weighted mixture of earlier block outputs instead of their unweighted sum.
- Mixture of experts
- A feed-forward layer made of many expert networks of which a router activates only a few per token. In the baseline, 16 of 896 routed experts are active, plus one shared expert.
- Quantile Balancing
- The report's method for keeping expert load even without an auxiliary loss. Per-expert biases are set from quantiles of routing margins, so each expert's share of tokens moves toward the target.
- SiTU-GLU
- The report's gated activation, in which both the gate and the up branch are soft-capped with tanh to bound their magnitude.
- Muon and Per-Head Muon
- Muon is an optimizer by other authors that orthogonalizes momentum updates with a Newton-Schulz iteration. The report's per-head variant applies the orthogonalization to each attention head separately.
- Multi-token prediction
- Training an extra head to predict tokens beyond the next one. In the baseline, an EAGLE-3 style draft model serves this role and also proposes tokens for speculative decoding.
- Speculative decoding
- A generation method in which a small draft model proposes tokens and the main model keeps those it agrees with, so more than one token can be emitted per main-model step.
- MOPD distillation
- The report's multi-teacher on-policy distillation. A student is rewarded per token by its log-probability gap to a teacher chosen for the task's domain and effort level.
- MXFP quantization
- The report's use of microscaling formats, in which each block of 32 values shares one power-of-two scale. The baseline uses fake quantization during training.
- XTML chat template
- The report's chat markup, built from open, separator and close tokens. It encodes messages, options, tool declarations, reasoning, responses and tool calls.
- MoonViT
- The report's vision transformer. Here it encodes images and video into tokens that are inserted at placeholder positions in the text sequence.
- Progressive context curriculum
- Raising training sequence length in stages. The baseline defines stages of 8192, 65536, 262144 and 1048576 tokens.
- BitNet b1.58 reference
- A paper by other authors on language models with ternary weights in , obtained by absmean scaling and rounding. A copy is kept with the pretraining workspace; it is not the lab's work and is not implemented in the baseline.
About this page
Written from the lab's own documents and source code. Figures and results are the lab's measurements as it recorded them at the time, and have not been independently replicated.
The Verace V series is the lab's line of language model architectures. It started from the lab's own code for the architecture described in a technical report by the Kimi Team (arXiv:2607.24653), listed here as the V0 baseline. Later versions replace the baseline's main parts with the lab's own designs and keep some of the report's components, which each page credits to the report.
Published under the PolyForm Noncommercial License 1.0.0: free for noncommercial use.