[hardware, recipe] fix: set --xla_tpu_bf16_emission_mode=PROMOTE_F32 in the TPU GRPO recipes #8301
<!-- coderabbit-ai-generated:v1 -->
<!-- This is an auto-generated comment: summarize by coderabbit.ai -->
<!-- review_stack_entry_start -->
<a href="https://app.coderabbit.ai/change-stack/verl-project/verl/pull/8301?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=3"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3" alt="Review in Change Stack →" height="32"></picture></a>
<!-- review_stack_entry_end -->
<!-- recent_review_start -->
No actionable comments were generated in the recent review.
<details>
<summary><strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/info.svg" width="16" height="16" align="absmiddle" alt=""></picture> Recent review info</strong></summary>
<dl>
<dd>
<!-- review_info_content -->
<details>
<summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog.svg" width="16" height="16" align="absmiddle" alt=""></picture> Run configuration</strong></summary>
<dl>
<dd>
a0561867-6645-45ed-88a8-cbd6a044a912</dd>
</dl>
</details>
<details>
<summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal.svg" width="16" height="16" align="absmiddle" alt=""></picture> Commits</strong></summary>
<dl>
<dd>
Reviewing files that changed from the base of the PR and between e017837c8a05281a9b1b061caa566543d977dfa8 and 26327f3dd45fd66d2aa47088758ba8a10c66c03c.
</dd>
</dl>
</details>
<details>
<summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner.svg" width="16" height="16" align="absmiddle" alt=""></picture> Files selected for processing: 2</strong></summary>
<dl>
<dd>
examples/tpu/grpo/run_qwen3_0_6b_torchtitan.sh
examples/tpu/grpo/run_qwen3_4b_torchtitan.sh
</dd>
</dl>
</details>
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
</dd>
</dl>
</details>
<!-- recent_review_end -->
<!-- walkthrough_start -->
<details>
<summary><strong>📝 Summary</strong></summary>
<dl>
<dd>
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
Summary by CodeRabbit
Improvements
TPU 7x runs sigmoid, SiLU, and GELU computations in f32 when using the affected GRPO launch configurations. TPU v6e behavior is unchanged.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Both Qwen3 TorchTitan GRPO launch scripts add --xla_tpu_bf16_emission_mode=PROMOTE_F32 to LIBTPU_INIT_ARGS. Comments describe its stated effect on TPU 7x and v6e.
Changes: TPU GRPO Launch Configuration
|Layer / File(s)|Summary|
|:---|:---|
|Configure bf16 emission mode <br> examples/tpu/grpo/run_qwen3_0_6b_torchtitan.sh, examples/tpu/grpo/run_qwen3_4b_torchtitan.sh|Both scripts add the PROMOTE_F32 flag to LIBTPU_INIT_ARGS and describe its stated behavior. The existing launch-barrier setting remains.|
Suggested reviewers: lixali
</dd>
</dl>
</details>
<!-- walkthrough_end -->
<!-- change_assessment_start -->
<strong>Priority: <picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/priority-normal-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Normal</strong>
<!-- change_assessment_commit:"26327f3dd45fd66d2aa47088758ba8a10c66c03c" -->
<!-- change_assessment_end -->
<details>
<summary><strong>Merge Risk:</strong> <strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/risk-unassessed-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Minimal</strong> · up to <code>26327</code></summary>
<dl>
<dd>
<!-- final_review_risk_start -->
<!-- final_review_risk_label
Merge Risk: ⚪ Minimal · up to 26327
-->
<!-- final_review_risk_coverage:{"sourceCommitId":"26327f3dd45fd66d2aa47088758ba8a10c66c03c","coveredCommitId":"26327f3dd45fd66d2aa47088758ba8a10c66c03c","kind":"reviewed"} -->
The TPU launch configuration is mergeable with no identified actionable risk.
<!-- final_review_risk_end -->
</dd>
</dl>
</details>
<details>
<summary><strong>Security architecture risk:</strong> <strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/risk-low-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Low</strong> · up to <code>e0178</code></summary>
<dl>
<dd>
<!-- architecture_review_start -->
<!-- architecture_review_label
Security Architecture Review
Security architecture risk: 🔵 Low · up to e0178
-->
The change does not visibly broaden access or privileges. Remaining uncertainty concerns whether the setting is supported and consistently applied across all distributed processes.
Retained concerns
No architecture-level concerns identified.
<details>
<summary><strong>Security review details</strong></summary>
<dl>
<dd>
Security Blast Radius
Trust Boundaries and Controls
Hardening Proposals
</dd>
</dl>
</details>
<!-- architecture_review_end -->
</dd>
</dl>
</details>
<!-- pre_merge_checks_walkthrough_start -->
<details>
<summary><strong>Pre-merge checks: <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> 5</strong></summary>
<dl>
<dd>
| Check name | Status | Explanation |
| :------------------------ | :--------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Title check | !Passed | The title names the change: adding --xla_tpu_bf16_emission_mode=PROMOTE_F32 to the TPU GRPO recipes. The raw summary covers both recipe scripts, which matches the title's scope. The title follows the … |
| Description check | !Passed | The description states that both TPU GRPO recipe scripts add the flag to LIBTPU_INIT_ARGS. It explains the reason (bf16 transcendental chains on TPU 7x), gives measurements, and names the dependency o… |
| Docstring Coverage | !Passed | No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within survi… |
| Linked Issues check | !Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | !Passed | Check skipped because no linked issues were found for this pull request. |
<details>
<summary><strong>Full details: Title check</strong></summary>
<dl>
<dd>
Explanation
The title names the change: adding --xla_tpu_bf16_emission_mode=PROMOTE_F32 to the TPU GRPO recipes. The raw summary covers both recipe scripts, which matches the title's scope. The title follows the [modules] type: description format.
</dd>
</dl>
</details>
<details>
<summary><strong>Full details: Description check</strong></summary>
<dl>
<dd>
Explanation
The description states that both TPU GRPO recipe scripts add the flag to LIBTPU_INIT_ARGS. It explains the reason (bf16 transcendental chains on TPU 7x), gives measurements, and names the dependency on a hardware-plugin change. It is related to the changeset.
</dd>
</dl>
</details>
<details>
<summary><strong>Full details: Docstring Coverage</strong></summary>
<dl>
<dd>
Explanation
No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 2 files.
</dd>
</dl>
</details>
</dd>
</dl>
</details>
<!-- pre_merge_checks_walkthrough_end -->
<!-- autopilot:start -->
<!-- autopilot:end -->
<!-- tips_start -->
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
<details>
<summary><strong>❤️ Share</strong></summary>
<dl>
<dd>
</dd>
</dl>
</details>
<sub>Comment @coderabbitai help to get the list of available commands.</sub>
<!-- tips_end -->
 <br/>All committers have signed the CLA.
maybe don't need to mention this is readme? it might be confuse to our customer.
just one sentence comment maybe with something like:
This flag promotes f32 (instead of bf16) for sigmoid/SiLU/GELU with TPU v7, for RL stability.
Approved these changes.
Done
Done
Approved these changes.
jialei777
gutianyu-google
<!-- repo: verl-project/verl | head: gutianyu-google:tpu7x-bf16-promote-f32 | base: main -->
<!-- title: [hardware, recipe] fix: set --xla_tpu_bf16_emission_mode=PROMOTE_F32 in the TPU GRPO recipes -->
What does this PR do?
Both TPU GRPO recipes (
examples/tpu/grpo/run_qwen3_0_6b_torchtitan.sh,run_qwen3_4b_torchtitan.sh) add--xla_tpu_bf16_emission_mode=PROMOTE_F32toLIBTPU_INIT_ARGS, with a one-line comment.On TPU 7x, XLA's default emission mode compiles bf16 transcendental chains (sigmoid, SiLU, tanh-GELU) natively in bf16, rounding at every step; on v6e the same chains are promoted to f32 and rounded once. The difference is in the compiled HLO (reproducible offline with libtpu 0.0.47 and 0.0.50) and its effect on Qwen3 is large: about 1.8x the SiLU error and 5x the logits error against an fp32 reference, greedy GSM8K evaluations inflated by about 8 pp, and a trainer/rollout
ppo_klof 0.008-0.010 instead of about 0.0015. With the flag, TPU 7x compiles these chains exactly like v6e; on v6e the flag changes nothing.Port of jialei777/verl-upstream#78 to the two recipes that exist here.
Checklist Before Starting
[{modules}] {type}: {description}Test
CI cannot cover this (TPU 7x hardware). Measured on TPU 7x with the Qwen3-4B recipe (verl
tpu-main+ plugin8619e2dc): rollout throughput -0.4%, trainer FFN step time unchanged; a 10-step GRPO run with only this flag (no code patches) matched v6e end to end (step-0 GSM8K 0.5466 vs v6e 0.5504,ppo_kl0.0011-0.0021 vs 0.008-0.010 without the flag); three 250-step chains with the flag land on the v6e and H100 trajectories. On 2 x v6e-4 the recipes run as before (the flag is a no-op there).API and Usage Example
No API change. The flag is on by default in both scripts; it only governs XLA-compiled ops (Pallas kernels cast on their own) and is an internal
xla_tpu_*flag, so it is pinned together with the image's libtpu version.Design & Code Changes
export LIBTPU_INIT_ARGS=...lines, with a one-line comment.LIBTPU_INIT_ARGSto the Ray workers (plugin PR "forward the driver's LIBTPU_INIT_ARGS and XLA_FLAGS to the Ray workers"); without it the recipes'exportstops at the driver, as it does today for--xla_tpu_use_enhanced_launch_barrier=false.Related, found while validating on TPU 7x with this stack (separate PRs): the Dockerfile does not install
orjson, which verl main imports at platform-registration time, and the 0.6B script's batch (4 prompts x 8 samples, micro batch 8) does not divide over more than 4 trainer chips, so the README's own 2 xv6e-8variant fails inref_compute_ref_log_prob.Checklist Before Submitting
ci-requestchannel.