---
title: '54465'
pageLayout: default
slug: thoughts/inference/vllm-prs/54465
permalink: https://aarnphm.xyz/thoughts/inference/vllm-prs/54465.md
generator:
  quartz: v4.6.0
  hostedProvider: Cloudflare
  baseUrl: aarnphm.xyz
full: https://aarnphm.xyz/llms-full.txt
---
# [#54465](https://github.com/aarnphm/aarnphm.github.io/issues/54465) \[Bugfix\]\[MLA\] Fix BLHNC addressing for FlashInfer sparse MLA

[vllm-project/vllm#54465](https://github.com/vllm-project/vllm/pull/54465) · LucasWilkinson · MERGED · created 2026-08-30T19:33:06Z · merged 2026-08-31T01:13:42Z

## Purpose

Fix sparse MLA cache addressing when `FLASHINFER_MLA_SPARSE` uses a block-outermost KV-cache layout such as BLHNC.

BLHNC places other layers’ pages between consecutive blocks of a given layer. Two paths incorrectly assumed that a layer’s physical block stride was exactly its logical block size:

- FlashInfer sparse index conversion multiplied the physical block ID by `block_size`, causing decode to read another layer’s page.
- The fused DeepSeek-V3.2/GLM cache writer derived the logical block size from the physical block stride, causing writes to land in the wrong block or layer.

## Changes

- Derive the physical row stride from the actual FlashInfer KV-cache view and pass it through both regular and DCP sparse-index conversion.
- Pass the logical MLA block size explicitly to the fused cache writer.
- Extend DCP physical-remapping coverage to a non-dense block stride.

## Why this is not duplicate work

Checked the open upstream PRs with:



```bash
gh pr list --repo vllm-project/vllm --state open --search "FlashInfer BLHNC sparse MLA in:title,body"
gh pr list --repo vllm-project/vllm --state open --search "BLOCK_STRIDE_ROWS in:title,body"
gh pr list --repo vllm-project/vllm --state open --search "KV cache layout FlashInfer MLA in:title,body"
gh pr list --repo vllm-project/vllm --state open --search "GLM BLHNC in:title,body"
gh pr list --repo vllm-project/vllm --state open --search "BLHNC"
gh pr list --repo vllm-project/vllm --state open --search "block stride sparse MLA"
```

The nearest related work is:

- [#44458](https://github.com/aarnphm/aarnphm.github.io/issues/44458) standardizes KV-cache layout selection and representation; it does not fix these sparse-MLA consumers.
- [#47527](https://github.com/aarnphm/aarnphm.github.io/issues/47527) fixes the SM120 packed FlashInfer sparse-MLA API path.
- [#53969](https://github.com/aarnphm/aarnphm.github.io/issues/53969) adds SM120 NoPE support and effective top-k validation.
- [#53781](https://github.com/aarnphm/aarnphm.github.io/issues/53781) adds HiSparse host buffering.

None fixes FlashInfer’s physical BLHNC row mapping or the fused GLM writer’s logical-block-size inference. This PR is an isolated prerequisite and does not include HiSparse or DMA changes.

## Test plan and results

Formatting and static checks:



```bash
.venv/bin/pre-commit run --files \
  vllm/v1/attention/backends/mla/flashinfer_mla_sparse.py \
  vllm/v1/attention/backends/mla/sparse_utils.py \
  vllm/models/deepseek_v32/common/kernels.py \
  tests/v1/attention/test_indexer_dcp_localize.py
```

Passed, including Ruff, mypy, SPDX, and repository policy hooks.

Focused CUDA regression:



```bash
.venv/bin/python -m pytest -vv \
  tests/v1/attention/test_indexer_dcp_localize.py::test_dcp_filter_compacts_valid_slots_for_sparse_kernel
```

Result: `2 passed` on NVIDIA H200.

Model validation used `zai-org/GLM-5.3` at revision `30333038ada1f1dacb294a93270305a890b50c14`, TP8, FP8 KV cache, CUDA graphs enabled, and the automatically selected `FLASHINFER_MLA_SPARSE` backend. With these two production fixes applied, three deterministic prompts generated 128 tokens each that were token-for-token identical between LBHNC and BLHNC. This model run was performed on the HiSparse-GLM development base before porting the isolated patch to current upstream `main`; the focused test above was rerun on this PR branch.

## AI assistance disclosure

AI assistance was used to investigate the addressing failures, implement and test the patch, and draft this PR description. Reviewed by author.

---

## comments

**LucasWilkinson** (2026-08-30T19:37:13Z):

/ci run

**MatthewBonanni** (2026-08-30T23:59:37Z):

/ci run

**github-actions** (2026-08-30T23:59:54Z):

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

