Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
c93c103
[Feature] Implement update_weights_from_disk for SGLang-D (Diffusion …
dreamyang-liu Feb 5, 2026
7703c69
[diffusion] refactor: extract WeightsUpdater for update_weights_from_…
dreamyang-liu Feb 6, 2026
886a6bc
chore: isort lint
dreamyang-liu Feb 6, 2026
3d19d61
[diffusion] offload-aware weight updates and cleanup
dreamyang-liu Feb 7, 2026
d0e2fec
[diffusion] refactor: move post-training API to dedicated package and…
dreamyang-liu Feb 8, 2026
07cc679
[diffusion] refactor: extract get_updatable_modules and harden Weight…
dreamyang-liu Feb 10, 2026
c442af2
[diffusion] address comments
dreamyang-liu Feb 11, 2026
881d8b3
adds doc string to diffusion rifit test
zhaochenyang20 Feb 11, 2026
dfc93f6
[diffusion] Add /get_weights_checksum endpoint for SHA-256 weight ver…
dreamyang-liu Feb 12, 2026
68902f3
[diffusion] Add corrupted-weight rollback test for update_weights_fro…
dreamyang-liu Feb 12, 2026
719d31f
[diffusion] Parametrize weight-update tests over FLUX and Qwen model …
dreamyang-liu Feb 13, 2026
81d585b
[diffusion] Optimize weight-update tests
dreamyang-liu Feb 13, 2026
85b646c
Merge branch 'feat/diffusion-update-weights-from-disk' of github.com:…
zhaochenyang20 Feb 14, 2026
32a743b
[TODO] model weights is updated only once
zhaochenyang20 Feb 14, 2026
c35eecd
Deduplicated tests; Should clean up
zhaochenyang20 Feb 14, 2026
41148c4
clean up codes with mixin; currently spanning 16mins; too long; shoul…
zhaochenyang20 Feb 14, 2026
14e69ec
Update docstring for GetWeightsChecksumReqInput
zhaochenyang20 Feb 14, 2026
b64b185
Refine docstring for weight checksum verification
zhaochenyang20 Feb 14, 2026
d68da5c
Simplify comments in layerwise offload method
zhaochenyang20 Feb 14, 2026
d3728cb
Improve documentation for iter_materialized_weights
zhaochenyang20 Feb 14, 2026
f831d94
fix lint
zhaochenyang20 Feb 15, 2026
bd23519
Refactor update_weights_from_disk tests
dreamyang-liu Feb 15, 2026
22b32c4
Merge branch 'main' into feat/diffusion-update-weights-from-disk
zhaochenyang20 Feb 16, 2026
a9f6808
Merge branch 'feat/diffusion-update-weights-from-disk' of github.com:…
zhaochenyang20 Feb 16, 2026
a32aed9
Merge branch 'main' into feat/diffusion-update-weights-from-disk
zhaochenyang20 Feb 16, 2026
66e3c17
Merge branch 'feat/diffusion-update-weights-from-disk' of github.com:…
zhaochenyang20 Feb 16, 2026
52ba35b
new docs string
zhaochenyang20 Feb 16, 2026
c3d478e
remove one line function
zhaochenyang20 Feb 16, 2026
cde71fe
consolidate rollback tests
zhaochenyang20 Feb 16, 2026
40bba8d
finalize the test
zhaochenyang20 Feb 16, 2026
7467682
fix CI random choice
zhaochenyang20 Feb 16, 2026
3100b2f
fix paring issue
zhaochenyang20 Feb 16, 2026
fb87570
incline path finding
zhaochenyang20 Feb 17, 2026
fab939e
remove redundant comments
zhaochenyang20 Feb 17, 2026
9e030f0
Merge branch 'main' into feat/diffusion-update-weights-from-disk
zhaochenyang20 Feb 18, 2026
2b44290
Merge branch 'feat/diffusion-update-weights-from-disk' of github.com:…
zhaochenyang20 Feb 18, 2026
f60f638
fix isort
zhaochenyang20 Feb 18, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
incline path finding
  • Loading branch information
zhaochenyang20 committed Feb 17, 2026
commit fb87570021df92b6b176caecc4d24bdc9251118d
13 changes: 0 additions & 13 deletions python/sglang/multimodal_gen/runtime/loader/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import re
from collections import defaultdict
from collections.abc import Callable, Iterator
from pathlib import Path
from typing import Any, Dict, Type

import torch
Expand Down Expand Up @@ -149,18 +148,6 @@ def _list_safetensors_files(model_path: str) -> list[str]:
return sorted(glob.glob(os.path.join(str(model_path), "*.safetensors")))


def find_weights_dir(local_path: str, module_name: str) -> Path | None:
"""Locate the safetensors directory for module_name under local_path.

Diffusion models store weights in per-module subdirectories (e.g.
transformer/, vae/, text_encoder/).
"""
dir_path = Path(local_path) / module_name
if dir_path.exists():
return dir_path
return None


def get_memory_usage_of_component(module) -> float | None:
"""
returned value is in GB, rounded to 2 decimal digits
Expand Down
14 changes: 7 additions & 7 deletions python/sglang/multimodal_gen/runtime/loader/weights_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@
from __future__ import annotations

import gc
from pathlib import Path

import torch
from torch.distributed.tensor import DTensor, distribute_tensor

from sglang.multimodal_gen.runtime.cache.teacache import TeaCacheMixin
from sglang.multimodal_gen.runtime.loader.utils import (
_list_safetensors_files,
find_weights_dir,
)
from sglang.multimodal_gen.runtime.loader.weight_utils import (
safetensors_weights_iterator,
Expand Down Expand Up @@ -108,9 +108,9 @@ def _validate_weight_files(
weights_map: dict[str, str] = {}
missing: list[str] = []
for module_name, _ in modules_to_update:
weights_dir = find_weights_dir(local_model_path, module_name)
if weights_dir and _list_safetensors_files(weights_dir):
weights_map[module_name] = weights_dir
weights_dir = Path(local_model_path) / module_name
if weights_dir.exists() and _list_safetensors_files(str(weights_dir)):
weights_map[module_name] = str(weights_dir)
else:
missing.append(module_name)
return weights_map, missing
Expand Down Expand Up @@ -306,8 +306,8 @@ def _rollback(self, updated_modules: list[str]) -> None:
module = self.pipeline.get_module(name)
if module is None:
continue
weights_dir = find_weights_dir(original_path, name)
if weights_dir is None:
weights_dir = Path(original_path) / name
if not weights_dir.exists():
continue
weights_iter = _get_weights_iter(weights_dir)
weights_iter = _get_weights_iter(str(weights_dir))
_load_weights_into_module(module, weights_iter)
Comment on lines +276 to +293
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I said, I think we should have other methods to _rollback.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you clarify what you mean by "other methods to _rollback"?

Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@

from sglang.multimodal_gen.runtime.loader.utils import (
_list_safetensors_files,
find_weights_dir,
)
from sglang.multimodal_gen.runtime.loader.weight_utils import (
compute_weights_checksum,
Expand Down Expand Up @@ -223,8 +222,10 @@ def _compute_checksum_from_disk(model_path: str, module_name: str) -> str:
same disk checksum is requested multiple times across tests.
"""
local_path = maybe_download_model(model_path)
weights_dir = find_weights_dir(local_path, module_name)
assert weights_dir is not None, f"No weights dir for {module_name} in {local_path}"
weights_dir = os.path.join(local_path, module_name)
assert os.path.exists(
weights_dir
), f"No weights dir for {module_name} in {local_path}"

safetensors_files = _list_safetensors_files(weights_dir)
assert safetensors_files, f"No safetensors files in {weights_dir}"
Expand Down