Skip to content

Commit e093335

Browse files
authored
Merge branch 'main' into tle_raw_cuda_ipc_allreduce
2 parents 9b6b875 + 595997e commit e093335

24 files changed

Lines changed: 2202 additions & 424 deletions

File tree

.github/workflows/sunrise3.6-build-and-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ jobs:
7171
export TRITON_OFFLINE_BUILD=1
7272
export TRITON_BUILD_PROTON=OFF
7373
export FLAGTREE_BACKEND=sunrise
74-
MAX_JOBS=32 python3 -m pip install . --no-build-isolation -v
74+
MAX_JOBS=32 python3 -m pip install . -v
7575
7676
- name: Clear cache if ClearCache label present
7777
if: steps.check_backend.outputs.should_skip != 'true'

python/setup_tools/utils/sunrise.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ def configure_llvm(path):
3333
cache.store(
3434
file="sunrise_llvm22_dev_release",
3535
condition=is_sunrise,
36-
url="https://baai-cp-web.ks3-cn-beijing.ksyuncs.com/trans/llvm-1fdc1dfa-triton-v3.6.x.tar.gz",
36+
url="https://baai-cp-web.ks3-cn-beijing.ksyuncs.com/trans/llvm-9027ac27-triton-v3.6.x.tar.gz",
3737
pre_hook=lambda: check_env("LLVM_SYSPATH"),
3838
post_hook=configure_llvm,
3939
)
4040
cache.store(
4141
file="sunriseTritonPlugin.so",
4242
condition=is_sunrise and not os.environ.get("FLAGTREE_PLUGIN"),
43-
url="https://baai-cp-web.ks3-cn-beijing.ksyuncs.com/trans/sunriseTritonPlugin_v0.6.0.tar.gz",
44-
md5_digest="f3c65d44",
43+
url="https://baai-cp-web.ks3-cn-beijing.ksyuncs.com/trans/sunriseTritonPlugin_v0.6.0.4.tar.gz",
44+
md5_digest="4c77b8c0",
4545
)
4646

4747

python/test/tle/unit/test_tle_cumsum.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ def _is_hcu_backend():
2727
threads_per_warp = get_current_target().warp_size if is_hip() else 32
2828

2929

30-
def _is_amd_hip_backend():
31-
return is_hip() and not FLAGTREE_BACKEND
32-
33-
3430
def _require_cuda():
3531
try:
3632
if _is_enflame_backend():
@@ -280,7 +276,6 @@ def test_tle_cumsum_amdgcn_fastpath_regression_guard():
280276
"Detected predicated ds_write: possible regression to generic path"
281277

282278

283-
@pytest.mark.skipif(_is_amd_hip_backend(), reason="requires AMD local-pointer lowering")
284279
def test_tle_cumsum_helper_preserves_adjacent_sentinel():
285280
block = 512
286281
num_warps = block // threads_per_warp
@@ -302,7 +297,6 @@ def test_tle_cumsum_helper_preserves_adjacent_sentinel():
302297
torch.testing.assert_close(sentinel, expected_sentinel)
303298

304299

305-
@pytest.mark.skipif(_is_amd_hip_backend(), reason="requires AMD local-pointer lowering")
306300
def test_tle_cumsum_scalar_base_addptr_alias_regression():
307301
block = 512
308302
num_warps = block // threads_per_warp

python/triton/experimental/tle/raw/cuda/runtime.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ def __init__(self, fn: Any, file: Path, *args, **kwargs) -> None:
234234
self.lowered_region_dialect: Final[str] = "llvm"
235235
self.arg_dialect: Final[str] = "llvm"
236236
self.source_file: Final[str] = str(file)
237+
self.opt_level: Final[str] = kwargs.get("opt_level", "-O3")
237238

238239
if self.library == "nvshmem":
239240
from triton.experimental.tle.raw.nvshmem.utils import enable_nvshmem_device_bc
@@ -259,7 +260,7 @@ def register_pending_source(self, *, hint: str = "") -> str:
259260
extern_func_name=self.extern_func_name,
260261
source=self.code,
261262
hint=hint,
262-
extra={"source_file": self.source_file},
263+
extra={"source_file": self.source_file, "opt_level": self.opt_level},
263264
)
264265

265266
def create_region_by_llvm(self, builder, llvm: str, handles, alias_indices, hint: str = "",
@@ -285,7 +286,7 @@ def make_llvm(self, mlir_context) -> str:
285286
"--cuda-device-only",
286287
_get_cuda_gpu_arch(),
287288
"-emit-llvm",
288-
"-O2",
289+
self.opt_level,
289290
"-S",
290291
"-",
291292
"-o",
@@ -314,5 +315,6 @@ def read_text(self):
314315
file=_CudaSourceFile(),
315316
extern_func_name=entry.get("extern_func_name"),
316317
deferred=True,
318+
opt_level=entry.get("opt_level"),
317319
)
318320
return cuda_fn.make_llvm(context)

python/triton/experimental/tle/raw/nvshmem/utils.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,18 @@ def set_signal_cuda_ptr(signal_ptr, signal, stream):
348348
CUDA_CHECK(err)
349349

350350

351+
def copy_on_stream(dst_ptr, src_ptr, nbytes, stream):
352+
_, cudart = _get_cuda_modules()
353+
(err, ) = cudart.cudaMemcpyAsync(
354+
dst_ptr,
355+
src_ptr,
356+
nbytes,
357+
cudart.cudaMemcpyKind.cudaMemcpyDefault,
358+
stream.cuda_stream,
359+
)
360+
CUDA_CHECK(err)
361+
362+
351363
def print_perf(
352364
name: str,
353365
value: float,

python/tutorials/tle/raw/nvshmem/02-allgather-gemm/ag-gemm-device.cu

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
#include <cuda_fp16.h>
21
#include <stddef.h>
32
#include <stdint.h>
43

54
extern "C" __device__ uint64_t nvshmem_signal_wait_until(uint64_t *sig_addr,
65
int cmp,
76
uint64_t cmp_value);
7+
extern "C" __device__ void
8+
nvshmemx_putmem_signal_block(void *dest, const void *source, size_t bytes,
9+
uint64_t *sig_addr, uint64_t signal, int sig_op,
10+
int pe);
811

912
enum {
1013
NVSHMEM_CMP_GE = 5,
@@ -16,7 +19,7 @@ ag_mark_local_ready(__attribute__((address_space(1))) uint64_t *ready,
1619
int rank) {
1720
if (threadIdx.x == 0) {
1821
__threadfence_system();
19-
ready[(size_t)rank] = 1;
22+
ready[rank] = 1;
2023
}
2124
__syncthreads();
2225
}
@@ -29,3 +32,13 @@ ag_wait_ready(__attribute__((address_space(1))) uint64_t *ready,
2932
}
3033
__syncthreads();
3134
}
35+
36+
extern "C" __device__ __attribute__((always_inline)) void
37+
ag_putmem_signal_block(__attribute__((address_space(1))) void *dest,
38+
__attribute__((address_space(1))) const void *source,
39+
size_t bytes,
40+
__attribute__((address_space(1))) uint64_t *sig_addr,
41+
uint64_t signal, int peer) {
42+
nvshmemx_putmem_signal_block(dest, source, bytes, sig_addr, signal,
43+
NVSHMEM_SIGNAL_SET, peer);
44+
}

python/tutorials/tle/raw/nvshmem/02-allgather-gemm/ag-gemm-host.cu

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
#include <cuda_fp16.h>
21
#include <cuda_runtime.h>
32
#include <nvshmem.h>
43
#include <nvshmemx.h>
54
#include <stdint.h>
65
#include <stdio.h>
7-
#include <stdlib.h>
86

97
#define CUDA_CHECK(stmt) \
108
do { \
@@ -16,10 +14,12 @@
1614
} \
1715
} while (0)
1816

19-
extern "C" int ag_gemm_workspace_create(int elements_per_rank, void **workspace,
20-
uint64_t **ready, int *mype, int *npes,
21-
int *mype_in_node, int *npes_in_node) {
22-
if (elements_per_rank <= 0 || workspace == nullptr || ready == nullptr) {
17+
extern "C" int ag_gemm_workspace_create(int elements_per_rank, int element_size,
18+
void **workspace, uint64_t **ready,
19+
int *mype, int *npes, int *mype_in_node,
20+
int *npes_in_node) {
21+
if (elements_per_rank <= 0 || element_size <= 0 || workspace == nullptr ||
22+
ready == nullptr) {
2323
return -1;
2424
}
2525

@@ -29,7 +29,7 @@ extern "C" int ag_gemm_workspace_create(int elements_per_rank, void **workspace,
2929
*npes_in_node = nvshmem_team_n_pes(NVSHMEMX_TEAM_NODE);
3030
CUDA_CHECK(cudaSetDevice(*mype_in_node));
3131

32-
size_t workspace_bytes = (size_t)(*npes) * elements_per_rank * sizeof(__half);
32+
size_t workspace_bytes = (size_t)(*npes) * elements_per_rank * element_size;
3333
*workspace = nvshmem_malloc(workspace_bytes);
3434
*ready = (uint64_t *)nvshmem_calloc((size_t)(*npes), sizeof(uint64_t));
3535
if (*workspace == nullptr || *ready == nullptr) {
@@ -61,3 +61,13 @@ extern "C" void *ag_gemm_peer_workspace_ptr(void *workspace, int peer) {
6161
extern "C" uint64_t *ag_gemm_peer_ready_ptr(uint64_t *ready, int peer) {
6262
return (uint64_t *)nvshmem_ptr(ready, peer);
6363
}
64+
65+
extern "C" void ag_gemm_barrier_all_on_stream(cudaStream_t stream) {
66+
nvshmemx_barrier_all_on_stream(stream);
67+
}
68+
69+
extern "C" void ag_gemm_signal_wait_until_on_stream(uint64_t *signal,
70+
uint64_t value,
71+
cudaStream_t stream) {
72+
nvshmemx_signal_wait_until_on_stream(signal, NVSHMEM_CMP_GE, value, stream);
73+
}

0 commit comments

Comments
 (0)