[JAX] EP Dispatch with overflow detection option - #3277
Conversation
Signed-off-by: Phuong Nguyen <phuonguyen@nvidia.com>
| recv_tokens, recv_topk_weights = tex.ep_dispatch_fwd( | ||
| cfg, handle_mem, topk_idx, tokens, topk_weights, recv_capacity_per_rank | ||
| ) | ||
| out_leading = tuple(tokens.shape[:-1]) |
There was a problem hiding this comment.
Positional return contracts break
Existing callers that unpack the documented two-value ep_prepare, four-value ep_dispatch, or two-value MoE results now receive an additional positional value unconditionally, causing ValueError: too many values to unpack even when overflow dropping is disabled.
Knowledge Base Used: JAX Fused Layers: Functions and Flax Modules
Greptile SummaryAdds opt-in EP overflow dropping and exposes pre-drop receive demand throughout the JAX EP/MoE stack.
Confidence Score: 3/5The public return-contract break should be resolved before merging because existing EP and MoE callers will fail even without opting into overflow dropping. The low-level overflow plumbing and custom-VJP structures are coordinated, but ep_prepare, ep_dispatch, moe, and the Flax wrapper all unconditionally add positional outputs, causing existing fixed-arity unpacking to raise at runtime. Files Needing Attention: transformer_engine/jax/ep.py, transformer_engine/jax/cpp_extensions/ep.py, transformer_engine/jax/moe.py, transformer_engine/jax/flax/moe.py Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant Bootstrap as ep_bootstrap
participant EP as EP backend
participant Prepare as ep_prepare
participant Dispatch as ep_dispatch / moe
User->>Bootstrap: drop_on_overflow
Bootstrap->>EP: NVTEEpGroupConfig
User->>Prepare: routing indices
Prepare->>EP: exchange routing metadata
EP-->>Prepare: token counts + total receive demand
User->>Dispatch: tokens and routing
Dispatch->>EP: dispatch with configured capacity
EP-->>Dispatch: received tokens + pre-drop demand
Dispatch-->>User: output tuple including total_recv_tokens
Reviews (1): Last reviewed commit: "[JAX] Add NCCL EP drop-on-overflow polic..." | Re-trigger Greptile |
Description
Adds a way to size EP recv buffers below the worst case and still stay correct.
ep_prepare/ep_dispatchnow exposetotal_recv_tokens, the per-rank pre-drop recv-slot demand, so callers can tell exactly when a step's routing exceedsrecv_capacity_per_rank; no need to conservatively provision every rank for the theoretical maximum.Bootstrap also gains an opt-in
drop_on_overflowpolicy so an occasional overflowing step is handled gracefully and keeps running (the default behavior is unchanged).Together these let users pick a tighter, cheaper recv capacity and monitor
total_recv_tokensto confirm it holds or to drive their own capacity policy.Type of change
Changes
ep_bootstrapgains adrop_on_overflowflag, plumbed throughset_ep_bootstrap_params(pybind) andNVTEEpGroupConfig.drop_on_overflow.ep_preparenow returns(token_counts, total_recv_tokens, handle_mem);ep_dispatch'scustom_vjpprimal correspondingly returnstotal_recv_tokensas a non-differentiable output.moe()and the Flax_MoEBlocknow return(output, aux_loss, total_recv_tokens); the extra output is non-differentiableep_finalize()(andreset_ep_config) to tear down the EPcommunicator so a process can re-
ep_bootstrapwith a different config.Checklist: