Skip to content

[Feature] Share Ascend Store objects between prefix pooling and PD - #21000

Draft
Yuli-yx wants to merge 18 commits into
vllm-project:mainfrom
Yuli-yx:codex/glm53flash-pool-stage1
Draft

Yuli-yx wants to merge 18 commits into
vllm-project:mainfrom
Yuli-yx:codex/glm53flash-pool-stage1

Conversation

@Yuli-yx

@Yuli-yx Yuli-yx commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does / why we need it?

Add an experimental LayerwisePoolConnector and a common Ascend Store object format so prefix pooling, PD handoff and decode writeback can reuse the same immutable KV objects. P publishes to a DRAM pool and can release its source buffers after copies drain, while D acquires and restores the required objects before resuming.

  • Compose the connector with the existing pool scheduler/worker and reuse upstream HeadMajorStoreLayout/MambaStoreLayout planning.
  • Share complete committed blocks between ordinary pooling and PD; add exact attention tails and recurrent/circular state snapshots for PD.
  • Reuse the original CPD proxy and kv_transfer_params envelope. P/D reconstruct keys without forwarding key lists or addresses.
  • Queue layerwise copies on the existing sender; drain before publication, checkpoint ACKs, cancellation or source-buffer reuse.
  • Pair MemCache 1.3.0 lease APIs correctly: WRITE_OK consumes the write lease, while remove_lease releases read operations. Returned read cleanup failures after drained copies are logged with TTL fallback.
  • Protect every P handoff object with a bounded read lease before returning the handoff. D acquires its own lease within the deadline, retaining it through copy. Expired/missing protection fails closed. Default handoff_ttl_s is 60 seconds (5–300).
  • Support MRV2 graph execution with bulk transfers at step boundaries. D restores cache and recurrent state before replay and publishes writeback after the step completes. Eager P retains layerwise overlap.
  • Reuse cached attention blocks on the decode consumer with per-group allocations. Restore the exact recurrent and circular handoff state.
  • Isolate producer handoff lease failures per request before returning a handoff. Other requests in the batch continue.
  • Preserve the stateful N-1 boundary and matching P/D MTP contract; fix asynchronous shared-layout initialization when allocator group 0 is absent.

The handoff is a bounded protection window, not a D-ACK protocol or indefinite pin. Cross-host deployment requires clock skew below one second. Native leases protect normal eviction, not forced deletion or pool failure. Producer handoff lease failures are surfaced as request errors before a handoff is emitted. The gap before acquiring protection remains follow-up work.

Design: shared objects and lease lifecycle, GLM layout and acceptance scope.

Does this PR introduce any user-facing change?

Yes. The connector requires MemCache, an explicit weight epoch (cache_prefix), compatible store_tp_size, and matching P/D code/protocol. The new ascend_shared_v2 handoff carries a deadline; mixed protocol versions are rejected. Shared-format objects do not interoperate with legacy rank-local objects. A release-note fragment is included.

This remains a draft. The performance target is long inputs (128K+), high prefix reuse (90%+), and improved sustainable concurrency under matched latency constraints. Performance improvement is not yet established.

How was this patch tested?

Latest lease/handoff update:

  • python3 -m pytest -q tests/ut/distributed/ascend_store/test_shared_io.py tests/ut/distributed/ascend_store/test_shared_transfer.py tests/ut/distributed/ascend_store/test_pd_pool.py tests/ut/distributed/ascend_store/test_kv_transfer.py: 124 passed, 17 warnings, in an isolated tree in the Ascend development container. Tests cover full/tail handoff protection, expiration, failed acquisition, write/read pairing, returned cleanup errors and asynchronous source lifetime.
  • Required local attempt from the workspace's vllm-ascend using its checked-in venv: uv run --no-sync pytest -q <the four affected test paths in the isolated PR worktree>. Collection is blocked by local Transformers 5.12.1 lacking Kimi_K25VisionConfig. A temporary Transformers 5.19.0 overlay exposed additional local vLLM baseline/StoreLayout mismatches. No local passing result is claimed; the main working tree and its dependency environment were left unchanged.
  • bash format.sh ci: passed after formatter changes were included. This covers Python, Markdown, spelling, shell and secret checks.
  • Installed MemCache 1.3.0 experiment matched the official release/1.3.0 source contract: WRITE_OK followed by read-lease removal reproduced -3106; overlapping P/D read leases retained exact bytes after P released. A pressure run recorded 45 evictions while D's protected object remained intact. Explicit remove was not protected.
  • Native GLM-5.3-Flash-w8a8, same-host P TP8/EP8 + D TP8/EP8, MRV2 eager, MTP=0, LayerwisePoolConnector through the original PD proxy: GSM8K precheck 31/32 (96.875%), 0 HTTP errors, 0 truncations, and all eight P HOLD/D GET ranks verified for every request.
  • The separate 1319-sample GSM8K run was stopped at the user's request after 279 successful responses, 0 HTTP errors. It passed the previous 266-response failure point with no cleanup/expiration failure. This is not a completed full-dataset score.
  • Runtime: CANN 9.2.1, torch/torch_npu 2.10, MemCache/MemFabric 1.3.0, vLLM 5df63a7203cdb9328d824a27b682e77c7b9928be with documented StoreLayout/SSM/draft-spec compatibility files. D's 4 GiB/rank native host allocation failed during startup; validation used P 4 GiB/rank + D 2 GiB/rank (48 GiB total pool).

Earlier BF16 native validation covered bulk/layerwise interoperability, MTP=0/1, byte-exact MLA/indexer/KDA state recovery, short/chunked/repeated PD requests, decode writeback reuse, and concurrent requests with actual preemption. Earlier concurrent logprob differences remain unexplained; no bitwise-equivalence claim is made.

Graph update (be1c20037d):

  • On A3, same-host P TP8/EP8 in eager mode and D TP8/EP8 with FULL_DECODE_ONLY, both using MTP3. All eight D workers captured graphs. Live requests recorded FULL replay and nonempty D writeback.
  • Remote CPU/mock preflight: python3 -m pytest -q tests/ut/distributed/ascend_store/{test_shared_io.py,test_shared_transfer.py,test_pd_pool.py,test_kv_transfer.py,test_pool_worker.py,test_ascend_store_connector.py}. 301 passed, 17 warnings. The regression exercises restore and publish with no Python layer callbacks.
  • Local preflight ran uv run pytest -q from the workspace's vllm-ascend checked-in venv against the isolated PR checkout's test_shared_transfer.py, test_pool_worker.py, test_pd_pool.py, and test_ascend_store_connector.py. Collection failed on the installed Transformers missing Kimi_K25VisionConfig. A temporary pinned vLLM/Transformers overlay failed on vllm.v1.core.kv_cache_planning. bash format.sh ci passed.

128K input and approximately 95% shared prefix, same-host D2D versus pool, TTFT ≤10 s and TPOT ≤20 ms. The pool was 48 GiB across P and D and used a 300 s handoff TTL.

Output length and concurrency Connector TTFT P99 TPOT P99 Output tokens/s Requests meeting both SLOs
256, 1 D2D 2.70 s 14.28 ms 42.0 4/4
256, 1 Pool 3.55 s 16.67 ms 35.3 4/4
1024, 4 D2D 6.47 s 16.41 ms 217.1 8/8
1024, 4 Pool 9.21 s 21.28 ms 165.9 7/8
1024, 16 D2D 21.47 s 26.14 ms 469.6 6/32
1024, 16 Pool 55.88 s 33.47 ms 223.6 1/32

At concurrency 1 with 256 output tokens, the median per-request slowest rank logged about 184 ms for the pool receive versus about 6.1 ms of D2D transfer buckets. The paths moved 1.59 GB/rank versus 111 MB/rank because the pool D did not reuse the local hybrid prefix. The pool receive includes planning and acquisition, and the P handoff drain/publish/hold took about 84 ms. At concurrency 16 with 1024 output tokens, sampled D KV usage peaked at 88.4% with seven active pool requests versus 34.4% with sixteen active D2D requests.

The pool C32 run completed 1/64 requests before P exited. The native log recorded 799 evictions followed by MMC_UNMATCHED_KEY (-3102) when P tried to acquire its handoff read lease. That path runs before protection is established. The fresh pool completed both 1024-output runs with the same graph configuration. After those runs, the first cold request of the 16-family pressure warmup reproduced the P-side -3102 failure. The capacity revisit comparison could not run.

Decode prefix reuse update (2b79bb89fe):

D2D opts into divergent hybrid local hits. The pool connector now opts in for PD-only decode and uses each group's unhashed block IDs for the receive plan. It restores missing attention blocks and exact recurrent and circular state before replay. The regression covers an attention group that missed a block within another group's local hit.

The same 128K input datasets and MTP3 settings ran on the same A3 P8+D8 pair. D recorded FULL graph replay. Across 44 hot requests, D local prefix hits reached 94.73%, up from 0%, and median receive payload fell from 1.59 GB/rank to 102 MB/rank. At 16 concurrency, sampled D KV occupancy fell from 88.4% to 33.1% and active requests rose from 7 to 15.

Output length and concurrency TTFT P99 before → after TPOT P99 before → after SLO output tokens/s before → after Requests meeting both SLOs
256, 2 5.34 → 5.22 s 18.29 → 22.74 ms 56.1 → 27.8 4/4 → 2/4
1024, 4 9.21 → 8.75 s 21.28 → 22.28 ms 145.2 → 150.2 7/8 → 7/8
1024, 16 55.88 → 26.01 s 33.47 → 37.17 ms 7.0 → 12.0 1/32 → 1/32

All 44 hot requests completed. At 16 concurrency total throughput rose from 223.6 to 383.5 tokens/s. SLO throughput remains below D2D at both 1024-output points. The SLO is TTFT ≤10 s and TPOT ≤20 ms.

  • Remote CPU/mock tests: python3 -m pytest -q tests/ut/distributed/ascend_store/{test_pd_pool.py,test_shared_transfer.py,test_shared_io.py,test_pool_worker.py,test_ascend_store_connector.py}. 249 passed, 17 warnings. Format checks passed.
  • Local uv run pytest -q against the updated test_pd_pool.py in the workspace's checked-in venv failed during collection because installed Transformers lacks Kimi_K25VisionConfig.

Producer handoff failure isolation (81d81d3ef4):

Worker results carry failed handoff request IDs across ranks. The scheduler finishes only those requests before building the Prefill response. A failed request returns HTTP 500 with no handoff parameters. Existing successful handoffs still use the paired leases.

On A3 with the 48 GiB pool and D in FULL_DECODE_ONLY + MTP3, the 128K / 1K-output run completed 32/32 at concurrency 16. The first four requests from the prior multi-prefix pressure warmup each reproduced native -3102 on their first P attempt. P remained up, and the existing proxy retry completed all four end to end. Both health endpoints returned 200 after the run. The native eviction counter reached 5,994.

A separate tagged failure injection exercised rank-level aggregation. The injected key was rejected by the SDK with -3000. P returned HTTP 500 with no handoff for that request, and a concurrent normal request and a subsequent request completed through the PD proxy. The injected code lives in the validation overlay.

  • Remote CPU/mock tests: python3 -m pytest -q tests/ut/distributed/ascend_store/{test_pd_pool.py,test_shared_io.py,test_shared_transfer.py,test_pool_worker.py,test_ascend_store_connector.py} — 250 passed, 17 warnings. Format checks passed.
  • Local checked-in venv test collection remained blocked by Transformers missing Kimi_K25VisionConfig.

Before merge

  • Align with latest upstream interfaces and resolve existing merge conflicts, then rerun integration CI.
  • Measure the remaining TPOT tail and repeat the capacity comparison after fixing P acquisition under eviction. Extend validation to longer inputs and cross-host PD.
  • Complete prolonged concurrency, concurrent-writer and lease/eviction fault coverage.
  • Reduce misses before P handoff protection and complete sustained multi-prefix capacity coverage.

Checklist

  • Boundary and failure-path regression tests

  • Native lease semantics and PD handoff evidence

  • Release note and protocol/configuration documentation

  • Performance comparison completed

  • Merge-baseline integration CI completed

  • vLLM main: vllm-project/vllm@c410543

Yuli-yx and others added 2 commits November 5, 2026 09:54
Add a composed LayerwisePoolConnector and shared Ascend layout/transfer/I/O
for complete prefix blocks, PD tails and stateful checkpoints. Document the
GLM-5.3-Flash phase-one validation scope and remaining production limitations.

Co-authored-by: wangxiaoteng888 <wangxiaoteng@huawei.com>
Co-authored-by: bowgneo <gavin.gq.bao@gmail.com>
Co-authored-by: yFeng-dev <yfeng.github@gmail.com>
Signed-off-by: Zhu Yixiang <66874062+Yuli-yx@users.noreply.github.com>
Signed-off-by: Zhu Yixiang <66874062+Yuli-yx@users.noreply.github.com>
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 introduces an experimental pool-backed PD connector designed to improve KV cache transfer efficiency by sharing prefix objects between ordinary pooling and speculative decoding. By establishing a unified object layout and lifecycle, the changes allow for the restoration of full blocks and partial tails without redundant key list forwarding or complex proxy modifications. The implementation focuses on composing existing pool scheduler and worker components, maintaining compatibility with current model structures while enabling opt-in shared-format pooling.

Highlights

  • Experimental Pool-backed PD Connector: Introduced LayerwisePoolConnector to enable shared Ascend Store objects between prefix pooling and speculative decoding (PD), allowing efficient restoration of full blocks and partial tails.
  • Shared Object Format: Implemented a common Ascend Store object format that reuses existing layout planning while binding physical tensors, strides, and component offsets, ensuring interoperability between bulk and layerwise execution.
  • Draft Ownership Propagation: Updated attn_utils.py to propagate draft ownership flags after cache-spec transformations, ensuring consistent identification of draft layers across the system.
  • Stateful Prefill Truncation: Extracted the stateful prefill truncation helper to a common utility, ensuring consistent boundary handling for both direct-transfer and pool-backed PD workflows.
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 Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@github-actions github-actions Bot added documentation Improvements or additions to documentation module:tests labels Nov 5, 2026
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! Thank you for contributing to the vLLM Ascend project. The following points will speed up your PR merge:‌‌

  • A PR should do only one thing, smaller PRs enable faster reviews.
  • Every PR should include unit tests and end-to-end tests ‌to ensure it works and is not broken by other future PRs.
  • Write the commit message by fulfilling the PR description to help reviewer and future developers understand.

If CI fails, you can run linting and testing checks locally according Contributing and Testing.


Tip

💡 Consider Linking a Related Issue or RFC

Your PR title contains the [Feature] 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:

  • Fixes #<issue_number>
  • Closes #<issue_number>
  • Resolves #<issue_number>
  • Refs #<rfc_or_issue_number> (for RFCs)

🙏 Thanks for helping us keep the project well-organized!

@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

Suggested PR Title:\n\nmarkdown\n[Ops][Feature] Pool-backed PD connector and shared object layout for Ascend Store\n\n\nSuggested PR Summary:\n\nmarkdown\n### What this PR does / why we need it?\nThis PR introduces the experimental `LayerwisePoolConnector` and shared object layout for Ascend Store and pool-backed PD integration. It enables ordinary `AscendStoreConnector` and `LayerwisePoolConnector` to share complete prefix objects. Several critical issues were identified, including type inconsistencies in scheduler return values, incorrect head count validation (using `num_heads` instead of `num_kv_heads`), missing bounds checks on block hashes, and potential TypeErrors in the I/O layer when handling null values.\n\n### Does this PR introduce _any_ user-facing change?\nYes, it registers the new `LayerwisePoolConnector` and introduces shared pool configuration options (`store_tp_size`, `cache_prefix`).\n\n### How was this patch tested?\nTested via newly added unit tests in `tests/ut/distributed/ascend_store/` covering the PD pool, shared transfer, shared I/O, and layout functionality.\n

Comment on lines +42 to +43
if not params.get("do_remote_prefill"):
return self.pool.get_num_new_matched_tokens(request, num_computed_tokens)

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.

critical

There is a critical type inconsistency in the return values of get_num_new_matched_tokens. If do_remote_prefill is False, it delegates to self.pool.get_num_new_matched_tokens(...) which returns a single int. If do_remote_prefill is True, it returns a tuple (count, count > 0). This type mismatch will cause runtime crashes (e.g., TypeError) in the caller depending on the request parameters. Both paths must be aligned to return the same type (either int or (int, bool) depending on the expected interface of the caller).

Suggested change
if not params.get("do_remote_prefill"):
return self.pool.get_num_new_matched_tokens(request, num_computed_tokens)
if not params.get("do_remote_prefill"):
matched = self.pool.get_num_new_matched_tokens(request, num_computed_tokens)
return matched, matched > 0

if (
cache.ndim != 4
or cache.shape[0] % num_blocks
or cache.shape[1] != spec.num_heads

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.

critical

cache.shape[1] represents the number of KV heads in the physical cache tensor. This must be compared to spec.num_kv_heads instead of spec.num_heads (which is the number of query heads). Comparing it to spec.num_heads will cause validation to incorrectly fail for any model using Grouped Query Attention (GQA) where num_heads != num_kv_heads.

Suggested change
or cache.shape[1] != spec.num_heads
or cache.shape[1] != spec.num_kv_heads

raise ValueError("Compressed/special head-slot content needs an explicit adapter")
if item.max_tp_shards is not None and tp > item.max_tp_shards:
raise ValueError("Replicated KV heads need a shared-shard ownership policy")
if item.num_heads * tp % store_tp:

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 sharding check item.num_heads * tp % store_tp uses num_heads (query heads) instead of num_kv_heads (KV heads). Since sharding is performed on the KV heads, this can lead to invalid sharding configurations passing validation and causing runtime crashes or data corruption for GQA models.

Suggested change
if item.num_heads * tp % store_tp:
if item.num_kv_heads * tp % store_tp:

Comment on lines +51 to +55
if not tail_only:
for index in range(first, complete):
digest = block_hash_to_str(
request.block_hashes[(index + 1) * layout.chunk_size // layout.hash_block_size - 1]
)

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

request.block_hashes is accessed using an index calculated from index without any bounds checking. If this index is out of bounds, it will raise an unhandled IndexError and crash the worker. A bounds check should be added to prevent crashes.

            if not tail_only:
                for index in range(first, complete):
                    hash_idx = (index + 1) * layout.chunk_size // layout.hash_block_size - 1
                    if hash_idx >= len(request.block_hashes):
                        raise ValueError("PD cannot restore a block with missing prefix hash")
                    digest = block_hash_to_str(request.block_hashes[hash_idx])

Comment on lines +73 to +81
self.transfer.prepare_step(metadata.pool)
seen = set()
try:
for request in metadata.tails:
plans = tuple(
plan for plan in self._plans(request, tail_only=True, writing=True) if plan.key not in seen
)
seen.update(plan.key for plan in plans)
self.tails.append(self.transfer.io.begin(plans, writing=True))

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

self.transfer.prepare_step(metadata.pool) is called outside the try...except block. If it raises an exception, self.abort() and self.transfer.abort_step() will not be called, potentially leaking resources or leaving the system in an inconsistent state. Moving it inside the try block ensures proper cleanup on failure.

Suggested change
self.transfer.prepare_step(metadata.pool)
seen = set()
try:
for request in metadata.tails:
plans = tuple(
plan for plan in self._plans(request, tail_only=True, writing=True) if plan.key not in seen
)
seen.update(plan.key for plan in plans)
self.tails.append(self.transfer.io.begin(plans, writing=True))
seen = set()
try:
self.transfer.prepare_step(metadata.pool)
for request in metadata.tails:
plans = tuple(
plan for plan in self._plans(request, tail_only=True, writing=True) if plan.key not in seen
)
seen.update(plan.key for plan in plans)
self.tails.append(self.transfer.io.begin(plans, writing=True))

):
raise RuntimeError("MemCache object size differs from the local StoreLayout")
gvas = [info.gva_list()[0] for info in infos]
if len(gvas) != len(plans) or any(not 0 < int(gva) < (1 << 64) - 1 for gva in gvas):

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

If gva is None, calling int(gva) will raise a TypeError. Using short-circuit evaluation gva is None or not 0 < int(gva) < (1 << 64) - 1 prevents this crash and makes the code more robust.

Suggested change
if len(gvas) != len(plans) or any(not 0 < int(gva) < (1 << 64) - 1 for gva in gvas):
if len(gvas) != len(plans) or any(gva is None or not 0 < int(gva) < (1 << 64) - 1 for gva in gvas):

Comment on lines +144 to +145
if len(results) != len(keys) or any(result != 0 for result in results):
raise RuntimeError("MemCache publication failed")

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

If results is None (e.g., due to a backend error), calling len(results) will raise a TypeError. Checking results is None first prevents this crash.

Suggested change
if len(results) != len(keys) or any(result != 0 for result in results):
raise RuntimeError("MemCache publication failed")
results = self.backend.batch_write_finish(keys, [0] * len(keys))
if results is None or len(results) != len(keys) or any(result != 0 for result in results):

Yuli-yx and others added 5 commits November 5, 2026 11:42
Queue preplanned shared object ranges on the existing layerwise sender.
Drain full blocks and PD state/tails before publication, checkpoint ACKs,
cancellation cleanup or step completion. Keep model and MTP logic unchanged.

Validate asynchronous readiness, live-state lifetime and failure cleanup
alongside legacy layerwise regressions in a remote CPU container (261 tests).
Native NPU model and overlap validation remains outstanding for this delta.

Co-authored-by: wangxiaoteng888 <wangxiaoteng@huawei.com>
Co-authored-by: bowgneo <gavin.gq.bao@gmail.com>
Co-authored-by: yFeng-dev <yfeng.github@gmail.com>
Signed-off-by: Zhu Yixiang <66874062+Yuli-yx@users.noreply.github.com>
Consume write leases through publication, retain bounded producer read leases until decode can acquire its own, and isolate returned read cleanup failures. Cover expiry, failed acquisition and asynchronous source lifetime.

Signed-off-by: zhuyixiang <zhuyixiang2014@163.com>
Restore KV and recurrent state before replay and publish committed cache at the step boundary. Preserve eager per-layer overlap for the prefill endpoint.

Signed-off-by: zhuyixiang <zhuyixiang2014@163.com>
Adopt divergent hybrid cache hits on the decode consumer and restore only missing attention blocks per group. Always restore the exact recurrent and circular handoff state.

Signed-off-by: zhuyixiang <zhuyixiang2014@163.com>
Report producer lease failures across ranks and finish affected requests before the scheduler emits a handoff. Keep successful requests in the same batch running.

Signed-off-by: zhuyixiang <zhuyixiang2014@163.com>
Publish and restore MTP attention and indexer KV alongside target state.
Keep target object keys stable, key reusable draft blocks by the following
prefix hash, and use request-specific keys at the terminal boundary.
Version MTP handoffs so target-only producers fail compatibility checks.

Validation: 265 affected unit tests on macOS CPU mocks and 265 on Ascend.
GLM-5.3-Flash-w8a8 at 128K/C8 with D FULL_DECODE_ONLY recovered draft
acceptance from 27.12% to 50.28% and reduced TPOT from 23.01 to 15.52 ms.

Signed-off-by: zhuyixiang <zhuyixiang2014@163.com>
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

2 similar comments
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

Seed the decode-side writeback boundary from the accepted producer handoff, while retaining the draft boundary that may obtain its prefix hash on decode. Clear the hint after a failed receive so recomputed KV remains eligible for publication.

Signed-off-by: zhuyixiang <zhuyixiang2014@163.com>
@Yuli-yx

Yuli-yx commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

GLM-5.3-Flash shared-pool throughput

Shared-pool commit d244763813ac6bec3c510d9db49906d2cbf86662. This update skips decode-side writeback preparation for prompt KV already published by prefill and preserves the MTP writeback boundary.

AISBench PD on Ascend A3, with P TP8 and D TP8, using GLM-5.3-Flash W8A8, 131,072 input tokens, 1 output token, and 10 GiB of MemCache per rank (160 GiB nominal total). Each paired case used the same requests and identical warmup data. Formal request counts were 64/64/64/96/192 at C1/C4/C8/C16/C32, respectively. Both decode services ran with graph capture across all 8 ranks. The effective modes were PIECEWISE for the baseline and FULL_DECODE_ONLY for the shared pool.

The baseline was native MooncakeConnectorV2 + MemCache layerwise at d96c01e5c2, with a temporary PP=1/DCP=1 allocation patch that sizes each object to its KV group's actual bytes. See #21598 for the allocation issue. The shared-pool benchmark used vLLM at 5df63a7203cd with compatibility changes and a startup-only MemCache initialization lock. The changed Ascend runtime Python files were checked against the benchmark checkout by AST after formatting.

Paired values below are baseline / shared pool. P hit rates are fractions of queried prompt tokens. P local hits were 0% in every baseline case.

Prefixes Concurrency Successful req/s Shared-pool throughput delta P external hit rate Shared-pool P local hit rate MemCache evicted keys
8 1 0.229 / 0.183 -20.1% 93.75% / 93.75% 0.00% 0 / 0
8 4 0.466 / 0.222 -52.4% 95.09% / 85.89% 4.37% 0 / 2,991
8 8 0.500 / 0.253 -49.3% 95.22% / 87.37% 4.40% 5,166 / 8,863
8 16 0.507 / 0.340 -33.1% 95.22% / 94.73% 0.00% 7,787 / 8,815
8 32 0.511 / 0.258 -49.5% 95.22% / 84.39% 7.40% 18,179 / 20,683
16 1 0.235 / 0.168 -28.3% 94.48% / 93.75% 0.00% 5,125 / 3,043
16 4 0.466 / 0.224 -51.8% 94.99% / 91.07% 0.00% 5,118 / 6,040
16 8 0.509 / 0.099 -80.6% 95.22% / 74.08% 0.00% 5,139 / 17,991
16 16 0.512 / 0.110 -78.6% 95.22% / 76.92% 0.96% 7,713 / 24,005
16 32 0.516 / 0.060 -88.4% 95.22% / 54.07% 3.73% 17,999 / 90,625

Each implementation completed 960 formal requests across the ten reported runs. The shared pool had no throughput win in this matrix. With 8 prefixes, its peak was 0.340 req/s at C16 and throughput fell to 0.258 req/s at C32. With 16 prefixes, its peak was 0.224 req/s at C4.

The gap was concentrated on P. At 8 prefixes/C1, both runs had 93.75% external hits and zero evictions, while mean P prefill was 2.99 s for the baseline and 4.15 s for the shared pool. At 16 prefixes/C32, shared-pool P combined coverage fell to 57.80%, mean P queue time increased from 46.7 s to 379.9 s, and mean P prefill increased from 7.31 s to 35.90 s.

Initial shared-pool runs stalled at 149/192 (8 prefixes/C32), 33/64 (16 prefixes/C4), and 46/64 (16 prefixes/C8). The logs showed a MemCache read lease failure (-3102) followed by state-copy or worker wait errors. Eviction batches coincided with the errors at second resolution. Key-level attribution remains open. The table uses completed retries for those cases. Retries started with an empty pool, so earlier pool history differs in some pairs despite identical warmup inputs. Eviction counts are counts of keys, and per-key bytes can differ by layout. These results cover the single-token workload and pool capacity above.

Local validation

bash format.sh ci passed. The following command ran in the workspace's existing vLLM-Ascend virtual environment with the pinned compatibility dependencies. It passed 367 tests and 207 subtests, with 16 warnings.

# Run from the workspace's vllm-ascend directory.
base="$(cd ../.vaws-local/pr21000 && pwd)"
dep="$base/profiling/20261109T120322Z-native-copy/local-test-deps"
env VLLM_VERSION=0.32.0+pr21000compat \
  PYTHONPATH="$dep:$base/source-ascend:$base/source-vllm" \
  uv run --no-sync pytest -q --basetemp "$(mktemp -d /tmp/vaws-wb.XXXXXX)" \
  "$base/source-ascend/tests/ut/distributed/ascend_store/"{test_pd_pool,test_pool_scheduler,test_shared_transfer,test_shared_groups,test_shared_mla,test_pool_worker,test_shared_io}.py

Signed-off-by: zhuyixiang <zhuyixiang2014@163.com>
@Yuli-yx

Yuli-yx commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

Decode backpressure on 128K multi-prefix requests

Commit 5a157fe2fd contains the shared-pool connector changes used in this experiment, including reuse of the native layerwise receive and send paths. The benchmark also used scheduler and allocator probes on both arms.

We ran AISBench on the same A3 host using GLM-5.3-Flash-W8A8, TP8 prefill and TP8 decode, a 10 GiB/rank pool, and PIECEWISE graph mode on D. To induce sustained decode backpressure, we set D's max_num_seqs=1 and P's to 32. Both arms used the same eight prefix families, eight priming requests, and 32 warmup requests at C16. The measured batch contained 64 requests at C16, each with 131,072 input and 256 output tokens. Both arms completed all 64. The native baseline used MooncakeConnectorV2 + MemCache layerwise with the compact allocation patch.

Metric Native D2D + MemCache layerwise LayerwisePoolConnector
Finished prefill requests whose P blocks were held for handoff 64/64 (81.02 s mean hold) 0/64
Requests directly denied initial P allocation 10/64 0/64
P idle with requests waiting, fraction of sampled time 73.4% 0%
Mean / P95 P enqueue-to-first-schedule 60.02 / 115.59 s 3.56 / 21.01 s
D running with requests queued, fraction of sampled time 97.0% 96.3%
Mean TTFT 190.51 s 108.42 s
Mean TPOT 54.97 ms 30.75 ms
End-to-end output throughput 17.66 tokens/s 31.16 tokens/s

In one native allocation attempt, a request needed 221 blocks and only 103 were available. Four finished prefills held 872 blocks exclusively. For each of the ten requests denied admission, releasing blocks referenced only by finished prefills would have covered its deficit. P external prefix token hit rates were 95.22% and 94.73%, respectively.

The 76.4% throughput gain is the end-to-end result of one run per configuration under an intentionally constrained D. D also spent less time between its first and last token per request (14.13 vs. 7.94 s). The allocator evidence isolates the P admission benefit. A separate experiment would be needed to attribute a share of the throughput gain to P release alone.

In a second workload, one 1,536-output-token request occupied D as 64 short requests arrived (128K input, one output token, C16). Short-request throughput rose from 0.400 to 0.426 req/s (+6.7%). During the first 18 s after short requests began arriving, each arm received 16 and P finished 7 vs. 6. The larger advantage appeared under sustained decode backlog.

Local CPU/mock preflight passed 1,557 tests and 437 subtests, with 12 skips. The pinned vLLM compatibility checkout lacks vllm.v1.core.kv_cache_planning, so the GLM cache-planning module was excluded. Ruff check and format passed on the changed files. The preflight command, run from the workspace's vllm-ascend directory with its existing virtual environment, was:

base="$(cd ../.vaws-local/pr21000 && pwd)"
w="$base/profiling/c1-critical-path/pr21000-update"
dep="$base/profiling/20261109T120322Z-native-copy/local-test-deps"
env VLLM_VERSION=0.32.0+pr21000compat PYTHONPATH="$dep:$w:$base/source-vllm" \
  uv run --no-sync pytest -qx --basetemp "$(mktemp -d /tmp/pr-wide.XXXXXX)" \
  "$w/tests/ut/distributed/ascend_store" "$w/tests/ut/kv_offload/mooncake_v2" \
  --ignore="$w/tests/ut/distributed/ascend_store/test_glm53_store.py"

…tion

Signed-off-by: zhuyixiang <zhuyixiang2014@163.com>
length = len(request.prompt_token_ids or ())
if params.get("remote_num_prompt_tokens") != length:
raise ValueError("Pool PD handoff prompt length differs from the decode request")
if self.handoff_ttl_s:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is unaccepttable, since it's common that p and d instances get different system clock.

ethan686 and others added 5 commits November 30, 2026 20:02
Signed-off-by: ethan686 <zbw_ethan@163.com>
Merge upstream main, use the scheduler's current block tables and checkpoint ownership, and forward shared prefix copies through the current native worker interfaces.

Signed-off-by: zhuyixiang <zhuyixiang2014@163.com>
Signed-off-by: zhuyixiang <zhuyixiang2014@163.com>
Signed-off-by: zhuyixiang <zhuyixiang2014@163.com>
Signed-off-by: zhuyixiang <zhuyixiang2014@163.com>
Signed-off-by: zhuyixiang <zhuyixiang2014@163.com>
@Yuli-yx

Yuli-yx commented Nov 30, 2026

Copy link
Copy Markdown
Contributor Author

Divisible TP handoff and allocation-pressure validation

Tested GLM-5.3-Flash with quantized weights, 3 speculative tokens, a TP8 producer, and two TP4 consumer replicas. Each request was restored by one TP4 replica. Decode used FULL_DECODE_ONLY throughout.

  • 6f5687d86f99bdb62658d2401351709f3fc30e09 passed device source/destination checksum comparisons for 128, 1152, 1153, 1154, 2305, and 131072 input tokens. The 128K request restored 6,998,020,096 bytes across 103,520 actual destination segments, including 570,448,896 draft bytes. Every segment matched its producer source by object, owner, offset, size, and registered address. Fixed-history target argmax matched cold TP4 recomputation in 11 of 12 cases, including all three 128K cases. At 641 tokens with prior output [12089, 13], handoff selected 576 and cold recomputation selected 3555. The byte checks cover the six audited input lengths.
  • The first full accuracy run stalled after 1,043 successful responses. MemCache returned -3016 while some producer ranks were preparing KDA objects, leaving peers waiting in a collective. That run has no accuracy score.
  • 06b2dc76521471de47d343b5d2ab6d2074559683 isolates capacity failures to the affected requests. With the real 160 GiB MemCache pool filled, 25 of 128 requests returned HTTP 500 without a handoff. A successful sibling completed on the consumer under pressure. A fresh producer handoff succeeded after releasing the filler objects.
  • On this commit, AISBench GSM8K scored 1,267/1,319 (96.06%) with 1,319 attempts, zero HTTP failures and zero length-capped outputs. The rerun used 10 GiB per rank, a 60-second producer hold, temperature 0, and concurrency 16. The configured default hold is 600 seconds.

CPU/mock preflight used uv run --no-sync pytest -q --tb=short on tests/ut/distributed/ascend_store, tests/ut/kv_offload/mooncake_v2, and tests/ut/test_platform.py with vLLM v0.34.0. Result on 06b2dc7652 was 2,836 passed, 13 skipped, and 772 subtests passed.

@Yuli-yx

Yuli-yx commented Nov 30, 2026

Copy link
Copy Markdown
Contributor Author

Background decode restore on d505d6d0d537e7efa187be2b6ca224e8ba867001

The A/B used the same A3 host, GLM-5.3-Flash weights, TP8 on each side, MTP3, a 160 GiB MemCache pool, and FULL_DECODE_ONLY on D. Only background_pd_receive changed. P used layerwise pooling in both arms.

Measurement Synchronous receive Background receive
Median extra pause for an existing stream after admitting a cold 128K request 979 ms 286 ms
Median time from the cold request reaching D to its first token 1,397 ms 1,330 ms
Median across D ranks of the largest gap between graph compute kernels around admission 902 ms 326 ms
Graph compute during native read calls, median across ranks 0 ms 83 ms
Existing-request FULL graph submissions during restore, per rank 0 2–4

The pause experiment used two established streams, each generating 128 tokens. After both emitted at least 12 tokens, we either admitted the cold request or continued without it. There were two warm-up pairs and six measured pairs, yielding 12 paired stream observations per arm. Pauses use intervals between nonempty SSE chunks because MTP may return multiple tokens in a chunk. Device timings come from a separate profiled pair. All eight ranks replayed a FULL graph on the new request's first scheduled step in both arms.

A separate AISBench throughput workload used 128K prompts, eight shared prefixes, fixed 64-token output, and independent warm-up. The SLO was TTFT ≤ 10 s and TPOT ≤ 20 ms.

Concurrency and request count Sync output tok/s Background output tok/s SLO passes, sync / background
C1, 6 11.39 11.11 6/6 · 6/6
C8, 48 27.50 27.44 3/48 · 3/48

The improvement in this workload is continuity for existing decode streams. Aggregate throughput at C8 was essentially unchanged.

  • One injected lease miss on D rank 3 affected its request only. A healthy request completed while rank 0 was held in the restore, and the failed request returned HTTP 500 after the other ranks drained. Cancelling another in-flight restore returned an abort, all eight ranks drained, and a retry succeeded. A forced allocation denial after a restored request had begun decoding produced one Core preemption. Its 48 output token IDs matched the unpreempted control.
  • Full GSM8K scored 1,263/1,319 (95.75%) with one attempt per example, no HTTP errors and no length-capped outputs.
  • On one fixed history, an initial PD vs cold comparison selected 1084 vs 576. The actual input contained 131,074 tokens. A repeat on that precise input matched all 201,968 actual D read segments, totaling 13,843,628,032 bytes, against their P sources. Two independent cold D recomputations on the same token IDs and seed selected 576 and 1084. This case does not establish bitwise equivalence of different compute paths.
  • CPU/mock preflight on the three previously listed suites using uv run --no-sync pytest -q --tb=short passed 2,838 tests and 772 subtests, with 13 skipped.

@Yuli-yx

Yuli-yx commented Nov 30, 2026

Copy link
Copy Markdown
Contributor Author

Native D2D control and decode backpressure on d505d6d0d537e7efa187be2b6ca224e8ba867001

The shared connector released P source blocks after publication and lease acquisition. We observed fewer P admission stalls under D pressure. End-to-end throughput depended on output length.

Both arms ran on the same A3 host with GLM-5.3-Flash-w8a8, P TP8, D TP8, MTP3, actual FULL decode graph replay, and a 160 GiB MemCache pool (10 GiB per rank). The control used clean vLLM-Ascend 34874a4c874008c66990a4b9fe4fc3fc891d881e, MooncakeConnectorV2 for PD, and native MemCache layerwise pooling on P. The container image, vLLM 0.34, and MemFabric A3 SDMA kernel were matched. All 16 workers initialized the SDMA engine in both arms. The shared test used a 60 s handoff hold.

AISBench PD replayed identical request files with 131,072 input tokens, eight shared prefixes and a 95% target common-prefix fraction. Each measured workload contained six requests per concurrency slot after warm-up. The pass criterion was TTFT ≤ 10 s and TPOT ≤ 20 ms. A one-token response only has a TTFT criterion.

Foreground workload Native D2D Shared pool Change SLO passes, native / shared
C1 × 64 output, 6 requests 12.08 output tokens/s 11.11 −8.0% 0 / 6
C8 × 64 output, 48 requests 35.13 output tokens/s 27.44 −21.9% 0 / 3
C16 × 512 output, 96 requests 151.43 output tokens/s 203.83 +34.6% 0 / 0
C16 × 1 output with D background, 96 requests 0.862 foreground requests/s 0.768 −10.9% 21 / 7

One-token mixed workload. Before starting the foreground driver, all 32 background D streams had generated at least eight tokens. Each of the 32 slots ran three requests of 2,048 output tokens. All 192 requests completed in each arm. D reported capacity waiting in 95/109 native samples and 103/126 shared samples. In the native arm, P delayed release on all 96 foreground requests, with a mean hold of 6.53 s and a peak of seven held requests. On 42 distinct requests, an allocation failed while enough blocks were held exclusively by finished prefills to satisfy it. One allocation needed 130 blocks, with 14 available and 508 reclaimable from four held requests. With the shared connector both counts were zero. Mean P queue time fell from 7.35 to 4.44 s. Median foreground TTFT rose from 15.81 to 17.69 s. Aggregate foreground plus background output fell from 1,277.39 to 1,238.82 tokens/s (−3.0%). Native/shared P external token hit rates were 99.32%/97.67%, and MemCache eviction operations were 0/2,651.

Long-output workload. At C16 × 512, native P delayed release by 16.81 s on average and 65 distinct requests encountered the allocation condition above. Shared P had zero such denials. D capacity waiting was present in 89.2% of native samples and 0% of shared samples. Median TTFT was 27.11/30.14 s and median TPOT was 43.96/15.14 ms (native/shared). D draft-token acceptance also changed from 2.26% to 52.72%. This run cannot isolate how much of the throughput gain came from block release versus speculative decoding.

Accuracy and copied state. Full GSM8K scored 1,260/1,319 (95.53%) on native P8/D8 and 1,263/1,319 (95.75%) on shared P8/D8. Each example had one attempt, with no HTTP errors or length caps. Fifteen questions were correct only on shared and twelve only on native (paired exact p=0.70). Shared P8/D4×DP2 scored 1,267/1,319 (96.06%). Native transfer and cold decode selected the same first token on 12/12 fixed histories. On the 131,074-token boundary case, both synchronous and background shared restores matched the bytes published by their respective P processes. Of 226,152 comparable P source segments from two independent service starts, 144,458 already had different digests at publication. Cold decode also changed top-1 across runs on the same token history. This limits what can be inferred about numerical reproducibility from the byte-level check.

The CPU/mock preflight for this head used the Ascend Store, Mooncake V2 and platform suites: 2,838 passed, 13 skipped, and 772 subtests passed. The same-head synchronous/background profiling measurements are in the earlier validation comment.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation module:core module:tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants