fix: retain colocated LoRA CUDA-IPC exporter storage - #2707
Open
zhoutong-hai wants to merge 1 commit into
Open
Conversation
Keep exported adapter storage alive across colocated publications and refresh it in place after an acknowledged unload. This avoids reclaiming CUDA-IPC handles while SGLang may still reference them and adds lifecycle/layout regression coverage.
zhoutong-hai
requested review from
Shi-Dong,
Zhichenzzz,
fzyzcjy,
maocheng23,
yueming-yuan and
yushengsu-thu
as code owners
August 21, 2026 23:46
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.
Summary
Fix the colocated LoRA CUDA-IPC exporter lifetime in
UpdateWeightFromTensor.The current full-adapter path releases its exporter tensors and calls
torch.cuda.ipc_collect()immediately after the SGLang load acknowledgement.The consumer can still be releasing imported handles at that point, so later
allocator reuse can race stale CUDA-IPC handles.
This change:
lifetime;
source-side failure to the gather group, then barriers and synchronizes CUDA
before reuse;
--offload-trainor PP > 1, where restored/assembled adapter tensors areotherwise temporary;
refresh;
ipc_collect()/empty_cache()reclamation from this path.Relation to #1923
This is the same lifecycle invariant and failure family reported in #1923:
keep one exporter allocation stable instead of rotating and reclaiming
CUDA-IPC handles mid-run.
The integration is different enough that this is a current-
mainimplementation rather than a cherry-pick. #1923 targets the older
kimi-k3chunked transport with a module-global 512 MiB flat transfer bufferand a per-chunk acknowledgement. Current
mainsends one full named-tensoradapter after PP assembly. This PR therefore retains an exact-layout payload
on each updater and adds explicit unload/error-broadcast/group-barrier
ordering around refresh.
Validation
Focused CPU coverage:
14 passed, 19 deselected; Ruff, Black,py_compile, andgit diff --checkpass.GPU validation used current
mainat778227d6d7cf7b581d1eb07910c873516b6baca9on 4 nodes / 32 H200s:full-adapter publications (two reuse cycles);
publications (two reuse cycles).
Both Ray submissions and both Sky jobs succeeded. All trainer-rank
publications returned successfully. Post-run checks found zero GPU processes,
zero pod restarts, zero cgroup OOM events, and no CUDA-IPC error, Xid, OOM,
NCCL failure, or actor restart.
Follow-up all-linear LoRA parity resolution
This PR only fixes publication/storage lifetime. It does not address
trainer/rollout numerical parity.
The subsequent GLM-5.2 investigation found two independent correctness
problems outside this PR:
sgl-kernelindexer top-k; deterministic FlashInfer top-k with stabletie-breaking made the exact scorer batch repeatable; and
gradient directly into
param.main_grad, bypassing the existing Parameterhook and allowing replicated LoRA factors to diverge after the second update.
That Miles defect is addressed by
PR #2723.
With deterministic top-k and the optimizer-boundary shared-factor collective,
the complete attention/MLA, dense-MLP, routed-expert gate/up, and routed-expert
down LoRA scope passed an eight-update sustained canary with every publication
returning successfully. The original expert-
down_projhypothesis andincomplete-mask status are therefore superseded.
PR #2707 remains intentionally scoped to the colocated CUDA-IPC exporter
lifetime; PR #2723 carries the later Miles gradient-synchronization fix.