Continual Pre-training GPT‑OSS‑120B

1. GPT‑OSS‑120B Design

1.1 MoE Shape

Depth-ordered interactive GPT‑OSS‑120B schema: prefix in → model layers → word out.

GPT‑OSS‑120B is a decoder-only sparse Mixture-of-Experts Transformer according to the released GPT‑OSS‑120B config. The residual stream is 2,880 wide, the vocabulary contains 201,088 tokens, and 36 decoder blocks sit between an untied input embedding and LM head. Every block contains shared attention plus a router and 128 distinct feed-forward experts. Routing is token-wise and layer-wise: each token selects four experts in every block, so only 3.125% of a layer’s expert pool is evaluated for that token.

The underlying decoder-block vocabulary—masked self-attention, multi-head projections, position-wise FFNs, residual paths, and normalization—is developed step by step in the earlier Self-Attention Layer and The Transformers Architecture article. GPT‑OSS retains that Transformer skeleton while replacing each dense feed-forward sublayer with a routed expert pool and using its GPT‑OSS-specific attention, normalization, and positional choices.

Component Exact logical parameters Derivation
One expert 24,891,840 gate/up: 2 × 2,880 × 2,880 + 5,760 bias; down: 2,880 × 2,880 + 2,880 bias
128 experts in one layer 3,186,155,520 128 × one expert
Attention in one layer 26,550,144 Q/K/V/O weights and biases plus 64 attention sinks
Router in one layer 368,768 [128, 2,880] weight + [128] bias
Two RMSNorms in one layer 5,760 2 × 2,880
All 36 decoder blocks 115,670,886,912 36 × 3,213,080,192
Embedding + untied LM head 1,158,266,880 2 × 201,088 × 2,880
Model total 116,829,156,672 Exact sum from the released weight index

Experts contain 114.702B parameters—98.18% of the logical model—while all attention layers contain 0.956B, the two vocabulary matrices 1.158B, and routers plus norms about 0.013B. These totals come from the published tensor index and configuration. The commonly reported 5.1B active parameters per token can be reproduced more precisely as 36 × (four experts + attention + router + two norms) + one dense vocabulary projection + final norm = 5,132,849,472. The input embedding is a row lookup, so counting the whole embedding matrix again would not describe per-token compute.

1.2 Attention and Context

Attention uses grouped-query attention according to the released config: 64 query heads but only 8 key/value heads, each with head dimension 64. Q is projected from 2,880 to 4,096; K and V each project to 512; the output projection maps 4,096 back to the 2,880-wide residual stream. Sharing each KV head across eight query heads reduces KV-cache size. Human-numbered odd layers use 128-token sliding causal attention and even layers use full causal attention, producing 18 local and 18 global layers. The local layers control long-context cost, while every other full layer still permits global information flow.

Position information uses RoPE with YaRN scaling in the GPT‑OSS‑120B config: original context 4,096, scale factor 32, maximum position 131,072, rope_theta=150000, beta_fast=32, and beta_slow=1. Each layer also has 64 learned attention-sink scalars—one per query head—which give softmax probability a learned non-content destination instead of forcing all mass onto ordinary tokens. Attention projections include biases, attention dropout is zero, and RMSNorm uses epsilon 1e‑5.

For the geometric derivation of RoPE and the PI/NTK/YaRN context-extension family, see RoPE and M‑RoPE.

The router maps each normalized token state from 2,880 dimensions to 128 logits, chooses the top four, and softmax-normalizes those four logits to weight the sum of their outputs, matching num_local_experts=128 and num_experts_per_tok=4. The fused expert projection interleaves 2,880 gate and 2,880 up values. Its exact gated activation clamps gate to a maximum of 7, clamps up to ±7, and computes (up + 1) × gate × sigmoid(1.702 × gate); a 2,880 × 2,880 down projection then returns to the residual width. The released configuration sets swiglu_limit=7.0 and router_aux_loss_coef=0.9.

1.3 MXFP4 Weights

OpenAI’s GPT‑OSS repository states that the models were post-trained with MXFP4 quantization of the MoE weights, making GPT‑OSS‑120B run on a single 80GB-class accelerator; Hugging Face’s MXFP4 docs describe it as the GPT‑OSS-specific 4-bit floating-point path in Transformers. In this article, MXFP4 should be read as the released model’s inference/storage weight format for MoE experts, not as a full optimizer-state format for CPT or full fine-tuning.

MXFP4 is a microscaling format: the Microscaling Data Formats paper defines MX as a per-block scale combined with narrow per-element formats; MXFP4 uses 4-bit FP4 elements and an 8-bit shared scale. In the common OCP-style layout, a block stores 32 E2M1 FP4 values plus one E8M0 scale, giving 32 × 4 + 8 = 136 bits per block, or about 4.25 bits/value before metadata and packing overhead. The block scale preserves more dynamic range than plain INT4 because each local group can choose its own power-of-two scale.

MXFP4 does not make full training fit in 80GB. The released checkpoint’s quantization and sharding index converts expert projection blocks to MXFP4 but excludes attention, routers, embeddings, and the LM head. This explains inference on an approximately 80GB accelerator; full training still needs dequantized or master weights, gradients, optimizer states, activations, communication buffers, and checkpoints.

1.4 Design Choices

Why can head_dim=64 work? A useful community hypothesis applies Scientific Spaces’ n > 8.33 ln N dimensional heuristic, motivated by minimum entropy and the connection between attention and skip-gram. With the natural logarithm used by that article, the estimates are about 40.4 for a 128-token window, 69.3 for 4,096 tokens, and 98.2 for 131,072 tokens. Thus 64 is a plausible conventional dimension for a local 128-token head, but it does not satisfy the same heuristic for GPT‑OSS’s full-attention layers or 128k context. The original community calculation used log2 in places, which is not the convention evidenced by the source’s numerical examples. More importantly, this is a heuristic—not proof that OpenAI selected 64 for this reason. The released architecture compensates systemically: 64 query heads give Q width 4,096 despite a 2,880 residual width, eight KV heads keep the cache narrow, and local/full attention alternates. The related MLA analysis is helpful for understanding why larger head dimensions may add representational room, but “larger is always better” ignores head count, cache size, kernels, and the fixed compute budget.

hidden_size = intermediate_size = 2,880 is not a dense MLP ratio of four. The official MoE forward pass sends the same normalized token to four independently parameterized experts, applies each expert’s gated nonlinearity and down projection, then takes a router-weighted sum. It does not concatenate the four experts into one 11,520-wide dense FFN. It is still useful to say that one token evaluates four separate 2,880-wide intermediate branches—11,520 intermediate scalar activations in aggregate—and therefore pays roughly the parameter/compute of four same-width experts, but the routing and nonlinear mixture are mathematically different from one width-11,520 layer. The common ReLU rank-loss argument in the linked FFN expansion discussion assumes a particular independent-zero model and does not transfer directly to GPT‑OSS’s clipped gated-SwiGLU. Superposition and the Transformer-circuits framework motivate richer feature spaces, but do not prescribe an exact ratio. In practice, dimensions should also be benchmarked on the target stack: hardware/model co-design reports up to 39% throughput differences between shape choices at comparable parameter counts, so an A100 microbenchmark result such as an MLP ratio near 2.7 is hardware-, kernel-, dtype-, and batch-specific rather than universal.

Biases and clipping are real; the optimizer story is unknown. The released reference code contains router, fused gate/up, and down-projection biases. It also clamps the gate at 7, clamps the up branch to ±7, adds 1 to the up branch, and evaluates (up + 1) × gate × sigmoid(1.702 × gate). Bounding expert activations is plausibly friendly to low-precision expert weights and outliers, but OpenAI has not published that causal rationale. Likewise, the presence of MLP biases does not establish whether Muon or any other optimizer was or was not used; the original optimizer and state remain undisclosed.

The receptive field is global every other layer. The official mask construction applies a 128-token sliding window to zero-indexed even layers and full causal attention to odd layers. Multiplying 128 × 36 = 4,608 is therefore not GPT‑OSS’s receptive field. Even in a hypothetical all-local stack, a careful token-count bound is approximately 1 + L × (W − 1), not simply L × W; in the real alternating stack, each full layer can already attend to the entire allowed prefix, up to the configured 131,072 positions. Local layers reduce attention cost between global layers rather than limiting the whole model to roughly 4k context.

Attention sinks are not KV shifting or four sink tokens. In OpenAI’s reference SDPA, the model owns 64 learned sink scalars—one per query head—concatenates one sink logit to each attention-score row, performs softmax, then discards the sink probability before multiplying by V. There is no learned sink K/V vector and no sink_token=4; four is the number of active MoE experts. KV Shifting Attention instead shifts key/value states to make induction easier and is a different mechanism. The sink gives attention a learned “none of the content tokens” destination, while KV shifting changes the content-bearing K/V computation.

UE8M0 is the scale behind MXFP4. The OCP MX specification defines an MXFP4 block as 32 E2M1 FP4 values sharing one E8M0 scale: 136 bits, or 4.25 bits per weight. NVIDIA calls the scale ue8m0: an unsigned exponent-only 8-bit float with no mantissa or infinity, with 0xff reserved for NaN and packed as ue8m0x2 in PTX. Newer Blackwell block-scaled MMA paths can consume MXFP4 with scale factors directly; other runtimes may dequantize or use different kernels. Finally, “FP4 is only deployment quantization” is incomplete for GPT‑OSS: the model card says OpenAI post-trained with MoE weights quantized to MXFP4. That does not mean original pre-training or optimizer states were FP4, but it is more than an after-the-fact deployment conversion.

1.5 Qwen3.5 Contrast

Qwen3.5‑35B‑A3B is a useful sparse-MoE contrast because it targets similar active compute with a very different backbone. It is an Apache‑2.0, natively multimodal causal model with a vision encoder, 35B total parameters, approximately 3B activated parameters, a 2,048-wide text stream, 248,320 padded vocabulary entries, and 40 text layers. Its published layout is 10 × [3 × (Gated DeltaNet → MoE) → 1 × (Gated Attention → MoE)]: 30 recurrent linear-attention layers alternate with ten full-attention layers instead of GPT‑OSS’s 18 sliding-window and 18 full-attention layers. The released model is post-trained; the separate Base checkpoint is the pre-trained starting point intended for further training.

Property Qwen3.5‑35B‑A3B GPT‑OSS‑120B
Modalities Native text, image, and video Text only
Logical / active parameters 35B / ≈3B 116.8B / ≈5.13B
Depth and width 40 layers, width 2,048 36 layers, width 2,880
Sequence mixer 30 Gated DeltaNet + 10 gated full-attention layers 18 sliding-window + 18 full-attention layers
MoE per layer 256 routed experts; top 8 + one shared; expert width 512 128 routed experts; top 4; expert width 2,880
Native context 262,144; YaRN extension to 1,010,000 131,072 via YaRN from 4,096
Conversation contract Qwen template, <think>, multimodal/tool tags Harmony roles, channels, recipients, and effort

The exact Qwen3.5 config makes the hybrid block concrete. Gated DeltaNet uses 32 value heads and 16 Q/K heads at dimension 128 plus a four-wide local convolution. Full gated attention uses 16 query heads, two KV heads, head dimension 256, output gating, and a 64-dimensional rotary subspace with interleaved multimodal RoPE sections 11/11/10 and rope_theta=10,000,000. Every layer has 256 routed experts, chooses eight, and also evaluates one shared expert; routing therefore combines sparse specialization with a dense path available to every token, with router_aux_loss_coef=0.001. Input and output embeddings are untied. One MTP layer predicts additional future tokens during training. The vision tower has 27 layers, width 1,152, intermediate width 4,304, 16 heads, 16×16 spatial patches, temporal patch size two, and 2× spatial merging before projection to the 2,048-wide language stream.

The release config stores BF16 tensors, whereas the Qwen3.5 training report describes a native FP8 training pipeline that applies low precision to activations, MoE routing, and matrix multiplications while retaining BF16 in sensitive operations. That is training arithmetic, not the same artifact as GPT‑OSS’s MXFP4 expert-weight representation. The same report attributes Qwen3.5’s throughput to early-fusion text/image/video training, heterogeneous parallelism for vision and language, a 248k multilingual vocabulary, and sparse computation; it reports support for 201 languages and dialects. Those are Qwen3.5-family facts, not a fully reproducible 35B-specific optimizer recipe.

The official model card reports both language and vision evaluations: for example, Qwen3.5‑35B‑A3B scores 85.3 on MMLU‑Pro, 84.2 on GPQA Diamond, 69.2 on SWE‑bench Verified, 81.4 on MMMU, and 71.1 on AndroidWorld under Qwen’s stated setups. These are vendor-reported numbers, not an independent apples-to-apples ranking; their value here is to show that the 3B-active model targets reasoning, coding, agents, and vision jointly rather than text perplexity alone.

2. Training Regimes

2.1 Scope and Goals

OpenAI released GPT‑OSS as open-weight models with native Harmony usage, and the GPT‑OSS‑120B weights/config are public; OpenAI has not released the original optimizer state, terminal learning rate, total pre-training tokens, or an official continued-pretraining recipe. The values below are engineering starting points triangulated from direct GPT‑OSS fine-tuning recipes and public large-model training runs. GPT‑OSS‑120B has about 117B total parameters from the released tensor shapes and roughly 5.1B active parameters per token; its MXFP4 80GB inference footprint does not imply that full-parameter AdamW training fits on one 80GB GPU.

“Mid-training” often conflates four optimization regimes. Continued pretraining changes knowledge, language, or domain distribution through next-token prediction on raw text and code. SFT teaches instruction following, format, tool use, and task mappings. DPO learns preference boundaries from chosen/rejected pairs. Online RL learns a policy from rollouts and rewards, as in the open Agent Factory 3 GPT‑OSS experiments. Model size alone cannot determine the learning rate.

Stage Training signal Primary goal Do not copy
CPT / domain adaptation Raw text, code, documents Change knowledge or domain distribution SFT/DPO sequence batches
Full SFT Supervised conversations Behavior, format, tools Million-token CPT batches
LoRA SFT Supervised conversations Low-cost behavior adaptation Full-parameter LR assumptions
DPO Chosen/rejected pairs Preference alignment CPT-scale learning rates
Online RL / RLVR Rollouts and rewards Agent policy Static-dataset batch descriptions

2.2 LR and Scale

Purpose Initial / peak LR Schedule Global batch Source basis
Narrow CPT, <5B tokens 5e‑6–2e‑5; start 1e‑5 Cosine; 1–2% warmup for a reset optimizer; finish near peak/30–peak/100 0.25–1M tokens/update Reuse + Code Llama extrapolation
Domain CPT, 20–100B tokens 1e‑5–4e‑5; start 2e‑5 Cosine; 0.5–1% warmup 1–4M tokens/update OLMo 100B, Code Llama, Reuse
Full SFT 2e‑6–2e‑5; broad SFT starts at 5e‑6–1e‑5 Linear/cosine or constant+warmup; ~3% 16–128 sequences/update Axolotl 120B + Tülu 70B
LoRA SFT 5e‑5–2e‑4; start 1e‑4 Cosine; 3% warmup; optionally retain 10% final LR 8–32 sequences/update OpenAI GPT‑OSS LoRA
DPO 1e‑7–5e‑7; start 2e‑7 Linear; 10% warmup 64–128 pairs/update Tülu 3 DPO
120B agentic RL Undisclosed for public full runs; LoRA pilot 1e‑6–5e‑6 sweep Algorithm-specific Report rollout/policy tokens Agent Factory 3

For domain CPT, run a short 1e‑5 → 2e‑5 → 4e‑5 sweep: this is an engineering interpolation between Axolotl’s direct GPT‑OSS‑120B SFT anchor, Reuse, Don’t Retrain’s scheduler study, and large CPT examples such as Code Llama. A true continuation with optimizer/scheduler state may need no warmup, but released GPT‑OSS weights do not provide that state; a short warmup is safer when AdamW is reinitialized. Track domain validation, general retention, instruction following, and downstream performance—not training loss alone.

Record unique examples or pairs, consumed tokens, and disk bytes separately. This mirrors the separation used by public data/recipe releases such as Tülu 3, OLMo 3, and Code Llama. The following storage column is only tokens × 4 bytes for int32 token IDs, not raw JSON/Parquet size.

Training tokens int32 token IDs Typical interpretation External anchor
1M 0.004 GB Small behavioral SFT OpenAI GPT‑OSS LoRA
100M 0.4 GB Medium post-training Tülu 3
1B 4 GB Large SFT / small CPT pilot Tülu 3
20B 80 GB Meaningful narrow-domain CPT Reuse CPT
100B 400 GB Formal mid-training ingredient OLMo 3
500B–1T 2–4 TB Large capability shift or specialization Code Llama

Behavioral SFT may need only 1k–50k high-quality examples, with OpenAI’s GPT‑OSS cookbook showing a 1k-example LoRA target; broad instruction tuning often uses 100k–1M conversations, with Tülu‑3 70B SFT as the full-parameter post-training anchor. A 0.1–5B-token CPT pilot tests feasibility, while 20–100B tokens is a credible main range for 70B/120B domain adaptation, anchored by OLMo 3’s 100B-token mid-training mix and the Reuse, Don’t Retrain CPT study. At 4M tokens/update, 100B tokens gives about 25,000 optimizer updates; using that batch on a 1B-token pilot gives only 250 updates.

2.3 Batch and Retention

global sequences = DP ranks × microbatch × gradient accumulation, matching the effective-batch definition in the Tülu 3 reproduction guide. With tensor or expert parallelism, DP ranks are not physical GPU count. For CPT, report the sum of non-padding tokens per optimizer update because packing and padding make sequence counts ambiguous; large CPT anchors such as Code Llama and OLMo 3 should be compared in tokens/update, not examples/update.

On 8×A100‑80GB, validate LoRA/SFT, Harmony labels, and loss correctness first; Axolotl’s published 8-card full-parameter run uses H100s plus CPU offload. On 32×A100‑80GB, FSDP2/ZeRO‑3 full FFT and CPT are more realistic. Extra GPUs should primarily reduce accumulation and wall-clock time rather than trigger linear LR scaling.

Do not feed domain data exclusively until the end. Use general replay, capability-related replay, staged mixtures, or checkpoint merging, following the retention concerns in Reuse, Don’t Retrain and the mixed-data design in Code Llama. Select mixture switches using both the LR trajectory and retention evaluations. A domain gain accompanied by immediate general-loss degradation is a signal to lower LR or increase replay—not simply to train on more tokens.

2.4 Qwen3.5 Training

The public evidence supports a training outline, not an exact recipe. According to the official Qwen3.5 report and model card, pre-training uses early fusion: text, image, and video are converted into a common token sequence and optimized together, with expanded multilingual, STEM, coding, and reasoning data under stricter filtering. The hybrid Gated DeltaNet/full-attention language backbone, vision encoder, sparse MoE, routers, and MTP objective are trained as one foundation model. Qwen reports a decoupled heterogeneous-parallel system that overlaps the vision and language components, near-text-only throughput for mixed multimodal training, and native FP8 execution with BF16 retained where numerical sensitivity requires it.

Post-training then adds instruction behavior, explicit thinking, tool use, visual reasoning, and agent policy. Qwen’s release description says reinforcement learning was scaled across million-agent environments with progressively harder task distributions; its asynchronous framework disaggregates rollout inference from training and adds dynamic load balancing and fault recovery across text, multimodal, and multi-turn environments. This tells us the direction—large heterogeneous SFT/RL and environment scaling—but not the exact 35B‑A3B SFT mixture, teacher models, reward composition, RL algorithm, rollout count, accepted-token count, optimizer, learning rate, batch, or total pre-training tokens. Those values are not publicly specified; the older Qwen3 four-stage recipe and larger Qwen3.5 variants must not be presented as the 35B checkpoint’s recipe.

For new CPT, start from Qwen3.5‑35B‑A3B‑Base when the goal is domain knowledge, then recover chat/tool behavior with the exact Qwen template. Starting from the post-trained checkpoint is defensible when preserving its existing instruction policy matters more than a clean base-model objective, but it creates the same forgetting/alignment tradeoff discussed for GPT‑OSS. A text-only CPT run may freeze the 27-layer vision tower; a joint multimodal CPT run must preserve image/video packing, multimodal RoPE positions, modality balance, and vision-language projection updates. These are engineering choices, not undisclosed Qwen settings.

3. Harmony Format

3.1 Roles and Channels

GPT‑OSS was post-trained on Harmony for conversation structure, reasoning, and function calls; the official Harmony guide states that self-hosted inference or training stacks must preserve this format. Harmony mirrors the conceptual shape of the Responses API and applies the hierarchy system > developer > user > assistant > tool.

Role Official purpose Source
system Model identity, knowledge cutoff/current date, reasoning effort, valid channels, and built-in tools Harmony guide
developer What other formats call the system prompt: instructions, function tools, and response formats Harmony guide
user User input Harmony guide
assistant Reasoning, tool calls, preambles, and final output Harmony guide
tool A tool result; the concrete tool name becomes the message author/role Harmony guide
Channel Meaning Operational rule Source
analysis Raw CoT and internal tool use Do not expose it to users; it is not trained to the same safety standard as final output Harmony guide
commentary Function calls and user-visible preambles Usually where functions are called; preambles may be displayed Harmony guide
final End-user response Display this channel to users Harmony guide

The system message should keep the standard model identity, include knowledge cutoff and current date, set Reasoning: low|medium|high (medium is the default), and declare analysis, commentary, final as valid channels, as specified in the OpenAI Harmony article. If developer-defined functions exist, it should say that calls to the functions namespace go to commentary. The developer message begins with instructions and may add # Tools or # Response Formats. Product identity/persona changes belong in developer instructions, not by rewriting the system identity.

Prefer the official openai_harmony renderer from PyPI or crates.io. It supplies typed system/developer content, converts JSON Schema tools to Harmony declarations, renders conversations to tokens, parses completion tokens back into messages, and provides a streaming parser exposing the current role, channel, content type, recipient, delta, and accumulated content. Streaming parsing also avoids breaking Unicode while decoding token-by-token.

encoding = load_harmony_encoding(HarmonyEncodingName.HARMONY_GPT_OSS)
prompt_tokens = encoding.render_conversation_for_completion(conversation, Role.ASSISTANT)
# Run the model; exclude the stop token from new_tokens.
messages = encoding.parse_messages_from_completion_tokens(new_tokens, Role.ASSISTANT)
stream = StreamableParser(encoding, role=Role.ASSISTANT)
Special token ID Meaning
<|start|> 200006 Start a message/header
<|end|> 200007 End a fully stored message
<|message|> 200008 Header-to-content boundary
<|channel|> 200005 Channel field in the header
<|constrain|> 200003 Tool-input content type, such as JSON
<|return|> 200002 Stop inference after a completed response
<|call|> 200012 Stop inference to execute a tool

3.2 Calls and State

A complete stored message is <|start|>{header}<|message|>{content}<|end|>, following the Harmony wire format. A completion begins at an assistant header, may emit multiple analysis messages, and ends with either <|return|> or <|call|>. The former is a decode-time stop token: normalize it to <|end|> before persisting the reply into the next prompt. Keep <|return|> at the end of supervised targets, while prior messages in a prompt should end in <|end|>.

Function tools live in the developer message under # Tools, normally inside a functions namespace, as shown in the OpenAI Harmony function-call examples. The official convention is TypeScript-like: a no-argument function is type name = () => any; argument-bearing functions receive a single _ object; comments describe fields; return type remains any; and definitions are separated by blank lines. Staying close to this representation improves tool-call accuracy.

<|channel|>analysis<|message|>Need current weather.<|end|>
<|start|>assistant<|channel|>commentary to=functions.get_current_weather
<|constrain|>json<|message|>{"location":"San Francisco"}<|call|>
<|start|>functions.get_current_weather to=assistant<|channel|>commentary
<|message|>{"sunny":true,"temperature":20}<|end|>
<|start|>assistant

The recipient may appear in the role or channel portion of the header according to Harmony parsing rules. After <|call|>, execute the function, append a tool-authored commentary message addressed to assistant, and resume sampling. A commentary message without a recipient can be a user-visible preamble—for example, an action plan before several calls—so it must not be treated as hidden CoT.

Conversation-state handling has two cases. After an assistant turn reaches final, remove its old analysis before the next user turn and keep the normalized final message, consistent with Harmony’s state guidance. During an unfinished tool/function chain, however, preserve the preceding analysis, call, and tool result when resuming generation; the model needs that chain to continue reasoning correctly. This distinction must be represented explicitly in SFT and agent trajectories.

3.3 Outputs and Loss

A structured response format belongs at the end of the developer message under # Response Formats, with a format name, optional description, and JSON Schema, as specified in the Harmony response-format section. Prompting the schema influences behavior but does not guarantee conformance; strict adherence requires grammar/constrained decoding during sampling.

GPT‑OSS was released with built-in tool behavior, and the Harmony guide describes built-in browser and Python tools in the system message rather than developer tools. Browser calls normally use the analysis channel with recipients such as browser.search, browser.open, and browser.find; Python calls use analysis with recipient python. Function tools defined by the developer normally use commentary. A runtime must still tolerate occasional channel variation described by the official guide.

For SFT, mask system, developer, user, and tool-output tokens; train current assistant analysis, commentary/calls, preambles when desired, and final output. This loss policy is an engineering choice derived from the Harmony channel semantics, OpenAI’s GPT‑OSS SFT notebook, and common supervised post-training practice in Tülu 3. Preserve all three reasoning efforts across comparable task families. For domain knowledge injection, begin with final loss weight 1.0 and analysis weight 0.2–0.5, or train analysis only on verifier-filtered traces. Validate raw messages → Harmony rendering → token IDs → labels → parsed messages, including <|return|>/<|end|> normalization and tool-resume exceptions.

Large-scale CPT should remain raw text/code causal-LM training, matching continued-pretraining work such as Reuse, Don’t Retrain, Code Llama, and OLMo 3; do not convert tens of billions of tokens into fake chats. Follow CPT with a smaller Harmony recovery SFT covering ordinary QA, low/medium/high reasoning, no-tool and tool trajectories, preambles, structured outputs, multi-turn final history, tool-chain continuation, and instruction conflicts.

3.4 Qwen3.5 Format

Qwen3.5 must not be rendered with Harmony. Its published chat template is ChatML-like: messages are delimited by <|im_start|> and <|im_end|>, the system message must come first, and ordinary roles are system, user, and assistant. There is no Harmony developer role, no analysis/commentary/final channel header, no recipient field, and no native Reasoning: low|medium|high control. Instead, enable_thinking=true opens <think>; disabling it emits an empty thinking block before the answer. The template can consume a separate reasoning_content field or split it from assistant content.

<|im_start|>system
You are a helpful assistant.<|im_end|>
<|im_start|>user
Explain the routing decision.<|im_end|>
<|im_start|>assistant
<think>...current-turn reasoning...</think>
...final answer...<|im_end|>

The template deliberately removes old reasoning before a new user query while keeping prior final answers, closely paralleling Harmony’s “do not replay completed CoT” rule even though the wire formats differ. For SFT, mask system/user prompts and tool responses; train the current assistant’s thinking plus final answer or tool call only when the trace is trusted. Do not train synthetic long thinking merely to increase length. Pair task difficulty with an appropriate reasoning budget, validate the split around <think>...</think>, and test multi-turn rendering so previous hidden traces cannot leak back into the prompt.

Tools are serialized differently as well. JSON tool schemas are injected into the system message under # Tools and <tools>; assistant calls use <tool_call><function=...><parameter=...>, and results appear inside <tool_response>. Multimodal content uses <|vision_start|><|image_pad|><|vision_end|> or the corresponding video pad. The Base model card notes that control tokens were already included during pre-training so parameter-efficient tuning need not modify the very large embedding matrix. Keep two separate render/parse test suites: one for Harmony/GPT‑OSS and one for Qwen3.5.

4. Training Practice

4.1 Runbook

For the general mechanics behind this parameter policy—how hard top‑k routing is trained, which experts receive gradients, and why “all parameters are trainable” does not mean that every weight changes on every step—see Which Parameters Update? in the companion MoE article. For GPT‑OSS‑120B full CPT this means the shared blocks, router, and all 128 experts per layer are trainable, while each token supplies a task gradient only to its selected four experts.

The parameter distribution from the published tensor index determines which adaptation method changes what. Attention-only LoRA touches a small shared subnetwork and is a strong first baseline for policy, tool use, and agent behavior, as shown by Agent Factory 3. Expert/MLP adaptation has much greater capacity for domain knowledge and generation-distribution shifts, but it also introduces routing imbalance and far larger optimizer/checkpoint costs, which is why the Axolotl 120B recipe emphasizes offload and checkpoint storage. Training the router changes which frozen or trainable experts receive tokens; freezing it stabilizes paths but may limit adaptation to a new domain. Always log per-layer expert selection frequency, routing entropy, tokens per expert, dropped/overflowed tokens if the implementation has capacity limits, and auxiliary router loss alongside domain and retention evaluations.

Public anchor Configuration Training lesson
Axolotl GPT‑OSS‑120B full SFT LR 2e‑5, BF16, FSDP2, activation checkpointing, CPU offload Sharding/offload and checkpoint storage dominate full 117B optimization
OpenAI GPT‑OSS‑20B LoRA SFT LR 2e‑4, 3% warmup, global batch 16 Validate Harmony, loss, and selected target modules before scaling
Agent Factory 3 GPT‑OSS‑120B RL Attention LoRA, frozen MoE/router, asynchronous rollout and routing replay Policy improvement can be tested without updating the 114.7B expert subsystem
  1. Lock model/tokenizer/config revisions; verify BF16/dequantized logits against the released MXFP4 checkpoint and test attention-sink plus sliding/full-attention parity.
  2. Establish domain, general, Harmony, tool, and routing-utilization baselines; run a LoRA or 0.5–1B-token CPT pilot before full optimization.
  3. Sweep CPT LR 1e‑5/2e‑5/4e‑5 and replay ratio; select the domain-gain/retention/routing-stability frontier, then scale toward 20–100B tokens using Reuse, Code Llama, and OLMo as scale anchors.
  4. Run high-quality Harmony recovery SFT, followed only then by preference tuning or RL.

For full training, use BF16, activation checkpointing, FSDP2/ZeRO‑3 or expert parallelism, sharded state dictionaries, and kernel parity tests, aligned with the Axolotl GPT‑OSS guide and large-model practice in Tülu 3. The internal LLM memory accounting guide derives why weights, gradients, optimizer states, and activations—not checkpoint weight size alone—determine feasibility, and its ZeRO/FSDP section explains the sharding vocabulary used here. Save the exact parameter-target policy, router loss, expert statistics, model/tokenizer/Harmony revisions, dataset hashes, packing and token counts, DP/TP/EP topology, microbatch, accumulation, optimizer/scheduler/RNG state, software commit, quantization/dequantization path, and attention-kernel version. Retain best-domain, best-retention, and best-routing-stability checkpoints rather than only the final step.

4.2 Qwen3.5 Runbook

Qwen3.5’s 256 routed experts are all trainable in a full run, but one token’s task gradient reaches only its selected eight routed experts plus the shared expert; routers, attention/DeltaNet blocks, embeddings, vision-language projection, and MTP head are shared or separately exercised. This is the same sparse-update distinction derived in Which Parameters Update?. Log per-layer expert load, routing entropy, shared-versus-routed contribution, auxiliary routing loss, dropped tokens if capacity is finite, and utilization by modality and language. A globally balanced router can still collapse locally on image tokens or a new domain.

  1. Choose and pin the Base or post-trained revision, processor, config, and template. Decide explicitly whether the vision tower and MTP head train.
  2. Before scale-up, test BF16/FP8 logit and gradient parity; Gated DeltaNet recurrent state and convolution; full-attention mRoPE; image/video position IDs; MoE dispatch; and MTP loss. The released config’s BF16 dtype is not proof that every training kernel used BF16.
  3. Run a short text-only or multimodal CPT sweep and select on domain gain, general retention, multimodal retention, routing stability, and long-context evaluation. Do not copy GPT‑OSS LR merely because both are sparse MoEs; architecture, checkpoint stage, active paths, and optimizer continuity differ.
  4. Restore behavior with Qwen-native SFT, then validate thinking-on/off, tools, image/video turns, multilingual generation, and 262k native context before DPO or asynchronous agent RL. Use YaRN extension toward 1,010,000 only as a separately evaluated deployment mode described by the official model card.

The main reproducibility boundary is simple: the official report reveals architecture-level training choices—early fusion, hybrid parallelism, native FP8, MTP, and asynchronous RL scale—while the 35B‑A3B release does not reveal a complete data/optimizer schedule. A credible experiment therefore records its own unique samples and consumed tokens, text/image/video mixture, sequence packing, trainable modules, MTP coefficient, router coefficient, FP8 recipe, DP/TP/EP topology, rollout versions, and every evaluation revision rather than labeling an inferred configuration “the Qwen recipe.”

For artifact validation, the official serving guide supports Transformers, vLLM, SGLang, and KTransformers, uses the qwen3 reasoning parser and qwen3_coder tool parser, and exposes MTP-assisted speculative decoding. Text-only deployment can omit the vision model, but a text-only training export should still be checked against the original processor, vocabulary, untied LM head, and chat template before it is considered compatible.

1. GPT‑OSS‑120B 设计

1.1 MoE 形态

按深度排列的交互式 GPT‑OSS‑120B schema:prefix in → model layers → word out。

GPT‑OSS‑120B 是 decoder-only sparse MoE Transformer,这些架构字段来自发布的 GPT‑OSS‑120B config。residual width 为 2,880,vocabulary 为 201,088,36 个 decoder blocks 位于不共享权重的 input embedding 与 LM head 之间。每个 block 都有共享 attention、一个 router 和 128 个独立 FFN experts;每个 token 在每一层单独选择 4 个 expert,即只计算该层 expert pool 的 3.125%。

关于 masked self-attention、multi-head projections、逐 token FFN、residual paths 与 normalization 组成 decoder block 的基础过程,可先阅读之前的《Self-Attention Layer and The Transformers Architecture》。GPT‑OSS 保留这个 Transformer 骨架,但将每个稠密前馈子层替换为 routed expert pool,并采用 GPT‑OSS 特有的 attention、normalization 与 positional choices。

组件 精确逻辑参数 计算
单个 expert 24,891,840 gate/up: 2 × 2,880 × 2,880 + 5,760 bias;down: 2,880 × 2,880 + 2,880 bias
单层 128 experts 3,186,155,520 128 × 单 expert
单层 attention 26,550,144 Q/K/V/O weights、biases 与 64 attention sinks
单层 router 368,768 [128, 2,880] weight + [128] bias
单层两个 RMSNorm 5,760 2 × 2,880
36 个 decoder blocks 115,670,886,912 36 × 3,213,080,192
Embedding + untied LM head 1,158,266,880 2 × 201,088 × 2,880
模型总计 116,829,156,672 weight index 的 tensor shapes 精确求和

其中 experts 占 114.702B(98.18%),attention 为 0.956B,两个 vocabulary matrices 为 1.158B,router 与 norms 合计约 0.013B;这些数值由 发布 tensor indexconfig 共同复现。公开的约 5.1B active parameters/token 可精确复现为 36 × (四个 experts + attention + router + 两个 norms) + 一个完整 vocabulary projection + final norm = 5,132,849,472。input embedding 是 row lookup,因此不能把整个 embedding matrix 再计入 dense per-token compute。

1.2 Attention 与 Context

Attention 是 config 中的 grouped-query attention:64 个 query heads、8 个 key/value heads,head dimension 都是 64。Q projection 为 2,880→4,096;K、V 各为 2,880→512;O projection 再把 4,096 映射回 2,880 residual width。每个 KV head 被 8 个 query heads 共享,因此 KV cache 显著小于普通 64-head MHA。按人类从 1 开始计数,奇数层使用 128-token sliding causal attention,偶数层使用 full causal attention,共 18 个 local 与 18 个 global layers;局部层控制长上下文成本,交替的全局层仍能传播远程信息。

位置编码为 RoPE + YaRN scaling:原始 context 4,096,factor=32,最大位置 131,072,rope_theta=150000beta_fast=32beta_slow=1。每层还有 64 个 learned attention-sink scalars,每个 query head 一个,使 softmax 可以把部分概率放到一个不承载普通 token value 的学习目标上,而不是强迫所有 attention mass 落到内容 token。Router 将 2,880-d token state 映射到 128 个 logits,选择 top 4,再对这四个 logits 做 softmax,这对应 num_local_experts=128num_experts_per_tok=4

RoPE 的几何推导及 PI/NTK/YaRN context-extension 路线见站内的《RoPE and M‑RoPE》

1.3 MXFP4 权重

OpenAI GPT‑OSS repo 说明这些模型在 post-training 中使用 MoE weights 的 MXFP4 quantization,使 GPT‑OSS‑120B 可以在单张 80GB 级 accelerator 上运行;Hugging Face MXFP4 docs 也把它描述为 GPT‑OSS 在 Transformers 中的 4-bit floating-point 路径。本文中,MXFP4 应被理解为发布模型中 MoE expert weights 的 inference/storage 格式,而不是 CPT 或 full fine-tuning 的完整 optimizer-state 格式。

MXFP4 是 microscaling format:Microscaling Data Formats 将 MX 定义为 per-block scale 加 narrow per-element format;MXFP4 使用 4-bit FP4 elements 与 8-bit shared scale。常见 OCP-style layout 是每个 block 存 32 个 E2M1 FP4 values 加 1 个 E8M0 scale,即 32 × 4 + 8 = 136 bits/block,约 4.25 bits/value。相比 plain INT4,block-wise floating scale 给每个局部 group 单独动态范围,量化误差通常更可控。

MXFP4 不意味着 full training 能放进 80GB。发布 checkpoint 的 weight index 显示 expert projection blocks 使用 MXFP4;attention、router、embedding 与 LM head 明确排除在量化列表外。这能解释 约 80GB accelerator 的推理部署,但 full training 仍需要 dequantized/master weights、gradients、optimizer states、activations、communication buffers 与 checkpoints。

1.4 设计辨析

head_dim=64 为什么可能成立?一个有趣的社区解释来自科学空间的 n > 8.33 ln N 维度 heuristic:它从最小熵与 attention/skip-gram 联系出发估计表示维度。按原文数值例子所使用的自然对数,N=128、4,096、131,072 时分别约为 40.4、69.3、98.2。因此 64 对 128-token local window 是合理的常用档位,却不能用同一公式解释 full-attention layers 或完整 128k context;原社区文章部分计算使用了 log2,与引用来源的对数约定并不一致。更重要的是,该公式是 heuristic,并不能证明 OpenAI 因此选择 64。完整设计是联动的:64 个 query heads 让 Q width 达到 4,096,尽管 residual width 只有 2,880;8 个 KV heads 控制 cache;local/full attention 交替。MLA 分析有助于理解更大 head dimension 的表示空间,但“大一定更好”还受 head count、KV cache、kernel 与总 compute budget 约束。

hidden_size = intermediate_size = 2,880 不等于 dense MLP ratio=4。官方 MoE forward 把同一个 normalized token 分别送入四个独立参数的 experts,每个 expert 完成 gated activation 与 down projection 后,再做 router-weighted sum;它不会把四个 expert 拼接成一个 11,520-wide dense FFN。可以说每个 token 总共计算四条 2,880-wide intermediate branches,即合计 11,520 个 intermediate scalar activations,并承担四个同宽 expert 的参数/计算量;但 routing、独立非线性与 mixture 在数学上不同于单个 width=11,520 layer。FFN 升维讨论中的 ReLU 降秩模型依赖独立置零假设,不能直接套到 clipped gated-SwiGLU。Toy Models of SuperpositionTransformer Circuits 支持“更丰富 feature space 有价值”的直觉,却不规定精确 ratio。工程上还应在真实 stack 上测速:hardware/model co-design 在相近参数量下观察到最高 39% throughput 差异,因此 A100 上约 2.7 的局部 microbenchmark 结果依赖 hardware、kernel、dtype 与 batch,不能当作通用最优值。

MLP bias 与 clip 是事实,optimizer 推断不是。发布的 reference code 明确包含 router、fused gate/up 与 down-projection biases;它还把 gate 上限裁到 7、up 裁到 ±7,给 up 加 1,并计算 (up + 1) × gate × sigmoid(1.702 × gate)。有界 activation 很可能有利于低精度 expert weights 和 outlier 控制,但 OpenAI 没有公开确认这一因果设计动机。同样,存在 MLP bias 不能推出是否使用 Muon;原始 optimizer 与 state 没有公开。

整个模型每隔一层就恢复 global receptive field。官方 mask implementation 对 zero-indexed even layers 使用 128-token sliding window,对 odd layers 使用 full causal attention,所以 128 × 36 = 4,608 不是 GPT‑OSS 的 receptive field。即使假设 36 层全是 local,更严谨的 token bound 也约为 1 + L × (W − 1);真实模型中,每个 full layer 已可访问允许范围内的完整 prefix,最长到配置的 131,072 positions。local layers 的作用是在 global layers 之间降低 attention cost,而不是把整体 context 限制在约 4k。

Attention sink 不是 KV shifting,也不是四个 sink tokens。OpenAI 的 reference SDPA 为 64 个 query heads 各学习一个 sink scalar:把一个 sink logit 拼到每行 attention scores,做 softmax,然后在乘 V 前丢弃 sink probability。这里没有 learned sink K/V vector,也没有 sink_token=4;数字 4 是每 token 激活的 MoE experts 数。KV Shifting Attention 通过移动 K/V states 帮助 induction,是另一套机制。sink 提供“不把概率分给任何内容 token”的出口,而 KV shifting 会改变承载内容的 K/V computation。

UE8M0 是 MXFP4 的共享 scale。OCP MX specification 定义每个 MXFP4 block 为 32 个 E2M1 FP4 values 共用一个 E8M0 scale,共 136 bits,即 4.25 bits/weight。NVIDIA 将该 scale 称为 ue8m0:8-bit unsigned exponent-only float,没有 mantissa 与 infinity,0xff 保留为 NaN,PTX 中以 ue8m0x2 packed format 使用。较新的 Blackwell block-scaled MMA 可以直接消费 MXFP4 与 scale;其他 runtime 可能 dequantize 或走不同 kernel。最后,“FP4 只是部署量化”对 GPT‑OSS 并不完整:model card 明确说 OpenAI 在 MoE weights quantized to MXFP4 的条件下做了 post-training。这不代表原始 pretraining 或 optimizer state 是 FP4,但也不是训练完成后的纯部署转换。

1.5 Qwen3.5 对照

Qwen3.5‑35B‑A3B 是很有价值的 sparse-MoE 对照:它用完全不同的 backbone 达到相近量级的 active compute。它采用 Apache‑2.0,是带 vision encoder 的原生多模态 causal model;总参数 35B、每 token 约激活 3B,text hidden width 2,048,padded vocabulary 248,320,text layers 40。官方 layout 是 10 × [3 × (Gated DeltaNet → MoE) → 1 × (Gated Attention → MoE)],即 30 个 recurrent linear-attention layers 与 10 个 full-attention layers;GPT‑OSS 则是 18 个 sliding-window 与 18 个 full-attention layers。当前发布模型已完成 post-training;单独的 Base checkpoint 才是面向继续训练的 pre-trained 起点。

属性 Qwen3.5‑35B‑A3B GPT‑OSS‑120B
模态 原生 text、image、video 仅 text
总参数 / 激活参数 35B / ≈3B 116.8B / ≈5.13B
深度与宽度 40 layers,width 2,048 36 layers,width 2,880
Sequence mixer 30 Gated DeltaNet + 10 gated full attention 18 sliding-window + 18 full attention
每层 MoE 256 routed experts;top 8 + 1 shared;expert width 512 128 routed experts;top 4;expert width 2,880
原生 context 262,144;YaRN 可扩到 1,010,000 由 4,096 经 YaRN 扩到 131,072
Conversation contract Qwen template、<think>、multimodal/tool tags Harmony roles、channels、recipients 与 effort

官方 config 给出了 hybrid block 的细节。Gated DeltaNet 使用 32 个 value heads 与 16 个 Q/K heads,head dimension=128,并带 width=4 的局部 convolution;full gated attention 使用 16 个 query heads、2 个 KV heads、head dimension=256、output gating,以及 64-dimensional interleaved multimodal RoPE(sections 11/11/10,rope_theta=10,000,000)。每层有 256 个 routed experts,选择 8 个,同时始终计算一个 shared expert,router_aux_loss_coef=0.001;因此 sparse specialization 之外还有所有 token 共用的 dense path。input/output embeddings 不共享。模型还用一个 MTP layer 训练额外的 future-token prediction。vision tower 为 27 layers、width 1,152、intermediate 4,304、16 heads、16×16 spatial patch、temporal patch=2、2× spatial merge,最后投影到 2,048-wide language stream。

发布 config 中 checkpoint dtype 是 BF16,而 Qwen3.5 训练报告描述的是 native FP8 training pipeline:activation、MoE routing 与 matrix multiplication 使用低精度,对数值敏感的操作保留 BF16。这是训练算术,不等于 GPT‑OSS 的 MXFP4 expert-weight artifact。官方报告还把吞吐归因于 text/image/video early fusion、vision/language heterogeneous parallelism、248k multilingual vocabulary 与 sparse computation,并称支持 201 种语言和方言。这些是 Qwen3.5 family 级公开事实,不是 35B 型号完整可复现的 optimizer recipe。

官方 model card 同时报告 language 与 vision evaluations:Qwen3.5‑35B‑A3B 在 Qwen 所述 setup 中得到 MMLU‑Pro 85.3、GPQA Diamond 84.2、SWE‑bench Verified 69.2、MMMU 81.4 与 AndroidWorld 71.1。这些是 vendor-reported numbers,不是独立、严格 apples-to-apples 的排名;它们在这里说明这个约 3B-active 模型的联合目标包含 reasoning、coding、agent 与 vision,而不只是 text perplexity。

2. 训练 Regimes

2.1 范围与目标

OpenAI 公开了 GPT‑OSS 的 open-weight 模型,GPT‑OSS‑120B 权重/configHarmony 接口 可用,但没有公开原始 optimizer state、末端 LR、完整预训练 token 数或官方 CPT recipe。下文数值是由 GPT‑OSS fine-tuning cookbookAxolotl GPT‑OSS guide 与大型开放训练实践交叉验证得到的工程起点。GPT‑OSS‑120B 约有 117B 总参数、每 token 激活约 5.1B 参数;MXFP4 的约 80GB 推理体积不能外推为单张 80GB GPU 可以做全参数 AdamW 训练。

CPT 用 raw text/code 的 next-token loss 改变知识与领域分布;SFT 学 instruction、格式与工具使用;DPO 学 chosen/rejected preference;在线 RL 学 rollout 与 reward,例如 Agent Factory 3 的 GPT‑OSS run。模型参数量本身不能决定 LR。

2.2 LR 与规模

窄域 CPT 从 1e‑5 起步,正式 20–100B-token CPT 从 2e‑5 起步,并 sweep 1e‑5/2e‑5/4e‑5;这个区间是由 Reuse, Don’t Retrain 的 CPT scheduler 研究、Code Llama 的大规模 CPT、OLMo 3 的 100B-token mid-training ingredient 与 Axolotl GPT‑OSS‑120B 的直接 120B recipe 外推得到。全参 SFT 为 2e‑6–2e‑5,参考 Tülu‑3 70B SFTAxolotl 120B;LoRA 为 5e‑5–2e‑4,参考 OpenAI GPT‑OSS‑20B LoRA;DPO 为 1e‑7–5e‑7,参考 Tülu 3 DPO。新建 optimizer 时 CPT 使用 0.5–1% 短 warmup;拥有连续 optimizer/scheduler state 时才优先考虑 zero-warmup continuation。

行为 SFT 可以只有 1k–50k 个高质量样本,其中 OpenAI cookbook 给出 1k-example GPT‑OSS LoRA 示例;广泛 instruction tuning 常为 100k–1M conversations,可参考 Tülu 3 的开放 post-training recipe;CPT pilot 为 0.1–5B token;正式 70B/120B domain adaptation 的可信主区间为 20–100B token,参考 OLMo 3Reuse。必须同时记录 unique examples、消费 tokens 与磁盘字节,因为 Code LlamaOLMoTülu 的公开资料分别用 corpus size、token count 和 example/pair count 描述规模。

2.3 Batch 与保留

global sequences = DP ranks × microbatch × gradient accumulation,这个定义与 Tülu 3 reproduction guide 一致;使用 TP/EP 时 DP ranks 不是物理 GPU 总数。CPT 记录 non-padding tokens/update,因为 Code LlamaOLMo 3 这类大规模 CPT 更适合按 token batch 对齐。8×A100‑80GB 先验证 LoRA/SFTHarmony labels 与数据正确性;32×A100‑80GB 才更适合把 full FFT/CPT 作为主路线。增加 GPU 优先减少 accumulation 与 wall-clock,而不是线性放大 LR。

不要把纯领域数据灌到结束。使用 general replay、capability-related replay、staged mixture 或 checkpoint merging;这个策略来自 Reuse, Don’t Retrain 对 mixture/scheduler 的研究与 Code Llama 的 mixed-data CPT 实践。用 domain gain 与 general retention 共同选择 LR 和 mixture。

2.4 Qwen3.5 训练

公开资料足以还原训练轮廓,却不足以构成精确 recipe。根据 Qwen3.5 官方报告model card,pre-training 采用 early fusion:把 text、image、video 转成统一 token sequence 联合优化,并扩大经过更严格过滤的 multilingual、STEM、coding 与 reasoning 数据。hybrid Gated DeltaNet/full-attention backbone、vision encoder、sparse MoE、routers 与 MTP objective 共同训练为一个 foundation model。Qwen 公开了 decoupled heterogeneous-parallel system,用重叠计算协调视觉与语言组件,使 mixed multimodal training 吞吐接近 text-only,并以 native FP8 执行大部分算子、在敏感位置保留 BF16。

Post-training 再加入 instruction behavior、显式 thinking、tool use、visual reasoning 与 agent policy。官方 release称 RL 扩展到 million-agent environments,并逐渐提高 task distribution 难度;异步框架将 rollout inference 与 training 解耦,并为 text、multimodal、multi-turn environments 提供 dynamic load balancing 与 fault recovery。它公开了方向——大规模 heterogeneous SFT/RL 与 environment scaling——却没有公开 35B‑A3B 独立的 SFT mixture、teacher models、reward composition、RL algorithm、rollout 数、accepted-token 数、optimizer、LR、batch 或完整 pre-training token 数。这些字段必须标为未公开;旧 Qwen3 的 four-stage recipe 与更大 Qwen3.5 型号不能冒充 35B checkpoint 的 recipe。

如果目标是注入 domain knowledge,优先从 Qwen3.5‑35B‑A3B‑Base 做 CPT,再用精确 Qwen template 恢复 chat/tool behavior。若保留已有 instruction policy 比干净的 base objective 更重要,也可以从 post-trained checkpoint 开始,但会产生与 GPT‑OSS 相同的 forgetting/alignment tradeoff。text-only CPT 可以冻结 27-layer vision tower;joint multimodal CPT 必须正确维护 image/video packing、multimodal RoPE position、modality balance 与 vision-language projection updates。这些属于工程选择,不是未公开的 Qwen 官方设置。

3. Harmony 格式

3.1 Roles 与 Channels

GPT‑OSS post-training 使用 Harmony 学习 conversation structure、reasoning 与 function calling;OpenAI Harmony guide 明确要求自行托管推理或训练时保留该格式。role hierarchy 是 system > developer > user > assistant > tool。system 负责固定模型 identity、knowledge cutoff/current date、Reasoning: low|medium|high、valid channels 与 built-in tools;developer 才相当于传统 system prompt,放 instructions、function tools 与 response formats。persona/identity 的产品级修改也应放在 developer,而不是改写标准 system identity。

analysiscommentaryfinal 三个 channel 的语义来自 Harmony 官方格式:analysis 是 raw CoT 与内部 tool use,安全标准不同于 final,不能展示给用户;commentary 用于 function call 与可见 preamble;final 是用户答案。medium 是默认 reasoning effort,SFT 仍应覆盖 low/medium/high,同类任务也要跨 effort 采样。

优先使用 PyPI/crates.io 的官方 openai_harmony renderer:它能构建 typed SystemContent/DeveloperContent、把 JSON Schema 工具转成 Harmony、render token、parse completion message,并用 StreamableParser 暴露当前 role/channel/content type/recipient/delta/content,避免 streaming Unicode 被拆坏。

Special token ID 用途 Source
<|start|> 200006 message/header 开始 Harmony
<|end|> 200007 完整历史 message 结束 Harmony
<|message|> 200008 header 与 content 分界 Harmony
<|channel|> 200005 channel 字段 Harmony
<|constrain|> 200003 tool input 类型,例如 JSON Harmony
<|return|> 200002 完成回答并停止采样 Harmony
<|call|> 200012 暂停采样并执行工具 Harmony

3.2 调用与状态

持久化 message 的基本结构是 <|start|>header<|message|>content<|end|>,来自 Harmony wire format。completion 可以生成多个 analysis message,最后以 <|return|><|call|> 停止。return 只用于 decode-time/监督 target;写回下一轮 history 时必须规范化成 end,历史 prompt 中的 message 都应是完整 end 结尾。

function tools 放在 developer 的 # Tools 下,通常包在 functions namespace,使用 Harmony 官方示例 的 TypeScript-like declaration:无参数函数写成 () => any,有参数函数接收名为 _ 的 object,字段说明用 comments,return type 保持 any,并在 definition 间留空行。模型调用时在 header 写 to=functions.name,可用 <|constrain|>json 指定参数类型,并以 call 停止。执行后追加由具体 tool name author、to=assistant、commentary channel 的结果,再从 assistant 继续采样。

没有 recipient 的 commentary 可能是用户可见 preamble,例如多工具调用前的 action plan,这一点来自 Harmony commentary channel 语义,不能当成隐藏 CoT。历史处理必须区分两种状态:assistant 已完成 final 后,下一 user turn 丢弃旧 analysis、只保留规范化后的 final;但在尚未完成的 tool/function chain 中,执行工具后继续 sampling 时必须保留此前 analysis、call 与 tool result,否则模型失去继续 reasoning 所需的上下文。

3.3 输出与 Loss

structured response schema 放在 developer 末尾的 # Response Formats,包含 format name、说明与 JSON Schema;这是 Harmony response-format section 的规则。prompt 只会影响行为,并不保证严格 schema adherence;需要在 sampling 时额外使用 grammar/constrained decoding。

GPT‑OSS releaseHarmony guide 说明模型支持 built-in browser 与 Python tools,它们定义在 system 而不是 developer。browser 通常走 analysis,recipient 为 browser.search/open/find;Python 走 analysis,recipient 为 python;developer-defined functions 通常走 commentary。runtime 仍需容忍官方文档提到的少量 channel variation。

SFT 时 mask system/developer/user/tool output,训练当前 assistant analysis、commentary/call、需要的 preamble 与 final;这是基于 Harmony channel semanticsOpenAI GPT‑OSS SFT notebookTülu 3 post-training practice 的工程策略。知识注入可从 final weight=1.0、analysis weight=0.2–0.5 起步,或只训练 verifier-filtered reasoning。单测必须覆盖 raw messages → Harmony rendering → token IDs → labels → parsed messages、return/end normalization 与 tool-resume exception。大规模 CPT 仍保持 raw text/code causal LM,参考 ReuseCode LlamaOLMo;之后再做较小的 Harmony recovery SFT,覆盖普通 QA、三档 effort、no-tool/tool、preamble、structured output、普通 multi-turn history、tool-chain continuation 与 instruction conflict。

3.4 Qwen3.5 格式

Qwen3.5 不能用 Harmony renderer。它发布的 chat template 采用 ChatML-like wire format:<|im_start|><|im_end|> 包围 message,system 必须位于最前,普通 roles 是 system、user、assistant。它没有 Harmony developer role,没有 analysis/commentary/final channel header,没有 recipient,也没有原生 Reasoning: low|medium|high。它用 enable_thinking=true 打开 <think>;关闭 thinking 时会在答案前输出空 thinking block。template 可以读取独立的 reasoning_content,也可以从 assistant content 中拆分 thinking。

<|im_start|>system
You are a helpful assistant.<|im_end|>
<|im_start|>user
Explain the routing decision.<|im_end|>
<|im_start|>assistant
<think>...current-turn reasoning...</think>
...final answer...<|im_end|>

在新的 user query 前,template 会删除旧 reasoning,只保留此前 final answer;它在语义上与 Harmony 的“不要把已完成 CoT 回灌历史”相似,但 wire format 完全不同。SFT 时 mask system/user prompts 与 tool responses;只有 trace 可信时才训练当前 assistant thinking 与 final/tool call。不要为了拉长输出而训练无意义的 synthetic thinking;应让 task difficulty 对应合理 reasoning budget,并单测 <think>...</think> split 与 multi-turn rendering,确保历史 hidden traces 不会泄回 prompt。

工具格式也不同。JSON tool schemas 在 system message 的 # Tools<tools> 中注入;assistant call 使用 <tool_call><function=...><parameter=...>,结果放入 <tool_response>。多模态内容使用 <|vision_start|><|image_pad|><|vision_end|>,video 则使用相应 video pad。Base model card 说明这些 control tokens 已进入 pre-training,因此 PEFT 不必微调巨大的 embedding matrix。应维护两套独立 render/parse tests:Harmony/GPT‑OSS 一套,Qwen3.5 一套。

4. 训练实践

关于这套参数策略背后的通用机制——hard top‑k routing 如何训练、哪些 experts 会收到梯度,以及为什么“所有参数可训练”不代表每个权重每一步都会改变——见 MoE 配套文章的 哪些参数会更新?。对 GPT‑OSS‑120B 的全参数 CPT 而言,共享模块、router 与每层全部 128 个 experts 都可训练,但一个 token 的任务梯度只会进入它选中的四个 experts。

训练可行性还应结合站内的大模型显存构成ZeRO/FSDP 分片阅读:决定 full training 成本的是 weights、gradients、optimizer states 与 activations 的总和,而不是 MXFP4 checkpoint 的文件大小。

4.1 Runbook

参数分布决定不同 adaptation 方法能改变什么。attention-only LoRA 只更新较小的共享子网络,适合先验证 policy、tool use 与 agent behavior;这个方向由 Agent Factory 3 的 GPT‑OSS‑120B RL 实验提供公开锚点。expert/MLP adaptation 对领域知识和生成分布的容量更大,但会带来 routing imbalance 与显著更高的 optimizer/checkpoint 成本;Axolotl 120B guide 因此强调 FSDP2、CPU offload 与 checkpoint storage。训练 router 会改变 token 被分配到哪些 expert;冻结 router 可稳定路径,但可能限制新领域适应。除 domain/general eval 外,必须记录逐层 expert selection frequency、routing entropy、tokens/expert、实现存在 capacity limit 时的 dropped/overflow tokens,以及 auxiliary router loss。

公开锚点 配置 训练含义
Axolotl 120B full SFT LR 2e‑5、BF16、FSDP2、activation checkpointing、CPU offload 完整 117B optimization 的主要约束是 sharding/offload 与 checkpoint storage
OpenAI 20B LoRA SFT LR 2e‑4、3% warmup、global batch 16 扩展前先验证 Harmony、loss 与 target modules
Agent Factory 3 120B RL attention LoRA、冻结 MoE/router、async rollout 与 routing replay 无需更新 114.7B expert subsystem 即可验证 policy improvement
  1. 锁定 model/tokenizer/config revisions;验证 BF16/dequantized logits 与 MXFP4 checkpoint 一致,并测试 attention sink、sliding/full attention parity。
  2. 建立 domain/general/Harmony/tool/routing-utilization baselines;full optimization 前先跑 LoRA 或 0.5–1B-token CPT pilot。
  3. sweep 1e‑5/2e‑5/4e‑5 与 replay ratio,按 domain gain、retention 与 routing stability 共同选择配置,再用 ReuseCode LlamaOLMo 作为规模锚点扩到 20–100B tokens。
  4. 进行高质量 Harmony recovery SFT,最后才加入 preference tuning 或 RL。

Full training 使用 BF16、activation checkpointing、FSDP2/ZeRO‑3 或 expert parallelism、sharded states 与 kernel parity tests;这些工程要求与 Axolotl GPT‑OSS guideTülu 3 的大模型 post-training runbook 一致。保存精确 trainable-target policy、router loss、expert statistics、model/tokenizer/Harmony revisions、dataset hashes、packing/token counts、DP/TP/EP topology、microbatch、accumulation、optimizer/scheduler/RNG state、software commit、quantization/dequantization path 与 attention kernel version;同时保留 best-domain、best-retention 与 best-routing-stability checkpoints。

4.2 Qwen3.5 Runbook

全参数训练时,Qwen3.5 的 256 个 routed experts 都可训练,但单个 token 的 task gradient 只进入选中的 8 个 routed experts 与 shared expert;router、attention/DeltaNet blocks、embeddings、vision-language projection 与 MTP head 则作为共享或独立路径参与。这与站内 哪些参数会更新?推导的 sparse-update 区别一致。应记录逐层 expert load、routing entropy、shared/routed contribution、auxiliary routing loss、存在 capacity limit 时的 dropped tokens,以及按 modality/language 划分的 utilization。全局 router 看似平衡,仍可能在 image tokens 或新领域上局部 collapse。

  1. 选择并锁定 Basepost-trained revision,以及 processor、configtemplate;明确决定 vision tower 与 MTP head 是否训练。
  2. 扩展前测试 BF16/FP8 logits 与 gradients parity、Gated DeltaNet recurrent state/convolution、full-attention mRoPE、image/video position IDs、MoE dispatch 与 MTP loss。发布 config 的 BF16 dtype 不代表所有训练 kernel 都用了 BF16。
  3. 先跑短程 text-only 或 multimodal CPT sweep,以 domain gain、general retention、multimodal retention、routing stability 与 long-context eval 共同选择。不能因为两者都是 sparse MoE 就复制 GPT‑OSS LR;architecture、checkpoint stage、active paths 与 optimizer continuity 都不同。
  4. 用 Qwen-native SFT 恢复行为,再验证 thinking on/off、tools、image/video turns、multilingual generation 与原生 262k context,之后才做 DPO 或 asynchronous agent RL。向 1,010,000 token 的 YaRN extension 应作为 官方 model card 所述的独立 deployment mode 单独评估。

可复现边界很清楚:官方报告公开了 early fusion、hybrid parallelism、native FP8、MTP 与 asynchronous RL scale 等架构级训练选择,却没有给出 35B‑A3B 完整 data/optimizer schedule。因此可信实验应记录自己的 unique samples 与 consumed tokens、text/image/video mixture、sequence packing、trainable modules、MTP coefficient、router coefficient、FP8 recipe、DP/TP/EP topology、rollout versions 与全部 eval revisions,而不是把外推配置命名为“Qwen 官方 recipe”。

artifact validation 可使用官方 serving guide 支持的 Transformers、vLLM、SGLang 与 KTransformers;官方部署使用 qwen3 reasoning parser、qwen3_coder tool parser,并支持 MTP speculative decoding。text-only 部署可以省略 vision model,但 text-only training export 在认定兼容前,仍需对原 processor、vocabulary、untied LM head 与 chat template 做 parity check。