determinant tests are too strict for f16
Closed this issue · 2 comments
webgpu:shader,execution,expression,call,builtin,determinant:f16 fails on some GPUs, including:
- Pixel 6 (Mali GPU). Chrome bug crbug.com/42241369
- Pixel 8 Pro (Mali GPU) (use the same bug as pixel 6)
- Intel® UHD Graphics 630 on Vulkan crbug.com/42251218
The existing test computes the determinant using input matrices that are designed to not lose any accuracy bits, by bounding the magnitude of the matrix elements. The analysis was done for f32, and taking the worst case from 4x4 matrices. It bounded the elements by the 4th root of the maximum integer that would fit in 23-ish bits (the number of significand bits); that turns out to be "bound elements by 38". That works for f32. But the analysis doesn't work for f16, where only 10 mantissa bits are represented, and there are 11 bits in the significand for normal numbers.
Redoing the analysis, only 2 bits of precision are allowed per element, roughly speaking, for f16. The failing cases go way beyond that, and we get errors in the last two bits of the result. This is not surprising in retrospect.
Sample failure for Pixel 6
Sample failure:
Traceback (most recent call last):
File "/b/swarming/w/ir/content/test/gpu/gpu_tests/gpu_integration_test.py", line 624, in _RunGpuTest
self.RunActualGpuTest(url, args)
File "/b/swarming/w/ir/content/test/gpu/gpu_tests/webgpu_cts_integration_test_base.py", line 371, in RunActualGpuTest
self.fail(self._query + ' failed\n' + log_str)
File "/b/swarming/w/ir/.task_template_vpython_cache/vpython/store/cpython+kp5sf4ggj3quhveqf2mb3pane0/contents/lib/python3.8/unittest/case.py", line 753, in fail
raise self.failureException(msg)
AssertionError: webgpu:shader,execution,expression,call,builtin,determinant:f16:inputSource="storage_r";dim=4 failed
- EXPECTATION FAILED: (mat4x4<f16>(7.0 (0x4700), -7.0 (0xc700), 7.0 (0x4700), -7.0 (0xc700), -7.0 (0xc700), 7.0 (0x4700), -7.0 (0xc700), 10.0 (0x4900), 7.0 (0x4700), -7.0 (0xc700), 7.0 (0x4700), -7.0 (0xc700), -7.0 (0xc700), 7.0 (0x4700), -7.0 (0xc700), 7.0 (0x4700)))
returned: 3.0 (0x4200)
expected: { 'f16', [0.0 (0x0000 subnormal)] }
Error
at GPUTest.eventualAsyncExpectation (http://127.0.0.1:42115/third_party/webgpu-cts/src/common/framework/fixture.js:167:28)
at GPUTest.expectGPUBufferValuesPassCheck (http://127.0.0.1:42115/third_party/webgpu-cts/src/webgpu/gpu_test.js:339:14)
at http://127.0.0.1:42115/third_party/webgpu-cts/src/webgpu/shader/execution/expression/expression.js:311:11
at processBatch (http://127.0.0.1:42115/third_party/webgpu-cts/src/webgpu/shader/execution/expression/expression.js:239:9)
at async Promise.all (index 0)
at async run (http://127.0.0.1:42115/third_party/webgpu-cts/src/webgpu/shader/execution/expression/expression.js:255:5)
at async RunCaseSpecific.fn (http://127.0.0.1:42115/third_party/webgpu-cts/src/webgpu/shader/execution/expression/call/builtin/determinant.spec.js:43:5)
Sample failure for Intel UHD 630
webgpu:shader,execution,expression,call,builtin,determinant:f16:inputSource="uniform";dim=2 failed
- EXPECTATION FAILED: (mat2x2<f16>(1.0 (0x3c00), -10.0 (0xc900), -1.0 (0xbc00), 1.0 (0x3c00)))
returned: -11.0 (0xc980)
expected: { 'f16', [-9.0 (0xc880)] }