Skip to content

[Refactor] Move weight completeness verification into the loader - #29323

Closed
EazyReal wants to merge 1 commit into
sgl-project:mainfrom
EazyReal:vmax/weight-loading-loader-side
Closed

EazyReal wants to merge 1 commit into
sgl-project:mainfrom
EazyReal:vmax/weight-loading-loader-side

Conversation

@EazyReal

@EazyReal EazyReal commented Jun 25, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

load_weights(weights) is reused as a tensor-copy primitive by startup loading, online/RL refits, and filtered Elastic-EP recovery. Model-local whole-checkpoint checks therefore fire in contexts that intentionally load only a subset.

The underlying contract is still needed on current main: RFC #28585 remains open, and the Weight Loader v2 tracker #31051 still lists the completeness result and verification contract as unfinished. This PR supplies that boundary without coupling it to one tensor-source implementation.

Changes

  • Add opt-in loader-side verification of required model parameters after a full-checkpoint load.
  • Let migrated models declare legitimate omissions with is_optional_weight(name).
  • Make full-checkpoint context explicit at the loader boundary.
  • Skip model-wide verification for filtered Elastic-EP refills and all FLASH_RL refits, including alternate disk transport formats.
  • Preserve model-local atomic checks for fused checkpoint shards.
  • Migrate Gemma4, DeepSeek-V4 / NextN / OCR, and Llama4 to return loaded parameter names and remove their model-wide diagnostics.
  • Cover the default, quantized RL initial-load, BitsAndBytes, GGUF, remote filesystem, and CPU-quantization loader paths.

The verifier intentionally checks parameters, not buffers. Persistent and derived buffer initialization remains model-owned.

Review context

Verification

  • Hosted lint passes on head 62d7418510: https://github.com/sgl-project/sglang/actions/runs/30517415886
  • All repository pre-commit hooks pass on the touched files.
  • git diff --check passes.
  • python3 -m py_compile passes on every touched Python file.
  • The isolated completeness helper contract passes.
  • A fresh-context independent review passes with no unresolved findings.
  • test/registered/unit/model_loader/test_load_and_verify_weights.py is registered for CPU CI. The full unit test could not run in this checkout because its Python environment does not include the project dependencies; hosted test matrices require the maintainer-controlled run-ci label.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@EazyReal

Copy link
Copy Markdown
Contributor Author

@kpham-sgl @pyc96 @b8zhong Could I get a quick review and run-ci on this loader/verifier split? It keeps load_weights as the tensor-copy primitive and moves completeness checks to full-checkpoint loading.

@EazyReal

EazyReal commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

@b8zhong could you take a look at this loader-side weight completeness refactor if you have bandwidth? It moves full-checkpoint checks out of load_weights, which should keep partial updates safe; a run-ci label would also help if it looks reasonable.

@EazyReal
EazyReal force-pushed the vmax/weight-loading-loader-side branch from fe3aeed to 06e7e7d Compare July 7, 2026 18:10
@EazyReal

EazyReal commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor Author

@b8zhong @JD-ETH just rebased this. The Weight Loader v2 plan still has “Completeness result and verification contract” open; this PR makes that full-checkpoint decision loader-owned while preserving load_weights for partial FLASH_RL and Elastic-EP updates.

EazyReal added a commit to EazyReal/sglang that referenced this pull request Aug 12, 2026
Route built-in partial update paths, including checkpoint-engine IPC, through an explicit load context while preserving full-checkpoint diagnostics by default. Keep DeepSeek-V4 fused-shard atomicity assertions active for every load.

Includes the Gemma4 scope from sgl-project#28519. This remains an interim fix pending the loader-owned completeness contract in sgl-project#28585 and sgl-project#29323.
@EazyReal EazyReal closed this Sep 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant