vllm.distributed.parallel_state ¶
vLLM distributed state. It takes over the control of the distributed environment from PyTorch. The typical workflow is:
- call
init_distributed_environmentto initialize the distributed environment. -
call
initialize_model_parallelorensure_model_parallel_initializedto initialize the model parallel groups. -
any code dealing with the distributed stuff
-
call
destroy_model_parallelto destroy the model parallel groups. - call
destroy_distributed_environmentto destroy the distributed environment.
If you only need to use the distributed environment without model/pipeline parallelism, you can skip the model parallel initialization and destruction steps.
Classes:
-
GroupCoordinator–PyTorch ProcessGroup wrapper for a group of processes.
-
Handle–Minimal async work handle used by P2P send/recv methods.
Functions:
-
checkpoint_prepare_distributed_state–Prepare every device communicator for a process checkpoint.
-
checkpoint_restore_distributed_state–Restore every device communicator after a process checkpoint.
-
destroy_model_parallel–Set the groups to none and destroy them.
-
ensure_model_parallel_initialized–Helper to initialize model parallel groups if they are not initialized,
-
get_etp_group–Return the Engram Tensor Parallel (ETP) group that shards one embedding table.
-
get_node_count–Return the total number of nodes in the distributed environment.
-
get_tensor_model_parallel_rank–Return my rank for the tensor model parallel group.
-
get_tensor_model_parallel_world_size–Return world size for the tensor model parallel group.
-
graph_capture–graph_captureis a context manager which should surround the code that -
in_the_same_node_as–This is a collective operation that returns if each rank is in the same node
-
initialize_model_parallel–Initialize model parallel groups.
-
is_global_first_rank–Check if the current process is the first rank globally across all
-
is_local_first_rank–Check if the current process is the first local rank (rank 0 on its node).
-
model_parallel_is_initialized–Check if tensor and pipeline parallel groups are initialized.
-
resume_device_comms–Restore suspended device communicators (collective).
-
suspend_device_comms–Release device communicator memory (collective; comms must be idle).
GroupCoordinator ¶
PyTorch ProcessGroup wrapper for a group of processes. PyTorch ProcessGroup is bound to one specific communication backend, e.g. NCCL, Gloo, MPI, etc. GroupCoordinator takes charge of all the communication operations among the processes in the group. It manages both CPU and device communication.
Methods:
-
all_reduce–User-facing all-reduce function before we actually call the
-
barrier–Barrier synchronization among the group.
-
broadcast–Broadcast the input tensor.
-
broadcast_object–Broadcast the input object.
-
broadcast_object_list–Broadcast the input object list.
-
broadcast_tensor_dict–Broadcast the input tensor dictionary.
-
gather–NOTE: We assume that the input tensor is on the same device across
-
isend_object–Non-blocking
send_object: isend size + pickled object on the -
isend_tensor_dict–Send the input tensor dictionary asynchronously.
-
make_sibling_device_group–Create a new device-side ProcessGroup with the same per-rank membership
-
recv–Receives a tensor from the source rank.
-
recv_object–Receive the input object list from the source rank.
-
recv_tensor_dict–Recv the input tensor dictionary.
-
send–Sends a tensor to the destination rank in a blocking way
-
send_object–Send the input object list to the destination rank.
-
send_tensor_dict–Send the input tensor dictionary.
Attributes:
-
first_rank–Return the global rank of the first process in the group
-
is_first_rank–Return whether the caller is the first process in the group
-
is_last_rank–Return whether the caller is the last process in the group
-
last_rank–Return the global rank of the last process in the group
-
next_rank–Return the global rank of the process that follows the caller
-
prev_rank–Return the global rank of the process that precedes the caller
Source code in vllm/distributed/parallel_state.py
421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 | |
first_rank property ¶
Return the global rank of the first process in the group
is_first_rank property ¶
Return whether the caller is the first process in the group
is_last_rank property ¶
Return whether the caller is the last process in the group
last_rank property ¶
Return the global rank of the last process in the group
next_rank property ¶
Return the global rank of the process that follows the caller
prev_rank property ¶
Return the global rank of the process that precedes the caller
_reap_completed_isends() ¶
Lazily drop self-retained isend_tensor_dict entries that have completed, oldest first (FIFO).
gloo Work.is_completed() is unreliable (it can report completion before the background copy of the source buffer finishes), so the metadata handle (handles[0], a gloo-backed _RetainedHandle) is never used as the completion gate. Instead we gate on the tensor-send handles (handles[1:]), which run on the device backend where is_completed() is reliable. Once all tensor sends are done the peer must already have posted the matching tensor recvs — and since the receiver ingests metadata before tensors, the gloo metadata send is then guaranteed complete, so wait() on it is ~instant and only serves to drop the retained refs.
Metadata-only entries (handles[1:] empty, e.g. an empty IntermediateTensors) have no reliable completion signal; drop them best-effort without blocking on the gloo metadata wait.
Source code in vllm/distributed/parallel_state.py
all_reduce(input_) ¶
User-facing all-reduce function before we actually call the all-reduce operation.
We need this because Dynamo does not support passing an arbitrary object (self in this case) to a custom op. We need to pass the group name as a string, and then look up the group coordinator from the group name, dispatch the all-reduce operation to the group coordinator.
In addition, PyTorch custom ops do not support mutation or returning a new tensor in the same op. So we always make the all-reduce operation out-of-place.
Source code in vllm/distributed/parallel_state.py
barrier() ¶
Barrier synchronization among the group. NOTE: don't use device_group here! barrier in NCCL is terrible because it is internally a broadcast operation with secretly created GPU tensors. It is easy to mess up the current device. Use the CPU group instead.
Source code in vllm/distributed/parallel_state.py
broadcast(input_, src=0) ¶
Broadcast the input tensor. NOTE: src is the local rank of the source rank.
Source code in vllm/distributed/parallel_state.py
broadcast_object(obj=None, src=0) ¶
Broadcast the input object. NOTE: src is the local rank of the source rank.
Source code in vllm/distributed/parallel_state.py
broadcast_object_list(obj_list, src=0, group=None) ¶
Broadcast the input object list. NOTE: src is the local rank of the source rank.
Source code in vllm/distributed/parallel_state.py
broadcast_tensor_dict(tensor_dict=None, src=0, group=None, metadata_group=None) ¶
Broadcast the input tensor dictionary. NOTE: src is the local rank of the source rank.
Source code in vllm/distributed/parallel_state.py
970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 | |
gather(input_, dst=0, dim=-1) ¶
NOTE: We assume that the input tensor is on the same device across all the ranks. NOTE: dst is the local rank of the destination rank.
Source code in vllm/distributed/parallel_state.py
isend_object(obj, dst) ¶
Non-blocking send_object: isend size + pickled object on the CPU group. Returns a handle that retains the serialized source tensors until wait drains both sends.
Source code in vllm/distributed/parallel_state.py
isend_tensor_dict(tensor_dict, dst=None, all_gather_group=None, all_gather_tensors=None) ¶
Send the input tensor dictionary asynchronously.
The returned handles are additionally self-retained in self._pending_isends (together with the sent source tensors) and reaped lazily on subsequent calls, so fire-and-forget callers that drop the handles cannot free or overwrite the send buffers while the sends are still in flight. Callers that do keep the handles may wait() them as before; the retention entry is dropped on reap either way.
Source code in vllm/distributed/parallel_state.py
1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 | |
make_sibling_device_group(group_desc=None) ¶
Create a new device-side ProcessGroup with the same per-rank membership as this coordinator's device_group, but backed by a distinct communicator. This is a collective call: every world rank must invoke it. Used where we want to issue ops that can run concurrently with ops on device_group.
Source code in vllm/distributed/parallel_state.py
recv(size, dtype, src=None) ¶
Receives a tensor from the source rank.
Source code in vllm/distributed/parallel_state.py
recv_object(src) ¶
Receive the input object list from the source rank.
Source code in vllm/distributed/parallel_state.py
recv_tensor_dict(src=None, all_gather_group=None, all_gather_tensors=None) ¶
Recv the input tensor dictionary. NOTE: src is the local rank of the source rank.
The group for the all-gather operation. If provided,
an optimization is enabled where each rank in the group sends a slice of a tensor and the receiver reconstructs it using an all-gather, which can improve performance. This is typically the tensor-parallel group.
all_gather_tensors: A dictionary to specify which tensors should use the all-gather optimization, which is only effective when all_gather_group is provided. By default, this optimization is on for any tensor whose size is divisible by the all_gather_group's world size. However, it should be disabled for tensors that are not fully replicated across the group (e.g., the residual tensor when sequence parallelism is enabled). This dictionary allows overriding the default behavior on a per-tensor basis.
Source code in vllm/distributed/parallel_state.py
send(tensor, dst=None) ¶
Sends a tensor to the destination rank in a blocking way
Source code in vllm/distributed/parallel_state.py
send_object(obj, dst) ¶
Send the input object list to the destination rank.
Source code in vllm/distributed/parallel_state.py
send_tensor_dict(tensor_dict, dst=None, all_gather_group=None, all_gather_tensors=None) ¶
Send the input tensor dictionary. NOTE: dst is the local rank of the source rank.
The group for the all-gather operation. If provided,
an optimization is enabled where each rank in the group sends a slice of a tensor and the receiver reconstructs it using an all-gather, which can improve performance. This is typically the tensor-parallel group.
all_gather_tensors: A dictionary to specify which tensors should use the all-gather optimization, which is only effective when all_gather_group is provided. By default, this optimization is on for any tensor whose size is divisible by the all_gather_group's world size. However, it should be disabled for tensors that are not fully replicated across the group (e.g., the residual tensor when sequence parallelism is enabled). This dictionary allows overriding the default behavior on a per-tensor basis.
Source code in vllm/distributed/parallel_state.py
Handle ¶
_RetainedHandle ¶
Handle that retains source tensors until all posted work completes.
Used by isend_object to keep the serialized CPU tensors alive while gloo copies them in the background; wait drops the refs once drained.
wait must be idempotent: gloo Work.wait() is single-shot for point-to-point operations — calling it a second time on an already completed send blocks forever (verified empirically). Both the worker's top-of-step drain of _pp_send_work and _reap_completed_isends may wait the same entry's metadata handle, so the second caller must not re-wait the underlying works.
Source code in vllm/distributed/parallel_state.py
_apply_to_device_comms(action) ¶
Apply action to every group's device communicator.
Walks the registered parallel groups and skips those without a device communicator (absent at world_size == 1).
Source code in vllm/distributed/parallel_state.py
_create_subgroups_split_group(group_ranks, group_name, torch_distributed_backend) ¶
Create the device + CPU subgroups for GroupCoordinator via torch.distributed.split_group.
split_group is collective on the parent group, so every parent rank must enter with the same split_ranks definition. Each rank receives the subgroup it belongs to.
Source code in vllm/distributed/parallel_state.py
_device_backend_str(torch_distributed_backend) ¶
Normalize torch_distributed_backend to the "<device>:<backend>" format required by split_group's backend argument.
Accepts either a bare backend name (e.g. "nccl") or an already-prefixed string (e.g. "cuda:nccl").
Source code in vllm/distributed/parallel_state.py
_get_unique_name(name) ¶
Get a unique name for the group. Example: _get_unique_name("tp") -> "tp:0" _get_unique_name("tp") -> "tp:1"
Source code in vllm/distributed/parallel_state.py
_init_process_group_for_split_group(*, backend, distributed_init_method, store, world_size, rank, local_rank, timeout) ¶
Initialize the default PG with both CPU (gloo) and device (e.g. nccl) backends and an eager device_id binding so that subgroups can be created via split_group (which requires the parent communicator to be eagerly initialized). Falls back to gloo on CPU-only systems.
Source code in vllm/distributed/parallel_state.py
_init_stateless_group(group_ranks, group_name, host, backend, coord_store, use_device_communicator=True, use_all2all=False) ¶
Create a StatelessGroupCoordinator with the given parameters.
Source code in vllm/distributed/parallel_state.py
_node_count(pg) ¶
Returns the total number of nodes in the process group.
Parameters:
-
(pg¶ProcessGroup | StatelessProcessGroup) –The process group to analyze
Returns:
-
int(int) –The total number of nodes
Source code in vllm/distributed/parallel_state.py
_platform_device_type() ¶
Return the device-type string (e.g. "cuda", "xpu", "cpu") for the current platform, in the form expected by torch.distributed.init_process_group(backend=...).
Source code in vllm/distributed/parallel_state.py
_replace_active_groups(*, world, dp, ep, eplb, node_count) ¶
Replace the active groups and return the groups they replaced.
The caller must destroy the returned DP, EP, WORLD, and EPLB groups collectively and in that order. Pass all-None to remove the active groups without replacement.
Source code in vllm/distributed/parallel_state.py
_split_tensor_dict(tensor_dict) ¶
Split the tensor dictionary into two parts: 1. A list of (key, value) pairs. If the value is a tensor, it is replaced by its metadata. 2. A list of tensors.
Source code in vllm/distributed/parallel_state.py
_validate_default_pg_for_split_group() ¶
When an external launcher (e.g. torchrun) initialized the default PG, GroupCoordinator cannot patch in additional backends or change the eager-init behavior — split_group only selects subsets of an existing parent. Validate that the parent has both device_id and a CPU (gloo) backend, and emit a descriptive error pointing at the exact init call to update otherwise.
Source code in vllm/distributed/parallel_state.py
checkpoint_prepare_distributed_state() ¶
Prepare every device communicator for a process checkpoint.
Source code in vllm/distributed/parallel_state.py
checkpoint_restore_distributed_state() ¶
Restore every device communicator after a process checkpoint.
Source code in vllm/distributed/parallel_state.py
destroy_model_parallel() ¶
Set the groups to none and destroy them.
Source code in vllm/distributed/parallel_state.py
ensure_model_parallel_initialized(tensor_model_parallel_size, pipeline_model_parallel_size, prefill_context_model_parallel_size=1, decode_context_model_parallel_size=1, backend=None) ¶
Helper to initialize model parallel groups if they are not initialized, or ensure tensor-parallel and pipeline-parallel sizes are equal to expected values if the model parallel groups are initialized.
Source code in vllm/distributed/parallel_state.py
get_etp_group() ¶
Return the Engram Tensor Parallel (ETP) group that shards one embedding table.
get_node_count() ¶
Return the total number of nodes in the distributed environment.
get_tensor_model_parallel_rank() ¶
get_tensor_model_parallel_world_size() ¶
graph_capture(device, graph_capture_context=None) ¶
graph_capture is a context manager which should surround the code that is capturing the CUDA graph. Its main purpose is to ensure that some operations will be run after the graph is captured, before the graph is replayed. It returns a GraphCaptureContext object which contains the necessary data for the graph capture. Currently, it only contains the stream that the graph capture is running on. This stream is set to the current CUDA stream when the context manager is entered and reset to the default stream when the context manager is exited. This is to ensure that the graph capture is running on a separate stream from the default stream, in order to explicitly distinguish the kernels to capture from other kernels possibly launched on background in the default stream.
A caller may pass an explicit graph_capture_context to control the stream used (e.g. to capture on the default stream).
Source code in vllm/distributed/parallel_state.py
in_the_same_node_as(pg, source_rank=0) ¶
This is a collective operation that returns if each rank is in the same node as the source rank. It tests if processes are attached to the same memory system (shared access to shared memory).
Source code in vllm/distributed/parallel_state.py
2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 | |
initialize_model_parallel(tensor_model_parallel_size=1, pipeline_model_parallel_size=1, prefill_context_model_parallel_size=1, decode_context_model_parallel_size=1, backend=None) ¶
Initialize model parallel groups.
Parameters:
-
(tensor_model_parallel_size¶int, default:1) –number of GPUs used for tensor model parallelism.
-
(pipeline_model_parallel_size¶int, default:1) –number of GPUs used for pipeline model parallelism.
-
(backend¶str | None, default:None) –name of torch distributed communication backend.
Let's say we have a total of 8 GPUs denoted by g0 ... g7 and we use 2 GPUs to parallelize the model tensor, and 4 GPUs to parallelize the model pipeline. The present function will create 4 tensor model-parallel groups and 2 pipeline model-parallel groups: 4 tensor model-parallel groups: [g0, g1], [g2, g3], [g4, g5], [g6, g7] 2 pipeline model-parallel groups: [g0, g2, g4, g6], [g1, g3, g5, g7] Note that for efficiency, the caller should make sure adjacent ranks are on the same DGX box. For example if we are using 2 DGX-1 boxes with a total of 16 GPUs, rank 0 to 7 belong to the first box and ranks 8 to 15 belong to the second box.
Source code in vllm/distributed/parallel_state.py
1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 | |
is_global_first_rank() ¶
Check if the current process is the first rank globally across all parallelism strategies (PP, TP, DP, EP, etc.).
Unlike group-specific checks like get_tensor_model_parallel_rank() == 0 or get_pp_group().is_first_rank, this function checks the global rank across all parallelism dimensions.
Returns:
-
bool(bool) –True if this is the global first rank (rank 0), False otherwise. Returns True if distributed is not initialized (single process).
Source code in vllm/distributed/parallel_state.py
is_local_first_rank() ¶
Check if the current process is the first local rank (rank 0 on its node).