Skip to content

Commit d5ee4fc

Browse files
Merge OpenAI Triton commit cf0db92 (#4902)
This PR change the Triton base from b3b9931 to cf0db92 (Jul 29). Pass rate: 98.83%
2 parents 563c2c1 + 0710c39 commit d5ee4fc

File tree

20 files changed

+801
-177
lines changed

20 files changed

+801
-177
lines changed

.github/workflows/integration-tests-amd.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,9 @@ jobs:
141141
cd ../../triton_kernels/
142142
python3 -m pytest -s -n 12 tests/
143143
fi
144-
144+
- name: Run distributed tests
145+
run: |
146+
make test-distributed
145147
- name: Run asan tests on AMD
146148
if: false
147149
run: |

.github/workflows/integration-tests-nvidia.yml

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,16 @@ jobs:
7070
- name: Update PATH
7171
run: |
7272
echo "$HOME/.local/bin" >> $GITHUB_PATH
73+
- name: Setup Python environment for GB200
74+
if: ${{ matrix.runner[0] == 'nvidia-gb200' }}
75+
run: |
76+
echo "/venv/bin" >> $GITHUB_PATH
77+
echo "VIRTUAL_ENV=/venv" >> $GITHUB_ENV
78+
echo "PYTHONHOME=" >> $GITHUB_ENV
7379
- name: Install Triton
7480
env:
7581
CUDA_HOME: "/usr/local/cuda"
7682
run: |
77-
if [ "${{ matrix.runner[0] }}" == "nvidia-gb200" ]; then
78-
source /venv/bin/activate
79-
fi
8083
nproc
8184
nvidia-smi
8285
echo "PATH is '$PATH'"
@@ -87,20 +90,14 @@ jobs:
8790
- name: Run lit tests
8891
run: make test-lit
8992
- name: Run python tests on CUDA
90-
run: |
91-
if [ "${{ matrix.runner[0] }}" == "nvidia-gb200" ]; then
92-
source /venv/bin/activate
93-
fi
94-
make NUM_PROCS=24 test-unit
93+
run: make NUM_PROCS=24 test-unit
94+
- name: Run distributed tests
95+
run: make test-distributed
9596
- name: Run interpreter tests
9697
if: ${{ matrix.runner[0] == 'nvidia-h100' }}
9798
run: make test-interpret
9899
- name: Run regression tests
99-
run: |
100-
if [ "${{ matrix.runner[0] }}" == "nvidia-gb200" ]; then
101-
source /venv/bin/activate
102-
fi
103-
make test-regression
100+
run: make test-regression
104101
- name: Run C++ unittests
105102
run: make test-cpp
106103
- name: Run Proton tests

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ test-unit: all
4444
$(PYTEST) --capture=tee-sys -rfs -vvv python/test/unit/instrumentation/test_gpuhello.py
4545
$(PYTEST) -s -n $(NUM_PROCS) python/test/gluon
4646

47+
.PHONY: test-distributed
48+
test-distributed: all
49+
$(PYTHON) -m pip install --upgrade pip
50+
$(PYTHON) -m pip install python/triton_kernels -v
51+
$(PYTEST) -s python/triton_kernels/bench/distributed.py
52+
4753
.PHONY: test-gluon
4854
test-gluon: all
4955
$(PYTEST) -s -n $(NUM_PROCS) python/test/gluon

lib/Tools/GenericSwizzling.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#include "triton/Tools/GenericSwizzling.h"
2-
#include "triton/Conversion/TritonGPUToLLVM/TargetInfoBase.h"
32

43
#include "third_party/f2reduce/f2reduce.h"
54
#include "triton/Tools/LayoutUtils.h"

python/test/conftest.py

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import sys
33
import pathlib
44
import pytest
5-
from typing import Optional, Set
65
import contextlib
76

87

@@ -108,49 +107,9 @@ def fresh_cache():
108107
yield fresh_cache
109108

110109

111-
def _fresh_knobs_impl(monkeypatch, skipped_attr: Optional[Set[str]] = None):
112-
from triton import knobs
113-
114-
if skipped_attr is None:
115-
skipped_attr = set()
116-
117-
knobs_map = {
118-
name: knobset
119-
for name, knobset in knobs.__dict__.items()
120-
if isinstance(knobset, knobs.base_knobs) and knobset != knobs.base_knobs and name not in skipped_attr
121-
}
122-
123-
# We store which variables we need to unset below in finally because
124-
# monkeypatch doesn't appear to reset variables that were never set
125-
# before the monkeypatch.delenv call below.
126-
env_to_unset = []
127-
prev_propagate_env = knobs.propagate_env
128-
129-
def fresh_function():
130-
nonlocal env_to_unset
131-
for name, knobset in knobs_map.items():
132-
setattr(knobs, name, knobset.copy().reset())
133-
for knob in knobset.knob_descriptors.values():
134-
if knob.key in os.environ:
135-
monkeypatch.delenv(knob.key, raising=False)
136-
else:
137-
env_to_unset.append(knob.key)
138-
knobs.propagate_env = True
139-
return knobs
140-
141-
def reset_function():
142-
for name, knobset in knobs_map.items():
143-
setattr(knobs, name, knobset)
144-
for k in env_to_unset:
145-
if k in os.environ:
146-
del os.environ[k]
147-
knobs.propagate_env = prev_propagate_env
148-
149-
return fresh_function, reset_function
150-
151-
152110
@pytest.fixture
153111
def fresh_knobs(monkeypatch):
112+
from triton._internal_testing import _fresh_knobs_impl
154113
fresh_function, reset_function = _fresh_knobs_impl(monkeypatch)
155114
try:
156115
yield fresh_function()
@@ -165,6 +124,7 @@ def fresh_knobs_except_libraries(monkeypatch):
165124
information from the environment as these may be
166125
needed to successfully compile kernels.
167126
"""
127+
from triton._internal_testing import _fresh_knobs_impl
168128
fresh_function, reset_function = _fresh_knobs_impl(monkeypatch, skipped_attr={"build", "nvidia", "amd"})
169129
try:
170130
yield fresh_function()

python/triton/_internal_testing.py

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
import triton
66
import triton.language as tl
77
from triton import knobs
8+
from typing import Optional, Set, Union
89
import pytest
910

1011
from numpy.random import RandomState
11-
from typing import Optional, Union
1212
from triton.runtime.jit import TensorWrapper, reinterpret, type_canonicalisation_dict
1313

1414
int_dtypes = ['int8', 'int16', 'int32', 'int64']
@@ -202,3 +202,44 @@ def unwrap_tensor(t: Union[torch.Tensor, triton.runtime.jit.TensorWrapper]) -> t
202202
if isinstance(t, triton.runtime.jit.TensorWrapper):
203203
return t.base
204204
return t
205+
206+
207+
def _fresh_knobs_impl(monkeypatch, skipped_attr: Optional[Set[str]] = None):
208+
from triton import knobs
209+
210+
if skipped_attr is None:
211+
skipped_attr = set()
212+
213+
knobs_map = {
214+
name: knobset
215+
for name, knobset in knobs.__dict__.items()
216+
if isinstance(knobset, knobs.base_knobs) and knobset != knobs.base_knobs and name not in skipped_attr
217+
}
218+
219+
# We store which variables we need to unset below in finally because
220+
# monkeypatch doesn't appear to reset variables that were never set
221+
# before the monkeypatch.delenv call below.
222+
env_to_unset = []
223+
prev_propagate_env = knobs.propagate_env
224+
225+
def fresh_function():
226+
nonlocal env_to_unset
227+
for name, knobset in knobs_map.items():
228+
setattr(knobs, name, knobset.copy().reset())
229+
for knob in knobset.knob_descriptors.values():
230+
if knob.key in os.environ:
231+
monkeypatch.delenv(knob.key, raising=False)
232+
else:
233+
env_to_unset.append(knob.key)
234+
knobs.propagate_env = True
235+
return knobs
236+
237+
def reset_function():
238+
for name, knobset in knobs_map.items():
239+
setattr(knobs, name, knobset)
240+
for k in env_to_unset:
241+
if k in os.environ:
242+
del os.environ[k]
243+
knobs.propagate_env = prev_propagate_env
244+
245+
return fresh_function, reset_function

python/triton/knobs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ def scope(self) -> Generator[None, None, None]:
361361
class BuildImpl(Protocol):
362362

363363
def __call__(self, name: str, src: str, srcdir: str, library_dirs: list[str], include_dirs: list[str],
364-
libraries: list[str], extra_compile_args: list[str], /) -> str:
364+
libraries: list[str], ccflags: list[str], /) -> str:
365365
...
366366

367367

python/triton/language/standard.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,9 +317,9 @@ def _or_combine(x, y):
317317

318318
@core._tensor_member_fn
319319
@jit
320-
@core._add_reduction_docstr("reduce_of")
320+
@core._add_reduction_docstr("reduce_or")
321321
def reduce_or(input, axis, keep_dims=False):
322-
core.static_assert(input.type.scalar.is_int(), "reduce_of only supported for integers")
322+
core.static_assert(input.type.scalar.is_int(), "reduce_or only supported for integers")
323323
return core.reduce(input, axis, _or_combine, keep_dims=keep_dims)
324324

325325

python/triton/runtime/_allocation.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,4 @@ def set_allocator(allocator: Allocator):
2929
The allocator function is called during kernel launch for kernels that
3030
require additional global memory workspace.
3131
"""
32-
global _allocator
3332
_allocator.set(allocator)

python/triton/runtime/_async_compile.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
from __future__ import annotations
22
from typing import Callable, Optional
33
from concurrent.futures import Executor, as_completed, Future
4+
from contextvars import ContextVar
45

5-
active_mode: Optional[AsyncCompileMode] = None
6+
active_mode: ContextVar[Optional[AsyncCompileMode]] = ContextVar("async_compile_active_mode", default=None)
67

78

89
class FutureKernel:
@@ -42,14 +43,13 @@ def submit(self, key, compile_fn, finalize_fn):
4243
return future_kernel
4344

4445
def __enter__(self):
45-
global active_mode
46-
if active_mode is not None:
46+
if active_mode.get() is not None:
4747
raise RuntimeError("Another AsyncCompileMode is already active")
48-
active_mode = self
48+
active_mode.set(self)
49+
return self
4950

5051
def __exit__(self, exc_type, exc_value, traceback):
51-
global active_mode
5252
# Finalize any outstanding compiles
5353
for future in as_completed(self.raw_futures):
5454
self.future_kernels[future._key].result()
55-
active_mode = None
55+
active_mode.set(None)

0 commit comments

Comments
 (0)