From 1f7f6d381cc82abf45ea5c8d1dbeb995d249e4fc Mon Sep 17 00:00:00 2001 From: Berk Geveci Date: Sat, 5 Dec 2026 15:08:18 -0500 Subject: [PATCH] TA-48 stays: sub-groups of 16 do not avoid IGC's component-select miscompile (#375) Checked on headroom (IGC 2.7.11): with every kernel at sub-groups of 16 and the i32 cast off, test_runtime_component_from_a_conditional_in_a_loop fails on Level Zero as TA-48 did (odd selectors take the last component, even the first). The workaround's row and _narrow_selector's docstring say so. --- docs/design/vendor-workarounds.md | 2 +- packages/tack-core/src/tack/lang/lowering/vectors.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/design/vendor-workarounds.md b/docs/design/vendor-workarounds.md index 36a2d5916..b23f0c23b 100644 --- a/docs/design/vendor-workarounds.md +++ b/docs/design/vendor-workarounds.md @@ -72,7 +72,7 @@ and goes when 7.x support does. | Each queued launch, fill and copy is followed by a barrier on an asynchronous immediate list, rather than using an in-order list. | Driver 25.05 | In-order lists (`ZE_COMMAND_QUEUE_FLAG_IN_ORDER`) cost about 100 µs of device time per kernel; a barrier costs about 5. | `level_zero_backend._ordered` | `test_level_zero_async.py` | | Copies to the device up to 16 MiB and from it up to 64 KiB go through pooled USM host memory (`_HostStaging`). | Driver 25.05 | Appending a copy from pageable memory did not return until the queue drained (to the device up to 4 MiB, from it up to 1 KiB), so a launch's scalar upload waited for every kernel before it. | `level_zero_backend.py` | `test_level_zero_async.py` | | `f64` `floor` and `ceil` are wrapped as `copysign(floor(x), x)`. | Max 1100, intel-opencl-icd 25.05.32567.17 | The double overloads returned `+0.0` for `ceil(-0.1)` and `floor(-0.0)`, where IEEE 754 requires `-0.0`; the f32 overloads are correct. Exact for every input, since neither function changes its operand's sign. | `OpenCLCodeGen._expr_call` | `test_float_semantics.py` on Level Zero | -| A runtime vector or matrix component index is compared as an i32: the selector is cast once where it is captured. | IGC 2.7.11 (compute runtime 25.05, Max 1100) | A chain of 64-bit equality tests on a selector that a conditional expression defined (`rows[f][j + 1 if j + 1 < size else 0]` in a sequential loop) selected the first component for an even selector and the last for an odd one, so the polyhedra face kernels read a triangle's padded -1 under debug mode's bounds checks (TA-48). `-ze-opt-disable` avoided it, as did a 32-bit selector, a `switch` or plain index arithmetic; the generated OpenCL C is correct and the CPU agrees. | `lowering/vectors.py` (`_narrow_selector`) | `test_new_features.py` (`test_runtime_component_from_a_conditional_in_a_loop`) on Level Zero | +| A runtime vector or matrix component index is compared as an i32: the selector is cast once where it is captured. | IGC 2.7.11 (compute runtime 25.05, Max 1100) | A chain of 64-bit equality tests on a selector that a conditional expression defined (`rows[f][j + 1 if j + 1 < size else 0]` in a sequential loop) selected the first component for an even selector and the last for an odd one, so the polyhedra face kernels read a triangle's padded -1 under debug mode's bounds checks (TA-48). `-ze-opt-disable` avoided it, as did a 32-bit selector, a `switch` or plain index arithmetic; the generated OpenCL C is correct and the CPU agrees. Not the SIMD32 bug below: with every kernel at sub-groups of 16 and the cast off, the test still fails the same way (#375, checked 2026-12-05 on IGC 2.7.11). | `lowering/vectors.py` (`_narrow_selector`) | `test_new_features.py` (`test_runtime_component_from_a_conditional_in_a_loop`) on Level Zero | | Every kernel requires sub-groups of 16 (`intel_reqd_sub_group_size(16)`), so none is compiled SIMD32. | IGC 2.7.11 (compute runtime 25.05.32567.17, Max 1100) | Five tack-dataset kernels computed wrong crossings, lattice points and AMR ghost marks; see below. | `opencl_gen.py` (`OCL_SUB_GROUP_SIZE`) | `test_opencl_gen.py` (`test_every_kernel_requires_sub_groups_of_16`); on Level Zero, with `--ids=i32` and `--ids=i64`, `test_high_order.py` (`test_everything_in_f32_on_every_backend`), `test_simplex_order.py` (contours and slices) and `test_bernstein.py` (`test_pieces_share_their_coefficients_to_the_bit`), and `vis2_amr` | | A stored native binary the driver refuses is rebuilt from the stored SPIR-V. | Drivers that refuse another build's native binary | The disk cache entry would be unusable. Counted as `native_refused` in the cache stats. | `level_zero_backend.load_variant` | `test_disk_cache.py` (`test_a_refused_native_binary_falls_back_to_spirv`) | diff --git a/packages/tack-core/src/tack/lang/lowering/vectors.py b/packages/tack-core/src/tack/lang/lowering/vectors.py index 960b3c717..d73a71a4c 100644 --- a/packages/tack-core/src/tack/lang/lowering/vectors.py +++ b/packages/tack-core/src/tack/lang/lowering/vectors.py @@ -606,7 +606,8 @@ def _narrow_selector(selector): (``rows[f][j + 1 if j + 1 < size else 0]`` in a sequential loop): the first component for an even selector, the last for an odd one (TA-48, ``docs/design/vendor-workarounds.md``). Compared as an i32 - the chain compiles right. + the chain compiles right. Requiring sub-groups of 16, which fixed + IGC's SIMD32 miscompiles, does not fix this one (#375). """ return ir.IRCast(value=selector, dtype=i32)