Skip to content

feat: use NPU test runtime device selection in Triton C++ tests. - #6

Open
jarvis666666 wants to merge 1 commit into
xLLM-AI:mainfrom
jarvis666666:cann9.1
Open

jarvis666666 wants to merge 1 commit into
xLLM-AI:mainfrom
jarvis666666:cann9.1

Conversation

@jarvis666666

Copy link
Copy Markdown
Contributor

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 feat: init npu python runtime in triton test main entries. #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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant