Skip to content

[Bugfix][KV Offloading] Isolate queued store compute events - #165

Merged
ShuhaoZhangTony merged 2 commits into
mainfrom
feature/kv-offload-event-lifecycle
Jul 30, 2026
Merged

[Bugfix][KV Offloading] Isolate queued store compute events#165
ShuhaoZhangTony merged 2 commits into
mainfrom
feature/kv-offload-event-lifecycle

Conversation

@ShuhaoZhangTony

@ShuhaoZhangTony ShuhaoZhangTony commented Jul 20, 2026

Copy link
Copy Markdown
Member

Purpose

The store path queued a reusable compute-completion event into the background copy backend. If dequeue is delayed across scheduler steps, recording that same event again can move the dependency observed by an earlier queue item.

This change allocates one event for every queued store. The new regression test submits two steps while the backend deliberately does not consume either wait event, then verifies the submissions retain distinct events recorded on the compute stream.

Paired vllm-ascend-hust current revision: 64f31cf631099a9c93abfcf4d83e63e0c85bf9cd (product code tested at 7feed154b6817aa607738185bb4cf6915e14c359; the final commit adds only the evidence manifest).

This does not modify or rewrite the merged vllm-ascend-hust #148 branch or its authorship.

Duplicate check: related upstream vLLM vllm-project#46278 established compute-to-store ordering, but the current open PR and issue sets contain no change that fixes reusable-event lifetime across delayed dequeue. This PR is not a duplicate.

Test Plan

Run the delayed-dequeue unit test and focused Ruff/format checks on the two changed files.

The paired exact revisions passed a real Ascend 910B2 tensor lifecycle gate: two queued D2H copies drained during concurrent shutdown, copied bytes and H2D reload matched exactly, and health, stream synchronization, thread exit, idempotent shutdown, and late-submission rejection passed. A Qwen3-0.6B smoke completed a first deterministic request and engine shutdown; forced reload was not claimed because reset_prefix_cache could not satisfy its precondition. See the machine-readable evidence. This is correctness/smoke evidence, not an online-serving or performance result; this PR makes no performance claim.

Test Result

  • Focused pytest: 1 passed.
  • Ruff check: passed.
  • Ruff format check: passed.
  • git diff --check: passed.
  • Real Ascend 910B2 exact-pair tensor lifecycle: passed; Qwen3-0.6B first-request/shutdown smoke: passed, with forced reload explicitly inconclusive.

@xmdhb

xmdhb commented Jul 21, 2026

Copy link
Copy Markdown

The core CUDA implementation looks correct for event isolation. One portability note: the inherited get_finished() uses torch.cuda.current_stream(), so NPU adapters must provide an accelerator-specific mapping or override this path. This is tracked in paired vllm-ascend-hust#154.

@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown

Ascend Benchmark Result

  • Commit: 2521456ed7fdc2a5181e670f45e77c6403eb4034
  • Scenario: random-online
  • Model: Qwen/Qwen2.5-3B-Instruct
  • Publish mode: artifact-preview
  • Leaderboard publish: skipped
  • HF publish: skipped
  • Perfgate mode: report
  • Baseline source: unavailable
  • Scenario mode: l1-smoke
  • Scenario label: none
  • Scenario reason: no L2 benchmark label found; using default PR benchmark scenario
  • Workflow run: view run
  • Stage 1 baseline: e4ce33646f2ef1781289e6dc651fad0d00177c55 source unavailable
  • Request throughput: 3.725351949824668 req/s
  • Output throughput: 59.60563119719469 tok/s
  • Mean TTFT: 685.2327939704992 ms
  • Failed requests: 0
  • Leaderboard engine version: 2521456e
  • Same-spec goal artifact: perfgate-ascend-qwen25-3b-910b2 (9845635e)

@CubeLander CubeLander left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The per-submission event isolation is the right fix for delayed dequeue: each queued store now retains the dependency recorded for its own scheduler step. The focused regression passes locally. There is one small required-check blocker below; I also left the paired preemption-drain correctness finding on vllm-ascend-hust#154.

"""Record submissions without consuming their wait events."""

def __init__(self) -> None:
self.wait_events = []

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The current required pre-commit run fails here with mypy [var-annotated]: Need type annotation for "wait_events". Please give the list an explicit type, for example self.wait_events: list[object | None] = [], and rerun the exact-head pre-commit check. The event-isolation behavior itself looks sound.

@ShuhaoZhangTony

Copy link
Copy Markdown
Member Author

Current handoff status

  • Exact head: 09dcfcce202c81161c569f0f8da24af0fbfc5ab4.
  • State: Ready for review; no unresolved review thread.
  • Evidence: latest effective pre-run, pre-commit, Ascend inference smoke/regression, and benchmark checks are successful. Older cancelled duplicates are superseded by later successes.
  • Remaining gate: one non-author approval.
  • Default reviewer requested: @moonandlife (王胜).
  • Resource state: no CI or NPU run is active for this handoff.

ShuhaoZhangTony and others added 2 commits July 26, 2026 16:36
Allocate a distinct compute-completion event for each queued store so delayed dequeue cannot observe a later record on a reused event. Cover two queued steps without consuming either wait event.

Signed-off-by: Shuhao Zhang (Tony) <shuhao_zhang@hust.edu.cn>
Signed-off-by: Shuhao Zhang (Tony) <5267690+ShuhaoZhangTony@users.noreply.github.com>
@moonandlife
moonandlife force-pushed the feature/kv-offload-event-lifecycle branch from 09dcfcc to 2521456 Compare July 26, 2026 08:36

@moonandlife moonandlife left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

结论:✅ benchmark通过后即可合入

评估

维度 评价
正确性 修复方式规范——每个异步提交应拥有自己的完成事件。旧代码跨步骤复用单个事件,在延迟出队时会触发数据竞争。
测试覆盖 mock backend 精确复现了竞争条件;断言同时验证了对象身份(is not)和调用次数(assert_called_once_with)。
回归风险 极低。生产代码仅改 4 行,其余为测试文件。
硬件验证 已在真实 910B2 上通过配对验证。
项目风格 符合现有规范——SPDX 头、类型注解、fixture 模式。

@ShuhaoZhangTony

ShuhaoZhangTony commented Jul 26, 2026

Copy link
Copy Markdown
Member Author

我已检查:该 PR 只修复 simple_kv_offload store compute event 复用问题,并补了延迟队列回归测试;pre-commit、smoke、regression、ascend-benchmark 均为 green。\n\n阻塞点不是代码问题,而是分支保护要求 1 个有写权限的 approving review;当前 token 是 PR 作者,GitHub 不允许自审。请王胜或其他 maintainer approve 后即可合并。

@ShuhaoZhangTony
ShuhaoZhangTony merged commit ab8af72 into main Jul 30, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants