Repository navigation
PR #45682: pjrt: propagate Prepare failure on non-two-phase multi-device Execute - #123626
Merged
Merged
Conversation
copybara-service
Bot
force-pushed
the
exported_pr_950753335
branch
3 times, most recently
from
July 20, 2026 14:36
6eaee3f to
2a1ba87
Compare
3 tasks
copybara-service
Bot
force-pushed
the
exported_pr_950753335
branch
11 times, most recently
from
July 24, 2026 09:06
ea7389d to
14371f2
Compare
…ice Execute Imported from GitHub PR openxla/xla#45682 ## The bug `CommonPjRtLoadedExecutable::Execute`'s multi-device path calls `ExecutePrepareWithOomRetries` per device, then — only when `supports_two_phase_launch()` is true — checks the returned status inside the two-phase barrier block. `CpuClient` overrides `supports_two_phase_launch()` to `false`, so on a multi-device CpuClient a Prepare failure is never checked and execution falls through to `ExecuteLaunch(*launch_args, ...)` with `launch_args.executable` still null → null-deref crash instead of a clean error. ## The fix Add an `else if (!launch_status.ok())` branch after the two-phase block: record the failure in `results[i]`, decrement `launching` under `mu`, return. Same shape as the two-phase failure path minus the barrier it doesn't participate in. ## Scope `CpuClient` is the only in-tree client with `supports_two_phase_launch()==false`. Two-phase clients (GPU/TPU stream-executor) are unchanged — the diff is purely additive. ## Test `MultiDevicePrepareFailurePropagatesError` in `[cpu_client_test.cc](http://cpu_client_test.cc/)`: 2-device CpuClient, 2-replica identity program, wrong-size buffer on device 1 so `CheckBufferCompatibilities` rejects it during Prepare. Asserts `Execute()` returns an error (not a crash) and that the error comes from the per-device Prepare path. Copybara import of the project: -- 1e96c1e75c504728fe20c950b4d46ea7ad464b59 by Nikhil Bhargava <[email protected]>: pjrt: propagate Prepare failure on non-two-phase multi-device Execute When supports_two_phase_launch()==false (CpuClient), the multi-device Execute path never checked the status returned by ExecutePrepareWithOomRetries — the only check was inside the two-phase branch. A Prepare failure fell through to ExecuteLaunch with launch_args.executable still null and crashed. Add the missing status check on the non-two-phase path: record the failure in results[i], decrement the launching counter under mu, and return — mirroring the two-phase failure handling without the barrier. Test: MultiDevicePrepareFailurePropagatesError in cpu_client_test.cc creates a 2-device CpuClient, passes a wrong-size buffer on one device so CheckBufferCompatibilities rejects it during Prepare, and asserts Execute() returns an error rather than crashing. Merging this change closes #45682 PiperOrigin-RevId: 953266494
copybara-service
Bot
force-pushed
the
exported_pr_950753335
branch
from
July 24, 2026 10:30
14371f2 to
ca79409
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.
PR #45682: pjrt: propagate Prepare failure on non-two-phase multi-device Execute
Imported from GitHub PR openxla/xla#45682
The bug
CommonPjRtLoadedExecutable::Execute's multi-device path callsExecutePrepareWithOomRetriesper device, then — only whensupports_two_phase_launch()is true — checks the returned status inside the two-phase barrier block.CpuClientoverridessupports_two_phase_launch()tofalse, so on a multi-device CpuClient a Prepare failure is never checked and execution falls through toExecuteLaunch(*launch_args, ...)withlaunch_args.executablestill null → null-deref crash instead of a clean error.The fix
Add an
else if (!launch_status.ok())branch after the two-phase block: record the failure inresults[i], decrementlaunchingundermu, return. Same shape as the two-phase failure path minus the barrier it doesn't participate in.Scope
CpuClientis the only in-tree client withsupports_two_phase_launch()==false. Two-phase clients (GPU/TPU stream-executor) are unchanged — the diff is purely additive.Test
MultiDevicePrepareFailurePropagatesErrorin[cpu_client_test.cc](http://cpu_client_test.cc/): 2-device CpuClient, 2-replica identity program, wrong-size buffer on device 1 soCheckBufferCompatibilitiesrejects it during Prepare. AssertsExecute()returns an error (not a crash) and that the error comes from the per-device Prepare path.Copybara import of the project:
--
1e96c1e75c504728fe20c950b4d46ea7ad464b59 by Nikhil Bhargava [email protected]:
pjrt: propagate Prepare failure on non-two-phase multi-device Execute
When supports_two_phase_launch()==false (CpuClient), the multi-device
Execute path never checked the status returned by
ExecutePrepareWithOomRetries — the only check was inside the two-phase
branch. A Prepare failure fell through to ExecuteLaunch with
launch_args.executable still null and crashed.
Add the missing status check on the non-two-phase path: record the
failure in results[i], decrement the launching counter under mu, and
return — mirroring the two-phase failure handling without the barrier.
Test: MultiDevicePrepareFailurePropagatesError in cpu_client_test.cc
creates a 2-device CpuClient, passes a wrong-size buffer on one device
so CheckBufferCompatibilities rejects it during Prepare, and asserts
Execute() returns an error rather than crashing.
Merging this change closes #45682
FUTURE_COPYBARA_INTEGRATE_REVIEW=openxla/xla#45682 from nbhargava:pjrt-non-two-phase-prepare-error 1e96c1e75c504728fe20c950b4d46ea7ad464b59