Carve MoltenVK on the M3 Max's identity out of NativeHalfConversion for measured conversions

reims-vgpu treats precision notes as fatal on Apple GPUs; NativeHalfConversion was its largest
group of Mac-only failures (37 tests). The note says a half rounded through the device's
conversion to 16 bits and back may differ from Metal's. On the M3 Max (MoltenVK 1.4.2, macOS
27.0.1), MoltenVK writes OpFConvert to 16 bits as MSL half(x), which is Metal's half(float), and
Metal's compiler folds the conversion of an image instruction's float texel into the access.

What: a new DriverDeviation::MetalHalfConversion (VkProperty::MetalHalfConversion), taken by the
APPLE9 MoltenVK row alone. Where the profile takes it:
- narrow::round_measured rounds a float the function holds (an AIR fptrunc or air.convert from
  float, through resize) by the conversion pair and records the pair's narrowing in a new module
  side table, measured_roundings (kept through edit.rs's retain and the roll pass's check);
- narrow::rounds_unmeasured finds any other conversion pair: one neither recorded nor of a texel
  an image read, fetch, sample or gather hands back (directly, through a composite extract, or
  through a parameter every call passes such a texel);
- the compile records NativeHalfConversion only where such an unmeasured pair exists, and
  otherwise requires the property.
A half operation or function computed in float and rounded keeps the note: Metal's half tanh
answers 7 of the 65,536 halves otherwise than the conversion of its float tanh. exp, sqrt and a
reciprocal on half matched, but they are functions, not the conversion, so they stay noted.

Verified on this M3 Max, word for word against plain Metal (an MSL probe, fast and safe math):
- the conversion of a float loaded (425,216 words), of a sum, product and quotient (144,896
  pairs each), of an fma (123,648) and of an integer's quotient (190,208): 0 words differ;
- the half result of read, nearest sample at the centre, linear sample a quarter texel off and
  gather of every texel of ten formats (RGBA32Float, RGBA16Float, RGBA8Unorm and its sRGB twin,
  RGBA8Snorm, RGBA16Unorm, RGBA16Snorm, RGB10A2Unorm, RG11B10Float, RGB9E5Float): 0 differ.
- New lane runtime_lane::half_conversions on MoltenVK: load, sum, product and fma kernels carry
  no note and 0 of 253,958 lanes per kernel differ from the half model; the half tanh kernel
  keeps the note. With measured_conversion forced false the lane fails.
- New core test half_conversions_are_metals_where_measured: the four forms lose the note and
  require the property on moltenvk-m3 with the deviation, keep it without the deviation, and the
  half tanh keeps it on both; it fails with the carve disabled.
- Notes of every public fixture on moltenvk-m3, lavapipe and nvidia-rtx5080-laptop before and
  after: NativeHalfConversion leaves 58 moltenvk-m3 rows, and no row gains a note. Consumer AIR on
  moltenvk-m3: 23 entries noted before, 2 after (a heap texture's held half read).

Docs: API.md (native-half-conversion exemption), HOWTO.md, the PrecisionNote, VkProperty and
deviation rustdoc, the driver-facts measurement record. SEMANTICS_VERSION 1949 and
ARTIFACT_FORMAT_VERSION 484 (new VkProperty variants in the codec); these bumps cover the rest of
this branch. api_signatures gains the two variants.

(cherry picked from commit 266f7cd26327e408d9cd1f0d6ea5ba33e49e10b3)
This commit is contained in:
Anees Iqbal committed 2026-11-02 16:41:46 -08:00
1 parent a44a550cbb
commit 217cc233f5
21 files changed
+649 -11

No files matched your search

+9 -1
View File
@@ -3456,7 +3456,15 @@ bound.
is the device's narrowing, and that conversion is neither under those controls nor measured to be
Metal's: the conversion on NVIDIA and lavapipe, and `GLSL.std.450 UnpackHalf2x16` and
`PackHalf2x16` on every device without `shaderFloat16`. A half denormal may read or encode as the
zero of its sign.
zero of its sign. **Exempt:** on a profile that takes `DriverDeviation::MetalHalfConversion`,
MoltenVK on Apple's GPUs of the Apple M3 Max's macOS 27 identity, a module whose every `half`
rounded through the conversion converts a `float` the function holds (an AIR `fptrunc` or
`air.convert` from `float`) or an image instruction's texel records no note for that rounding and
requires `VkProperty::MetalHalfConversion`: measured word for word against plain Metal, with and
without fast math, over 1,173,760 `float`s loaded, summed, multiplied, divided and fused, an
integer's quotient, and every texel of ten formats read, sampled and gathered as `half`. A `half`
operation or function computed in `float` and rounded keeps the note (Metal's `half` `tanh`
answers 7 of the 65,536 `half`s otherwise).
- `metal2vulkan-degrade-native-half-quantize` (precision). `PrecisionNote::NativeHalfQuantize`:
Native half rounding (a quantize): the module rounds a `half` result it computes in `float` (a
`half` operation's, a function's, a conversion from `float`'s, a texel's) by the device's