From f3c9f748ce94ede0bddb3626654e1d8b0bb31797 Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Wed, 11 Nov 2026 15:37:37 -0800 Subject: [PATCH] RUNTIME_VERSION 2066, SEMANTICS_VERSION 2038: half + - * on the device's 16-bit arithmetic take the AIR's own contraction Half arithmetic followed float's rule but for contraction: every half + - * was lowered NoContraction, and a half fma-shaped pair as Fma(a, b, -0), whatever the AIR's fast-math flags said. Now a half + - * whose flags allow contraction is left contractable, as float's is, so the device may fuse it (rule 1: the device's native arithmetic). Notes: on the float-controls basis (Iris, 780M) half's notes are float's. On the measured basis (MoltenVK) a contractable half + - * records FastMathRewrites whatever its neighbours: Metal's fast compile folds an undecorated 16-bit op's conversions away, so even a lone op can answer the unrounded float result (M3, fast_half_chain: (1 + 2^-11) + 2^-11 with every sum fast stores 1 + 2^-11 on all 4096 threads, neither Metal's rounded 1 nor the held 1 + 2^-10). The exported float_binop_notes predicts the same. Holding half in 16 bits instead of widening was measured and not taken: on top of the contraction it is no faster on the 780M and gives the gain back on the Iris. Fixture hnq_half_layer_composite (a half layer-compositing fragment function: 16-tap filters, a colour-op switch, a 40-case blend, its taps unrolled and live across two passes) and lane tests. Verified (potluck jobs, on the branch): - performance, hnq proxy, median ms per draw, two states x 16 draws twice interleaved: Iris base 25.49/25.15, contraction 23.52/23.16 (-7.5%; SIMD8 instructions 7652 -> 7091, 0 spills); 780M base 7.39/7.19, contraction 6.71/6.52 (-9%). - half lanes 24/24 on the M3 (c66c73c1ce), Iris, 780M and lavapipe (cce43e469c). - fresh translation census on the M3, base 5cad27af52 against the tip, 17,057 rows over moltenvk-m3, intel-irisxe-rplp-anv and amd-780m-radv: 0 rows changed outcome, 0 defects; 181 s base, 204 s tip (the 8 slowest rows re-timed alternately: base 434/432/448 ms, tip 440/436/428 ms: host contention); slowest row 429-446 ms; peak worker resident memory about 216 MiB. Proxy translation 0.04-0.17 s and about 46 MiB, base and tip alike. - translator suite: 5464 passed; the golden tables and the air_input printouts are re-blessed on development at the batch. Clippy three ways and rustdoc clean. --- crates/metal2vulkan/src/cache/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/metal2vulkan/src/cache/mod.rs b/crates/metal2vulkan/src/cache/mod.rs index dfe81a392..9af2885f0 100644 --- a/crates/metal2vulkan/src/cache/mod.rs +++ b/crates/metal2vulkan/src/cache/mod.rs @@ -60,7 +60,7 @@ mod tests; /// unchanged version, and its bless records the version. Independent of the crate's version and of /// [`ARTIFACT_FORMAT_VERSION`]. The commit that bumps it says what changed; this comment keeps no /// history. -pub const SEMANTICS_VERSION: u32 = 2037; +pub const SEMANTICS_VERSION: u32 = 2038; /// The byte-layout version of encoded artifacts (`CompiledFunction::to_bytes` and the /// [`PipelineArtifact`] encodings). Every encoded artifact carries it, and a decode under another @@ -93,7 +93,7 @@ pub const ARTIFACT_FORMAT_VERSION: u32 = 502; /// changes no behaviour, and then updates that hash alone with the commit saying why, or changes /// behaviour and also bumps this version. The commit that bumps it says what changed; this comment /// keeps no history. -pub const RUNTIME_VERSION: u32 = 2065; +pub const RUNTIME_VERSION: u32 = 2066; /// The digest of the sources this build of the crate was compiled from: SHA-256, as lowercase hex, /// of the manifest, the build script, and exactly the files the crate roots' module tree compiles