Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions tests/end_to_end/test_sanitizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1209,6 +1209,29 @@ def test_sanitizer_supports_data_dependent_cumsum_index():
assert len(cumsum_sanitizer.records) == 0


fp8_rounding_sanitizer = SymbolicSanitizer(abort_on_error=False)


@tilelens.trace(client=fp8_rounding_sanitizer)
@triton.jit
def fp8_rtne_cast_kernel(x_ptr, out_ptr, BLOCK: tl.constexpr):
offs = tl.arange(0, BLOCK)
x = tl.load(x_ptr + offs)
y = x.to(tl.float8e5, fp_downcast_rounding="rtne")
tl.store(out_ptr + offs, y.to(tl.float32))


def test_sanitizer_supports_fp_downcast_rounding():
fp8_rounding_sanitizer.records.clear()

x = torch.randn((8,), dtype=torch.float32)
out = torch.empty_like(x)

fp8_rtne_cast_kernel[(1,)](x, out, BLOCK=x.numel())

assert len(fp8_rounding_sanitizer.records) == 0


ashr_index_sanitizer = SymbolicSanitizer(abort_on_error=False)


Expand Down
4 changes: 4 additions & 0 deletions tilelens/clients/symbolic_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -2231,6 +2231,10 @@ def __init__(self, op: str, src: Any, dst_type: Any, rounding_mode: Any):
super().__init__(op)
self.add_child("src", src)
self.add_child("dst_type", dst_type)
# Triton passes an ir.ROUNDING_MODE enum (or None); keep its integer
# value so that the child is an ordinary constant.
if rounding_mode is not None and not isinstance(rounding_mode, SymbolicExpr):
rounding_mode = int(rounding_mode)
self.add_child("rounding_mode", rounding_mode)
self.dtype, self.shape = self._unpack_dtype(
self.dst_type.to_py(), self.src.shape
Expand Down
Loading