Skip to content

Commit 2b108e9

Browse files
yingxudengliutongxuan
authored andcommitted
refactor: cleanup headers and optimize branch checks.
1 parent b1e2a27 commit 2b108e9

File tree

7 files changed

+12
-11
lines changed

7 files changed

+12
-11
lines changed

xllm/core/common/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ cc_library(
3030
absl::random_random
3131
absl::strings
3232
torch
33-
$<$<BOOL:${USE_NPU}>:torch_python>
3433
$<$<BOOL:${USE_NPU}>:torch_npu>
3534
$<$<BOOL:${USE_MSPTI}>:mspti>
3635
$<$<BOOL:${USE_NPU}>:ms_tools_ext>

xllm/core/common/global_flags.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,9 @@ DEFINE_bool(enable_constrained_decoding,
466466
"through pre-defined rules.");
467467

468468

469+
#if defined(USE_NPU)
469470
DEFINE_string(
470471
npu_kernel_backend,
471472
"ATB",
472473
"NPU kernel backend. Supported options: ATB, TORCH. Default is ATB.");
474+
#endif

xllm/core/common/global_flags.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,4 +227,6 @@ DECLARE_double(dit_cache_residual_diff_threshold);
227227

228228
DECLARE_bool(enable_constrained_decoding);
229229

230+
#if defined(USE_NPU)
230231
DECLARE_string(npu_kernel_backend);
232+
#endif

xllm/core/framework/parallel_state/collective_communicator.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ limitations under the License.
2121
#include "npu_process_group.h"
2222
#include "xllm_kernels/core/include/atb_speed/base/external_comm_manager.h"
2323
#include "xllm_kernels/core/include/atb_speed/utils/singleton.h"
24-
#include "xllm_kernels/models/base/param/mapping.h"
2524
#elif defined(USE_MLU)
2625
#include "mlu_process_group.h"
2726
#elif defined(USE_CUDA)

xllm/core/framework/parallel_state/cuda_process_group.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ class ProcessGroupNccl : public ProcessGroup {
3434
: ProcessGroup(device) {
3535
c10::intrusive_ptr<c10d::ProcessGroupNCCL::Options> pg_options =
3636
c10d::ProcessGroupNCCL::Options::create();
37-
#if TORCH_VERSION_MAJOR >= 2 && TORCH_VERSION_MINOR >= 7
37+
#if TORCH_VERSION_MAJOR > 2 || \
38+
(TORCH_VERSION_MAJOR == 2 && TORCH_VERSION_MINOR >= 7)
3839
pg_options->group_name = group_name;
3940
#endif
4041
int rank = global_rank;

xllm/core/framework/parallel_state/npu_process_group.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ limitations under the License.
1414
==============================================================================*/
1515

1616
#include "npu_process_group.h"
17-
#ifdef TORCH_HIGHER_THAN_PTA6
18-
#include <torch_npu/csrc/framework/OpCommand.h>
19-
#else
20-
#include <torch_npu/csrc/aten/NPUNativeFunctions.h>
21-
#include <torch_npu/csrc/framework/utils/OpPreparation.h>
22-
#endif
2317

2418
#include <c10d/ProcessGroup.hpp>
2519
#include <c10d/TCPStore.hpp>
@@ -49,7 +43,10 @@ ProcessGroupHCCL::ProcessGroupHCCL(int global_rank,
4943
: ProcessGroup(device) {
5044
c10::intrusive_ptr<c10d_npu::ProcessGroupHCCL::Options> hccl_pg_options =
5145
c10d_npu::ProcessGroupHCCL::Options::create();
52-
// hccl_pg_options->group_name = group_name;
46+
#if TORCH_VERSION_MAJOR > 2 || \
47+
(TORCH_VERSION_MAJOR == 2 && TORCH_VERSION_MINOR >= 7)
48+
hccl_pg_options->group_name = group_name;
49+
#endif
5350
int rank = global_rank;
5451
if (world_size != rank_size) {
5552
auto [local_rank, group_ranks] =

xllm/core/layers/common/tests/tests_utils.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ class MockBackend : public c10d::Backend {
125125

126126
int64_t getSize() const { return world_size_; }
127127

128-
#if TORCH_VERSION_MAJOR >= 2 && TORCH_VERSION_MINOR >= 7
128+
#if TORCH_VERSION_MAJOR > 2 || \
129+
(TORCH_VERSION_MAJOR == 2 && TORCH_VERSION_MINOR >= 7)
129130
void shutdown() override {
130131
// Mock implementation - do nothing
131132
}

0 commit comments

Comments
 (0)