Add: integrate kernel-mode PRs with an end-to-end launch test - #2216
Merged
YunjiQin merged 2 commits intoSep 14, 2026
Conversation
Bring the in-flight kernel-mode PRs onto one line on the current mainline, where a context borrowed from the caller runs a real operator through the four public kernel entries on a2a3. - simpler_kernel_mode_launch reaches device execution on onboard tensormap_and_ringbuffer: a host owner validates the context and callable, encodes the invocation, and submits it through the three-stream binder; the AICPU dispatch entry hands the payload to the TMR executor. The kernel path commits the pooled arena before the runtime image is uploaded. host_build_graph and simulation report no kernel capability. - host_build_graph gains host build separated from upload, resource planning with prepare and freeze, immutable graph packets and sealed execution slots. - The kernel resource model borrows the caller's ACL state, device and stream, keeps a failed close retryable, admits one live kernel context per device and runtime in a loaded host runtime, and holds kernel capacity through the shared static arena bank. - prepare_callable takes the caller stream; launch is id-based and checks the callable's generation on host and device; launch events fork from the caller's Start to AICore first, then AICPU. - Host error codes follow the merged K1 numbering. INVALID_ARGUMENT is BASE - 4 and the callable and capacity codes take BASE - 5 through BASE - 9. An out-of-range launch id is an argument error. - tests/ut/py/test_kernel_mode_c_api.py owns its ACL, device, stream and tensors, drives the four entries, and compares all 16384 elements of two launches against x + scalar with fresh addresses and scalars, while committed memory stays constant and returns to zero after finalize. - docs/zh-cn/kernel-mode-integration-test.md explains the test, the launch sequence and what graph mode has and has not covered; the kernel docs join the mkdocs nav. - INTEGRATION-LOG.md records each contract decision and why. Co-authored-by: Leaf-Salix <2503954024@qq.com> Co-authored-by: YunjiQin <a1339924773@gmail.com> Co-authored-by: TaoZQY <zhangtaolqy@mail.ustc.edu.cn>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
tests/ut/py/test_worker/test_kernel_mode_entry.py asserted that every runtime refuses kernel init. On the integrated tree the onboard tensormap_and_ringbuffer runtime claims the borrowed device, so three hardware jobs failed: both init_refused jobs and program_init_still_works. The refusal cases now load host_build_graph, which reports no kernel capability, so they still prove the call reaches the C ABI and that a refused init leaves the caller's stream usable. A new init_claims_borrowed_stream case matches the C++ twin: TMR init succeeds, reports kernel support, and refuses a second worker on the same device while the first stays initialized. The validation record gains the full sweeps run on the merged tree: Python hardware unit tests, the full Python unit suite, the invocation transport probe, a2a3 onboard and SDMA scenes, and both simulation sweeps.
YunjiQin
approved these changes
Sep 14, 2026
YunjiQin
merged commit Sep 14, 2026
5b2a5a5
into
hw-native-sys:feat/kernel-mode-integration-test
3 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Integrates the in-flight kernel-mode PRs into one line on the current mainline, and proves it with a public-entry, caller-owned launch that computes real results on a2a3 hardware.
main, and this branch adopts its final contract.tensormap_and_ringbuffer,simpler_kernel_mode_launchvalidates the context and callable, encodes the invocation and submits it through the three-stream binder. The AICPU dispatch entry hands the payload to the TMR executor. The kernel path commits the pooled arena before the runtime image is uploaded.host_build_graphand simulation report no kernel capability.tests/ut/py/test_kernel_mode_c_api.py::test_kernel_eager_launch_executes_fresh_tensor_and_scalar_snapshotscreates its own ACL state, device, stream and tensors, drives init, prepare_callable, launch and finalize, and compares all 16,384 FLOAT32 elements of two launches againstx + scalar.docs/zh-cn/kernel-mode-integration-test.mddescribes the test, the launch sequence, and the current state of graph mode. The kernel docs are added to the mkdocs nav, which--strictrequires.Contract decisions
Every decision is recorded with its reasoning in
INTEGRATION-LOG.md, entries D0 to D14.INVALID_ARGUMENTisBASE - 4;CALLABLE_COUNT_EXCEEDED,CALLABLE_BYTES_EXCEEDED,CALLABLE_NOT_RESIDENT,CALLABLE_STALE,CAPACITY_EXCEEDEDareBASE - 5toBASE - 9prepare_callablecaller_streamlaunchINVALID_ARGUMENTKernelEventKindnames the fifth eventPrepareTailrtsLaunchCpuKernelpath; theWithHostArgsnative binder stays available for a later switchChipWorkerresolves init, prepare and launch only whensupportedis nonzeromainis not carriedEffect on the original PRs
prepare_callablein Add: persistent kernel-context execution resources (K2) #2176, Add: TMR kernel invocation snapshots and native transport adapter(K4) #2180 and Add: TMR kernel resident arguments and invocation isolation(K5) #2189; the handle ABI in Add: bounded kernel callable registration #2190; the event enum in Add: persistent kernel-context execution resources (K2) #2176; the K1 variant carried by Refactor: [H1] measure HBG graphs before device upload #2171 to Add: [H3] seal and validate HBG execution slots #2175.Testing
Hardware: a2a3, through
onboard-arch-precheckandtask-submit --device auto.SIMPLER_ENABLE_HARDWARE_TESTS=ON, no hardware^requires_hardware(_a2a3)?$test_comm_lifecycle,test_kernel_mode_entry)tests/ut -m "not requires_hardware"tests/ut -m requires_hardware --platform a2a3tools/cann-examples/tmr-invocation-snapshot-m "not sdma" --exclude-level 4mkdocs build --strictThe 13 hardware cases are the eager numerical launch, seven lifecycle retry scenarios, two device-query rejections, kernel init on a borrowed device for both runtimes, and the K2 capture probe with 100 replays.
The full Python hardware run found
tests/ut/py/test_worker/test_kernel_mode_entry.pystill asserting that every runtime refuses kernel init, which failed three jobs against TMR. The second commit points its refusal cases athost_build_graphand addsinit_claims_borrowed_stream, matching the C++ twin; the 30-passed result is from the fixed file. Details are indocs/kernel-integration-validation.md, sections "Mainline merge revalidation" and "Full sweeps on the merged tree".Not covered
host_build_graphkernel execution: H4 has no submitted PR, so HBG reports no kernel capability.