Repository navigation
CollectiveX: align eager samples across ranks like DeepEP's bench_kineto / CollectiveX:像 DeepEP 的 bench_kineto 一样跨 rank 对齐 eager 样本 - #4056
Conversation
There was a problem hiding this comment.
I reviewed this PR and didn't find any bugs. Because it changes cross-rank benchmark timing/alignment semantics in a CODEOWNER-owned path (collectivex/), a human look would still be worthwhile.
What was reviewed: the per-sample spin-then-all-reduce alignment and spin calibration in ep_timing.py, and its wiring through ep_backend.alignment_misses() into ep_harness's missed_fraction/tail-withholding logic; chain()'s once-per-sibling (not per-sample) alignment, which matches its docstring and is covered by dedicated tests; and that stage's percentiles publish ungated by missed_fraction by design (stage is local work, noted both in-code and in methodology.md).
Extended reasoning...
The diff adds a per-sample GPU-spin-then-device-all-reduce rank-alignment barrier to CollectiveX's eager EP benchmark timing (ep_timing.py), exposes it via ep_backend.py, aggregates missed-sample counts into missed_fraction and tail-withholding plus implementation metadata in ep_harness.py, documents it in methodology.md, and adds/extends tests in test_chain.py. It touches no auth, crypto, or data-exposure surface — it is internal benchmarking/measurement code. I traced the alignment logic (spin calibration, leads/missed_samples, chain's once-per-sibling barrier, and the tail-gating formula) end to end and found it internally consistent with its own tests and docs; the deciding factor for deferring rather than approving is that collectivex/ is CODEOWNER-owned (by the PR's own author and another owner) and this is a non-trivial, hardware-calibration-dependent change to measurement semantics, so a human sign-off is still warranted.
6e3a21e to
3c8ea48
Compare
edab294 to
911eaef
Compare
911eaef to
030f8ef
Compare
Graphed rows now open each timed replay with an in-graph all-reduce, so a late host launch no longer lands inside the window. Eager rows had no per-sample alignment at all: the cross-rank MAX charged host launch skew as latency at small T. That covers uccl-ep normal mode and every eager prefill, which sit beside graphed rows on the dashboard. Each eager sample, and each chain sibling, now opens with a GPU spin (500 us of wall time, calibrated per series) and then a device all-reduce, queued ahead of the sample with no host sync before the start event. That is the order DeepEP's own benchmark uses, so the last rank's timed work is already queued when the barrier releases everyone. Eager rows carry a new `-eager-spin-ar` kernel-generation suffix. 图回放行现在在每次计时回放前于图内执行 all-reduce,主机延迟启动不再落入计时窗口。 而 eager 行此前没有逐样本对齐:小 T 时跨 rank 的 MAX 把主机启动偏差计为延迟。 这影响 uccl-ep normal 模式和所有 eager prefill,它们在仪表盘上与图回放行并列。 现在每个 eager 样本以及每条链的起点,都先执行一次 GPU 自旋(按序列校准为 500 微秒 墙钟时间),再执行设备端 all-reduce,二者在样本之前入队,且开始事件前没有主机同步。 这与 DeepEP 自身基准测试的顺序一致,屏障释放时最后一个 rank 的计时工作已在队列中。 eager 行带有新的 `-eager-spin-ar` kernel generation 后缀。
A 500 us spin covered the typical sample enqueue (~50-70 us) but not its occasional stalls: on h200 uccl-ep normal decode the roundtrip p99 roughly doubled and the cross-rank spread p99 rose from ~20 us to 185-293 us. The spin now lasts 2 ms by default (COLLX_ALIGN_SPIN_US) and is calibrated after each series' warm-up instead of before it. Each sample also records the host time from the spin's enqueue to its start event. A sample that some rank entered after its spin ran out counts as missed. Rows publish per-series counts under rank_alignment and withhold every fresh-entry tail the misses could fill (p99 at 1% of samples, p95 at 5%, p90 at 10%); implementation.rank_alignment records the method and spin length. The methodology documents the miss gate and the host-synced and no-L2-flush limits, and marks the old spread examples and the 5-10% vendor estimate as predating per-sample alignment. CollectiveX:延长 eager 对齐自旋并统计未对齐样本 500 us 的自旋能覆盖通常的样本入队时间(约 50-70 us),但覆盖不了偶发的 主机停顿:在 h200 uccl-ep normal decode 上,roundtrip p99 约翻倍,跨 rank spread p99 从约 20 us 升至 185-293 us。自旋默认改为 2 ms (COLLX_ALIGN_SPIN_US),并在每个序列预热之后而非之前校准。 每个样本还记录从自旋入队到起始事件记录的主机耗时。若某个 rank 在自旋结束 之后才进入样本,该样本计为未对齐。每行在 rank_alignment 下按序列发布计数, 并隐藏未对齐样本可能填满的所有 fresh-entry 尾部百分位(样本的 1% 隐藏 p99,5% 隐藏 p95,10% 隐藏 p90);implementation.rank_alignment 记录对齐 方法和自旋时长。 方法文档补充了未对齐门控、主机同步模式和无 L2 刷新的限制,并注明旧的 spread 示例和 5-10% 的厂商对比估计早于逐样本对齐。
The ~1.3 ms dispatch excursions in eager uccl-ep normal EP16 decode on b200-nscale come from the platform, not from the rank alignment. While uccl-ep EP16 runs, the nodes intermittently run the cores of both sockets at about 200 MHz effective (scaling_cur_freq) for 100-200 ms, every 2-5 s, then take 10-20 ms to wind back up through 3-7x. An idle pinned process outside the benchmark runs ~16x slow over the same spans, the GPUs keep their clocks and the thermal-throttle counters stay at zero. The same nodes show none of it idle, with 40 cores busy, during uccl-ep EP8, or during deepep-v2 EP16, whose RDMA is GPU-initiated where uccl-ep posts its own from 32 busy-polling CPU proxies per node. Base and eager runs see it at the same rate (0.15-0.29 episodes/s per node). A host-synced dispatch relaunches its transfer from inside the window once the notify counts arrive, so those 50-100 us of host work take 1-2 ms and every rank waits on them: MIN rises with MAX. About 90-98% of the inflated eager samples sit inside a node-wide slow interval. Pre-alignment rows are not immune: three base runs had roundtrip p99 at 2.4-4.6 ms at 2, 10 and 6 of 10 rungs. Their loop is paced by the host, so it slows ~8x during a throttle, while the eager loop is paced by its 2 ms spin and slows ~2.4x. A throttle therefore holds a smaller share of base samples. On one node pair with equal canary-measured throttle rates, base roundtrip p99 was inflated at 2 of 10 rungs and an eager variant with base's in-window host work at 10 of 10. Series whose dispatch waits on the host (uccl-ep normal, deepep-v2 normal prefill) now pass each sample through a host gate, outside the window. Before the sample opens, a ~20 us interpreter probe runs; while it is more than 2.5x slower than the run's lowest calibrated median, the rank keeps probing instead of opening the sample, and the other ranks wait at the alignment barrier. A probe after the final sync catches a throttle that began inside the window. A sample waits at most 0.5 s and a run 60 s in total; past that, throttled samples count as stalled. Rows publish rank_alignment.host_held_samples (holds longer than 1 ms; those samples opened at speed and gate nothing) and host_stalled_samples (a probe beside the window over 5x), each with its largest series share. Stalled samples gate the tails like missed ones. Away from throttles a ~50 us slice of Python on a rank's own core exceeds 2.5x its median in at most 0.2% of samples and 5x in about 0.001%. Other series take no probes, and graphed rows are unchanged. Holding measures the library on a host running at speed; a uccl-ep EP16 decode loop on this platform pays the throttles too, and host_held_fraction shows how often they came. This replaces gating the tails on probe-detected stalls alone. Stalls hit 0.9-3.2% of decode samples, so that withheld p99 at all 10 rungs. Validated on b200-nscale at 2048 samples per rung. EP16 decode: three held runs kept roundtrip p99 at 477-870 us at every rung, two of them on the node pair of the base run inflated at 6 rungs. Their cross-rank spread p99 was 21-30 us (base 33-394) and p50 1-26% below base. Holds covered about 2% of a series at most (5% in prefill) and stalls at most 0.4% (0.6%), so no tail was withheld; misses stayed at 0-2 per 2048. EP16 prefill p99 sat 90-170 us above p50, against 1.5-3.4 ms in base. A fourth held run shared a node pair with the 10-rung base run: one of those nodes kept a socket throttled a third of the time, the hold budget ran out and every tail was withheld. uccl-ep EP8 and deepep-v2 EP16 saw no throttle and no holds. Every row passed correctness. 修复(collectivex):主机降频期间暂缓 eager 主机同步样本 b200-nscale 上 eager uccl-ep normal EP16 decode 中约 1.3 ms 的 dispatch 异常来自平台本身,而非 rank 对齐。uccl-ep EP16 运行期间,节点会间歇性地 让两个插槽的核心以约 200 MHz 的有效频率(scaling_cur_freq)运行 100-200 ms,每 2-5 秒一次,随后还需 10-20 ms 才从 3-7 倍的减速逐步恢复。 基准测试之外一个空闲且绑核的进程在同一时段内慢约 16 倍;GPU 时钟不受 影响,温度降频计数保持为零。同样的节点在空闲时、40 个核心满载时、 uccl-ep EP8 期间,以及 deepep-v2 EP16 期间都没有出现这种情况: deepep-v2 的 RDMA 由 GPU 发起,而 uccl-ep 由每节点 32 个忙轮询的 CPU 代理线程发起。base 与 eager 运行看到的降频频率相同(每节点每秒 0.15-0.29 次)。主机同步的 dispatch 在 notify 计数到达后于计时窗口内 重新发射传输,因此这 50-100 us 的主机工作被拉长到 1-2 ms,所有 rank 都要等待它:MIN 与 MAX 一同升高。约 90-98% 被拉长的 eager 样本落在整个 节点变慢的区间内。 对齐之前的结果并非不受影响:三次 base 运行分别在 10 档中的 2、10、6 档 出现 2.4-4.6 ms 的 roundtrip p99。其循环由主机驱动,降频期间会变慢约 8 倍;而 eager 循环由 2 ms 的自旋驱动,只变慢约 2.4 倍。因此一次降频落入 base 样本的比例更小。在同一组节点、经 canary 测得降频频率相同的情况下, base 的 roundtrip p99 在 10 档中有 2 档被拉高,而窗口内主机工作与 base 相同的 eager 变体则是 10 档全部被拉高。 dispatch 需要等待主机的序列(uccl-ep normal、deepep-v2 normal prefill) 现在让每个样本在计时窗口之外经过一道主机闸门。样本开始之前会先运行一个 约 20 us 的解释器探针;只要它比本次运行最低的校准中位数慢 2.5 倍以上,该 rank 就继续探测而不开始样本,其他 rank 在对齐屏障处等待。最后一次同步 之后的探针用于捕捉在窗口内开始的降频。单个样本最多等待 0.5 秒,整次运行 总计最多 60 秒;超出之后,降频中的样本计为停顿。结果行发布 rank_alignment.host_held_samples(超过 1 ms 的等待;这些样本在全速时才 开始,不影响尾部)和 host_stalled_samples(窗口两侧任一探针慢于 5 倍), 并分别给出其最大序列占比。停顿样本与错过对齐的样本一样会隐去尾部。在 降频之外,rank 自身核心上一段约 50 us 的 Python 超过其中位数 2.5 倍的 样本至多占 0.2%,超过 5 倍的约占 0.001%。其他序列不做探针测量,图模式的 结果不变。暂缓样本衡量的是主机全速时的库性能;在该平台上运行的 uccl-ep EP16 decode 循环同样要承受这些降频,host_held_fraction 显示它们出现的 频率。 此修改取代了仅凭探针检测到的停顿来隐去尾部的做法。停顿影响 0.9-3.2% 的 decode 样本,那样做会让全部 10 档的 p99 被隐去。 已在 b200-nscale 上以每档 2048 个样本验证。EP16 decode:三次暂缓样本的 运行在每一档的 roundtrip p99 都保持在 477-870 us,其中两次与那个有 6 档 被拉高的 base 运行使用同一组节点。其跨 rank spread p99 为 21-30 us (base 为 33-394),p50 比 base 低 1-26%。暂缓的样本最多约占一个序列的 2% (prefill 为 5%),停顿至多 0.4%(0.6%),因此没有尾部被隐去;错过对齐 的样本保持在每 2048 个中 0-2 个。EP16 prefill 的 p99 比 p50 高 90-170 us,而 base 高 1.5-3.4 ms。第四次暂缓样本的运行与那个 10 档全部 被拉高的 base 运行共用一组节点:其中一个节点有一个插槽三分之一的时间 处于降频,等待预算耗尽,所有尾部都被隐去。uccl-ep EP8 和 deepep-v2 EP16 没有出现降频,也没有暂缓的样本。所有结果行都通过了正确性检查。
556b630 to
9cd5f10
Compare
Summary
Eager rows are the modes that cannot be graph-captured: uccl-ep normal, and the deepep-v2, nccl-ep and flashinfer prefill rows. They opened each timed window at each rank's host launch, so the cross-rank MAX charged launch skew to the measured operation. #3727 aligns graphed rows with an in-graph all-reduce. This PR aligns eager rows the way DeepEP's
bench_kinetodoes: every sample first enqueues a GPU spin (2 ms of wall time,COLLX_ALIGN_SPIN_US) and then a device all-reduce, with no host sync before the start event.A sample whose host takes longer than the spin to reach its start event can open its window late. Each sample's host lead is therefore checked against the spin.
rank_alignmentreports the missed samples per series and amissed_fraction.implementation.rank_alignmentrecords the method and the spin length, and eager rows'kernel_generationgains-eager-spin-ar.Results
H200 EP8 uccl-ep normal decode. These are single runs, interleaved on one node. Base is #3727 without this change.
cross_rank_min_usp50 drops 9-11%, andpair_periodmoves -6% to +2%, within run-to-run drift.pair_periodis unchanged, and every row has 0 misses, so the_sleepcalibration holds on ROCm.Host throttles: b200 uccl-ep EP16
Two-node uccl-ep normal decode on b200-nscale showed ~1.3 ms dispatch excursions on every rank at once in about 1% of eager samples, which the miss counter could not see. The cause is the platform, not the alignment:
The fix applies only to series whose dispatch waits on the host (uccl-ep normal, deepep-v2 normal prefill):
host_held_samplesandhost_stalled_sampleswith their shares, so the platform's exposure stays visible. Graphed rows and other series are unchanged.b200 EP16 decode, 2048 samples per rung, three base and three held runs:
Notes
stageseries is not aligned. Staging is local work, so its misses are counted but do not gate the row.AI model disclosure
claude-opus-5-5, run through Claude Code): implementation, tests, the hardware A/B runs and this description.claude-fable-5-1): independent read-only review of the 500 µs version. It found the cause of the p99 regression and proposed the longer spin and the miss counter.claude-opus-5-5) subagents: cluster preparation, the multi-node A/B, and the b200 host-throttle diagnosis and fix.中文
摘要
Eager 行是无法被 CUDA graph 捕获的模式:uccl-ep normal,以及 deepep-v2、nccl-ep 和 flashinfer 的 prefill 行。它们在各 rank 的主机启动时打开计时窗口,因此跨 rank 的 MAX 会把启动偏差算进被测操作。#3727 用图内 all-reduce 对齐 graph 行;本 PR 按 DeepEP
bench_kineto的方式对齐 eager 行:每个样本先入队一个 GPU 自旋(墙钟 2 ms,可用COLLX_ALIGN_SPIN_US调整),再入队一个设备端 all-reduce,起始事件之前没有主机同步。如果主机到达起始事件所用的时间超过自旋时长,该样本的窗口可能晚开,因此每个样本都会把主机领先时间与自旋时长比较。
rank_alignment按序列报告未对齐样本数和missed_fraction。implementation.rank_alignment记录对齐方法和自旋时长;eager 行的kernel_generation增加-eager-spin-ar后缀。结果
H200 EP8 uccl-ep normal decode。均为单次运行,在同一节点上交替执行;base 为不含本改动的 #3727。
cross_rank_min_usp50 下降 9-11%;pair_period变化在 -6% 到 +2% 之间,属于运行间漂移。pair_period不变,每行未对齐样本为零,说明_sleep校准在 ROCm 上同样有效。主机降频:b200 uccl-ep EP16
b200-nscale 上两节点的 uccl-ep normal decode 中,约 1% 的 eager 样本在所有 rank 上同时出现约 1.3 ms 的 dispatch 异常,未对齐计数器无法发现。原因在平台而非对齐:
修复只作用于 dispatch 需要等待主机的序列(uccl-ep normal、deepep-v2 normal prefill):
host_held_samples和host_stalled_samples及其占比,使平台的影响保持可见。graph 行和其他序列不变。b200 EP16 decode,每档 2048 个样本,三次 base 和三次暂缓运行:
说明
stage序列不对齐;staging 是本地工作,因此其未对齐样本只计数、不参与门控。