Skip to content

perf(v41 mono): TP8 layer kernel - seam x8 handoff, index select, MoE down take, PV merge - #3813

Open
yifehuan wants to merge 25 commits into
mainfrom
yifehuan/mono_layerkernel
Open

yifehuan wants to merge 25 commits into
mainfrom
yifehuan/mono_layerkernel

Conversation

@yifehuan

@yifehuan yifehuan commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

No description provided.

…SCALATE retries

COPY_SAFE (16 units, set beside KV copies) costs the layer kernel +3.6..3.9% TPOT
at TP8 (G128) though a step's waits end in a few retries. With
ATOM_MONO_POLL_ESCALATE=N a wait's first N retries sleep one unit and only the
later ones the configured backoff, as the gfx1250 step escalates past
BACKOFF_ROUNDS. Off by default; part of the JIT cache tag.
…e top-k without carried scores

down_y: thread 0 takes the arrival rank (DQ) and the first unit (DNQ) back to back
and hands both over in one LDS word (take_down_rank_unit). The two atomics' words go
through an opaque move: on a uniform address LLVM's atomic optimizer reads each result
back at once, which was two agent-scope round trips in series before the CTA's first
unit. A unit's next is still taken after it (down_y_run, then take_down_unit): taking
it ahead let the first CTAs to arrive claim two units each and the last none (+6%), and
placing the first round by block made the CTAs that end ug late hold up their units (+3.5%).

stage_route: a lane's keys sorted with their experts only, each winner's unbiased score
read back from route_scores' LDS by its expert at the end (the same value, the same
top-k-order sum), and the round's max by in-row DPP rotations fused into v_max_i32_dpp
(select.wave_max_key) instead of xor shuffles: the six rounds 224 -> 131 ISA lines.
Bit-identical routes.

TP8 layer kernel, single node, fixed acceptance 3.51, short TPOT (133K / 400K), each
arm against the same run's base:
- dq3 + top-k (049, 3 pairs): -1.22% / -1.39% (-33 / -38 us a step)
- dq3 + top-k (032, 1 pair before the job's time limit): -1.33% / -1.20%
- dq3 alone (049, 2 runs): -0.02% / -1.01%, -1.05% / -0.92%
- top-k alone (4 runs on 032 / 227): mean -0.63% / -0.58%
Needle 83K / 133K / 300K (natural MTP): 3/3, as the base. The layer build compiles
(TP8, fp8 / bf16 KV, sharded or not), 164 VGPRs, no new spills.
…s together

_merge_pv ran its 20 16-slot blocks a wave one branch each, so every block's
transposed V read and P read waited its own LDS round trip before its MFMA.
Now PV_GROUP (4) blocks a branch: the group's reads issue together, then its
four MFMAs, one LDS round trip a group (5 a wave). A group's condition is its
first block's (the slots holding keys are a prefix of the selection's and of
the window's, a group inside one of them), any block's across their boundary;
an OR of a group's four held the kernel's SGPRs, at their 104, to 36 B of
scratch, which the runtime refuses. A block without a key in a taken group
adds exact +0 products (V +0 at its slots, P exp2(NEG - m) = +0): acc and
the output unchanged.

Layer kernel, TP8, fixed acceptance 3.51, 049 + 086, two pairs each:
-0.63% TPOT on average (133K / 400K: +0.31 / -1.32, -0.69 / -0.83);
ISA 18640 -> 18485 instructions, scratch 0, SGPR spills 220 as before.
GSM400 gate (natural MTP): 3.392 tokens/step vs 3.319, GSM 0.9325 vs 0.945,
needle pass, within the gate's run-to-run spread (no API seed at T=0.01).
…nd trip

load_seam_x8 copied the seam's normed rows into LDS with two rows_to_lds
calls, so the codes' loads went out only after the words' had landed and
been stored: two device round trips after the X8F poll (G205 timeline: the
wqkv side's rows in LDS 1.0 us after the flag). rows_to_lds_together
(mono/device/ops.py) issues every spec's loads, then stores them; a
side-effecting no-op after the loads keeps LLVM from sinking the codes'
load past the words' stores (without it the ISA still read 4 loads, then 1).
The same words and codes land in the same LDS: the output is unchanged.

Layer kernel, TP8, fixed acceptance 3.51, 049, three pairs (G208):
133K -0.25% / 400K -0.47% TPOT, every pair faster (-0.17 / -0.19 / -0.40,
-0.42 / -0.37 / -0.61); scratch 0, SGPR spills 220 as before.
… word's code in its tag

An ordinary sharded layer (AttnPreBuild.slice_x8: it folds, feeds no
indexer, takes no embedding) no longer runs the seam norm. Seam A's slices
quantize x for wqkv_a themselves, as TK's QKV takes it:
bf16(bf16(LIN) attn_w) without the attention rstd (q_norm and kv_norm
cancel a row's scale), MXFP8 over the slice's 32 columns with ATOM's
quantize_fp8 code. Each word goes to its destination rank's X8G with its
group's E8M0 code in the high half of its tag (Mailbox.put_coded), and
wqkv_a takes words and codes in one poll (Mailbox.poll_coded): no LIN /
LSSQ push, no norm stage, no X8 flag, no second round trip for the codes.
The slice's norm weights go out with its first loads (at the quantization
they were a load on every slice's path), and with the norm's CTAs free the
gate blocks move onto slice CTAs 16.. and wqkv_a starts at CTA 160, so q's
96 tasks sit on CTAs no slice holds (their weights were out only past the
slice: those tasks ended the stage 1 us late).

TPOT against 6f918444, TP8, one request, fixed acceptance 3.51, 133K /
400K: the probe (sx8e) -0.51 / -0.32% (3 rounds, 049), -1.07 / -0.57%
(3 rounds, 049), -0.81 / -0.79% (1 round, 140); this code -1.28 / -0.40%
(3 pairs, 049). Without the placement -0.49 / -0.64%. Not bit-exact (x8
without the rstd): GSM400 gate 4 runs 0.924 (0.9175 .. 0.935), tokens a
step 3.333, needle 8/8; HEAD 0.929 / 3.326 / 8/8.
…beside its blk tree

The candidate producer (the c1 layer) ranked its row's columns only after
its blk tree had picked the top 2048 blocks and compacted their rows: blk
L0 -> blk L1 + compaction -> sel L0 -> sel L1, all serial (G232: ~33 us of
the layer's index stage at 133K). The attention waits on the selection
alone; the blocks and the compaction are read only by the later REINDEX
layers (after the launch, _candidate_table). Its selection now takes every
column as a FULL row's tree, on CTAs from PROD_SEL0 = 48 (past the blk
tree's first level), so it runs beside the blk tree instead of after it.
Same answer: every top-512 row lies in a block whose maximum reaches it,
so among the top-2048 blocks (index_plan.compacts), ties to the lower
column in both.

Past PROD_FULL_MAX = 32 segments (262144 columns) the full tree's first
level outgrows the grid beside the blk tree (400K: 49 segments, 294 tasks)
and ran slower (+0.5 .. +0.8%), so a wider row keeps the compacted path.

Timeline (133K): the c1 layer's index stage -8.65 us, its end -8.3 us.
TPOT against aa60187a, fixed acceptance 3.51, 6 pairs on two nodes:
133K -0.58% (median -0.36%, 5 of 6 negative), 400K -0.11% (median
-0.03%). Bit-exact.
A candidate producer's blk tree compacted each long row's candidate
blocks into the front of its ilog row in place (_compact). Since c1pb
its selection takes every column beside that tree (PROD_FULL_MAX), and
there the compaction raced the full tree's level-0 reads of the same
row: it rewrote columns those tasks could still be reading, and nothing
read what it wrote (a REINDEX layer scores its candidates afresh into
ilog). The compaction now runs only where the selection ranks the
compacted columns (_wide, the same test run_indexer makes); icout and
ICRDY go out as before.

A wait in _compact for the full tree's level-0 lists would deadlock:
past 208 lists the full tree's tasks wrap onto CTAs 0..47, which hold
the compacting blk tasks.

Measured (G264b, 049): natural-MTP gate GSM 0.93, needle 133K / 400K
found, tokens/step 3.295; first TPOT pair 133K -0.93%, 400K -0.17%.
Contract S=6 holds; 423 CPU tests pass.
…st step's k-th

Each selection list keeps its previous step's k-th order key as an
anchor, in a block the runner places in front of each selecting
layer's isel (index_plan.anchor_bytes; zero at first: a miss). The
first round bins the keys whose top 16 bits lie within 127 of the
anchor's into 254 bins, the window's top and bottom as the two outer
ones. When the k-th lands inside the window, the prefix and the
remaining count are exactly what rounds 0 and 1 would leave, and only
rounds 2 and 3 run; otherwise the four rounds run as before. A zero,
stale or garbage anchor only misses, so the selection is exact either
way (python model: 36k cases incl. ties, +-0, +-inf, NaN).

Measured on fe31e33b: TPOT 6 pairs (049 / 140), 133K -0.45% (all six
negative), 400K -0.14%; natural-MTP gates GSM 0.94 / 0.9525, needle
133K / 400K found, tokens/step 3.275 / 3.292. The timeline shows the
c0 index stage 0.5-0.9 us earlier a layer (a hit saves radix round 1).
Contract S=6 holds; 423 CPU tests pass. The runner asserts a step's
rows <= ANCHOR_ROWS (64).
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every eligible PR before approval:

  • ✅ Pre Checkin: Black, Ruff, catalog schema validation, non-GPU unit tests

Heavy model tests:

  • ✅ Gate checks are published on every PR so required checks do not stay missing
  • ✅ Expensive jobs run only after the PR is approved, or when a matching ci:* label is present
  • ✅ Pre Checkin must pass before approved heavy jobs continue
  • ✅ Without a matching label, expensive jobs also require a relevant path
  • ✅ A matching ci:* label is an explicit request and can open the gate even when paths would otherwise skip it

Path scope:

  • Native ATOM uses an ignore list: docs/markdown and plugin or Mesh paths are skipped
  • vLLM and SGLang use include lists: their own plugin code under atom/plugin/, plugin CI scripts, model list and release images. A core-only change does not run them; add ci:vllm / ci:sglang to ask for them
  • ATOMesh uses an include list: Mesh code, the ATOMesh accuracy workflow and its 1P1D launcher, plus the shared models_accuracy.json and accuracy_to_dashboard.py. ATOMesh benchmarks run after merge or on dispatch, not on PRs
  • Relevant path alone does not start expensive jobs; approval still opens the automatic path-scoped gate
Label Tests
ci:full Run all heavy PR model tests: native ATOM, vLLM, SGLang, and ATOMesh
ci:atom Run native ATOM model accuracy tests
ci:vllm Run ATOM vLLM OOT model accuracy tests
ci:sglang Run ATOM SGLang model accuracy tests
ci:mesh Run the ATOMesh accuracy tests, standalone and 1P1D, for Mesh-related changes

Without a matching ci:* label, heavy jobs are skipped when the path is not relevant or the PR is not approved.
Add labels via the sidebar or gh pr edit 3813 --add-label <label>

A mailbox wait's first POLL_ESCALATE (32) retries sleep one unit, only its
later ones POLL_SLEEP_UNITS, whenever the backoff is above 1: the
ATOM_MONO_POLL_ESCALATE switch is gone. A step's waits end in a few
retries, so COPY_SAFE's 16 (set beside KV copies) now spaces the long
waits alone. At COPY_SAFE the TP8 layer kernel's TPOT is 2.5 .. 3.7%
below a fixed 16 on three nodes (133K / 400K), within 0.6% of the
default 4's.

Hang reproducer (tools/mono_mailbox_copy_repro.py --mode side --repeats
1024, one GPU a process, 300 s watchdog, every round with a GPU event-window
overlap): on #3350's code, where 4 hung 2/2 (rounds 8 and 18), the same
escalation passed 16/16 and a fixed 16 13/13. On this code even 1 and 4 pass
(#3736's sync rework), so its escalated 24/24 and fixed-16 24/24 prove
nothing alone.
Since #3736 K1's ABI has ibound and numa_word, which the reproducer gave
neither a buffer nor a zero: it failed in setup ("K1 ABI fields without
a buffer or a zero") and then waited for the watchdog. Its K1 feeds no
index and keeps no dual-copy region (region_addrs reads no numa_word
then), so both are 0. --setup-only, mono-alone and side runs complete.
wqkv_a's poll of a slice_x8 build's words (load_slice_x8) takes every
row's quads at once: at 18 and 24 rows (a 16-row tile, 20 quads a
thread) the K1 took 256 VGPRs and spilled 28 B of scratch, which the
widths refuse, so a step of 3 or 4 requests took the original path
(seen as "V4.1 mono decode declined the 18-row / 24-row build"). A
build of more than SLICE_X8_MAX_TOKENS (12) rows keeps the seam norm,
as before slice_x8: scratch 0 at 18 / 24 rows (132 / 136 VGPRs), 6 and
12 rows unchanged (slice_x8, 140 / 214 VGPRs).
The escalation's retry counter in _spin pushed the layer kernel past its
SGPRs: the 5-row sharded FP8-KV build spilled 36 B of scratch (SGPRs at
104), and at server start the 5- and 6-row layer builds were "rebuilt
lean", +6.8% / +6.3% TPOT at 133K / 400K on 140 (one pair, against
9c08cccc, default backoff 4). Polling is main's again: 4 by default, 16
(COPY_SAFE) where a KV transfer or offload connector copies beside the
kernels; polling.py is main's and _spin sleeps POLL_SLEEP_UNITS on every
retry. The layer builds at 5 and 6 rows (TP8, FP8 / BF16 KV, sharded or
not) take the same VGPRs / SGPRs as 9c08cccc's, none with scratch.
Config set the Mono mailbox spacing to COPY_SAFE (16) for any KV transfer
or offload connector. The hold it guards against (#3369) needs a
copy kernel running beside a Mono grid: the copy's small workgroups keep
CUs the grid's last CTAs need while the resident CTAs' polls starve the
copy's loads. Isolated with the reproducer on #3350-era code: no hold when
the side kernel touches no memory, when it is CU-masked to half the CUs (or
to CUs disjoint from the grid's), or when the polls are light. The
Mooncake connector's DeepSeek-V4.1 copies (slot regions: no landing, no KV
or index staging) are two device copies of a compressor-state slot on the
forward's stream, so they never run beside the Mono launches; the PD
decode paid COPY_SAFE's 3.6 .. 3.9% TPOT for nothing.

_kv_copies_beside_mono leaves the spacing at the default for Mooncake with
DeepSeek-V4.1 and keeps COPY_SAFE for every other connector. The connector
now issues those two copies on the stream `set_forward_stream` reports
(RapidServe's per-forward stream), else the current stream as before, and
waits for the producer's gather with an event on that stream.
…allel

With ATOM_MOONCAKE_MATCHED_RAILS, a producer rank created each extra rail's
engine lazily on the first transfer to that rail, under the pool lock, and
registered the KV chunks one at a time. On MI355X/ionic with HIP dma-buf that
is about 1 s of kernel time per 2 GiB chunk: 61-138 s per rail for 131 chunks,
seven rails per rank in turn. The registration holds the process mmap lock,
so the serving thread blocked in mmap/munmap, the forward stalled, and the
first transfers passed their 120 s deadline (PD 4P8D, first request never
returned; 40 minutes after it, 22 of 28 rails were registered).

RailEnginePool.build_all() now builds every configured rail when the
connector registers its KV caches: all rails in parallel, each with
batch_register_memory (Mooncake's threaded registration, which takes the
primary 6-15 s), falling back to one-by-one registration with exact rollback.
A rail that fails stays failed, as before. get() keeps the lazy path for a
pool that was not built.
…ntry

An index-layer build (c0/c1/c2) carries 296-308 KB of code and runs once a
decode step, tens of MB of weight streaming after its previous launch, so
its I-cache misses go to HBM. At entry, wave 7 of CTAs 248..255 (one per XCD)
reads a dword of every 128 B line of the kernel's own text into its XCD's
L2: from the pc (s_getpc_b64) to lld's _etext, through a buffer whose
records end at the text, so nothing past the code object is read. Those CTAs
hold no slice, gate or seam-norm task; their first wait is the normed rows.
Ordinary-layer builds are byte-identical.

Short TPOT, TP8, fp8 KV, fp4 index, fixed acceptance 3.51, 3 pairs each:
- G287 (092): 133K -0.51%, 400K -0.62% (6 of 6 pairs negative).
- G288 (049): -0.20% / +0.02% against the base, and -0.53% / -0.24%
  against a same-layout control (the code present, the warm never run).
  The ~0.5-0.9 KB the warm adds to an index build shifts the rest of its
  code; on 049 that layout change alone costs ~+0.3%.
- G289: natural GSM400 gate 0.9375, needle 133K/400K found, 3.31
  tokens/step (no numeric change).
gfx950's vmcnt counts loads and stores in issue order, so any wait also
covers every older op. Two consequences showed up in the down stage's ISA:

- down_y_unit issued the first task's weights before the slot's MID poll,
  so the poll's first check waited for those weights. The other tasks'
  weights then went out only after the poll returned.
- Each task's DY stores (and each shared task's SDO store) sat ahead of the
  next task's weight wait, so that wait also covered the stores'
  cross-XCD acks.

Now:
- Mailbox.poll takes `between`, loads issued after the poll's first pass
  and before its check (_spin_first). down_y_unit issues the scale blocks
  and every task's weights there, and the first check waits on the poll's
  own loads alone (vmcnt(14) in the s6 ISA).
- down_y_unit runs every task's chains before any DY store.
- shared_down_unit holds each task's SDO word and stores them at the unit's
  end.

Measured with an in-process same-ISA A/B (Thue-Morse step labels, roles
swapped by request, TP8 single node, 3585 steps an arm; host A/A
-1.66 +- 0.62 us/step):
- all three: -16.3 +- 1.3 and -17.0 +- 1.8 us/step (about -0.6%)
- any one alone: not resolved
- dropping any one of the three costs 5.5 to 8.8 us/step

Process-level short TPOT could not resolve the change (2SE 0.2 to 1.2%).
It is bit-exact by construction: only issue order changes. GSM400 natural
gate 0.94.
A layer kernel's ~100 mailbox region addresses were summed once, when the
context was made, and held to their last use at the 104-SGPR cap (lane
spills, and scratch a little past it). `sync.fresh_s64` now passes a
region's base through an `s_mov_b64` whose asm string LLVM cannot merge
across stages, so each address is computed where it is used. A call site's
string (`_site`) is shared by a `range_constexpr` loop's unrolled
iterations. The kernel's late-read kernel arguments go through it once at
entry, so no merged kernarg tuple is held across the kernel.

The strings' counters restart at each trace (a new MLIR context), so a
kernel's IR, and FlyDSL's cache key from it, depend on its own trace
alone: a rebuild hits the cache.

Lane-varying bases (col_gather's per-lane peer, the indexer's replicated
`rdone`) keep `fresh=False`: forcing them uniform sent every push to one
rank.

SGPR spills: s6 265 -> 49, s12 239 -> 70, s24 210 -> 113, draft ~250 -> 42.
TP8 single node: TPOT 400K -0.58% (6/6 pairs), 133K -0.28% (5/6); AgentX
C1 matched requests -0.95% (n = 164, 83% faster); GSM400 gate 0.94.
The entry warm of 74f23800 ran in the index layers only, on the view that an
ordinary layer's ~100 KB of code, launched every layer, stays in L2. It
does not: a whole layer of weights streams through L2 between two launches
of the same code. Every layer build now warms its code at entry: one wave of
each of the last 8 CTAs (one an XCD), which hold no slice, gate or seam norm
task. The function is renamed `warm_layer_code` accordingly.

Same-ISA in-process A/B (switch word, Thue-Morse labels, role swap), TP8:
-7.0 +- 2.0, -7.4 +- 0.9 and -9.0 +- 1.2 us/step on two nodes. The
compile-time build shows no TPOT regression (133K -0.24%, 400K -0.54%).
…ng lane

The merge lands V as [8-column block][key][8 columns]. A block of
ATTENTION_KEYS_MAX keys is 10 240 B, 0 mod 256 B, so a 16-byte landing
store's 8 lanes of one key, one in each of 8 blocks, hit the same banks
(8-way). V_SLOTS = ATTENTION_KEYS_MAX + 10 makes the block stride 10 400 B:
distinct banks. The PV's transposing reads stay 2-way either way. Addresses
keep the unpadded form (slots, then words), so the keys' offsets remain the
stores' and reads' immediates and the land/gather interleave is unchanged.
Layout only: bit-exact.

TP8, torch profiler, 3 rounds against the same build unpadded: index layers
c0 -0.69 / -0.73 and c2 -0.77 / -0.65 us a launch (133K / 400K, all 12
per-round pairs negative), about -5 us a step; ordinary layers within
+-0.1.
…tonic sort), one barrier

Under TP with a step's picks a lane of one wave (ep == 1, picks <= 64),
load_route builds the table on wave 0: the (expert, pick) keys sorted by a
bitonic network whose partners are DPP and v_permlane*_swap, no LDS and no
barrier, then the slots, U and the pick tiles from ballots. The token
bitmaps' path (load_route_bitmaps) stays for the other steps. Both lay out
the same words.

GPU unit test: 57344 random routes, 0 mismatches against the bitmaps' table.
Natural-MTP gate x2: GSM400 0.94 / 0.945, needles found at 133K and 400K,
tokens per step 3.555 / 3.535.
TP8 profiler (2 rounds, 133K / 400K): ordinary layer -0.27 / -0.22 us,
every layer kind faster, about -12 us a step over the layers.
TP4: ordinary -0.08 / -0.16 us (within noise; no regression).
…tale specs

The router's seam poll (48 CTAs x 512 threads x 7 tagged specs, about 2.2 MB
a pass) re-read every spec on each retry. Mailbox.poll(stale_only=True) keeps
a settled spec's words and drops its load: the offset is moved past the
buffer resource's record count, so the hardware returns zeros without a memory
access. Only the specs still at an old tag go out again. The retry's loads all
issue before the merging selects (sched_barrier), as in-order vmcnt would
otherwise wait for them one at a time. Same words and same tag checks:
bit-exact. Only the router's LIN / LSSQ poll uses it.

Natural-MTP gate x2: GSM400 0.9325 / 0.9375, needles found at 133K and 400K,
tokens per step 3.540 / 3.542.
TP8 profiler, 8 rounds on two nodes (133K / 400K): ordinary layer
-0.15 / -0.04 us, index layers -0.14 .. -0.46, about -7.6 / -3.4 us a step.
TP4: ordinary -0.42 / -0.40 us, about -13 us a step.
…the peer tables (TP8)

Every slice unit's path had one cold round trip in series before its first
data load: the peer-table loads at kernel entry and their waits
(readfirstlane), then the slice's norm weights, mix weights, rows and pend.
At TP8 the layer kernel now issues the seam A slice unit's loads first
(slice_entry_prefetch), on the CTA's own task, so the two round trips
overlap. A CTA without a slice unit loads out of the buffers' range (no
memory access). The loaders keep their earlier statement order on every
path that does not prefetch, so TP4, index-layer and other builds trace as
before (byte-identical layer kernels at TP4 s5/s6/s12). Same words: bit-exact.

Natural-MTP gate x2 on these exact kernels: GSM400 0.9375 / 0.9375, needles
found at 133K and 400K, tokens per step 3.524 / 3.616.
TP8 profiler (4 rounds, 133K / 400K): ordinary layer -0.28 / -0.26 us, all
8 rounds negative; step graph -11.7 / -7.8 us.
TP4: neutral to slightly positive but inconsistent over two runs, so off.
…o KRDY drain or flag (TP8)

The scores' window chunk waited for this step's window rows through KRDY: the
kv_norm CTA stored the row into kvrow, drained its stores (s_waitcnt vmcnt(0),
barrier), put the flag, and the score wave polled the flag, then loaded the
rows (DMA to LDS) in a second round trip. That path ended the score stage in
almost every sample, about 0.5 us behind the q path.

Where window_rows_tagged (TP8, FP8 pool, no indexer / compressor / token
parallel / DSpark block, at most 8 rows), kv_norm puts the row as tagged
pairs instead (KVT, K1's tag, a dual region): a data word a pair, its group's
E8M0 code in the tag's high half (Mailbox.put_coded). No kvrow copy, no
drain, no KRDY. The readers poll the words themselves:
- the score: a one-chunk task's waves 4 .. 7 hold no keys; wave 4 + i polls
  the step rows among wave i's 16 slots (Mailbox.poll_need: a row the slots
  do not hold loads out of range and never holds the batch) into its own LDS
  rows, the codes gathered by DPP, before _q_shared's first barrier. Wave i
  reads a step row's words and codes there. Its DMA and its q step no longer
  wait behind the flag.
- the merge: a step-row slot's 8 columns are one quad of KVT, its code from
  the tag.
Same words and codes as kvrow's planes: bit-exact. Every other build keeps
KRDY and kvrow and traces as before (index / compressor layers, TP4, s12 /
s24, BF16 pools: byte-identical layer kernels).

GPU unit test (kv_norm's pairs vs kvrow's planes; scores and merge with KVT
vs KRDY + kvrow over random requests, window counts and selections):
384 cases each (writer, score, merge), 0 mismatches; the negative control (one row flipped) mismatched
exactly its readers.
Natural-MTP gate x6 on these exact kernels: GSM400 0.945 / 0.925 / 0.925 /
0.94 / 0.935 / 0.9375 (mean 0.935; same-day baseline mean 0.937), needles
found at 133K and 400K every run, tokens per step natural (3.52 .. 3.64).
TP8 profiler (8 rounds on two nodes, 133K / 400K): ordinary layer
-0.38 / -0.49 us, 16 of 16 rounds negative; step graph -12.7 / -22.8 us
and -6.8 / -11.5 us.
@yifehuan yifehuan closed this Nov 27, 2026
@yifehuan
yifehuan deleted the yifehuan/mono_layerkernel branch November 27, 2026 04:28
@yifehuan
yifehuan restored the yifehuan/mono_layerkernel branch November 27, 2026 10:23
@yifehuan yifehuan reopened this Nov 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every eligible PR before approval:

  • ✅ Pre Checkin: Black, Ruff, catalog schema validation, non-GPU unit tests

Heavy model tests:

  • ✅ Gate checks are published on every PR so required checks do not stay missing
  • ✅ Expensive jobs run only after the PR is approved, or when a matching ci:* label is present
  • ✅ Pre Checkin must pass before approved heavy jobs continue
  • ✅ Without a matching label, expensive jobs also require a relevant path
  • ✅ A matching ci:* label is an explicit request and can open the gate even when paths would otherwise skip it

Path scope:

  • Native ATOM uses an ignore list: docs/markdown and plugin or Mesh paths are skipped
  • vLLM and SGLang use include lists: their own plugin code under atom/plugin/, plugin CI scripts, model list and release images. A core-only change does not run them; add ci:vllm / ci:sglang to ask for them
  • ATOMesh uses an include list: Mesh code, the ATOMesh accuracy workflow and its 1P1D launcher, plus the shared models_accuracy.json and accuracy_to_dashboard.py. ATOMesh benchmarks run after merge or on dispatch, not on PRs
  • Relevant path alone does not start expensive jobs; approval still opens the automatic path-scoped gate
Label Tests
ci:full Run all heavy PR model tests: native ATOM, vLLM, SGLang, and ATOMesh
ci:atom Run native ATOM model accuracy tests
ci:vllm Run ATOM vLLM OOT model accuracy tests
ci:sglang Run ATOM SGLang model accuracy tests
ci:mesh Run the ATOMesh accuracy tests, standalone and 1P1D, for Mesh-related changes

Without a matching ci:* label, heavy jobs are skipped when the path is not relevant or the PR is not approved.
Add labels via the sidebar or gh pr edit 3813 --add-label <label>

…files back to main

This branch changed files every mono model shares: atom/mono/device/sync.py
(region addresses computed at each use, for every model's kernels, and the
mailbox waits only V4.1 calls), device/ops.py and device/select.py
(helpers only V4.1 calls), and dsa_indexer/select.py (a fresh=False the
sync change required). It also carried PD / Mooncake fixes (atom/config.py,
the Mooncake connector and its rail engine pool, their tests) and an update
of the mailbox copy reproducer tool, none of it monokernel work.

All of those files are main's again. What the V4.1 kernels need from them
moved, verbatim, under atom/models/deepseek_v41/mono/kernels/:

- mailbox.py: FreshAddr, a region address whose value is computed at each
  use from a fresh_s64 base (fresh=False for a lane-varying base); its
  sreg / dreg / preg; region_addrs, device.numa's over FreshAddr regions;
  fresh_s64 / fresh_s32; and Mailbox, sync.Mailbox with put_coded,
  poll_coded, poll_need and poll's between / stale_only
- code_warm.py: code_tail and warm_code, a layer's code read into L2
- lds_rows.py: rows_to_lds_together
- wave_max.py: wave_max_key

Every V4.1 kernel imports them from there; the unchanged sync names it
uses (POLL_MAX, Quad, publish) still come from sync. The other models'
kernels, the DSA indexer and the shared LM head that V4.1's head_launch
binds build from main's sync again.
Drop four unused noqa directives (E731 is not enabled: RUF100) in
attn_pre.py and layer.py, and black 26.10.1's one-line form of the route
word select in moe.py.
@yifehuan
yifehuan marked this pull request as ready for review November 27, 2026 12:15

@valar-cop valar-cop left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some changes needed..

tp8 decode ms/step before/after at the shape these fire (s<=8 for kvt/route, s<=12 for slice_x8)? and which run covers slice_x8 no-rstd numerically?

ci green.

if key.slice_x8:
# an ordinary sharded layer's slices put wqkv_a's x8 into every rank's
# X8G (``attn_pre.slice_direct_pair``); the norm stage does not run
regions += [RegionDecl("x8g", P, "k1.slice")]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

none of the new variants is traced.. slice_x8, x8g, slice_entry_prefetch, the fused LayerBuild (window_rows_tagged/kvt/code_warm) and load_route_wave never compile in tests. add them to the build list or name the run that covers them?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants