Fix Torchax backend on Pathways #1052
Open
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 fixes running the Torchax backend on Pathways. In Pathways, the following line would cause the weights to be loaded onto CPU devices on the controller: https://github.com/vllm-project/tpu-inference/blob/main/tpu_inference/models/vllm/vllm_model_wrapper.py#L108C9-L109C74
This would later raise a failure when the weights are transferred to the TPU device with
jax.device_put(), since the target device is non-PJRT.The fix is to detach the original pytorch/jax tensor wrapper and just use a numpy array for
jax.device_put().If the change fixes a bug or a Github issue, please include a link, e.g.,:
FIXES: b/444030476
Tests
Please describe how you tested this change, and include any instructions and/or
commands to reproduce.
Checklist
Before submitting this PR, please make sure: