Fix OOM in to_huggingface conversion and stabilize post-training E2E TPU pipelines - #4937
Draft
SurbhiJainUSC wants to merge 1 commit into
Draft
Fix OOM in to_huggingface conversion and stabilize post-training E2E TPU pipelines#4937SurbhiJainUSC wants to merge 1 commit into
SurbhiJainUSC wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces memory optimizations in the Hugging Face checkpoint conversion process by popping state dictionary keys and invoking garbage collection. It also adds support for specifying a target weight data type when restoring Orbax checkpoints, and updates various TPU end-to-end RL test scripts with new environment variables and execution parameters. Feedback is provided regarding the handling of tuple keys during state dictionary popping to prevent potential downstream crashes if subkeys are missing.
SurbhiJainUSC
force-pushed
the
post_train_dag
branch
3 times, most recently
from
August 18, 2026 20:49
f223d8f to
b8ef6b3
Compare
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
SurbhiJainUSC
force-pushed
the
post_train_dag
branch
11 times, most recently
from
August 19, 2026 20:02
38c1a95 to
f5ed603
Compare
SurbhiJainUSC
force-pushed
the
post_train_dag
branch
from
August 19, 2026 20:04
f5ed603 to
c62c80c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes the following issues caught by TPU post-training E2E pipeline:
Checkpoint Conversion:
state_dictand triggergc.collect()per iteration in_transform_weights_to_full_modelto prevent host RAM accumulation and OOM-kill on large models (e.g., Llama 3.1 70B).checkpoint_dictafter state dict extraction.ocp.ArrayRestoreArgsinload_orbax_checkpointwhenweight_dtypeis specified, reducing initial checkpoint memory footprint.LLaMA 3.1 70B RL failure:
VLLM_WORKER_MULTIPROC_METHOD=spawn,VLLM_ENABLE_V1_MULTIPROCESSING=0,GRPC_ENABLE_FORK_SUPPORT=0,PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=upb).use_pathways=${use_pathways}totrain_rlandvllm_decodeto prevent falling back to Pathways execution on standard distributed JAX/XPK clusters.chips_per_vm=4andmax_target_length=512for stable GRPO training on TPU v5p slices.Gemma 3 / Gemma 4 Post-Training E2E Tests:
export DATASET_PATH=gs://maxtext-datasettotest_gemma3_multimodal_sft.sh.use_pathwaysforwarding totest_gemma3_rl.sh.test_gemma4_rl.shwithbatch_size=1,chips_per_vm=4, andmax_target_length=512.Tests
E2E tests
Checklist
Before submitting this PR, please make sure (put X in square brackets):
gemini-reviewlabel.