Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
vllm_cscc
Commits
a08df832
Unverified
Commit
a08df832
authored
Aug 13, 2024
by
Woosuk Kwon
Committed by
GitHub
Aug 13, 2024
Browse files
[TPU] Support multi-host inference (#7457)
parent
16422ea7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
4 deletions
+11
-4
docs/source/getting_started/tpu-installation.rst
docs/source/getting_started/tpu-installation.rst
+1
-1
vllm/distributed/device_communicators/tpu_communicator.py
vllm/distributed/device_communicators/tpu_communicator.py
+10
-3
No files found.
docs/source/getting_started/tpu-installation.rst
View file @
a08df832
...
...
@@ -8,7 +8,7 @@ vLLM supports Google Cloud TPUs using PyTorch XLA.
Requirements
------------
* Google Cloud TPU VM (single host)
* Google Cloud TPU VM (single
& multi
host)
* TPU versions: v5e, v5p, v4
* Python: 3.10
...
...
vllm/distributed/device_communicators/tpu_communicator.py
View file @
a08df832
import
ray
import
torch
import
torch.distributed
as
dist
from
torch.distributed
import
ProcessGroup
...
...
@@ -18,9 +19,15 @@ class TpuCommunicator:
return
self
.
disabled
=
False
local_rank
=
dist
.
get_rank
(
group
)
world_size
=
dist
.
get_world_size
(
group
)
pjrt
.
initialize_multiprocess
(
local_rank
,
world_size
)
# NOTE(woosuk): When using TP > 1 on TPUs, every TPU on the same node
# must be used together. Therefore, the local rank and world size can
# be simply calculated as follows.
global_rank
=
dist
.
get_rank
(
group
)
global_world_size
=
dist
.
get_world_size
(
group
)
num_nodes
=
len
(
ray
.
nodes
())
local_world_size
=
global_world_size
//
num_nodes
local_rank
=
global_rank
%
local_world_size
pjrt
.
initialize_multiprocess
(
local_rank
,
local_world_size
)
xr
.
_init_world_size_ordinal
()
def
all_reduce
(
self
,
x
:
torch
.
Tensor
)
->
torch
.
Tensor
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment