Skip to content

Commit 9a27fc6

Browse files
authored
[PROFILER] Move disable_buffer_load_check to config with env var support (#227)
1 parent af906c1 commit 9a27fc6

File tree

3 files changed

+35
-9
lines changed

3 files changed

+35
-9
lines changed

tests/test_profiler.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,8 @@ def test_for_loop_statistics():
7070
# Create profiler in the test function
7171
# Disable block sampling to ensure all blocks are executed
7272
cfg._profiler_enable_block_sampling = False
73-
loop_profiler = Profiler(
74-
disable_buffer_load_check=True, disable_load_mask_percentage_check=True
75-
)
73+
cfg._profiler_disable_buffer_load_check = True
74+
loop_profiler = Profiler(disable_load_mask_percentage_check=True)
7675
traced_kernel = triton_viz.trace(loop_profiler)(for_loop_test_kernel)
7776

7877
# Run the kernel
@@ -179,7 +178,8 @@ def test_mask_percentage():
179178
# Create profiler in the test function
180179
# Disable block sampling to ensure all blocks are executed
181180
cfg._profiler_enable_block_sampling = False
182-
mask_profiler = Profiler(disable_buffer_load_check=True)
181+
cfg._profiler_disable_buffer_load_check = True
182+
mask_profiler = Profiler()
183183
traced_kernel = triton_viz.trace(mask_profiler)(mask_percentage_test_kernel)
184184

185185
# Run the kernel
@@ -305,11 +305,11 @@ def test_block_sampling(test_name, enable_sampling, k_value, expected_executions
305305
# Configure block sampling via config - must be done BEFORE creating Profiler
306306
# Set the private attribute directly to ensure it takes effect
307307
cfg._profiler_enable_block_sampling = enable_sampling
308+
cfg._profiler_disable_buffer_load_check = True
308309

309310
# Create profiler with k value
310311
profiler = Profiler(
311312
k=k_value,
312-
disable_buffer_load_check=True,
313313
disable_load_mask_percentage_check=True,
314314
)
315315

@@ -360,9 +360,10 @@ def test_load_store_skip_disabled():
360360
cfg._profiler_enable_load_store_skipping = False
361361
# Also disable block sampling to ensure all blocks are executed
362362
cfg._profiler_enable_block_sampling = False
363+
cfg._profiler_disable_buffer_load_check = True
363364

364365
# Create profiler and traced kernel
365-
profiler = Profiler(disable_buffer_load_check=True)
366+
profiler = Profiler()
366367
traced_kernel = triton_viz.trace(profiler)(simple_kernel)
367368

368369
# Run kernel
@@ -388,9 +389,10 @@ def test_load_store_skip_enabled():
388389
cfg._profiler_enable_load_store_skipping = True
389390
# Also disable block sampling to ensure all blocks are executed
390391
cfg._profiler_enable_block_sampling = False
392+
cfg._profiler_disable_buffer_load_check = True
391393

392394
# Create profiler and traced kernel
393-
profiler = Profiler(disable_buffer_load_check=True)
395+
profiler = Profiler()
394396
traced_kernel = triton_viz.trace(profiler)(simple_kernel)
395397

396398
# Run kernel

triton_viz/clients/profiler/profiler.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ class Profiler(Client):
4343
def __init__(
4444
self,
4545
callpath: bool = True,
46-
disable_buffer_load_check: bool = False,
4746
disable_for_loop_unroll_check: bool = False,
4847
disable_load_mask_percentage_check: bool = False,
4948
k: int | None = None,
@@ -76,7 +75,7 @@ def __init__(
7675

7776
# Case 4: Buffer Load Check
7877
self.has_buffer_load = False
79-
self.disable_buffer_load_check = disable_buffer_load_check
78+
self.disable_buffer_load_check = cfg.profiler_disable_buffer_load_check
8079
self.potential_buffer_load_issue_found = False
8180

8281
# Block sampling

triton_viz/core/config.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ def reset(self) -> None:
5757
os.getenv("PROFILER_ENABLE_BLOCK_SAMPLING", "1") == "1"
5858
)
5959

60+
# --- Profiler Performance Issues Detection ---
61+
# AMD Buffer Load Check: detects buffer_load instruction usage in kernel ASM
62+
self._profiler_disable_buffer_load_check = (
63+
os.getenv("PROFILER_DISABLE_BUFFER_LOAD_CHECK", "0") == "1"
64+
)
65+
6066
# ---------- disable_sanitizer ----------
6167
@property
6268
def disable_sanitizer(self) -> bool:
@@ -171,5 +177,24 @@ def profiler_enable_block_sampling(self, value: bool) -> None:
171177
def virtual_memory(self) -> bool:
172178
return self._virtual_memory
173179

180+
# ---------- profiler_disable_buffer_load_check ----------
181+
@property
182+
def profiler_disable_buffer_load_check(self) -> bool:
183+
return self._profiler_disable_buffer_load_check
184+
185+
@profiler_disable_buffer_load_check.setter
186+
def profiler_disable_buffer_load_check(self, value: bool) -> None:
187+
if not isinstance(value, bool):
188+
raise TypeError("profiler_disable_buffer_load_check expects a bool.")
189+
190+
previous = getattr(self, "_profiler_disable_buffer_load_check", None)
191+
self._profiler_disable_buffer_load_check = value
192+
193+
# User-friendly status messages
194+
if value and not previous:
195+
print("Profiler buffer load check disabled.")
196+
elif not value and previous:
197+
print("Profiler buffer load check enabled.")
198+
174199

175200
config = Config()

0 commit comments

Comments
 (0)