vllm.distributed.weight_transfer.sharded_rdt_engine ¶
Sharded Ray Direct Transport (RDT) weight transfer engine (consumer side).
Pulls only the slice each vLLM worker consumes under tensor/expert parallelism, not the full HF-format tensor.
Two phases. BAKE, once at init_transfer_engine: drive model.load_weights against FakeRDTTensor placeholders and record, per leaf module, how each destination slice is fetched (an op chain) and where it lands (an as_strided descriptor). REPLAY, every sync: no load_weights, no FakeRDTTensor dispatch, no discovery — pull the recorded slices in packed chunks over a ring of receive buffers, scatter them into freshly materialized params, then quant and kernel-copy. A live name with no recorded plan fails the plan build: there is no fallback load.
Weights arrive in checkpoint format: the engine drives layerwise reload itself, in start_weight_update / finish_weight_update.
Data flow¶
One thing at four resolutions, over three lifetimes. FetchKey -- (name, op_chain), "which slice of which trainer tensor" -- is the atom; everything else is bookkeeping around it.
BAKE once at init, kept for the engine's life
FakeRDTTensor intercepts the model's loaders; each copy_ records a
_Scatter (sharded_rdt_fake): src FetchKey, owning layer, the destination
as_strided region, and the produced dtype/nbytes.
-> _name_to_plan: name -> that module's scatter list
PLAN once, cached, _build_call_plan
_Chunk one packed pull: its scatters, deduped keys, the byte-exact
pack_layout, which producer serves it, and what to run after
(materialize / quant / free). One per (group, owner class).
_CallPlan all chunks + pre_free.
RUN per chunk, per sync, _run_chunk_pipeline
_Chunk -> _PendingPull issued, not yet landed: Ray ref, buffer views,
ring slot. [RPC thread]
-> _ProcItem chunk + results + slot. [hand-off to the
background scatter thread]
The RUN pair stays split on purpose: it is the thread boundary, and only targets should outlive the get -- carrying the Ray ref and the whole-buffer blob into the queue would keep both alive for the scatter's lifetime.
See docs/training/weight_transfer/sharded_rdt.md for the design and the measured results behind the choices here.
Classes:
-
ShardedRDTWeightTransferEngine–Pull-based RDT/NIXL backend that transports only the slice each worker
-
ShardedRDTWeightTransferInitInfo–Initialization info for the sharded RDT backend.
-
ShardedRDTWeightTransferUpdateInfo–Update info for the sharded RDT backend: intentionally EMPTY.
ShardedRDTWeightTransferEngine ¶
Bases: WeightTransferEngine[ShardedRDTWeightTransferInitInfo, ShardedRDTWeightTransferUpdateInfo]
Pull-based RDT/NIXL backend that transports only the slice each worker consumes.
Requires distributed_executor_backend="ray", nixl in the shared env, a named trainer actor exposing a @ray.method(tensor_transport="nixl") producer, and weight loaders that stay inside SUPPORTED_OPS — anything needing real data (.to, .item, arithmetic, bool-mask indexing) raises during the bake.
The plan is baked once at init_transfer_engine into one scatter list per fully-loaded leaf module, indexed by source name; every update_weights replays the modules its gathered names cover.
Methods:
-
drain_pending–Block until the background thread has processed every queued item and
-
finish_weight_update–Drain the deferred pull/process pipeline (so every layer is fully
-
init_transfer_engine–Configure the ring, bind the producers, bake the replay plan, and
-
receive_weights–Pull + replay the baked leaf modules the sync covers.
-
start_weight_update–Put the model's params on meta so layerwise reload streams them in
-
update_weights–Receive one update. Unlike the base, does NOT issue a per-update
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 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 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 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 | |
_bake(init_info) ¶
Bake the replay plan once, as a self-driven meta dry run.
Puts the params on meta, then drives model.load_weights over init_info.names through the model's ORIGINAL loaders (the stamps bypass online_process_loader, so _layerwise_process is never in the path). Nothing materializes or pulls; the fake's copy_ records the source op chain and the meta destination's geometry. Afterwards one scatter list per fully-loaded leaf module (copied numel == loadable size) is indexed by source name; a partial or unrecordable module fails the plan build. The model is restored.
This leans on layerwise internals a public API should expose first-class: a currently-loading hook instead of monkeypatched stamps, a dry-run mode instead of bypassing online_process_loader, and an abort_layerwise_reload instead of _restore_after_dry_run.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
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 | |
_build_call_plan(names, group_lens) ¶
Build the STATIC plan for one whole-sync call.
Pure — no pulls, no engine state touched — so the result is cached and reused every sync. Three passes: 1. Split names into gather groups, one chunk per owner class present in this worker's baked copies, recording each group's last chunk for its free_group signal (or pre_free when this worker pulls nothing from it). Every group is signaled exactly once by construction. The stream has no per-group call boundaries, so group L+1's first chunk issues while L's still stream. 2. Per leaf module, find its FIRST and LAST chunk — materialize on the first, quant/kernel/reset on the last, correct by construction instead of by runtime counters. 3. Assemble _Chunks: dedup keys and precompute the packed layout.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
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 | |
_build_fake_weights(names, sink, device) ¶
Zero-storage lazies for names, dtype/shape from the init metadata, all feeding the bake's recording sink.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
_build_static_plan(init_info) ¶
Build the chunk/free plan once. It never changes across syncs, so update_weights needs no per-sync names.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
_chunk_module_scatters(modules) ¶
Cut the modules' copies into one chunk per distinct owner class present, ascending by class index, as (class_idx, scatters) pairs.
A chunk is one packed pull, so every name in it must share a producer — which is exactly what an owner class is. The cut is a pure function of the bake and the ownership table. Copy order within a chunk is bake order, 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(pending) ¶
Blocking half of a pull: the NIXL read lands during this ray.get.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
_configure_ring(init_info) ¶
Ring depth K.
Must run before _ensure_proc_worker creates the per-slot events and counters, and before any buffer is grown (both happen on the first pull).
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
_dispatch_item(item) ¶
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
_global_worker_index() ¶
This worker's stable, distinct global index across the inference fleet: data_parallel_index * world_size + rank over the TP*PP world.
data_parallel_index, not data_parallel_rank: vLLM resets the latter to 0 in a dense worker but keeps the former as the distinct global DP rank. Same formula as the sibling nccl_engine, so dense-via-TP and MoE-via-DP+EP both yield distinct 0..C-1.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
_install_recording_stamps(model, recorder) ¶
Wrap each loadable param's weight_loader to stamp recorder.current = (leaf_module, param_name) before delegating to the original loader, so the fake'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(chunk, slot) ¶
Reserve slot, lay the targets out in its buffer, dispatch the produce RPC and point the transfer at the buffer — 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, both stages required: a generation wait (the CUDA event binds only to its LAST record, so synchronizing before the background thread recorded this item's event passes silently — observed as nondeterministic weight corruption), then the event synchronize. It must precede set_target_for_ref, not just the get: the transfer may start any time after the metadata push. See the doc's "slot generation handshake".
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
_mark_slot_done(slot) ¶
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() ¶
Total inference-worker count. Prefers the driver-supplied init_info.num_consumers (authoritative -- the driver knows the whole fleet); else world_size_across_dp, the same stride _global_worker_index indexes with, so the two agree at any pp.
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 plan: receive buffers are ring_depth slots at the largest chunk's pack_bytes, and each bound producer is asked to pre-register a serve ring at the max bytes this consumer will pull from it. A no-op when this worker has no chunks.
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(item) ¶
Scatter-thread half: materialize this chunk's first-seen modules, scatter its slices on the process stream, publish the slot, then hand the modules it COMPLETES to the quant thread.
Mirrors _layerwise_process minus the loader replay. Once every scatter reading item.slot is enqueued, records the slot's read-done event so the RPC thread can block on it before overwriting the slot.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
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 | |
_pull_targets(chunk, slot, buffer) ¶
Per-key dtype views into slot's buffer.
The packed layout is static, so the views are built once per (chunk, slot) rather than once per pull -- rebuilding them cost ~1150 Python ops per pull at 235B. Keyed on the buffer pointer as well, so a regrow invalidates instead of handing back views into a freed buffer.
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
_resolve_consumer_id(init_info) ¶
This worker's DISTINCT index in 0..C-1 across the whole fleet.
Within one engine that is _global_worker_index(). But a fleet of INDEPENDENT engines (each with its own parallel config) restarts that index at 0 per engine, so each engine offsets into its own range using replica_rank: with a uniform fleet, workers_per_replica = C // num_replicas. num_replicas defaults to 1 (offset 0), preserving single-engine and single-DP-deployment behaviour.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
_resolve_producers(init_info) ¶
Work out this worker's consumer identity, build the router, and bind EVERY producer actor.
Pull routing is M:N: each chunk goes to ONE producer holding every name in it (see RdtRouter), so one producer serves a whole pull. All producers are bound regardless, because the per-group free_group signal fans out to every owner of a group, including producers this worker never pulls from.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
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 | |
_restore_after_dry_run(model) ¶
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_chunk_pipeline(plan) ¶
Pipelined chunk pulls over the ring of receive slots.
Issues up to ring_depth produce RPCs ahead of the blocking gets, so while chunk i's RDMA streams the producer serves i+1 into its own ring slot and the background thread scatters i-1 out of another. Reads stay serialized on the shared NIC — the bandwidth floor, not a loss.
Slot safety rests on two arguments spelled out in the doc: the producer's ring is no shallower than this one and drain-before-issue orders its reuse; the consumer's slots are held by _issue_pull's generation handshake.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
_run_quant(layers, ready) ¶
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
_signal_group_done(group_idx) ¶
Fire-and-forget free_group signal at EVERY owner of the group.
The per-group barrier: each owner counts one signal per live consumer and frees the group (releasing its lookahead credit) on the last one, so every owner must hear from every consumer — including owners this worker pulls nothing from. Refs are held and drained in drain_pending so every signal has EXECUTED before the sync ends: begin_sync resets the counters, and a straggler landing in the next sync would credit a group it does not belong to.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
_workers_per_replica(init_info) ¶
Consumers per inference deployment, assuming a uniform fleet.
Read by this worker's consumer id and by the router's block carve, which must not disagree, so it is derived once here.
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
finish_weight_update() ¶
Drain the deferred pull/process pipeline (so every layer is fully loaded) before finalizing the layerwise reload.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
init_transfer_engine(init_info) ¶
Configure the ring, bind the producers, bake the replay plan, and pre-register every NIXL buffer -- in that order, because each step depends on the previous one.
The bake drives model.load_weights and the pre-registration blocks on RPCs to the producers, so this is a heavyweight one-off; every later update_weights is pure replay.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
receive_weights(update_info) ¶
Pull + replay the baked leaf modules the sync covers.
The chunk/free plan is STATIC across syncs — a pure function of the baked plan and the driver's group partition — so it was built once at init and every sync just re-runs the pipeline over its self-describing chunks, with no per-sync bookkeeping and an empty update_info.
Assumes each baked module's source names fall within one gather group, which the per-layer / pre / post partition guarantees (a leaf module's sources all live in one decoder layer). A module that did span groups would be planned once per group and could pull a name whose group the pipeline already freed, which parks the pull until the producer's stall watchdog fires.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
start_weight_update() ¶
Put the model's params on meta so layerwise reload streams them in as each layer's slices land. Baked replay uses checkpoint format.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
update_weights(update_info) ¶
Receive one update. Unlike the base, does NOT issue a per-update device sync: post-processing is deferred to background threads and a sync here would block on them and serialize the pull/process pipeline. Completion is guaranteed by drain_pending in finish_weight_update.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
ShardedRDTWeightTransferInitInfo dataclass ¶
Bases: WeightTransferInitInfo
Initialization info for the sharded RDT backend.
Attributes:
-
buffer_presize_gb(float) –Pre-size each packed receive-buffer slot to this many GiB
-
dtype_names(list[str]) –Dtype name (e.g. 'bfloat16') for each entry of
names. -
group_lens(list[int]) –Partition of
namesinto gather groups, in the SAME order the trainers -
name_owner_class(list[int]) –Per-name index into
owner_sets, parallel tonames: which producers -
names(list[str]) –The trainer's complete, flat param name list. The bake drives
-
num_consumers(int) –Total consumer count across the fleet, for M:N routing. Authoritative when
-
num_rdt_buffers(int) –Depth of the consumer receive-buffer ring. Must match the
-
num_replicas(int) –Number of independent inference engines in the fleet. Default 1 => the
-
owner_sets(list[list[int]]) –The distinct producer sets that occur, each a sorted list of trainer ranks
-
produce_method_name(str) –Name of the trainer-side producer method. It and the rest of the serve
-
replica_rank(int) –This inference engine's ordinal in the fleet (0..
num_replicas-1). -
shapes(list[list[int]]) –Full HF shape for each entry of
names. -
trainer_actor_names(list[str]) –Names of all trainer Ray actors exposing the producer method (set via
-
trainer_actor_namespace(str | None) –Optional Ray namespace the trainer actor(s) live in.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | |
buffer_presize_gb = 0.0 class-attribute instance-attribute ¶
Pre-size each packed receive-buffer 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 buffers ONCE matters beyond perf -- see the doc's "Sizing buffers once matters beyond throughput".
dtype_names = field(default_factory=list) class-attribute instance-attribute ¶
Dtype name (e.g. 'bfloat16') for each entry of names.
group_lens = field(default_factory=list) class-attribute instance-attribute ¶
Partition of names into gather groups, in the SAME order the trainers gather and publish them (group-major; sum(group_lens) == len(names), and names must be ordered to match). Required: the engine pre-builds the whole static chunk/signal plan from it at init, and fires free_group at every owner as each group's last chunk completes.
name_owner_class = field(default_factory=list) class-attribute instance-attribute ¶
Per-name index into owner_sets, parallel to names: which producers hold each name. Empty means every producer holds every name.
This one table expresses every layout the trainer can have — pipeline stages (the names of these groups have this owner set), expert parallelism (this expert name has this one-rank owner set), and combinations of the two — so the engine cuts each group's baked copies into one chunk per distinct class present and routes each chunk to that class's owner. Derived by the trainer from WeightSource.held_names().
names = field(default_factory=list) class-attribute instance-attribute ¶
The trainer's complete, flat param name list. The bake drives model.load_weights over all of them once and keys the plan by source name.
num_consumers = 0 class-attribute instance-attribute ¶
Total consumer count across the fleet, for M:N routing. Authoritative when
0; at 0 the engine infers it from
parallel_config, which is correct for the supported serving modes but worth setting explicitly under M:N. Each worker's distinct index comes from_global_worker_index.
num_rdt_buffers = 2 class-attribute instance-attribute ¶
Depth of the consumer receive-buffer ring. Must match the producer's — _run_chunk_pipeline's slot-safety argument rests on it. 2 = double buffer: chunk i+1's serve overlaps chunk i's RDMA, and scatter(i-1) overlaps RDMA(i) in the other slot. Keep depth x chunk_bytes under the fabric's address-translation reach (~2-3 GB/flow on the reference 8xB200 RoCE cluster, where K=3 measurably hurt).
num_replicas = 1 class-attribute instance-attribute ¶
Number of independent inference engines in the fleet. Default 1 => the per-replica offset is 0 and consumer identity is exactly _global_worker_index (preserves single-engine and single-DP-deployment behavior). When > 1, workers_per_replica = num_consumers // num_replicas and this engine's consumers occupy replica_rank * workers_per_replica + _global_worker_index(). Assumes a uniform fleet (every replica has the same worker count). Set alongside replica_rank, by the driver.
owner_sets = field(default_factory=list) class-attribute instance-attribute ¶
The distinct producer sets that occur, each a sorted list of trainer ranks (indices into trainer_actor_names). Indexed by name_owner_class. Empty means every producer holds every name.
produce_method_name = 'rdt_produce_weights_batched' class-attribute instance-attribute ¶
Name of the trainer-side producer method. It and the rest of the serve surface (free_group, reserve_serve_buffer) are documented where they are implemented, on _RDTProducerServer in sharded_rdt_trainer.py.
replica_rank = 0 class-attribute instance-attribute ¶
This inference engine's ordinal in the fleet (0..num_replicas-1).
Multi-engine deployments run several INDEPENDENT inference engines, each with its own self-contained parallel config, so every engine's _global_worker_index restarts at 0 and would collide across engines. The driver gives each engine a distinct replica_rank (with identical num_replicas) so the engine offsets its consumers into a globally distinct range for the M:N block assignment.Default 0/1 (single engine) needs no override.
shapes = field(default_factory=list) class-attribute instance-attribute ¶
Full HF shape for each entry of names.
trainer_actor_names = field(default_factory=list) class-attribute instance-attribute ¶
Names of all trainer Ray actors exposing the producer method (set via .options(name=...)), ordered by trainer rank. RdtRouter picks one of them per pull, out of the name's owner set. Every actor is bound regardless, because free_group fans out to every owner. Must be non-empty; a single-producer trainer passes a one-element list.
trainer_actor_namespace = None class-attribute instance-attribute ¶
Optional Ray namespace the trainer actor(s) live in.
ShardedRDTWeightTransferUpdateInfo dataclass ¶
Bases: WeightTransferUpdateInfo
Update info for the sharded RDT backend: intentionally EMPTY.
The chunk/free plan is a pure function of the baked plan and the driver's gather-group partition, both fixed for the engine's lifetime, so it is built once at init_transfer_engine from ShardedRDTWeightTransferInitInfo's names + group_lens. ONE update_weights per sync then just re-runs that plan; there is nothing per-sync to carry.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
_CallPlan dataclass ¶
The static plan for one sync (see Data flow). Pure, so it is built once and reused; runtime is then execution only.
pre_free = groups with NO chunk on this worker, signaled at sync start (owners tolerate a signal preceding its publish). With the last-chunk signals this keeps the completeness invariant consumer-local: every group is signaled exactly once.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
_Chunk dataclass ¶
One packed pull plus its post-processing (see Data flow).
A module's copies span chunks when its experts sit in several owner classes, so materialize fires on its FIRST chunk and quant on its LAST -- materialize-once by construction, not by a runtime counter. pack_layout mirrors the producer's rule byte-exactly.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
_PendingPull dataclass ¶
A dispatched pull whose blocking ray.get has not run (see Data flow).
targets/blob must stay strongly referenced until it completes: set_target_for_ref stores WEAKREFS, so dropping them silently reroutes the transfer into a fallback buffer.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
_ProcItem dataclass ¶
A landed pull handed to the background scatter thread (see Data flow).
results alias the ring buffer slot, held as strong refs so they outlive the RPC-thread frame until the scatter consumes them.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
_dtype_from_name(name) ¶
Resolve a string like 'bfloat16' to torch.bfloat16.
Source code in vllm/distributed/weight_transfer/sharded_rdt_engine.py
_plan_digest(keys_per_chunk) ¶
Digest of the chunks one consumer pulls from one producer, in pull order.
Two consumers a producer serves out of ONE shared serve ring must agree on this, since sharing rests on their plans being identical; the producer compares it at init. Over the whole (name, op-chain) list rather than the names, because the chains decide the bytes each pull returns.