Conversation
Weight tying (e.g. lm_head.weight is embed_tokens.weight, Qwen3-4B) made two targets reference the same live parameter with independent pinned mirrors and onload/offload state machines: one target's CPU rebind poisoned the other's GPU residency bookkeeping, and async prefetch exposed half-copied tensors to the other's forward (torn vocab embedding reads -> wrong conditioning; with prefetch_limit it crashed on device mismatch instead). Shared states are now owned by their first target: duplicates are dropped from later targets (tie_deduped, bookkeeping-only transport), owners are forced persistent so the shared tensor stays resident for the handle lifetime, and prefetch_residency_bytes is recomputed after the drop. Trade-offs: tied tensors stay GPU-resident (bypassing persistent_buckets, Qwen3-4B fp16 embedding ~778MB), and attaching a GPU-resident model briefly allocates the duplicate pinned mirror before dedupe frees it. Non-CPU-mirror offload devices are out of scope. Verified: tied toy LM (Embedding + blocks + norm + tied lm_head) is bitwise-equal to the GPU-resident baseline across sync / async / async+prefetch_limit, with owner-forced-persistent and tie_deduped structure asserts; real klein_fit TE outputs are bitwise-stable across offload variants; all 37 layerwise offload tests pass. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
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.
Weight tying (e.g. lm_head.weight is embed_tokens.weight, Qwen3-4B) made two targets reference the same live parameter with independent pinned mirrors and onload/offload state machines: one target's CPU rebind poisoned the other's GPU residency bookkeeping, and async prefetch exposed half-copied tensors to the other's forward (torn vocab embedding reads -> wrong conditioning; with prefetch_limit it crashed on device mismatch instead).
Shared states are now owned by their first target: duplicates are dropped from later targets (tie_deduped, bookkeeping-only transport), owners are forced persistent so the shared tensor stays resident for the handle lifetime, and prefetch_residency_bytes is recomputed after the drop.
Trade-offs: tied tensors stay GPU-resident (bypassing persistent_buckets, Qwen3-4B fp16 embedding ~778MB), and attaching a GPU-resident model briefly allocates the duplicate pinned mirror before dedupe frees it. Non-CPU-mirror offload devices are out of scope.
Verified: tied toy LM (Embedding + blocks + norm + tied lm_head) is bitwise-equal to the GPU-resident baseline across sync / async / async+prefetch_limit, with owner-forced-persistent and tie_deduped structure asserts; real klein_fit TE outputs are bitwise-stable across offload variants; all 37 layerwise offload tests pass.