jcbtc commited on
Commit
956a1c1
·
verified ·
1 Parent(s): 3321977

Publish Ling 3.0 Flash CIRU Strix-native runtime

Browse files
.gitattributes CHANGED
@@ -1,35 +1,6 @@
1
- *.7z filter=lfs diff=lfs merge=lfs -text
2
- *.arrow filter=lfs diff=lfs merge=lfs -text
3
- *.bin filter=lfs diff=lfs merge=lfs -text
4
- *.bz2 filter=lfs diff=lfs merge=lfs -text
5
- *.ckpt filter=lfs diff=lfs merge=lfs -text
6
- *.ftz filter=lfs diff=lfs merge=lfs -text
7
- *.gz filter=lfs diff=lfs merge=lfs -text
8
- *.h5 filter=lfs diff=lfs merge=lfs -text
9
- *.joblib filter=lfs diff=lfs merge=lfs -text
10
- *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
- *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
- *.model filter=lfs diff=lfs merge=lfs -text
13
- *.msgpack filter=lfs diff=lfs merge=lfs -text
14
- *.npy filter=lfs diff=lfs merge=lfs -text
15
- *.npz filter=lfs diff=lfs merge=lfs -text
16
- *.onnx filter=lfs diff=lfs merge=lfs -text
17
- *.ot filter=lfs diff=lfs merge=lfs -text
18
- *.parquet filter=lfs diff=lfs merge=lfs -text
19
- *.pb filter=lfs diff=lfs merge=lfs -text
20
- *.pickle filter=lfs diff=lfs merge=lfs -text
21
- *.pkl filter=lfs diff=lfs merge=lfs -text
22
- *.pt filter=lfs diff=lfs merge=lfs -text
23
- *.pth filter=lfs diff=lfs merge=lfs -text
24
- *.rar filter=lfs diff=lfs merge=lfs -text
25
- *.safetensors filter=lfs diff=lfs merge=lfs -text
26
- saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
- *.tar.* filter=lfs diff=lfs merge=lfs -text
28
- *.tar filter=lfs diff=lfs merge=lfs -text
29
- *.tflite filter=lfs diff=lfs merge=lfs -text
30
- *.tgz filter=lfs diff=lfs merge=lfs -text
31
- *.wasm filter=lfs diff=lfs merge=lfs -text
32
- *.xz filter=lfs diff=lfs merge=lfs -text
33
- *.zip filter=lfs diff=lfs merge=lfs -text
34
- *.zst filter=lfs diff=lfs merge=lfs -text
35
- *tfevents* filter=lfs diff=lfs merge=lfs -text
 
1
+ *.bundle binary
2
+ *.patch text eol=lf
3
+ *.sh text eol=lf
4
+ *.md text eol=lf
5
+ *.png filter=lfs diff=lfs merge=lfs -text
6
+ Ling-3.0-Flash-CIRU-int4-Strix-native.tar.gz filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
CHANGELOG.md ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Runtime change manifest
2
+
3
+ ## Immutable identities
4
+
5
+ - Original model: `inclusionAI/Ling-3.0-flash-int4`
6
+ - Model revision: `ca3ea63b0255d212c4fe6020db9e0a51ce136006`
7
+ - Model format: 24 safetensors shards, 77,012,299,464 bytes total
8
+ - vLLM upstream base: `d35eb6c44071ea806018841c490f0d2f3219c485`
9
+ - CIRU runtime head: `388d82de2abe418e73380ba250270d3abc62ac12`
10
+ - Net vLLM delta: six files, 365 insertions, 26 deletions
11
+
12
+ ## Weight changes
13
+
14
+ None. No tensor, quantization scale, tokenizer, template, configuration, or MTP weight was modified. The official packed-INT4 checkpoint is consumed directly.
15
+
16
+ ## Source changes
17
+
18
+ ### `csrc/libtorch_stable/sampler.cu`
19
+
20
+ Uses 512 rather than 1024 merge threads on ROCm so Wave32 hardware does not exceed the 64 KB LDS limit. This is a general ROCm correctness change.
21
+
22
+ ### `vllm/v1/attention/ops/merge_attn_states.py`
23
+
24
+ Adds an opt-in Torch implementation selected by `VLLM_ROCM_SAFE_MERGE_ATTN_STATES=1`. It handles token-first and head-first LSE layouts and avoids an observed `gfx1151` HSA fault in the Triton merge kernel.
25
+
26
+ ### `vllm/v1/attention/backends/mla/triton_mla.py`
27
+
28
+ Declares uniform query-length support and converts causal multi-token verifier blocks into per-token Triton MLA decode rows with correct causal KV-prefix lengths. This is relevant to MLA speculative verification, not W4A16 specifically.
29
+
30
+ ### `vllm/model_executor/layers/fused_moe/fused_moe.py`
31
+
32
+ Adds a naive small-decode block assignment specialization that bypasses sorting/alignment only under a narrow validated guard.
33
+
34
+ ### `vllm/model_executor/layers/fused_moe/moe_fused_mul_sum.py`
35
+
36
+ Adds a low-launch-overhead Triton reduction for one to three tokens, top-k 8, and hidden size 2560.
37
+
38
+ ### `vllm/model_executor/layers/fused_moe/experts/triton_moe.py`
39
+
40
+ Wires the guarded WNA16 paths together and adds the exact small-shape `gfx1151` SiLU-and-multiply kernel. Every adjacent shape or unsupported configuration retains the upstream route.
41
+
42
+ ## Runtime configuration
43
+
44
+ - Triton MLA attention
45
+ - Triton MoE backend
46
+ - native checkpoint MTP, K1 (`num_speculative_tokens=1`)
47
+ - compile sizes `[1,2]`
48
+ - CUDA graphs disabled
49
+ - chunked prefill and prefix caching enabled
50
+ - AITER and ROCm skinny GEMM disabled
51
+ - safe attention merge enabled
52
+ - native context 262,144 tokens
53
+ - five active sequences for 256K; two for experimental 1M
54
+
55
+ ## Performance context
56
+
57
+ The runnable public/upstream-compatible starting path measured 0.268944 tok/s in a warmed deterministic target-only decode test. The released runtime measures 21.4407 tok/s target-only and 26.2343 effective tok/s with native K1 MTP: 79.72x and 97.55x the starting throughput, respectively.
58
+
59
+ The final exact-shape SiLU candidate passed bitwise source fixtures and exact output checks. In the matched final-step comparison against the already-optimized CIRU parent, it improved target-only decode by 7.7457% and K1 effective decode by 4.3743%. Those percentages describe only the last runtime optimization, not the public-to-release gain. Only clean, resource-gated measurements were retained as promotion evidence.
60
+
61
+ ## Public release packaging
62
+
63
+ - Added the CIRU model-card artwork at `assets/ling30int4.png`.
64
+ - Added distro-aware host dependencies and portable Python 3.12 provisioning through `uv`.
65
+ - Added native-Linux instructions for Ubuntu/Debian, Fedora, Arch, and the validated NixOS boundary.
66
+ - Added an explicitly experimental Windows 11 WSL2/AMD ROCDXG path; native Windows vLLM is not claimed.
67
+ - Changed the public native-256K profile from `gpu_memory_utilization=0.82` to the validated long-context `0.75` envelope. It retains a 2,519,792-token KV pool and five active sequence slots while avoiding the observed 60K memory-pressure failure.
68
+ - Added the retained 60K PP/TG comparison against AtomicChat AD-IQ4_XXS and ROCmFP4 STRIX MTP, with the native row marked for a final-commit refresh.
Ling-3.0-Flash-CIRU-int4-Strix-native.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fdf2953bf7ed602a535f497569d226288b77a8a12dd08d548c66906a60049935
3
+ size 263719
MANIFEST.json ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "release_name": "Ling-3.0-Flash-CIRU-int4-Strix-native",
3
+ "release_archive": "Ling-3.0-Flash-CIRU-int4-Strix-native.tar.gz",
4
+ "release_type": "runtime-distribution",
5
+ "weights_changed": false,
6
+ "base_model": {
7
+ "repo_id": "inclusionAI/Ling-3.0-flash-int4",
8
+ "revision": "ca3ea63b0255d212c4fe6020db9e0a51ce136006",
9
+ "format": "compressed-tensors packed INT4 safetensors",
10
+ "shards": 24,
11
+ "shard_bytes": 77012299464,
12
+ "native_context": 262144
13
+ },
14
+ "runtime": {
15
+ "upstream_repo": "https://github.com/vllm-project/vllm.git",
16
+ "upstream_base": "d35eb6c44071ea806018841c490f0d2f3219c485",
17
+ "ciru_head": "388d82de2abe418e73380ba250270d3abc62ac12",
18
+ "commits_ahead": 15,
19
+ "net_files_changed": 6,
20
+ "net_insertions": 365,
21
+ "net_deletions": 26
22
+ },
23
+ "validated_stack": {
24
+ "python": "3.12.12",
25
+ "torch": "2.13.0+rocm7.15.0a20260728",
26
+ "hip": "7.15.0",
27
+ "triton": "3.8.0+git4cff872c.rocm7.15.0a20260728",
28
+ "flash_attention": "2.8.3",
29
+ "gpu": "AMD Radeon 8060S",
30
+ "architecture": "gfx1151"
31
+ },
32
+ "profiles": {
33
+ "native_256k": {"max_model_len": 262144, "max_num_seqs": 5, "gpu_memory_utilization": 0.75, "kv_pool_tokens_observed": 2519792},
34
+ "experimental_yarn_1m": {"max_model_len": 1048576, "max_num_seqs": 2, "native_training": false}
35
+ },
36
+ "platforms": {
37
+ "validated": ["NixOS native Linux on gfx1151"],
38
+ "documented_unvalidated": ["Ubuntu/Debian native Linux", "Fedora native Linux", "Arch native Linux", "Windows 11 WSL2 with AMD ROCDXG"],
39
+ "unsupported": ["native Windows vLLM"]
40
+ },
41
+ "performance": {
42
+ "host_scope": "single AMD Strix Halo gfx1151 host",
43
+ "public_starting_target_only_tokens_per_second": 0.268944,
44
+ "release_target_only_tokens_per_second": 21.4407,
45
+ "release_native_mtp_k1_effective_tokens_per_second": 26.2343,
46
+ "release_target_only_multiple": 79.72,
47
+ "release_native_mtp_k1_multiple": 97.55,
48
+ "comparison_scope": "full campaign progression; starting TG8 and final TG32, not a single-variable matched A/B",
49
+ "exact_2k_k1_concurrency": {
50
+ "c1_aggregate_decode_tokens_per_second": 26.33,
51
+ "c2_aggregate_decode_tokens_per_second": 38.90,
52
+ "c4_aggregate_decode_tokens_per_second": 59.03,
53
+ "c5_aggregate_decode_tokens_per_second": 62.16,
54
+ "validated_max_concurrency": 5,
55
+ "c6_status": "engine failure in chunked-prefill MLA accumulation; public profiles cap active sequences below this boundary"
56
+ },
57
+ "retained_60k_prompt_512_output": {
58
+ "native_source": "fabbc7e928dfa64c29dcdf0f795b05246555f4ae",
59
+ "native_pp_tokens_per_second": 419.334843,
60
+ "native_tg_tokens_per_second": 19.924752,
61
+ "atomic_chat_pp_tokens_per_second": 265.63,
62
+ "atomic_chat_tg_tokens_per_second": 25.11,
63
+ "rocmfp4_pp_tokens_per_second": 249.23,
64
+ "rocmfp4_tg_tokens_per_second": 19.00,
65
+ "refresh_required_for_release_head": true
66
+ }
67
+ }
68
+ }
README.md ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ base_model: inclusionAI/Ling-3.0-flash-int4
4
+ pipeline_tag: text-generation
5
+ library_name: vllm
6
+ tags:
7
+ - rocm
8
+ - amd
9
+ - strix-halo
10
+ - gfx1151
11
+ - vllm
12
+ - w4a16
13
+ - speculative-decoding
14
+ - mtp
15
+ - windows
16
+ - wsl
17
+ ---
18
+
19
+ # Ling-3.0-Flash-CIRU-int4-Strix-native
20
+
21
+ ![Ling 3.0 Flash CIRU INT4 for Strix Halo](assets/ling30int4.png)
22
+
23
+ `Ling-3.0-Flash-CIRU-int4-Strix-native` is CIRU's native vLLM/ROCm runtime distribution for InclusionAI's official packed-INT4 Ling 3.0 Flash checkpoint on AMD Strix Halo (`gfx1151`).
24
+
25
+ The model weights were **not** changed, requantized, merged, fine-tuned, or renamed internally. This release combines the original checkpoint at revision `ca3ea63b0255d212c4fe6020db9e0a51ce136006` with a pinned vLLM fork, ROCm 7.15 build recipe, and launch profiles validated on an AMD Radeon 8060S with 128 GB unified memory.
26
+
27
+ **A 97.5x native ROCm serving campaign:** the first working upstream-compatible build decoded at 0.269 tok/s; this distribution reaches 26.23 tok/s with native MTP K1, while retaining the official vendor checkpoint, OpenAI-compatible serving, continuous batching, and Ling's structured tool parser.
28
+
29
+ ## What this release changes
30
+
31
+ The runtime is based on vLLM commit `d35eb6c44071ea806018841c490f0d2f3219c485` plus a 15-commit CIRU branch ending at `388d82de2abe418e73380ba250270d3abc62ac12`. Its net source delta is six files, 365 insertions, and 26 deletions.
32
+
33
+ - Fixes a Wave32 LDS overflow in the ROCm top-k merge launch.
34
+ - Adds an opt-in safe PyTorch attention-state merge for a `gfx1151` Triton/HSA fault, including both supported MLA LSE layouts.
35
+ - Routes causal uniform multi-token MLA verification blocks through Triton decode with correct per-token sequence lengths.
36
+ - Adds narrowly guarded W4A16 MoE decode/verification fast paths for Ling's exact small-token geometry.
37
+ - Adds a `gfx1151` Triton SiLU-and-multiply kernel for Ling's exact eager W4A16 shapes.
38
+
39
+ See [CHANGELOG.md](CHANGELOG.md) for the public file-level runtime diff.
40
+
41
+ ## Performance: 97.5x over the public starting point
42
+
43
+ The closest runnable public/upstream starting point was frozen vLLM commit `d35eb6c44071ea806018841c490f0d2f3219c485` plus the publicly proposed five-line ROCm sampler fix required to launch on `gfx1151`. With the unchanged official model, that path produced **0.268944 tok/s** in a warmed deterministic target-only decode test. This release reaches **26.2343 effective tok/s** with the checkpoint's native K1 MTP: **97.55x the starting throughput**, or approximately **100x**.
44
+
45
+ | Public-to-release progression | Decode throughput | Multiple vs. starting point |
46
+ |---|---:|---:|
47
+ | Upstream-compatible starting path, target only | 0.268944 tok/s | 1.00x |
48
+ | This release, target only | 21.4407 tok/s | 79.72x |
49
+ | This release, native MTP K1 | 26.2343 effective tok/s | 97.55x (~100x) |
50
+
51
+ The starting row is a warmed deterministic eight-token test; the final rows are medians from deterministic 32-token tests. The multiplier therefore describes the full optimization campaign on the same model and host, not a single-variable matched A/B. The final exact-shape kernel step was also tested separately against the already-optimized CIRU parent: target-only decode rose from 19.8993 to 21.4407 tok/s (+7.7457%), and K1 rose from 25.1348 to 26.2343 tok/s (+4.3743%). That smaller percentage is the final incremental step, not the overall release gain.
52
+
53
+ MTP acceptance remained 82.35% with 1.8235 mean tokens per step. Retained controls had exact token IDs/text and zero faults. These are local single-host measurements, not claims for other AMD architectures.
54
+
55
+ ### How 0.269 became 26.23 tok/s
56
+
57
+ | Stage | Decode throughput | Incremental result |
58
+ |---|---:|---:|
59
+ | First working upstream-compatible build | 0.269 tok/s | starting point |
60
+ | Disable pathological ROCm skinny-GEMM dispatch on Wave32 | 7.57 tok/s | 28.16x |
61
+ | vLLM compilation mode 3, decode size 1, graphs off | 11.21 tok/s | +48.1% |
62
+ | Coherent ROCm 7.15 / Torch 2.13 / Triton 3.8 stack | 14.84 tok/s | +32.4% |
63
+ | W4A16 MoE expert assignment and finalize reduction | 19.71 tok/s | +42.4% |
64
+ | Repair optimized multi-token verifier routing; native MTP K1 | 25.13 tok/s | +27.3% |
65
+ | Exact-shape `gfx1151` SiLU-and-multiply kernel | **26.23 tok/s** | +4.37% K1; 97.55x overall |
66
+
67
+ The largest single problem was silent selection of vLLM's ROCm skinny-GEMM path on Wave32: disabling it alone improved identical-output decode by 28.16x. The remaining gains came from compilation, a coherent AMD software stack, Ling-shaped W4A16 MoE paths, repaired MTP verification routing, and the final exact-shape activation kernel.
68
+
69
+ ### Serving results
70
+
71
+ On exact 2K prompts with 256 forced output tokens, K1 MTP, and simultaneous bursts:
72
+
73
+ | Concurrent requests | Aggregate prefill | Aggregate decode | Per-request decode |
74
+ |---:|---:|---:|---:|
75
+ | 1 | 521.06 tok/s | 26.33 tok/s | 26.33 tok/s |
76
+ | 2 | 503.31 tok/s | 38.90 tok/s | 19.73 tok/s |
77
+ | 4 | 508.15 tok/s | 59.03 tok/s | 15.34 tok/s |
78
+ | 5 | 468.30 tok/s | **62.16 tok/s** | 14.40 tok/s |
79
+
80
+ The C4 row reproduced at 59.15 and 59.03 aggregate decode tok/s across independent loads. For context, CIRU's local llama.cpp Vulkan GGUF reference reached 51.08 tok/s single-stream with MTP: this native vLLM stack is slower single-stream, but exceeds that single-stream reference at C4 and C5 while using the official checkpoint and vLLM serving stack.
81
+
82
+ The runtime also sustained 540.19, 550.20, and 536.13 prefill tok/s at 2K, 8K, and 16K in clean long-prefill tests on an earlier retained build; treat those rows as a floor rather than a claim measured again on the final commit. The final stack completed CIRU's 20-scenario structured tool-call suite using Ling's native parser.
83
+
84
+ ### 60K PP/TG comparison
85
+
86
+ This retained comparison uses one frozen 60,000-token prompt followed by 512 forced output tokens:
87
+
88
+ | Stack | PP | TG | Request wall |
89
+ |---|---:|---:|---:|
90
+ | **CIRU native K1 MTP** | **419.33 tok/s** | 19.92 tok/s | **168.75 s** |
91
+ | AtomicChat AD-IQ4_XXS, llama.cpp Vulkan | 265.63 tok/s | **25.11 tok/s** | 246.28 s |
92
+ | ROCmFP4 STRIX MTP, llama.cpp Vulkan | 249.23 tok/s | 19.00 tok/s | 267.84 s |
93
+
94
+ Native vLLM gives up 20.66% TG to Atomic at 60K, but its 57.87% PP lead completes the combined request 31.48% sooner. It leads ROCmFP4 by 68.25% PP, 4.88% TG, and 37.00% in combined wall time.
95
+
96
+ The native row predates the release's final SiLU kernel commit, so this table is a retained baseline rather than a final-commit maximum. See [docs/BENCHMARKS.md](docs/BENCHMARKS.md) for the exact protocol, source identities, and refresh rule.
97
+
98
+ ## Files in this package
99
+
100
+ - `runtime/Ling-3.0-Flash-CIRU-int4-Strix-native-vllm.bundle`: exact Git objects for the CIRU branch, based on the pinned upstream commit.
101
+ - `runtime/Ling-3.0-Flash-CIRU-int4-Strix-native-vllm.patch`: reviewable net source diff.
102
+ - `scripts/download-model.sh`: downloads the unchanged official checkpoint into a directory named `Ling-3.0-Flash-CIRU-int4-Strix-native`.
103
+ - `scripts/install-host-deps.sh`: distro-aware Linux/WSL host dependency installer.
104
+ - `scripts/build-vllm-gfx1151.sh`: reproducible build entry point for the pinned AMD wheel stack.
105
+ - `scripts/run-256k.sh`: native 256K, native-MTP K1 server profile with five active sequence slots.
106
+ - `scripts/run-1m-yarn-experimental.sh`: experimental 4x YaRN 1M profile with two active sequence slots.
107
+ - `MANIFEST.json`: machine-readable identities and scope.
108
+
109
+ The named release archive is `Ling-3.0-Flash-CIRU-int4-Strix-native.tar.gz`. It contains the runtime distribution, image, and documentation—not a second 77 GB copy of unchanged weights.
110
+
111
+ ## Quick start
112
+
113
+ The exact validated environment is Python 3.12, Torch `2.13.0+rocm7.15.0a20260728`, HIP `7.15.0`, Triton `3.8.0+git4cff872c.rocm7.15.0a20260728`, FlashAttention `2.8.3`, and the CIRU vLLM source at `388d82de2`.
114
+
115
+ ```bash
116
+ bash scripts/install-host-deps.sh
117
+ bash scripts/build-vllm-gfx1151.sh "$HOME/ciru-ling-runtime"
118
+ bash scripts/download-model.sh "$HOME/models"
119
+
120
+ VENV="$HOME/ciru-ling-runtime/.venv" \
121
+ MODEL_PATH="$HOME/models/Ling-3.0-Flash-CIRU-int4-Strix-native" \
122
+ bash scripts/run-256k.sh
123
+ ```
124
+
125
+ The API advertises model ID `Ling-3.0-Flash-CIRU-int4-Strix-native` on `http://127.0.0.1:18081/v1`.
126
+
127
+ Choose the platform guide before building:
128
+
129
+ - [Native Linux: Ubuntu/Debian, Fedora, Arch, and NixOS notes](docs/UBUNTU_BUILD.md)
130
+ - [Windows 11 through WSL2 and AMD ROCDXG](docs/WINDOWS_WSL2.md)
131
+
132
+ The exact runtime has been validated on CIRU's native-Linux NixOS Strix Halo host. Mainstream native-Linux and Windows/WSL instructions are designed to be reproducible but are not yet CIRU clean-host validations. Native Windows vLLM is not supported; Windows users must use WSL2.
133
+
134
+ ## Context and concurrency
135
+
136
+ The official checkpoint is natively configured and trained for 256K context. `run-256k.sh` uses `max_model_len=262144`, `max_num_seqs=5`, and the validated `gpu_memory_utilization=0.75` long-context envelope. That envelope reported a 2,519,792-token KV pool, enough for five full 256K sequences.
137
+
138
+ Five is also the validated serving safety cap. A six-request 2K+256 simultaneous burst terminated the engine in the chunked-prefill MLA accumulation path with an LSE extent mismatch. With `max_num_seqs=5`, additional requests wait in the scheduler instead of entering that unvalidated C6 path.
139
+
140
+ The 1M profile is an experimental 4x YaRN extension, not native 1M training. It uses two active slots so two full-length requests fit; further requests wait in the vLLM scheduler.
141
+
142
+ ## Does this work for other W4A16 models?
143
+
144
+ The fork remains a vLLM runtime and safely falls back to upstream paths when its guards do not match, but the measured speedups are mostly Ling-specific:
145
+
146
+ - The Wave32 top-k fix is broadly relevant to ROCm Wave32 GPUs.
147
+ - Safe attention merging and uniform verifier routing are relevant to compatible ROCm MLA workloads, independent of W4A16.
148
+ - The W4A16 fast assignment path currently requires 512 experts, top-k 8, block size 32, and one to three tokens.
149
+ - The fast reduction requires hidden size 2560 and top-k 8.
150
+ - The SiLU path requires exact `(8,1536)->(8,768)` or `(16,1536)->(16,768)` BF16 shapes on `gfx1151`.
151
+
152
+ Other W4A16 models will run only if already supported by this vLLM base; they should not be expected to receive these speedups unless their geometry matches. Generalizing those kernels is part of the upstream plan.
153
+
154
+ ## Credits and license
155
+
156
+ - Model and official INT4 weights: [InclusionAI/Ling-3.0-flash-int4](https://huggingface.co/inclusionAI/Ling-3.0-flash-int4), MIT license.
157
+ - Inference engine: [vLLM](https://github.com/vllm-project/vllm), Apache-2.0.
158
+ - ROCm, Torch, and Triton packages: AMD and their respective upstream projects.
159
+ - Strix Halo kernel, TTM/GTT, and WSL/ROCDXG guidance: [AMD ROCm documentation](https://rocm.docs.amd.com/en/docs-7.2.0/how-to/system-optimization/strixhalo.html) and [ROCDXG](https://github.com/ROCm/librocdxg).
160
+ - Runtime integration, profiling, kernels, and validation: CIRU.
161
+
162
+ The original model license continues to govern the weights. The vLLM patch and bundle retain vLLM's upstream licensing and file headers.
SHA256SUMS ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ eb208bf38f31d7b068af8e8351378615017b911eb7d0302264d5398cde5d403e ./.gitattributes
2
+ 411ac21b4849cb3bf65f84a55263550dcd658e0623c2b117233ba1fced1c17ff ./assets/ling30int4.png
3
+ 82cf1d95343c44abfbf6daec0d3e0e23240de2caf44da0e2cc797e94fa2f876c ./CHANGELOG.md
4
+ 26c2195a819fe61daa19b1e73b2371d597240aba0dd5f614719209b9dd76f07f ./config/experimental-yarn-1m.env
5
+ eb4b47674187eaf3035efec1fc0f17a33ac540bf94391cbaae9fec0119ed2fae ./config/native-256k.env
6
+ 788ea98c240e3009cc44b0e1899c87e542f4394922e4ff16a8479c7e1003dc22 ./docs/BENCHMARKS.md
7
+ acdccd00a7605cf06001471cc7cad3f07f8bcd5edafa935cafb521b1d51392d2 ./docs/UBUNTU_BUILD.md
8
+ 0d6258e6b4a896feedcf6bf6d6b332a2a6eabde0f7f657828de81c303c540701 ./docs/VALIDATED_ENVIRONMENT.md
9
+ 3bfadd289f312c0cd99eea1883c7352828268f360b7b5e53c40f3175d6ed1593 ./docs/WINDOWS_WSL2.md
10
+ 88f444c673ba58f9b87d70d664b0876669cf648177358c709dfe180a557ee694 ./MANIFEST.json
11
+ 1618febb4927cc20d6dfc237841b1456e782bbcaf5bb16744996972c7a885a5d ./README.md
12
+ 15e48a8df3b65a73c81cf73c820ba12b4ab9474697d6b3f876c26c0b0cd3d455 ./runtime/COMMITS.txt
13
+ 6b03af3a1685a1969ff96870ea776537f5f67fd3674fc353880bd088bcef9a9c ./runtime/Ling-3.0-Flash-CIRU-int4-Strix-native-vllm.bundle
14
+ 8f307e9f2f16207856ca0b064a765a73bbebc029ad0b0fed61e5975a17e07ab6 ./runtime/Ling-3.0-Flash-CIRU-int4-Strix-native-vllm.patch
15
+ f4caeda80ed751a40fa976aa7853357b88075e6eb6d2d49e68b0bc8599754c34 ./runtime/SHA256SUMS.runtime
16
+ 25ab169703ed6c39260f9336f3d484c9a11b1f9b31c7f9072866b158365de983 ./scripts/build-vllm-gfx1151.sh
17
+ 6a8530b9b38c52d6fe8efab5dd3a6bbf02a3f24a0b9a800b86a6dde3a3103071 ./scripts/download-model.sh
18
+ d6aa5efee74c850f2ab65efeb4dfb66142c440d66276983282de6aec6a855270 ./scripts/install-host-deps.sh
19
+ 27d3cfba9f4178f83cbd2d7e44db098ab69e515f76e5c98c40ac219b7b0597ca ./scripts/run-1m-yarn-experimental.sh
20
+ 296ee94a925db5b97e21afb6ffd4ae3c0cc1c2be67af81e21350f43efaa59ead ./scripts/run-256k.sh
21
+ aa5f1137c666abe07c9fc37a64547dc535d461958db58f7da80beea4133367f9 ./scripts/run-common.sh
assets/ling30int4.png ADDED

Git LFS Details

  • SHA256: 411ac21b4849cb3bf65f84a55263550dcd658e0623c2b117233ba1fced1c17ff
  • Pointer size: 131 Bytes
  • Size of remote file: 226 kB
config/experimental-yarn-1m.env ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ MODEL_ID=Ling-3.0-Flash-CIRU-int4-Strix-native
2
+ CONTEXT_LENGTH=1048576
3
+ MAX_NUM_SEQS=2
4
+ GPU_MEMORY_UTILIZATION=0.82
5
+ SPECULATIVE_TOKENS=1
6
+ HF_OVERRIDES='{"max_position_embeddings":1048576,"rope_scaling":{"rope_type":"yarn","factor":4.0,"original_max_position_embeddings":262144}}'
config/native-256k.env ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ MODEL_ID=Ling-3.0-Flash-CIRU-int4-Strix-native
2
+ CONTEXT_LENGTH=262144
3
+ MAX_NUM_SEQS=5
4
+ GPU_MEMORY_UTILIZATION=0.75
5
+ SPECULATIVE_TOKENS=1
docs/BENCHMARKS.md ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Benchmark notes
2
+
3
+ All results below are local measurements on one Ryzen AI MAX+ 395 / Radeon 8060S Strix Halo system with 128 GB unified memory. They compare complete model-format and runtime stacks; they are not model-quality rankings.
4
+
5
+ ## 60K prompt plus 512-token decode
6
+
7
+ The frozen workload used exactly 60,000 direct prompt tokens, 512 forced output tokens, temperature 0, EOS ignored, a unique cache salt, and no reusable prefix.
8
+
9
+ | Stack | Format/runtime | PP | TG | Request wall |
10
+ |---|---|---:|---:|---:|
11
+ | **CIRU native K1 MTP** | official InclusionAI packed INT4, vLLM/ROCm | **419.33 tok/s** | 19.92 tok/s | **168.75 s** |
12
+ | [AtomicChat AD-IQ4_XXS](https://huggingface.co/AtomicChat/Ling-3.0-flash-GGUF) | mixed GGUF, llama.cpp Vulkan | 265.63 tok/s | **25.11 tok/s** | 246.28 s |
13
+ | [raulvidis ROCmFP4 STRIX MTP](https://huggingface.co/raulvidis/Ling-3.0-flash-ROCmFP4-STRIX-MTP-GGUF) | ROCmFP4 GGUF, llama.cpp Vulkan MTP | 249.23 tok/s | 19.00 tok/s | 267.84 s |
14
+
15
+ At this workload, native vLLM trails Atomic's decode by 20.66% but leads its prefill by 57.87%, completing the combined request 31.48% sooner. Against ROCmFP4, native leads prefill by 68.25%, decode by 4.88%, and combined request time by 37.00%.
16
+
17
+ The native row used the validated `gpu_memory_utilization=0.75`, 262,144-context envelope and K1 MTP. It accepted 254 of 258 draft tokens (98.45%) and completed without cache hits, preemption, JIT during measurement, or device faults.
18
+
19
+ ### Update status
20
+
21
+ The native 60K row was measured at CIRU runtime commit `fabbc7e928dfa64c29dcdf0f795b05246555f4ae`, immediately before the final exact-shape SiLU kernel commit. The released commit `388d82de2abe418e73380ba250270d3abc62ac12` has not yet been rerun on this 60K protocol. The table is therefore a valid retained comparison, but not a claim that 19.92 tok/s is the final commit's maximum 60K speed. Replace the native row only after a matched rerun of all three stacks or a clearly labeled native-only refresh.
22
+
23
+ ## Short decode and concurrent serving
24
+
25
+ - Strict final-commit single-request K1 TG32 median: **26.2343 tok/s**.
26
+ - Highest individual strict final-commit TG32 row: **26.2445 tok/s**.
27
+ - Exact-2K C1 serving sweep: **26.33 tok/s** aggregate decode.
28
+ - Exact-2K C5 serving sweep: **62.16 tok/s** aggregate decode, or 14.40 tok/s per request.
29
+
30
+ Use 26.23 tok/s as the reproducible single-request headline and 62.16 tok/s only when explicitly labeled five-request aggregate throughput.
docs/UBUNTU_BUILD.md ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Linux build guide for Strix Halo
2
+
3
+ This guide covers native Linux on AMD Ryzen AI MAX / MAX+ (`gfx1151`). The release was built and exercised end-to-end on NixOS; Ubuntu/Debian, Fedora, and Arch use the same self-contained ROCm/Torch wheel transaction but remain community portability paths until clean-host reports are retained.
4
+
5
+ ## What is installed where
6
+
7
+ There are two separate layers:
8
+
9
+ 1. The host must expose the Strix Halo GPU through the Linux AMDGPU/KFD driver as `/dev/kfd` and `/dev/dri`.
10
+ 2. `scripts/build-vllm-gfx1151.sh` installs the exact ROCm 7.15, Torch 2.13, Triton 3.8, and development SDK wheels into a private virtual environment. Do not mix a different system PyTorch or ROCm userspace into that environment.
11
+
12
+ The wheel layout and `device-gfx1151` extra come from [AMD TheRock's Python packaging](https://github.com/ROCm/TheRock/blob/main/RELEASES.md). vLLM lists Ryzen AI MAX / `gfx1151` as an AMD ROCm target, but this release needs the included CIRU source delta rather than a stock vLLM wheel.
13
+
14
+ ## Hardware and storage
15
+
16
+ - x86-64 Strix Halo / Radeon 8060S (`gfx1151`)
17
+ - 128 GB unified memory strongly recommended; smaller systems are not expected to fit the 77 GB checkpoint plus runtime and KV cache
18
+ - at least 110 GB free disk for weights, the runtime environment, sources, build outputs, and caches
19
+ - a current BIOS and Linux kernel with the Strix Halo KFD fixes
20
+
21
+ AMD documents the required kernel and memory configuration in its [Strix Halo system-optimization guide](https://rocm.docs.amd.com/en/docs-7.2.0/how-to/system-optimization/strixhalo.html). For generic distributions, Linux 6.18.4 or newer contains the required upstream fixes. AMD also identifies current Fedora, Arch, Ubuntu OEM, and Ubuntu 26.04 paths with those fixes; check the live compatibility table instead of assuming that any kernel carrying an AMDGPU driver is sufficient.
22
+
23
+ ## 1. Verify the host driver
24
+
25
+ After installing the current AMD-supported driver/kernel path for your distribution, add the user to the GPU access groups and reboot:
26
+
27
+ ```bash
28
+ sudo usermod -a -G render,video "$LOGNAME"
29
+ sudo reboot
30
+ ```
31
+
32
+ Then verify:
33
+
34
+ ```bash
35
+ uname -r
36
+ groups
37
+ ls -l /dev/kfd /dev/dri/renderD*
38
+ ```
39
+
40
+ If `/dev/kfd` is absent, stop here. The Python wheels cannot replace a missing kernel driver.
41
+
42
+ ## 2. Configure unified-memory access
43
+
44
+ Strix Halo maps system memory dynamically through GTT/TTM. AMD recommends keeping the fixed BIOS GPU reservation small and increasing the shared TTM limit instead. On CIRU's 128 GB host, the validated mapping limit was 124 GiB. That limit is not a permanent reservation, but the model can still leave very little free RAM during long-context requests.
45
+
46
+ AMD's supported helper is:
47
+
48
+ ```bash
49
+ sudo apt-get install -y pipx
50
+ pipx ensurepath
51
+ pipx install amd-debug-tools
52
+ amd-ttm
53
+ amd-ttm --set 124
54
+ sudo reboot
55
+ ```
56
+
57
+ The first line is the Ubuntu/Debian package name; Fedora and Arch users should install their distribution's `pipx` package instead. Use `124` only on a 128 GB machine. Close other memory-heavy applications before loading the model. A clean 60K+512 run peaked near 117 GB mapped GTT and left about 2 GiB of available RAM.
58
+
59
+ ## 3. Install distro host dependencies
60
+
61
+ The helper supports Ubuntu/Debian, Fedora/RHEL-family systems, and Arch:
62
+
63
+ ```bash
64
+ bash scripts/install-host-deps.sh
65
+ ```
66
+
67
+ It installs a C/C++ toolchain, Git, `curl`, `pkg-config`, NUMA and DRM headers, and `uv`. `uv` then supplies the exact Python 3.12 interpreter, so the host distribution does not need to package `python3.12` itself.
68
+
69
+ ## 4. Build the pinned runtime
70
+
71
+ From the root of this Hugging Face repository:
72
+
73
+ ```bash
74
+ bash scripts/build-vllm-gfx1151.sh "$HOME/ciru-ling-runtime"
75
+ ```
76
+
77
+ The script:
78
+
79
+ - installs the pinned TheRock `device-gfx1151` ROCm/Torch transaction;
80
+ - runs `rocm-sdk init` and `rocm-sdk test`;
81
+ - reconstructs the exact CIRU vLLM commit from the included Git bundle;
82
+ - builds vLLM native extensions for `gfx1151` only;
83
+ - installs the pinned AMD Triton FlashAttention path; and
84
+ - imports every required native vLLM extension.
85
+
86
+ A successful build ends with:
87
+
88
+ ```text
89
+ CIRU vLLM gfx1151 build: PASS
90
+ ```
91
+
92
+ ## 5. Download the unchanged checkpoint and serve
93
+
94
+ ```bash
95
+ export PATH="$HOME/.local/bin:$PATH"
96
+ bash scripts/download-model.sh "$HOME/models"
97
+
98
+ VENV="$HOME/ciru-ling-runtime/.venv" \
99
+ MODEL_PATH="$HOME/models/Ling-3.0-Flash-CIRU-int4-Strix-native" \
100
+ bash scripts/run-256k.sh
101
+ ```
102
+
103
+ In another shell:
104
+
105
+ ```bash
106
+ curl -fsS http://127.0.0.1:18081/health
107
+ curl -fsS http://127.0.0.1:18081/v1/models
108
+ curl -fsS http://127.0.0.1:18081/v1/chat/completions \
109
+ -H 'Content-Type: application/json' \
110
+ -d '{"model":"Ling-3.0-Flash-CIRU-int4-Strix-native","messages":[{"role":"user","content":"Reply with exactly: STRIX READY"}],"temperature":0,"max_tokens":16}'
111
+ ```
112
+
113
+ The native profile uses the validated `gpu_memory_utilization=0.75` envelope, native 262,144 context, K1 MTP, and at most five active requests. Extra requests wait in vLLM's scheduler.
114
+
115
+ ## Portability status
116
+
117
+ | Platform | Status |
118
+ |---|---|
119
+ | NixOS, native Linux, 128 GB Strix Halo | validated build, load, API, correctness, and performance |
120
+ | Ubuntu/Debian native Linux | documented, not yet clean-host validated by CIRU |
121
+ | Fedora / Arch native Linux | dependency path documented; use a kernel carrying AMD's Strix Halo fixes |
122
+ | Windows 11 through WSL2/ROCDXG | experimental; see [WINDOWS_WSL2.md](WINDOWS_WSL2.md) |
123
+ | Native Windows Python | not supported for this vLLM release |
124
+
125
+ When reporting a portability result, include the OS, kernel, GPU identity, `rocm-sdk test` result, build tail, model-load result, and one exact API response.
docs/VALIDATED_ENVIRONMENT.md ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Validated environment
2
+
3
+ ## Hardware
4
+
5
+ - AMD Radeon 8060S / Strix Halo
6
+ - GPU target: `gfx1151`, Wave32
7
+ - 128 GB unified memory
8
+ - Linux TTM/GTT mapping limit: 124 GiB
9
+
10
+ ## Software
11
+
12
+ - NixOS host
13
+ - Python 3.12.12
14
+ - Torch `2.13.0+rocm7.15.0a20260728`
15
+ - HIP `7.15.0`
16
+ - Triton `3.8.0+git4cff872c.rocm7.15.0a20260728`
17
+ - AMD clang 23
18
+ - torchvision `0.28.0+rocm7.15.0a20260728`
19
+ - torchaudio `2.11.0.2+rocm7.15.0a20260728`
20
+ - FlashAttention `2.8.3`, Dao-AILab commit `0e60e39473e8df549a20fb5353760f7a65b30e2d`, Python-only AMD Triton path
21
+ - vLLM upstream base `d35eb6c44071ea806018841c490f0d2f3219c485`
22
+ - CIRU runtime head `388d82de2abe418e73380ba250270d3abc62ac12`
23
+
24
+ ## Build facts
25
+
26
+ - Fresh Python 3.12 environment.
27
+ - Exact AMD multi-architecture wheel transaction installed in one resolver operation.
28
+ - `rocm-sdk init` and all 27 SDK tests passed.
29
+ - vLLM compiled for `gfx1151` only with 16 jobs.
30
+ - Clean native build completed in 92 seconds on the validation host.
31
+ - Imports passed for `vllm._C`, `vllm._C_stable_libtorch`, `vllm._moe_C_stable_libtorch`, `vllm._rocm_C`, and `vllm.cumem_allocator`.
32
+
33
+ The Ubuntu/Debian, Fedora, Arch, and Windows/WSL build paths in this package are portability candidates and have not yet been clean-host validated by CIRU.
34
+
35
+ The published native-256K launcher uses the separately validated `gpu_memory_utilization=0.75` long-context envelope. It exposed a 2,519,792-token KV pool and completed the frozen 60K+512 workload without faults, although system-memory margin was only about 2 GiB at peak.
docs/WINDOWS_WSL2.md ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Windows 11 through WSL2 and AMD ROCDXG
2
+
3
+ This runtime does not build as a native Windows vLLM application. Windows users must run the Linux build inside WSL2 and expose the Strix Halo GPU through AMD's ROCDXG layer.
4
+
5
+ AMD now supports Strix Halo under WSL2, but CIRU has not yet validated this exact ROCm 7.15 nightly runtime under ROCDXG. Treat this as an experimental portability path and report results before calling it production-ready.
6
+
7
+ ## Requirements
8
+
9
+ - Windows 11 on a 128 GB Ryzen AI MAX / MAX+ Strix Halo system
10
+ - a current AMD Windows driver compatible with ROCDXG
11
+ - current WSL2 with Ubuntu 24.04 or another distribution listed in AMD's live compatibility matrix
12
+ - at least 110 GB free storage inside WSL or on a fast WSL virtual disk
13
+
14
+ Use AMD's current [ROCm on Ryzen WSL guide](https://rocm.docs.amd.com/projects/radeon-ryzen/en/latest/docs/install/installryz/wsl/howto_wsl.html) and the [ROCDXG quickstart and compatibility matrix](https://github.com/ROCm/librocdxg). Do not follow older `roc4wsl` instructions.
15
+
16
+ ## 1. Install and size WSL2
17
+
18
+ In an elevated PowerShell window:
19
+
20
+ ```powershell
21
+ wsl --install -d Ubuntu-24.04
22
+ wsl --update
23
+ wsl --shutdown
24
+ ```
25
+
26
+ For a 128 GB machine, create `%UserProfile%\.wslconfig` with a large WSL memory ceiling:
27
+
28
+ ```ini
29
+ [wsl2]
30
+ memory=120GB
31
+ swap=16GB
32
+ ```
33
+
34
+ Then run `wsl --shutdown` again. This allocation is intentionally large because the checkpoint is 77 GB before KV cache and runtime overhead. It leaves little room for Windows applications; close memory-heavy programs before serving. The 60K benchmark has not been validated under WSL.
35
+
36
+ ## 2. Install the AMD Windows driver and ROCDXG
37
+
38
+ Follow AMD's live guide in this order:
39
+
40
+ 1. Install the compatible AMD Windows driver.
41
+ 2. Install the ROCm packages inside the WSL distribution using AMD's current quickstart.
42
+ 3. Install the matching ROCDXG release, either from its `.deb` package or source instructions.
43
+ 4. Restart WSL.
44
+
45
+ Inside Ubuntu, verify that the bridge is active:
46
+
47
+ ```bash
48
+ test -e /dev/dxg
49
+ rocminfo | grep -A4 -B2 gfx1151
50
+ ```
51
+
52
+ Do not proceed until `rocminfo` identifies `gfx1151`. Native-Linux `/dev/kfd` instructions do not apply to the WSL bridge.
53
+
54
+ ## 3. Clone and build the CIRU runtime
55
+
56
+ Inside WSL:
57
+
58
+ ```bash
59
+ git clone https://huggingface.co/jcbtc/Ling-3.0-Flash-CIRU-int4-Strix-native
60
+ cd Ling-3.0-Flash-CIRU-int4-Strix-native
61
+
62
+ bash scripts/install-host-deps.sh
63
+ bash scripts/build-vllm-gfx1151.sh "$HOME/ciru-ling-runtime"
64
+ ```
65
+
66
+ The build script detects WSL and refuses to continue when `/dev/dxg` is absent. It installs the release's pinned Linux ROCm/Torch userspace in its own virtual environment; do not install a separate PyTorch into that environment.
67
+
68
+ ## 4. Download and serve
69
+
70
+ ```bash
71
+ export PATH="$HOME/.local/bin:$PATH"
72
+ bash scripts/download-model.sh "$HOME/models"
73
+
74
+ VENV="$HOME/ciru-ling-runtime/.venv" \
75
+ MODEL_PATH="$HOME/models/Ling-3.0-Flash-CIRU-int4-Strix-native" \
76
+ bash scripts/run-256k.sh
77
+ ```
78
+
79
+ Verify `/health`, `/v1/models`, and an exact short completion using the commands in [UBUNTU_BUILD.md](UBUNTU_BUILD.md).
80
+
81
+ ## Known WSL boundaries
82
+
83
+ - Native Windows ROCm PyTorch support does not imply native Windows vLLM support.
84
+ - ROCDXG's supported ROCm/driver combinations change independently; use its live matrix.
85
+ - AMD documents limited profiling support under WSL.
86
+ - Very large WSL memory mappings are sensitive to `.wslconfig`, host pressure, and the Windows driver.
87
+ - The published Linux performance numbers must not be presented as WSL performance until measured there.
runtime/COMMITS.txt ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ c3f74efb866edba8892f18506b1c4febc157a799 [Bugfix][Kernel][ROCm] Fix Wave32 LDS overflow in top-k merge launch
2
+ abefcfad484b85af6f57703c815a5f169807a3fd research(profile): annotate Ling decoder families
3
+ a73488d0243736797f75412ad23549cada767a47 Revert "research(profile): annotate Ling decoder families"
4
+ c7e91b99ce98786dad42f830965759e1ff1f74ac Reapply "research(profile): annotate Ling decoder families"
5
+ d8481aec96d9a3caca7323f5d6b5bcef3f0fb8ed Revert "Reapply "research(profile): annotate Ling decoder families""
6
+ 8457fad14b028e1c443cb4c5998df377873e3d95 Enable native merge attention states on ROCm
7
+ 8743a17f147d899d670af9b808d5bf93a5bf26fb Revert "Enable native merge attention states on ROCm"
8
+ 7deddd0a87a94637e4fbe2d309a484ab9a04e33f Add opt-in safe ROCm attention merge
9
+ 3715c596c1a0df9d42d133a61d14dbed5105ab0a Handle MLA LSE layouts in safe ROCm merge
10
+ f6773b23215df5aa2a8de5050bd2f9b6fa53b727 ROCm: route uniform MLA verify blocks through causal decode
11
+ 15a4190ddf0a363e08d518345a8f3e23e8bc8bd9 Optimize decode WNA16 expert assignment
12
+ abfff126e0698d98f1872f87f501d36a19382240 Optimize single-token MoE reduction
13
+ 928e725a9dbcdbea0bf6c914c8b3fe93f08b0d3f Optimize K2 verification MoE support kernels
14
+ fabbc7e928dfa64c29dcdf0f795b05246555f4ae Extend MoE support fast path to K1 verification
15
+ 388d82de2abe418e73380ba250270d3abc62ac12 ROCm: optimize exact small WNA16 SiLU activation
runtime/Ling-3.0-Flash-CIRU-int4-Strix-native-vllm.bundle ADDED
Binary file (12.4 kB). View file
 
runtime/Ling-3.0-Flash-CIRU-int4-Strix-native-vllm.patch ADDED
@@ -0,0 +1,550 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/csrc/libtorch_stable/sampler.cu b/csrc/libtorch_stable/sampler.cu
2
+ index 519e213281cd07a9a4cc81f7bc5fcb843277528d..847d8284afc992c3f75e2d65f240afe3d3d0e0e3 100644
3
+ --- a/csrc/libtorch_stable/sampler.cu
4
+ +++ b/csrc/libtorch_stable/sampler.cu
5
+ @@ -711,7 +711,12 @@ void top_k_per_row_decode(const torch::stable::Tensor& logits, int64_t next_n,
6
+ static_cast<int>(next_n), seqLensIs2D,
7
+ outLogitsAux.mutable_data_ptr<float>());
8
+
9
+ +#ifndef USE_ROCM
10
+ constexpr int kNumThreadsPerBlockMerge = 1024;
11
+ +#else
12
+ + // 1024 threads exceed the 64 KB LDS limit on Wave32 GPUs.
13
+ + constexpr int kNumThreadsPerBlockMerge = 512;
14
+ +#endif
15
+ vllm::topKPerRowDecode<kNumThreadsPerBlockMerge, true, false, true>
16
+ <<<numRows, kNumThreadsPerBlockMerge, topK * sizeof(int32_t), stream>>>(
17
+ outLogitsAux.const_data_ptr<float>(), seqLens.const_data_ptr<int>(),
18
+ diff --git a/vllm/model_executor/layers/fused_moe/experts/triton_moe.py b/vllm/model_executor/layers/fused_moe/experts/triton_moe.py
19
+ index 9d93dfe54ac1a81d5c1f512bc266b9732506e31a..dd96f6da4cc3e3655bbab58f64ceed0882f2e7c0 100644
20
+ --- a/vllm/model_executor/layers/fused_moe/experts/triton_moe.py
21
+ +++ b/vllm/model_executor/layers/fused_moe/experts/triton_moe.py
22
+ @@ -27,6 +27,7 @@ from vllm.model_executor.layers.fused_moe.fused_moe import (
23
+ from vllm.model_executor.layers.fused_moe.moe_align_block_size import (
24
+ moe_align_block_size,
25
+ )
26
+ +from vllm.model_executor.layers.fused_moe.moe_fused_mul_sum import moe_sum_decode
27
+ from vllm.model_executor.layers.fused_moe.topk_weight_and_reduce import (
28
+ TopKWeightAndReduceNoOP,
29
+ )
30
+ @@ -55,10 +56,100 @@ from vllm.model_executor.layers.quantization.utils.quant_utils import (
31
+ kInt8StaticTensorSym,
32
+ )
33
+ from vllm.platforms import current_platform
34
+ -from vllm.triton_utils import tl
35
+ +from vllm.triton_utils import tl, triton
36
+ from vllm.utils.multi_stream_utils import maybe_execute_in_parallel
37
+
38
+
39
+ +def _use_wna16_naive_block_assignment(
40
+ + *,
41
+ + num_tokens: int,
42
+ + top_k: int,
43
+ + num_experts: int,
44
+ + global_num_experts: int,
45
+ + block_size_m: int,
46
+ + expert_map: torch.Tensor | None,
47
+ + use_int4_w4a16: bool,
48
+ + block_shape: list[int] | None,
49
+ +) -> bool:
50
+ + """Select the narrowly validated gfx1151 WNA16 small-token fast path."""
51
+ + return (
52
+ + num_tokens in (1, 2, 3)
53
+ + and top_k == 8
54
+ + and num_experts == 512
55
+ + and global_num_experts == 512
56
+ + and block_size_m == 16
57
+ + and expert_map is None
58
+ + and use_int4_w4a16
59
+ + and block_shape == [0, 32]
60
+ + )
61
+ +
62
+ +
63
+ +_WNA16_SILU_OUTPUT_SIZE = 768
64
+ +_WNA16_SILU_BLOCK_SIZE = 128
65
+ +
66
+ +
67
+ +@triton.jit
68
+ +def _wna16_exact_silu_and_mul_kernel(
69
+ + input_ptr,
70
+ + output_ptr,
71
+ + OUTPUT_SIZE: tl.constexpr,
72
+ + BLOCK_SIZE: tl.constexpr,
73
+ +):
74
+ + row = tl.program_id(0)
75
+ + block = tl.program_id(1)
76
+ + offsets = block * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)
77
+ + mask = offsets < OUTPUT_SIZE
78
+ + row_input = input_ptr + row * (2 * OUTPUT_SIZE)
79
+ + gate = tl.load(row_input + offsets, mask=mask, other=0.0).to(tl.float32)
80
+ + up = tl.load(row_input + OUTPUT_SIZE + offsets, mask=mask, other=0.0).to(
81
+ + tl.float32
82
+ + )
83
+ +
84
+ + # Match the native packed HIP kernel's intermediate BF16 rounding.
85
+ + activated = (gate * tl.sigmoid(gate)).to(tl.bfloat16).to(tl.float32)
86
+ + tl.store(
87
+ + output_ptr + row * OUTPUT_SIZE + offsets,
88
+ + activated * up,
89
+ + mask=mask,
90
+ + )
91
+ +
92
+ +
93
+ +def _use_wna16_exact_silu_and_mul(
94
+ + output: torch.Tensor, input: torch.Tensor
95
+ +) -> bool:
96
+ + if torch.compiler.is_compiling() or not current_platform.is_rocm():
97
+ + return False
98
+ + from vllm.platforms.rocm import on_gfx1151
99
+ +
100
+ + return (
101
+ + on_gfx1151()
102
+ + and input.is_cuda
103
+ + and output.is_cuda
104
+ + and input.dtype == torch.bfloat16
105
+ + and output.dtype == torch.bfloat16
106
+ + and input.is_contiguous()
107
+ + and output.is_contiguous()
108
+ + and input.shape in ((8, 1536), (16, 1536))
109
+ + and output.shape == (input.shape[0], _WNA16_SILU_OUTPUT_SIZE)
110
+ + )
111
+ +
112
+ +
113
+ +def _invoke_wna16_exact_silu_and_mul(
114
+ + output: torch.Tensor, input: torch.Tensor
115
+ +) -> None:
116
+ + grid = (
117
+ + input.shape[0],
118
+ + triton.cdiv(_WNA16_SILU_OUTPUT_SIZE, _WNA16_SILU_BLOCK_SIZE),
119
+ + )
120
+ + _wna16_exact_silu_and_mul_kernel[grid](
121
+ + input,
122
+ + output,
123
+ + OUTPUT_SIZE=_WNA16_SILU_OUTPUT_SIZE,
124
+ + BLOCK_SIZE=_WNA16_SILU_BLOCK_SIZE,
125
+ + num_warps=1,
126
+ + )
127
+ +
128
+ +
129
+ class TritonExperts(LoRAExpertsMixin, mk.FusedMoEExpertsModular):
130
+ """Triton-based fused MoE expert implementation."""
131
+
132
+ @@ -603,6 +694,33 @@ class TritonWNA16Experts(TritonExperts):
133
+ or moe_parallel_config.use_fi_nvl_one_sided_kernels
134
+ )
135
+
136
+ + def activation(
137
+ + self,
138
+ + activation: MoEActivation,
139
+ + output: torch.Tensor,
140
+ + input: torch.Tensor,
141
+ + **kwargs,
142
+ + ) -> None:
143
+ + # Keep compiled MLA-side MoE activations on Inductor's fused pointwise
144
+ + # route. The exact KDA-side eager shapes otherwise pay the high fixed
145
+ + # latency of the generic HIP activation kernel on gfx1151.
146
+ + if (
147
+ + activation == MoEActivation.SILU
148
+ + and self.activation_config.clamp_limit is None
149
+ + and self.quant_config.use_int4_w4a16
150
+ + and self.block_shape == [0, 32]
151
+ + and _use_wna16_exact_silu_and_mul(output, input)
152
+ + ):
153
+ + _invoke_wna16_exact_silu_and_mul(output, input)
154
+ + return
155
+ +
156
+ + super().activation(
157
+ + activation,
158
+ + output,
159
+ + input,
160
+ + **kwargs,
161
+ + )
162
+ +
163
+ def apply(
164
+ self,
165
+ output: torch.Tensor,
166
+ @@ -681,9 +799,35 @@ class TritonWNA16Experts(TritonExperts):
167
+ )
168
+ intermediate_cache3 = _resize_cache(workspace2, (num_tokens, top_k_num, K))
169
+
170
+ - sorted_token_ids, expert_ids, num_tokens_post_padded = moe_align_block_size(
171
+ - topk_ids, config["BLOCK_SIZE_M"], global_num_experts, expert_map
172
+ + use_naive_block_assignment = _use_wna16_naive_block_assignment(
173
+ + num_tokens=num_tokens,
174
+ + top_k=top_k_num,
175
+ + num_experts=E,
176
+ + global_num_experts=global_num_experts,
177
+ + block_size_m=config["BLOCK_SIZE_M"],
178
+ + expert_map=expert_map,
179
+ + use_int4_w4a16=self.quant_config.use_int4_w4a16,
180
+ + block_shape=self.block_shape,
181
+ )
182
+ + use_naive_block_assignment = (
183
+ + use_naive_block_assignment
184
+ + and topk_ids.shape == (num_tokens, top_k_num)
185
+ + and topk_ids.is_contiguous()
186
+ + )
187
+ + if use_naive_block_assignment:
188
+ + sorted_token_ids = None
189
+ + expert_ids = topk_ids.view(-1)
190
+ + # Compile-time dead in the naive kernel specialization.
191
+ + num_tokens_post_padded = expert_ids
192
+ + else:
193
+ + sorted_token_ids, expert_ids, num_tokens_post_padded = (
194
+ + moe_align_block_size(
195
+ + topk_ids,
196
+ + config["BLOCK_SIZE_M"],
197
+ + global_num_experts,
198
+ + expert_map,
199
+ + )
200
+ + )
201
+
202
+ invoke_fused_moe_wna16_triton_kernel(
203
+ hidden_states,
204
+ @@ -737,5 +881,20 @@ class TritonWNA16Experts(TritonExperts):
205
+ block_shape=self.block_shape,
206
+ )
207
+
208
+ - # separate function is required for MoE + LoRA
209
+ - self.moe_sum(intermediate_cache3, output)
210
+ + # The native HIP top-k sum has very high fixed latency on gfx1151 for
211
+ + # the exact target-decode and K1/K2 verification shapes. Keep every
212
+ + # adjacent shape on the native implementation.
213
+ + if (
214
+ + use_naive_block_assignment
215
+ + and self._lora_context is None
216
+ + and intermediate_cache3.shape
217
+ + in ((1, 8, 2560), (2, 8, 2560), (3, 8, 2560))
218
+ + and output.shape in ((1, 2560), (2, 2560), (3, 2560))
219
+ + and output.shape[0] == intermediate_cache3.shape[0]
220
+ + and intermediate_cache3.is_contiguous()
221
+ + and output.is_contiguous()
222
+ + ):
223
+ + moe_sum_decode(intermediate_cache3, output)
224
+ + else:
225
+ + # separate function is required for MoE + LoRA
226
+ + self.moe_sum(intermediate_cache3, output)
227
+ diff --git a/vllm/model_executor/layers/fused_moe/fused_moe.py b/vllm/model_executor/layers/fused_moe/fused_moe.py
228
+ index be4930052a9a1c883679f7e7415853b2f9c9f667..034c963b7cee65d253e9c27517463c2e59b2d1c0 100644
229
+ --- a/vllm/model_executor/layers/fused_moe/fused_moe.py
230
+ +++ b/vllm/model_executor/layers/fused_moe/fused_moe.py
231
+ @@ -97,6 +97,7 @@ def fused_moe_kernel_gptq_awq(
232
+ stride_bzn,
233
+ block_k_diviable: tl.constexpr,
234
+ group_size: tl.constexpr,
235
+ + naive_block_assignment: tl.constexpr,
236
+ # Meta-parameters
237
+ BLOCK_SIZE_M: tl.constexpr,
238
+ BLOCK_SIZE_N: tl.constexpr,
239
+ @@ -155,12 +156,20 @@ def fused_moe_kernel_gptq_awq(
240
+ # and accumulate
241
+ # `a_ptrs` is a block of [BLOCK_SIZE_M, BLOCK_SIZE_K] pointers
242
+ # `b_ptrs` is a block of [BLOCK_SIZE_K, BLOCK_SIZE_N] pointers
243
+ - num_tokens_post_padded = tl.load(num_tokens_post_padded_ptr)
244
+ - if pid_m * BLOCK_SIZE_M >= num_tokens_post_padded:
245
+ - return
246
+ - offs_token_id = pid_m * BLOCK_SIZE_M + tl.arange(0, BLOCK_SIZE_M).to(tl.int64)
247
+ + offs = tl.arange(0, BLOCK_SIZE_M).to(tl.int64)
248
+ + if not naive_block_assignment:
249
+ + num_tokens_post_padded = tl.load(num_tokens_post_padded_ptr)
250
+ + if pid_m * BLOCK_SIZE_M >= num_tokens_post_padded:
251
+ + return
252
+ + offs_token_id = pid_m * BLOCK_SIZE_M + offs
253
+ + offs_token = tl.load(sorted_token_ids_ptr + offs_token_id)
254
+ + else:
255
+ + # Decode-only fast path: one routed token per program. The remaining
256
+ + # lanes are masked so no alignment, sorting, or padded-count load is
257
+ + # needed.
258
+ + offs_token = tl.where(offs == 0, pid_m, num_valid_tokens)
259
+ # Cast to int64 to prevent overflow in stride*offset products
260
+ - offs_token = tl.load(sorted_token_ids_ptr + offs_token_id).to(tl.int64)
261
+ + offs_token = offs_token.to(tl.int64)
262
+ token_mask = offs_token < num_valid_tokens
263
+
264
+ off_experts = tl.load(expert_ids_ptr + pid_m).to(tl.int64)
265
+ @@ -677,7 +686,7 @@ def invoke_fused_moe_wna16_triton_kernel(
266
+ B_scale: torch.Tensor | None,
267
+ B_zp: torch.Tensor | None,
268
+ topk_weights: torch.Tensor | None,
269
+ - sorted_token_ids: torch.Tensor,
270
+ + sorted_token_ids: torch.Tensor | None,
271
+ expert_ids: torch.Tensor,
272
+ num_tokens_post_padded: torch.Tensor,
273
+ mul_routed_weight: bool,
274
+ @@ -695,8 +704,11 @@ def invoke_fused_moe_wna16_triton_kernel(
275
+ M = A.size(0)
276
+ num_tokens = M * top_k
277
+
278
+ - EM = sorted_token_ids.size(0)
279
+ - if A.size(0) < config["BLOCK_SIZE_M"]:
280
+ + if sorted_token_ids is None:
281
+ + EM = num_tokens * config["BLOCK_SIZE_M"]
282
+ + else:
283
+ + EM = sorted_token_ids.size(0)
284
+ + if sorted_token_ids is not None and A.size(0) < config["BLOCK_SIZE_M"]:
285
+ # optimize for small batch_size.
286
+ # We assume that top_ids of each token is unique,
287
+ # so num_valid_experts <= batch_size <= BLOCK_SIZE_M,
288
+ @@ -756,6 +768,7 @@ def invoke_fused_moe_wna16_triton_kernel(
289
+ has_zp=B_zp is not None,
290
+ use_int4_w4a16=use_int4_w4a16,
291
+ use_int8_w8a16=use_int8_w8a16,
292
+ + naive_block_assignment=(sorted_token_ids is None),
293
+ **config,
294
+ )
295
+
296
+ diff --git a/vllm/model_executor/layers/fused_moe/moe_fused_mul_sum.py b/vllm/model_executor/layers/fused_moe/moe_fused_mul_sum.py
297
+ index 768f41db854e0d532d5faeb3379eab1ab8ad5ef4..827f19fdd2117821861e89cb29571875d56257c0 100644
298
+ --- a/vllm/model_executor/layers/fused_moe/moe_fused_mul_sum.py
299
+ +++ b/vllm/model_executor/layers/fused_moe/moe_fused_mul_sum.py
300
+ @@ -7,6 +7,55 @@ from vllm.platforms import current_platform
301
+ from vllm.triton_utils import tl, triton
302
+
303
+
304
+ +@triton.jit
305
+ +def moe_sum_decode_kernel(
306
+ + input_ptr,
307
+ + output_ptr,
308
+ + size: tl.constexpr,
309
+ + top_k: tl.constexpr,
310
+ + BLOCK_K: tl.constexpr,
311
+ +):
312
+ + """Sum a small token batch's routed outputs in fixed route order."""
313
+ + token = tl.program_id(1)
314
+ + offsets = tl.program_id(0) * BLOCK_K + tl.arange(0, BLOCK_K)
315
+ + mask = offsets < size
316
+ + accumulator = tl.zeros((BLOCK_K,), dtype=tl.float32)
317
+ + for route in tl.static_range(top_k):
318
+ + value = tl.load(
319
+ + input_ptr + (token * top_k + route) * size + offsets,
320
+ + mask=mask,
321
+ + other=0.0,
322
+ + )
323
+ + accumulator += value.to(tl.float32)
324
+ + tl.store(output_ptr + token * size + offsets, accumulator, mask=mask)
325
+ +
326
+ +
327
+ +def moe_sum_decode(
328
+ + inputs: torch.Tensor,
329
+ + output: torch.Tensor,
330
+ +) -> torch.Tensor:
331
+ + """Low-launch-overhead sum for exact Ling WNA16 decode/verify shapes."""
332
+ + assert inputs.shape in ((1, 8, 2560), (2, 8, 2560), (3, 8, 2560))
333
+ + assert output.shape in ((1, 2560), (2, 2560), (3, 2560))
334
+ + assert output.shape[0] == inputs.shape[0]
335
+ + assert inputs.dtype == torch.bfloat16
336
+ + assert output.dtype == torch.bfloat16
337
+ + assert inputs.is_contiguous()
338
+ + assert output.is_contiguous()
339
+ +
340
+ + if not isinstance(inputs, FakeTensor):
341
+ + moe_sum_decode_kernel[(5, inputs.shape[0])](
342
+ + inputs,
343
+ + output,
344
+ + size=2560,
345
+ + top_k=8,
346
+ + BLOCK_K=512,
347
+ + num_warps=4,
348
+ + num_stages=2,
349
+ + )
350
+ + return output
351
+ +
352
+ +
353
+ @triton.jit
354
+ def moe_fused_mul_sum_kernel(
355
+ inputs_ptr,
356
+ diff --git a/vllm/v1/attention/backends/mla/triton_mla.py b/vllm/v1/attention/backends/mla/triton_mla.py
357
+ index 71a38e95d0ad49fd6a0511cf6613b5cab1f62af0..641f68b166ff4b4269eb7ec6f07b5cead3849a38 100644
358
+ --- a/vllm/v1/attention/backends/mla/triton_mla.py
359
+ +++ b/vllm/v1/attention/backends/mla/triton_mla.py
360
+ @@ -13,6 +13,7 @@ from vllm.model_executor.layers.attention.mla_attention import (
361
+ MLACommonImpl,
362
+ MLACommonMetadata,
363
+ MLACommonMetadataBuilder,
364
+ + QueryLenSupport,
365
+ )
366
+ from vllm.platforms import current_platform
367
+ from vllm.platforms.interface import DeviceCapability
368
+ @@ -51,6 +52,9 @@ class TritonMLAMetadataBuilder(MLACommonMetadataBuilder[MLACommonMetadata]):
369
+ _cudagraph_support: ClassVar[AttentionCGSupport] = (
370
+ AttentionCGSupport.UNIFORM_SINGLE_TOKEN_DECODE
371
+ )
372
+ + # Uniform multi-token groups (for example MTP verification) can use the
373
+ + # decode kernel when each query row is mapped to its causal KV prefix.
374
+ + query_len_support: ClassVar[QueryLenSupport] = QueryLenSupport.UNIFORM
375
+ # Non-causal DSpark block is flattened to one decode row per query token in
376
+ # forward_mqa, so no intra-block causal masking is required.
377
+ supports_non_causal_multi_token_decode: ClassVar[bool] = True
378
+ @@ -74,12 +78,10 @@ class TritonMLAMetadataBuilder(MLACommonMetadataBuilder[MLACommonMetadata]):
379
+ """
380
+ if not is_workspace_manager_initialized():
381
+ return
382
+ - # Decode reorder threshold is 1, so decode tokens <= max_num_seqs.
383
+ + # Uniform multi-token decode flattens each request's block to query_len
384
+ + # rows. Reserve the largest admitted block before the workspace locks.
385
+ B = self.vllm_config.scheduler_config.max_num_seqs
386
+ - # Non-causal DSpark draft flattens each request's block to query_len
387
+ - # decode rows; cover max_num_seqs * block_len rows.
388
+ - if getattr(self, "non_causal_multi_token_decode", False):
389
+ - B *= self.reorder_batch_threshold
390
+ + B *= self.reorder_batch_threshold or 1
391
+ # DCP all-gathers the query heads before forward_mqa.
392
+ q_num_heads = self.num_heads * self.dcp_world_size
393
+ max_splits = _compute_num_kv_splits(
394
+ @@ -285,14 +287,34 @@ class TritonMLAImpl(MLACommonImpl[MLACommonMetadata]):
395
+
396
+ block_table = attn_metadata.decode.block_table
397
+ seq_lens = attn_metadata.decode.seq_lens
398
+ - if not attn_metadata.causal:
399
+ - # Non-causal DSpark block: flatten to one decode row per query token.
400
+ - # Each row attends to the same committed KV prefix (per-row seq_lens)
401
+ - # and never to sibling block tokens = non-causal block semantics.
402
+ - # Mirrors FlashInferMLA's non-causal path.
403
+ - query_len = attn_metadata.num_decode_tokens // attn_metadata.num_decodes
404
+ - if query_len > 1:
405
+ - block_table = block_table.repeat_interleave(query_len, dim=0)
406
+ + num_decodes = attn_metadata.num_decodes
407
+ + num_decode_tokens = attn_metadata.num_decode_tokens
408
+ + assert num_decodes > 0
409
+ + assert num_decode_tokens == B
410
+ + assert num_decode_tokens % num_decodes == 0
411
+ +
412
+ + query_len = num_decode_tokens // num_decodes
413
+ + if query_len > 1:
414
+ + block_table = block_table.repeat_interleave(query_len, dim=0)
415
+ + if attn_metadata.causal:
416
+ + logger.info_once(
417
+ + "Triton MLA A1 causal spec-as-decode route active: "
418
+ + "query_len=%d",
419
+ + query_len,
420
+ + )
421
+ + # seq_lens includes the whole verify block. Row t may attend
422
+ + # only through its own position: context + t + 1.
423
+ + token_offsets = torch.arange(
424
+ + query_len,
425
+ + device=seq_lens.device,
426
+ + dtype=seq_lens.dtype,
427
+ + )
428
+ + seq_lens = (
429
+ + seq_lens.unsqueeze(1) - (query_len - 1) + token_offsets
430
+ + ).clamp_min(0).flatten()
431
+ + else:
432
+ + # Non-causal DSpark rows share the committed KV prefix and do
433
+ + # not attend to sibling block tokens.
434
+ seq_lens = seq_lens.repeat_interleave(query_len)
435
+
436
+ # Run MQA — always pass layer scales. When KV cache is
437
+ diff --git a/vllm/v1/attention/ops/merge_attn_states.py b/vllm/v1/attention/ops/merge_attn_states.py
438
+ index 20c7503e9d0518a1c9459c6a599708f94a2bae62..cc860e1ab26ca78bf747a00b160314c4d740c5b1 100644
439
+ --- a/vllm/v1/attention/ops/merge_attn_states.py
440
+ +++ b/vllm/v1/attention/ops/merge_attn_states.py
441
+ @@ -1,11 +1,87 @@
442
+ # SPDX-License-Identifier: Apache-2.0
443
+ # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
444
+
445
+ +import os
446
+ +
447
+ import torch
448
+
449
+ from vllm.platforms import current_platform
450
+
451
+
452
+ +def _merge_attn_states_torch(
453
+ + output: torch.Tensor,
454
+ + prefix_output: torch.Tensor,
455
+ + prefix_lse: torch.Tensor,
456
+ + suffix_output: torch.Tensor,
457
+ + suffix_lse: torch.Tensor,
458
+ + output_lse: torch.Tensor | None,
459
+ + prefill_tokens_with_context: int | None,
460
+ +) -> None:
461
+ + """Safe ROCm fallback for the Triton merge kernel.
462
+ +
463
+ + This follows the reference implementation in
464
+ + tests/kernels/attention/test_merge_attn_states.py. It is intentionally
465
+ + opt-in because it trades a small amount of prefill performance for avoiding
466
+ + gfx1151 HSA memory faults in merge_attn_states_kernel.
467
+ + """
468
+ + num_context_tokens = (
469
+ + output.shape[0]
470
+ + if prefill_tokens_with_context is None
471
+ + else prefill_tokens_with_context
472
+ + )
473
+ + tokens_first_lse = prefix_lse.shape[:2] == output.shape[:2]
474
+ + if num_context_tokens:
475
+ + if tokens_first_lse:
476
+ + p_lse = prefix_lse[:num_context_tokens, :].clone()
477
+ + s_lse = suffix_lse[:num_context_tokens, :].clone()
478
+ + else:
479
+ + p_lse = prefix_lse[:, :num_context_tokens].clone()
480
+ + s_lse = suffix_lse[:, :num_context_tokens].clone()
481
+ + p_lse[p_lse == torch.inf] = -torch.inf
482
+ + s_lse[s_lse == torch.inf] = -torch.inf
483
+ + max_lse = torch.maximum(p_lse, s_lse)
484
+ + p_exp = torch.nan_to_num(torch.exp(p_lse - max_lse), nan=0.0)
485
+ + s_exp = torch.nan_to_num(torch.exp(s_lse - max_lse), nan=0.0)
486
+ + denom = p_exp + s_exp
487
+ + p_scale = torch.where(denom > 0, p_exp / denom, 0.0)
488
+ + s_scale = torch.where(denom > 0, s_exp / denom, 0.0)
489
+ + p_scale_output_layout = (
490
+ + p_scale.unsqueeze(-1)
491
+ + if tokens_first_lse
492
+ + else p_scale.transpose(0, 1).unsqueeze(-1)
493
+ + )
494
+ + s_scale_output_layout = (
495
+ + s_scale.unsqueeze(-1)
496
+ + if tokens_first_lse
497
+ + else s_scale.transpose(0, 1).unsqueeze(-1)
498
+ + )
499
+ + merged = (
500
+ + prefix_output[:num_context_tokens]
501
+ + * p_scale_output_layout
502
+ + + suffix_output[:num_context_tokens]
503
+ + * s_scale_output_layout
504
+ + )
505
+ + output[:num_context_tokens].copy_(merged.to(output.dtype))
506
+ + if output_lse is not None:
507
+ + merged_lse = torch.logaddexp(p_lse, s_lse)
508
+ + if tokens_first_lse:
509
+ + output_lse[:num_context_tokens, :].copy_(merged_lse)
510
+ + else:
511
+ + output_lse[:, :num_context_tokens].copy_(merged_lse)
512
+ +
513
+ + if num_context_tokens < output.shape[0]:
514
+ + output[num_context_tokens:].copy_(suffix_output[num_context_tokens:])
515
+ + if output_lse is not None:
516
+ + if tokens_first_lse:
517
+ + output_lse[num_context_tokens:, :].copy_(
518
+ + suffix_lse[num_context_tokens:, :]
519
+ + )
520
+ + else:
521
+ + output_lse[:, num_context_tokens:].copy_(
522
+ + suffix_lse[:, num_context_tokens:]
523
+ + )
524
+ +
525
+ +
526
+ def merge_attn_states(
527
+ output: torch.Tensor,
528
+ prefix_output: torch.Tensor,
529
+ @@ -46,6 +122,21 @@ def merge_attn_states(
530
+ When provided, output must be FP8 dtype.
531
+ """
532
+
533
+ + if (
534
+ + current_platform.is_rocm()
535
+ + and os.getenv("VLLM_ROCM_SAFE_MERGE_ATTN_STATES", "0") == "1"
536
+ + and output_scale is None
537
+ + ):
538
+ + return _merge_attn_states_torch(
539
+ + output,
540
+ + prefix_output,
541
+ + prefix_lse,
542
+ + suffix_output,
543
+ + suffix_lse,
544
+ + output_lse,
545
+ + prefill_tokens_with_context,
546
+ + )
547
+ +
548
+ # Both the CUDA and Triton kernels derive the suffix head stride from
549
+ # prefix_output, so suffix_output must share the same head stride.
550
+ assert prefix_output.stride(1) == suffix_output.stride(1), (
runtime/SHA256SUMS.runtime ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ 15e48a8df3b65a73c81cf73c820ba12b4ab9474697d6b3f876c26c0b0cd3d455 COMMITS.txt
2
+ 6b03af3a1685a1969ff96870ea776537f5f67fd3674fc353880bd088bcef9a9c Ling-3.0-Flash-CIRU-int4-Strix-native-vllm.bundle
3
+ 8f307e9f2f16207856ca0b064a765a73bbebc029ad0b0fed61e5975a17e07ab6 Ling-3.0-Flash-CIRU-int4-Strix-native-vllm.patch
scripts/build-vllm-gfx1151.sh ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ set -Eeuo pipefail
3
+
4
+ install_root="${1:-$PWD/ciru-ling-runtime}"
5
+ script_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
6
+ package_root="$(cd -- "$script_dir/.." && pwd)"
7
+ venv="$install_root/.venv"
8
+ source_dir="$install_root/vllm"
9
+ index=https://rocm.nightlies.amd.com/whl-multi-arch/
10
+ base=d35eb6c44071ea806018841c490f0d2f3219c485
11
+ head=388d82de2abe418e73380ba250270d3abc62ac12
12
+ bundle="$package_root/runtime/Ling-3.0-Flash-CIRU-int4-Strix-native-vllm.bundle"
13
+ flash_source="$install_root/flash-attention"
14
+ flash_commit=0e60e39473e8df549a20fb5353760f7a65b30e2d
15
+
16
+ command -v git >/dev/null
17
+ command -v uv >/dev/null || {
18
+ echo "Missing uv. Run scripts/install-host-deps.sh first." >&2
19
+ exit 2
20
+ }
21
+
22
+ if [ "$(uname -s)" != Linux ]; then
23
+ echo "This vLLM/ROCm build requires Linux. On Windows, use WSL2 and docs/WINDOWS_WSL2.md." >&2
24
+ exit 2
25
+ fi
26
+
27
+ if grep -qi microsoft /proc/sys/kernel/osrelease 2>/dev/null; then
28
+ test -e /dev/dxg || {
29
+ echo "WSL2 detected but /dev/dxg is missing. Install AMD ROCDXG before building." >&2
30
+ exit 2
31
+ }
32
+ else
33
+ test -e /dev/kfd || {
34
+ echo "Missing /dev/kfd. Install/enable the AMDGPU KFD driver for gfx1151 first." >&2
35
+ exit 2
36
+ }
37
+ test -d /dev/dri || {
38
+ echo "Missing /dev/dri. The AMDGPU render device is not available." >&2
39
+ exit 2
40
+ }
41
+ fi
42
+
43
+ mkdir -p "$install_root"
44
+ if [ ! -x "$venv/bin/python" ]; then
45
+ UV_CACHE_DIR="${UV_CACHE_DIR:-$install_root/uv-cache}" uv python install 3.12
46
+ UV_CACHE_DIR="${UV_CACHE_DIR:-$install_root/uv-cache}" uv venv --python 3.12 "$venv"
47
+ fi
48
+
49
+ UV_CACHE_DIR="${UV_CACHE_DIR:-$install_root/uv-cache}" uv pip install \
50
+ --python "$venv/bin/python" \
51
+ --index-url "$index" \
52
+ 'torch[device-gfx1151]==2.13.0+rocm7.15.0a20260728' \
53
+ 'torchvision[device-gfx1151]==0.28.0+rocm7.15.0a20260728' \
54
+ 'torchaudio==2.11.0.2+rocm7.15.0a20260728' \
55
+ 'triton==3.8.0+git4cff872c.rocm7.15.0a20260728' \
56
+ 'rocm[libraries,devel,device-gfx1151]==7.15.0a20260728'
57
+
58
+ "$venv/bin/rocm-sdk" init
59
+ "$venv/bin/rocm-sdk" test
60
+
61
+ if [ ! -d "$source_dir/.git" ]; then
62
+ git clone https://github.com/vllm-project/vllm.git "$source_dir"
63
+ fi
64
+
65
+ git -C "$source_dir" fetch origin "$base"
66
+ git -C "$source_dir" fetch "$bundle" \
67
+ refs/heads/codex/ling3-gfx1151-rocm715:refs/heads/ciru/ling3-gfx1151-rocm715
68
+ git -C "$source_dir" checkout ciru/ling3-gfx1151-rocm715
69
+ test "$(git -C "$source_dir" rev-parse HEAD)" = "$head"
70
+
71
+ site="$($venv/bin/python - <<'PY'
72
+ import site
73
+ print(site.getsitepackages()[0])
74
+ PY
75
+ )"
76
+ sdk="$site/_rocm_sdk_devel"
77
+ core="$site/_rocm_sdk_core"
78
+ test -x "$sdk/bin/hipcc"
79
+
80
+ # Match the compatibility adjustment used by vLLM's ROCm SDK-wheel images.
81
+ rocm_sdk_init="$site/rocm_sdk/__init__.py"
82
+ "$venv/bin/python" - "$rocm_sdk_init" <<'PY'
83
+ from pathlib import Path
84
+ import sys
85
+ p = Path(sys.argv[1])
86
+ s = p.read_text()
87
+ s = s.replace("rtld_global: bool = True", "rtld_global: bool = False")
88
+ p.write_text(s)
89
+ PY
90
+
91
+ hsakmt_targets="$sdk/lib/cmake/hsakmt/hsakmtTargets.cmake"
92
+ if [ -f "$hsakmt_targets" ]; then
93
+ sed -i 's|-L/__w/[^;"]*|-L${_IMPORT_PREFIX}/lib/rocm_sysdeps/lib|g' \
94
+ "$hsakmt_targets"
95
+ sed -i 's|/usr/lib64/libc.so;||g' "$hsakmt_targets"
96
+ fi
97
+
98
+ export PATH="$sdk/bin:$sdk/llvm/bin:$venv/bin:$PATH"
99
+ export LD_LIBRARY_PATH="$sdk/lib:$core/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
100
+ export PYTHONPATH="$core/share/amd_smi${PYTHONPATH:+:$PYTHONPATH}"
101
+ export HIP_DEVICE_LIB_PATH="$core/lib/llvm/amdgcn/bitcode"
102
+ export VLLM_TARGET_DEVICE=rocm
103
+ export PYTORCH_ROCM_ARCH=gfx1151
104
+ export ROCM_PATH="$sdk"
105
+ export ROCM_HOME="$sdk"
106
+ export ROCM_SOURCE_DIR="$sdk"
107
+ export HIP_PATH="$sdk"
108
+ export CMAKE_PREFIX_PATH="$sdk/lib/cmake:$site/torch/share/cmake"
109
+ export HIP_FORCE_DEV_KERNARG=1
110
+ export MAX_JOBS="${MAX_JOBS:-16}"
111
+ export CMAKE_BUILD_PARALLEL_LEVEL="$MAX_JOBS"
112
+ export CMAKE_ARGS="-DROCM_PATH=$sdk -DCMAKE_HIP_ARCHITECTURES=gfx1151 ${CMAKE_ARGS:-}"
113
+
114
+ UV_CACHE_DIR="${UV_CACHE_DIR:-$install_root/uv-cache}" uv pip install \
115
+ --python "$venv/bin/python" \
116
+ 'cmake>=3.26.1,<4' ninja 'packaging>=24.2' \
117
+ 'setuptools>=77.0.3,<80' 'setuptools-scm>=8' \
118
+ 'setuptools-rust>=1.9' wheel 'jinja2>=3.1.6'
119
+ UV_CACHE_DIR="${UV_CACHE_DIR:-$install_root/uv-cache}" uv pip install \
120
+ --python "$venv/bin/python" "$core/share/amd_smi"
121
+ UV_CACHE_DIR="${UV_CACHE_DIR:-$install_root/uv-cache}" uv pip install \
122
+ --python "$venv/bin/python" -r "$source_dir/requirements/rocm.txt"
123
+
124
+ cd "$source_dir"
125
+ UV_CACHE_DIR="${UV_CACHE_DIR:-$install_root/uv-cache}" uv pip install \
126
+ --python "$venv/bin/python" --no-build-isolation --no-deps -e .
127
+
128
+ if [ ! -d "$flash_source/.git" ]; then
129
+ git clone https://github.com/Dao-AILab/flash-attention.git "$flash_source"
130
+ fi
131
+ git -C "$flash_source" fetch origin "$flash_commit"
132
+ git -C "$flash_source" checkout --detach "$flash_commit"
133
+ FLASH_ATTENTION_TRITON_AMD_ENABLE=TRUE \
134
+ UV_CACHE_DIR="${UV_CACHE_DIR:-$install_root/uv-cache}" uv pip install \
135
+ --python "$venv/bin/python" --no-build-isolation --no-deps "$flash_source"
136
+
137
+ "$venv/bin/python" - <<'PY'
138
+ import importlib
139
+ import importlib.metadata
140
+ import torch
141
+ import triton
142
+ assert torch.__version__ == "2.13.0+rocm7.15.0a20260728"
143
+ assert torch.version.hip == "7.15.0"
144
+ assert triton.__version__ == "3.8.0"
145
+ assert importlib.metadata.version("flash_attn") == "2.8.3"
146
+ for name in (
147
+ "vllm._C",
148
+ "vllm._C_stable_libtorch",
149
+ "vllm._moe_C_stable_libtorch",
150
+ "vllm._rocm_C",
151
+ "vllm.cumem_allocator",
152
+ ):
153
+ importlib.import_module(name)
154
+ print("CIRU vLLM gfx1151 build: PASS")
155
+ PY
scripts/download-model.sh ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ set -Eeuo pipefail
3
+
4
+ destination_root="${1:-$PWD/models}"
5
+ release_name=Ling-3.0-Flash-CIRU-int4-Strix-native
6
+ revision=ca3ea63b0255d212c4fe6020db9e0a51ce136006
7
+ destination="$destination_root/$release_name"
8
+
9
+ if command -v hf >/dev/null 2>&1; then
10
+ hf_cmd=(hf)
11
+ elif command -v uvx >/dev/null 2>&1; then
12
+ hf_cmd=(uvx --from 'huggingface_hub[cli]' hf)
13
+ else
14
+ echo "Missing Hugging Face CLI and uvx. Run scripts/install-host-deps.sh first." >&2
15
+ exit 2
16
+ fi
17
+
18
+ mkdir -p "$destination_root"
19
+ "${hf_cmd[@]}" download inclusionAI/Ling-3.0-flash-int4 \
20
+ --revision "$revision" \
21
+ --local-dir "$destination"
22
+
23
+ printf 'model_path=%s\nsource_revision=%s\n' "$destination" "$revision"
scripts/install-host-deps.sh ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ set -Eeuo pipefail
3
+
4
+ if [ "$(uname -s)" != Linux ]; then
5
+ echo "Run this inside native Linux or WSL2, not native Windows." >&2
6
+ exit 2
7
+ fi
8
+
9
+ if [ ! -r /etc/os-release ]; then
10
+ echo "Cannot identify the Linux distribution: /etc/os-release is missing." >&2
11
+ exit 2
12
+ fi
13
+
14
+ # shellcheck disable=SC1091
15
+ source /etc/os-release
16
+ distro="${ID:-unknown} ${ID_LIKE:-}"
17
+
18
+ if [[ "$distro" =~ (ubuntu|debian) ]]; then
19
+ sudo apt-get update
20
+ sudo apt-get install -y \
21
+ build-essential git curl ca-certificates pkg-config \
22
+ libnuma-dev libdrm-dev python3-dev
23
+ elif [[ "$distro" =~ (fedora|rhel|centos) ]]; then
24
+ sudo dnf install -y \
25
+ gcc gcc-c++ make git curl ca-certificates pkgconf-pkg-config \
26
+ numactl-devel libdrm-devel python3-devel
27
+ elif [[ "$distro" =~ (arch) ]]; then
28
+ sudo pacman -Syu --needed --noconfirm \
29
+ base-devel git curl ca-certificates pkgconf numactl libdrm python
30
+ else
31
+ echo "Unsupported automatic dependency install for: $distro" >&2
32
+ echo "Install a C/C++ toolchain, git, curl, pkg-config, NUMA headers, libdrm headers, and Python 3; then install uv." >&2
33
+ exit 2
34
+ fi
35
+
36
+ if ! command -v uv >/dev/null 2>&1; then
37
+ curl -LsSf https://astral.sh/uv/install.sh | sh
38
+ export PATH="$HOME/.local/bin:$PATH"
39
+ fi
40
+
41
+ command -v uv >/dev/null || {
42
+ echo "uv was installed under ~/.local/bin; add that directory to PATH and rerun." >&2
43
+ exit 2
44
+ }
45
+
46
+ printf 'Host dependencies ready on %s.\n' "${PRETTY_NAME:-$distro}"
47
+ printf 'Next: bash scripts/build-vllm-gfx1151.sh "$HOME/ciru-ling-runtime"\n'
scripts/run-1m-yarn-experimental.sh ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ set -Eeuo pipefail
3
+
4
+ script_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
5
+ package_root="$(cd -- "$script_dir/.." && pwd)"
6
+ # shellcheck disable=SC1091
7
+ set -a
8
+ source "$package_root/config/experimental-yarn-1m.env"
9
+ set +a
10
+ exec bash "$script_dir/run-common.sh"
scripts/run-256k.sh ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ set -Eeuo pipefail
3
+
4
+ script_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
5
+ package_root="$(cd -- "$script_dir/.." && pwd)"
6
+ # shellcheck disable=SC1091
7
+ set -a
8
+ source "$package_root/config/native-256k.env"
9
+ set +a
10
+ exec bash "$script_dir/run-common.sh"
scripts/run-common.sh ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ set -Eeuo pipefail
3
+
4
+ release_name=Ling-3.0-Flash-CIRU-int4-Strix-native
5
+ venv="${VENV:?Set VENV to the built runtime virtual environment}"
6
+ model_path="${MODEL_PATH:?Set MODEL_PATH to the downloaded checkpoint directory}"
7
+ host="${HOST:-127.0.0.1}"
8
+ port="${PORT:-18081}"
9
+ cache_root="${CACHE_ROOT:-$HOME/.cache/ciru-ling3-vllm}"
10
+
11
+ test -x "$venv/bin/vllm"
12
+ test -d "$model_path"
13
+ site="$($venv/bin/python - <<'PY'
14
+ import site
15
+ print(site.getsitepackages()[0])
16
+ PY
17
+ )"
18
+ sdk="$site/_rocm_sdk_devel"
19
+ core="$site/_rocm_sdk_core"
20
+ test -x "$sdk/bin/hipcc"
21
+ mkdir -p "$cache_root/vllm" "$cache_root/triton" "$cache_root/huggingface-modules"
22
+
23
+ export PATH="$sdk/bin:$sdk/llvm/bin:$venv/bin:$PATH"
24
+ export LD_LIBRARY_PATH="$sdk/lib:$core/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
25
+ export PYTHONPATH="$core/share/amd_smi${PYTHONPATH:+:$PYTHONPATH}"
26
+ export HIP_DEVICE_LIB_PATH="$core/lib/llvm/amdgcn/bitcode"
27
+ export ROCM_PATH="$sdk"
28
+ export ROCM_HOME="$sdk"
29
+ export ROCM_SOURCE_DIR="$sdk"
30
+ export HIP_PATH="$sdk"
31
+ export HIP_FORCE_DEV_KERNARG=1
32
+ export HSA_NO_SCRATCH_RECLAIM=1
33
+ export VLLM_ROCM_USE_AITER=0
34
+ export VLLM_ROCM_USE_SKINNY_GEMM=0
35
+ export VLLM_ROCM_SAFE_MERGE_ATTN_STATES=1
36
+ export VLLM_CACHE_ROOT="$cache_root/vllm"
37
+ export TRITON_CACHE_DIR="$cache_root/triton"
38
+ export HF_MODULES_CACHE="$cache_root/huggingface-modules"
39
+ export FLASH_ATTENTION_TRITON_AMD_ENABLE=TRUE
40
+ export FLASH_ATTENTION_TRITON_AMD_AUTOTUNE=FALSE
41
+ unset TORCH_BLAS_PREFER_HIPBLASLT
42
+ unset PYTORCH_TUNABLEOP_ENABLED
43
+ unset PYTORCH_TUNABLEOP_TUNING
44
+ unset VLLM_TUNED_CONFIG_FOLDER
45
+
46
+ args=(
47
+ serve "$model_path"
48
+ --host "$host"
49
+ --port "$port"
50
+ --served-model-name "$release_name"
51
+ --trust-remote-code
52
+ --attention-backend TRITON_MLA
53
+ --moe-backend triton
54
+ --enable-chunked-prefill
55
+ --enable-prefix-caching
56
+ --mamba-cache-mode align
57
+ --enable-auto-tool-choice
58
+ --tool-call-parser ling3
59
+ --reasoning-parser ling3
60
+ --max-model-len "$CONTEXT_LENGTH"
61
+ --max-num-seqs "$MAX_NUM_SEQS"
62
+ --gpu-memory-utilization "$GPU_MEMORY_UTILIZATION"
63
+ --compilation-config '{"mode":3,"cudagraph_mode":"NONE","compile_sizes":[1,2]}'
64
+ --speculative-config "{\"method\":\"mtp\",\"num_speculative_tokens\":$SPECULATIVE_TOKENS}"
65
+ )
66
+
67
+ if [ -n "${HF_OVERRIDES:-}" ]; then
68
+ args+=(--hf-overrides "$HF_OVERRIDES")
69
+ fi
70
+
71
+ if [ "${DRY_RUN:-0}" = 1 ]; then
72
+ printf '%q ' "$venv/bin/vllm" "${args[@]}"
73
+ printf '\n'
74
+ exit 0
75
+ fi
76
+
77
+ exec "$venv/bin/vllm" "${args[@]}"