Repository navigation
feat: use NPU test runtime device selection in Triton C++ tests. - #6
Open
jarvis666666 wants to merge 1 commit into
Open
jarvis666666 wants to merge 1 commit into
jarvis666666 wants to merge 1 commit into
Conversation
Problem: - Triton C++ gtest binaries call bare torch_npu::init_npu() in SetUpTestSuite/SetUp and torch_npu::finalize_npu() in teardown. Triton npubin kernel registration/loading depends on the NPU python runtime, which is initialized in the test main entries since xLLM-AI#3 (xllm::testing::init_npu_test_runtime). The extra bare init_npu() re-initializes the runtime and pins the device via a device string, while finalize_npu() tears the runtime down mid-process while later suites may still need it. Change (10 files under triton_npu/test/): - Replace torch_npu::init_npu(...) with c10_npu::SetDevice(kDeviceId) so SetUp only selects the device; runtime init stays in main(). - Remove torch_npu::finalize_npu() from teardown; process-exit teardown stays with finalize_npu_test_runtime()/atexit (idempotent). - Include torch_npu/csrc/core/npu/NPUFunctions.h for c10_npu::SetDevice. Compatibility: - c10_npu::SetDevice and NPUFunctions.h exist in both torch_npu 2.9.0.post6 and 2.10.0.post4 (verified on a3-arm images), so the change applies to both the torch 2.9 and 2.10 image generations. - Test-only change; no operator implementation is touched. Verification: - The equivalent change in the xllm verification tree (mainline bc38092fe + this fix) compiled clean twice (rc=0) on a3-arm CANN 9.1.0 / torch_npu 2.10.post4.
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.
Problem:
Change (10 files under triton_npu/test/):
Compatibility:
Verification: