Skip to content

Commit bfded34

Browse files
authored
Compatible with older versions of Python and Torch (#469)
* Compatible with older versions of python and torch * Format
1 parent 2be0d4f commit bfded34

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

‎csrc/deep_ep.cpp‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1765,5 +1765,6 @@ PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) {
17651765
.def("get_next_low_latency_combine_buffer", &deep_ep::Buffer::get_next_low_latency_combine_buffer);
17661766

17671767
m.def("is_sm90_compiled", deep_ep::is_sm90_compiled);
1768-
m.attr("topk_idx_t") = py::cast(c10::CppTypeToScalarType<deep_ep::topk_idx_t>::value);
1768+
m.attr("topk_idx_t") =
1769+
py::reinterpret_borrow<py::object>((PyObject*)torch::getTHPDtype(c10::CppTypeToScalarType<deep_ep::topk_idx_t>::value));
17691770
}

‎tests/test_low_latency.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
import torch
44
import torch.distributed as dist
55
from functools import partial
6-
from typing import Literal
6+
from typing import Literal, Set
77

88
import deep_ep
99
from utils import init_dist, bench, bench_kineto, calc_diff, hash_tensor, per_token_cast_back
1010

1111

12-
def simulate_failure_and_skip(rank: int, api: Literal["dispatch", "combine", "clean"], expected_masked_ranks: set[int]):
12+
def simulate_failure_and_skip(rank: int, api: Literal["dispatch", "combine", "clean"], expected_masked_ranks: Set[int]):
1313
# Simulates rank failure when the rank first calls the corresponding communication API
1414
failed_api_ranks = {
1515
# API -> rank to fail (rank fails when it first calls the corresponding communication API)
@@ -29,7 +29,7 @@ def simulate_failure_and_skip(rank: int, api: Literal["dispatch", "combine", "cl
2929

3030

3131
def query_mask_buffer_and_check(api: Literal["dispatch", "combine", "clean"], buffer: deep_ep.Buffer, mask_status: torch.Tensor,
32-
expected_masked_ranks: set[int]):
32+
expected_masked_ranks: Set[int]):
3333
buffer.low_latency_query_mask_buffer(mask_status)
3434
assert set(mask_status.nonzero().squeeze(-1).tolist()) == expected_masked_ranks
3535

0 commit comments

Comments
 (0)