Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions triton_npu/test/triton_causal_conv1d_update_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <torch/nn/functional/conv.h>
#include <torch/torch.h>
#include <torch_npu/torch_npu.h>
#include <torch_npu/csrc/core/npu/NPUFunctions.h>

#include <optional>

Expand Down Expand Up @@ -144,7 +145,7 @@ class TritonCausalConv1dUpdateTest : public ::testing::Test {
}

torch::manual_seed(42);
torch_npu::init_npu(device_str_);
c10_npu::SetDevice(kDeviceId);
kernel_name_ = "_causal_conv1d_update_qwen_decode_kernel";
binary_filename_ = "_causal_conv1d_update_qwen_decode_kernel.npubin";
binary_path_ = GetKernelBinaryPath(binary_filename_);
Expand All @@ -155,7 +156,6 @@ class TritonCausalConv1dUpdateTest : public ::testing::Test {
void TearDown() override {
if (npu_available_) {
try {
torch_npu::finalize_npu();
} catch (...) {
}
}
Expand Down
3 changes: 2 additions & 1 deletion triton_npu/test/triton_causal_conv1d_update_v2_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <gtest/gtest.h>
#include <torch/torch.h>
#include <torch_npu/torch_npu.h>
#include <torch_npu/csrc/core/npu/NPUFunctions.h>

#include <algorithm>
#include <optional>
Expand Down Expand Up @@ -246,7 +247,7 @@ class TritonCausalConv1dUpdateV2Test : public ::testing::Test {

torch::manual_seed(42);
if (!g_npu_initialized_v2) {
torch_npu::init_npu(device_str_);
c10_npu::SetDevice(kDeviceIdV2);
g_npu_initialized_v2 = true;
}
kernel_name_ = "_causal_conv1d_update_kernel_npu_tiled_v2";
Expand Down
4 changes: 2 additions & 2 deletions triton_npu/test/triton_chunk_gated_delta_rule_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <gtest/gtest.h>
#include <torch/torch.h>
#include <torch_npu/torch_npu.h>
#include <torch_npu/csrc/core/npu/NPUFunctions.h>

#include <optional>
#include <string>
Expand Down Expand Up @@ -331,7 +332,7 @@ class TritonChunkGatedDeltaRuleTest
static void SetUpTestSuite() {
try {
torch::zeros({1}, torch::TensorOptions().device("npu:0"));
torch_npu::init_npu("npu:" + std::to_string(kDeviceId));
c10_npu::SetDevice(kDeviceId);
auto& reg = KernelRegistry::get_instance();
std::string binary_path = GetKernelBinaryPath(kBinaryName);
npu_initialized_ = reg.register_kernel(kKernelName, binary_path) &&
Expand All @@ -347,7 +348,6 @@ class TritonChunkGatedDeltaRuleTest
}
try {
KernelRegistry::get_instance().cleanup();
torch_npu::finalize_npu();
} catch (...) {
}
}
Expand Down
4 changes: 2 additions & 2 deletions triton_npu/test/triton_fused_gdn_gating_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <gtest/gtest.h>
#include <torch/torch.h>
#include <torch_npu/torch_npu.h>
#include <torch_npu/csrc/core/npu/NPUFunctions.h>

#include <array>

Expand Down Expand Up @@ -81,7 +82,7 @@ class TritonFusedGdnGatingTest : public ::testing::Test {
binary_filename_ = "fused_gdn_gating_decode_kernel.npubin";

torch::manual_seed(42);
torch_npu::init_npu(device_str_);
c10_npu::SetDevice(kDeviceId);

binary_path_ = GetKernelBinaryPath(binary_filename_);
auto& reg = KernelRegistry::get_instance();
Expand All @@ -96,7 +97,6 @@ class TritonFusedGdnGatingTest : public ::testing::Test {
void TearDown() override {
if (npu_available_) {
try {
torch_npu::finalize_npu();
} catch (...) {
}
}
Expand Down
4 changes: 2 additions & 2 deletions triton_npu/test/triton_fused_qkvzba_split_reshape_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <gtest/gtest.h>
#include <torch/torch.h>
#include <torch_npu/torch_npu.h>
#include <torch_npu/csrc/core/npu/NPUFunctions.h>

#include <tuple>
#include <vector>
Expand Down Expand Up @@ -119,7 +120,7 @@ class TritonFusedQkvzbaSplitReshapeTest
static void SetUpTestSuite() {
try {
torch::zeros({1}, torch::TensorOptions().device("npu:0"));
torch_npu::init_npu("npu:" + std::to_string(kDeviceId));
c10_npu::SetDevice(kDeviceId);
auto& reg = KernelRegistry::get_instance();
npu_initialized_ = true;
for (const char* kernel_name : kFusedQkvzbaSplitReshapeKernels) {
Expand All @@ -139,7 +140,6 @@ class TritonFusedQkvzbaSplitReshapeTest
if (npu_initialized_) {
try {
KernelRegistry::get_instance().cleanup();
torch_npu::finalize_npu();
} catch (...) {
}
}
Expand Down
4 changes: 2 additions & 2 deletions triton_npu/test/triton_l2norm_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <gtest/gtest.h>
#include <torch/torch.h>
#include <torch_npu/torch_npu.h>
#include <torch_npu/csrc/core/npu/NPUFunctions.h>

#include <tuple>
#include <vector>
Expand Down Expand Up @@ -45,7 +46,7 @@ class TritonL2NormTest : public ::testing::TestWithParam<std::vector<int64_t>> {
static void SetUpTestSuite() {
try {
torch::zeros({1}, torch::TensorOptions().device("npu:0"));
torch_npu::init_npu("npu:" + std::to_string(kDeviceId));
c10_npu::SetDevice(kDeviceId);
auto& reg = KernelRegistry::get_instance();
std::string binary_path =
GetKernelBinaryPath("l2norm_fwd_kernel2_loop.npubin");
Expand All @@ -63,7 +64,6 @@ class TritonL2NormTest : public ::testing::TestWithParam<std::vector<int64_t>> {
}
try {
KernelRegistry::get_instance().cleanup();
torch_npu::finalize_npu();
} catch (...) {
}
}
Expand Down
4 changes: 2 additions & 2 deletions triton_npu/test/triton_layernorm_fwd_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <gtest/gtest.h>
#include <torch/torch.h>
#include <torch_npu/torch_npu.h>
#include <torch_npu/csrc/core/npu/NPUFunctions.h>

#include <iomanip>
#include <iostream>
Expand Down Expand Up @@ -123,7 +124,7 @@ class TritonLayerNormFwdTest : public ::testing::Test {
static void SetUpTestSuite() {
try {
torch::zeros({1}, torch::TensorOptions().device("npu:0"));
torch_npu::init_npu("npu:" + std::to_string(kDeviceId));
c10_npu::SetDevice(kDeviceId);
npu_initialized_ = true;
} catch (...) {
npu_initialized_ = false;
Expand All @@ -134,7 +135,6 @@ class TritonLayerNormFwdTest : public ::testing::Test {
if (npu_initialized_) {
try {
KernelRegistry::get_instance().cleanup();
torch_npu::finalize_npu();
} catch (...) {
}
}
Expand Down
3 changes: 2 additions & 1 deletion triton_npu/test/triton_recurrent_gated_delta_rule_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <gtest/gtest.h>
#include <torch/torch.h>
#include <torch_npu/torch_npu.h>
#include <torch_npu/csrc/core/npu/NPUFunctions.h>

#include <optional>

Expand Down Expand Up @@ -122,7 +123,7 @@ class TritonRecurrentGatedDeltaRuleTest : public ::testing::Test {
static void SetUpTestSuite() {
try {
torch::zeros({1}, torch::TensorOptions().device("npu:0"));
torch_npu::init_npu("npu:" + std::to_string(kDeviceId));
c10_npu::SetDevice(kDeviceId);
auto& reg = KernelRegistry::get_instance();
std::string binary_path = GetKernelBinaryPath(
"fused_recurrent_gated_delta_rule_fwd_kernel.npubin");
Expand Down
4 changes: 2 additions & 2 deletions triton_npu/test/triton_rope_inplace_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <gtest/gtest.h>
#include <torch/torch.h>
#include <torch_npu/torch_npu.h>
#include <torch_npu/csrc/core/npu/NPUFunctions.h>

#include <vector>

Expand Down Expand Up @@ -94,7 +95,7 @@ class TritonRopeInplaceTest
static void SetUpTestSuite() {
try {
torch::zeros({1}, torch::TensorOptions().device("npu:0"));
torch_npu::init_npu("npu:" + std::to_string(kDeviceId));
c10_npu::SetDevice(kDeviceId);
auto& reg = KernelRegistry::get_instance();
std::string binary_path =
GetKernelBinaryPath("rope_inplace_kernel.npubin");
Expand All @@ -110,7 +111,6 @@ class TritonRopeInplaceTest
if (npu_initialized_) {
try {
KernelRegistry::get_instance().cleanup();
torch_npu::finalize_npu();
} catch (...) {
}
}
Expand Down
4 changes: 2 additions & 2 deletions triton_npu/test/triton_split_rmsnorm_rope_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <gtest/gtest.h>
#include <torch/torch.h>
#include <torch_npu/torch_npu.h>
#include <torch_npu/csrc/core/npu/NPUFunctions.h>

#include <algorithm>
#include <cstdlib>
Expand Down Expand Up @@ -145,7 +146,7 @@ class TritonSplitRmsnormRopeTest : public ::testing::Test {
static void SetUpTestSuite() {
try {
torch::zeros({1}, torch::TensorOptions().device("npu:0"));
torch_npu::init_npu("npu:" + std::to_string(kDeviceId));
c10_npu::SetDevice(kDeviceId);
npu_initialized_ = true;
} catch (...) {
npu_initialized_ = false;
Expand All @@ -156,7 +157,6 @@ class TritonSplitRmsnormRopeTest : public ::testing::Test {
if (npu_initialized_) {
try {
KernelRegistry::get_instance().cleanup();
torch_npu::finalize_npu();
} catch (...) {
}
}
Expand Down