perf(deepseek): submit decode asynchronously - #154
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughDeepSeek V4 fused MTP decode now submits asynchronous L3 work and reclaims outputs after completion. Slot-local buffers preserve in-flight results. Profiling accepts asynchronous worker spans and reports submit-to-completion timing. ChangesAsynchronous decode pipeline
Estimated code review effort: 4 (Complex) | ~45 minutes Mergeability Score: 🟡 Moderate · up to The change adds asynchronous decode timing analysis, but the current analyzer can pair overlapping spans and can label fallback blocking timings as submit-to-completion. This can produce incorrect performance reports, so merge should wait for these bounded observability issues to be fixed or explicitly accepted. Sequence Diagram(s)sequenceDiagram
participant DeviceLane
participant DeepSeekV4Runner
participant L3Worker
participant ReclaimLane
DeviceLane->>DeepSeekV4Runner: submit prepared fused MTP decode
DeepSeekV4Runner->>L3Worker: submit L3 work and retain slot bindings
L3Worker-->>DeviceLane: return pending completion handle
ReclaimLane->>L3Worker: wait for completion
L3Worker-->>ReclaimLane: complete device work
ReclaimLane->>DeepSeekV4Runner: reclaim and read outputs
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.agents/skills/profile-dsv4-serving-strace/scripts/analyze_profile.py:
- Line 358: Update the report formatting around the fused decode steady-mean
output to choose its metric label from
summary["serving_profile"]["decode_timing_source"], distinguishing
submit-to-completion from the blocking_kernel_span fallback. Keep the existing
fused_serving mean value and formatting unchanged while ensuring the Markdown
label accurately reflects the timing source.
- Around line 123-128: Update the async kernel lifecycle validation in the
submits/waits loop to require each wait span’s start timestamp to be at or after
the paired submit span’s end (`submit["ts"] + submit["dur"]`). Raise the
existing invalid-lifecycle RuntimeError when this condition fails, before
appending to kernel_durations_ms.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: c91456b1-f6b4-4a34-b9c2-0d1c029f5f83
📒 Files selected for processing (8)
.agents/skills/profile-dsv4-serving-strace/SKILL.md.agents/skills/profile-dsv4-serving-strace/scripts/analyze_profile.py.agents/skills/profile-dsv4-serving-strace/scripts/run_profile.pypypto_serving/model/common/executor/executor.pypypto_serving/model/common/executor/pypto_executor.pypypto_serving/model/deepseek/npu_runner.pypypto_serving/serving/server/serving_worker.pytests/unit/model/deepseek/test_model_components.py
a559e1b to
8ec3a37
Compare
a26d59b to
6abbec1
Compare
78923d8 to
1aed42d
Compare
Main's async-decode PR hw-native-sys#154 (submit decode asynchronously) adds _DeepSeekV4PendingL3Dispatch and _submit_l3 built on the legacy values-dict/_coerce_l3_arg pipeline. Re-expressed through the TaskArgs architecture: - Keep main's _DeepSeekV4PendingL3Dispatch handle class and the async decode flow (submit + wait at reclaim). - Port _submit_l3 to the L3DispatchMixin resolver (resolve_l3_arg + the mixin's static-upload cache) instead of _coerce_l3_arg; the legacy _run_l3/_share_cpu_tensor/_copy_shared duplicates stay dropped (the mixin owns them). - Drop main's slot-local Host-Out re-allocations in _decode_input_slots: the per-slot decode/MTP TaskArgs already own slot-local outputs, which satisfies the async mutable-binding requirement by construction. _decode_input_slots keeps only the two fused-MTP prepend buffers. - _ensure_decode_buffers gains a default vocab_size for main's single-arg caller. - Tests: main's async-style fake_submit_l3 (writes at wait) adapted to the TaskArgs slot tensors. Verified: 177 unit tests green, ruff + compile clean.
Summary
submit()and deferhandle.result()to the output/reclaim lane.worker_submitand.worker_waitspans and report submit-to-completion timingCloses #148.
Why
Serving already separated prepare, dispatch, and reclaim, but the device lane still called the blocking PyPTO
run()API. Now that PyPTO exposes asynchronous handles, serving can submit the next prepared decode while the output lane waits for the previous invocation and publishes its tokens.The handle lifetime also changes the binding contract: every mutable Host Out buffer must remain unique and alive until completion, even when reclaim does not read that buffer. The two decode snapshots therefore own separate main and MTP hidden/logit outputs.
Validation
python -m pytest tests/unit— 144 passedgit diff --checkpassed0,2,4,6,8,10,12,14