blob: 582721065595a764128045a7b4439ee48f7ee992 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
|
# Maintainer: Will Handley <wh260@cam.ac.uk>
pkgname=sglang-git
_pkgname=sglang
pkgver=r12460.b6b9145c9
pkgrel=1
pkgdesc='A fast serving framework for large language models and vision language models'
arch=('x86_64')
url='https://github.com/sgl-project/sglang'
license=('Apache-2.0')
depends=(
'python>=3.10'
'python-aiohttp'
'python-numpy'
'python-pybase64'
'python-partial-json-parser'
'python-pydantic'
'python-requests'
'python-pytorch'
'python-safetensors'
'python-sgl-kernel-git'
'python-torchvision'
'python-transformers'
'python-triton'
'python-setproctitle'
'python-tqdm'
'python-orjson'
'python-compressed-tensors'
'python-gguf'
'python-msgspec'
'python-einops'
'python-soundfile'
'python-xgrammar'
'ipython'
'python-fastapi'
'python-starlette'
'python-openai'
'python-huggingface-hub'
'python-pillow'
'python-packaging'
'python-psutil'
'python-scipy'
'python-sentencepiece'
'python-pyzmq'
'python-python-multipart'
'uvicorn'
'python-flashinfer'
)
makedepends=(
'python-build'
'python-installer'
'python-wheel'
'python-setuptools'
'python-setuptools-scm'
'git'
)
optdepends=(
'python-anthropic: Anthropic API backend'
'python-datasets: Dataset loading'
'python-grpcio: gRPC support'
'python-modelscope: ModelScope model hub'
'ninja: Build system for JIT compilation'
'python-outlines: Structured generation'
'python-tiktoken: OpenAI tokenizer'
'python-tilelang: DeepSeek V4 model support'
'python-timm: Vision model library'
'python-uvloop: Fast event loop'
# NVFP4 on SM120 (RTX 5090 / RTX PRO 6000) — see SM120-NVFP4-NOTES.md
'cuda: NVFP4/CUTLASS JIT compilation'
'gcc15: nvcc 13.x host compiler on systems with GCC 16+'
'cutlass: headers for SGLang/FlashInfer NVFP4 JIT'
'python-nvidia-cudnn-frontend: FlashInfer cuDNN FP4/FP8 backend imports'
'python-compressed-tensors-git: RedHatAI NVFP4 recipe scale_dtype support (>=0.15.0)'
)
provides=('sglang')
conflicts=('sglang')
_models=(
'deepseek_v4_flash'
'gemma_4_e2b'
'gemma_4_e4b'
'gemma_4_26b_a4b'
'gemma_4_26b_a4b_fp8'
'gemma_4_26b_a4b_nvfp4'
'gemma_4_31b'
'gemma_4_31b_fp8'
'gemma_4_31b_nvfp4'
'qwen3.5_0.8b'
'qwen3.5_2b'
'qwen3.5_4b'
'qwen3.5_9b'
'qwen3.5_27b'
'qwen3.5_27b_fp8'
'qwen3.5_27b_gptq_int4'
'qwen3.5_35b_a3b'
'qwen3.5_35b_a3b_fp8'
'qwen3.5_35b_a3b_gptq_int4'
'qwen3.5_122b_a10b'
'qwen3.5_122b_a10b_fp8'
'qwen3.5_122b_a10b_gptq_int4'
'qwen3.5_397b_a17b'
'qwen3.5_397b_a17b_fp8'
'qwen3.5_397b_a17b_gptq_int4'
'qwen3.6_27b'
'qwen3.6_27b_fp8'
'qwen3.6_27b_awq_int4'
'qwen3.6_27b_gptq_int4'
'qwen3.6_27b_autoround_int4'
'qwen3.6_27b_nvfp4'
'qwen3.6_27b_text_nvfp4'
'qwen3.6_35b_a3b'
'qwen3.6_35b_a3b_fp8'
'qwen3.6_35b_a3b_awq_int4'
'qwen3.6_35b_a3b_gptq_int4'
'qwen3.6_35b_a3b_autoround_int4'
'qwen3.6_35b_a3b_nvfp4'
)
# Mark every shipped conf as backup so pacman preserves user edits and
# emits .pacnew on package-side changes instead of silently overwriting.
backup=('etc/sglang/sglang.conf' 'etc/sglang/sglang.env')
for _m in "${_models[@]}"; do
backup+=("etc/sglang/${_m}.conf")
done
source=("${_pkgname}::git+https://github.com/williamjameshandley/sglang.git#branch=wjh/v4-flash-mxfp4-routed-experts"
'sglang@.service'
'sglang.conf'
'sglang.env'
'sglang.sysusers'
'deepseek_v4.jinja'
'wjh-fp4-3d-reshape.patch'
'SM120-NVFP4-NOTES.md'
'gemma_4_31b_nvfp4.env.example'
'qwen3.6_27b_text_nvfp4.env.example'
'cache-fixup'
'qwen3.6_27b_text_nvfp4.preprocessor_config.json'
"${_models[@]/%/.conf}")
sha256sums=('SKIP')
for _ in 'sglang@.service' 'sglang.conf' 'sglang.env' 'sglang.sysusers' 'deepseek_v4.jinja' 'wjh-fp4-3d-reshape.patch' 'SM120-NVFP4-NOTES.md' 'gemma_4_31b_nvfp4.env.example' 'qwen3.6_27b_text_nvfp4.env.example' 'cache-fixup' 'qwen3.6_27b_text_nvfp4.preprocessor_config.json' "${_models[@]}"; do
sha256sums+=('SKIP')
done
pkgver() {
cd "${_pkgname}"
printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}
prepare() {
cd "${_pkgname}"
# Local SM120 NVFP4 fixes: dense FP4 3D activation reshape, SGLang
# CUTLASS scale-byte clamp from upstream PR #22927, JIT 3D handling,
# and /usr/include/cutlass discovery fallback. -F0 prevents fuzzy
# misapply if upstream context drifts. Drop once upstream carries
# equivalents. See SM120-NVFP4-NOTES.md.
patch -Np1 -F0 < "${srcdir}/wjh-fp4-3d-reshape.patch"
}
build() {
cd "${_pkgname}/python"
cp pyproject_other.toml pyproject.toml
rm -rf build dist *.egg-info
# Use latest upstream tag for Python version (pkgver format isn't PEP 440)
export SETUPTOOLS_SCM_PRETEND_VERSION="$(git tag -l 'v[0-9]*' --sort=-v:refname | head -1 | sed 's/^v//')"
python -m build --wheel --no-isolation
}
package() {
cd "${_pkgname}/python"
python -m installer --destdir="${pkgdir}" dist/*.whl
install -Dm644 "${srcdir}/sglang@.service" "${pkgdir}/usr/lib/systemd/system/sglang@.service"
install -Dm644 "${srcdir}/sglang.sysusers" "${pkgdir}/usr/lib/sysusers.d/sglang.conf"
install -Dm644 "${srcdir}/sglang.conf" "${pkgdir}/etc/sglang/sglang.conf"
install -Dm600 "${srcdir}/sglang.env" "${pkgdir}/etc/sglang/sglang.env"
for model in "${_models[@]}"; do
install -Dm644 "${srcdir}/${model}.conf" "${pkgdir}/etc/sglang/${model}.conf"
done
# SM120 NVFP4 docs + working env-file template. Installed under
# /usr/share/doc so package upgrades don't clobber any user edits to
# /etc/sglang/<instance>.env. Operator copies the example, fills in
# the HF snapshot hash, and drops it into /etc/sglang/.
install -Dm644 "${srcdir}/SM120-NVFP4-NOTES.md" \
"${pkgdir}/usr/share/doc/${pkgname}/SM120-NVFP4-NOTES.md"
install -Dm644 "${srcdir}/gemma_4_31b_nvfp4.env.example" \
"${pkgdir}/usr/share/doc/${pkgname}/gemma_4_31b_nvfp4.env.example"
install -Dm644 "${srcdir}/qwen3.6_27b_text_nvfp4.env.example" \
"${pkgdir}/usr/share/doc/${pkgname}/qwen3.6_27b_text_nvfp4.env.example"
# Workaround: deepseek-ai/DeepSeek-V4-Flash ships tokenizer_config.json
# without a chat_template field, and sglang has no built-in deepseek-v4
# template. Lifted from DeepSeek-V3.2-Exp, which uses the same special
# tokens. Remove once upstream ships a chat_template for V4-Flash.
install -Dm644 "${srcdir}/deepseek_v4.jinja" "${pkgdir}/etc/sglang/deepseek_v4.jinja"
# HF-cache fixup helper. Idempotent script that injects missing files
# (e.g. preprocessor_config.json for text-only siblings of VL checkpoints)
# into the relevant snapshot dirs. Invoked via ExecStartPre in the unit.
# Cheap no-op when /usr/share/sglang/cache-fixups/ is empty.
install -Dm755 "${srcdir}/cache-fixup" "${pkgdir}/usr/lib/sglang/cache-fixup"
# Per-model fixup data. The directory name under cache-fixups/ MUST match
# the HF Hub cache-dir name (models--<owner>--<repo>).
install -Dm644 "${srcdir}/qwen3.6_27b_text_nvfp4.preprocessor_config.json" \
"${pkgdir}/usr/share/sglang/cache-fixups/models--sakamakismile--Qwen3.6-27B-Text-NVFP4-MTP/preprocessor_config.json"
}
|