feat(normal): support DeepEP normal-mode diagnosis - #17
Open
Marsssqqq wants to merge 9 commits into
Open
Conversation
added 6 commits
August 10, 2026 16:30
There was a problem hiding this comment.
Pull request overview
Adds DeepEP “normal mode” semantic diagnosis to DeepXTrace, including a stable cumulative-counter stats contract, windowing/correlation logic, optional structured NPZ artifacts, and updated heatmap tooling to visualize Normal windows (while keeping LL diagnosis intact).
Changes:
- Introduces normal-mode semantic diagnoser + structured normal-window artifact format/load/export.
- Extends
Diagnoseto collect/gather normal-mode cumulative counters (sync or async), correlate evidence, and optionally export window artifacts. - Updates
tools/deepxtrace_heatmap.py+ docs/tests to render Normal.npzartifacts and enforce stable default layout.
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/README.md | Documents Normal artifact rendering, stable layout presets, and new CLI flags. |
| tools/deepxtrace_heatmap.py | Adds Normal artifact rendering, stable layouts, log-scale completion heatmaps, and Notify panel rendering. |
| tests/test_normal_tools.py | Adds tests for artifact round-trip and heatmap CLI behavior (mocked plotting stack). |
| tests/test_normal_diagnose.py | Adds unit tests for normal-mode notify/completion diagnosis and cross-probe correlation. |
| tests/test_diagnose.py | Adds tests for subgroup root handling, normal windowing, and async snapshot ordering. |
| src/deepxtrace/normal_diagnose.py | Implements normal-mode preprocessing, per-probe diagnosis, and incident correlation. |
| src/deepxtrace/normal_artifact.py | Implements schema-versioned .npz artifact export + metric loading/validation. |
| src/deepxtrace/diagnose.py | Adds normal-mode stats schema, snapshot/gather/windowing, logging/export, and async loop updates. |
| setup.py | Bumps package version to 0.2.0. |
| README.md | Documents normal-mode integration contract, logging, and artifact/heatmap workflow. |
| .gitignore | Ignores generated visualization artifacts under tools/. |
Suppressed comments (1)
tools/deepxtrace_heatmap.py:100
calculate_nonzero_scale_min()exits when there are no positive values. Combined with LogNorm + masking, an all-zero matrix can be rendered safely; exiting here prevents generating heatmaps for sparse/empty probes.
def calculate_nonzero_scale_min(matrix):
"""Use the smallest finite positive value as the matrix scale minimum."""
positive_values = matrix[np.isfinite(matrix) & (matrix > 0)]
if positive_values.size == 0:
raise SystemExit(
"Error: Heatmap data must contain at least one positive value.")
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Marsssqqq
force-pushed
the
xym/deepepv1-normal-deepxtrace-public
branch
from
August 12, 2026 14:51
019e4b9 to
cc817fa
Compare
alpha-baby
approved these changes
Aug 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds end-to-end diagnosis for DeepEP's throughput-oriented Normal dispatch and combine path. It allocates the cumulative probe counters, collects stream-ordered snapshots, constructs independent diagnosis windows, localizes six Notify and Completion probes, correlates their evidence into conservative incident classes, and exports structured logs, NPZ artifacts, and heatmaps.
Motivation
Normal mode and low-latency mode serve different workloads. Normal mode is used for MoE training and inference prefill, where larger token sets traverse a hierarchical RDMA/NVLink path and communication overlaps with upstream computation and scheduling. A slow operation can therefore mean either that a rank arrived late or that progress slowed after arrival.
The existing low-latency receive-wait matrix cannot express all of these stages. Normal diagnosis needs separate arrival and completion evidence, topology-aware localization, and conservative cross-probe correlation.
Runtime integration
Diagnosis is disabled by default and configured by DeepXTrace:
Every EP rank calls
Diagnose.create_from_env(). The factory verifies that enablement and collection mode are consistent across the group. When disabled, it returnsNone.The Dispatch getter returns a ten-tensor opaque bundle; the Combine getter returns a five-tensor opaque bundle. Applications pass both bundles without unpacking or reordering them. Notify timer scratch remains private to DeepEP.
Counter layout and normalization
All Normal counters are views into one contiguous CUDA
int64allocation:3 x 23 x EP3 x EP3 x EPAfter gathering one local vector from every destination rank, the Completion groups are transposed from
[destination, source]into source-oriented matrices. Notify metrics useduration_sum_ns / count; Completion metrics usecost_sum_cycles / sample_count, whiletokens / sample_countremains available as load context.Ordered snapshot and window collection
Both schedules operate on the same monotonic counter block:
Passing the producer stream is the ordered path used by the companion integration. If asynchronous collection is explicitly used without it, DeepXTrace emits a warning and falls back to an unordered best-effort D2H snapshot.
For non-world or non-contiguous EP subgroups, DeepXTrace resolves the ordered global ranks, creates the matching Gloo group for asynchronous collection, and uses the correct global root. Rank 0 subtracts consecutive cumulative snapshots to form the current window. At the end of warm-up, a new cumulative boundary is captured and all earlier samples are discarded.
Normal probes
notify_dispatchcached_notify_dispatchcached_notify_combinedispatch_finaldispatch_rdma_recvcombine_logical_recvSemantic diagnosis
Independent probe analysis
Each Notify probe compares valid per-rank average duration with the current peer median. A ratio at or below
0.25is raw late-arrival evidence: a rank entering a synchronizing Notify kernel later typically spends less time waiting inside that kernel. The three Notify paths are not merged.Completion probes first construct a same-window topology reference:
The diagnoser applies
log(actual / reference), removes the window-wide, source-row, and destination-column effects in order, and then tests the remaining point/edge residual. Dense matrices additionally compare node blocks with other blocks of the same intra-node or inter-node class. This produces source rows, destination columns, points, node blocks, source/destination gateways, and gateway edges without reporting the same shared slowdown repeatedly at every cell.Global slowdown is intentionally simpler than per-cell historical comparison: after three accepted normal windows establish a baseline, one topology-aggregated scalar per probe is compared with the median of up to 16 previous normal windows. An anomalous window is not learned into that history. This baseline bootstrap is separate from the collection warm-up boundary described above.
duration / peer median <= 0.25>= 1.25x>= 2.0x>= 3.5>= 1.3x3 / 16accepted normal windowsThe three user-facing ratios remain configurable through
DEEPEP_DIAGNOSE_*environment variables; the history and robust-score constants are implementation policy.Cross-probe correlation
Correlation is conservative and does not erase the six independent probe results:
notify_dispatchorcached_notify_dispatchanomaly, with bothdispatch_finalanddispatch_rdma_recvnormalpre_stage_arrival_skewfor that Notify probecached_notify_combineanomaly, withcombine_logical_recvnormalpre_stage_arrival_skewfor that Notify probeglobal_data_path_slowdownlocalized_data_path_slowdownunclassifiedRDMA receive evidence is attached to a global or localized data-path incident when its scope supports the same conclusion; it is not treated as a fixed HCA-to-rank mapping.
Logging, artifacts, and heatmaps
0emits the compact per-window summary.DEEPEP_DIAGNOSE_LOG_DETAILS=1additionally emits all six per-probe details and the full source-oriented vectors/matrices. Every Normal summary, detail, and values line carries the sameInstanceID,EPSize, andWindowIndexcontext; each detail is immediately followed by its values.tools/deepxtrace_heatmap.py --all <window.npz>renders one Notify chart and three Completion heatmaps.Validation
EP16 setup
The functional run used two 8-GPU NVIDIA H20-3e nodes (EP16), PyTorch
2.11.0+cu130, an asynchronous one-second interval with a one-second collection warm-up, detail logging level 1, 4,096 tokens, hidden size 4,096, top-k 8, 128 experts, and 24 communication SMs. The Normal APIs were exercised after initializing NVSHMEM withlow_latency_mode=Trueand explicit NIC-PE mapping across four bonded HCAs. The workload ran 512 warm-up iterations followed by 512 measured iterations per phase. Dispatch alternated between 256 non-cached and 256 cached calls; cached Combine ran for all 512 iterations. Both node launchers and all RDMA pressure processes exited successfully.Five-phase result
The window column identifies the NPZ artifact used for the heatmaps; numeric signatures summarize all 512 measured iterations in that phase.
ok; no fixed source-row or destination-column bias0.036non-cached and0.006cached; all Completion medians remained within0.2%of baselinepre_stage_arrival_skewincidents for rank 90.006; all Completion medians remained within0.3%of baselinepre_stage_arrival_skewfor rank 91.371x / 1.447x / 1.514xbaselineglobal_data_path_slowdown0/1/8/9localized_data_path_slowdownThe current
tools/deepxtrace_heatmap.py --allimplementation generated four images from each representative NPZ window: one three-panel Notify-duration chart plus Dispatch-final, Dispatch-RDMA-receive, and Combine-logical-receive cost-per-sample heatmaps.Heatmap evidence
Baseline — window 3
Rank-9 pre-dispatch compute delay — window 8
Rank-9 pre-combine compute delay — window 16
All-HCA RDMA pressure — window 26
Single-HCA RDMA pressure — window 58
Each heatmap uses an independent automatic color scale; cross-window comparisons should use the annotated cell values rather than colors alone.
Compatibility
0.1.0to0.2.0.Companion DeepEP PR
The device-side Normal Notify, Dispatch, and Combine probes, together with the optional Dispatch/Combine tensor-bundle arguments, are implemented in deepseek-ai/DeepEP#720.