Skip to content

feat(rocm): add Pyhip GR read support for Qwen3.8 Flash Next TP2 and TP4 - #39

Merged
sammysun0711 merged 9 commits into
qwen38-flash-next-amd-current-fix-installfrom
qwen38-flydsl-gr-read-update
Oct 9, 2026
Merged

sammysun0711 merged 9 commits into
qwen38-flash-next-amd-current-fix-installfrom
qwen38-flydsl-gr-read-update

Conversation

@apinge

@apinge apinge commented Sep 29, 2026 •

Copy link
Copy Markdown
Owner

Motivation

This PR integrates gr read via pyhip for Qwen3.8 flash next tp2 and tp4. To avoid duplicating code, this PR directly imports the pyhip.ops.gr_read interface (tingqli/pyhip#56).

Add SGLANG_GR_READ_FLYDSL (default off) to select the integration or the original path at model construction.

Modifications

  1. Pack up weight and down weight in class PyHIPGRReadMethod's function process_weights_after_loading
  2. Add warmup_pyhip_gr_read to warm up compiler cache (especially for prefill case)
  3. Update related scripts and tests.

Accuracy Tests

TP2

python -m sglang.test.run_eval   --eval-name gsm8k --num-examples 1319 --max-tokens 16384 --port 7080
[aiter] import [module_aiter_core] under /opt/aiter/aiter/jit/module_aiter_core.so
ChatCompletionSampler initialized with self.system_message=None self.temperature=0.0 self.max_tokens=16384 self.reasoning_effort=None self.extra_body=None self.stop=None self.record_meta_info=True
100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1314/1314 [20:13<00:00,  1.08it/s]
Total latency: 1213.535 s
Score: 0.979
Output throughput: 506.222 token/s
[METRIC] gsm8k_score=0.9794520547945206 labels={"model": "Qwen/Qwen3.8-Flash-Next-PTPC-FP8", "eval": "gsm8k"}
[METRIC] gsm8k_latency=1213.5351034309715 labels={"model": "Qwen/Qwen3.8-Flash-Next-PTPC-FP8", "eval": "gsm8k"}
====================
Speculative decoding: no per-request spec_accept_length in responses (non-speculative server, or --api completion which lacks return_meta_info).
====================
Writing report to /tmp/gsm8k_Qwen_Qwen3.8-Flash-Next-PTPC-FP8.html
{'score:std': np.float64(0.14186517244662997), 'score': np.float64(0.9794520547945206), 'latency': 1213.5351034309715, 'output_throughput': 506.22186227919343}
Writing results to /tmp/gsm8k_Qwen_Qwen3.8-Flash-Next-PTPC-FP8.json

Speed Tests and Profiling

T2 profiled with 12kin 350 out 1conc

before prefill (torch compiled)

image

after prefill (pyhip)

image

before decode (tuned triton kernel)

image

after decode (pyhip)

image

before

#Input tokens: 384000
#Output tokens: 11200
Starting warmup with 1 sequences...
Warmup completed with 1 sequences. Starting main benchmark run...
100%|██████████| 32/32 [03:04<00:00,  5.75s/it]

============ Serving Benchmark Result ============
Backend:                                 sglang    
Traffic request rate:                    inf       
Max request concurrency:                 1         
Successful requests:                     32        
Benchmark duration (s):                  184.10    
Total input tokens:                      384000    
Total input text tokens:                 384000    
Total generated tokens:                  11200     
Total generated tokens (retokenized):    11127     
Request throughput (req/s):              0.17      
Input token throughput (tok/s):          2085.84   
Output token throughput (tok/s):         60.84     
Peak output token throughput (tok/s):    74.00     
Peak concurrent requests:                2         
Total token throughput (tok/s):          2146.68   
Concurrency:                             1.00      
----------------End-to-End Latency----------------
Mean E2E Latency (ms):                   5751.80   
Median E2E Latency (ms):                 5746.90   
P90 E2E Latency (ms):                    5781.82   
P95 E2E Latency (ms):                    5785.21   
P99 E2E Latency (ms):                    5790.66   
---------------Time to First Token----------------
Mean TTFT (ms):                          1010.13   
Median TTFT (ms):                        1006.73   
P90 TTFT (ms):                           1026.76   
P95 TTFT (ms):                           1040.63   
P99 TTFT (ms):                           1047.72   
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms):                          13.59     
Median TPOT (ms):                        13.58     
P90 TPOT (ms):                           13.59     
P95 TPOT (ms):                           13.63     
P99 TPOT (ms):                           13.66     
---------------Inter-Token Latency----------------
Mean ITL (ms):                           13.59     
Median ITL (ms):                         13.58     
P90 ITL (ms):                            13.61     
P95 ITL (ms):                            13.64     
P99 ITL (ms):                            14.11     
Max ITL (ms):                            31.57     
==================================================

after

#Input tokens: 384000
#Output tokens: 11200
Starting warmup with 1 sequences...
Warmup completed with 1 sequences. Starting main benchmark run...
100%|██████████| 32/32 [02:39<00:00,  4.98s/it]

============ Serving Benchmark Result ============
Backend:                                 sglang    
Traffic request rate:                    inf       
Max request concurrency:                 1         
Successful requests:                     32        
Benchmark duration (s):                  159.46    
Total input tokens:                      384000    
Total input text tokens:                 384000    
Total generated tokens:                  11200     
Total generated tokens (retokenized):    11177     
Request throughput (req/s):              0.20      
Input token throughput (tok/s):          2408.08   
Output token throughput (tok/s):         70.24     
Peak output token throughput (tok/s):    86.00     
Peak concurrent requests:                2         
Total token throughput (tok/s):          2478.32   
Concurrency:                             1.00      
----------------End-to-End Latency----------------
Mean E2E Latency (ms):                   4981.00   
Median E2E Latency (ms):                 4979.18   
P90 E2E Latency (ms):                    4991.42   
P95 E2E Latency (ms):                    4993.08   
P99 E2E Latency (ms):                    4994.18   
---------------Time to First Token----------------
Mean TTFT (ms):                          894.00    
Median TTFT (ms):                        891.66    
P90 TTFT (ms):                           904.62    
P95 TTFT (ms):                           905.58    
P99 TTFT (ms):                           908.01    
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms):                          11.71     
Median TPOT (ms):                        11.71     
P90 TPOT (ms):                           11.72     
P95 TPOT (ms):                           11.72     
P99 TPOT (ms):                           11.72     
---------------Inter-Token Latency----------------
Mean ITL (ms):                           11.71     
Median ITL (ms):                         11.71     
P90 ITL (ms):                            11.74     
P95 ITL (ms):                            11.76     
P99 ITL (ms):                            11.93     
Max ITL (ms):                            12.64     
==================================================

Checklist

Review and Merge Process

  1. Ping Merge Oncalls to start the process. See the PR Merge Process.
  2. Get approvals from CODEOWNERS and other reviewers.
  3. Trigger CI tests with comments or contact authorized users to do so.
    • Common commands include /tag-and-rerun-ci, /tag-run-ci-label, /rerun-failed-ci
  4. After green CI and required approvals, ask Merge Oncalls or people with Write permission to merge the PR.

@apinge apinge changed the title use pyhip gr read feat(rocm): add Pyhip GR read support for Qwen3.8 Flash Next TP2 and TP4 Sep 29, 2026
@apinge
apinge requested a balanced review from Copilot September 29, 2026 11:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Some loaders can silently use incorrectly packed weights, and the default dependency and launch-script configuration introduce deployment failures.

Review effort: Balanced
Findings: 3 High severity · 1 Low severity

Open (4)
What changed in this PR

Adds PyHIP GR-read acceleration for Qwen3.8 Flash Next on ROCm.

Changes:

  • Integrates packed PyHIP GR-read weights and warmup paths.
  • Adds configuration and launch-script controls.
  • Adds gfx942 correctness and lifecycle tests.
File Description
python/​sglang/​srt/​environ.py Defines the GR-read environment toggle.
python/​sglang/​srt/​layers/​gr_read_pyhip.py Implements PyHIP loading, packing, and warmup.
python/​sglang/​srt/​layers/​hyperconnection.py Routes eligible HC mixing through PyHIP.
python/​sglang/​srt/​model_executor/​model_runner.py Adds post-load warmup.
python/​sglang/​srt/​model_executor/​runner/​decode_cuda_graph_runner.py Warms captured decode shapes.
python/​sglang/​srt/​model_executor/​model_runner_components/​weight_updater.py Rejects unsafe online weight updates.
scripts/​launch_qwen38_flash_next_fp8_mi308x_pure_tp1.sh Disables PyHIP for TP1.
scripts/​launch_qwen38_flash_next_fp8_mi308x_pure_tp_4_or_8_or_2.sh Configures PyHIP for TP2/4/8 launches.
test/​registered/​kernels/​test_gr_read_pyhip.py Tests API, packing, execution, graphs, and lifecycle.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread python/sglang/srt/environ.py Resolved
Comment on lines +51 to +53
def process_weights_after_loading(self, module):
if module._gr_read_weights is not None:
return

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

That makes a lot of sense. However, ShardedStateLoader (which typically requires explicitly specifying --load-format sharded_state) and Remote KV are both special weight-loading mechanisms that are not used in our case yet. I’ve added a TODO comment to track this issue.

@apinge
apinge marked this pull request as ready for review September 29, 2026 12:27
@apinge
apinge requested a review from sammysun0711 September 29, 2026 12:27
Comment thread python/pyproject_other.toml Resolved
@apinge
apinge requested a review from sammysun0711 October 9, 2026 08:29
@sammysun0711
sammysun0711 merged commit 182e5e8 into qwen38-flash-next-amd-current-fix-install Oct 9, 2026
75 of 88 checks passed
@apinge
apinge deleted the qwen38-flydsl-gr-read-update branch October 12, 2026 03:31
sammysun0711 added a commit that referenced this pull request Nov 6, 2026
* [AMD] Tune Qwen3.8 HC mix for MI308X

Specialize the BF16 HC mix for the Qwen3.8 shape on 80-CU gfx942 devices using measured Triton launch parameters and smaller row tiles.

Expand correctness coverage to 1-16 rows, add graph replay regression tests, and register AMD kernel CI.

Validation: 39 tests passed on MI308X. Graph replay with all 100 checkpoint HC weight pairs improves by approximately 2.28x over the original persistent configuration.
(cherry picked from commit 8cf5501)

* feat(rocm): add Pyhip GR read support for Qwen3.8 Flash Next TP2 and TP4 (#39)

* use pyhip gr read

* update comments

* add comments

* update scripts

* update setup

* update pyproject_other.toml

* Revert "update pyproject_other.toml"

This reverts commit 9b0cebd.

* update pyprojct

* update warmup

(cherry picked from commit 182e5e8)
Ported onto qwen4_v0.5.21 with only the changes the branch's lint requires:
- Test moved to test/registered/kernels/ops/gemm/ (kernel test layout) and
  registered with register_amd_ci (check-registered-tests).
- ruff-format applied to the added lines.
- Dropped hunks whose context no longer exists: scripts/ TP1 launcher
  (removed), compressed-tensors bump, and weight_updater call-site edits
  (call sites already pass the model).

* Address review comments on Qwen3.8 GR cherry-pick

- hc_mix: use is_gfx942_supported() for the gfx942 check and keep the
  original num_ctas line.
- launch script: drop the duplicate AITER_MOE_PADDING_SIZE export; #86
  exports it at its definition.

---------

Co-authored-by: apinge <[email protected]>
Co-authored-by: tongqiu <[email protected]>
Co-authored-by: root <[email protected]>
Co-authored-by: Xiake Sun <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants