Repository navigation
Conversation
… FP8 on MI308X - Client runs quant post-processing before receiving so tensor layout/dtype (fnuz, PyHIP GR packing) matches the seed. - Recompute load-time derived buffers (gemma_weight) after the raw copy. - Exchange a (name, shape, dtype) manifest digest before broadcasting; a mismatch now fails fast on both sides instead of deadlocking RCCL (seed RoPE caches grow at runtime). - Seed no longer crashes when a send group failed to init; client checks build_group result. - SGLANG_DEBUG_WEIGHT_CHECKSUM_DIR: per-rank post-load checksums. - Client launch script and validation report (benchmark/rfork_mi308x).
…ke HIP R-Fork - R-Fork transfer_engine: on ROCm register whole allocator segments, working around Mooncake HIP transport resolving addresses from the IPC allocation base (silently wrong weights otherwise); add standalone repro. - R-Fork transfer_engine: recompute derived buffers after the copy. - Benchmark tools: startup timer, per-model page-cache eviction, first-request latency, raw fastsafetensors throughput, weight-cache daemon shim. - Report: kernel-cache transfer, storage loaders (fastsafetensors, runai, prefetch, no-mmap), Mooncake vs RCCL, weight_cache limitation.
… load_weights and full launch commands SGLANG_DEBUG_WEIGHT_ITER_TIMING logs time blocked on the checkpoint iterator vs time in load_weights, and splits fastsafetensors into file read and per-tensor distribution.
Receivers run process_weights_after_loading before the copy, which sets k_scale_float/v_scale_float from the -1 placeholders (1.0). The copy then brings the seed's final k/v_scale tensors, but the floats consumed by the attention backends stayed at 1.0 for checkpoints with non-unit KV scales. Refresh them from the received tensors next to the alias rebind.
- warm page cache is now prepared (read in) and verified like cold; abort if residency is not reached (O_DIRECT loaders left "warm" runs cold) - remove a stale log before launch so an old "fired up" is not taken as ready - non-R-Fork runs use HIP_VISIBLE_DEVICES (fastsafetensors uses cuda:rank and ignores --base-gpu-id); R-Fork ranges must be contiguous, equal size, disjoint - refuse to launch on GPUs with >2 GiB in use; interleave repeats
…TP4 rerun Full rerun at 378743602 with the same scripts and table layout for TP2 and TP4: startup matrix (6 configs x page cache warm/cold x 2), cold kernel cache, per-rank checksums and GSM8K for disk/RCCL/Mooncake. README shortened; adds script usage.
Drop what was only used for analysis or convenience: - RCCL transfer manifest check (guarded a buffer-transfer variant that is not used; parameters-only transfer as before) - SGLANG_DEBUG_WEIGHT_ITER_TIMING and the iterator/fastsafetensors timers - rfork client launch script and analysis-only benchmark tools
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
6 open issues
In PyTorch (at least through 2.x as commonly used),Tensor.view(...)is for reshaping and does… · New This pre-processing is gated only onremote_instance_weight_loader_backend != MODELEXPRESS, and… · New Calling.item()on GPU tensors typically triggers a device-to-host synchronization. If there are… · New This assumes everysegmentinmemory_snapshothasaddressandtotal_sizekeys. Earlier code… · New The comment understates peak extra memory: the chunk is converted to int64 (8×), butweightsis… · New The error message says “not in _weights_send_group list”, but_weights_send_groupis being used… · New
What changed in this PR
Fixes remote-instance (“R-Fork”) weight loading correctness on MI308X/ROCm by making receiver-side weight layout match the seed, restoring derived state skipped by raw copies, and hardening error handling and diagnostics.
Changes:
- Ensure remote-instance receivers pre-apply quant post-processing before raw weight transfer, and restore derived buffers/aliases after receiving.
- Add ROCm-specific Mooncake HIP workaround to register full allocator segments to prevent shifted reads.
- Add debug checksum dumping for post-load verification and add MI308X benchmark/correctness tooling.
| File | Description |
|---|---|
| python/sglang/srt/model_loader/remote_instance_weight_loader_utils.py | On ROCm, registers whole allocator segments with Mooncake transfer engine to avoid shifted reads. |
| python/sglang/srt/model_loader/loader.py | Pre-matches seed’s post-processed layout before transfer; restores derived state after transfer; raises on failed group build. |
| python/sglang/srt/model_executor/model_runner_components/weight_exporter.py | Returns a clear error if the send group is missing instead of raising KeyError. |
| python/sglang/srt/model_executor/model_runner_components/load_model_utils.py | Adds optional per-rank param/buffer checksum dumping controlled by an env var. |
| python/sglang/srt/environ.py | Introduces SGLANG_DEBUG_WEIGHT_CHECKSUM_DIR env var. |
| benchmark/rfork_mi308x/verify_rfork.py | Script to compare per-tensor checksums across seed/client and run GSM8K for correctness. |
| benchmark/rfork_mi308x/mooncake_hip_offset_repro.py | Minimal repro for Mooncake HIP offset bug motivating full-segment registration. |
| benchmark/rfork_mi308x/evict_model_cache.py | Utility to measure/evict page-cache residency for model files. |
| benchmark/rfork_mi308x/bench_startup.py | Benchmark harness for startup time across load modes/cache states on MI308X. |
| benchmark/rfork_mi308x/README.md | Documents observed performance wins, correctness validation, and how to reproduce. |
Review effort: Lite
yicyang
marked this pull request as ready for review
October 28, 2026 07:57
apinge
self-requested a review
October 29, 2026 12:19
Starts the new instance in its own container on the same node (host network, shared IPC, GPU devices) and runs MODE=rfork against a seed in another container. CROSS_CONTAINER.md lists the requirements, usage and one TP2 measurement.
…over RCCL - transfer_engine path is back to the base branch: no whole-segment registration workaround, no pre-receive processing or derived-state restore for it (both now NCCL only) - remove mooncake_hip_offset_repro.py - bench_startup.py: configs disk and rfork_nccl only; drop the kernel-cache option; place every run with HIP_VISIBLE_DEVICES - verify_rfork.py: disk seed + RCCL instance only - launcher renamed to launch_qwen38_flash_next_fp8_mi308x_rfork.sh with MODE=seed|rfork; cross-container launcher is RCCL only - README: R-Fork scale-out effect, dependencies (none beyond ROCm), usage
yicyang
marked this pull request as draft
November 9, 2026 02:38
apinge
reviewed
Nov 9, 2026
yicyang
marked this pull request as ready for review
November 9, 2026 05:23
Owner
|
The test has passed according to doc |
apinge
approved these changes
Nov 9, 2026
apinge
merged commit Nov 9, 2026
6ca1975
into
apinge:qwen38-flash-next-amd-current-fix-install
1 check failed
apinge
pushed a commit
that referenced
this pull request
Nov 10, 2026
* Fix R-Fork weight loading on MI308X (#67) * [AMD] Make R-Fork (remote_instance, nccl) work for Qwen3.8-Flash-Next FP8 on MI308X - Client runs quant post-processing before receiving so tensor layout/dtype (fnuz, PyHIP GR packing) matches the seed. - Recompute load-time derived buffers (gemma_weight) after the raw copy. - Exchange a (name, shape, dtype) manifest digest before broadcasting; a mismatch now fails fast on both sides instead of deadlocking RCCL (seed RoPE caches grow at runtime). - Seed no longer crashes when a send group failed to init; client checks build_group result. - SGLANG_DEBUG_WEIGHT_CHECKSUM_DIR: per-rank post-load checksums. - Client launch script and validation report (benchmark/rfork_mi308x). * [AMD] Validate ModelExpress-style startup paths on MI308X; fix Mooncake HIP R-Fork - R-Fork transfer_engine: on ROCm register whole allocator segments, working around Mooncake HIP transport resolving addresses from the IPC allocation base (silently wrong weights otherwise); add standalone repro. - R-Fork transfer_engine: recompute derived buffers after the copy. - Benchmark tools: startup timer, per-model page-cache eviction, first-request latency, raw fastsafetensors throughput, weight-cache daemon shim. - Report: kernel-cache transfer, storage loaders (fastsafetensors, runai, prefetch, no-mmap), Mooncake vs RCCL, weight_cache limitation. * benchmark/rfork_mi308x: add per-phase startup time breakdown * Add weight-iterator timing debug switch; report per-rank disk read vs load_weights and full launch commands SGLANG_DEBUG_WEIGHT_ITER_TIMING logs time blocked on the checkpoint iterator vs time in load_weights, and splits fastsafetensors into file read and per-tensor distribution. * benchmark/rfork_mi308x: add bench_startup.py startup-time matrix * benchmark/rfork_mi308x: add TP2 results and seed-stall finding * benchmark/rfork_mi308x: correct runai/no-mmap memory note (peak only, KV unaffected) * remote_instance: refresh KV-cache scale floats after receiving weights Receivers run process_weights_after_loading before the copy, which sets k_scale_float/v_scale_float from the -1 placeholders (1.0). The copy then brings the seed's final k/v_scale tensors, but the floats consumed by the attention backends stayed at 1.0 for checkpoints with non-unit KV scales. Refresh them from the received tensors next to the alias rebind. * benchmark/rfork_mi308x: make bench_startup cache/GPU state explicit - warm page cache is now prepared (read in) and verified like cold; abort if residency is not reached (O_DIRECT loaders left "warm" runs cold) - remove a stale log before launch so an old "fired up" is not taken as ready - non-R-Fork runs use HIP_VISIBLE_DEVICES (fastsafetensors uses cuda:rank and ignores --base-gpu-id); R-Fork ranges must be contiguous, equal size, disjoint - refuse to launch on GPUs with >2 GiB in use; interleave repeats * benchmark/rfork_mi308x: add verify_rfork.py; rewrite README with TP2/TP4 rerun Full rerun at 378743602 with the same scripts and table layout for TP2 and TP4: startup matrix (6 configs x page cache warm/cold x 2), cold kernel cache, per-rank checksums and GSM8K for disk/RCCL/Mooncake. README shortened; adds script usage. * benchmark/rfork_mi308x: clarify R-Fork cold page-cache cells were not run * benchmark/rfork_mi308x: measure R-Fork configs with a cold page cache too * Trim PR to necessary changes Drop what was only used for analysis or convenience: - RCCL transfer manifest check (guarded a buffer-transfer variant that is not used; parameters-only transfer as before) - SGLANG_DEBUG_WEIGHT_ITER_TIMING and the iterator/fastsafetensors timers - rfork client launch script and analysis-only benchmark tools * benchmark/rfork_mi308x: README with usage and results only * benchmark/rfork_mi308x: drop prefetch config and results (no gain measured) * benchmark/rfork_mi308x: stop the seed when a run aborts * load_model_utils: correct the checksum peak-memory comment * scripts: add a reference launcher for the fast-startup options * scripts: add a cross-container R-Fork reference launcher Starts the new instance in its own container on the same node (host network, shared IPC, GPU devices) and runs MODE=rfork against a seed in another container. CROSS_CONTAINER.md lists the requirements, usage and one TP2 measurement. * Drop Mooncake, storage loaders and seed-startup options; keep R-Fork over RCCL - transfer_engine path is back to the base branch: no whole-segment registration workaround, no pre-receive processing or derived-state restore for it (both now NCCL only) - remove mooncake_hip_offset_repro.py - bench_startup.py: configs disk and rfork_nccl only; drop the kernel-cache option; place every run with HIP_VISIBLE_DEVICES - verify_rfork.py: disk seed + RCCL instance only - launcher renamed to launch_qwen38_flash_next_fp8_mi308x_rfork.sh with MODE=seed|rfork; cross-container launcher is RCCL only - README: R-Fork scale-out effect, dependencies (none beyond ROCm), usage * benchmark/rfork_mi308x: README results from the TP2 re-run at the RCCL-only head * benchmark/rfork_mi308x: README TP2 results re-measured at the rebased head --------- Co-authored-by: yicyang <[email protected]> (cherry picked from commit 6ca1975 on qwen38-flash-next-amd-current-fix-install) Conflicts resolved in loader.py (post_load_weights rename, import block) and load_model_utils.py (PLE offload condition now read via get_exec()). Signed-off-by: yicyang <[email protected]> Signed-off-by: Ethan Yang <[email protected]> * R-Fork: adapt the cherry-picked scripts to qwen4_v0.5.21 Launch scripts live in evaluation/ on this branch, so move the R-Fork launchers there and point bench_startup.py at evaluation/. The base launch script defaults MTP=1 here; R-Fork is validated without the MTP draft model, so the R-Fork launcher and bench_startup.py default MTP=0. Signed-off-by: yicyang <[email protected]> * [CI] Add a same-container TP2 R-Fork case to the Qwen4 CI Qwen3.8-Flash-TP2-RFork starts a TP2 seed from disk, then a TP2 instance on two other idle GPUs that pulls the seed's weights over RCCL (--load-format remote_instance). It fails unless the new instance loads via R-Fork, every rank's per-tensor checksums match the seed, and the new instance passes the TP2 GSM8K gate (reference 98.0%). The summary also reports the new instance's startup time and load_weight. Under --pressure it only checks loading and checksums. Signed-off-by: yicyang <[email protected]> * R-Fork cross-container launcher: drop the private workspace mount The launcher no longer requires or mounts a host workspace directory. The new container runs the image's SGLang at REPO_DIR (default /opt/sglang); DOCKER_ARGS passes extra docker run arguments, e.g. a mount for a host checkout used with REPO_DIR. Signed-off-by: yicyang <[email protected]> * [CI] Run the R-Fork case in the daily schedule only; drop README footnotes - Qwen3.8-Flash-TP2-RFork is daily-only: PR runs skip it, the daily schedule and an explicit case selection run it. matrix_cases() in qwen4_ci.py now builds the Actions matrix and is unit tested. - Under --pressure the R-Fork case also checks the complete seed and server logs after shutdown, like the other pressure cases. - README: remove the measurement footnotes. Signed-off-by: yicyang <[email protected]> --------- Signed-off-by: yicyang <[email protected]> Signed-off-by: Ethan Yang <[email protected]> Co-authored-by: yicyang <[email protected]>
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.



Motivation
R-Fork (
--load-format remote_instance) starts a new instance by copying weights from a running seed instead ofreading the checkpoint. On MI308X with Qwen3.8-Flash-Next-PTPC-FP8, this cuts startup from about 126 s to about 67 s
(TP2). However, the seed holds post-processed weights, and the current loader does not account for that. As a result,
the new instance crashes or loads mismatched derived state. This PR fixes the RCCL (
nccl) backend.Changes
process_weights_after_loadingbefore receiving, so the receiver has the seed's layout (fnuz FP8, PyHIPpacking). Without it, the new instance crashes.
gemma_weightvia_rebind_parameter_aliases, andk/v_scale_floatfrom the received tensors. A raw copy skips the hooks that compute these.build_groupfails. Otherwise the new instance hangs in the broadcast.KeyError.SGLANG_DEBUG_WEIGHT_CHECKSUM_DIR(off by default): dump per-rank tensor checksums after loading, to verifythat the copied weights match the seed.
launch_qwen38_flash_next_fp8_mi308x_rfork.sh(MODE=seed|rfork);launch_qwen38_flash_next_fp8_mi308x_rfork_cross_container.sh, which starts the new instance in its own container on the same node.bench_startup.py, disk vs R-Fork);verify_rfork.py);The
transfer_engine(Mooncake) andmodelexpresspaths are unchanged.Dependencies
None beyond the SGLang ROCm image.
torch.distributed'sncclbackend. On ROCm PyTorch, that is RCCL, which ships with ROCm (/opt/rocm/lib/librccl.so; RCCL 2.30.4 in the tested image).requests, which is already installed.Requirements:
ip_local_port_range;--network=host --ipc=hostand the GPU devices.Test
Single node, 8x MI308X. Launch to ready is the mean of 2 runs, with kernel caches and page cache warm.
VALIDATION_ROW
¹ Measured before the last cleanup commits. Those commits removed debug-only code and the Mooncake changes; the NCCL path is unchanged.
² That run had
NCCL_DEBUG=INFOon. The weight transfer itself took the same 3 s as within one container.Known issue (pre-existing, not changed here): if a new instance dies after asking the seed to set up the transfer group
but before joining it, the seed blocks in the rendezvous for up to 30 minutes.