Skip to content

[Maxtext][Tunix] Fix Weight Conversion for Qwen3.5-35B - #5045

Open
YixuanWang-99 wants to merge 1 commit into
mainfrom
yixuann-weightsync-rebased-on-mohit
Open

[Maxtext][Tunix] Fix Weight Conversion for Qwen3.5-35B#5045
YixuanWang-99 wants to merge 1 commit into
mainfrom
yixuann-weightsync-rebased-on-mohit

Conversation

@YixuanWang-99

@YixuanWang-99 YixuanWang-99 commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

Description

This is the new weight converter between maxtext and tunix vllm rollout engine, tests passed.

Key changes

  • Fix weight conversion errors for qwen3.5-35b model, for both direct conversion and torchax conversion
  • Improve the standalone validate_converter.py using the production weight loading
  • Move get_rollout_kwargs_for_parallelism from train_rl to model_creation_utils, works for both single-device and multi-device TP/DP/EP setups

Tests

We have two conversion modes:

  1. for maxtext trainer to vllm maxtext rollout (mode 1), using either transfer_stete_directly() and new weightConverter, standalone tests passed
  2. for maxtext trainer to vllm native rollout (mode 2), using standalone converter Qwen35MaxTextToVLLMConverter, standalone test passed.

Then we have e2e test for post_train/train_rl 10 step smoke tests also passed:

  1. Mode 2, with vllm native HF layout, logs
  2. Mode 1, with vlllm maxtext layout, logs

To vllm maxtext layout, Standalone tests passed, E2E test is ongoing:

python -m maxtext.integration.vllm.validate_converter \
      src/maxtext/configs/post_train/rl.yml \
      model_name=qwen3.5-35b-a3b \
      tokenizer_type=huggingface \
      tokenizer_path=Qwen/Qwen3.5-35B-A3B \
      load_parameters_path='gs://hengtaoguo-maxtext-logs/checkpoints/qwen3.5-35b-a3b/scanned/2026-06-11-10-27/0/items' \
      run_name=validate_qwen35_maxtext_integration \
      vllm_hf_overrides=\"{'architectures': ['MaxTextForCausalLM']}\" \
      vllm_additional_config='{\"maxtext_config\": {\"model_name\": \"qwen3.5-35b-a3b\", \"model_call_mode\": \"inference\", \"enable_dp_attention\": false, \"allow_split_physical_axes\": true, \"log_config\": false, \"weight_dtype\": \"bfloat16\", \"prefuse_moe_weights\": true}, \"use_weight_converter\": false}' \
      use_standalone_converter=False \
      max_prefill_predict_length=128 \
      max_target_length=512 \
      scan_layers=true \
      skip_jax_distributed_system=true \
      weight_dtype=bfloat16 \
      rollout_tensor_parallelism=1 \
      hbm_utilization_vllm=0.85 \
      use_chat_template=False \
      hf_access_token=<token>\
      prompt=\"'Translate the following sentence into French: The quick brown fox jumps over the lazy dog.'\""

To vllm native HF layout, Standalone tests passed, E2E test is ongoing:

python -m maxtext.integration.vllm.validate_converter \
      src/maxtext/configs/post_train/rl.yml \
      model_name=qwen3.5-35b-a3b \
      tokenizer_type=huggingface \
      tokenizer_path=Qwen/Qwen3.5-35B-A3B \
      load_parameters_path='gs://hengtaoguo-maxtext-logs/checkpoints/qwen3.5-35b-a3b/scanned/2026-06-11-10-27/0/items' \
      run_name=validate_qwen35_standalone_integration \
      use_standalone_converter=True \
      max_prefill_predict_length=128 \
      max_target_length=512 \
      scan_layers=true \
      skip_jax_distributed_system=true \
      weight_dtype=bfloat16 \
      rollout_tensor_parallelism=1 \
      hbm_utilization_vllm=0.85 \
      use_chat_template=False \
      hf_access_token=<token>\
      prompt='Translate the following sentence into French - The quick brown fox jumps over the lazy dog.' "

Checklist

Before submitting this PR, please make sure (put X in square brackets):

  • I have performed a self-review of my code. For an optional AI review, add the gemini-review label.
  • I have necessary comments in my code, particularly in hard-to-understand areas.
  • I have run end-to-end tests tests and provided workload links above if applicable.
  • I have made or will make corresponding changes to the doc if needed, including adding new documentation pages to the relevant Table of Contents (toctree directive) as explained in our documentation.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request integrates MaxText with Tunix and Raiden weight synchronization for RL post-training. Key changes include re-exporting Tunix's shared trainer data types to avoid type mismatches, refactoring MaxTextTrainingEngine to support dynamic/static batch splitting for JIT compilation, and implementing chunked Raiden weight synchronization to prevent host memory OOMs. Additionally, the weight conversion and validation pipelines are updated to align with production rollout behavior. Review feedback suggests treating nnx.Param as a leaf during tree_map in unscan_layers to avoid double-wrapping, and converting nnx.State to a standard dictionary before flattening in _split_into_chunks to ensure robustness against future Flax NNX refactorings.

Comment thread src/maxtext/integration/tunix/weight_mapping/raiden_unscan.py
Comment thread src/maxtext/training_engine/maxtext_engine.py
@YixuanWang-99
YixuanWang-99 force-pushed the yixuann-weightsync-rebased-on-mohit branch from 27902b5 to af235d0 Compare August 28, 2026 17:28
Comment thread src/maxtext/integration/vllm/maxtext_vllm_rollout.py Outdated
@YixuanWang-99
YixuanWang-99 force-pushed the yixuann-weightsync-rebased-on-mohit branch from 08a81fc to f748fb4 Compare August 29, 2026 03:52
@YixuanWang-99 YixuanWang-99 changed the title [Maxtext][Tunix] Direct Weight Conversion for Qwen3.5-35B [Maxtext][Tunix] Fix Weight Conversion for Qwen3.5-35B Aug 29, 2026
@YixuanWang-99
YixuanWang-99 force-pushed the yixuann-weightsync-rebased-on-mohit branch from 4738a55 to d5e1e01 Compare August 31, 2026 22:56
@YixuanWang-99
YixuanWang-99 force-pushed the yixuann-weightsync-rebased-on-mohit branch from d5e1e01 to 4521fc5 Compare August 31, 2026 23:05
@codecov

codecov Bot commented Aug 31, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants