← Back to Pull requests

[hardware, recipe] fix: set --xla_tpu_bf16_emission_mode=PROMOTE_F32 in the TPU GRPO recipes #8301

Closed
gutianyu-google closed this pull request without merging on Oct 28, 2026 04:52 UTC
View on GitHub
gutianyu-google gutianyu-google commented on Oct 20, 2026 17:21 UTC
Author

<!-- 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_F32 to LIBTPU_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_kl of 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

  • Search for similar PRs: https://github.com/verl-project/verl/pulls?q=is%3Apr+xla_tpu_bf16_emission_mode (none)

  • Format the PR title as [{modules}] {type}: {description}
  • Test

    CI cannot cover this (TPU 7x hardware). Measured on TPU 7x with the Qwen3-4B recipe (verl tpu-main + plugin 8619e2dc): 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_kl 0.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

  • The two export LIBTPU_INIT_ARGS=... lines, with a one-line comment.

  • Depends on verl-hardware-plugin forwarding the driver's LIBTPU_INIT_ARGS to the Ray workers (plugin PR "forward the driver's LIBTPU_INIT_ARGS and XLA_FLAGS to the Ray workers"); without it the recipes' export stops at the driver, as it does today for --xla_tpu_use_enhanced_launch_barrier=false.

  • Rebased on main after #8288; the scripts merge cleanly.

  • Review (jialei777): the README section was dropped and the script comment cut to one sentence, so the README stays customer-facing.
  • 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 x v6e-8 variant fails in ref_compute_ref_log_prob.

    Checklist Before Submitting

  • Read the Contribute Guide.

  • Apply pre-commit checks (shell only).

  • Add / Update the documentation: not needed, the flag is explained by its comment.

  • Add unit or end-to-end test(s): not feasible, needs TPU 7x hardware; measurements above.

  • Once your PR is ready for CI, send a message in the ci-request channel.
  • Diff: 6 lines (+4 / -2) across 2 files Reviewer: jialei777 Review duration: 10770m
    All Vouch review confidence checks passed
    Residual risk 0.03 = Change Risk (0.16) × (1 − Review Confidence (0.81)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.16 · 6 lines diff across 2 files
    0.16
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.71 · 5 substantive comment(s)
    0.71
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    81%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.116
    Real PR Conversation Timeline
    9 items
    coderabbitai[bot] coderabbitai[bot] commented on Oct 20, 2026 17:21 UTC
    Bot

    <!-- 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&amp;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>

  • Source mode: Auto

  • Repository: Unavailable

  • Branch: Unavailable

  • File: No configuration file from this repository applied

  • Commit: Unavailable

  • Layers: Organization UI

  • Review profile: CHILL

  • Plan: Advanced

  • Run ID: 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

  • _inferred_ — The changed behavior is scoped to libtpu initialization for processes launched by these two example recipes. The compared edits introduce no additional credential source, network endpoint, service identity, or resource permission.
  • Trust Boundaries and Controls

  • _observed_ — The new flag value is a fixed string rather than newly accepted caller input. RAY_OVERRIDE_JOB_RUNTIME_ENV and plugin selection predate this PR and remain unchanged. The forwarding uncertainty concerns runtime configuration delivery, not a demonstrated change in authentication or authorization.
  • Hardening Proposals

  • _proposed_ — Validate the flag against the pinned libtpu build and retain startup evidence from every trainer and rollout worker, including replacement workers, confirming delivery before libtpu initialization. This would close the compatibility and propagation gaps without treating them as established vulnerabilities.
  • </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 -->

  • <!-- {"checkboxId":"2708ad07-9f24-4260-9c11-7dc76a49f2e3"} --> <strong title="Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts">Autofix</strong> · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

  • <!-- 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>

  • X

  • Mastodon

  • Reddit

  • LinkedIn
  • </dd>
    </dl>
    </details>

    <sub>Comment @coderabbitai help to get the list of available commands.</sub>

    <!-- tips_end -->

    cla-assistant[bot] cla-assistant[bot] commented on Oct 20, 2026 17:21 UTC
    Bot
    jialei777 jialei777 commented on code on Oct 26, 2026 04:48 UTC
    Code Review
    examples/tpu/grpo/README.md:1
    @@ -147,3 +147,22 @@ The scripts take their settings from environment variables, e.g. `-- RAY_DATA_HO
        The 4B run takes about 10 minutes to start, then about 18-27 s per step (~22 s average over 100 steps).
     
     To scale further to **2 `v6e-8` slices (16 chips)**, create two multi-host node pools with `--machine-type ct6e-standard-4t --num-nodes 2 --tpu-topology 2x4`, set `numOfHosts: 2` and `cloud.google.com/gke-tpu-topology: 2x4` (with `memory: 400Gi`, `cpu: "48"`, `google.com/tpu: "4"`) in [`ray-tpu-v6e-2slice.yaml`](ray-tpu-v6e-2slice.yaml), and run with `NNODES_TRAINER=2 N_CHIPS_TRAINER=4 NNODES_ROLLOUT=2 N_CHIPS_ROLLOUT=4`.
    +
    +## 7. TPU 7x numerics: `--xla_tpu_bf16_emission_mode=PROMOTE_F32`

    maybe don't need to mention this is readme? it might be confuse to our customer.

    jialei777 jialei777 commented on code on Oct 26, 2026 04:51 UTC
    Code Review
    examples/tpu/grpo/run_qwen3_0_6b_torchtitan.sh:1
    @@ -13,7 +13,9 @@ export VERL_USE_EXTERNAL_MODULES=verl_hardware_plugin
     export RAY_OVERRIDE_JOB_RUNTIME_ENV=1
     export RAY_memory_monitor_refresh_ms=0
     export RAY_memory_usage_threshold=0.99
    -export LIBTPU_INIT_ARGS="--xla_tpu_use_enhanced_launch_barrier=false"
    +# PROMOTE_F32: TPU 7x otherwise evaluates bf16 sigmoid/SiLU/GELU chains natively in bf16 (v6e promotes them

    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.

    jialei777 jialei777 approved these changes on Oct 26, 2026 04:51 UTC
    Approved Reviewer

    Approved these changes.

    gutianyu-google gutianyu-google commented on code on Oct 27, 2026 17:19 UTC
    Code Review
    examples/tpu/grpo/README.md:1
    @@ -147,3 +147,22 @@ The scripts take their settings from environment variables, e.g. `-- RAY_DATA_HO
        The 4B run takes about 10 minutes to start, then about 18-27 s per step (~22 s average over 100 steps).
     
     To scale further to **2 `v6e-8` slices (16 chips)**, create two multi-host node pools with `--machine-type ct6e-standard-4t --num-nodes 2 --tpu-topology 2x4`, set `numOfHosts: 2` and `cloud.google.com/gke-tpu-topology: 2x4` (with `memory: 400Gi`, `cpu: "48"`, `google.com/tpu: "4"`) in [`ray-tpu-v6e-2slice.yaml`](ray-tpu-v6e-2slice.yaml), and run with `NNODES_TRAINER=2 N_CHIPS_TRAINER=4 NNODES_ROLLOUT=2 N_CHIPS_ROLLOUT=4`.
    +
    +## 7. TPU 7x numerics: `--xla_tpu_bf16_emission_mode=PROMOTE_F32`

    Done

    gutianyu-google gutianyu-google commented on code on Oct 27, 2026 17:19 UTC
    Code Review
    examples/tpu/grpo/run_qwen3_0_6b_torchtitan.sh:1
    @@ -13,7 +13,9 @@ export VERL_USE_EXTERNAL_MODULES=verl_hardware_plugin
     export RAY_OVERRIDE_JOB_RUNTIME_ENV=1
     export RAY_memory_monitor_refresh_ms=0
     export RAY_memory_usage_threshold=0.99
    -export LIBTPU_INIT_ARGS="--xla_tpu_use_enhanced_launch_barrier=false"
    +# PROMOTE_F32: TPU 7x otherwise evaluates bf16 sigmoid/SiLU/GELU chains natively in bf16 (v6e promotes them

    Done

    jialei777 jialei777 approved these changes on Oct 28, 2026 01:50 UTC
    Approved Reviewer

    Approved these changes.

    Reviewers
    Assignees
    gutianyu-google gutianyu-google
    Labels
    risk: low confidence: 81.1% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 16.1% (LOW) · Higher = larger blast radius
    16.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 81.1% · Lower = rushed or shallow review
    81.1%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 3% · Safe to merge
    3%