---
title: '51612'
pageLayout: default
slug: thoughts/inference/vllm-prs/51612
permalink: https://aarnphm.xyz/thoughts/inference/vllm-prs/51612.md
generator:
  quartz: v4.6.0
  hostedProvider: Cloudflare
  baseUrl: aarnphm.xyz
full: https://aarnphm.xyz/llms-full.txt
---
# [#51612](https://github.com/aarnphm/aarnphm.github.io/issues/51612) \[4/N\]\[KV-Cache Layout Refactor\] Promote local KV cache specs via a class-changing replace helper

[vllm-project/vllm#51612](https://github.com/vllm-project/vllm/pull/51612) · LucasWilkinson · MERGED · created 2026-08-10T04:21:43Z · merged 2026-08-11T21:29:30Z

## Purpose

`_promote_local_kv_cache_specs` rebuilds each promoted spec with a hand-written constructor call per class, and the explicit field lists have drifted: the MLA and chunked-local promotions silently drop `kv_quant_mode` (mis-sizing promoted pages for quantized KV caches), and the chunked-local promotion drops `head_size_v`.

This PR adds `replace_as()` — `dataclasses.replace` generalized to rebuild a spec as a different class — and drives the promotion from a source→target class mapping resolved through the MRO (the `functools.singledispatch` idiom, so subclasses hit their own entry first). Every shared field is carried automatically; new spec fields can no longer be silently lost in promotion.

Behavior changes (both bug fixes):

- Promoted MLA and chunked-local specs now retain `kv_quant_mode`.
- Promoted `SlidingWindowMLASpec` records its `sliding_window`, matching what the `SlidingWindowSpec` promotion already does per the `FullAttentionSpec` docstring (“we use FullAttentionSpec and record the sliding window size”).

Extracted from the KV-layout standardization work ([#44458](https://github.com/aarnphm/aarnphm.github.io/issues/44458) / RFC [#42082](https://github.com/aarnphm/aarnphm.github.io/issues/42082)) since it stands alone.

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

---

## comments

**LucasWilkinson** (2026-08-10T04:26:13Z):

/ci run

**github-actions** (2026-08-10T04:26:28Z):

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

**mergify** (2026-08-10T04:33:51Z):

Hi @LucasWilkinson, the pre-commit checks have failed. Please run:



```bash
uv pip install pre-commit>=4.5.1
pre-commit install
pre-commit run --all-files
```

Then, commit the changes and push to your branch.

For future commits, `pre-commit` will run automatically on changed files before each commit.

**LucasWilkinson** (2026-08-10T15:53:34Z):

/ci run

**mergify** (2026-08-10T16:13:54Z):

Hi @LucasWilkinson, the pre-commit checks have failed. Please run:



```bash
uv pip install pre-commit>=4.5.1
pre-commit install
pre-commit run --all-files
```

Then, commit the changes and push to your branch.

For future commits, `pre-commit` will run automatically on changed files before each commit.

**LucasWilkinson** (2026-08-10T18:51:59Z):

/ci run

**github-actions** (2026-08-10T18:52:23Z):

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

**njhill** (2026-08-11T14:17:34Z):

The CI failure should hopefully be fixed by this: [vllm-project/vllm#51756](https://github.com/vllm-project/vllm/pull/51756) (we could merge it first)

**njhill** (2026-08-11T18:12:15Z):

/ci run

**github-actions** (2026-08-11T18:12:33Z):

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

**njhill** (2026-08-11T19:36:10Z):

/ci run

**github-actions** (2026-08-11T19:36:28Z):

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

