-
Notifications
You must be signed in to change notification settings - Fork 75
Labels
Milestone
Description
Describe the bug
test_line_info.py::test_line_info_ir_source[ttir] fails on consecutive runs due to cached compiled IR code containing old references to temporary files from previous test runs.
@pytest.mark.parametrize("status", ["ttir", ""])
def test_line_info_ir_source(monkeypatch, status, tmp_path):
try:
obj_kind, command, anchor, separator = get_disassembler_command_and_debug_line_format()
except BaseException:
pytest.skip("disassembler is not available")
src = """
#loc = loc("/path/test.py":7:0)
module {
tt.func public @test(%arg0: !tt.ptr<f32> {tt.divisibility = 16 : i32} loc("/path/test.py":7:0), %arg1: !tt.ptr<f32> {tt.divisibility = 16 : i32} loc("/path/test.py":7:0)) attributes {noinline = false} {
%0 = tt.load %arg0 : !tt.ptr<f32> loc(#loc1)
tt.store %arg1, %0 : !tt.ptr<f32> loc(#loc2)
tt.return loc(#loc3)
} loc(#loc)
} loc(#loc)
#loc1 = loc("/path/test.py":8:16)
#loc2 = loc("/path/test.py":9:20)
#loc3 = loc("/path/test.py":9:4)
"""
monkeypatch.setenv("USE_IR_LOC", status)
temp_file = tmp_path / "test.ttir"
temp_file.write_text(src)
kernel_info = triton.compile(str(temp_file))
if obj_kind == "spvbin":
file_lines = spv_extract_file_lines(kernel_info.asm["spv"], command)
else:
file_lines = extract_file_lines(command, anchor, separator, kernel_info.asm[obj_kind])
if status == "ttir":
assert check_file_lines(file_lines, "/path/test.py", 8, should_contain=False)
import os
if os.name != "nt":
path = str(temp_file)
else:
# FIXME: use `str(temp_file)` instead of `temp_file.name`
# when https://github.com/KhronosGroup/SPIRV-LLVM-Translator/issues/3126 is fixed.
path = temp_file.name
> assert check_file_lines(file_lines, path, -1, should_contain=True)
E assert False
E + where False = check_file_lines([('"/tmp/pytest-of-jovyan/pytest-71/test_line_info_ir_source_ttir_0/test.ttir"', '5'), ('"/tmp/pytest-of-jovyan/pytest-71/test_line_info_ir_source_ttir_0/test.ttir"', '4'), ('"/tmp/pytest-of-jovyan/pytest-71/test_line_info_ir_source_ttir_0/test.ttir"', '5'), ('"/tmp/pytest-of-jovyan/pytest-71/test_line_info_ir_source_ttir_0/test.ttir"', '6')], '/tmp/pytest-of-jovyan/pytest-85/test_line_info_ir_source_ttir_0/test.ttir', -1, should_contain=True)
language/test_line_info.py:308: AssertionError
Purging Triton cache makes the issue go away.
Fixing this might require forcefully disabling cache for the duration of the test or somehow invalidating it otherwise,.
Environment details
Triton: 462a07e