[Bugfix][MRV1] Fix KV cache buffer corruption for extracting hidden states - #13498
Conversation
…en-state layers When a KV cache tensor's shared_by list contains both MambaSpec and HiddenStateCacheSpec layers, sharing one physical buffer causes float32 ssm_state writes to overwrite bfloat16 hidden-states data (same bytes, different interpretation). Allocate a separate tensor for the HiddenStateCacheSpec layers in that case. Also: - Route AscendExtractHiddenStatesProposer to cm_base when selecting spec_decode_common_attn_metadata so it uses the base KV cache group. - Validate that extract_hidden_states drafter layers live in a single KV cache group during initialize_kv_cache. Signed-off-by: chenyue1122 <oyoy7102@163.com>
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a critical memory corruption issue occurring in hybrid model configurations where Mamba and hidden-state extraction layers share the same physical KV cache buffer. By isolating memory allocations for these specific layer types, the fix prevents incompatible data types from overwriting each other. Additionally, the PR improves the robustness of the speculative decoding pipeline by correctly wiring the Ascend-specific proposer and adding validation checks during KV cache initialization. Highlights
New Features🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
|
👋 Hi! Thank you for contributing to the vLLM Ascend project. The following points will speed up your PR merge:
If CI fails, you can run linting and testing checks locally according Contributing and Testing. Tip 💡 Consider Linking a Related Issue or RFCYour PR title contains the [BugFix] tag, indicating a bug fix or new feature. Linking a related issue or RFC in the PR description is strongly encouraged — it gives reviewers helpful context and speeds up the review. You can use any of these keywords:
🙏 Thanks for helping us keep the project well-organized! |
There was a problem hiding this comment.
Code Review
Suggested PR Title:
[Ops][BugFix] Prevent memory corruption between Mamba and HiddenStateCache specs in KV cache allocationSuggested PR Summary:
### What this PR does / why we need it?
This PR adds support for `AscendExtractHiddenStatesProposer` and prevents memory corruption when `shared_by` contains both `MambaSpec` and `HiddenStateCacheSpec` by allocating separate physical memory tensors. It also adds validation for speculative decoding configuration.
Feedback:
- Avoid code duplication in `_allocate_kv_cache_tensors` by using the existing helper method `_allocate_int8_cache_tensor`.
- Replace the runtime `assert` statement with an explicit type check and `TypeError` to ensure robustness in production environments.
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
CI passed with existing tests.| if self.vllm_config.kv_transfer_config is None: | ||
| tensor = torch.zeros(kv_cache_tensor.size, dtype=torch.int8, device=self.device) | ||
| else: | ||
| cache_size_aligned = kv_cache_tensor.size + alignment | ||
| tensor = torch.zeros(cache_size_aligned, dtype=torch.int8, device=self.device) | ||
| tensor = self._align_memory(tensor, alignment)[: kv_cache_tensor.size] | ||
|
|
||
| for layer_name_inner in kv_cache_tensor.shared_by: | ||
| # shared the kvcache for all shared layers | ||
| kv_cache_raw_tensors[layer_name_inner] = tensor | ||
| if has_mamba and has_hidden: | ||
| # Allocate separate tensor for HiddenStateCacheSpec layers | ||
| # so ssm_state writes don't corrupt hidden-states data | ||
| if self.vllm_config.kv_transfer_config is None: | ||
| tensor_hs = torch.zeros(kv_cache_tensor.size, dtype=torch.int8, device=self.device) | ||
| else: | ||
| cache_size_aligned = kv_cache_tensor.size + alignment | ||
| tensor_hs = torch.zeros(cache_size_aligned, dtype=torch.int8, device=self.device) | ||
| tensor_hs = self._align_memory(tensor_hs, alignment)[: kv_cache_tensor.size] |
There was a problem hiding this comment.
There is an existing helper method _allocate_int8_cache_tensor defined in this class that handles the exact same allocation and alignment logic (including checking kv_transfer_config and performing _align_memory). Using this helper method here for both tensor and tensor_hs avoids code duplication, simplifies the logic, and makes the code much more maintainable.
| if self.vllm_config.kv_transfer_config is None: | |
| tensor = torch.zeros(kv_cache_tensor.size, dtype=torch.int8, device=self.device) | |
| else: | |
| cache_size_aligned = kv_cache_tensor.size + alignment | |
| tensor = torch.zeros(cache_size_aligned, dtype=torch.int8, device=self.device) | |
| tensor = self._align_memory(tensor, alignment)[: kv_cache_tensor.size] | |
| for layer_name_inner in kv_cache_tensor.shared_by: | |
| # shared the kvcache for all shared layers | |
| kv_cache_raw_tensors[layer_name_inner] = tensor | |
| if has_mamba and has_hidden: | |
| # Allocate separate tensor for HiddenStateCacheSpec layers | |
| # so ssm_state writes don't corrupt hidden-states data | |
| if self.vllm_config.kv_transfer_config is None: | |
| tensor_hs = torch.zeros(kv_cache_tensor.size, dtype=torch.int8, device=self.device) | |
| else: | |
| cache_size_aligned = kv_cache_tensor.size + alignment | |
| tensor_hs = torch.zeros(cache_size_aligned, dtype=torch.int8, device=self.device) | |
| tensor_hs = self._align_memory(tensor_hs, alignment)[: kv_cache_tensor.size] | |
| tensor = self._allocate_int8_cache_tensor(kv_cache_tensor.size, alignment) | |
| if has_mamba and has_hidden: | |
| # Allocate separate tensor for HiddenStateCacheSpec layers | |
| # so ssm_state writes don't corrupt hidden-states data | |
| tensor_hs = self._allocate_int8_cache_tensor(kv_cache_tensor.size, alignment) |
| self.speculative_config | ||
| and self.speculative_config.uses_extract_hidden_states() | ||
| ): | ||
| assert isinstance(self.drafter, AscendExtractHiddenStatesProposer) |
There was a problem hiding this comment.
Using assert statements for runtime type validation or configuration checks is discouraged in production code. Assertions can be globally disabled when Python is run with optimization flags (e.g., python -O), which would bypass this type check entirely and potentially lead to an unhandled AttributeError on the subsequent line. It is safer and more robust to explicitly check the type and raise a TypeError.
| assert isinstance(self.drafter, AscendExtractHiddenStatesProposer) | |
| if not isinstance(self.drafter, AscendExtractHiddenStatesProposer): | |
| raise TypeError( | |
| "Expected self.drafter to be an instance of " | |
| "AscendExtractHiddenStatesProposer when " | |
| "uses_extract_hidden_states is True." | |
| ) |
|
LGTM. Upstream vLLM doesn't have this problem because its KV cache config builder isolates incompatible spec types into separate KVCacheTensor entries before allocation ever runs, while the Ascend fork's rewritten _allocate_kv_cache_tensors lumps all non-attention layer types into a single shared buffer, breaking that isolation. |
…tadata and add NaN/Inf guard Two related follow-ups on the KV cache buffer corruption fix in commit 8d58ec7 (PR vllm-project#13498): - worker/model_runner_v1.py: In the spec-decode branch that selects `spec_decode_common_attn_metadata` for `AscendExtractHiddenStatesProposer`, use the group-specific `cm` instead of `cm_base` when the drafter's `kv_cache_gid` matches the current KV cache group. Now that the drafter owns a dedicated `HiddenStateCacheSpec` tensor (separated from the Mamba ssm_state buffer), it must consult attention metadata scoped to its own KV cache group rather than the base group's metadata. - tests/e2e/.../spec_decode/test_extract_hidden_states.py: Extend `_verify_output` with `torch.isnan` / `torch.isinf` assertions on the extracted hidden states. This applies to every parametrized case (dense eager, dense ACL graph, hybrid dummy-weight) so a re-aliased Mamba + HiddenStateCacheSpec buffer would be caught even in dummy-weight runs where non-zero cannot be asserted. Signed-off-by: chenyue1122 <oyoy7102@163.com>
The Inf-check assertion message in `_verify_output` fits on one line at the project's 120-char limit; ruff-format collapses it accordingly. This fixes the pre-commit CI failure on PR vllm-project#13498 where the hook made changes that were not committed locally. Signed-off-by: chenyue1122 <oyoy7102@163.com>
Drop the PR reference from the assertion messages so they stay concise and self-contained. Signed-off-by: chenyue1122 <oyoy7102@163.com>
…tates (vllm-project#13498) When a KV cache tensor's shared_by list contains both MambaSpec and HiddenStateCacheSpec layers, sharing one physical buffer causes float32 ssm_state writes to overwrite bfloat16 hidden-states data (same bytes, different interpretation). Allocate a separate tensor for the HiddenStateCacheSpec layers in that case. Also: - Route AscendExtractHiddenStatesProposer to cm_base when selecting spec_decode_common_attn_metadata so it uses the base KV cache group. - Validate that extract_hidden_states drafter layers live in a single KV cache group during initialize_kv_cache. ### What this PR does / why we need it? Fix KV cache buffer corruption for hybrid model configurations that use both Mamba layers and extract-hidden-states layers in the same KV cache tensor group. Also wire AscendExtractHiddenStatesProposer into the spec-decode attention metadata plumbing. - The added has_mamba / has_hidden scan runs only inside the existing hybrid/hidden-state branch, so the hot path for plain attention layers is untouched. - Alignment handling (_align_memory with kv_transfer_config) is duplicated for the new tensor_hs; keeping the two allocations symmetric was intentional so KV-transfer setups behave identically for both buffers. - No new public API. Behavior for non-hybrid configs is byte-for-byte identical. ### Does this PR introduce _any_ user-facing change? No. Signed-off-by: chenyue1122 oyoy7102@163.com - vLLM version: v0.26.0 - vLLM main: vllm-project/vllm@0351e9a --------- Signed-off-by: chenyue1122 <oyoy7102@163.com>
…tates (vllm-project#13498) When a KV cache tensor's shared_by list contains both MambaSpec and HiddenStateCacheSpec layers, sharing one physical buffer causes float32 ssm_state writes to overwrite bfloat16 hidden-states data (same bytes, different interpretation). Allocate a separate tensor for the HiddenStateCacheSpec layers in that case. Also: - Route AscendExtractHiddenStatesProposer to cm_base when selecting spec_decode_common_attn_metadata so it uses the base KV cache group. - Validate that extract_hidden_states drafter layers live in a single KV cache group during initialize_kv_cache. Fix KV cache buffer corruption for hybrid model configurations that use both Mamba layers and extract-hidden-states layers in the same KV cache tensor group. Also wire AscendExtractHiddenStatesProposer into the spec-decode attention metadata plumbing. - The added has_mamba / has_hidden scan runs only inside the existing hybrid/hidden-state branch, so the hot path for plain attention layers is untouched. - Alignment handling (_align_memory with kv_transfer_config) is duplicated for the new tensor_hs; keeping the two allocations symmetric was intentional so KV-transfer setups behave identically for both buffers. - No new public API. Behavior for non-hybrid configs is byte-for-byte identical. No. Signed-off-by: chenyue1122 oyoy7102@163.com - vLLM version: v0.26.0 - vLLM main: vllm-project/vllm@0351e9a --------- Signed-off-by: chenyue1122 <oyoy7102@163.com>
…tates (vllm-project#13498) When a KV cache tensor's shared_by list contains both MambaSpec and HiddenStateCacheSpec layers, sharing one physical buffer causes float32 ssm_state writes to overwrite bfloat16 hidden-states data (same bytes, different interpretation). Allocate a separate tensor for the HiddenStateCacheSpec layers in that case. Also: - Route AscendExtractHiddenStatesProposer to cm_base when selecting spec_decode_common_attn_metadata so it uses the base KV cache group. - Validate that extract_hidden_states drafter layers live in a single KV cache group during initialize_kv_cache. Fix KV cache buffer corruption for hybrid model configurations that use both Mamba layers and extract-hidden-states layers in the same KV cache tensor group. Also wire AscendExtractHiddenStatesProposer into the spec-decode attention metadata plumbing. - The added has_mamba / has_hidden scan runs only inside the existing hybrid/hidden-state branch, so the hot path for plain attention layers is untouched. - Alignment handling (_align_memory with kv_transfer_config) is duplicated for the new tensor_hs; keeping the two allocations symmetric was intentional so KV-transfer setups behave identically for both buffers. - No new public API. Behavior for non-hybrid configs is byte-for-byte identical. No. Signed-off-by: chenyue1122 oyoy7102@163.com - vLLM version: v0.26.0 - vLLM main: vllm-project/vllm@0351e9a --------- Signed-off-by: chenyue1122 <oyoy7102@163.com> Signed-off-by: lijiaqi139 <lijiaqi139@huawei.com>
…tates (vllm-project#13498) When a KV cache tensor's shared_by list contains both MambaSpec and HiddenStateCacheSpec layers, sharing one physical buffer causes float32 ssm_state writes to overwrite bfloat16 hidden-states data (same bytes, different interpretation). Allocate a separate tensor for the HiddenStateCacheSpec layers in that case. Also: - Route AscendExtractHiddenStatesProposer to cm_base when selecting spec_decode_common_attn_metadata so it uses the base KV cache group. - Validate that extract_hidden_states drafter layers live in a single KV cache group during initialize_kv_cache. Fix KV cache buffer corruption for hybrid model configurations that use both Mamba layers and extract-hidden-states layers in the same KV cache tensor group. Also wire AscendExtractHiddenStatesProposer into the spec-decode attention metadata plumbing. - The added has_mamba / has_hidden scan runs only inside the existing hybrid/hidden-state branch, so the hot path for plain attention layers is untouched. - Alignment handling (_align_memory with kv_transfer_config) is duplicated for the new tensor_hs; keeping the two allocations symmetric was intentional so KV-transfer setups behave identically for both buffers. - No new public API. Behavior for non-hybrid configs is byte-for-byte identical. No. Signed-off-by: chenyue1122 oyoy7102@163.com - vLLM version: v0.26.0 - vLLM main: vllm-project/vllm@0351e9a --------- Signed-off-by: chenyue1122 <oyoy7102@163.com> Signed-off-by: lijiaqi139 <lijiaqi139@huawei.com>
…tates (vllm-project#13498) When a KV cache tensor's shared_by list contains both MambaSpec and HiddenStateCacheSpec layers, sharing one physical buffer causes float32 ssm_state writes to overwrite bfloat16 hidden-states data (same bytes, different interpretation). Allocate a separate tensor for the HiddenStateCacheSpec layers in that case. Also: - Route AscendExtractHiddenStatesProposer to cm_base when selecting spec_decode_common_attn_metadata so it uses the base KV cache group. - Validate that extract_hidden_states drafter layers live in a single KV cache group during initialize_kv_cache. Fix KV cache buffer corruption for hybrid model configurations that use both Mamba layers and extract-hidden-states layers in the same KV cache tensor group. Also wire AscendExtractHiddenStatesProposer into the spec-decode attention metadata plumbing. - The added has_mamba / has_hidden scan runs only inside the existing hybrid/hidden-state branch, so the hot path for plain attention layers is untouched. - Alignment handling (_align_memory with kv_transfer_config) is duplicated for the new tensor_hs; keeping the two allocations symmetric was intentional so KV-transfer setups behave identically for both buffers. - No new public API. Behavior for non-hybrid configs is byte-for-byte identical. No. Signed-off-by: chenyue1122 oyoy7102@163.com - vLLM version: v0.26.0 - vLLM main: vllm-project/vllm@0351e9a --------- Signed-off-by: chenyue1122 <oyoy7102@163.com> Signed-off-by: lijiaqi139 <lijiaqi139@huawei.com>
…tates (vllm-project#13498) When a KV cache tensor's shared_by list contains both MambaSpec and HiddenStateCacheSpec layers, sharing one physical buffer causes float32 ssm_state writes to overwrite bfloat16 hidden-states data (same bytes, different interpretation). Allocate a separate tensor for the HiddenStateCacheSpec layers in that case. Also: - Route AscendExtractHiddenStatesProposer to cm_base when selecting spec_decode_common_attn_metadata so it uses the base KV cache group. - Validate that extract_hidden_states drafter layers live in a single KV cache group during initialize_kv_cache. Fix KV cache buffer corruption for hybrid model configurations that use both Mamba layers and extract-hidden-states layers in the same KV cache tensor group. Also wire AscendExtractHiddenStatesProposer into the spec-decode attention metadata plumbing. - The added has_mamba / has_hidden scan runs only inside the existing hybrid/hidden-state branch, so the hot path for plain attention layers is untouched. - Alignment handling (_align_memory with kv_transfer_config) is duplicated for the new tensor_hs; keeping the two allocations symmetric was intentional so KV-transfer setups behave identically for both buffers. - No new public API. Behavior for non-hybrid configs is byte-for-byte identical. No. Signed-off-by: chenyue1122 oyoy7102@163.com - vLLM version: v0.26.0 - vLLM main: vllm-project/vllm@0351e9a --------- Signed-off-by: chenyue1122 <oyoy7102@163.com> Signed-off-by: lijiaqi139 <lijiaqi139@huawei.com>
…tates (vllm-project#13498) When a KV cache tensor's shared_by list contains both MambaSpec and HiddenStateCacheSpec layers, sharing one physical buffer causes float32 ssm_state writes to overwrite bfloat16 hidden-states data (same bytes, different interpretation). Allocate a separate tensor for the HiddenStateCacheSpec layers in that case. Also: - Route AscendExtractHiddenStatesProposer to cm_base when selecting spec_decode_common_attn_metadata so it uses the base KV cache group. - Validate that extract_hidden_states drafter layers live in a single KV cache group during initialize_kv_cache. Fix KV cache buffer corruption for hybrid model configurations that use both Mamba layers and extract-hidden-states layers in the same KV cache tensor group. Also wire AscendExtractHiddenStatesProposer into the spec-decode attention metadata plumbing. - The added has_mamba / has_hidden scan runs only inside the existing hybrid/hidden-state branch, so the hot path for plain attention layers is untouched. - Alignment handling (_align_memory with kv_transfer_config) is duplicated for the new tensor_hs; keeping the two allocations symmetric was intentional so KV-transfer setups behave identically for both buffers. - No new public API. Behavior for non-hybrid configs is byte-for-byte identical. No. Signed-off-by: chenyue1122 oyoy7102@163.com - vLLM version: v0.26.0 - vLLM main: vllm-project/vllm@0351e9a --------- Signed-off-by: chenyue1122 <oyoy7102@163.com> Signed-off-by: lijiaqi139 <lijiaqi139@huawei.com> Signed-off-by: jiaqi-lee <15316070896@163.com>
…tates (vllm-project#13498) When a KV cache tensor's shared_by list contains both MambaSpec and HiddenStateCacheSpec layers, sharing one physical buffer causes float32 ssm_state writes to overwrite bfloat16 hidden-states data (same bytes, different interpretation). Allocate a separate tensor for the HiddenStateCacheSpec layers in that case. Also: - Route AscendExtractHiddenStatesProposer to cm_base when selecting spec_decode_common_attn_metadata so it uses the base KV cache group. - Validate that extract_hidden_states drafter layers live in a single KV cache group during initialize_kv_cache. Fix KV cache buffer corruption for hybrid model configurations that use both Mamba layers and extract-hidden-states layers in the same KV cache tensor group. Also wire AscendExtractHiddenStatesProposer into the spec-decode attention metadata plumbing. - The added has_mamba / has_hidden scan runs only inside the existing hybrid/hidden-state branch, so the hot path for plain attention layers is untouched. - Alignment handling (_align_memory with kv_transfer_config) is duplicated for the new tensor_hs; keeping the two allocations symmetric was intentional so KV-transfer setups behave identically for both buffers. - No new public API. Behavior for non-hybrid configs is byte-for-byte identical. No. Signed-off-by: chenyue1122 oyoy7102@163.com - vLLM version: v0.26.0 - vLLM main: vllm-project/vllm@0351e9a --------- Signed-off-by: chenyue1122 <oyoy7102@163.com> Signed-off-by: lijiaqi139 <lijiaqi139@huawei.com> Signed-off-by: jiaqi-lee <15316070896@163.com>
…tates (vllm-project#13498) When a KV cache tensor's shared_by list contains both MambaSpec and HiddenStateCacheSpec layers, sharing one physical buffer causes float32 ssm_state writes to overwrite bfloat16 hidden-states data (same bytes, different interpretation). Allocate a separate tensor for the HiddenStateCacheSpec layers in that case. Also: - Route AscendExtractHiddenStatesProposer to cm_base when selecting spec_decode_common_attn_metadata so it uses the base KV cache group. - Validate that extract_hidden_states drafter layers live in a single KV cache group during initialize_kv_cache. ### What this PR does / why we need it? Fix KV cache buffer corruption for hybrid model configurations that use both Mamba layers and extract-hidden-states layers in the same KV cache tensor group. Also wire AscendExtractHiddenStatesProposer into the spec-decode attention metadata plumbing. - The added has_mamba / has_hidden scan runs only inside the existing hybrid/hidden-state branch, so the hot path for plain attention layers is untouched. - Alignment handling (_align_memory with kv_transfer_config) is duplicated for the new tensor_hs; keeping the two allocations symmetric was intentional so KV-transfer setups behave identically for both buffers. - No new public API. Behavior for non-hybrid configs is byte-for-byte identical. ### Does this PR introduce _any_ user-facing change? No. Signed-off-by: chenyue1122 oyoy7102@163.com - vLLM version: v0.26.0 - vLLM main: vllm-project/vllm@0351e9a --------- Signed-off-by: chenyue1122 <oyoy7102@163.com>
…tates (vllm-project#13498) When a KV cache tensor's shared_by list contains both MambaSpec and HiddenStateCacheSpec layers, sharing one physical buffer causes float32 ssm_state writes to overwrite bfloat16 hidden-states data (same bytes, different interpretation). Allocate a separate tensor for the HiddenStateCacheSpec layers in that case. Also: - Route AscendExtractHiddenStatesProposer to cm_base when selecting spec_decode_common_attn_metadata so it uses the base KV cache group. - Validate that extract_hidden_states drafter layers live in a single KV cache group during initialize_kv_cache. Fix KV cache buffer corruption for hybrid model configurations that use both Mamba layers and extract-hidden-states layers in the same KV cache tensor group. Also wire AscendExtractHiddenStatesProposer into the spec-decode attention metadata plumbing. - The added has_mamba / has_hidden scan runs only inside the existing hybrid/hidden-state branch, so the hot path for plain attention layers is untouched. - Alignment handling (_align_memory with kv_transfer_config) is duplicated for the new tensor_hs; keeping the two allocations symmetric was intentional so KV-transfer setups behave identically for both buffers. - No new public API. Behavior for non-hybrid configs is byte-for-byte identical. No. Signed-off-by: chenyue1122 oyoy7102@163.com - vLLM version: v0.26.0 - vLLM main: vllm-project/vllm@0351e9a --------- Signed-off-by: chenyue1122 <oyoy7102@163.com> Signed-off-by: lijiaqi139 <lijiaqi139@huawei.com> Signed-off-by: jiaqi-lee <15316070896@163.com>
…tates (vllm-project#13498) When a KV cache tensor's shared_by list contains both MambaSpec and HiddenStateCacheSpec layers, sharing one physical buffer causes float32 ssm_state writes to overwrite bfloat16 hidden-states data (same bytes, different interpretation). Allocate a separate tensor for the HiddenStateCacheSpec layers in that case. Also: - Route AscendExtractHiddenStatesProposer to cm_base when selecting spec_decode_common_attn_metadata so it uses the base KV cache group. - Validate that extract_hidden_states drafter layers live in a single KV cache group during initialize_kv_cache. ### What this PR does / why we need it? Fix KV cache buffer corruption for hybrid model configurations that use both Mamba layers and extract-hidden-states layers in the same KV cache tensor group. Also wire AscendExtractHiddenStatesProposer into the spec-decode attention metadata plumbing. - The added has_mamba / has_hidden scan runs only inside the existing hybrid/hidden-state branch, so the hot path for plain attention layers is untouched. - Alignment handling (_align_memory with kv_transfer_config) is duplicated for the new tensor_hs; keeping the two allocations symmetric was intentional so KV-transfer setups behave identically for both buffers. - No new public API. Behavior for non-hybrid configs is byte-for-byte identical. ### Does this PR introduce _any_ user-facing change? No. Signed-off-by: chenyue1122 oyoy7102@163.com - vLLM version: v0.26.0 - vLLM main: vllm-project/vllm@0351e9a --------- Signed-off-by: chenyue1122 <oyoy7102@163.com>
…tates (vllm-project#13498) When a KV cache tensor's shared_by list contains both MambaSpec and HiddenStateCacheSpec layers, sharing one physical buffer causes float32 ssm_state writes to overwrite bfloat16 hidden-states data (same bytes, different interpretation). Allocate a separate tensor for the HiddenStateCacheSpec layers in that case. Also: - Route AscendExtractHiddenStatesProposer to cm_base when selecting spec_decode_common_attn_metadata so it uses the base KV cache group. - Validate that extract_hidden_states drafter layers live in a single KV cache group during initialize_kv_cache. Fix KV cache buffer corruption for hybrid model configurations that use both Mamba layers and extract-hidden-states layers in the same KV cache tensor group. Also wire AscendExtractHiddenStatesProposer into the spec-decode attention metadata plumbing. - The added has_mamba / has_hidden scan runs only inside the existing hybrid/hidden-state branch, so the hot path for plain attention layers is untouched. - Alignment handling (_align_memory with kv_transfer_config) is duplicated for the new tensor_hs; keeping the two allocations symmetric was intentional so KV-transfer setups behave identically for both buffers. - No new public API. Behavior for non-hybrid configs is byte-for-byte identical. No. Signed-off-by: chenyue1122 oyoy7102@163.com - vLLM version: v0.26.0 - vLLM main: vllm-project/vllm@0351e9a --------- Signed-off-by: chenyue1122 <oyoy7102@163.com> Signed-off-by: lijiaqi139 <lijiaqi139@huawei.com> Signed-off-by: jiaqi-lee <15316070896@163.com> (cherry picked from commit 62458e4)
…tates (vllm-project#13498) When a KV cache tensor's shared_by list contains both MambaSpec and HiddenStateCacheSpec layers, sharing one physical buffer causes float32 ssm_state writes to overwrite bfloat16 hidden-states data (same bytes, different interpretation). Allocate a separate tensor for the HiddenStateCacheSpec layers in that case. Also: - Route AscendExtractHiddenStatesProposer to cm_base when selecting spec_decode_common_attn_metadata so it uses the base KV cache group. - Validate that extract_hidden_states drafter layers live in a single KV cache group during initialize_kv_cache. Fix KV cache buffer corruption for hybrid model configurations that use both Mamba layers and extract-hidden-states layers in the same KV cache tensor group. Also wire AscendExtractHiddenStatesProposer into the spec-decode attention metadata plumbing. - The added has_mamba / has_hidden scan runs only inside the existing hybrid/hidden-state branch, so the hot path for plain attention layers is untouched. - Alignment handling (_align_memory with kv_transfer_config) is duplicated for the new tensor_hs; keeping the two allocations symmetric was intentional so KV-transfer setups behave identically for both buffers. - No new public API. Behavior for non-hybrid configs is byte-for-byte identical. No. Signed-off-by: chenyue1122 oyoy7102@163.com - vLLM version: v0.26.0 - vLLM main: vllm-project/vllm@0351e9a --------- Signed-off-by: chenyue1122 <oyoy7102@163.com> Signed-off-by: lijiaqi139 <lijiaqi139@huawei.com> Signed-off-by: jiaqi-lee <15316070896@163.com> (cherry picked from commit 62458e4) Signed-off-by: jiaqi-lee <15316070896@163.com>
…tates (vllm-project#13498) When a KV cache tensor's shared_by list contains both MambaSpec and HiddenStateCacheSpec layers, sharing one physical buffer causes float32 ssm_state writes to overwrite bfloat16 hidden-states data (same bytes, different interpretation). Allocate a separate tensor for the HiddenStateCacheSpec layers in that case. Also: - Route AscendExtractHiddenStatesProposer to cm_base when selecting spec_decode_common_attn_metadata so it uses the base KV cache group. - Validate that extract_hidden_states drafter layers live in a single KV cache group during initialize_kv_cache. Fix KV cache buffer corruption for hybrid model configurations that use both Mamba layers and extract-hidden-states layers in the same KV cache tensor group. Also wire AscendExtractHiddenStatesProposer into the spec-decode attention metadata plumbing. - The added has_mamba / has_hidden scan runs only inside the existing hybrid/hidden-state branch, so the hot path for plain attention layers is untouched. - Alignment handling (_align_memory with kv_transfer_config) is duplicated for the new tensor_hs; keeping the two allocations symmetric was intentional so KV-transfer setups behave identically for both buffers. - No new public API. Behavior for non-hybrid configs is byte-for-byte identical. No. Signed-off-by: chenyue1122 oyoy7102@163.com - vLLM version: v0.26.0 - vLLM main: vllm-project/vllm@0351e9a --------- Signed-off-by: chenyue1122 <oyoy7102@163.com> Signed-off-by: lijiaqi139 <lijiaqi139@huawei.com> Signed-off-by: jiaqi-lee <15316070896@163.com> (cherry picked from commit 62458e4) Signed-off-by: jiaqi-lee <15316070896@163.com>
…#14687) ### What this PR does / why we need it? This is the v0.26.0 release-blocker backport rollup. It contains only the 19 audited high-severity correctness and stability fixes that were still missing from releases/v0.26.0rc at 1f95052. The branch has 23 physical commits because #14619 is preserved as its complete five-commit atomic series. Cross-branch equivalents are deduplicated, and every logical fix remains independently reviewable and revertible. #### Included fixes | # | Source / target PR | Severity | Problem fixed | |---:|---|---|---| | 1 | #13538 | P0 correctness | Qwen3-VL MoE + FlashComm1 + deepstack used the wrong residual tensor and could silently corrupt output. | | 2 | #13600 | P0 deadlock | MRV1/MRV2 main and draft update streams could mutually wait during repeated full-graph execution. | | 3 | #13498 | P0 data corruption | Float32 Mamba state could overwrite the shared bf16 hidden-state cache buffer. | | 4 | #13902 | P0 correctness | RL weight reload left ACL graphs referencing stale W8A8-MXFP8 weight addresses. | | 5 | #12359 / #12371 | P0 correctness | Mooncake reformatted KV before all TP/CP pulls for a request completed, causing TP inequality or reordered KV. | | 6 | #13111 / #13113 / #13110 | P1 KV correctness | Multi-KV-group save/load incorrectly reused group-0 block size for every group. | | 7 | #13116 / #13117 / #13099 | P1 state consistency | Async KV load failures were not shared with the scheduler, preventing recompute recovery. | | 8 | #13308 / #13310 / #13307 | P1 crash | Memcache batch query/allocation before lazy initialization could assert in scheduler or worker. | | 9 | #13012 | P1 hang/corruption | Level-2 sleep/wake could lose the MoE loader and leave EPLB tensors pointing at released storage. | | 10 | #13414 | P1 crash/correctness | Dynamic EPLB initialized W8A8 scales for only the first expert weight. | | 11 | #14001 | P1 crash | MiniMax-M3 index_q was reshaped using total size instead of the per-head dimension. | | 12 | #14394 | P1 crash/hang | MRV2 FULL_DECODE_ONLY dropped graph padding when runtime mode was FULL. | | 13 | #13136 | P1 crash | P/D + DP zero-token ranks compared None with MC2 capacity and raised TypeError. | | 14 | #13183 | P1 unavailable | ec_both was treated as producer-only and skipped KV specification/data needed by its consumer role. | | 15 | #13123 | P1 OOB/device error | MRV2 dummy-token remainder was concentrated on one request and could exceed max_model_len. | | 16 | #13159 | P1 crash | MRV2 num_nans used the wrong Triton libdevice and the penalty kernel could exceed the CANN grid limit. | | 17 | #12940 | P1 crash | DFlash profiling used total query count instead of actual input tokens for RoPE/graph capture. | | 18 | #13394 via #13405 | P0 correctness | RL sampling tensor lifetime errors could produce Inf/OOV tokens and contaminate later output. | | 19 | #14142 via #14619 | P1 long-run/state correctness | P/D rejection left stale KV/accounting and unsafe retry/replay behavior could leak, duplicate, or return wrong responses. | #### Backport policy - Selected the audited v0.26 release-adapted commits where available; the closed rollup #14337 was not revived wholesale. - Kept only one canonical copy of fixes duplicated across 0.23, 0.25, and main. - Manually adapted #13136, the core #13123 input-batch hunk, and #13159 to preserve current v0.26/MegaMoe/model-runner behavior. - Used the current v0.26 target change from #13405 and the complete five-commit #14619 series. - Intentionally excluded performance-only, UX-only, conditional-support, low-confidence, and owner-unsettled fixes from this release window. ### Does this PR introduce _any_ user-facing change? Yes, behavior is corrected for the affected configurations: crashes, deadlocks, hangs, incorrect output, stale KV state, and data corruption are prevented. There is no new public API, CLI option, or configuration requirement. ### How was this patch tested? Local validation completed: - Audited manifest: 19/19 logical fixes, 23/23 expected source commits; missing 0, duplicate 0, unexpected 0. - All 23 commits retain source provenance and Signed-off-by trailers. - Ruff lint and format checks passed for all 38 changed Python files. - Python syntax compilation passed for all 38 changed Python files. - git diff --check, codespell, forbidden-import, package-init, context-manager, and filename checks passed. - The final worktree is clean at 86b2ca8. The backports retain or add focused tests for AscendStore, Mooncake rejection cleanup, fused MoE/EPLB, W8A8-MXFP8 reload, worker sleep/wake, MRV2 graph padding, penalty-grid limits, hidden-state extraction, and two-card speculative DP. NPU UT/E2E was not run locally because the available Windows environment has no vLLM, PyTorch/torch_npu, pytest, or Ascend device. CI and targeted NPU regression are therefore required before merge, especially: - MRV1/MRV2 full-graph repeated-iteration deadlock/teardown. - Mooncake TP2/TP4 out-of-order pull KV equality and P/D rejection cleanup. - Qwen3-VL FlashComm1 + deepstack fixed-seed correctness. - Level-2 sleep/wake, dynamic EPLB, and multi-round RL weight reload. - P/D + DP zero-token ranks, ec_both, DFlash profile/graph, and RL Inf/OOV sampling. - Proxy retry and streaming replay behavior from #14619. #### Review checklist - [x] Only the 19 approved release-critical logical fixes are included. - [x] One logical fix per commit; #14619 remains an atomic five-commit series. - [x] No performance-only backports are included. - [x] Source provenance and sign-offs are retained. - [ ] Repository CI passes. - [ ] Targeted Ascend NPU correctness and long-run tests pass. - vLLM version: v0.26.0 - vLLM main: vllm-project/vllm@d02df74 --------- Signed-off-by: kyle-zhangchi <chiiiiiizhang@gmail.com> Signed-off-by: lijiaqi139 <lijiaqi139@huawei.com> Signed-off-by: jiaqi-lee <15316070896@163.com> Signed-off-by: tyy0829 <1455207791@qq.com> Signed-off-by: yejj710 <abyss1999@163.com> Signed-off-by: jiajinzhu2 <jiajinzhu@huawei.com> Signed-off-by: chenyue1122 <oyoy7102@163.com> Signed-off-by: XuRongSheng <1843167357@qq.com> Signed-off-by: muziyuhui666 <lijianfu9@huawei.com> Signed-off-by: Pz1116 <zpbzpb123123@gmail.com> Signed-off-by: zouyida2052 <zouyida2002@gmail.com> Signed-off-by: likailong <likailong5@huawei.com> Signed-off-by: hanxi-java <634498162@qq.com> Signed-off-by: Liam <ml646@duke.edu> Signed-off-by: AuroraEmiya <Sakura.iostream@gmail.com> Signed-off-by: HF-001 <1670186653@qq.com> Signed-off-by: wangxiaoteng <wangxiaoteng@huawei.com> Signed-off-by: Hcm03 <chengminhua1@huawei.com> Signed-off-by: zhuyixiang <zhuyixiang2014@163.com> Signed-off-by: moonseeker <2290166829@qq.com> Co-authored-by: kyle-zhangchi <chiiiiiizhang@gmail.com> Co-authored-by: tyy0829 <87685049+tyy0829@users.noreply.github.com> Co-authored-by: yejj <abyss1999@163.com> Co-authored-by: jiajinzhu2 <jiajinzhu@huawei.com> Co-authored-by: CHENYUE <56943221+PHOEBEMOON0802@users.noreply.github.com> Co-authored-by: Xu Rongsheng <73730571+MmMmaru@users.noreply.github.com> Co-authored-by: yjyang62 <yangjinyang5@huawei.com> Co-authored-by: muziyuhui666 <lijianfu9@huawei.com> Co-authored-by: CXY-Katrina <katrina.cxy@gmail.com> Co-authored-by: cywang250805 <wangchaoyu7@huawei.com> Co-authored-by: Bill845514379 <huangjianbao2@huawei.com> Co-authored-by: yejj710 <yejj710@gmail.com> Co-authored-by: AuroraEmiya <Sakura.iostream@gmail.com> Co-authored-by: HaoxinZong <116423146+HaoxinZong@users.noreply.github.com> Co-authored-by: pz1116 <47019764+Pz1116@users.noreply.github.com> Co-authored-by: zouyida2052 <zouyida2002@gmail.com> Co-authored-by: iKeybot <92210799+iKeybot-code@users.noreply.github.com> Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: 韩熙 <63780107+hanxi-java@users.noreply.github.com> Co-authored-by: zouzy <38661932+zouzy5137@users.noreply.github.com> Co-authored-by: AuroraEmiya <92282919+AuroraEmiya@users.noreply.github.com> Co-authored-by: Liam <ml646@duke.edu> Co-authored-by: kx <1670186653@qq.com> Co-authored-by: wangxiaoteng888 <56506195+wangxiaoteng888@users.noreply.github.com> Co-authored-by: Hcm03 <chengminhua1@huawei.com> Co-authored-by: zhuyixiang <zhuyixiang2014@163.com> Co-authored-by: moonseeker <2290166829@qq.com>
…tates (vllm-project#13498) When a KV cache tensor's shared_by list contains both MambaSpec and HiddenStateCacheSpec layers, sharing one physical buffer causes float32 ssm_state writes to overwrite bfloat16 hidden-states data (same bytes, different interpretation). Allocate a separate tensor for the HiddenStateCacheSpec layers in that case. Also: - Route AscendExtractHiddenStatesProposer to cm_base when selecting spec_decode_common_attn_metadata so it uses the base KV cache group. - Validate that extract_hidden_states drafter layers live in a single KV cache group during initialize_kv_cache. ### What this PR does / why we need it? Fix KV cache buffer corruption for hybrid model configurations that use both Mamba layers and extract-hidden-states layers in the same KV cache tensor group. Also wire AscendExtractHiddenStatesProposer into the spec-decode attention metadata plumbing. - The added has_mamba / has_hidden scan runs only inside the existing hybrid/hidden-state branch, so the hot path for plain attention layers is untouched. - Alignment handling (_align_memory with kv_transfer_config) is duplicated for the new tensor_hs; keeping the two allocations symmetric was intentional so KV-transfer setups behave identically for both buffers. - No new public API. Behavior for non-hybrid configs is byte-for-byte identical. ### Does this PR introduce _any_ user-facing change? No. Signed-off-by: chenyue1122 oyoy7102@163.com - vLLM version: v0.26.0 - vLLM main: vllm-project/vllm@0351e9a --------- Signed-off-by: chenyue1122 <oyoy7102@163.com>
…vllm-project#14687) ### What this PR does / why we need it? This is the v0.26.0 release-blocker backport rollup. It contains only the 19 audited high-severity correctness and stability fixes that were still missing from releases/v0.26.0rc at 1f95052. The branch has 23 physical commits because vllm-project#14619 is preserved as its complete five-commit atomic series. Cross-branch equivalents are deduplicated, and every logical fix remains independently reviewable and revertible. #### Included fixes | # | Source / target PR | Severity | Problem fixed | |---:|---|---|---| | 1 | vllm-project#13538 | P0 correctness | Qwen3-VL MoE + FlashComm1 + deepstack used the wrong residual tensor and could silently corrupt output. | | 2 | vllm-project#13600 | P0 deadlock | MRV1/MRV2 main and draft update streams could mutually wait during repeated full-graph execution. | | 3 | vllm-project#13498 | P0 data corruption | Float32 Mamba state could overwrite the shared bf16 hidden-state cache buffer. | | 4 | vllm-project#13902 | P0 correctness | RL weight reload left ACL graphs referencing stale W8A8-MXFP8 weight addresses. | | 5 | vllm-project#12359 / vllm-project#12371 | P0 correctness | Mooncake reformatted KV before all TP/CP pulls for a request completed, causing TP inequality or reordered KV. | | 6 | vllm-project#13111 / vllm-project#13113 / vllm-project#13110 | P1 KV correctness | Multi-KV-group save/load incorrectly reused group-0 block size for every group. | | 7 | vllm-project#13116 / vllm-project#13117 / vllm-project#13099 | P1 state consistency | Async KV load failures were not shared with the scheduler, preventing recompute recovery. | | 8 | vllm-project#13308 / vllm-project#13310 / vllm-project#13307 | P1 crash | Memcache batch query/allocation before lazy initialization could assert in scheduler or worker. | | 9 | vllm-project#13012 | P1 hang/corruption | Level-2 sleep/wake could lose the MoE loader and leave EPLB tensors pointing at released storage. | | 10 | vllm-project#13414 | P1 crash/correctness | Dynamic EPLB initialized W8A8 scales for only the first expert weight. | | 11 | vllm-project#14001 | P1 crash | MiniMax-M3 index_q was reshaped using total size instead of the per-head dimension. | | 12 | vllm-project#14394 | P1 crash/hang | MRV2 FULL_DECODE_ONLY dropped graph padding when runtime mode was FULL. | | 13 | vllm-project#13136 | P1 crash | P/D + DP zero-token ranks compared None with MC2 capacity and raised TypeError. | | 14 | vllm-project#13183 | P1 unavailable | ec_both was treated as producer-only and skipped KV specification/data needed by its consumer role. | | 15 | vllm-project#13123 | P1 OOB/device error | MRV2 dummy-token remainder was concentrated on one request and could exceed max_model_len. | | 16 | vllm-project#13159 | P1 crash | MRV2 num_nans used the wrong Triton libdevice and the penalty kernel could exceed the CANN grid limit. | | 17 | vllm-project#12940 | P1 crash | DFlash profiling used total query count instead of actual input tokens for RoPE/graph capture. | | 18 | vllm-project#13394 via vllm-project#13405 | P0 correctness | RL sampling tensor lifetime errors could produce Inf/OOV tokens and contaminate later output. | | 19 | vllm-project#14142 via vllm-project#14619 | P1 long-run/state correctness | P/D rejection left stale KV/accounting and unsafe retry/replay behavior could leak, duplicate, or return wrong responses. | #### Backport policy - Selected the audited v0.26 release-adapted commits where available; the closed rollup vllm-project#14337 was not revived wholesale. - Kept only one canonical copy of fixes duplicated across 0.23, 0.25, and main. - Manually adapted vllm-project#13136, the core vllm-project#13123 input-batch hunk, and vllm-project#13159 to preserve current v0.26/MegaMoe/model-runner behavior. - Used the current v0.26 target change from vllm-project#13405 and the complete five-commit vllm-project#14619 series. - Intentionally excluded performance-only, UX-only, conditional-support, low-confidence, and owner-unsettled fixes from this release window. ### Does this PR introduce _any_ user-facing change? Yes, behavior is corrected for the affected configurations: crashes, deadlocks, hangs, incorrect output, stale KV state, and data corruption are prevented. There is no new public API, CLI option, or configuration requirement. ### How was this patch tested? Local validation completed: - Audited manifest: 19/19 logical fixes, 23/23 expected source commits; missing 0, duplicate 0, unexpected 0. - All 23 commits retain source provenance and Signed-off-by trailers. - Ruff lint and format checks passed for all 38 changed Python files. - Python syntax compilation passed for all 38 changed Python files. - git diff --check, codespell, forbidden-import, package-init, context-manager, and filename checks passed. - The final worktree is clean at 86b2ca8. The backports retain or add focused tests for AscendStore, Mooncake rejection cleanup, fused MoE/EPLB, W8A8-MXFP8 reload, worker sleep/wake, MRV2 graph padding, penalty-grid limits, hidden-state extraction, and two-card speculative DP. NPU UT/E2E was not run locally because the available Windows environment has no vLLM, PyTorch/torch_npu, pytest, or Ascend device. CI and targeted NPU regression are therefore required before merge, especially: - MRV1/MRV2 full-graph repeated-iteration deadlock/teardown. - Mooncake TP2/TP4 out-of-order pull KV equality and P/D rejection cleanup. - Qwen3-VL FlashComm1 + deepstack fixed-seed correctness. - Level-2 sleep/wake, dynamic EPLB, and multi-round RL weight reload. - P/D + DP zero-token ranks, ec_both, DFlash profile/graph, and RL Inf/OOV sampling. - Proxy retry and streaming replay behavior from vllm-project#14619. #### Review checklist - [x] Only the 19 approved release-critical logical fixes are included. - [x] One logical fix per commit; vllm-project#14619 remains an atomic five-commit series. - [x] No performance-only backports are included. - [x] Source provenance and sign-offs are retained. - [ ] Repository CI passes. - [ ] Targeted Ascend NPU correctness and long-run tests pass. - vLLM version: v0.26.0 - vLLM main: vllm-project/vllm@d02df74 --------- Signed-off-by: kyle-zhangchi <chiiiiiizhang@gmail.com> Signed-off-by: lijiaqi139 <lijiaqi139@huawei.com> Signed-off-by: jiaqi-lee <15316070896@163.com> Signed-off-by: tyy0829 <1455207791@qq.com> Signed-off-by: yejj710 <abyss1999@163.com> Signed-off-by: jiajinzhu2 <jiajinzhu@huawei.com> Signed-off-by: chenyue1122 <oyoy7102@163.com> Signed-off-by: XuRongSheng <1843167357@qq.com> Signed-off-by: muziyuhui666 <lijianfu9@huawei.com> Signed-off-by: Pz1116 <zpbzpb123123@gmail.com> Signed-off-by: zouyida2052 <zouyida2002@gmail.com> Signed-off-by: likailong <likailong5@huawei.com> Signed-off-by: hanxi-java <634498162@qq.com> Signed-off-by: Liam <ml646@duke.edu> Signed-off-by: AuroraEmiya <Sakura.iostream@gmail.com> Signed-off-by: HF-001 <1670186653@qq.com> Signed-off-by: wangxiaoteng <wangxiaoteng@huawei.com> Signed-off-by: Hcm03 <chengminhua1@huawei.com> Signed-off-by: zhuyixiang <zhuyixiang2014@163.com> Signed-off-by: moonseeker <2290166829@qq.com> Co-authored-by: kyle-zhangchi <chiiiiiizhang@gmail.com> Co-authored-by: tyy0829 <87685049+tyy0829@users.noreply.github.com> Co-authored-by: yejj <abyss1999@163.com> Co-authored-by: jiajinzhu2 <jiajinzhu@huawei.com> Co-authored-by: CHENYUE <56943221+PHOEBEMOON0802@users.noreply.github.com> Co-authored-by: Xu Rongsheng <73730571+MmMmaru@users.noreply.github.com> Co-authored-by: yjyang62 <yangjinyang5@huawei.com> Co-authored-by: muziyuhui666 <lijianfu9@huawei.com> Co-authored-by: CXY-Katrina <katrina.cxy@gmail.com> Co-authored-by: cywang250805 <wangchaoyu7@huawei.com> Co-authored-by: Bill845514379 <huangjianbao2@huawei.com> Co-authored-by: yejj710 <yejj710@gmail.com> Co-authored-by: AuroraEmiya <Sakura.iostream@gmail.com> Co-authored-by: HaoxinZong <116423146+HaoxinZong@users.noreply.github.com> Co-authored-by: pz1116 <47019764+Pz1116@users.noreply.github.com> Co-authored-by: zouyida2052 <zouyida2002@gmail.com> Co-authored-by: iKeybot <92210799+iKeybot-code@users.noreply.github.com> Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: 韩熙 <63780107+hanxi-java@users.noreply.github.com> Co-authored-by: zouzy <38661932+zouzy5137@users.noreply.github.com> Co-authored-by: AuroraEmiya <92282919+AuroraEmiya@users.noreply.github.com> Co-authored-by: Liam <ml646@duke.edu> Co-authored-by: kx <1670186653@qq.com> Co-authored-by: wangxiaoteng888 <56506195+wangxiaoteng888@users.noreply.github.com> Co-authored-by: Hcm03 <chengminhua1@huawei.com> Co-authored-by: zhuyixiang <zhuyixiang2014@163.com> Co-authored-by: moonseeker <2290166829@qq.com>
When a KV cache tensor's shared_by list contains both MambaSpec and HiddenStateCacheSpec layers, sharing one physical buffer causes float32 ssm_state writes to overwrite bfloat16 hidden-states data (same bytes, different interpretation). Allocate a separate tensor for the HiddenStateCacheSpec layers in that case.
Also:
What this PR does / why we need it?
Fix KV cache buffer corruption for hybrid model configurations that use both Mamba layers and extract-hidden-states layers in the same KV cache tensor group. Also wire AscendExtractHiddenStatesProposer into the spec-decode attention metadata plumbing.
Does this PR introduce any user-facing change?
No.
Signed-off-by: chenyue1122 oyoy7102@163.com