vllm.distributed.weight_transfer.sharded_rdt_engine ¶
Sharded Ray Direct Transport (RDT) weight transfer engine.
This backend pulls only the slice that each vLLM worker actually consumes (under tensor/expert parallelism), not the full HF-format tensor.
It works in two phases, keyed per update_weights name set:
-
Bake (first sync for a name set): drive
model.load_weightswithLazyRDTTensorplaceholders that defer materialization. The placeholders intercept a whitelisted set of view/slice ops into a single ordered op chain; the whole payload's slices are fetched in one batched RPC, the trainer replays each chain on its live parameter and ships only the resulting slice. While replaying the loaders, we record a plan: for each leaf module, how each destination slice is fetched (source op-chain) and where it lands (anas_strideddescriptor into a real param). -
Replay (every later sync): no
model.load_weights, no lazy-tensor dispatch, no per-loader discovery. One batched pull, then scatter each recorded slice directly into freshly materialized params, runprocess_weights_after_loading, and copy into kernel storage.
Within a single update_weights call we replay the baked groups its names cover (one batched pull) and route only the residual names — those with no recorded plan (attention/partial-layer finalize path, or experts owned by another EP rank that no-op in their loader) — to the plain per-slice load.
Only valid with is_checkpoint_format=True (layerwise reload). See sharded_weight_loader_rdt.md and baked_rdt_replay.md for the design, and the spike in nixl_slice_spike.py confirming NIXL is view-aware.
LazyRDTTensor ¶
Bases: Tensor
Zero-storage tensor that records how to fetch a weight slice.
Built via _make_wrapper_subclass so .shape/.dtype/.device/ .size()/.dim() work without allocating storage. Every supported op (narrow/view/reshape/transpose/getitem/...) returns a new LazyRDTTensor with the spec appended to its chain; copy_ is the data sink. Its behaviour depends on the _ctx the engine installed:
_BakeRecorder(dry-run bake): record a_BakedCopy(the op chain plus the boundparam_nameand the meta destination's offset/shape/stride) and fire a metacopy_. No data moves.- the trainer's producer method (slow path): a meta destination is a no-op meta
copy_; a real destination pulls this one slice via a singleproduce_methodRPC and copies it in.
Any op outside the allowlist (arithmetic, .item, .to, .float, .data, bool-mask indexing, etc.) raises _UnsupportedLazyOp in __torch_dispatch__ so failures are loud rather than silently fetching the wrong bytes.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 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 | |
_intercept classmethod ¶
_intercept(
self_: LazyRDTTensor,
func: Callable,
op_name: str,
args: tuple,
kwargs: dict,
)
Append the op to self_._ops and return a child (or tuple of children for chunk-like multi-return ops).
Shape/dtype of each child come from running the op on a meta tensor — PyTorch already knows the semantics, no need to reimplement them.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
_make_child ¶
_make_child(
new_shape: Size, new_dtype: dtype, *new_ops: OpSpec
) -> LazyRDTTensor
Append one or more ops to the chain and return a fresh child.
Variadic so multi-return ops (e.g. chunk) can append both the base op and an indexing op in a single call.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
_meta ¶
_meta() -> Tensor
A zero-storage meta tensor of this lazy's current shape/dtype.
Used to compute the post-op shape/dtype via PyTorch itself, which is more reliable than reimplementing shape inference per op. The result is never used for data — only its metadata.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
ShardedRDTWeightTransferEngine ¶
Bases: WeightTransferEngine[ShardedRDTWeightTransferInitInfo, ShardedRDTWeightTransferUpdateInfo]
Pull-based RDT/NIXL backend that transports only the slice each worker consumes.
Requires
distributed_executor_backend="ray"so workers are Ray actors.- The trainer actor is created with
.options(name=...)and exposes a method decorated with@ray.method(tensor_transport="nixl")that takes a list of(name, op_chain)specs and returns a list of slice tensors. The chain is replayed on the trainer's live parameter viagetattr(tensor, op_name)(*args, **kwargs). nixlis installed in the env shared by trainer and workers.is_checkpoint_format=True(layerwise reload).- Weight loaders that only use the supported op set (narrow, view, reshape, transpose, t, permute, getitem with int/slice/tuple, unsqueeze, squeeze, flatten, contiguous, chunk, copy_). Loaders that need .to(), .float(), .item(), .data, bool-mask indexing, or arithmetic on the loaded weight land in
__torch_dispatch__during the bake and raise (not supported by this backend).
The plan is baked once at init_transfer_engine (a meta dry run over init_info.names) into one _BakedGroup per fully-loaded leaf module, indexed by source name. Every update_weights replays the leaf modules its gathered names cover. See the module docstring and baked_rdt_replay.md.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
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 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 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 | |
_bake ¶
_bake(init_info: ShardedRDTWeightTransferInitInfo) -> None
Bake the replay plan once, as a self-driven meta dry run.
We put the model's params on meta (via initialize_layerwise_reload) and then drive model.load_weights over all of init_info.names through the model's original loaders — _install_recording_stamps wraps the original loader, bypassing online_process_loader entirely — so _layerwise_process is never in the path. Nothing materializes, pulls, or kernel-copies; the lazy's copy_ just records, per leaf module, the source op chain + the meta destination's param_name and offset/shape/stride. Afterwards we build one _BakedGroup per fully-loaded leaf module (copied numel == the module's loadable size) and index it by source name; partial / attention / unrecordable modules are left out and take the plain load. The model is restored.
FUTURE / cleanliness: this still reaches into layerwise internals that a richer, public layerwise API should expose first-class — and which a downstream RL framework porting this engine (and unable to patch vLLM) must replicate. vLLM's layerwise reload should grow proper support for these trace-only flows, e.g.: 1. A "currently-loading (module, param_name)" hook so the lazy can attribute each copy_ without us monkeypatching loaders (_install_recording_stamps). 2. A trace/dry-run mode that drives the loaders against meta without materializing or processing — so we don't have to bypass online_process_loader by hand to keep _layerwise_process from firing. 3. A public abort_layerwise_reload to restore without materializing (we hand-roll _place_kernel_tensors + reset in _restore_after_dry_run because finalize_layerwise_reload would materialize real params, defeating the meta/memory win). Until then we lean on existing symbols (initialize_layerwise_reload, _get_original_loader, get_layer_size, _place_kernel_tensors).
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
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 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 | |
_build_call_plan ¶
[RDT-SINGLE-CALL] Build the STATIC plan for one whole-sync call.
PURE — no pulls, no side effects — so the result is cached and reused every sync (see _run_call_plan / _CallPlan). Three passes: 1. Split names into the driver's gather groups; chunk-plan EACH group into flat _Scatter chunks (layerwise_split chunks/group, same working-set/reach math); record each group's last chunk index for free_gather (or pre_free for groups this worker doesn't pull). The concatenated stream has no per-group call boundaries, so group L+1's first chunk issues while group L's chunks still stream. 2. For each leaf module, find its FIRST and LAST chunk (materialize on the first, quant/kernel/reset on the last — replaces the runtime remaining-copy counters, correct materialize-once by construction). 3. Assemble _Chunks: dedup keys + precompute the packed byte layout (16B-aligned, keys order) so the pull path does no per-call work.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 | |
_chunk_group_scatters ¶
_chunk_group_scatters(
groups: list[_BakedGroup],
) -> list[list[_Scatter]]
Cut the groups' copies (group-major, order-stable) into at most layerwise_split byte-balanced chunks of flat _Scatters. Copies are atomic — a single huge copy (e.g. lm_head) becomes its own oversized chunk — and a module's copies may span chunks (materialize/quant fire on its first/last chunk; see _build_call_plan).
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
_complete_pull ¶
_complete_pull(
pending: _PendingPull,
) -> dict[FetchKey, Tensor]
Blocking half of a pull: the NIXL read lands during this ray.get.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
_dispatch_item ¶
_dispatch_item(item: _ProcItem) -> None
Hand one chunk item to the background scatter thread.
Counts the item against its slot BEFORE dispatch: the next pull into that slot must wait until the background thread has processed (and RECORDED the read-done event for) every item ever queued on it.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
_ensure_proc_worker ¶
Lazily create the per-slot events, the background CUDA stream, the work queue, and the single processing thread. Idempotent.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
_fire_free_gather ¶
Fire-and-forget free of one gather group on EVERY bound producer (the engine-side replacement for the driver's free_group in single-call mode).
Under M:N a producer gathered this group (all ranks gather in lockstep) and may have served part of it to this consumer, so every producer this consumer binds must receive the free — even one that served nothing of this group (a chunk's split may not have handed it a run). Each bound producer ref-counts: it frees the group only after all N of its assigned consumers have called, so every assigned consumer must fire regardless of what it actually pulled. Refs are held and drained in drain_pending so every free has executed before the sync ends.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
_global_worker_index ¶
_global_worker_index() -> int
This inference worker's stable, DISTINCT global index across the whole inference fleet: data_parallel_index * world_size + rank where world_size is TPPP and rank is the rank within the TPPP world.
Uses data_parallel_index (NOT data_parallel_rank): vLLM resets data_parallel_rank to 0 in a dense (non-MoE) worker — each dense DP replica is an independent engine — but keeps data_parallel_index as the distinct global DP rank ("not overridden for dense models"). This is the same worker-rank formula the sibling nccl_engine uses, so it is correct with EP on or off, ray or mp: dense served via TP (index = tp_rank) and MoE served via DP+EP (index = dp rank) both yield distinct 0..C-1.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
_install_recording_stamps ¶
_install_recording_stamps(
model: Module, recorder: _BakeRecorder
) -> None
Wrap each loadable param's weight_loader to stamp recorder.current = (leaf_module, param_name) before delegating to the original loader, so the lazy's copy_ can attribute each recorded copy. functools.wraps keeps the loader's real signature (so vLLM's _layerwise_process param redirect still works if a stamp leaks), and _rdt_stamp_inner tags it so _restore_after_dry_run can unwrap it.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
_issue_pull ¶
_issue_pull(chunk: _Chunk, slot: int) -> _PendingPull
Reserve slot, lay the targets out in its arena, dispatch the produce RPC and point the transfer at the arena — WITHOUT the blocking ray.get (that is _complete_pull). The chunked pipeline issues chunk i+1 before completing chunk i, so the producer serves the next chunk while the in-flight RDMA streams.
Slot-reuse guard, TWO stages, both required: (1) generation wait — the CUDA event only binds to its LAST record(), so first wait for the background thread to have RECORDED the event for every item ever queued on this slot (else the synchronize binds to a stale record and passes silently — observed as nondeterministic weight corruption); (2) event synchronize — waits for the recorded scatters to finish on the GPU. Note the transfer may start any time after set_target_for_ref (metadata push), so the guard must precede it, not just the get.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
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 | |
_load_unbaked ¶
_load_unbaked(
names: list[str],
load_weights: Callable[
[list[tuple[str, Tensor]]], None
],
) -> None
Plain load for a call whose names aren't all baked: rebuild lazies for names (dtype/shape from the init metadata) and run vLLM's stock inline layerwise reload — the worker's initialize_layerwise_reload is active for the sync, so each layer is processed as it completes and the lazy's Pass-2 copy_ pulls its slice on demand. No recording, no batching; runs every sync for the call (the rare, unbaked case).
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
_log_timing staticmethod ¶
_log_timing(
mode: str,
total_seconds: float,
pull_seconds: float,
pull_calls: int,
process_seconds: float,
nixl_delta: dict | None = None,
phase_split: dict | None = None,
pull_bytes: int = 0,
) -> None
Log a one-line timing summary for one receive_weights call.
mode is replay or unbaked. pull_seconds is the full ray.get round trip; nixl_delta (when present) splits that into the consumer-side registration / transfer / deregistration AND the produce_wait / recv_wall cleave measured by the NIXL patch. process_seconds is the scatter/materialize/quantize/kernel-copy work after the pull; phase_split (when present) breaks it into its per-phase *_seconds (from the engine's PhaseTimer). pull_bytes is the bytes THIS worker pulled this call, logged as bytes so the driver can compute true per-worker bandwidth (bytes/transfer) and distinguish an EP-imbalance straggler (more bytes) from a transport straggler (equal bytes, lower GB/s).
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
_mark_slot_done ¶
_mark_slot_done(slot: int) -> None
Publish that a queued item's read-done event has been recorded (or the item failed) so a pull waiting to reuse slot can proceed to its CUDA-event synchronize.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
_num_consumers ¶
_num_consumers() -> int
Total inference-worker count. Prefer the driver-supplied init_info.num_consumers (authoritative — the driver knows the full fleet); else infer data_parallel_size * tensor_parallel_size, which is correct for the SUPPORTED serving modes (dense→TP keeps tensor_parallel_size; MoE→DP+EP keeps data_parallel_size). It is only wrong for DP-over-dense, which vLLM itself rejects as "not supported/useful for dense models".
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
_preregister_at_init ¶
Register every NIXL buffer this worker will use, at init, before any transfer runs — so nothing registers during the sync-0 RDMA churn.
Both sides are sized from the (static) cached plan: * consumer receive arenas: _NSLOTS uint8 ring slots, each sized to the largest chunk's packed bytes (pack_bytes); * producer serve rings: each bound producer is asked (reserve_serve_arena) to pre-register a ring at the max bytes THIS consumer will pull from it (the max byte_end-byte_start over that producer's sub-pulls). A no-op if there is no pre-built plan (the lazy back-compat path keeps registering on first use, which is safe in the 1:1 / P>=C regimes).
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
_proc_worker_loop ¶
Single persistent thread: run each queued item's process phase on the background stream. Exits on the None sentinel (shutdown). An item that raises is recorded in _proc_error and re-raised on the RPC thread / at drain, so a failed sync fails loudly rather than corrupting silently.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
_process_item ¶
_process_item(item: _ProcItem) -> None
Scatter-thread half: materialize this chunk's first-seen modules + scatter its slices on the process stream, publish the slot, then hand the modules this chunk COMPLETES to the quant thread (see _run_quant).
Mirrors _layerwise_process minus the loader replay; the quant / kernel-copy / info.reset() tail runs on the quant thread, ordered after this chunk's scatters via a recorded event.
After all scatters that read item.slot's arena are enqueued on the process stream, record the slot's read-done event so the RPC thread can block on it before overwriting the slot with a later pull.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
1921 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 | |
_pull ¶
The single NIXL pull site: one batched RPC for keys (a set/list of (name, op_chain)), returning {key: slice tensor}.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
_quant_worker_loop ¶
Dedicated quant thread: drains (completed_modules, scatter-done event) batches. Errors surface via _proc_error like the scatter thread's.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
_raise_proc_error ¶
Re-raise (once) any error captured by the background thread.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
_restore_after_dry_run ¶
_restore_after_dry_run(model: Module) -> None
Restore each layerwise layer's saved kernel tensors without pulling (a real finalize_layerwise_reload would materialize/load) and reset its info. Also unwrap any recording stamp left on the params, since a leaked stamp would sit under the next sync's online_process_loader and silently break _layerwise_process's param redirect.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
_run_call_plan ¶
Execute a (cached) call plan: run the chunk pipeline (each chunk self-describes its scatter/materialize/quant/free work), return the residual names for the plain-load fallback.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
_run_chunk_pipeline ¶
_run_chunk_pipeline(plan: _CallPlan) -> None
[RDT-RING] Pipelined chunk pulls over the ring of receive slots.
Issues up to _NSLOTS produce RPCs ahead of the blocking gets, so while chunk i's RDMA streams (inside its ray.get): the producer serves chunk i+1 into ITS ring slot, and the background thread scatters chunk i-1 out of another receive slot. Reads themselves stay serialized (they share the flow's NIC — that is the bandwidth floor, not a loss).
Producer-ring safety needs no coordination: chunk i+K is issued only after chunk i's get returned (drain-before-issue below), so by the time produce call #(i+K) reuses producer slot (i mod K), read #i is done. Consumer-slot safety is _issue_pull's generation handshake; the drain of chunk i-K (which queues its scatter and bumps queued[slot]) strictly precedes the issue of chunk i on the same thread.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 | |
_run_quant ¶
Quant/kernel-copy/reset the given COMPLETED leaf modules, exactly as _layerwise_process. Runs on the quant thread's own stream, ordered after the modules' scatters via ready; touches only the scattered params (never a receive slot), so it can overlap subsequent chunks' RDMA and scatters. info.reset() is what makes finalize skip the layer — drain_pending joins the quant queue before finalize runs.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
_scatter_of ¶
_scatter_of(layer: Any, c: _BakedCopy) -> _Scatter
Build a self-contained _Scatter from a bake-time _BakedCopy, folding in the produced slice's dtype/nbytes (dtype from the source name's metadata; produced shape == the destination region c.shape).
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
_select_producer_indices ¶
The producers this worker binds under the M:N block rule (assign_producer_indices). With P==C this is the identity map (worker i -> trainer i, one producer). With P>C the worker binds a contiguous block of producers and splits its pulls across them; with C>P several workers share one producer. Isolated so a future policy (rail-aware, per-layer rotation) can replace this decision without touching the pull path.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
_split_chunk_pull ¶
_split_chunk_pull(
keys: list[FetchKey],
pack_layout: list[
tuple[int, dtype, int, tuple[int, ...]]
],
pack_bytes: int,
) -> list[tuple[int, list[FetchKey], int, int]]
Split one chunk's packed pull across this consumer's bound producers.
Cuts keys into P = len(self._produce_methods) CONTIGUOUS byte-balanced runs (greedy ceil cut on each key's packed nbytes, same rule as _chunk_group_scatters). Each run maps to a contiguous span of the shared packed arena: byte_start = pack_layout[first].off and byte_end = pack_layout[last].off + nbytes[last] (the TIGHT end of the run's last key — the packed layout has no trailing pad, so this is exactly the bytes the producer writes; for the final run it equals pack_bytes). Because every off is 16B-aligned and a producer packs its run from offset 0, arena[byte_start:byte_end] receives that producer's bytes exactly (span length == producer blob length). Returns one (producer_local_idx, run_keys, byte_start, byte_end) per non-empty run. P==1 => a single run over the whole chunk. An atomic key larger than the balanced target simply makes its run oversized (accepted; the other producers idle that chunk).
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
drain_pending ¶
Block until the background thread has processed every queued item and its stream work is complete, then re-raise any error it hit. Called from the worker's finish_weight_update before finalize_layerwise_reload so every baked layer is fully loaded (and info.reset()-ed) first.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
init_transfer_engine ¶
init_transfer_engine(
init_info: ShardedRDTWeightTransferInitInfo,
) -> None
Resolve the trainer actor and bind its batched producer method.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
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 | |
receive_weights ¶
receive_weights(
update_info: ShardedRDTWeightTransferUpdateInfo,
load_weights: Callable[
[list[tuple[str, Tensor]]], None
],
) -> None
Pull + replay the baked leaf modules the sync covers.
The chunk/free plan is STATIC across syncs (a pure function of the baked plan + the driver's group partition), so it is built once and cached: from init_info.group_lens at init if the driver supplied it — in which case this update_info may be EMPTY — else lazily from the first non-empty update_info (the driver keeps passing names + group_lens). Either way every sync just re-runs the pipeline over the self-describing chunks — no per-sync bookkeeping. Residual names with no baked plan — attention scales, padded/partial layers — take the plain per-slice load; load_weights is used only by that path.
Assumes each baked module's source names fall within one gather group (true for the per-layer / pre / post partition); if not, the pull fails loudly on the missing slice rather than loading wrong data.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
trainer_send_weights staticmethod ¶
trainer_send_weights(
iterator: Iterator[tuple[str, Tensor]],
trainer_args: dict[str, Any] | Any,
) -> None
No-op for the pull-based sharded RDT backend.
Workers initiate the transfer themselves via the trainer's @ray.method(tensor_transport="nixl") batched accessor. Retained to satisfy the abstract base class.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
ShardedRDTWeightTransferInitInfo dataclass ¶
Bases: WeightTransferInitInfo
Initialization info for the sharded RDT backend.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
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 | |
arena_presize_gb class-attribute instance-attribute ¶
arena_presize_gb: float = 0.0
[RDT-RING] Pre-size each packed receive-arena slot to this many GiB (0 = size to the first chunk + coarse 256MB round-up). Set it to cover the model's largest atomic chunk (e.g. an untied lm_head). Sizing arenas ONCE matters beyond perf: Ray's NIXL desc cache is keyed by data_ptr and entries outlive their tensors, so repeated small regrowths can false-hit a recycled pointer and silently skip registering the new extent (NIXL_ERR_NOT_FOUND at initialize_xfer, or worse a stale-MR write).
dtype_names class-attribute instance-attribute ¶
Dtype name (e.g. 'bfloat16') for each entry of names.
group_lens class-attribute instance-attribute ¶
Optional partition of names into gather groups (same meaning as ShardedRDTWeightTransferUpdateInfo.group_lens). When set, names must be in group-major order matching this partition, and the engine PRE-BUILDS the whole static chunk/free plan once at init (it never changes across syncs) so update_weights can be called with an EMPTY update info. When empty, the plan is instead built lazily from the first update_weights call and cached (back-compat: the driver keeps passing names+group_lens).
layerwise_split class-attribute instance-attribute ¶
layerwise_split: int = 1
[RDT-SPLIT] Split each gather group's copies into this many byte-balanced chunk pulls (1 = whole group per pull, 3 = thirds). Chunks are cut at individual-tensor granularity (copies atomic; a module's copies may span chunks — quant defers to its last copy). Tune together with num_rdt_buffers for the working-set/reach budget.
names class-attribute instance-attribute ¶
The full, flat list of parameters to transfer (the trainer's complete param name list). The engine bakes a replay plan once at init_transfer_engine by driving model.load_weights over all of these against meta params, then keys the plan by source name. update_weights later passes the subset of these names it gathered for that call.
num_consumers class-attribute instance-attribute ¶
num_consumers: int = 0
Total inference-worker (consumer) count across the whole fleet, for the M:N producer/consumer block assignment (see assign_producer_indices). The driver knows it (tensor_parallel_size * data_parallel_size). Authoritative when > 0; when 0 the engine infers it from parallel_config (correct for the supported serving modes — dense→TP, MoE→DP+EP). Set it explicitly for M:N so the count is never guessed. Each worker's DISTINCT index comes from data_parallel_index * world_size + rank (see _global_worker_index).
num_rdt_buffers class-attribute instance-attribute ¶
num_rdt_buffers: int = 2
[RDT-RING] Depth of the consumer receive-arena ring (the producer mirrors it from the NUM_RDT_BUFFERS env var). 2 = double buffer: chunk i+1's produce/serve overlaps chunk i's RDMA read, and scatter(i-1) overlaps RDMA(i) in the other slot. Tune with layerwise_split so num_rdt_buffers x chunk_bytes stays under the fabric's address-translation reach (~2-3 GB/flow on the reference 8xB200 RoCE cluster; K=3 measurably HURT there) or the transfer drops out of the fast regime.
pack_check class-attribute instance-attribute ¶
pack_check: bool = False
[RDT-PACK-CHECK diagnostic] After every pull, checksum the received packed blob and append {pid, bytes, sum} to /tmp/rdt_profile/packcheck_cons.jsonl; the producer logs the matching sum when RDT_PACK_CHECK=1. Diffing the streams localizes any producer/consumer packed-layout divergence (the core invariant of the packed contract).
produce_method_name class-attribute instance-attribute ¶
produce_method_name: str = 'rdt_produce_weights_batched'
Name of the trainer-side producer method (see examples/rl/rdt_producer.py for the reference implementation). Must be decorated with @ray.method(tensor_transport="nixl"). Contract: given a batched specs list [(name, [(op_name, args, kwargs_items), ...]), ...], replay each chain on the named tensor and return ONE contiguous uint8 blob with every slice byte-packed at 16B-aligned offsets in specs order (the engine computes the identical layout and carves dtype views back out). With pack=False (the engine's rare residual/unbaked path), return one slice tensor per spec instead. The trainer must also expose free_gather(names) (may be a no-op when it has no gather plan).
shapes class-attribute instance-attribute ¶
Full HF shape for each entry of names.
trainer_actor_name class-attribute instance-attribute ¶
trainer_actor_name: str | None = None
Name of a single trainer Ray actor (set via .options(name=...)).
Back-compat single-producer form. Prefer trainer_actor_names when the trainer exposes more than one NIXL producer (see below). Exactly one of trainer_actor_name / trainer_actor_names must be non-empty.
trainer_actor_names class-attribute instance-attribute ¶
Names of all trainer Ray actors that expose the producer method, ordered by trainer rank. When the trainer all-gathers each layer to every rank (not just rank 0), all of them can serve NIXL pulls, so inference workers spread their pulls across this list to parallelize the trainer-side clone + NIC egress instead of funneling everything through rank 0. Under the M:N block assignment (see _select_producer_indices / assign_producer_indices) each inference worker binds its contiguous BLOCK of this list: with more producers than consumers it binds several and splits every pull across them; with more consumers than producers several workers share one producer (which ref-counts frees). If empty, trainer_actor_name is used.
ShardedRDTWeightTransferUpdateInfo dataclass ¶
Bases: WeightTransferUpdateInfo
Update info for the sharded RDT backend (single-call design).
ONE update_weights per sync carries ALL of the sync's names in gather-group order; the engine chunk-plans each group and pipelines the packed pulls over the receive ring (see receive_weights).
Both fields are optional: when the driver supplied group_lens on the INIT info, the engine pre-built the (static) plan and this update info can be left empty.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
group_lens class-attribute instance-attribute ¶
Partition of names into gather groups (group-major; sum(group_lens) == len(names)), in the SAME order the driver sent to the trainers' run_gather_plan. The engine fires free_gather on the bound producer as each group's last chunk completes. Empty = treat all of names as one group (e.g. a gather-free trainer serving live params).
_BakeRecorder dataclass ¶
Shared recording context for the dry-run bake.
During the single dry-run load_weights pass, the engine stamps current = (leaf_module, param_name) around each param's loader (see _install_recording_stamps). The lazy's copy_ then reads current to attribute the copy to its destination param, appending a _BakedCopy (op chain from the source; offset/shape/stride from the meta dest view) into copies_by_layer[leaf_module]. None marks a copy_ we couldn't attribute (its group then falls back to a plain load). The dict is keyed by the module object, so iterating it after the pass yields each leaf module once. No real storage, no transfer — everything is meta.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
_BakedCopy dataclass ¶
One recorded scatter: pull src from the trainer and copy it into param_name at the recorded strided region.
Captured once during the bake's dry run — the lazy source carries the op chain (src); the loader binds the destination param (param_name), whose meta view yields offset/shape/stride (valid on meta; no real storage needed). On every later sync the destination is reconstructed as param.as_strided(shape, stride, offset) and filled by copy_ — no loader, no lazy tensor, no discovery.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
_BakedGroup dataclass ¶
A baked leaf module and the destination scatters that fill its params.
layer is a strong reference to the module, held for the engine's lifetime and cleared in shutdown. The module persists across syncs (the model is not rebuilt), and its LayerReloadingInfo — with the meta restore_metadata and per-sync kernel_tensors — is re-established by initialize_layerwise_reload at the start of every update. Whether the layer needs process_weights_after_loading is decided at replay time (same quant_method check the stock path uses), so it isn't stored here.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
_CallPlan dataclass ¶
The STATIC plan for one sync — a pure function of the baked plan (_name_to_group / _live_names / _name_meta) and the driver's group partition, both fixed for the engine's lifetime. Built ONCE (at init when the driver passes group_lens on the init info, else lazily on the first update_weights) and reused every sync: each self-describing _Chunk carries its own scatter/pack/materialize/quant/free actions, so runtime is pure execution — no per-sync counters or side-tables.
pre_free = gather groups with NO chunk on this worker but which the trainer still gathered under the lockstep plan (freed before the pipeline). residual = live-but-unbaked names for the plain-load fallback.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
_Chunk dataclass ¶
One packed pull + its post-processing, fully described at plan time.
scatters is the flat list of copies this chunk pulls (byte-balanced cut of the gather group's copies; a module's copies may span chunks). keys/pack_layout/pack_bytes are the deduped source keys and the byte-exact packed arena layout (16B-aligned, keys order) mirroring the producer — precomputed so the pull path does no per-call arithmetic. materialize = leaf modules whose FIRST scatter is in this chunk (empty HF params allocated before the scatter loop, once per module by construction). quant = modules whose LAST scatter is in this chunk (run process_weights_after_loading / kernel-copy / info.reset() after the scatter). free = gather-group name lists whose last chunk this is (fire free_gather after the pull returns).
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
_PendingPull dataclass ¶
An issued-but-not-completed pull: the produce RPC(s) are dispatched and the transfer(s) pointed at ring-slot arena views, but the blocking ray.get has not run. Under the M:N split ONE chunk fans out to several producers (one produce RPC per bound producer, each filling a disjoint sub-range of the same receive slot), so refs is a list. targets/blob hold the arena views strongly referenced until completion — set_target_for_ref stores weakrefs, so dropping them would silently reroute a transfer into a fallback buffer. targets are the full-chunk per-key views (for the scatter); blob holds the per-producer sub-range views handed to set_target_for_ref.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
_ProcItem dataclass ¶
One chunk of deferred post-processing handed from the RPC thread (which did the synchronous pull) to the background process thread.
chunk is the self-describing _Chunk (scatters + materialize/quant module lists). results are views aliasing the ring arena slot; they are held as strong refs here so they outlive the RPC-thread frame until the background scatter consumes them. The timing fields were measured on the RPC thread during the pull and are logged (together with the process-phase split) by the background thread after it finishes the item.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
_Scatter dataclass ¶
One self-contained scatter: pull src and copy the received slice into layer's param_name at the recorded strided region.
Enriched form of _BakedCopy for the runtime plan — it carries its own produced dtype / nbytes (so the pack layout and byte-balancing need no side-table lookup) and a strong ref to its leaf layer. The param is resolved at RUNTIME (getattr(layer, param_name)), not baked: every sync re-materializes fresh param tensors, so a param handle captured at plan time would be stale.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
_UnsupportedLazyOp ¶
Bases: NotImplementedError
Raised when a weight loader calls an op we don't support on a LazyRDTTensor.
Surfaced as NotImplementedError so callers can distinguish "this backend can't handle this loader" from genuine bugs.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
_arena_alloc_bytes ¶
Size a NIXL arena / ring slot for nbytes, rounded up so the buffer is allocated ONCE and never regrows: the max of the request, an optional presize floor, and a coarse 256MB round-up. Sizing once matters beyond perf — Ray's NIXL desc cache is keyed by data_ptr and its entries outlive their tensors, so repeated small regrowths can false-hit a recycled pointer and skip registering the new extent (see arena_presize_gb). Shared by both sides (consumer receive arenas + producer serve rings).
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
_dtype_from_name ¶
Resolve a string like 'bfloat16' to torch.bfloat16.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
_freeze_kwargs ¶
Sort kwargs into a tuple of items for hashable storage in OpSpec.
_greedy_run_starts ¶
Greedy contiguous byte-balanced partition of weights into at most n runs; returns the START index of each run (the first is always 0). Walks left to right, accumulating into the current run and cutting before an item that would push the run past the ceil(total/n) target — never emitting more than n runs. An item heavier than the target simply makes its run oversized (accepted). Shared by the gather-group -> chunk split (_chunk_group_scatters) and the M:N per-pull producer split (_split_chunk_pull); both are the same greedy cut over different weights.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
assign_producer_indices ¶
Producers (global indices) that consumer consumer_idx binds.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
count_consumers ¶
Number of consumers that bind producer producer_idx (its free target).