Module profile

Module profile 

Source
Expand description

ATLAS_GLM_PROFILE=1 — per-section decode timing for the GLM-5.3 stack.

Off unless the variable is set. Every span ends in a synchronize, so enabling it SERIALISES the stream: read the split, not the total, and never quote a tok/s taken with it on.

Sections are chosen to separate the three things that can each explain a 10x decode gap and look identical from the outside: weight bandwidth (the GEMM buckets), launch and host-sync latency (moe_hostsync, call counts), and collectives (reduce_*).

Constants§

DSA_ATTEND
DSA_INDEXER
DSA_PROJ
DSA_SELECT
KDA
MHC
MHC_POST
mHC split by kernel: hc_pre (the mix + finish pair) vs hc_post (+ expand/head).
MLP_DENSE
MOE_COMBINE
MOE_EXPERTS
MOE_HOSTSYNC
MOE_ROUTER
MOE_SHARED
NORM
REDUCE_ATTN
REDUCE_ATTN_BAR
A 2-BYTE collective issued immediately before the real one, PROFILING ONLY. It is a rendezvous: neither rank leaves it until both have arrived, so it absorbs the per-call arrival jitter and charges the minimum-payload NCCL latency. The real 8 KB reduce that follows therefore starts with both ranks synchronised, which is what makes REDUCE_ATTN/REDUCE_MLP readable as network-and-kernel cost rather than “network plus whatever the other rank was still doing”.
REDUCE_ATTN_ENQ
Host-side ENQUEUE cost of the two collectives — the driver/NCCL calls only, no sync. Paired with REDUCE_ATTN/REDUCE_MLP, which then time ONLY the synchronize that follows, i.e. the device + network + rank-skew wait. Splitting them is the difference between “the fabric is slow” and “we call it 90 times a token”.
REDUCE_MLP
REDUCE_MLP_BAR
REDUCE_MLP_ENQ

Functions§

end
end_nosync
Record a span WITHOUT synchronising — host-side wall time only.
end_us
Same, returning the measured microseconds (0.0 when profiling is off).
full
True only at level 1 — the per-kernel spans.
on
probe_buf
4-byte device scratch for the rendezvous probe. Allocated once, PROFILING ONLY.
start
Open a span. None when profiling is off, which makes end a no-op.
start_hot
A span that survives level 2: the collectives and their rendezvous probe.
stash_route
Called from forward_moe right after the routing D2H. No-op unless tracing.
step
Close one token. Dumps a cumulative per-token split every 8 steps, then keeps going — the totals are cumulative so a later dump is simply better averaged.
trace_bar
Emit the joined line. site is attn or mlp; moe says whether THIS layer’s MLP is routed (the 3 dense layers are the natural control: no EP imbalance is possible there).
trace_on
ATLAS_GLM_ROUTE_TRACE=1 — emit one line per reduce site per layer per token carrying the router’s selected GLOBAL expert ids and the measured rendezvous (arrival-skew) time.