Skip to content

[WIP]feat: support qwen3.5 linear-state prefix cache.#1839

Draft
yingxudeng wants to merge 1 commit into
xLLM-AI:mainfrom
yingxudeng:feat/qwen35_prefix_cache_main_0628
Draft

[WIP]feat: support qwen3.5 linear-state prefix cache.#1839
yingxudeng wants to merge 1 commit into
xLLM-AI:mainfrom
yingxudeng:feat/qwen35_prefix_cache_main_0628

Conversation

@yingxudeng

@yingxudeng yingxudeng commented Jun 27, 2026

Copy link
Copy Markdown
Collaborator

Description

Related Issues

Change Type

  • Bug fix
  • New feature
  • Performance improvement
  • Refactor
  • Documentation
  • Test
  • Build or CI

Pull Request Checklist

Thank you for contributing to xLLM. Before requesting review, please make sure the following items are complete.

PR Title and Commit Messages

  • The PR title and each commit message follow the xLLM commit format: <type>: <subject>.

Allowed types: feat, bugfix, docs, test, refactor, chore, style, revert, perf, model, build, release.
The subject should use clear English, start with a verb, include at least 4 words, and end with ..

Pre-commit Checks

  • I have installed pre-commit by running pip install pre-commit or an equivalent command.
  • I have installed the hooks with pre-commit install.
  • I have run pre-commit run --all-files and fixed any reported issues.

If you are unsure how to set up pre-commit, see the pre-commit documentation.

Self Review

  • I have self-reviewed the code according to .agents/skills/code-review/references/custom-code-style.md, especially code written or assisted by AI.
  • I have rebased this PR onto the latest main branch.

Build and Test Coverage

  • Tests have been added or updated as needed.
  • CUDA: python setup.py build test has passed on a CUDA machine.
  • NPU: python setup.py build test has passed on an NPU machine.
  • MLU: python setup.py build test has passed on an MLU machine.

Reviewer Notes

pr说明如下:
https://yingxudeng.github.io/xllm-notes/reports/qwen35-linear-prefix-cache-pr1839/

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces linear-state prefix caching for Qwen3.5 GDN recurrent states, implementing a dedicated LinearStateBlockManager to manage checkpoints and live slots with LRU eviction and zero-copy promotion. It integrates linear-state checkpointing and restoration across the LLM/VLM engines, batch input builders, and chunked prefill schedulers, supported by updated KV cache estimation and extensive unit tests. The code review feedback highlights several style guide violations, specifically regarding naming conventions (recommending snake_case for functions and snake_case_ for member variables) and scoping rules (requiring file-local helper functions to be placed in anonymous namespaces).

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +52 to +56
LinearStatePrefixHash MakePrefixHash(uint8_t tag) {
LinearStatePrefixHash hash{};
hash.fill(tag);
return hash;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The function MakePrefixHash violates the naming convention specified in the repository style guide. Functions must be named using snake_case.

LinearStatePrefixHash make_prefix_hash(uint8_t tag) {\n  LinearStatePrefixHash hash{};\n  hash.fill(tag);\n  return hash;\n}
References
  1. Functions must be named using snake_case. (link)

Comment on lines +67 to +71
int32_t dp_rank = -1;
// Pin matched checkpoints until the worker copies them into sequence-owned
// live slots on the compute stream.
std::vector<Block> restore_pins;
std::vector<Promotion> promotions;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The member variables dp_rank, restore_pins, and promotions in the class LinearStateCheckpointReservations violate the naming convention specified in the repository style guide. Member variables must use snake_case_ (with a trailing underscore).

  int32_t dp_rank_ = -1;\n  // Pin matched checkpoints until the worker copies them into sequence-owned\n  // live slots on the compute stream.\n  std::vector<Block> restore_pins_;\n  std::vector<Promotion> promotions_;
References
  1. Member variables must use snake_case_ (with a trailing underscore). (link)

Comment thread xllm/core/framework/kv_cache/kv_cache_estimation.cpp
Comment thread tests/core/framework/batch/batch_test.cpp
@yingxudeng yingxudeng force-pushed the feat/qwen35_prefix_cache_main_0628 branch 24 times, most recently from d2c4c3d to 23fb5d7 Compare July 4, 2026 05:07
@yingxudeng yingxudeng force-pushed the feat/qwen35_prefix_cache_main_0628 branch from 23fb5d7 to 2b9ab40 Compare July 6, 2026 03:54
@yingxudeng yingxudeng force-pushed the feat/qwen35_prefix_cache_main_0628 branch 3 times, most recently from 85a863f to 1bf85ef Compare July 7, 2026 06:26
@yingxudeng yingxudeng force-pushed the feat/qwen35_prefix_cache_main_0628 branch 9 times, most recently from 88b05a8 to 2cbc641 Compare July 8, 2026 14:42
@yingxudeng yingxudeng force-pushed the feat/qwen35_prefix_cache_main_0628 branch from 2cbc641 to 20cfd3f Compare July 14, 2026 07:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant