vllm.models.kimi_k3.amd.specialized_decode.mono.common.sync
¶
The tagged mailbox: hand-offs between the CTAs of one GPU (device scope) and
between GPUs (system scope), every address a named region (Addr) recorded
when the kernel is traced (trace).
Classes:
-
Addr–A mailbox region's address: the region's name and space, recorded when the
-
Mailbox–Tagged-pair hand-off between CTAs (device scope) and GPUs (system scope).
Functions:
-
preg–Peer-symmetric region
regionat byteoffsetof a rank's buffer -
publish–This CTA's plain stores made readable by every CTA, then (thread
who) -
shift–amoved bydeltabytes (a traced or Python integer), same region. -
sreg–Scratch region
regionat byteoffsetofbase. -
stall–The fault hook (tests only): CTA 0 of rank
fault_rankstallsticks
Addr
dataclass
¶
A mailbox region's address: the region's name and space, recorded when the
kernel is traced (trace), and the traced address. The space also
sets the hand-off's scope: device for SCRATCH, system for PEER.
Source code in vllm/models/kimi_k3/amd/specialized_decode/mono/common/sync.py
Mailbox
¶
Tagged-pair hand-off between CTAs (device scope) and GPUs (system scope).
Every 32-bit value is stored next to this launch's tag; a consumer
polls the payload until all tags match, so a hand-off costs one round trip
(no store drain, no separate flag). The tag is layer + 1: it tells the
layers of one step apart, and the runner zeroes every mailbox at a step's
start (StepMailboxes.begin_step), so a pair from an earlier step never
carries a live tag. Every address is an Addr: its space picks the scope.
Methods:
-
__init__–health: this rank's health words (FAILED, then a wait record a -
poll–Batched poll of pairs
specs= [(Addr, pair index, npairs in {1, 2})], -
put_bf–Elements i .. i+len(vs) (2 or 4, i aligned) as packed bf16 pairs, one
-
put_words–Raw 32-bit words (1 or 2) at pairs i.. as (word, tag). Integer payloads
Source code in vllm/models/kimi_k3/amd/specialized_decode/mono/common/sync.py
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 | |
__init__(layer, health, alarm, region_ids)
¶
health: this rank's health words (FAILED, then a wait record a
CTA); alarm: this rank's flag word on the output rank;
region_ids: region name -> the id a record names it by.
Source code in vllm/models/kimi_k3/amd/specialized_decode/mono/common/sync.py
poll(specs, batch=POLL_MAX)
¶
Batched poll of pairs specs = [(Addr, pair index, npairs in {1, 2})],
all of one space.
All pairs are re-loaded together while any tag is stale, so a batch costs one round trip after its last producer lands. Returns the value words.
Source code in vllm/models/kimi_k3/amd/specialized_decode/mono/common/sync.py
put_bf(a, i, vs)
¶
Elements i .. i+len(vs) (2 or 4, i aligned) as packed bf16 pairs, one store.
Source code in vllm/models/kimi_k3/amd/specialized_decode/mono/common/sync.py
put_words(a, i, words)
¶
Raw 32-bit words (1 or 2) at pairs i.. as (word, tag). Integer payloads (fp8 words) must come this way: through an f32 value a NaN bit pattern is not kept.
Source code in vllm/models/kimi_k3/amd/specialized_decode/mono/common/sync.py
_spin(load_all, pending, health, alarm, region_id, index, tag)
¶
Re-issue load_all until pending clears, for at most WAIT_TICKS, and
not at all once this rank has failed (health word FAILED), so a failed
step runs to its end instead of hanging. A side-effecting op in the loop keeps
the loads from being hoisted.
A CTA's first give-up is recorded in its health record; it then raises the
output rank's flag for this rank (alarm) and drains that store before it
sets FAILED, so no later store of this rank's can overtake the flag.
Source code in vllm/models/kimi_k3/amd/specialized_decode/mono/common/sync.py
preg(base, offset, region)
¶
Peer-symmetric region region at byte offset of a rank's buffer
base.
publish(put, a, i, v, who)
¶
This CTA's plain stores made readable by every CTA, then (thread who)
the mailbox pair (a, i) := v. The stores are drained first: a flag may
not overtake the data it announces, and a workgroup-scope release fence does
not wait for them (LLVM's AMDGPU memory model omits vmcnt outside tgsplit
mode: the workgroup's waves share one CU, the readers here do not).
Source code in vllm/models/kimi_k3/amd/specialized_decode/mono/common/sync.py
shift(a, delta)
¶
a moved by delta bytes (a traced or Python integer), same region.
sreg(base, offset, region)
¶
stall(fault_rank, fault_epoch, fault_layer, ticks, rank, epoch, layer)
¶
The fault hook (tests only): CTA 0 of rank fault_rank stalls ticks
once, in the launch for slot fault_layer of the step at epoch
fault_epoch.