Skip to content

Fix Qwen 3.5 35B RL gibberish output issue and show end-to-end RL convergence - #4770

Open
AntonyMei wants to merge 13 commits into
mainfrom
yixuanm-qwen35-rl-fixes-clean
Open

Fix Qwen 3.5 35B RL gibberish output issue and show end-to-end RL convergence#4770
AntonyMei wants to merge 13 commits into
mainfrom
yixuanm-qwen35-rl-fixes-clean

Conversation

@AntonyMei

@AntonyMei AntonyMei commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Description

This PR fixes the Qwen 3.5 RL gibberish output issue and shows end-to-end RL training convergence with Qwen 3.5 35B + v5p-64 on GSM8K. This is a clean up of the fixes in yixuanm-dev-35b-new branch.

FIXES: b/521604343
FIXES: b/542769108

Tests

On yixuanm-dev-35b-new, Qwen 3.5 35B + v5p-64 on GSM8K shows end-to-end convergence:
gs://yixuanm-maxtext-logs/ConvergenceTesting/ym-qw35-35/tensorboard

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 adds support for Qwen3.5 post-training reinforcement learning (RL) using GRPO on TPU hardware. Key enhancements include a hybrid cache layout helper for Qwen's Gated DeltaNet (GDN) to prevent silent quantization, scanned-weight unrolling for direct MaxText-to-MaxText weight synchronization, support for partial multi-dimensional rotary position embeddings (MRoPE), and dynamic replication of batch dimensions in the Mixture of Experts (MoE) layer to avoid sharding mismatches. Additionally, answer extraction utilities have been updated to handle prefilled reasoning start tokens. The code review feedback suggests several robustness improvements, including converting all path segments to strings during weight unrolling, adding defensive checks for null values in the MoE layer to prevent AttributeError crashes, and making the answer extraction regex robust to empty reasoning blocks.

Comment thread src/maxtext/integration/vllm/maxtext_vllm_rollout.py Outdated
Comment thread src/maxtext/layers/moe.py Outdated
Comment thread src/maxtext/layers/moe.py Outdated
Comment thread src/maxtext/trainers/post_train/rl/utils_rl.py Outdated
Comment thread src/maxtext/utils/sharding.py Outdated
Comment thread src/maxtext/layers/moe.py
Comment thread src/maxtext/layers/moe.py Outdated

@NuojCheng NuojCheng left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Sharding and MoE components LGTM if my comments are resolved. Thank you for the code cleanup Yixuan!

Comment thread src/maxtext/integration/vllm/maxtext_vllm_rollout.py
Comment thread src/maxtext/utils/sharding.py
Comment thread src/maxtext/configs/post_train/rl_gsm8k_qwen35_35b_v5p64.yml Outdated
Comment thread src/maxtext/integration/vllm/maxtext_vllm_adapter/adapter.py Outdated
Comment thread src/maxtext/integration/vllm/hybrid_cache_utils.py
Comment thread src/maxtext/layers/embeddings.py
Comment thread tests/post_training/unit/extract_answer_test.py Outdated
@AntonyMei
AntonyMei force-pushed the yixuanm-qwen35-rl-fixes-clean branch from 6567fec to 92c2eca Compare August 8, 2026 02:25
@AntonyMei
AntonyMei force-pushed the yixuanm-qwen35-rl-fixes-clean branch from 92c2eca to afa2658 Compare August 10, 2026 22:11

@A9isha A9isha left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks a lot Yixuan!

@AntonyMei
AntonyMei force-pushed the yixuanm-qwen35-rl-fixes-clean branch from 5be4e3f to 45b2dda Compare August 11, 2026 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants