Repository navigation
Conversation
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 refactors the AscendStore metadata implementation to improve maintainability and modularity. By splitting the large metadata.py file into single-purpose modules, the codebase becomes more organized and easier to navigate. The changes preserve existing cache behavior and logic while providing a cleaner separation of concerns between scheduling, configuration, and transfer state management. 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. |
There was a problem hiding this comment.
Code Review
This pull request refactors the KV transfer metadata management by introducing a RequestTransferState dataclass to encapsulate transfer-related fields, moving them out of the ReqMeta class. It also introduces a GroupBufferLayout to handle memory descriptors for KV cache groups, improving modularity. A high-severity issue was identified in GroupBufferLayout.from_buffers where an incorrect modulo operation could cause an IndexError when broadcasting block_strides. The changes include extensive updates to tests and internal modules to accommodate these structural improvements.
| else () | ||
| ) | ||
| strides = ( | ||
| tuple(block_strides[index % len(block_lengths)] for index in range(len(base_addresses))) |
There was a problem hiding this comment.
In from_buffers, when broadcasting block_strides over base_addresses, the modulo operation uses len(block_lengths) instead of len(block_strides). If block_strides has a different length than block_lengths (for example, if it is shorter), this will raise an IndexError at runtime. To ensure robustness and correctness, the modulo should use len(block_strides).
| tuple(block_strides[index % len(block_lengths)] for index in range(len(base_addresses))) | |
| tuple(block_strides[index % len(block_strides)] for index in range(len(base_addresses))) |
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
|
Last updated: 2026-11-27 01:02 UTC+8 for commit ci-gate failed. Reason:
See the workflow run for full logs. This comment is updated in place on each new failure and marked as passed once the gate passes (it is kept for history, not deleted). Missing owner approvals. Every changed file needs one approval from its CODEOWNERS owner(s):
|
021416f to
9f1c2df
Compare
Coverage
More info see: Summary |
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
9f1c2df to
fd8d816
Compare
43860c6 to
1389307
Compare
1389307 to
64d6bdb
Compare
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
64d6bdb to
373bc97
Compare
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
Split the AscendStore metadata implementation into single-purpose modules without changing cache behavior, based on vllm-project#20996 and merged with current main. - metadata.py keeps scheduling and connector payloads and re-exports moved helpers for compatibility - cache_config.py resolves topology and cache-group configuration - pool_keys.py owns PoolKey building and block-hash serialization - request_state.py holds RequestTracker, side-effect-free SaveDecision, and group id normalization - token_database.py owns the chunked token database - transfer_metadata.py consolidates the 22 per-request worker-preparation fields into RequestTransferState - cache_layout.py registers per-group buffer layout descriptors (stride broadcast fixed per review) Adapted to the planes data-plane refactor (vllm-project#21314): 58 legacy request/view field accesses in planes/block_key.py and planes/gva.py migrated onto request.transfer; prepare_layerwise_step fuses _data_plane.prepare_sessions with the new field location; test fixtures build a real ChunkedTokenDatabase; benchmark fixture synced with the current scheduler contract. Also fixes the mypy assignment error carried by vllm-project#20996 and two unverified transfer-array test assertions. Squashed to a single commit because the CI checkout rebases the branch onto the base ref, which cannot replay a merge commit. Verified: full ascend_store + kv_offload suite (1114 cases) shows zero per-test regressions against origin/main; the 7 new metadata tests pass; ruff clean. Signed-off-by: zhaosusu <zhaosusu1@h-partners.com>
from_tracker eagerly converted every group's block ids and gvas to numpy arrays on the scheduler critical path; main only materializes arrays on the worker thread. At 256 concurrent requests with 256 blocks x 5 groups this added ~13.5 ms to every scheduler step (and ~192 ms at 4096 blocks), directly inflating TTFT on prefill-heavy workloads; an E2E benchmark on DeepSeek-V4-Flash measured ~1% throughput/TTFT regression. Store the tracker's id lists by reference instead and materialize them lazily on first array access, which happens on the worker thread (planes/gva read paths now go through get_block_ids_array). The lazy source shares identity with ReqMeta.block_ids_by_group, so pickling the metadata payload costs no extra bytes. Empty gvas conversions reuse one shared empty array. Measured: scheduler-side from_tracker drops 13.51 ms -> 0.22 ms per step (256 req x 256 blocks x 5 groups); the one-time materialization runs on the worker thread where main performs the same conversion. Full ascend_store + kv_offload suite: zero per-test changes. Signed-off-by: zhaosusu <zhaosusu1@h-partners.com>
The GVA save preparation issued one exists check and one batch_alloc per request (per step): at 256 concurrent decode requests that is 512 sequential store round trips, which is pure added latency on the worker save path and grows linearly with batch size. Split _alloc_gvas_for_save into three phases: collect every group's candidate keys without I/O (each group holds its slot in the published per-group arrays so group order is preserved), issue one merged exists check plus one merged batch_alloc for all requests (keys and sizes concatenated in request-then-group order, so per-request transfer ordering is preserved), then distribute the replies back in that same order. Failure semantics are unchanged: the offload gate still reads the raw alloc replies (a UINT64_MAX SSD-hit sentinel filters to 0 but is not a failure), partial keys keep their per-request alloc, and a failed batch disables the step's saves exactly as before. Verified with a counting store: 8 requests x 2 groups now take 1 exists + 1 alloc call instead of 16 + 16, with identical backfill values and key order; mixed cacheable/non-cacheable groups keep their slot placeholders. The full ascend_store + kv_offload suite (1107 cases) shows zero per-test changes. Signed-off-by: zhaosusu <zhaosusu1@h-partners.com>
373bc97 to
5ff96d3
Compare
ec0be94 to
92f78f5
Compare
The upstream save-path tests added in the latest main window lock the per-request implementation contract: hash conversion is counted per request until the first allocation failure stops the loop, per-request key lists keep their nesting, and isolated requests observe their own exists-check state. The cross-request batched collector broke those observable timings while chasing fewer store round trips. Restore main's per-request save allocation (with the step-scoped hash memo and public-key dedup that main already ships) as the contract of record; the scheduler-thread materialization deferral from the previous commit stays, with the block-id reads going through the lazy accessor so from_tracker-built requests still materialize on the worker thread. Signed-off-by: zhaosusu <zhaosusu1@h-partners.com>
92f78f5 to
c6525db
Compare
What this PR does / why we need it?
Decouple the AscendStore metadata implementation, based on #20996, rebased onto current main with all conflicts resolved.
vllm_ascend/distributed/kv_transfer/kv_pool/ascend_store/metadata.py(~1240 lines on main) mixed scheduling payloads, the token database, key building, cache-group configuration, and worker transfer state in one module. This PR splits it into single-purpose modules without changing cache behavior:metadata.pykeeps scheduling and connector payloads (LoadSpec,ReqMeta,AscendConnectorMetadata,AscendStoreKVConnectorWorkerMetadata) and re-exports moved helpers for compatibility with existing importscache_config.pyresolves topology and cache-group configuration (TP/DCP mismatch, block sizes, cacheable and sharded-Mamba group ids)pool_keys.pyownsPoolKeybuilding, block-hash serialization, and lazy grouped hash viewsrequest_state.pyholdsRequestTracker, side-effect-freeSaveDecision, and group id normalizationtoken_database.pyowns the chunked token database (chunk selection, key prefix cache, segmented addressing)transfer_metadata.pyconsolidates per-request worker arrays, keys, masks, and offsets intoRequestTransferStatecache_layout.pyregisters per-group buffer layout descriptors shared by bulk and layer selectionField contract: the 22 worker-preparation fields that used to sit directly on
ReqMeta(save_keys,load_keys,store_masks,block_gvas_by_group_np, key/offset fields, ...) move torequest.transfer.ReqMetakeeps a legacy**transfer_fieldsconstructor entry point and delegating accessors (get_block_ids_array,get_transfer_arrays).Adapted to current main: since #21314 moved layerwise save/load preparation into
layerwise/planes/data-plane strategies, this PR migrates 58 legacyrequest./view.field accesses inplanes/block_key.pyandplanes/gva.pyonto the consolidatedrequest.transferstate, and fuses_data_plane.prepare_sessionswith the new field location inprepare_layerwise_step.test_pool_worker_pp_object_bounds.pynow builds a realChunkedTokenDatabaseinstead of theworker.token_database = workeralias. The benchmark fixture is synced with the current scheduler contract so the harness runs on the merged tree.Cache keys, hash selection, mask boundaries, transfer ordering, partial-block snapshots, speculative rollback, Mamba null blocks, and pipeline layer coordinates are preserved.
Does this PR introduce any user-facing change?
No. Internal refactor only: no API, parameter, environment variable, or default behavior change; no release note fragment needed.
How was this patch tested?
tests/ut/distributed/ascend_store/+ relatedkv_offloadtests (1114 cases) on origin/main vs this branch after the merge: zero per-test regressions; the 7 new tests (group selection, descriptor addressing, save decisions, copied-view ownership) all pass.token_databasealias fixture, two unverified transfer-array assertions) were fixed and cpu-ut is green on both vLLM matrix versions.cache_layout.py(stride broadcast modulo) is fixed.ruff check/ruff formatpass; metadata microbenchmarks from [Refactor] Split AscendStore metadata responsibilities #20996 validation show no regression and improvements on large configs (e.g. 4096 blocks: 162us -> 85us).Checklist
Testing
Boundary / edge-case coverage: new tests cover empty groups, missing arrays, grouped fallback paths, and stride/length broadcast descriptors (
test_metadata.py,test_segmented_cache_transfer.py).Meaningful & reliable tests: the 7 new tests assert real metadata behavior, not mock implementation details.
Performance impact: benchmark evidence above; the normal path reuses the group-0 ID array and avoids legacy list-normalization work.
vLLM main: vllm-project/vllm@c410543