Skip to content

[Hotfix] final fixes for P2P Transfer - #22663

Merged
yueming-yuan merged 5 commits into
sgl-project:sglang-milesfrom
JD-ETH:patch-fix-dpsk-5-10-v4
Apr 13, 2026
Merged

[Hotfix] final fixes for P2P Transfer #22663
yueming-yuan merged 5 commits into
sgl-project:sglang-milesfrom
JD-ETH:patch-fix-dpsk-5-10-v4

Conversation

@JD-ETH

@JD-ETH JD-ETH commented Apr 13, 2026

Copy link
Copy Markdown
Contributor
  1. Cherry-pick PR fix: deprecated interfaces after dump #22486 — fix: deprecated interfaces after dump
    - Fix Qwen3 rope_parameters → use get_rope_config() helper instead of accessing config.rope_parameters dict directly
    - (model_runner.py conflict resolved — redundant import removed)
  2. fix(weight_checker): skip _weight_fp32 in weight equality check
    - _reset_tensors(): skip _weight_fp32 buffers (don't randomize them)
    - _postprocess_tensors(): add _weight_fp32 to non_persistent_buffer_patterns (don't fail on mismatch)
    - Reason: Glm4MoeGate._weight_fp32 is a FP32 cache of the bf16 gate weight. Runtime invalidation after P2P weight update is not supported yet. Same skip pattern as cos_sin_cache / inv_freq.
  3. chore: remove redundant local import of get_local_ip_auto
  4. Cherry-pick [sglang-miles] fix fused qkv load weight from hf #22552 that fixes a special shard loading implementation in sglang

Validated models (all ✅ with --check-weight-update-equal + p2p)

  • Qwen3-4B (Qwen3ForCausalLM, 1 node)
  • GLM-Z1-9B-0414 (Glm4ForCausalLM, 1 node)
  • Moonlight-16B-A3B (DeepseekV2ForCausalLM, 2 nodes)
  • GLM-4.7-9B-Flash (Glm4MoeLiteForCausalLM, 2 nodes)
  • GLM-5_4layer (DeepseekV3ForCausalLM, 2 nodes)
  • Qwen3-30B-A3B (Qwen3MoeForCausalLM, 4 nodes)
  • GLM-4.5-Air (Glm4MoeForCausalLM, 8 nodes)

JD-ETH and others added 5 commits April 11, 2026 06:32
The stacked_params_mapping routes q_a_proj and kv_a_proj_with_mqa to
ReplicatedLinear.weight_loader with a shard_id, but ReplicatedLinear
does not support shard_id. Skip the stacked path for this param_name
so weights fall through to the existing cached_a_proj path in
do_load_weights(), which correctly caches both halves and torch.cats
them before loading.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Change lazy import from `sglang.srt.utils` to `sglang.srt.utils.network`
to match the module where `get_local_ip_auto` is actually defined.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Glm4MoeGate._weight_fp32 is a FP32 cache of the bf16 gate weight.
Runtime invalidation of this cache after weight update is not yet
supported. Skip it in both _reset_tensors and _postprocess_tensors,
same pattern as cos_sin_cache and inv_freq.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Already imported at module level (line 183).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@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!

def _reset_tensors(self):
for name, param in self._model_state():
if "cos_sin_cache" in name or "freqs_cis" in name:
if "cos_sin_cache" in name or "freqs_cis" in name or "_weight_fp32" in name:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: maybe we could maintain a list where these keys could be skipped.

@yueming-yuan
yueming-yuan merged commit 2b93c2f into sgl-project:sglang-miles Apr 13, 2026
1 check passed
fzyzcjy pushed a commit to fzyzcjy/sglang that referenced this pull request May 6, 2026
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Letian Ruan <ruanlt420@gmail.com>

Cherry-picked weight_checker.py changes only from the original PR.

(cherry picked from commit 2b93c2f)
fzyzcjy added a commit that referenced this pull request May 6, 2026
LLThomas pushed a commit to LLThomas/sglang that referenced this pull request May 8, 2026
nanjiangwill pushed a commit to nanjiangwill/sglang that referenced this pull request Jul 7, 2026
…t#21278, sgl-project#22663)

Includes making Cohere2MoeConfig a dataclass so parameter mapping can
introspect config fields for P2P weight update.

Co-authored-by: JensenFire <elevenji@outlook.com>
nanjiangwill pushed a commit to nanjiangwill/sglang that referenced this pull request Jul 7, 2026
…sgl-project#18565, sgl-project#22663, sgl-project#28001, sgl-project#29675)

Combined weight-processing machinery, folding the general post-process
plumbing from the INT4 QAT work (sgl-project#18565), the P2P post_load_weights
extension (sgl-project#22663), the weight-processing refactor (sgl-project#28001), and the
pause-aware weight locking fix (sgl-project#29675) into its final form:

- Begin/EndWeightUpdate request chain: engine/http_server/
  tokenizer_control_mixin (pause-aware locking) -> scheduler ->
  weight_updater sessions with {target,draft,all} runner selectors
- loader.py: public post_load_weights, restore_weight/postprocess_weight
  via _apply_quant_method_hook (skips LoRA wrappers)
- model_runner begin/end_weight_update + receive_weights_from_distributed
- iter_runners() on tp_worker and all spec v2 workers (incl. port to
  DFlashWorkerV2; v1 dflash/frozen-kv workers no longer exist)
- CompressedTensorsFusedMoEMethod.restore_weights_before_loading dispatch
- weight_checker ComparableWeight refactor + weight_checker_comparator

Co-authored-by: JD-ETH <jaedon.guo@gmail.com>
Co-authored-by: maocheng23 <35615230+maocheng23@users.noreply.github.com>
yueming-yuan pushed a commit that referenced this pull request Jul 14, 2026
…22663)

Includes making Cohere2MoeConfig a dataclass so parameter mapping can
introspect config fields for P2P weight update.

Co-authored-by: JensenFire <elevenji@outlook.com>

Merged with v0.5.15's fused-indexer-wk loading in the deepseek weight
loader; kept self.stacked_params_mapping refactor alongside it.
yueming-yuan added a commit that referenced this pull request Jul 14, 2026
…sessions + spec-draft weight check (#18565, #22663, #28001, #29675, #27750)

Combined weight-processing machinery, folding the general post-process
plumbing from the INT4 QAT work (#18565), the P2P post_load_weights
extension (#22663), the weight-processing refactor (#28001), and the
pause-aware weight locking fix (#29675) into its final form, plus the
extension of the weight checker to speculative draft worker(s) (#27750):

- Begin/EndWeightUpdate request chain: engine/http_server/
  tokenizer_control_mixin (pause-aware locking) -> scheduler ->
  weight_updater sessions with {target,draft,all} runner selectors
- loader.py: public post_load_weights, restore_weight/postprocess_weight
  via _apply_quant_method_hook (skips LoRA wrappers)
- model_runner begin/end_weight_update + receive_weights_from_distributed
- iter_runners() on tp_worker and all spec v2 workers (incl. DFlashWorkerV2)
- CompressedTensorsFusedMoEMethod.restore_weights_before_loading dispatch
- weight checker: selector + skip_tensor_list + role-prefixed overall_checksum
  over get_model_runners(selector), replacing _get_draft_model_runner

Kept v0.5.15's upstreamed ComparableWeight weight_checker_comparator
(incl. the #29623 ue8m0 scale-unpack fix); adapted the weight_checker
caller to its public compare_weights/CHUNK_NUMEL API.

Co-authored-by: JD-ETH <jaedon.guo@gmail.com>
Co-authored-by: maocheng23 <35615230+maocheng23@users.noreply.github.com>
Co-authored-by: Jiajun Li <jiajun.li@radixark.ai>
yueming-yuan pushed a commit that referenced this pull request Jul 14, 2026
…22663)

Includes making Cohere2MoeConfig a dataclass so parameter mapping can
introspect config fields for P2P weight update.

Co-authored-by: JensenFire <elevenji@outlook.com>

Merged with v0.5.15's fused-indexer-wk loading in the deepseek weight
loader; kept self.stacked_params_mapping refactor alongside it.
yueming-yuan added a commit that referenced this pull request Jul 14, 2026
…sessions + spec-draft weight check (#18565, #22663, #28001, #29675, #27750)

Combined weight-processing machinery, folding the general post-process
plumbing from the INT4 QAT work (#18565), the P2P post_load_weights
extension (#22663), the weight-processing refactor (#28001), and the
pause-aware weight locking fix (#29675) into its final form, plus the
extension of the weight checker to speculative draft worker(s) (#27750):

- Begin/EndWeightUpdate request chain: engine/http_server/
  tokenizer_control_mixin (pause-aware locking) -> scheduler ->
  weight_updater sessions with {target,draft,all} runner selectors
- loader.py: public post_load_weights, restore_weight/postprocess_weight
  via _apply_quant_method_hook (skips LoRA wrappers)
- model_runner begin/end_weight_update + receive_weights_from_distributed
- iter_runners() on tp_worker and all spec v2 workers (incl. DFlashWorkerV2)
- CompressedTensorsFusedMoEMethod.restore_weights_before_loading dispatch
- weight checker: selector + skip_tensor_list + role-prefixed overall_checksum
  over get_model_runners(selector), replacing _get_draft_model_runner

Kept v0.5.15's upstreamed ComparableWeight weight_checker_comparator
(incl. the #29623 ue8m0 scale-unpack fix); adapted the weight_checker
caller to its public compare_weights/CHUNK_NUMEL API.

Co-authored-by: JD-ETH <jaedon.guo@gmail.com>
Co-authored-by: maocheng23 <35615230+maocheng23@users.noreply.github.com>
Co-authored-by: Jiajun Li <jiajun.li@radixark.ai>
yueming-yuan added a commit that referenced this pull request Jul 14, 2026
…sessions + spec-draft weight check (#18565, #22663, #28001, #29675, #27750)

Combined weight-processing machinery, folding the general post-process
plumbing from the INT4 QAT work (#18565), the P2P post_load_weights
extension (#22663), the weight-processing refactor (#28001), and the
pause-aware weight locking fix (#29675) into its final form, plus the
extension of the weight checker to speculative draft worker(s) (#27750):

- Begin/EndWeightUpdate request chain: engine/http_server/
  tokenizer_control_mixin (pause-aware locking) -> scheduler ->
  weight_updater sessions with {target,draft,all} runner selectors
- loader.py: public post_load_weights, restore_weight/postprocess_weight
  via _apply_quant_method_hook (skips LoRA wrappers)
- model_runner begin/end_weight_update + receive_weights_from_distributed
- iter_runners() on tp_worker and all spec v2 workers (incl. DFlashWorkerV2)
- CompressedTensorsFusedMoEMethod.restore_weights_before_loading dispatch
- weight checker: selector + skip_tensor_list + role-prefixed overall_checksum
  over get_model_runners(selector), replacing _get_draft_model_runner

Kept v0.5.15's upstreamed ComparableWeight weight_checker_comparator
(incl. the #29623 ue8m0 scale-unpack fix); adapted the weight_checker
caller to its public compare_weights/CHUNK_NUMEL API.

Co-authored-by: JD-ETH <jaedon.guo@gmail.com>
Co-authored-by: maocheng23 <35615230+maocheng23@users.noreply.github.com>
Co-authored-by: Jiajun Li <jiajun.li@radixark.ai>
yueming-yuan added a commit that referenced this pull request Jul 14, 2026
…sessions + spec-draft weight check (#18565, #22663, #28001, #29675, #27750)

Combined weight-processing machinery, folding the general post-process
plumbing from the INT4 QAT work (#18565), the P2P post_load_weights
extension (#22663), the weight-processing refactor (#28001), and the
pause-aware weight locking fix (#29675) into its final form, plus the
extension of the weight checker to speculative draft worker(s) (#27750):

- Begin/EndWeightUpdate request chain: engine/http_server/
  tokenizer_control_mixin (pause-aware locking) -> scheduler ->
  weight_updater sessions with {target,draft,all} runner selectors
- loader.py: public post_load_weights, restore_weight/postprocess_weight
  via _apply_quant_method_hook (skips LoRA wrappers)
- model_runner begin/end_weight_update + receive_weights_from_distributed
- iter_runners() on tp_worker and all spec v2 workers (incl. DFlashWorkerV2)
- CompressedTensorsFusedMoEMethod.restore_weights_before_loading dispatch
- weight checker: selector + skip_tensor_list + role-prefixed overall_checksum
  over get_model_runners(selector), replacing _get_draft_model_runner

Kept v0.5.15's upstreamed ComparableWeight weight_checker_comparator
(incl. the #29623 ue8m0 scale-unpack fix); adapted the weight_checker
caller to its public compare_weights/CHUNK_NUMEL API.

Co-authored-by: JD-ETH <jaedon.guo@gmail.com>
Co-authored-by: maocheng23 <35615230+maocheng23@users.noreply.github.com>
Co-authored-by: Jiajun Li <jiajun.li@radixark.ai>
yueming-yuan pushed a commit that referenced this pull request Jul 25, 2026
…22663)

Includes making Cohere2MoeConfig a dataclass so parameter mapping can
introspect config fields for P2P weight update.

Rebased onto v0.5.16, which extracted the remote-instance transfer engine out
of ModelRunner into RemoteInstanceWeightTransporter: the per-rank
RankParallelismConfig is now built in `init_engine()` and published from
`maybe_register_and_publish_weight_info()`, instead of the ModelRunner methods
this commit originally added. The hoisted deepseek expert_params_mapping also
picks up v0.5.16's broader `is_wint4afp8_or_wint4a16_config` predicate rather
than the old `quant_config.get_name() == "w4afp8"` check.

Co-authored-by: JensenFire <elevenji@outlook.com>
yueming-yuan added a commit that referenced this pull request Jul 25, 2026
… for spec draft worker(s) (#27749, #28575, #18565, #22663, #28001, #29675, #27750)

Squash of the spec-draft distributed-update work and the weight-processing
session work: the latter rewrites iter_draft_runners()/get_model_runners() the
former introduces, so they cannot be applied independently.

  - Draft runners never join the update group, so the target receives the
    broadcast once and the weights are loaded into every selected runner.
  - Begin/EndWeightUpdate session chain: engine / http_server /
    tokenizer_control_mixin (pause-aware locking) -> scheduler ->
    SchedulerWeightUpdaterManager, with {target,draft,all} runner selectors.
  - loader.py: public post_load_weights plus restore_weight/postprocess_weight
    via _apply_quant_method_hook (skips LoRA wrappers).
  - weight checker: skip_tensor_list + role-prefixed overall_checksum over
    get_model_runners(selector), replacing _get_draft_model_runner.

Reimplemented onto v0.5.16, which had already extracted weight updating into
ModelRunner.weight_updater (WeightUpdater): the receive/load split lands there
as receive_weights_from_distributed() + load_weights() rather than on
ModelRunner, and the scheduler fan-out drives runner.weight_updater.*. The
worker-level update_weights_from_{distributed,tensor} entry points on
TpModelWorker / EAGLEWorkerV2 / NGRAMWorker are dropped: the scheduler now owns
the fan-out, and leaving them would be a second path that updates one runner
only. iter_runners() replaces the ad-hoc draft-runner discovery on every spec v2
worker (incl. DFlashWorkerV2). The unit test moves to test/registered/rl/, since
v0.5.16 retired test/srt/ from CI collection.

Co-authored-by: Yueming Yuan <yym022502@gmail.com>
Co-authored-by: JD-ETH <jaedon.guo@gmail.com>
Co-authored-by: maocheng23 <35615230+maocheng23@users.noreply.github.com>
yueming-yuan pushed a commit that referenced this pull request Jul 25, 2026
…22663)

Includes making Cohere2MoeConfig a dataclass so parameter mapping can
introspect config fields for P2P weight update.

Rebased onto v0.5.16, which extracted the remote-instance transfer engine out
of ModelRunner into RemoteInstanceWeightTransporter: the per-rank
RankParallelismConfig is now built in `init_engine()` and published from
`maybe_register_and_publish_weight_info()`, instead of the ModelRunner methods
this commit originally added. The hoisted deepseek expert_params_mapping also
picks up v0.5.16's broader `is_wint4afp8_or_wint4a16_config` predicate rather
than the old `quant_config.get_name() == "w4afp8"` check.

Co-authored-by: JensenFire <elevenji@outlook.com>
yueming-yuan added a commit that referenced this pull request Jul 25, 2026
… for spec draft worker(s) (#27749, #28575, #18565, #22663, #28001, #29675, #27750)

Squash of the spec-draft distributed-update work and the weight-processing
session work: the latter rewrites iter_draft_runners()/get_model_runners() the
former introduces, so they cannot be applied independently.

  - Draft runners never join the update group, so the target receives the
    broadcast once and the weights are loaded into every selected runner.
  - Begin/EndWeightUpdate session chain: engine / http_server /
    tokenizer_control_mixin (pause-aware locking) -> scheduler ->
    SchedulerWeightUpdaterManager, with {target,draft,all} runner selectors.
  - loader.py: public post_load_weights plus restore_weight/postprocess_weight
    via _apply_quant_method_hook (skips LoRA wrappers).
  - weight checker: skip_tensor_list + role-prefixed overall_checksum over
    get_model_runners(selector), replacing _get_draft_model_runner.

Reimplemented onto v0.5.16, which had already extracted weight updating into
ModelRunner.weight_updater (WeightUpdater): the receive/load split lands there
as receive_weights_from_distributed() + load_weights() rather than on
ModelRunner, and the scheduler fan-out drives runner.weight_updater.*. The
worker-level update_weights_from_{distributed,tensor} entry points on
TpModelWorker / EAGLEWorkerV2 / NGRAMWorker are dropped: the scheduler now owns
the fan-out, and leaving them would be a second path that updates one runner
only. iter_runners() replaces the ad-hoc draft-runner discovery on every spec v2
worker (incl. DFlashWorkerV2). The unit test moves to test/registered/rl/, since
v0.5.16 retired test/srt/ from CI collection.

Co-authored-by: Yueming Yuan <yym022502@gmail.com>
Co-authored-by: JD-ETH <jaedon.guo@gmail.com>
Co-authored-by: maocheng23 <35615230+maocheng23@users.noreply.github.com>
yueming-yuan pushed a commit that referenced this pull request Jul 25, 2026
…22663)

Includes making Cohere2MoeConfig a dataclass so parameter mapping can
introspect config fields for P2P weight update.

Rebased onto v0.5.16, which extracted the remote-instance transfer engine out
of ModelRunner into RemoteInstanceWeightTransporter: the per-rank
RankParallelismConfig is now built in `init_engine()` and published from
`maybe_register_and_publish_weight_info()`, instead of the ModelRunner methods
this commit originally added. The hoisted deepseek expert_params_mapping also
picks up v0.5.16's broader `is_wint4afp8_or_wint4a16_config` predicate rather
than the old `quant_config.get_name() == "w4afp8"` check.

Co-authored-by: JensenFire <elevenji@outlook.com>
yueming-yuan added a commit that referenced this pull request Jul 25, 2026
… for spec draft worker(s) (#27749, #28575, #18565, #22663, #28001, #29675, #27750)

Squash of the spec-draft distributed-update work and the weight-processing
session work: the latter rewrites iter_draft_runners()/get_model_runners() the
former introduces, so they cannot be applied independently.

  - Draft runners never join the update group, so the target receives the
    broadcast once and the weights are loaded into every selected runner.
  - Begin/EndWeightUpdate session chain: engine / http_server /
    tokenizer_control_mixin (pause-aware locking) -> scheduler ->
    SchedulerWeightUpdaterManager, with {target,draft,all} runner selectors.
  - loader.py: public post_load_weights plus restore_weight/postprocess_weight
    via _apply_quant_method_hook (skips LoRA wrappers).
  - weight checker: skip_tensor_list + role-prefixed overall_checksum over
    get_model_runners(selector), replacing _get_draft_model_runner.

Reimplemented onto v0.5.16, which had already extracted weight updating into
ModelRunner.weight_updater (WeightUpdater): the receive/load split lands there
as receive_weights_from_distributed() + load_weights() rather than on
ModelRunner, and the scheduler fan-out drives runner.weight_updater.*. The
worker-level update_weights_from_{distributed,tensor} entry points on
TpModelWorker / EAGLEWorkerV2 / NGRAMWorker are dropped: the scheduler now owns
the fan-out, and leaving them would be a second path that updates one runner
only. iter_runners() replaces the ad-hoc draft-runner discovery on every spec v2
worker (incl. DFlashWorkerV2). The unit test moves to test/registered/rl/, since
v0.5.16 retired test/srt/ from CI collection.

Co-authored-by: Yueming Yuan <yym022502@gmail.com>
Co-authored-by: JD-ETH <jaedon.guo@gmail.com>
Co-authored-by: maocheng23 <35615230+maocheng23@users.noreply.github.com>
yueming-yuan pushed a commit that referenced this pull request Jul 25, 2026
…22663)

Includes making Cohere2MoeConfig a dataclass so parameter mapping can
introspect config fields for P2P weight update.

Rebased onto v0.5.16, which extracted the remote-instance transfer engine out
of ModelRunner into RemoteInstanceWeightTransporter: the per-rank
RankParallelismConfig is now built in `init_engine()` and published from
`maybe_register_and_publish_weight_info()`, instead of the ModelRunner methods
this commit originally added. The hoisted deepseek expert_params_mapping also
picks up v0.5.16's broader `is_wint4afp8_or_wint4a16_config` predicate rather
than the old `quant_config.get_name() == "w4afp8"` check.

Co-authored-by: JensenFire <elevenji@outlook.com>
yueming-yuan added a commit that referenced this pull request Jul 25, 2026
… for spec draft worker(s) (#27749, #28575, #18565, #22663, #28001, #29675, #27750)

Squash of the spec-draft distributed-update work and the weight-processing
session work: the latter rewrites iter_draft_runners()/get_model_runners() the
former introduces, so they cannot be applied independently.

  - Draft runners never join the update group, so the target receives the
    broadcast once and the weights are loaded into every selected runner.
  - Begin/EndWeightUpdate session chain: engine / http_server /
    tokenizer_control_mixin (pause-aware locking) -> scheduler ->
    SchedulerWeightUpdaterManager, with {target,draft,all} runner selectors.
  - loader.py: public post_load_weights plus restore_weight/postprocess_weight
    via _apply_quant_method_hook (skips LoRA wrappers).
  - weight checker: skip_tensor_list + role-prefixed overall_checksum over
    get_model_runners(selector), replacing _get_draft_model_runner.

Reimplemented onto v0.5.16, which had already extracted weight updating into
ModelRunner.weight_updater (WeightUpdater): the receive/load split lands there
as receive_weights_from_distributed() + load_weights() rather than on
ModelRunner, and the scheduler fan-out drives runner.weight_updater.*. The
worker-level update_weights_from_{distributed,tensor} entry points on
TpModelWorker / EAGLEWorkerV2 / NGRAMWorker are dropped: the scheduler now owns
the fan-out, and leaving them would be a second path that updates one runner
only. iter_runners() replaces the ad-hoc draft-runner discovery on every spec v2
worker (incl. DFlashWorkerV2). The unit test moves to test/registered/rl/, since
v0.5.16 retired test/srt/ from CI collection.

Co-authored-by: Yueming Yuan <yym022502@gmail.com>
Co-authored-by: JD-ETH <jaedon.guo@gmail.com>
Co-authored-by: maocheng23 <35615230+maocheng23@users.noreply.github.com>
Chronostasys pushed a commit to MindLab-Research/sglang that referenced this pull request Aug 24, 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.

4 participants