Files
metal2vulkan/crates/metal2vulkan-validation/corpus
Anees Iqbal 7cce610704 Delete the shader-side dropped-store mask
One work packet, landed as 5 commits (a31d02e99a..46c3156d42 on archive/development-linear-2026-10-28), in order:

* Delete the shader-side dropped-store mask

What. The per-stage mask of buffer slots whose stores the shader drops
goes, with everything that existed only for it:

- translator: the store-dropping lowering (lower/access/sink.rs; the
  guarded stores in emit, psb, pulled, dynamic, atomic and blob; the
  write-only store-sink binding and the OpSelect of two storage-buffer
  pointers that chose it, with its VariablePointers requirement), the
  specialization key, the stage-table field and their codec tags;
- runtime: argument_table's dropped_store_buffers and its refresh,
  Buffer::drops_writes (now unused), the two variable-pointer enables,
  and SetZeroChoice.store_sinks (now the layout's set-0 bindings);
- tests: engine_dropped_stores, engine_dropped_store_sink, the sink
  cases of neutral_zeros_shared, and dynamic_multi_variable's two
  encoders_plain tests, whose only binding of several variables was the
  sink. The narrow-unit kernel now runs at its buffers' starts and at
  moving offsets: the moved run checks that a dynamic offset reaches
  every variable of its three-variable binding, and no dispatch at a
  moved offset reuses its predecessor's set in either form, since a slot
  read to its buffer's end has a range that moves with its offset;
- the Apple M3 Max known-gaps row for
  host-page-writes-kernel-store-read-only at
  case/bytes-in-the-same-command-buffer-bytes, which this fixes.

Removed public items:
- metal2vulkan::bind::StageTable::dropped_store_buffers (field)
- metal2vulkan::bind::StageShape::dropped_store_buffers (field)
- metal2vulkan::pipeline::SpecKey::DroppedStoreSlots(Stage)
- metal2vulkan::pipeline::SyntheticBinding::StoreSink
- metal2vulkan::device::VkFeature::VariablePointers
- metal2vulkan::device::VkFeature::VariablePointersStorageBuffer
(the two features were asked for only by the sink's pointer select)

Why. The mask was set only from Buffer::drops_writes, which is true only
for host pages imported through a read-only view, and only macOS makes
one (VIEWS_DROP_WRITES; ReadOnlyView::of is None elsewhere, and
no_copy_options keeps the private bit off it). No other path set it:
Linux writable imports, dma-buf imports (excluded where writes drop),
heaps (the same import) and argument buffers (which name no slot). On
that memory the view already takes the GPU's writes nowhere, so the
shader-side drop was redundant there. It was also wrong: a later
command of the same command buffer reads the stored words back from
the GPU's caches on Metal (8 runs of 8 on the M3 Max), and the
shader-side drop made it read the pages' own bytes.

Versions, placeholders for the landing to renumber: SEMANTICS_VERSION
2000, ARTIFACT_FORMAT_VERSION 500 (the codec loses four tags),
RUNTIME_VERSION 1840. api_signatures.tsv re-blessed, docs/REFUSALS.md
and docs/CONFORMANCE-COVERAGE.md regenerated, the runtime sources
re-pinned. FAST-PATHS: the read-only-memory known gap now says what is
true (writes reach the pages off macOS), and the dynamic multi-variable
row is scoped to bindings whose range stays as their offset moves.

Verified:
- metal2vulkan suite: 3329 of 3330 pass. golden_hashes moves 3391
  cells (every module with a device store loses its guard); the table
  is re-blessed on development.
- clippy -D warnings clean, plain and with --cfg m2v_gpu; rustdoc
  -D warnings clean for the four touched crates.
- MoltenVK 1.4.2 on the M3 Max: conformance replay of the four
  host-page-writes cases exits 0, both kernel-store cases exact (the
  visibility pair "announced", the fast-math notice, as before). The
  host-page, read-only and private-bit lanes and argument_table,
  neutral_zeros_shared and dynamic_multi_variable pass.
- lavapipe (arm64, linux-gate): full conformance replay exits 0, its
  891 gap rows exactly the ones the ledger expects on the venue (none
  unlisted, none stale); the same lanes pass.

* Lane: a kernel's stores into private-bit memory reach only its own command buffer

What. runtime_lane::degrade_notices gains
a_kernel_s_stores_into_private_bit_memory_reach_only_its_own_command_buffer.
It dispatches a4_index_word into no-copy memory of an anonymous
mapping, filled with 0xab and made with Metal's private option bit 24,
bound 512 bytes in, then copies the first 1024 bytes in the same
command buffer and in a later one, and reads them from the CPU.

Why. It holds Metal's measured answer where the runtime gives it: the
same command buffer's copy reads the stored words, everywhere; on
macOS, where the pages come through a read-only view, the later command
buffer and the CPU read the pages' own bytes and nothing is announced;
elsewhere they read the stores, announced once as the private-option
notice. Every byte the stores do not name keeps 0xab at every site.

Verified: MoltenVK 1.4.2 on the M3 Max prints "drops writes true; same
command buffer stored true, later command buffer stored false, CPU
stored false" and passes; lavapipe (arm64) prints "drops writes false;
... true, true, true" and passes.

* Number SEMANTICS_VERSION 1907, ARTIFACT_FORMAT_VERSION 475 and RUNTIME_VERSION 1681, past development's

The dropped-store mask's deletion took the placeholders 2000, 500 and
1840; development is at 1906, 474 and 1680.

* Re-bless the golden tables after the dropped-store mask's deletion

Every module with a device store loses its read-only guard (a31d02e99a),
so bless_golden_hashes moves 1330 rows of golden_hashes.tsv;
bless_engine_inventory, bless_engine_goldens and tests::air_input wrote
nothing new.

Verified: the three bless runs and air_input exit 0 at 623f8d2170.

* Re-bless the authored compile census after the dropped-store mask's deletion

corpus-triage --audit authored-compile --bless over 2253 cases and 21
profiles: 0 differences, 0 regressions, 0 failed, 20159 artifacts moved
by hash alone (the store guard's words). Slowest compile 586 ms,
slowest case across all profiles 18.5 s, peak worker RSS 231 MB.

Verified: the census run above at 623f8d2170.
2026-10-28 17:24:23 +02:00
..

Authored validation corpus

Canonical state is plain, deterministically ordered JSONL. The generated .index.sqlite is gitignored and may be deleted at any time.

crates/metal2vulkan-validation/corpus/
  local/sources/shard_000.jsonl ... shard_063.jsonl  # private, gitignored
  local/library-modules/shard_000.jsonl ...          # non-entry AIR dependencies, private
  cases/shard_000.jsonl ...                         # authored, no AIR bodies
  observations/metal/shard_000.jsonl ...
  observations/moltenvk/shard_000.jsonl ...
  observations/vulkan/shard_000.jsonl ...
  observations/parity/<scenario>.jsonl              # Metal's records of the parity scenarios
  authored-compile.tsv                              # each case's compile outcome per profile-leg
  .index.sqlite                                     # generated, gitignored

observations/parity/sequences.jsonl holds one line per Metal environment recorded on the Apple M3 Max. Under macOS 27.0.1, the reference, every seed ran and matches the model. Under macOS 26.7 seeds 32, 51 and 62 are Metal-side gaps: Metal's driver crashed on an indirect dispatch in each, and that line records the crash in place of the seed's records. The sequences lane names a gap seed of the line it compares with in its output.

authored-compile.tsv is the authored compile census's expectation file: one line per committed case, its outcome on each profile-leg of its header, compiled or the executor's refusal label. Only corpus-triage --audit authored-compile writes it: each train's gate adds new cases and venues' profile-legs and drops removed cases (--bless-additions), and a change that moves a case's outcome commits the file blessed with it (--bless; docs/VALIDATION.md, "Compile every committed authored case").

Committed cases and observations may reference private AIR. A checkout with no private store at all (no local/, and no --private-corpus) indexes only the rows of its public sources: those of private AIR are expected and unavailable there, and corpus-index reports how many it left out (scope=public-only). A checkout with a private store indexes every row, and a missing source shard is an error.

All paths with the same shard number cover the same bucket. The bucket is the first six bits of lowercase air_sha256. This is a permanent storage contract: do not change the bucket count or mapping to rebalance the corpus.

The 64-bucket choice is based on a 2026-08-10 measurement of 43,656 private source rows. The measured 32-, 64-, and 128-bucket layouts averaged 1,364.25, 682.12, and 341.06 rows per bucket, respectively; their largest buckets held 1,451, 740, and 401 rows. Sixty-four was the smallest layout with an average below 1,000 rows while retaining reasonably large sequential JSONL shards.

Sources

Private source rows contain the SHA-256 of the exact sanitized text, stable AIR stage/entry metadata, sanitized air_ll, optional blob_b64, the sorted lib_sha256s array of parent-library hashes, and a non-semantic label. Harvest output is sorted by AIR hash and byte-identical for the same extracted inputs. Metallibs, AIR bodies, and source shards must never be committed.

Harvest retains non-entry AIR modules separately instead of discarding them. These modules carry visible/intersection function implementations and other linkable helpers, along with the set of parent metallib hashes in which each sanitized module appeared. They are not shader queue rows and cannot be authored as standalone cases; later function-table linking resolves them as dependencies of a stage entry across its complete parent-library provenance. Resolution succeeds only when the symbol identifies one exact retained module across that union.

A harvest can keep only some stages: corpus-harvest --only-stages object,mesh keeps the modules whose !air.* entry lists name one of them, and skips before any llvm-dis every metallib whose function table lists no function of those stages. A full harvest may instead go to an archive, a separate corpus root outside the checkout that is never synced, indexed, or committed; then corpus-harvest --from-archive ARCHIVE merges only the selected rows from the archive's shards into the corpus, so a later selection needs no second walk of the machine. The selection is --only-stages LIST, --rows FILE (the source rows whose air_sha256 is the first field of a line of FILE), or both, and each selected row brings the archive's library modules of its parent libraries, the dependencies linking may resolve it against. A --rows file naming a row the archive does not hold (or one the stage filter beside it refuses) fails before anything is merged.

Cases

One AIR can have several named cases. A case explicitly records buffers, threadgroup memory, acceleration structures, top-level/array/argument-buffer textures, samplers, color render targets, an optional depth/stencil attachment, vertex inputs, kernel stage inputs, function constants, dispatch or draw parameters, selected output, comparison, and execution-safety contract. Missing bytes, sizes, formats, dimensions, constants, or output choices are errors. AIR the checker does not classify as mechanically loop-free (a CFG or call-graph cycle among reachable functions, an unresolved call, or bitcode the typed decoder refuses) uses execution_safety: authored_bounded; its rationale must identify the authored input or function-constant value that makes every reachable loop finite. loop_free is verified, never trusted (see docs/VALIDATION.md).

Fragment cases declare every reflected color output in render_targets, every reflected depth or stencil aspect in depth_stencil, and provide a draw. Both executors derive a matching fullscreen vertex interface from AIR metadata, preserve the authored initial attachment bytes with load semantics, execute the draw, and compare the selected color, depth, or stencil region. The AIR depth qualifier (any, less, or greater) determines the pipeline depth comparison on both APIs. This is the same observation/evidence path used by kernel cases.

Custom air.imageblock_master fragments additionally declare fragment_imageblock planes keyed by exact AIR user semantic and product-supported member format; a fragment-imageblock output selects that semantic and a 2D region.

Vertex cases declare vertex_inputs, exactly one render target at index zero, and a vertex_observation selecting position or a reflected user-varying location. The generated fragment observer makes that vertex result an exact render-target observation on both APIs.

An instance acceleration_structures entry represents a literal instance acceleration structure. Its child_references length is the instance count. The Metal oracle builds that many identity instances of a canonical triangle and binds the resulting opaque object. Candidate runners bind the translator's documented shadow ABI at the same Metal buffer index: little-endian u32 instance count, reserved zero u32, then the listed little-endian u64 host pointer payloads. Those pointer payloads are deliberately explicit; raw child-pointer identities are not portable Metal-versus-Vulkan comparison values.

A primitive entry sets kind: "primitive" and supplies primitive_triangles_b64 as tightly packed little-endian float3 vertices (36 bytes per triangle). The Metal oracle builds the BLAS from those vertices; the Vulkan candidate uses the identical bytes in the primitive geometry shadow.

Direct Metal visible-function references are authored under visible_function_references as the logical metadata function name plus the SHA-256 of its retained AIR module. The module may belong to a separately harvested library because Metal's linked-functions contract is explicitly cross-library; both the Metal oracle and Vulkan candidate consume that same exact module. Visible and intersection function tables explicitly list their Metal buffer binding and populated slots. A visible slot names an exact function plus the SHA-256 of a retained non-entry AIR module from the same parent metallib. An intersection slot is tagged either linked with that same exact dependency contract, or opaque_triangle with the sorted Metal intersection-signature flags. Opaque triangle is a populated native sentinel, not a null slot and not a synthetic AIR function. Case checking resolves linked dependencies once. Metal binds the corresponding native table entry; the Vulkan candidate statically replaces visible calls and fully opaque-triangle ray queries only when their authored signatures match. Unresolved modules, cross-metallib functions, missing symbols, unauthored slots, and signature mismatches are errors or honest translation fallback. Tables carried inside an air.indirect_buffer use argument_buffer_intersection_function_tables; their identity is the owning buffer binding plus field byte offset. Reflection supplies the owner parameter, field ordinal, and Metal argument index, so Metal encoding and Vulkan static specialization consume the same AIR-derived coordinate.

case_id is SHA-256 over a canonical semantic JSON encoding. It includes everything capable of changing execution or comparison and excludes the name, rationale, author, public source, JSON key order, shard, and storage details. input_sha256 independently binds observations to the exact literal inputs.

A case whose AIR is a public fixture names it: public_source is the fixture's repository-relative path (crates/metal2vulkan-validation/fixtures/public/...). corpus-case-check --install sets it from the AIR, and installing an identity its slot already holds rewrites only such fields and keeps its observations. The checker refuses a case whose named fixture no longer hashes to its air_sha256, so an edited fixture is caught by its path even where the old AIR is in no shard.

Within an AIR and an entry, name is a unique conceptual slot: a case's slot is its module, its entry, and its name, so a same-name case over another entry of a module is another slot. Replacing a slot removes the old case identity and only its Metal/MoltenVK/Vulkan observations through a recoverable aligned-shard transaction. Explicit deletion uses corpus-case-check --delete-air HASH --delete-name NAME [--delete-entry ENTRY] (the entry is needed only when the module's cases use the name over several entries) and performs the same targeted cascade without installing a replacement.

Observations

A Metal slot is (case_id, environment_id). A candidate slot is (case_id, backend, environment_id). Requalification replaces the exact slot; duplicate active slots are rejected.

Metal evidence carries case, AIR, input, output, environment, and oracle-ABI hashes. Candidate evidence additionally carries the exact Metal output hash, SPIR-V hash, backend environment, and executor ABI. Reuse requires every dependency to match.

Metal qualification runs a checked literal case three times. All selected outputs must be identical, and the result must differ from the exact initial bytes across the entire selected region. A returned poison region is a qualification failure, not a golden. Candidates require an exact usable Metal observation and compare only against that observation's selected bytes.

Public fixtures

crates/metal2vulkan-validation/fixtures/public/ holds owned synthetic fixtures, not corpus data. Its top-level .ll files (except <name>.air.ll, the typed-pointer Metal half of a fixture) are indexed as public source rows. The product's fixture inventory (crates/metal2vulkan/tests/public_fixture_expectations_engine.tsv) compiles every .ll file here and in engine/. A module's air_sha256 is the SHA-256 of the whole .ll text, comments included, so an edited fixture is a new AIR: its cases are reinstalled under the new hash and their observations re-recorded. A module that declares one entry point is one row with that identity; a row of a module that declares several is keyed by the module and its entry (below). Every committed .ll here and below (again except <name>.air.ll) must assemble with llvm-as of the LLVM that engine/TOOLCHAIN pins, the oldest the gates use (crates/metal2vulkan-validation/tests/fixtures_assemble_with_the_pinned_llvm.rs).

crates/metal2vulkan-validation/fixtures/public/engine/ holds owned MSL for the re-architecture. Its top-level .ll files (again except <name>.air.ll) are indexed as public source rows too, labelled public/engine/<name>.ll, so they can carry authored cases; the Metal oracle loads such a row's .air.ll half. Neither the index nor the inventory descends further (engine/companions/ holds no rows). A public row is one entry point of one module: a module whose !air.kernel, !air.vertex, and !air.fragment lists declare several entries is a row per entry, each with the whole module's text and air_sha256 and keyed by entry_row_key (the SHA-256 of the sorted JSON {"air_sha256", "entry"}), and each row's facts are read from its entry's projection of the module. corpus-index and the authoring-capability census print public-sources rows=<n> modules=<m>. A case over such a module names the module's air_sha256 and its entry, and is indexed under that entry's row. scripts/regen-air-fixtures/ compiles each .metal with xcrun metal and writes an .ll review companion (llvm-dis), an .air.ll typed-pointer text that xcrun metal-as reassembles into the same module (checked on every run), and TOOLCHAIN, which records the compiler and SDK versions and the pinned LLVM (21, the oldest the gates use) whose llvm-dis writes each .ll and whose llvm-as must accept it. A run writes the compiled .air only where the directory already holds one: a handful of fixtures commit theirs for tests to read as bitcode, and every other fixture's stays in the run's scratch directory. Tests that need typed-pointer bitcode assemble it from the committed .air.ll with xcrun metal-as on macOS and skip with a visible message elsewhere; the opaque-pointer path is covered by llvm-as of the committed .ll.

Committed device profiles for per-profile validation live in crates/metal2vulkan-validation/profiles/, generated by scripts/regen-device-profiles/ with pinned provenance.

Safety and privacy

The checker accepts acyclic AIR as loop_free and cyclic AIR only as authored_bounded with an explicit finite-bound rationale. The latter is an auditable semantic assertion about the literal inputs, not a claim that a CPU timeout can cancel already committed GPU work.

Committed cases and observations may contain authored input/output bytes but no AIR bodies or Apple-owned binaries. Git history is the audit trail for replaced cases; active shards retain no superseded case identities.