Fix missing Ascend RT launch hooks for vLLM native kernels - #12
Conversation
|
Thanks for your pull request. Before we can look at it, you'll need to add a 'DCO signoff' to your commits. 📝 Please follow instructions in the contributing guide to update your commits with the DCO Full details of the Developer Certificate of Origin can be found at developercertificate.org. The list of commits missing DCO signoff:
DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: ltaodream The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Welcome @ltaodream! It looks like this is your first PR to Project-HAMi/hami-vnpu-core 🎉 |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughTwo new exported FFI wrapper functions, ChangesKernel launch hooks
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant Caller
participant HookFFI
participant NpuLimiter
participant Passthrough
Caller->>HookFFI: rtKernelLaunchWithHandle(handle, tilingKey, blockDim, argsInfo, smDesc, stm, kernelInfo)
HookFFI->>NpuLimiter: wait_for_token(stm)
NpuLimiter-->>HookFFI: token acquired
HookFFI->>Passthrough: forward args
Passthrough-->>Caller: return u64
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Motivation
hami-vnpu-corelimits Ascend compute usage by intercepting selected Ascend RT launch APIs and calling the existing token limiter before forwarding the launch to the real runtime API.The current hook set already covers:
rtAicpuKernelLaunchExWithArgsrtAicpuKernelLaunchWithFlagrtKernelLaunchWithFlagV2rtKernelLaunchWithHandleV2rtModelExecuteHowever, vLLM-Ascend native kernels can also launch through RT symbols that are not currently intercepted by
hami-vnpu-core.In the local vLLM-Ascend environment,
libvllm_ascend_kernels.soimports the following RT launch symbols:Before this PR,
rtKernelLaunchWithHandleandrtVectorCoreKernelLaunchWithHandlewere missing from the hook layer. Kernels launched through these symbols could bypassnpu_limiter().wait_for_token(stm), so compute throttling would not apply to those paths.This matters for serving stacks such as vLLM-Ascend and SGLang-on-Ascend, where native custom kernels may be used by inference workloads. In that case, memory quota enforcement can still work, but compute isolation may be ineffective if the hot launch path is not intercepted.
This PR adds the two missing RT launch hooks and keeps the implementation aligned with the existing RT-layer interception design.
Modifications
This PR adds hooks for:
rtKernelLaunchWithHandlertVectorCoreKernelLaunchWithHandleBoth hooks follow the existing pattern used by other RT launch hooks:
No new scheduling policy is introduced. The change only extends coverage of the existing compute limiter to additional RT launch APIs.
Main changes:
rtKernelLaunchWithHandlehook.rtVectorCoreKernelLaunchWithHandlehook.hook.rs.Validation
Static Symbol Check
Checked that vLLM-Ascend imports the missing RT launch symbols:
Result:
This confirms that vLLM-Ascend native kernels can use the two symbols added by this PR.
Build Check
Built
hami-vnpu-corelocally:Result: passed.
Confirmed the new symbols are exported by
libvnpu.so:Result:
Diff Check
Checked the patch for whitespace issues:
Result: passed.
Runtime Test Environment
Runtime validation was performed on a real Ascend NPU environment.
Environment details:
cann-8.5.1target/release/libvnpu.soNPU_GLOBAL_SHM_PATHNPU_PRIORITY=20andNPU_PRIORITY=80NPU status after testing:
Result:
Runtime Workload
The runtime test used a vLLM-Ascend native custom op:
The op is provided by:
This path uses the vLLM-Ascend native kernel library that imports the missing RT launch symbols.
The test repeatedly launched the same native op from two concurrent processes.
Each process used:
The only intended difference between the two processes was:
Baseline Without LD_PRELOAD
First, the same two-process workload was run without
LD_PRELOAD.Result:
33018 ops/s32967 ops/sThe two processes had effectively equal throughput without the limiter.
Original hami-vnpu-core Behavior
Then the same workload was run with the original
hami-vnpu-corehook library before this PR.Result:
2025984 ops/s8028584 ops/sThe throughput ratio was only about
1.10x, so the workload was not meaningfully throttled according to the20/80priority split.This shows that the original hook set did not intercept the relevant vLLM-Ascend native launch path.
Behavior With This PR
Finally, the same workload was run with this PR applied.
Result:
205250 ops/s8021665 ops/sThe throughput ratio was about
4.13x, matching the expected20/80priority ratio.This confirms that adding
rtKernelLaunchWithHandleandrtVectorCoreKernelLaunchWithHandlemakes the existing compute limiter effective for this vLLM-Ascend native kernel path.Result Summary
Observed throughput:
LD_PRELOAD33018 ops/s32967 ops/s25984 ops/s28584 ops/s5250 ops/s21665 ops/sConclusion:
This PR fixes a real RT-layer interception gap for vLLM-Ascend native kernels. The original hook set did not meaningfully limit this workload, while this PR makes the existing priority-based compute limiter effective.
Summary by CodeRabbit