RUNTIME 2228 / ARTIFACT_FORMAT 518: a dispatch of an inert kernel records no Vulkan dispatch

The translator records, from the final SPIR-V (ModuleStats::inert, spirv/verify/effects.rs),
whether a kernel can affect anything outside its invocation: inert means no loop, and no store,
atomic or image write to any storage class but Function, Private or Workgroup, in the entry or
anything it calls. Anything not classified counts as writing. A module with a loop is never
inert, since a kernel that never terminates is the one case where skipping would change the
outcome. The runtime's compute record path (compute::record, shared by direct, threads, indirect
and the host-encoded ICB path) records no vkCmdDispatch for an inert pipeline and counts it in
WorkCounts::dispatches_skipped_inert. The encoder's fences, events, barriers and the command
buffer's completion are unchanged, and a skipped dispatch's reads take no hazard tracking. Metal's
answer is the same: nothing an inert kernel does is observable, and counter sampling is a
RuntimeGap. GPU-encoded ICBs don't go through record and still dispatch. API.md documents it.

Why: on the RTX 2080 (gbt-2080, m3-max-25739, pin 69) the guest's upload_uchar_buffer kernel is
empty (`ret void`, its one buffer argument unused) and is dispatched as 1-thread threadgroups:
3,661 command buffers of it alone, 6,853 dispatches, 11.7 s of GPU time over the walk (p50
0.11 ms, p90 1.0 ms, max 111 ms a dispatch).

Verified (ftconv, at 80a7769421 on 80ff4aafa7, step codes read inside the jobs):
- 25890 engine_inert (4 profiles x 7 kernels incl. the codec round trip): NEXTEST=0, 1/1.
- 25912 lavapipe --cfg m2v_cpu_icd runtime inert_dispatch: NEXTEST=0, 3/3. Counter: empty
  direct/threads/indirect +3, workgroup-store-only +1, loop and device-store +0 (fills write
  1..=N); a fence and an event around a skipped dispatch still order a later read of an earlier
  write.
- 25913 clippy --workspace --all-targets --all-features -D warnings (plain): CLIPPY=0.
Not yet run at landing: clippy under m2v_gpu and m2v_cpu_icd, rustdoc -D warnings (dispatched by
ftconv), the 2080 before/after run and a walk with the counter.

ARTIFACT_FORMAT_VERSION 517 -> 518 (the artifact codec carries inert); RUNTIME_VERSION
2227 -> 2228.
This commit is contained in:
Anees Iqbal committed 2026-11-13 09:58:44 -08:00
1 parent b36335e5ba
commit 3969e96010
14 files changed
+668 -6

No files matched your search

+6
View File
@@ -788,6 +788,12 @@ assert!(stats.reachable_blocks <= stats.blocks);
produced, walk the entry `DeviceProfile::specialized_entry` gives, which is that AIR specialized
and canonicalized. A decoded function's `ir::InstKind::Call` sites give each callee's call
count, which is what turns its own blocks into the program inlining will make of it.
- `inert` says the module holds no loop and that no instruction of it writes memory other than an
invocation's own and its workgroup's (`Function`, `Private` and `Workgroup` storage), writes an
image, or emits or drops an output of its stage. Every invocation of such a module ends and
leaves nothing behind, so a dispatch of an inert kernel computes nothing anyone can read:
`metal2vulkan-runtime` records no Vulkan dispatch of it. An instruction the check does not
classify as reading or computing alone (an interlock, a ray query) makes a module not inert.
The counts are of the module `spirv` holds: the verifier counts the module it checked, and
serialization and relocation assign link numbers without adding or removing an instruction. They