[Refactor][Model Loader] Unify the weight loading lifecycle - #48908
Closed
aoshen02 wants to merge 7 commits into
Closed
[Refactor][Model Loader] Unify the weight loading lifecycle#48908aoshen02 wants to merge 7 commits into
aoshen02 wants to merge 7 commits into
Conversation
Contributor
|
Documentation preview: https://vllm--48908.org.readthedocs.build/en/48908/ |
Contributor
|
This pull request has merge conflicts that must be resolved before it can be |
Unify initial loading and checkpoint reload post-processing behind a lightweight WeightLoadSession, and let checkpoint-format weight transfer engines share the same lifecycle. Related: #48312 Co-authored-by: OpenAI Codex <codex@openai.com> Signed-off-by: aoshen02 <aoshen@inferact.ai>
Preserve legacy post-load hooks, make interrupted checkpoint reloads safely retryable, and cover V2 weight transfer, online quantization, CPU offload, and CUDA Graph replay. Co-authored-by: OpenAI Codex <codex@openai.com> Signed-off-by: aoshen02 <aoshen@inferact.ai>
Use operation-scoped strong references, let the session finalize initial-load modules directly, and make LayerReloadingInfo.reset clear all transient state. This removes compatibility indirection and duplicate cleanup while preserving the public layerwise reload entry points. Co-authored-by: OpenAI Codex <codex@openai.com> Signed-off-by: aoshen02 <aoshen@inferact.ai>
Signed-off-by: aoshen02 <aoshen@inferact.ai>
Signed-off-by: aoshen02 <aoshen@inferact.ai>
Signed-off-by: aoshen02 <aoshen@inferact.ai>
Signed-off-by: aoshen02 <aoshen@inferact.ai>
aoshen02
force-pushed
the
codex/weight-lifecycle-plan-c
branch
from
July 18, 2026 01:34
20f3b06 to
71a5d8b
Compare
Contributor
|
This pull request has merge conflicts that must be resolved before it can be |
This was referenced Jul 19, 2026
Collaborator
Author
|
The original PR cannot be reopened because its head repository was detached from the fork network after the visibility transition. The conflict-resolved continuation is now open as #49201, based on |
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.
Implements the lifecycle design proposed in #48920.
Related correctness taxonomy: #48312. Complementary storage-identity work: #48478 and #48902.
Problem
Initial model loading and checkpoint-format reload had the same three post-load requirements, but different callers assembled them independently:
That made a new loader or transfer path easy to get subtly wrong.
Design
flowchart LR I["Initial loader"] --> P["WeightLoadSession.prepare"] R["V2 checkpoint reload"] --> P T["TorchAO reload"] --> P W["Checkpoint IPC / NCCL"] --> P P --> L["Existing load / transfer implementation"] L --> F["WeightLoadSession.finish"] F --> LW["layerwise: materialize + process + copy back"] F --> D["utils: discover post-load module types"] D --> Q["Quant"] Q --> A["Attention / MLA / MM encoder"] A --> H["HPC-derived state"]The boundary is deliberately small:
The responsibilities are separated instead of putting all policy in the session:
WeightLoadSession.__init__prepare()finish()abort()process_quant()QuantizeMethodBasehook at most once in this loadfinalize_attention_runtime()_process_quant_method()utils._process_modules_after_loading()layerwise._finish_layerwise_loading()Attention,MLAAttention, andMMEncoderAttentionnow share one internal type tuple used by both the model-wide traversal and layerwise deferral. Adding another post-load attention wrapper requires changing one classification point, not the session.This PR does not replace
BaseModelLoader.load_weights,model.load_weights, IPC, or NCCL. They still own the source and transport of weights. It also adds no registry, generic object walk, runtime retry, or synchronization protocol.Failure semantics
abort()restores temporary Python/module structure only. It cannot restore tensor values already written, does not retry the update, and does not make a partially updated model safe for inference. The original exception is re-raised.The caller must already pause/drain inference during an update.
Simplification in the final revision
load_session.py: 172 lines -> 150 linesprocess_all_modules()and_process_hpc()from the sessionprocess_weights_after_loading()wrapper that constructed an unprepared sessionisinstancepolicy from the sessionfinalize_layerwise_reloadaliasScope relative to #48312
This is lifecycle infrastructure, not the complete correctness checker:
Validation
Final commit:
20f3b063ff.77 passed, 21 deselected9 passed1 passedgit diff --check: passedThe final VIME E2E used Qwen2.5-0.5B-Instruct on
h200-1: four trainer GPUs, four V2 vLLM engines, IPC weight transfer, FULL + PIECEWISE CUDA Graph capture, and two train/update/replay iterations.train_rollout_logprob_abs_diffThe log confirms
Using V2 Model Runner,IPCWeightTransferEngine, both CUDA Graph capture modes, successfulstart_weight_update -> update_weights -> finish_weight_update, and replay after each update. It ended withWEIGHT_LIFECYCLE_E2E_PASS variant=c.AI assistance
AI assistance was used to research, implement, test, and draft this change. I reviewed the resulting diff and validation evidence and can explain and maintain the implementation.