Qwen4-35B-A3B
Qwen4-35B-A3B is a hybrid-attention
Mixture-of-Experts (MoE) vision-language model of the
Qwen3.8-Flash-Next
architecture family: GatedDeltaNet and QSA sparse-attention layers, four
persistent HyperConnection streams, and one Engram N-gram Embedding table,
paired with a Qwen3-VL-style vision tower. Its configuration declares
Qwen4MoeForConditionalGeneration; NeMo AutoModel loads it with the
Qwen3_8_FlashNextForConditionalGeneration implementation, with every size and
the Engram table layout taken from the checkpoint configuration.
This page covers image-text fine-tuning on MedPix-VQA, language-only fine-tuning on 128K-token packed sequences, and mock-token pretraining.
Fine-Tune Qwen4-35B-A3B
Follow the installation instructions, then run the LoRA recipe on four GPUs from the repository root:
The other three recipes each run on 2 nodes of 8 H100 GPUs. Use the Slurm Launcher Guide for multi-node runs; each recipe header lists the environment variables it needs.
Model Reference
Model Architecture
Available Models
Architecture
- The decoder repeats three GatedDeltaNet layers followed by one QSA sparse-attention layer. QSA compresses index keys in groups of four, selects up to 512 causal groups (2,048 tokens), appends the incomplete causal tail, and evaluates main grouped-query attention (16 query heads, 2 key/value heads) only on the selected tokens.
- Decoder layer 2 adds Engram values derived from eight raw-token bigram hashes and eight raw-token trigram hashes. The table has 160,003,584 padded rows of width 128.
- Four 2,048-wide HyperConnection streams are read and written by every attention and MoE block; a final learned read collapses them before the untied language-model head.
Image Input
- The vision tower’s merged features replace the embeddings of the image
placeholder tokens. QSA layers use three-axis (temporal, height, width)
rotary positions: text tokens advance all three axes together, and an image
that starts at position
pusesp + rowandp + columnon the height and width axes; the token after it continues atp + max(rows, columns). - The Engram layer hashes the raw token IDs, image placeholders included, as the reference implementation does.
Validated Configuration
Image-Text Fine-Tuning
Both runs completed without NaNs or collective errors. A step trains 16 samples
in the full-parameter recipe and 8 in the LoRA recipe, and the validation passes
cover 335,473 and 335,097 label tokens. MedPix-VQA samples average about 370
tokens at these image sizes, so about 9% of each 4,096-token row is content and
the rest is padding. Peak GPU memory was 53.0 GiB (full-parameter) and 46.3 GiB
(LoRA). The LoRA run wrote its adapter, optimizer, and RNG state at the last
step. The full-parameter run used NCCL’s internal InfiniBand (IB) transport
(NCCL_NET_PLUGIN=none and NCCL_NET=IB).
Text Fine-Tuning and Pretraining
The 128K-token packed run trained 100 optimizer steps of one 131,072-token pack
each (12.9M tokens, 7.9M of them supervised). Training loss fell from a mean of
0.972 over the first 10 steps to 0.741 over the last 10, and the gradient norm
from 2.99 to 0.45. Steady-state throughput was 57,894 tokens per second (3,618
per GPU, 2.23 seconds per step) with a peak of 43 GiB of PyTorch memory and
58 GiB of GPU memory per GPU. The run completed without NaNs or collective
errors and used NCCL’s internal InfiniBand (IB) transport
(NCCL_NET_PLUGIN=none and NCCL_NET=IB).
The pretraining recipe was run with --benchmark on 2 nodes / 16 H100 80GB,
from random initialization on mock tokens: two 8,192-token sequences per GPU
and step, FSDP2 over the 16 GPUs with two EP8 groups (one per node), and
model.backend.compile_hc=true. Over 30 steps after 20 warm-up steps it
reached 130,634 tokens per second (8,165 per GPU, 2.01 seconds per step), a
model FLOPs utilization (MFU) of 17.5%, with a peak of 56 GiB of PyTorch
memory and 66 GiB of GPU memory per GPU. The first run on a node, with empty
compile caches, peaked at 74 GiB of GPU memory. --benchmark turns on
balanced routing, so the number excludes routing imbalance and is not a
measurement of learned routing.
Example Recipes
Current Scope
- Apart from image input, the feature scope and limits of the implementation are those listed on the Qwen3.8-Flash-Next page.
- Image inputs are supported for padded
[batch, sequence]batches. Video inputs, and image inputs combined with context parallelism, pipeline parallelism, or packed sequences, are rejected with an error. model.backend.attn=fa4builds a route byte mask of shape[local queries, global keys]that is limited to 2^31 entries per call. A 131,072-token pack therefore needs at most 8,192 tokens per context-parallel rank (cp_size >= 16).- Full-parameter SFT keeps weights, gradients, and optimizer state for 55.5B trainable parameters: about 65 GiB per GPU on 8 GPUs and 32 GiB on 16. The full-parameter recipes therefore use two nodes.