Repository navigation
Conversation
An in-place weight update (the rollout sync, a weight-cache daemon's load) rewrites the parameters at their addresses. V4.1 mono read copies made at bind time that nothing refreshed, so every runner that takes updates was refused. Now every weight pointer a V4.1 gfx950 mono launch reads is either in place or a registered derived buffer rebuilt in place after an update; a bind-time audit refuses anything else. Copies removed (the kernel reads the parameter in place, same arithmetic): - LK compressor: compressor.norm / indexer.k_norm as bf16 (bf16 -> f32 exact). - LK draft context: each stage's own wkv rows of wqkv_a (3 pointers; the preshuffle permutes within 16-row groups) instead of _context_kv_fused. - LK Engram gate: q_weight * k_weight in the kernel (exact in f32) instead of EngramOp.gate_weight. - hi compressor: norm / k_norm in place; comp.aux keeps only pack_wk(wk). - hi draft context: the draft stages' own wkv packs, not 3 duplicates. - hi block draft: the noise row from its owner rank's vocab shard (PeerEmbedding), not DSpark's cached _noise_row. - hi eng.gw: its own q*k product (registered) instead of aliasing gate_weight. Derived weights (atom/models/deepseek_v41/mono/weight_refresh.py): hi registers every buffer it packs and rebuilds it by re-running the install's packing into the bound tensors; only entries whose sources changed rebuild, and a rebuild that moves an address raises. The audit covers every LK launch's weights and every hi pointer-table weight set; strict (refusing at bind, agreed over TP) under a runner that takes updates. Wiring: V4.1's config_refusal drops the shared rollout refusal (gfx1250 and other models keep it) and still refuses a weight-updating runner without sleep_keeps_memory_resident. MonoDecodeModel answers the update path's model hooks (weight_sync_target, weight_update_refusal, after_weight_update), which weight_updater calls before a sync's first write and at its last bucket (all paths), behind the readers' fence. Verified on MI355X TP8 (hi: bf16 KV + DSpark; LK: fp8 KV), A -> B -> A on a live engine (update_weights over SHM + an in-place wo_b write with rebuild_after_weight_update), B = A with layer 2 / head perturbed: - sha256 of every derived buffer and perturbed parameter, all ranks: hot A->B == fresh B on 5064/5064 buffers and 64/64 params; B->A == A0 likewise; LK has no derived buffers, params equal. - negative control (rebuild skipped): 48 buffer digests differ, exactly the touched entries (hi head, hi layer 2). - class-A value identity on the live model: all checks true on all ranks. - addresses and graphs unchanged: 633 derived pointers, 1517 parameter pointers, 336 hi pointer tables, decode/draft graph objects. - rebuild per update: hi 15-43 ms (rollout), 13-14 ms (daemon path); LK 1-3 ms. - no TPOT change (forced acceptance).
Contributor
🏷️ CI GuideRuns automatically on every eligible PR before approval:
Heavy model tests:
Path scope:
|
This branch has not been deployed
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.
Why
An in-place weight update (the rollout sync
update_weights*, later a weight-cache daemon'sload) rewrites themodel's parameters at their own addresses, so captured graphs stay valid. DeepSeek-V4.1's mono decode read copies made
at bind time that nothing refreshed: after an update it would keep serving the old weights, and no shape or dtype check
could notice. That is why
atom/mono/runtime/deployment.pyrefuses every runner that takes updates.This PR makes every weight pointer a V4.1 gfx950 mono launch reads either in place (inside a parameter's storage)
or a registered derived buffer that is rebuilt in place after an update. A bind-time audit refuses anything
else. The refusal is lifted for V4.1 gfx950 only.
Scope: DeepSeek-V4.1, gfx950, mono only: the layer-kernel (LK) path and the hi monokernel path. Everything V4.1-specific
lives in
atom/models/deepseek_v41/mono/. The only shared change is a small model hook in the rollout updater.What changed
Copies removed; the kernel reads the parameter in place, with unchanged arithmetic:
compressor.norm/indexer.k_norm_context_kv_fusedwkvrows ofwqkv_a(3 pointers; the 16x16 preshuffle permutes within 16-row groups, so the rows are one contiguous run)EngramOp.gate_weight(derived at load)q_weight * k_weightmultiplied in the kernel (exact in f32)comp.aux= cat(norm, pack_wk(wk), k_norm)comp.norm/comp.knormread in place;comp.auxkeeps only the re-laid-outwkwkvpackswkvpacks_noise_rowPeerEmbedding)eng.gwEngramOp.gate_weightq * kproduct (registered, rebuilt)Derived weights:
atom/models/deepseek_v41/mono/weight_refresh.pyDerivedWeights.register(name, sources, dests, rebuild):rebuild()re-derivesdestsfromsourcesinto the samestorage. A rebuild that moves an address raises. Only entries whose sources were rewritten are rebuilt.
tensors. That covers the layers' MXFP8 linears, the shared expert, indexer
wq_b,comp.aux,eng.gw, the Engramwkvcolumn shards, the head, the draft stages and the draft context'smain_proj. LK registers nothing: it readsevery weight in place.
audit: every weight pointer must lie in a parameter's storage or a registered destination, and every entry's sourcesin a parameter's storage. This covers each LK runner's launches (layers, compressor, LM head, Engram, draft context,
draft head) and every hi pointer-table weight set. Under a runner that takes weight updates the audit is strict: a
failing path is refused at bind, agreed over the TP group.
rebuild_after_weight_update(model, changed)/weight_update_refusal(model)are the entry points for aweight-cache daemon's
loadlater.Wiring
config.config_refusaldrops the shared "rollout weight updates" refusal, which V4.1 now answers at bind. gfx1250 andevery other model keep it. V4.1 still refuses a weight-updating runner unless
Config.sleep_keeps_memory_residentisset, because a sleep would move the weights and the KV pool that mono binds.
MonoDecodeModelanswers the update path's model hooks:weight_sync_target(the parameters keep the model's ownnames),
weight_update_refusal()andafter_weight_update(changed).atom/rollout/weight_updater.pycalls those hooks, if a model defines them: the refusal before a sync's first write,and
after_weight_updateat the sync's last bucket (after the expert relayout, behind the readers' fence). This runson every path: direct, SHM, IPC and RDMA.
weight_sync_record.pygainstouched().Verification (MI355X, TP8)
The GPU runs below used this change on origin/main 215b924. Since then I moved the registry into the V4.1 package and
replaced the rollout integration with the model hooks; that changes no kernel, packing or rebuild code. The branch is
rebased on current main.
Checkpoint B is checkpoint A (
DeepSeek-V4.1-Flash) with a deterministic perturbation of layer 2 and the LM head:wq_a,wkv, indexerwq_bandwo_b;compressor.norm,k_normandattn_norm;wk, and scaled rows ofhead.Updates go A -> B -> A on a live engine (RLHF runner, CUDA graphs captured). Seven tensors go through
update_weightsover SHM. The TP-sharded FP8
wo_bis written in place followed byrebuild_after_weight_update, as a daemonloadwould do it. Configs: hi (bf16 KV, fp4 index, DSpark 5 drafts) and LK (fp8 KV).
Bit-exact rebuild. I compared sha256 digests of every derived buffer and of every perturbed parameter on all 8
ranks:
Greedy outputs cannot serve as this check: the engine is not run-to-run deterministic at this configuration (two
identical runs on origin/main already differ in a few tokens), so the comparison is made on the bytes the kernels read.
Negative control. The same A->B update with the rebuild skipped leaves 48 buffer digests (6 a rank) unequal to
fresh B, all of them in exactly the touched entries (
hi head,hi layer 2).Class A, value identity on the live model (all ranks):
q*k == gate_weight;eng.gw == gate_weight;[comp.norm, comp.aux, comp.knorm]equals the oldaux, and the norms are theparameters;
wkvis the stage packs and equals a fresh context pack;_noise_row;Addresses and graphs are stable across A->B, B->A and the skipped A->B: unchanged are every derived-buffer
pointer (633 a rank), every parameter pointer (1517), all 336 hi pointer tables (address and contents) and the
captured decode and draft graph objects. Nothing was recaptured.
Audit: hi passes strict on every rank: 1402 weight pointers, 762 in place and 640 in 47 derived entries. LK passes
for both the target and draft runners.
Rebuild time per update (per rank, min-max): hi rollout 15-18 ms (A->B) and 38-43 ms (B->A), hi daemon path
13-14 ms; LK 1-3 ms (nothing to rebuild).
No TPOT change (forced acceptance).
CPU tests:
tests/test_deepseek_v41_mono_weight_refresh.py: the registry, the audit (a positive case and anunregistered-pointer case), the refusals, and the rollout hooks;
tests/test_deepseek_v41_mono_weight_update.py: LK/hi binding on stand-ins; its layer-kernel cases need the GPUstack.
The mono, V4.1 and rollout suites fail the same tests as origin/main does.
Out of scope / notes
mono/gfx1250/) keeps the refusal._context_kv_fused,_draft_kv_tail,_noise_row,hc_*_fn_packedandEngramOp.gate_weight. Mono no longer reads any of them.loadis not part of this PR. It would callweight_update_refusalbefore writing andafter_weight_update(orrebuild_after_weight_update) after.reload_policy._unreloadable_paramsrefuses V4.1-Flash's MXFP4 experts and per_1x32 FP8 for full-precisionwrites. The test runner overrode only that check and sent tensors in their native dtype.
MemoryManagerMixin.clear_kv_cacheassumes a runner-levelkv_cachepool, which a V4.1 runner does not have.