Skip to content

Refactor EP runtime architecture - #874

Draft
Binyang Li (Binyang2014) wants to merge 26 commits into
feature/epfrom
binyli/ep
Draft

Refactor EP runtime architecture#874
Binyang Li (Binyang2014) wants to merge 26 commits into
feature/epfrom
binyli/ep

Conversation

@Binyang2014

Copy link
Copy Markdown
Contributor

Unify latency and overlap under one runtime, organize kernels by dispatch and combine algorithms, and expose one opaque dispatch handle.

Unify latency and overlap under one runtime, organize kernels by dispatch and combine algorithms, and expose one opaque dispatch handle.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Comment thread python/mscclpp/ep/backend.py Outdated
Comment thread python/mscclpp/ep/types.py Outdated
Comment thread python/mscclpp/ep/backend.py Outdated
Comment thread python/mscclpp/ep/backend.py Outdated
Comment thread python/mscclpp/ep/backend.py Outdated
Comment thread python/mscclpp/ep/communicator.py Outdated
Comment thread python/mscclpp/ep/latency.py Outdated
Comment thread python/mscclpp/ep/latency.py Outdated
Comment thread python/mscclpp/ep/latency.py Outdated
Use mode-local constructors and operation names, remove legacy low-latency tuning names, and expose distinct runtime-owned dispatch and combine-input buffers.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use cooperative Python initialization and return the rank-major combine destination with DispatchOutput instead of exposing another communicator getter.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Binyang2014

Copy link
Copy Markdown
Contributor Author

Addressed the latest review in 2090bd5:

  • Backend now uses one standard super().__init__(config, output_layout) path; there are no direct class __init__ calls and no separate mode instances.
  • Removed get_combine_input_buffer(). Rank-major dispatch returns the runtime-owned MLP/combine destination as dispatch_out.combine_input_buffer, tying it to the dispatch result and active layout.

Replace mode mixin inheritance with an abstract Backend and factory-created LatencyBackend or OverlapBackend, each owning the unified Runtime.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Binyang2014

Copy link
Copy Markdown
Contributor Author

Updated backend hierarchy in db0cb30: Backend is now an abstract parent, create_backend() selects LatencyBackend or OverlapBackend from MoEMode, and each concrete backend owns the same unified C++ Runtime type. The previous multiple-inheritance/MRO initialization is removed.

Use full mscclpp.ep module paths consistently across the Python API.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Binyang2014

Copy link
Copy Markdown
Contributor Author

Updated in 5d752e3: all internal Python imports under mscclpp.ep now use full absolute package paths.

Remove duplicate output-layout arguments from backend factory and constructors; each concrete backend resolves its default directly from MoECommunicatorConfig.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Binyang2014

Copy link
Copy Markdown
Contributor Author

Updated in 61eb952: create_backend() and concrete backend constructors now accept only MoECommunicatorConfig; each backend reads and resolves config.output_layout directly. The duplicate layout plumbing is removed.

Move runtime-owned BF16, FP8, and generic CUDA pointer tensor helpers into the shared EP utilities.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Binyang2014

Copy link
Copy Markdown
Contributor Author

Updated in e7fb586: runtime-owned generic, BF16, and FP8 CUDA pointer tensor views are now centralized in mscclpp.ep.utils; latency.py only selects layout/dtype and owns mode behavior.

Remove the latency-only dispatch buffer getter and use DispatchOutput.tokens uniformly across modes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Binyang2014

Copy link
Copy Markdown
Contributor Author

Updated in f4377dd: removed the latency-only dispatch output getter. Every mode now exposes dispatch output uniformly through dispatch_out.tokens; runtime allocation remains internal.

Move dispatch datatype resolution and scale metadata helpers out of the latency backend into common EP utilities.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Binyang2014

Copy link
Copy Markdown
Contributor Author

Updated in 6e44bb7: dispatch datatype resolution and scale metadata helpers are now common mscclpp.ep.utils functions. latency.py retains only latency-mode support policy and execution.

Use one dtype-driven zero-copy tensor helper for BF16, FP8 E4M3, INT32, and FP32 runtime buffers.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Binyang2014

Copy link
Copy Markdown
Contributor Author

Updated in a67f794: BF16 and FP8 pointer wrappers are merged into one dtype-driven tensor_from_pointer() helper, also used for INT32/FP32 metadata.

Use the generic dtype-driven CUDA pointer tensor helper directly in overlap mode.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Binyang2014

Copy link
Copy Markdown
Contributor Author

Updated in 5125a93: removed the redundant bf16_view() wrapper; overlap mode now calls the generic dtype-driven tensor_from_pointer() directly.

Expose only MoEMode.LATENCY and MoEMode.OVERLAP across C++, Python bindings, documentation, and tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Binyang2014

Copy link
Copy Markdown
Contributor Author

Updated in 4faa42c: removed LOW_LATENCY and HIGH_THROUGHPUT compatibility aliases. MSCCL++ now exposes only MoEMode.LATENCY and MoEMode.OVERLAP.

Name fixed-buffer algorithms with a latency prefix and use layout-first token-major preparation, dispatch, and reduction names throughout C++, bindings, and Python.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Binyang2014

Copy link
Copy Markdown
Contributor Author

Updated in 3c9ef8b: removed mode suffixes throughout the EP surface. Fixed-buffer algorithms use qualifier-first names (latencyExpertMajor, latencyRankMajor, etc.); token-major APIs use layout-first names (tokenMajorPrepare, tokenMajorDispatch, tokenMajorReduce).

Describe each dispatch/combine layout and algorithm, and make DeviceContext carry its persistent device pointer so kernel APIs accept one context argument.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Binyang2014

Copy link
Copy Markdown
Contributor Author

Updated in 5b8ae8a: api.cuh now documents each expert-major, rank-major, and token-major dispatch/combine contract separately. DeviceContext also carries its persistent devicePtr_, so every API accepts one context argument instead of separate host/device context parameters.

Organize kernels directly under dispatch/combine, use operation-first fixed-buffer names, and remove implementation prefixes from shared dispatch constants.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Binyang2014

Copy link
Copy Markdown
Contributor Author

Updated in 21f74b9: flattened kernel sources directly under dispatch/ and combine/; backend/runtime selection now owns mode policy. Fixed-buffer APIs use expertMajorDispatch/rankMajorDispatch, while token-major remains tokenMajorPrepare/tokenMajorDispatch/tokenMajorReduce.

Expose expert-major rank-local reduction, rank-major gather reduction, and expert-major direct send as distinct combine entry points.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Binyang2014

Copy link
Copy Markdown
Contributor Author

Updated in 654e707: split the generic combine API into layout-specific entry points: expertMajorRankLocalReduce, rankMajorGatherReduce, and expertMajorDirectSend.

Align combine entry points and kernels with dispatch naming across expert-major, rank-major, and token-major algorithms.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Binyang2014

Copy link
Copy Markdown
Contributor Author

Updated in f0b8759: all combine kernels and entry points now use a Combine suffix, matching dispatch naming (expertMajorLocalReduceCombine, rankMajorGatherReduceCombine, expertMajorDirectSendCombine, tokenMajorReduceCombine).

Replace broad shared-detail namespace imports with explicit helper declarations in dispatch and combine internals.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use a local shared namespace alias while retaining selective imports in dispatch and combine internals.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use one optional num_blocks setting with latency and overlap defaults, and keep NCCL monitoring enabled in tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Binyang2014

Copy link
Copy Markdown
Contributor Author

Updated in 5024680: replaced latency_num_blocks and num_sms tuning with one optional num_blocks field (defaults: 130 latency, 20 overlap). Test-only NCCL monitoring overrides were also removed; hardware SM-count fields remain internal.

Use passive latency/throughput contexts with matching Python Runtime subclasses over one unified C++ MoERuntime. Flatten mode sources, rename the overlap mode to throughput, and clean extension build and API plumbing.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Port the host-assigned latency dispatch epoch fix to the unified runtime and flattened kernel layout.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add dispatch and combine suffixes to data-movement kernel filenames and update build and source-layout references.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Place dispatch and combine APIs directly in mscclpp::ep and keep internal helpers in the shared detail namespace.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Install documented runtime and request types under mscclpp/ext/ep, keep kernel contracts private, consolidate host headers, and retain CUDA implementation headers beside their sources.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant