Skip to content

Commit c536a06

Browse files
authored
refactor: move NPULayerSynchronizerImpl to platform dir. (jd-opensource#237)
1 parent 0b6544e commit c536a06

File tree

14 files changed

+32
-19
lines changed

14 files changed

+32
-19
lines changed

xllm/core/common/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ cc_library(
88
etcd_client.h
99
global_flags.h
1010
instance_name.h
11-
layer_synchronizer.h
1211
macros.h
1312
metrics.h
1413
$<$<BOOL:${USE_NPU}>:mspti_helper.h>
@@ -19,7 +18,6 @@ cc_library(
1918
SRCS
2019
etcd_client.cpp
2120
global_flags.cpp
22-
layer_synchronizer.cpp
2321
metrics.cpp
2422
$<$<BOOL:${USE_NPU}>:mspti_helper.cpp>
2523
options.cpp

xllm/core/distributed_runtime/worker_service.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ void WorkerService::ExecuteModel(
388388
top_logprobs =
389389
safe_to(sample_output.top_logprobs, torch::kCPU, true);
390390
}
391-
auto ret = stream_->synchronize_stream();
391+
auto ret = stream_->synchronize();
392392
}
393393
}
394394
} else {
@@ -460,7 +460,7 @@ void WorkerService::GetLastStepResult(
460460
// [num_seq, topk]
461461
const auto& top_logprobs =
462462
safe_to(sample_output.top_logprobs, torch::kCPU, true);
463-
auto ret = stream_->synchronize_stream();
463+
auto ret = stream_->synchronize();
464464

465465
forward_output_to_proto(next_tokens,
466466
logprobs,

xllm/core/framework/eplb/eplb_executor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ void EplbExecutor::eplb_worker_loop() {
9494

9595
c10::StreamGuard streamGuard = stream_->set_stream_guard();
9696
model_->prepare_expert_weight(task.layer_id, task.expert_ids);
97-
auto ret = stream_->synchronize_stream();
97+
auto ret = stream_->synchronize();
9898
auto prepare_end = std::chrono::high_resolution_clock::now();
9999
auto prepare_duration =
100100
std::chrono::duration_cast<std::chrono::milliseconds>(prepare_end -

xllm/core/framework/kv_cache/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,5 @@ cc_library(
3232
$<$<BOOL:${USE_NPU}>:torch_npu>
3333
mooncake_store
3434
:xtensor
35+
$<$<BOOL:${USE_NPU}>:platform_npu>
3536
)

xllm/core/framework/kv_cache/kv_cache_transfer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ limitations under the License.
1717

1818
#include <folly/futures/Future.h>
1919

20-
#include "common/layer_synchronizer.h"
2120
#include "common/types.h"
2221
#include "core/framework/parallel_state.h"
2322
#include "kv_cache.h"
23+
#include "platform/npu/npu_layer_synchronizer.h"
2424
#include "util/threadpool.h"
2525

2626
namespace xllm {

xllm/core/framework/model/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ if(USE_NPU)
1818
# Modify dependencies for npu
1919
list(APPEND BASE_DEPS torch_npu)
2020
list(APPEND BASE_DEPS :npu_layers)
21+
list(APPEND BASE_DEPS :platform_npu)
2122
endif()
2223

2324
# Define the library

xllm/core/framework/model/model_input_params.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ limitations under the License.
1919
#include <torch/torch.h>
2020

2121
#if defined(USE_NPU)
22-
#include "common/layer_synchronizer.h"
22+
#include "platform/npu/npu_layer_synchronizer.h"
2323
#endif
2424
#include "framework/request/mm_data.h"
2525
#include "npu_dp_ep_padding.h"

xllm/core/platform/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,8 @@ cc_library(
1313
torch
1414
$<$<BOOL:${USE_NPU}>:torch_npu>
1515
$<$<BOOL:${USE_NPU}>:ascendcl>
16-
)
16+
)
17+
18+
if(USE_NPU)
19+
add_subdirectory(npu)
20+
endif()
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
include(cc_library)
2+
3+
cc_library(
4+
NAME
5+
platform_npu
6+
HDRS
7+
npu_layer_synchronizer.h
8+
SRCS
9+
npu_layer_synchronizer.cpp
10+
DEPS
11+
torch_npu
12+
glog::glog
13+
torch
14+
ascendcl
15+
)

xllm/core/common/layer_synchronizer.cpp renamed to xllm/core/platform/npu/npu_layer_synchronizer.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,12 @@ See the License for the specific language governing permissions and
1313
limitations under the License.
1414
==============================================================================*/
1515

16-
#include "common/layer_synchronizer.h"
16+
#include "npu_layer_synchronizer.h"
1717

1818
#include <glog/logging.h>
1919

2020
namespace xllm {
2121

22-
#if defined(USE_NPU)
2322
NPULayerSynchronizerImpl::NPULayerSynchronizerImpl(const int64_t num_layers)
2423
: events_(num_layers, nullptr), event_record_flags_(num_layers) {
2524
uint32_t flags = ACL_EVENT_SYNC;
@@ -53,6 +52,5 @@ bool NPULayerSynchronizerImpl::synchronize_layer(const int64_t layer_index) {
5352
}
5453
return true;
5554
}
56-
#endif
5755

5856
} // namespace xllm

0 commit comments

Comments
 (0)