Skip to content
Merged
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
5 changes: 3 additions & 2 deletions csrc/engine/infer_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,10 @@ InferEngine::InferEngine(
&& device_type != infinicore::Device::Type::kMoore
&& device_type != infinicore::Device::Type::kCambricon
&& device_type != infinicore::Device::Type::kIluvatar
&& device_type != infinicore::Device::Type::kHygon) {
&& device_type != infinicore::Device::Type::kHygon
&& device_type != infinicore::Device::Type::kAscend) {
throw std::invalid_argument(
"flash-attn is only available on NVIDIA, MetaX, Moore, Cambricon, Iluvatar, and Hygon devices");
"flash-attn is only available on NVIDIA, MetaX, Moore, Cambricon, Iluvatar, Hygon, and Ascend devices");
}
const auto *paged_cache_config = dynamic_cast<const cache::PagedKVCacheConfig *>(cache_config);
if (paged_cache_config == nullptr) {
Expand Down
9 changes: 7 additions & 2 deletions csrc/infinicore/src/ops/mha_kvcache/mha_kvcache_infiniops.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ using TensorMeta = ::infinicore::op::infiniops::TensorMeta;
// InfiniOps provides device-aware default selection for these operators.
std::size_t implementation_index_for_device(
infini::ops::Device::Type device_type) {
if (device_type == infini::ops::Device::Type::kIluvatar) {
if (device_type == infini::ops::Device::Type::kIluvatar
|| device_type == infini::ops::Device::Type::kAscend) {
return 0;
}
if (device_type == infini::ops::Device::Type::kMoore) {
Expand All @@ -41,7 +42,8 @@ bool is_supported(const Tensor &out,
&& device_type != Device::Type::kMoore
&& device_type != Device::Type::kCambricon
&& device_type != Device::Type::kIluvatar
&& device_type != Device::Type::kHygon)
&& device_type != Device::Type::kHygon
&& device_type != Device::Type::kAscend)
|| q->ndim() != 4
|| out->ndim() != 4
|| k_cache->ndim() != 4
Expand Down Expand Up @@ -214,6 +216,9 @@ static bool registered = []() {
MhaKVCache::plan_dispatcher().registerDevice(Device::Type::kHygon, &plan);
MhaKVCache::run_dispatcher().registerDevice(Device::Type::kHygon, &run);
MhaKVCache::cleanup_dispatcher().registerDevice(Device::Type::kHygon, &cleanup);
MhaKVCache::plan_dispatcher().registerDevice(Device::Type::kAscend, &plan);
MhaKVCache::run_dispatcher().registerDevice(Device::Type::kAscend, &run);
MhaKVCache::cleanup_dispatcher().registerDevice(Device::Type::kAscend, &cleanup);
return true;
}();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ using TensorMeta = ::infinicore::op::infiniops::TensorMeta;
// InfiniOps provides device-aware default selection for these operators.
std::size_t implementation_index_for_device(
infini::ops::Device::Type device_type) {
if (device_type == infini::ops::Device::Type::kIluvatar) {
if (device_type == infini::ops::Device::Type::kIluvatar
|| device_type == infini::ops::Device::Type::kAscend) {
return 0;
}
if (device_type == infini::ops::Device::Type::kMoore) {
Expand All @@ -45,7 +46,8 @@ bool is_supported(const Tensor &out,
&& device_type != Device::Type::kMoore
&& device_type != Device::Type::kCambricon
&& device_type != Device::Type::kIluvatar
&& device_type != Device::Type::kHygon)
&& device_type != Device::Type::kHygon
&& device_type != Device::Type::kAscend)
|| q->ndim() != 3
|| out->ndim() != 3
|| ((paged && (k->ndim() != 4 || v->ndim() != 4))
Expand Down Expand Up @@ -258,6 +260,12 @@ static bool registered = []() {
Device::Type::kHygon, &run);
MultiheadAttentionVarlen::cleanup_dispatcher().registerDevice(
Device::Type::kHygon, &cleanup);
MultiheadAttentionVarlen::plan_dispatcher().registerDevice(
Device::Type::kAscend, &plan);
MultiheadAttentionVarlen::run_dispatcher().registerDevice(
Device::Type::kAscend, &run);
MultiheadAttentionVarlen::cleanup_dispatcher().registerDevice(
Device::Type::kAscend, &cleanup);
return true;
}();

Expand Down
5 changes: 3 additions & 2 deletions test/static/test_infinicore_runtime_contracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ def test_exact_infiniops_adapter_set_is_registered(self) -> None:
"gelu/gelu_infiniops.cc": 1,
"gelutanh/gelutanh_infiniops.cc": 1,
"gemm/gemm_infiniops.cc": 3,
"mha_kvcache/mha_kvcache_infiniops.cc": 18,
"mha_kvcache/mha_kvcache_infiniops.cc": 21,
"mul/mul_infiniops.cc": 3,
"multi_head_attention_varlen/mha_varlen_infiniops.cc": 18,
"multi_head_attention_varlen/mha_varlen_infiniops.cc": 21,
"ones/ones_infiniops.cc": 3,
"paged_caching/paged_caching_infiniops.cc": 3,
"random_sample/random_sample_infiniops.cc": 1,
Expand Down Expand Up @@ -324,6 +324,7 @@ def test_unavailable_configurable_surfaces_are_rejected(self) -> None:
self.assertIn(
"device_type != infinicore::Device::Type::kCambricon", infer_engine
)
self.assertIn("device_type != infinicore::Device::Type::kAscend", infer_engine)
self.assertIn("paged_cache_config->num_blocks() == 0", infer_engine)
self.assertIn("paged_cache_config->block_size() == 0", infer_engine)
self.assertIn("paged_cache_config->block_size() % 256 != 0", infer_engine)
Expand Down
11 changes: 10 additions & 1 deletion test/static/test_modern_infinicore_compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ def test_current_infiniops_backend_bridges_are_registered(self) -> None:
"kCambricon",
"kIluvatar",
"kHygon",
"kAscend",
):
with self.subTest(adapter=relative_path, device=device):
self.assertIn(f"device_type != Device::Type::{device}", attention)
Expand All @@ -219,6 +220,10 @@ def test_current_infiniops_backend_bridges_are_registered(self) -> None:
)
self.assertIn("configForImplementation<", attention)
self.assertIn("implementation_index_for_device(device_type)", attention)
self.assertIn(
"device_type == infini::ops::Device::Type::kAscend",
attention,
)
self.assertIn("device_type == Device::Type::kMoore", attention)
self.assertIn("device_type == Device::Type::kIluvatar", attention)
self.assertIn("return 0;", attention)
Expand Down Expand Up @@ -258,7 +263,11 @@ def test_current_infiniops_backend_bridges_are_registered(self) -> None:
engine,
)
self.assertIn(
"flash-attn is only available on NVIDIA, MetaX, Moore, Cambricon, Iluvatar, and Hygon devices",
"device_type != infinicore::Device::Type::kAscend",
engine,
)
self.assertIn(
"flash-attn is only available on NVIDIA, MetaX, Moore, Cambricon, Iluvatar, Hygon, and Ascend devices",
engine,
)
self.assertIn(
Expand Down
Loading