[Runtime] Clear strides when the paged KV cache copies one row of aux data - #20491
Merged
Merged
Conversation
…data
PlainPagedKVCacheAuxDataManager writes the length info and the compact
copy positions one row at a time into a {rows, n} view. CopyVecDataToArray
narrowed the destination to one dimension but kept the strides of the
view, so the contiguity check in CopyDataFromTo failed as soon as n was
above one. That is every forward pass with more than one sequence on a
cache with sliding window support, on any device other than CUDA and CPU.
Clear the strides with the shape, as the cached manager already does.
tlopex
approved these changes
Sep 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PlainPagedKVCacheAuxDataManagerfills the length info and the compact copy positions one row at a time into a{rows, n}view.CopyVecDataToArraynarrows the destination to one dimension for each row but keeps the strides of the two-dimensional view, soCopyDataFromTorejects it as non-contiguous oncenis above one. With sliding window support enabled that is any forward pass over more than one sequence, on every device that uses the plain manager (Metal, Vulkan, OpenCL, WebGPU). MLC LLM hits it when serving concurrent Gemma 4 requests on Metal.CopyVecDataToArray, as the cached manager already does