Adds native image training to Qwen3.8 Flash Next (`qwen4_exp`) through Prime-RL’s existing multimodal pipeline. - Adds the checkpoint-compatible vision encoder and composite model, merges image features into placeholders, and constructs packed MRoPE positions. - Preserves raw token IDs for PLE hashing; CP shards merged embeddings, token IDs and positions after vision encoding. - Keeps vision parameter names and checkpoint conversion intact, including frozen-vision and text-only dummy-forward handling. - Includes #4259’s validated linear patch projection, learned-position interpolation and rotary-trig alignment. No fused-head or hyperconnection experiments. - Provides Qwen3.5/Qwen3.8 image RL examples using the included `primeintellect/color-codeword@0.1.0` environment and native `null` harness, with disjoint training/evaluation slices and comments showing where to substitute your multimodal environment. Qwen3.8 uses CP8. Rebased onto main `088570f8` (2026-10-26). Main now supplies #4252’s PLE memory fix, #4264’s FLA 0.6.0 update and #4279’s new QSA kernels/activation-checkpoint plan handling. ### Validation Nebius H200, PyTorch 2.13.0+cu130, exact release kernel wheel `v0.1.0-b52bd9d`, job **6812**: - **47 passed:** Qwen3.8 model/meta/checkpoint and VLM checks, Qwen3.5 VLM regressions, activation-checkpoint policies and kernel selection tests. - Four fixed-input old/new attention controls include the production 24-query-head / 2-KV-head / 256-dimension geometry, packed/batched shapes and 2,051 selection slots. Outputs and gradients remain close to the FP32 reference (roughly 0.21–0.24% relative L2); the new output and Q/K/V gradients are bitwise identical across three repeats. - Old/new selector sets match exactly in all three paired controls, including packed bounds and a CP query offset. The new selector’s order is repeatable. - These are component numerical checks, not a full-model KL measurement or a full-size trainer update. Two-GPU packed-image CP2 + full AC + compilation also passes forward/backward on both ranks (job 6817), with finite gradients and outputs matching the unsharded reference within atol=0.02, rtol=0.03. - Example follow-up: both previously failing `test_load_configs` cases pass (**2 passed**). Both configs also load 1,024 shuffled image training tasks and 128 disjoint evaluation tasks, and resolve `ColorCodewordEnv` with `NullHarness`. Browser-only fields were replaced with the native harness's compaction setting. Both examples inherit the default Prime runtime (no subprocess override); train/eval runtime resolution was verified. Whitespace checks pass. - Ruff lint/format and whitespace checks pass. Vision implementation and vision tests are unchanged from the previously validated PR head. The examples retain CP8 for Qwen3.8 and use main’s renamed max_staleness field (8). Earlier frozen-model validation of the three vision changes used one eight-image prefix and all 4,545 generated targets, with saved inference expert replay and stable attention ordering. Exact full-vocabulary KL fell **0.002570 → 0.001602** with FLA 0.5.2 and **0.002430 → 0.001249** with FLA 0.6.0. These results predate this main rebase and do not establish training-wide gains. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > New vision encoder and MRoPE/CP paths affect large-scale RL training numerics and distributed behavior; mitigated by extensive unit tests but not full production KL validation in this PR. > > **Overview** > **Adds native vision-language training for Qwen3.8 Flash Next** (`qwen4_exp`) on top of Prime-RL’s existing multimodal stack, alongside doc and example updates for Qwen3.5/Qwen3.8 image RL and SFT. > > The trainer gains a composite **VLM model**: vision encoder (`model.visual`), image-token scatter into language embeddings, **packed MRoPE** positions from `mm_token_type_ids` / `image_grid_thw`, and **context-parallel sharding after** vision merge. PLE still hashes raw placeholder `input_ids`; checkpoint conversion **keeps** `model.visual` weights instead of dropping them. `QwenVLAdapter` registers `qwen4_exp`. > > **Docs** list Qwen3.8 in model/VLM tables, add a `qwen3.8` renderer, and revise multimodal limits (FP32 trainer + BF16 vLLM is OK; monitor mismatch KL metrics). > > **Examples**: new `rl-qwen3.5.toml` and `rl-qwen3.8.toml` (4×8 H200 trainer + 4 inference replicas, `color-codeword`, GRPO/IPO); expanded `examples/extra/vlm/README.md`. > > **Tests** cover VLM forward/backward, router replay, MRoPE packing, and composite checkpoint roundtrip. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit b12f244d24b0e86afa8a3746e9f3c1cfdebc3113. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: Codex <codex@local>
1.7 KiB
Vision-language training
RL and SFT examples for the custom PrimeRL VLM implementations.
Image RL
| Config | Model | Batch / group | CP |
|---|---|---|---|
rl-qwen3.5.toml |
Qwen/Qwen3.5-122B-A10B |
336 / 16 | 4 |
rl-qwen3.8.toml |
Qwen/Qwen3.8-Flash-Next |
256 / 16 | 8 |
Both target 4 trainer + 4 inference nodes, each with 8× H200 GPUs.
The examples use primeintellect/color-codeword with separate training and evaluation task slices. Replace it with your multimodal environment and compatible harness, and update run/W&B names and the shared output path. Install environments with uv sync --all-extras --all-packages and export any credentials they require.
After setup, validate from a shared checkout:
uv run rl @ examples/extra/vlm/rl-qwen3.8.toml --dry-run
Remove --dry-run to submit; swap in rl-qwen3.5.toml for Qwen3.5. See Scaling for Slurm configuration and Training for monitoring and resume.
SFT
Both configs use LoRA with a frozen vision encoder and assistant-only loss masking.
| Config | Model | Hardware |
|---|---|---|
sft.toml |
Qwen/Qwen3.5-0.8B (dense, LoRA rank 16) |
sanity-scale, 20 steps |
sft-moe.toml |
Qwen/Qwen3.6-35B-A3B (MoE, LoRA rank 32, EP8) |
one 8-GPU node |
Set data.name to your multimodal chat dataset, then:
uv run sft @ examples/extra/vlm/sft.toml
Keep micro_batch_size = 1 for VLM SFT and the MoE config's EP degree aligned with its GPU count. See Training for checkpoint export.