Distributed immutable expert weights
Distributed Weight Data Parallelism (DWDP) separates expert-weight ownership from execution parallelism. Each worker permanently stores a contiguous expert shard, but runs its own token batch through every logical expert. Attention, dense layers, and mixture-of-experts (MoE) layers execute locally. Weight owners do not have to execute the same layer or have requests at the same time.
Mapping.moe_weight_group identifies storage peers. It does not replace attention DP ranks, request routing, P/D rank pins, or an execution group. MoELayer._storage_spec controls allocation and checkpoint slicing; MoELayer._spec describes compute-visible experts. Kernel selection and routing use the compute specification.
Weight loading and memory ownership
The MoE kernel declares supports_peer_weights when its preprocessor returns a PreparedExpertWeights manifest: a layout identity, processed expert-major tensors, and an explicit distinction between streamed weights and small per-expert constants. Non-expert state stays on the layer. In particular, the loader must preserve the existing layer-wide input-scale maximum across all logical experts. The initial FlashInfer TRT-LLM NVFP4 and MXFP4 SiTU paths supply this manifest directly. MXFP4 experts store no input scale; the kernel quantizes their activations on each forward.
A model-owned MoEPeerWeights publishes each processed layer immediately and rebinds its parameters to immutable owned storage. Old processed allocations do not accumulate beside the full model. Finalization exchanges peer handles and manifests, reconstructs complete per-expert constants, and binds stable full-expert tensor views before tuning and cache sizing.
The kernel-package factory dispatches the storage implementation. CUDA driver, fabric and virtual-memory details remain under tokenspeed-kernel/thirdparty. The CUDA implementation maps each layer's local expert region to permanent source storage and remote regions to one of two reusable staging pools. Source pages that straddle expert boundaries receive their missing immutable edge bytes once at setup. All foreign allocations for one owner share a virtual-address arena, reducing fabric access-region use.
The shareable-handle type is explicit. Fabric handles require an IMEX channel; POSIX file descriptors support owners in one Linux socket namespace, including SM90 systems without IMEX. POSIX peers must have the same effective user ID; both ends check Linux socket peer credentials before exchanging descriptors. Descriptor exchange is startup-only: owners send in rank order, and each receiver imports one owner's handles and closes its descriptors before receiving the next owner's. The receiver holds at most one owner's descriptors beside its exports. Partial exchanges and failed imports close every descriptor they acquired.
Physical source storage, both staging pools, full per-expert metadata, kernel workspace, and maximum-batch activations must be accounted for before sizing KV cache. Reserved virtual addresses are not physical cache consumption. Unused startup allocator blocks are released before serving, including eager execution, so freed processed weights do not occupy runtime driver headroom.
Optional: Dense-weight sharing
--dense-weight-sharing-size extends CUDA DWDP to processed dense weights. It must match --moe-weight-sharing-size and requires eager prefill (--enforce-eager --disable-prefill-graph). Omitting it keeps dense weights resident and preserves MoE-only DWDP.
A model declares the eligible layers and processed non-parameter tensors. DensePeerWeights packs large non-expert weight storage, preserves aliases, strides and offsets, and binds stable views before cache sizing. Small weights and storage shared across layers remain replicated. Weight ownership does not change the worker's local execution groups.
Dense and expert stores have separate staging slots and layer descriptors on the same copy stream. One worker submits both stores' jobs in FIFO order, so prefetch preserves layer lookahead without blocking the forward thread on a future layer's submission. Each acquire still waits for its own ready write to be submitted before enqueuing the GPU wait. Each dense layer releases its slot after its readers are enqueued; teardown drains each store's submissions before freeing its storage. CPU-backed sleep/wake releases and restores both stores; online updates retain the model owner's existing opt-in requirements.
Forward ordering
Weight operations belong on the data plane. The ordinary model forward primes the first required MoE. Before each MoE, the compute stream waits for its weights; after all readers are enqueued, the layer records that its slot can be reused and starts the next layer's prefetch. Copies into a reused slot wait for the previous reader's release. This includes the final readers of a forward: the ordering is not reset at forward boundaries. Fetch completion and reader release are 64-bit sequence flags in device memory, written and waited on by streams. A flag wait is enqueued only after its write: a wait ahead of its producer blocks the GPU, and lazy module loading on any thread then deadlocks.
Any side-stream weight reader must join the compute stream before release. A new reader on a different stream waits for the preceding release, including when the same layer remains resident, so a later slot overwrite covers all readers. Host run-ahead is allowed. Only startup and collective teardown coordinate with other weight owners, over a dedicated named process group; ordinary prefetch, acquire and release do not.
A prefetch submits a layer's copy-engine copies on the store's copy stream. The worker supports the CUDA 12.8 and CUDA 13 batch-copy API signatures. The schedule splits each peer's bytes into chunks of 8 MB divided by the number of owners and takes one chunk from every peer per round, in a fixed per-rank random order. Submitting a layer's tens of thousands of copies blocks while the copy stream's queue is full, so a worker thread submits them, in batches of 4,096 copies: the driver may hold a batch's copies until its submission returns, and with several batches the first ones copy while the rest are submitted. The reader waits on the host until the worker has enqueued the ready write, then enqueues its flag wait.
The host receives only DeviceSpecs.requires_forward_coordination, derived from execution groups, and hands the control plane a DP coordination group only when execution spans workers or a shared L3 namespace needs agreed flushes. The control plane continues using the same scheduler and submission path. When execution is fully local, it does not gather per-round DP metadata, dispatch an idle forward for another worker, or rendezvous across DP for a cache flush. The executor uses the same execution-group requirement when accepting forward metadata. Startup cache capacity agreement remains collective; local cache-copy completion stays local. The initial DWDP configuration rejects shared L3 and online expert rebalancing; Host L2 remains supported. Paused workers use the same coordination group as normal rounds.
Ordinary breakable prefill graphs keep MoE compute in captured segments over the full-expert views bound at finalization. First-layer prefetch, each acquire, and each release followed by the next prefetch are ordered eager breaks. They run during capture and on every replay, so staging state advances and reader release is recorded on the replay's compute stream. Warmups use the same eager operations; capture itself records compute without reading the weights. A plain decode graph capture cannot replay these host-side operations, so decode and aggregated workers using DWDP require --enforce-eager.
Both the CUDA and Ascend PeerWeightStore implementations support reinforcement learning (RL) lifecycles while keeping stable VA reservations and full-expert view layouts (data_ptr, shape, stride): resident online weight updates (Mooncake SDK and disk), co-located sleep/wake through --enable-memory-saver (cpu_backup and discard), and --load-format dummy startup (skipping re-randomizing finalized composite views over shared staging pools). During live updates and wake/sleep transitions, the local reader and async peer-copy streams quiesce across the storage group before owned device buffers or VMM physical handles are rewritten or unmapped, staging slots are invalidated (and CUDA sequence flags and slot counters are reset on resume), and boundary intervals and replicated metadata are refreshed after barrier agreement. Teardown drains local readers/copies and establishes peer quiescence before unmapping VA reservations and physical handles. A model exposing peer weights implements PeerWeightOwner; the forward thread performs teardown as its last task.
Initial and RL supported configurations
The initial CUDA integration supports K3 NVFP4 and MXFP4 SiTU experts through the FlashInfer TRT-LLM kernels on a fabric-connected NVIDIA prefill instance with local execution groups, PP1, and a fixed token budget. This K3 path selects fabric handles explicitly. POSIX support is exposed through the storage API for compatible model integrations, not as a K3 transport option. Eager execution and ordinary breakable prefill graphs use the same weight ordering. Idle forwards skip weight reads. Kernel tuning and other graph consumers can use stable weight views with acquisition/release outside capture. Unsupported model, layout, transport, and graph combinations fail explicitly.
Validation includes cross-node reconstruction, page-boundary handling, complete expert metadata, idle owners, odd/even queued forwards, bounded staging, full-model mapping counts, and numerical comparison against resident weights.
CUDA prefill workers support auto, safetensors, and dummy checkpoint loading and eager or breakable prefill graphs. At the store level, the CUDA peer-weight store implements the cpu_backup/discard VMM lifecycle for --enable-memory-saver and the Mooncake/disk update protocol.
The online-update declaration is backend-neutral. For any peer-weight owner, deploying Mooncake/disk updates requires its reload path to write owned_weights() and call MoEPeerWeights.enable_owned_updates(); discard additionally requires supports_weight_discard. The in-tree K3 path does none of these, so it continues to reject Mooncake/disk updates and discard at startup. An Ascend peer-weight owner outside this tree must make the same opt-in in the same release, otherwise its online updates are refused. On Ascend NPU, peer weights additionally support eager decode and aggregated (null) roles (--enforce-eager). All owners must remain available for the instance lifetime; deployment must terminate the instance on worker failure. Independent forwarding does not provide owner replacement or recovery after an owner fails.