Commit Graph
4 Commits
Author SHA1 Message Date
Anees Iqbal e73c87d49b Stop three emission decisions from following hash-map iteration order
The same AIR translated to different SPIR-V on every run. Not different ids that
canonicalization normalizes away -- genuinely different modules: a different
prologue order, different constant declarations, different type declarations. Each
run was individually correct and passed spirv-val, which is why nothing caught it.

It matters because the validation ladder compares a candidate's output by SHA-256,
consumers cache translated SPIR-V by content hash, and a bug report is only
reproducible if the module that produced it can be produced again.

Three sources, all the same shape -- an unordered collection deciding the order
something is emitted or minted in:

- native emitter (functions.rs): the device-address prologue materializes one
  address per direct buffer parameter, and that list was built by iterating
  `raw_offsets`. The position each address lands at fixes which address-table slot
  the module reads there, so the whole prologue permuted. Order by entry parameter
  ordinal, which is stable and is the order a reader expects. The rewrite also
  drops a redundant `contains_key` and, with it, an eager map index that would have
  panicked on any raw offset that is not a direct parameter.
- buffer-address lowering (buffer_addresses.rs): `ctx.const_uint` mints a constant
  the first time it sees a value, so the order the table's location constants were
  requested in -- taken from a `HashSet` -- was their declaration order.
- nesting structurizer (reloop_nest/emit.rs): `demote_phis` walked `blocks.keys()`,
  minting a variable and a `TypePointer Function` per demoted phi in hash-map
  order. Record the function's own block order at indexing time and walk that.

tests/deterministic_output.rs pins the contract. Rust seeds every HashMap's hasher
differently, including two built in the same process, so translating one input
twice in one test is enough to expose an order-following emission decision -- it is
strictly stronger than comparing two CLI runs, and it found the second and third
sources after the first was already fixed. It covers an authored four-buffer
device-address kernel (with a guard that the kernel still lowers to an address
table, so the case cannot decay into covering nothing) and every public fixture
that translates.

Verified: the authored kernel produced 6 distinct hashes in 6 CLI runs before the
first fix and 1 after; 12 in-process runs collapsed from 2 distinct modules to 1
after the second. Over 1267 sampled local-corpus sources, 1159 translated and 2
still varied before the third fix; after it, a 240-source sample was fully stable
and the two known varying cases were checked individually. cargo test -p
metal2vulkan: 1704 lib + 3 determinism + 3 env + 6 fallback, all passing.
Workspace clippy -D warnings and all-features Rustdoc: clean.
2026-08-31 15:39:00 +03:00
Anees Iqbal 8b78eaca3b Expand macOS 26 AIR translation coverage
Overhaul the validation workflow around sharded authored cases, dependency-exact observations, incremental indexed corpus audits, bounded parallel translation, and native Metal/Vulkan comparison.\n\nExpand native AIR lowering, reflection, linked-function specialization, resource and stage-interface support, and structural CFG/pointer repair across the harvested macOS 26 corpus. Add exact intrinsic inventory, distributed 16x16x16 matrix lowering, explicit opaque tensor linkage, and regression coverage for the newly supported feature classes.\n\nThe final corpus verification accounts for all 88,819 indexed AIR modules under the current product fingerprint: 65,355 translate and validate directly, 23,464 require exact authored linkage, and zero fail or remain unresolved.
2026-08-13 21:46:27 +02:00
Anees Iqbal 1b013834bc Improve translation correctness and oracle safety
Add structural lowering fixes for function constants, byte aggregates, texture arrays, sampling, and SIMD operations. Harden corpus oracle planning and quarantine unsafe or non-comparable rows without GPU resubmission. Reject reused SPIR-V merge ownership and fast-fallback oversized systematic CFG failures so broken AIR returns promptly instead of emitting invalid bytes after lengthy retries.
2026-08-10 16:54:26 +02:00
Anees Iqbal 3007485352 🆕 Open Source metal2vulkan 2026-07-22 13:15:24 +03:00