-
Notifications
You must be signed in to change notification settings - Fork 1
Runtime knobs (ctx/util/seqs/async/APC/drafter block) + mamba prefix-hit seed fix (vllm#55600), README on the single-Spark memory budget #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,17 +5,52 @@ set -euo pipefail | |||||||||||||||||||||||||||||||||
| python3 /opt/glm53/patch_glm_video_placeholders.py | ||||||||||||||||||||||||||||||||||
| K="${ONE_SPARK_K:-5}" # DFlash2 draft depth; 5 = best prose/code, 8 = best structured (see README K sweep) | ||||||||||||||||||||||||||||||||||
| SPEC='{"method":"dflash","model":"/draft","num_speculative_tokens":'"$K"',"kv_cache_dtype":"auto","draft_sample_method":"probabilistic","rejection_sample_method":"standard","draft_tensor_parallel_size":1}' | ||||||||||||||||||||||||||||||||||
| # ---- Runtime knobs (all default to the shipped recipe behaviour) ---- | ||||||||||||||||||||||||||||||||||
| # ONE_SPARK_CTX / ONE_SPARK_UTIL / ONE_SPARK_SEQS / ONE_SPARK_MNBT: context, gpu-memory-utilization, | ||||||||||||||||||||||||||||||||||
| # max-num-seqs, max-num-batched-tokens. | ||||||||||||||||||||||||||||||||||
| # ONE_SPARK_ASYNC=0|1: force --no-async-scheduling / --async-scheduling (unset = vLLM default, async for DFlash). | ||||||||||||||||||||||||||||||||||
| # With async on, the DFlash2 drafter reserves a 2047+2*MNBT token in-flight window; each 64-token drafter | ||||||||||||||||||||||||||||||||||
| # block is padded to a full 7168-token MLA page, so that window costs 257 blocks (13 GiB) for 262k context. | ||||||||||||||||||||||||||||||||||
| # ONE_SPARK_ASYNC=0 halves it; bs=1 decode is unchanged. | ||||||||||||||||||||||||||||||||||
| # ONE_SPARK_APC=0|1: --no-enable-prefix-caching / --enable-prefix-caching (default 1). | ||||||||||||||||||||||||||||||||||
| # ONE_SPARK_DRAFT_BLOCK=N (e.g. 1024): raise the drafter's compact block in the padded slot-share path | ||||||||||||||||||||||||||||||||||
| # (kv_cache_utils.py) so the drafter reserves ~10 blocks instead of 145/257. FlashAttention reports | ||||||||||||||||||||||||||||||||||
| # MultipleOf(16) and select_common_block_size returns the manager block, so kernel block == manager block. | ||||||||||||||||||||||||||||||||||
| # Measured lossless (acceptance 3.3-3.6, decode unchanged). Unset = shipped 64. | ||||||||||||||||||||||||||||||||||
| # ONE_SPARK_MAMBA_SEED_FIX=1 (default): fix for vllm-project/vllm#55600 — add_request seeds the mamba state | ||||||||||||||||||||||||||||||||||
| # index with cache_config.block_size, which EngineCore lowers to the drafter's block (64/1024) while mamba | ||||||||||||||||||||||||||||||||||
| # state lives in 7168-token blocks; prefix hits of >= 8 blocks then read past the block-table row (Xid 31) | ||||||||||||||||||||||||||||||||||
| # and shorter hits silently restore the wrong KDA state. Fail-closed: if the anchor is missing the container | ||||||||||||||||||||||||||||||||||
| # refuses to start (set ONE_SPARK_MAMBA_SEED_FIX=0 to start anyway; then also set ONE_SPARK_APC=0). | ||||||||||||||||||||||||||||||||||
| case "${ONE_SPARK_ASYNC:-}" in 0) ASYNC_FLAG=--no-async-scheduling ;; 1) ASYNC_FLAG=--async-scheduling ;; *) ASYNC_FLAG= ;; esac | ||||||||||||||||||||||||||||||||||
| case "${ONE_SPARK_APC:-1}" in 0) APC_FLAG=--no-enable-prefix-caching ;; *) APC_FLAG=--enable-prefix-caching ;; esac | ||||||||||||||||||||||||||||||||||
| if [ -n "${ONE_SPARK_DRAFT_BLOCK:-}" ]; then | ||||||||||||||||||||||||||||||||||
| KVU=/usr/local/lib/python3.12/dist-packages/vllm/v1/core/kv_cache_utils.py | ||||||||||||||||||||||||||||||||||
| sed -i "s/compact_block = 64$/compact_block = ${ONE_SPARK_DRAFT_BLOCK}/; s/s.block_size != 64 or s.page_size_padded != mla_page/s.block_size != ${ONE_SPARK_DRAFT_BLOCK} or s.page_size_padded != mla_page/" "$KVU" | ||||||||||||||||||||||||||||||||||
| echo "[one-spark] drafter block patch: $(grep -c "compact_block = ${ONE_SPARK_DRAFT_BLOCK}" "$KVU") + $(grep -c "block_size != ${ONE_SPARK_DRAFT_BLOCK}" "$KVU") sites" | ||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||
| if [ "${ONE_SPARK_MAMBA_SEED_FIX:-1}" = "1" ]; then | ||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win 🔎 Supported by static analysis🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- scripts/serve-one-spark.sh (numbered) ---'
cat -n scripts/serve-one-spark.sh
printf '%s\n' '--- references to the settings ---'
rg -n -C 3 'ONE_SPARK_(MAMBA_SEED_FIX|APC)|MAMBA_SEED_FIX|prefix.cache|block.table|KDA' --glob '!node_modules' --glob '!build' --glob '!dist' .Repository: gitcommit90/glm-5.3-one-spark Length of output: 50388 🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- script metadata and relevant definitions ---'
wc -l scripts/serve-one-spark.sh
sed -n '1,90p' scripts/serve-one-spark.sh
printf '%s\n' '--- callers and documentation ---'
rg -n -C 4 'serve-one-spark|ONE_SPARK_MAMBA_SEED_FIX|ONE_SPARK_APC' --glob '!node_modules' --glob '!build' --glob '!dist' .Repository: gitcommit90/glm-5.3-one-spark Length of output: 15895 🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- exact startup branch matrix for the reviewed conditions ---'
for pair in '1 1' '0 0' '0 1' '2 1'; do
read -r mamba apc <<EOF
$pair
EOF
if [ "$mamba" = "1" ]; then
mamba_branch=apply_fix
else
mamba_branch=skip_fix
fi
case "$apc" in
0) apc_flag=disable_apc ;;
*) apc_flag=enable_apc ;;
esac
printf 'ONE_SPARK_MAMBA_SEED_FIX=%s ONE_SPARK_APC=%s -> %s, %s\n' \
"$mamba" "$apc" "$mamba_branch" "$apc_flag"
done
printf '%s\n' '--- README safety statements ---'
sed -n '69,90p' README.mdRepository: gitcommit90/glm-5.3-one-spark Length of output: 2178 Reject invalid Mamba-fix settings.
Accept only Proposed validation+MAMBA_SEED_FIX="${ONE_SPARK_MAMBA_SEED_FIX:-1}"
+case "$MAMBA_SEED_FIX" in
+ 1) ;;
+ 0)
+ if [ "${ONE_SPARK_APC:-1}" != "0" ]; then
+ echo "[one-spark] FATAL: MAMBA_SEED_FIX=0 requires APC=0" >&2
+ exit 97
+ fi
+ ;;
+ *)
+ echo "[one-spark] FATAL: ONE_SPARK_MAMBA_SEED_FIX must be 0 or 1" >&2
+ exit 97
+ ;;
+esac
-if [ "${ONE_SPARK_MAMBA_SEED_FIX:-1}" = "1" ]; then
+if [ "$MAMBA_SEED_FIX" = "1" ]; then📝 Committable suggestion
Suggested change
🤖 Prompt for AI AgentsSource: MCP tools |
||||||||||||||||||||||||||||||||||
| MH=/usr/local/lib/python3.12/dist-packages/vllm/v1/worker/gpu/model_states/mamba_hybrid.py | ||||||||||||||||||||||||||||||||||
| sed -i "s|(new_req_data.num_computed_tokens - 1) // self.cache_config.block_size|(new_req_data.num_computed_tokens - 1) // self.cache_config.mamba_block_size|" "$MH" | ||||||||||||||||||||||||||||||||||
| N=$(grep -c "num_computed_tokens - 1) // self.cache_config.mamba_block_size" "$MH") | ||||||||||||||||||||||||||||||||||
| echo "[one-spark] mamba seed fix (vllm#55600): $N site" | ||||||||||||||||||||||||||||||||||
| if [ "$N" != "1" ]; then | ||||||||||||||||||||||||||||||||||
| echo "[one-spark] FATAL: mamba seed fix not applied (expected 1 match, got $N) - did the image change? Without it a prefix-cache hit of >= 8 blocks faults (Xid 31). Set ONE_SPARK_MAMBA_SEED_FIX=0 ONE_SPARK_APC=0 to start deliberately." >&2 | ||||||||||||||||||||||||||||||||||
| exit 97 | ||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||
| exec vllm serve /model \ | ||||||||||||||||||||||||||||||||||
| --served-model-name GLM-5.3-Flash-EXL3-2.05 \ | ||||||||||||||||||||||||||||||||||
| --host "${ONE_SPARK_HOST:-127.0.0.1}" --port "${ONE_SPARK_PORT:-18080}" \ | ||||||||||||||||||||||||||||||||||
| --tensor-parallel-size 1 \ | ||||||||||||||||||||||||||||||||||
| --tool-call-parser glm47 --enable-auto-tool-choice \ | ||||||||||||||||||||||||||||||||||
| --reasoning-parser glm45 \ | ||||||||||||||||||||||||||||||||||
| --enable-prefix-caching --no-enable-flashinfer-autotune \ | ||||||||||||||||||||||||||||||||||
| $APC_FLAG --no-enable-flashinfer-autotune \ | ||||||||||||||||||||||||||||||||||
| --quantization exl3 \ | ||||||||||||||||||||||||||||||||||
| --max-model-len 262144 \ | ||||||||||||||||||||||||||||||||||
| --gpu-memory-utilization 0.90 \ | ||||||||||||||||||||||||||||||||||
| --max-num-seqs 4 --max-num-batched-tokens 7168 \ | ||||||||||||||||||||||||||||||||||
| --max-model-len "${ONE_SPARK_CTX:-262144}" \ | ||||||||||||||||||||||||||||||||||
| --gpu-memory-utilization "${ONE_SPARK_UTIL:-0.90}" \ | ||||||||||||||||||||||||||||||||||
| --max-num-seqs "${ONE_SPARK_SEQS:-4}" --max-num-batched-tokens "${ONE_SPARK_MNBT:-7168}" \ | ||||||||||||||||||||||||||||||||||
| $ASYNC_FLAG \ | ||||||||||||||||||||||||||||||||||
| --kv-cache-dtype fp8 \ | ||||||||||||||||||||||||||||||||||
| --speculative-config "$SPEC" \ | ||||||||||||||||||||||||||||||||||
| --chat-template /opt/glm53/chat_template.jinja \ | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: gitcommit90/glm-5.3-one-spark
Length of output: 8109
🏁 Script executed:
#!/bin/bash head -n 40 scripts/serve-one-spark.shRepository: gitcommit90/glm-5.3-one-spark
Length of output: 3876
Fail closed when the drafter patch is incomplete.
set -euo pipefailalready stops the script whensedcannot openKVU. However,sedreturns success when either substitution matches zero lines. Theechocommand then prints the counts, andexec vllm servestill runs with the unchanged 64-token layout.Require both patch sites before startup.
Proposed validation
🤖 Prompt for AI Agents