---
title: '59528'
pageLayout: default
slug: thoughts/inference/vllm-prs/59528
permalink: https://aarnphm.xyz/thoughts/inference/vllm-prs/59528.md
generator:
  quartz: v4.6.0
  hostedProvider: Cloudflare
  baseUrl: aarnphm.xyz
full: https://aarnphm.xyz/llms-full.txt
---
# [#59528](https://github.com/aarnphm/aarnphm.github.io/issues/59528) \[Bugfix\] Keep the GLM-5.3 kpool tail and Qwen4 QSA ring out of the null block

[vllm-project/vllm#59528](https://github.com/vllm-project/vllm/pull/59528) · ivanium · MERGED · created 2026-10-01T01:55:26Z · merged 2026-10-08T20:44:05Z

## Purpose

Block id 0 is the null block. It is shared by every KV cache group and is assumed to stay zero. Since [#35431](https://github.com/aarnphm/aarnphm.github.io/issues/35431), the runners mark rows that own no state with 0 in the block table, not `PAD_SLOT_ID`: dummy runs, CUDA graph capture and padding rows all carry 0. Two ring caches that address their pages through column 0 of the block table did not treat 0 as “no ring”, so dummy runs wrote their rows into block 0:

- **GLM-5.3-Flash kpool tail:** `_kpool_tail_slot_mapping_kernel` maps every token to `block_table[req][0] * kpool + pos % kpool`. Its torch fallback does the same.
- **Qwen4 QSA circular ring:** `circular_qsa_slot_mapping` and `_build_qsa_metadata_kernel` map tokens to `block_table[req, 0]` and kept every block `>= 0`. The compressed QSA path already keeps dummy slots inert (`test_qsa_compressed_metadata_keeps_dummy_slots_inert`); the ring path did not.

Every scheduled request owns its ring block, so a request on the null block has none. Its tokens now map to PAD, as the generic slot mapping does. The ring writers already skip PAD slots.

This is the same pattern as [#58560](https://github.com/aarnphm/aarnphm.github.io/issues/58560), which fixes the DeepSeek-V4.1 compressor ring.

## Changes

- `vllm/v1/attention/backends/mla/indexer.py`: the kpool tail slot mapping (Triton and torch) emits PAD for requests on the null block.
- `vllm/models/qwen4_exp/common/qsa_cache.py`: the QSA circular ring slot mapping (torch and Triton) requires block `> 0`.
- Tests: the existing QSA circular metadata test, which runs the Triton builder, also checks a dummy batch (all-zero block table) and expects PAD. QSA tests that used block 0 as a real ring block now start real blocks at 1. This includes `_make_block_table` in the AMD pre-indexer test, which could randomly hand out block 0. For the kpool tail, the existing CPU padding test now ends with a padding request on the null block, and the existing Triton-vs-CPU test adds a mixed batch and an all-null dummy batch. Both check that the null-block request maps to PAD.

## Not a duplicate

- [#58560](https://github.com/aarnphm/aarnphm.github.io/issues/58560) covers only the DeepSeek-V4.1 compressor ring.
- [#57158](https://github.com/aarnphm/aarnphm.github.io/issues/57158) zeroes block 0 after capture. That does not cover DP idle-rank dummy batches during serving.
- [#57169](https://github.com/aarnphm/aarnphm.github.io/issues/57169) and [#59297](https://github.com/aarnphm/aarnphm.github.io/issues/59297) move the kpool tail onto `CircularBufferSpec` / the packed layout but keep its slot kernel unchanged.
- [#54296](https://github.com/aarnphm/aarnphm.github.io/issues/54296) masks out-of-range block indices in the generic slot mapping kernel, which neither ring uses.

## Test Plan



```bash
pytest tests/models/qwen4_exp/test_qsa_reference.py tests/models/qwen4_exp/test_qsa_pre_indexer_amd.py tests/v1/attention/test_kpool_tail_slot_mapping.py tests/v1/worker/test_gpu_kpool_tail_slot_mapping.py
pre-commit run --files <changed files>
```

## Test Result

- Rebased on main `d6fe5dca68`. 102 passed, 16 skipped on GB200. The 16 skips are `test_qsa_pre_indexer_amd.py`, which requires ROCm.
- Control: with the QSA change reverted, the dummy-batch check fails: dummy tokens map to real slots in block 0.
- Control: with the kpool tail change reverted, the CPU padding test and the two null-block Triton cases fail.
- `pre-commit` passes.
- No model eval. Only tokens of requests on the null block change, and those are dummy or padding rows whose outputs are discarded. Real requests never own block 0 (`BlockPool` pops it as the null block at init), so their mappings and outputs are unchanged.

AI assistance (Claude Code) was used for this PR. The submitter reviewed the changes and ran the tests above.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---

## comments

**mergify** (2026-10-01T06:36:11Z):

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @ivanium.

<https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork>

**ivanium** (2026-10-08T18:47:04Z):

/ci run

**github-actions** (2026-10-08T18:48:42Z):

❌ This PR is 1 commit behind upstream `main`. Your branch must contain every commit currently on upstream `main`. No new CI build was started. Merge or rebase onto the latest `main`, then rerun `/ci run`. To test this branch at your own risk, use `/ci run --allow-stale`.

<!-- vllm-ci-command:6066751660 -->

**njhill** (2026-10-08T19:00:26Z):

/ci run

**github-actions** (2026-10-08T19:00:48Z):

✅ Triggered [Buildkite CI #93683](https://buildkite.com/vllm/ci/builds/93683) for commit `c25289d5cf19`.

