Commit Graph
6989 Commits
Author SHA1 Message Date
Anees Iqbal 70dffca0c2 Deep threadgroups run as one row: SpecKey::DeepThreadgroup on from_queries, rt keys it on the size
Metal allows 1024 threads along z; a device's maxComputeWorkGroupSize[2] may hold 64 (NVIDIA's),
so rt refused a kernel's threadgroup of 1x1x320 (Limit::ThreadgroupShape) and could not play a
recorded stream past its frame 216 on any NVIDIA card. One form serves every shape on every
device: a threadgroup deeper than DEEP_THREADGROUP (64) runs as one row of its threads.

Translator, on Device::from_queries' profile only (ProfileFacts::deep_threadgroups, OneRow; Device::new
keeps Axes and is byte-equal): a kernel whose workgroup is its threadgroup (LocalSizeForm::Spec,
no compute derivatives) declares the boolean SpecKey::DeepThreadgroup. Its WorkgroupSize is
(Deep ? sx*sy*sz : sx, Deep ? 1 : sy, Deep ? 1 : sz), OpSpecConstantOp selects (the WorkgroupSize
rule now takes spec-constant operations whose defaults are positive), and its position in the
threadgroup Deep ? LocalInvocationIndex unflattened over (sx, sy) : LocalInvocationId. The linear
index, workgroup and grid builtins keep their values, so group counts, regions and indirect
buffers are untouched. The binder sets it for a region deeper than 64 and checks that region as
the flattened tiers' are. MetalDeviceProperties on that profile reports the capped invocations
on every axis (1024 on every floor device) instead of the device's per-axis sizes.
SEMANTICS_VERSION 2172, ARTIFACT_FORMAT_VERSION 536.

rt: the key is a function of the variant's size (size[2] > DEEP_THREADGROUP), so it adds no
pipeline and no cache key. choose() takes no device limit: an image-only kernel's deep tile runs
whole as one row on every device (it ran whole on RADV/ANV and in tiles on NVIDIA). fits(),
ComputeLimits::max_group_size and Limit::ThreadgroupShape are deleted: every workgroup is within
the floor by construction (a const assertion). A module that neither flattens nor declares the
key is a creation gap. README: the deep form, worst-case pipeline counts, the 50-pipeline line.
REFUSALS.md regenerated; API.md; api_signatures blessed; api_surface pins DEEP_THREADGROUP.

Tests: the translator runs a barrier-exchange kernel at 1x1x320, 2x3x100, 1x4x256 (deep) and 4x4x4
on the interpreter, checks the evaluated WorkgroupSize, no key on Device::new, the binder's
setting on an NVIDIA profile, and the reported maxima; rt's choice tests drop the device limit;
the observing-kernel device test adds deep whole, ragged and indirect dispatches; the square
test adds a column 256 deep.

Verified: built and tested under the check job named in the report.
2026-11-18 04:21:18 -08:00
Anees Iqbal 5c5ce57119 replay: the Managed form comes from the identity of the device the guest makes its objects on
A stream may record more than one device: reims's one-copy recording on the 780M also holds the
host window's device on the display GPU, which is not unified. Each segment opens with one identity
record per live device in id order, and the player passed every record to the backend, so the last
one decided how every Managed buffer was kept, whichever device the guest used.

The player now reads ahead which recorded device the guest makes its objects on (the one that most
calls making an object have as their receiver, the lowest id of a tie) and takes the Managed form
from that device's identity record only. The report names the other devices on a
`devices apart from the guest's` line.

Test: a unit test with two devices, one unified and one not, the guest on each in turn.
2026-11-18 04:14:03 -08:00
Anees Iqbal 8a39262627 replay: a second copy's synchronizeResource: takes its buffer from the resource argument
The argument is a {Buffer: #id} variant, not an object: the two-copy play of r3 on the 780M stopped
at frame 203 on 'argument 0 is {Buffer: #3081}, not an object'.
2026-11-18 04:03:19 -08:00
Anees Iqbal 49febff9b5 replay: a two-copy stream's Managed buffers keep a second copy on a one-copy device
A stream recorded where Managed buffers have two copies (Metal's hasUnifiedMemory false) relies
on them: a didModifyRange: makes the GPU's copy of the range equal the CPU's bytes at the next
commit, over whatever a kernel wrote there. On a device whose Managed buffers are one copy (the
runtime's, on unified memory) a kernel's write into the buffer stayed where the recording put the
CPU's bytes back, and later work read it: gb r3's frame 1138 reads such a count and runs a kernel
past the end of a buffer on the 780M.

The backend now keeps the second copy itself there: the buffer object is the GPU's copy and
second::Seconds the CPU's, both Shared buffers in places of its own. The stream's writes and
m2v.check read the CPU's copy; didModifyRange: names a range, and the next commit copies every
range named since into the GPU's copy in a command buffer of the backend's own on the committing
command buffer's queue, committed just before it; synchronizeResource: copies the GPU's copy into
the CPU's. A stream recorded with one copy plays Managed as Shared on every device, as before. The
report's managed second copies line says how many buffers and bytes took a second copy and how
many bytes the commits copied, so that such a play is never read as a one-copy guest's.

Verified: the unit test named_ranges_merge_where_they_overlap_or_touch; the play evidence is in
the hand-over.
2026-11-18 04:03:19 -08:00
Anees Iqbal 53274a5352 rt: a Managed buffer keeps two copies on every device that is not unified
What: where device-local memory has no room for a copy block, a Managed buffer's device copy is
now a Private block of its own, taken through the pool, so it spills to whatever memory type has
room like any Private block; where no type has room, new_managed_buffer returns the allocation's
out-of-device-memory error (Metal: nil). Before, such a buffer was its Shared range, one copy,
on a device whose has_unified_memory is false. Gauges::managed_spilled_bytes counts the bytes of
Managed buffers whose device copy is not device-local, while they live; the replay player
reports it beside spilled_bytes. The rt README states the cost: on a full discrete card a
Managed kernel reads its copy across the host link.

Why: the planner's ruling. Metal keeps a Managed buffer's two copies on a discrete Mac: a
kernel's write stays in the GPU's copy until a synchronize, and didModifyRange sends the CPU's
bytes over it. With one copy, a kernel's write reached the consumer's bytes, and a range named
with no CPU write left the kernel's value in place: a program could observe the difference.

Tests: tests::managed::every_device_keeps_metal_s_two_copy_rule_for_a_managed_buffer (every
device): a kernel takes each word x to 2x+1, the range is named with no host write, a second
kernel reads it. Where has_unified_memory is false the consumer's bytes keep the host's words
and the reader reads them, and the buffer's address is not its Shared range's; on a unified
device the reader reads the kernel's write. tests::spill: the same rule with the Private type's
allocations made to fail (the test seam core.fail_private) and the pool's Private blocks
spilled; on a device that is not unified the gauge counts the buffer's 256 bytes while it lives
and reads 0 after. The api signature table gains the gauge field.
2026-11-18 03:52:56 -08:00
Anees Iqbal 6ab8b5da26 matrix: a job's script travels in its environment, not on its command line
The UHD 630 leg's harness job has failed in three matrices (0bd215eee3 among them, job
m3-max-45587) with "bash: -c: line 49: unexpected EOF while looking for matching `''" before any
row ran. The Windows host starts a job's command through a command line cut at 8,191
characters. The harness leg's script carries every leg's per-row limits and grew from 3,271
bytes at aaf4d16993 (last good UHD harness run) to 12,837 at 0bd215eee3 and 16,075 at
b2e33dba6d. Byte 8,191 of the 0bd215eee3 script falls on its line 49, the line bash named.

The script now goes in the job's environment (M2V_JOB, read and unset before it runs), and the
command line is a fixed one-liner, on every node. A Windows variable holds 32,767 characters.

Verified: the 0bd215eee3 and b2e33dba6d scripts parse with bash -n on macOS (so the script itself
is whole); a test job on the mini with an 18,627-byte script in M2V_JOB, against the same script
as the argument (control), is in the landing message.
2026-11-18 03:39:53 -08:00
Anees Iqbal affea51d8a harness: the binary imports count_instructions, which it calls before it makes a device
The previous commit called it through a run:: path the binary does not have in scope, so the
harness binary did not compile (check job m3-max-45575, msi).
2026-11-18 03:31:27 -08:00
Anees Iqbal d2e5edbd60 harness and matrix: record the whole process's instructions per run and gate the frame and burst rows on them
The harness now counts each timed run's user-space instructions across the whole process. The
counts repeat run to run where the times do not: rt's p50 spread across processes was 0.16 to
0.27%. The matrix gates the frame and burst rows (WALL_ROWS) on those counts, beside the host-time
judgement and floors they keep under the GPU-p50 rule.

devtools: ProcessInstructions opens one user-space instructions counter per core type with
inherit set, so every thread started after it opens counts: the runtimes' and the drivers'
threads too. The harness opens it first thing in main, before any device starts a thread, and
each timed run records the counted delta. A node that refuses perf_event_open, and every
non-Linux host, records none.

harness: each row whose runs were not sized prints
`M2V-MATRIX instructions harness-<runtime>/<row>/per_run <p50>`.

matrix: a frame or burst row with a count on both runtimes passes the instructions gate as well as
its time's limit:
- it fails when rt's count is over old's;
- it fails when rt's count is past 1.03 times the stored count in scripts/matrix/instructions.tsv
  (one column per driver family, `all` where the legs agree within 3%);
- it is named when its count is more than 1% under the stored count, which then ratchets down;
- it is named when no count is stored, and is then gated against old alone.
The single-kernel rows stay judged on their GPU p50 as before, and every row's count is shown
beside its times. The old runtime's harness counts are parked from the per-record
instructions-versus-base check, like its times. instructions.tsv starts empty: a matrix run's
counts seed it. VALIDATION.md describes the time rules and the gate in one paragraph.

Verified: scripts/matrix tests (python3 -m unittest discover, 45 OK) on this Mac, over this rule
and the GPU-p50 rule together. Before the rebase, check m3-max-45591 on msi (at c597bb3603) passed
clippy x4, nextest for devtools, harness and rt (118 passed, with the process counter's test), and
the release harness build. Count job m3-max-45641 on the 2080's node recorded the per_run count of
every row on both runtimes except long_4cb, which is sized.
2026-11-18 03:31:27 -08:00
Anees Iqbal b2e33dba6d matrix: a harness row with a GPU time is judged on it against the old runtime's GPU-time floor
The planner's ruling on the old-against-old GPU-p50 floors. On the XTX, whose host-time floors
reach 1.2-1.3 on the shader rows (8 runs, m3-max-45546), the same runs' GPU p50 spreads 1.004 on
simd_reduce (36.96-37.12 us, host time 44.9-55.8 us), 1.008 on narrow_ints, 1.012 on image_filter
and 1.024 on constexpr_sampling: the host time's spread is the host's, not the card's. So:

- A row with a GPU time on both runtimes is judged on its GPU p50, new over old, against the old
  runtime's GPU-time floor on that leg (the new scripts/matrix/gpu-floors.tsv), with its host
  times shown beside it. A ceiling applies to the time its row is judged on.
- The frame and burst rows (WALL_ROWS) stay on their host time and its floor, with the
  instructions gate: their GPU time spans the gaps between their command buffers and spreads as
  widely on several GPUs (1.68 on the Iris Xe's frame_5cb, 1.43 on the UHD 630's
  burst_160_shared). gpu-floors.tsv lists no such row.
- CARD_VARIANCE names rows whose GPU time varies on the card itself: the XTX's sampling (GPU p50
  16.3-20.3 us over the 8 runs; 1.264 in the earlier 4-run set, m3-max-45424) and
  constant_managed (66.8-69.2 or 74.4 us). They are judged like any other row, never fail a leg,
  and are named on its line as the card's variance.
- A re-timed run keeps the row's GPU time too (RETIME_KEEP, harness-retime-gpu/), and the re-time
  selection chooses by the same measure (RETIME_SELECT with GPULIMITS and WALLRE), so a row judged
  on its GPU time is re-timed and judged on its re-timed GPU pairs.

gpu-floors.tsv comes from the runs behind floors.tsv, no new job: the harness of 4cc7963005, 4
runs of `harness --runtime old` per leg (8 on the XTX), jobs m3-max-45422 (1002:15bf), 45430
(1002:1900), 45423 (1002:699f), 45546 (1002:744c), 45425 (10de:1e87), 45426 (10de:2204), 45437
(8086:3e9b) and 45427 (8086:a7a0). Its header notes that the UHD 630's texture_read (1.075) and
the Iris Xe's wide_bindings (1.097) are those GPUs' floors, not reds.

Verified: the matrix's Python tests (42, 4 new: a row with a GPU time judged on it and a frame or
burst row on its time, the GPU floor and the re-timed GPU pairs, a card's variance named and
failing nothing, the re-time keeping both times), run locally; the harness runs' shell renders
and passes `bash -n` for a leg with limits.
2026-11-18 03:24:47 -08:00
Anees Iqbal ef181c884d Reflow the import lists the rebase resolution unioned 2026-11-18 03:17:11 -08:00
Anees Iqbal 4ac94af120 replay: a released buffer's place waits for the command buffers that named it and are not yet committed
The new runtime's backend gave a released buffer's place back after the commits made so far, free
once they completed. A command buffer that named the buffer before its release but is committed
after it was not among them: the place could go to a new buffer, whose bytes the stream then
writes, before that command buffer ran, which then read the new buffer's bytes as its own (a
dispatch's arguments among them). Metal keeps a released buffer for every command buffer that
names it.

Each uncommitted command buffer's encoders' named buffers are kept; a release waits for those
command buffers (Places::give's users) and goes to the commit count when the last of them is
committed or released uncommitted (Places::ended).

Verified: the unit test a_place_waits_for_its_uncommitted_users.
2026-11-18 03:17:00 -08:00
Anees Iqbal fa930a9793 runtime lane: the replay draw test's metallib holds one-entry modules
A metallib function's module declares that function as its one entry; the
translator's container cross-check refuses any other (ContainerMismatch). The
test put the whole render fixture, five entries, behind each function, so the
render pipeline state was refused and skipped on every device (job 45305 on
lavapipe: "skipped render states 1, the first #6: the translator made no
pipeline: invalid input: Abi(ContainerMismatch) at metadata").

Each function's module is now the fixture with its entry lists cut to that
function's own entry node, found by the node's `!{ptr @name, ...}` line, and
assembled in the test's scratch directory.

Verified: the next job runs the test on lavapipe, then the legs on every
device.
2026-11-18 03:14:48 -08:00
Anees Iqbal 73f24bed7a replay rt backend: the report names the first skipped render state and why
A render pipeline state the runtime answers with a typed gap or the translator
refuses is skipped and counted, and nothing said which one or why: the replay
device test's draw was skipped on every device (legs 45244, 45245, 45246) with
skipped_render_states=1 and no reason. The backend now keeps the first such
state's object id and the runtime's answer, and its lines print
`skipped render states N, the first #ID: WHY`. The device test prints the
backend's lines after the player's.

REPLAY-STREAM.md names the line.

Verified: the next job builds the validation crate in every cfg and runs the
replay test on lavapipe.
2026-11-18 03:14:48 -08:00
Anees Iqbal 39f79ecb8e replay rt backend: the pass setters reborrow the attachment they set
set_attachment! takes its attachment by value, so passing the `&mut`
binding moved it before the clear value was set. Lint 45173 caught it
(E0382, three times). Each setter now passes `&mut *a`, as the old backend's
setters do.

Verified: the next lint compiles the validation crate in every cfg.
2026-11-18 03:14:47 -08:00
Anees Iqbal 3e0df2df8c runtime lane: a draw into a pass plays through the replay player on the new runtime
A device test of the player's rt backend, the first one: a stream it writes
makes a render pipeline state of the render library's colored_vertex and
colored_fragment (a metallib of runtime_examples.ll), a 4x4 RGBA8Unorm
target, vertex buffers, and a pass whose setter records clear the target to
red. It draws one triangle over the whole target, green. A blit copies the
target to a Shared buffer, which the stream checks green. The play must
report no skipped encoder, render state, draw, call or object, and at least
one pass.

Without the render port it fails. The backend skipped the render encoder
whole (skipped_encoders 1), so the target stayed red and the check differs.

The new runtime's device is opened behind the hang tripwire, as every device
open in the crate is, and keeps its kernels in a cache the test owns.

Verified: the lane leg under --cfg m2v_gpu on the lab's devices and
lavapipe.
2026-11-18 03:14:47 -08:00
Anees Iqbal e8113811dd replay: the rt backend plays render pipeline states, passes and render encoders
The new runtime builds draws (its render encoder, render pipeline and
depth-stencil states), so the player's rt backend stops skipping render
encoders whole. It plays, on rt's API:

- newRenderPipelineStateWithDescriptor:error:, its constexpr samplers numbered
  as a compute pipeline state's are (one helper, `numbered`, for both);
  newDepthStencilStateWithDescriptor:; MTLRenderPassDescriptor.new and
  .renderPassDescriptor with their m2v.setPass, m2v.setColorAttachment,
  m2v.setDepthAttachment and m2v.setStencilAttachment setter records;
- renderCommandEncoderWithDescriptor: and the render encoder's calls the old
  runtime's backend plays, with the vertex stage's textures and samplers, both
  stages' bytes, cull mode, winding, blend color, and the draws' instance,
  base-vertex and base-instance forms.

What rt does not build stays skipped and counted, honestly: a render pipeline
state rt answers with a typed gap or the translator refuses
(skipped_render_states); a parallel render encoder, or a render encoder of a
pass that holds what rt's descriptor does not (resolve textures, depth planes,
store action options, a visibility result buffer, layered or tile rendering, a
skipped texture) or that rt answers with a typed gap (skipped_encoders); and a
draw whose pipeline state, bound buffer or texture, or index buffer is a
skipped object (skipped_draws).

The render pipeline, depth-stencil and pass-key parsing moves from the old
backend's descriptors.rs to replay/translator.rs, shared by both backends, as
the sampler's is. docs/REPLAY-STREAM.md says what the rt backend plays and
counts.

Verified: lint of the validation crate (clippy in every cfg, the replay
tests, rustdoc); the device test that follows plays a draw on every device.
2026-11-18 03:14:47 -08:00
Anees Iqbal ab6a03d765 Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-18 03:14:35 -08:00
Anees Iqbal a5f404ed8d cache codec: the signed fixed-function vertex fetch has its tag
The codec's VertexFetch enum names every variant, so adding SignedFixedFunction failed the
compile (E0004 in the digest and put matches, lint 45478). Old artifacts hold no such tag, so the
encoding is unchanged for them.

Verified: the next lint compiles the translator and its tests.
2026-11-18 03:13:48 -08:00
Anees Iqbal 0d1a32436b vertex input under the identity domains: every attribute in fixed function, no pulled form
Planner ruling 11-18 (final): fixed-function vertex input for every attribute on every device,
the form native Vulkan uses and the fastest measured on every device, one form. Nothing of the
pulled form is taken on Device::from_queries' profile. Before this, the translator's
containment rule (contain::encoding is Check::InShader without buffer robustness) moved every
[[stage_in]] attribute into the shader, a form that reads through a descriptor the identity
domains refuse, so every rt render state with a vertex descriptor was refused as
Unsupported(IdentityDomains).

Translator (metal::vertex::fetch_as, pipeline::link::vertex::resolve), under the identity domains
only (lower::access::identity), so Device::new's profile and the old runtime are unchanged:
- the containment rule no longer moves an attribute: the device bounds the fetch as it bounds
  any (no buffer robustness: a fetch outside its buffer reads what the device gives);
- an unnormalized signed-integer format (Char*, Short*, Int*) is fetched in fixed function into
  a variable declared int, VertexFetch::SignedFixedFunction (new): Vulkan's numeric-type match
  lets a SINT format feed only a signed variable, and the device sign-extends as Metal does. The
  module reads the variable's bits by OpBitcast. Elsewhere such an attribute is still pulled and
  sign-extended in the shader;
- every case that pulled is a typed refusal by what it needs, never a second fetch form.

Metal's vertex descriptor on the rt floor:
- Maps directly:
  - formats: every Metal vertex format to the Vulkan format of its layout and conversion, by the
    device's VERTEX_BUFFER format query. 8/16-bit integer formats read into float attributes go
    through USCALED/SSCALED, signed integer formats into int variables, UChar4Normalized_BGRA is
    B8G8R8A8_UNORM, the 10:10:10:2 formats are A2B10G10R10, and FloatRG11B10 is
    B10G11R11_UFLOAT_PACK32. The validation crate's profiles of RADV (780M x2, RDNA3), ANV (Iris
    Xe, UHD 770), NVIDIA (Pascal, RTX 50) and lavapipe report VERTEX_BUFFER for all of them but
    FloatRGB9E5;
  - steps: PerVertex is VERTEX rate; PerInstance at rate 1 is INSTANCE rate;
  - offsets and strides: the descriptor's, baked into the VkPipeline.
- No fixed-function equivalent on the floor, so a typed refusal:
  - PerInstance rate > 1 and Constant: Unsupported{VertexStepRate}, by query. They need
    VK_KHR_vertex_attribute_divisor's vertexAttributeInstanceRateDivisor (plus ZeroDivisor for
    Constant) and supportsNonZeroFirstInstance, which the floor does not enable, so it is
    refused on every rt device today. Its needs name the missing feature, or the
    maxVertexAttribDivisor limit;
  - a format the device does not report for VERTEX_BUFFER: Unsupported{Format} with that format
    usage, by query;
  - FloatRGB9E5: Unsupported{Format}, not implemented, by need. Of the profiles above only
    lavapipe's reports it, and its fetch answers 0 for the fourth component, where Metal and
    Vulkan give 1;
  - an offset or stride off the format's component alignment (Metal takes any byte multiple on
    Apple5+), and an offset, stride, attribute count or layout count past
    maxVertexInputAttributeOffset, maxVertexInputBindingStride, maxVertexInputAttributes or
    maxVertexInputBindings: Unsupported{VertexInputLayout}, with the limit where one is passed;
  - PerPatch and PerPatchControlPoint: Unsupported{Tessellation}, as before.

rt: RenderPipelineKind::StepRate is deleted: the translator's VertexStepRate refusal comes first
on every rt device, so no pipeline states a divisor. README: the vertex input bullets, their
refusals, and the known gap that a vertex fetch outside its buffer returns what the device gives.
docs/API.md: the identity domains' vertex input. REFUSALS.md regenerated, with reach marks for the
two new features (VertexStepRate app, VertexInputLayout rare); api_signatures blessed.

Tests:
- engine_identity_render from_queries_fetches_every_attribute_in_fixed_function (lavapipe and
  moltenvk-m3 profiles with buffer robustness and the divisor withheld): ima_vertex's float2
  and short attributes are R32G32_SFLOAT and R16_SINT, nothing pulled, L3-valid; a rate-2 layout
  is VertexStepRate needing vertexAttributeInstanceRateDivisor. It fails without this commit (the
  attributes were pulled, then refused as IdentityDomains);
- rt draw every_device_fetches_a_signed_attribute_in_fixed_function: a short of -2 reaches the
  fragment's uint output as 0xFFFFFFFE on every texel; a rate-2 layout is refused as
  VertexStepRate. The existing stage-in test (vertex buffer and set_vertex_bytes) now makes its
  pipeline.

Verified: the next lint job and the device legs on every device.
2026-11-18 03:13:48 -08:00
Anees Iqbal b075c6e953 rt draw tests: buffers zeroed through new_buffer's zero_from
development's new_buffer takes zero_from (Option<u64>) where it took a bool;
the draw tests' two buffers ask Some(0), all their bytes zeroed, as true did.
The rebase onto 1d9ceb87c8 left them on the bool, which lint 44991 caught
(clippy under --cfg m2v_gpu and m2v_cpu_icd).

Verified: the next lint compiles the device tests.
2026-11-18 03:13:48 -08:00
Anees Iqbal 1020e38a3c harness run: the render encoder's trait is in scope where passes end
encode_pass ends a render pass with end_encoding, a method of the harness's
RenderCommandEncoder trait, which run.rs did not import; the Windows cross build
of the harness failed on it (six errors, all that trait's methods).

Verified: the arm builds and lint that follow compile this tree.
2026-11-18 03:13:48 -08:00
Anees Iqbal 2aabffabb0 rt draws: a buffer bound off its argument's alignment is refused before the draw records anything, by the dispatch's shared check
Identity's Refusal::BufferOffsetAlignment (89bf650d2e) checked dispatches alone; a draw rounded the
address down to the argument's alignment (`address & !mask`) and drew from another place. The
draw now applies the same check to each buffer its vertex and fragment functions reach
(FieldValue::BufferAddress's mask, from RuntimeFact::AddressAlignment), after its other checks and
before anything is recorded, and pushes the address unrounded. The check is one function,
encoder::check_alignment(slot, mask, buffer, offset), which the compute encoder's
check_alignments loops over and the draw calls too; the refusal's doc names draws.

Test: every_device_refuses_a_draw_whose_buffer_is_off_its_alignment binds colored_vertex's float2
positions at 20 (alignment 8) and its float4 colours at 24 (alignment 16): each draw is refused
with the slot, offset and alignment; the buffers bound at 16 then draw the top half green, and the
pass is one submission, three barriers and one pass. REFUSALS.md regenerated.
2026-11-18 03:13:48 -08:00
Anees Iqbal 6c8763164e harness: draws, a render encoder's triangles in both runtimes, and the draw_full and draw_2000 workloads
The harness timed compute alone. A plan's step can now be a draw (plan::Grid::Draw): its function
is the vertex function, its fragment function and target name the render pipeline state, made
once per vertex function, fragment function and target, and its bindings are the vertex
function's buffers. Consecutive draws into one target share one render encoder, whose one colour
attachment is cleared as the pass starts and stored as it ends; a dispatch or blit ends it. The
RenderCommandEncoder trait is setRenderPipelineState:, setVertexBuffer:offset:atIndex:, a draw
of triangles and endEncoding, implemented for the old runtime and the new.

Two workloads of the render library's colored_vertex and colored_fragment (Source::Render, made
for the first plan that names it): draw_full, 64 draws that each cover a 512 by 512 RGBA16Float
target, and draw_2000, 2,000 that each cover a 16 by 16 one, where each draw's own cost leads.
The target's every texel must be green after the first run, read out by the harness's texel
kernel. Plan::validate refuses a draw into a texture the plan lacks or made without RenderTarget
usage, and a draw with a blit or a binding other than a buffer (a new test).

Verified: to come in the lint and the timing jobs of this branch.
2026-11-18 03:13:47 -08:00
Anees Iqbal 3df4f73d9c rt draw tests: the triangle test runs the new target's upload in a submission apart before it counts
Legs 44820-44823 counted four barriers on every device where the test asked three: the upload
that moves the freshly made target to its home layout led the measured submission, with its own
barrier. The pass tests already run an empty command buffer first; this test now does the same,
so it counts the pass's two barriers and the segment's end alone.
2026-11-18 03:13:47 -08:00
Anees Iqbal 69f8f3bb7c rt draws: the render encoder's error links by the imported paths, and the stencil test's state no longer shadows its maker
The private-docs lint refused eight explicit link targets that the imports now resolve, and the
m2v_gpu build refused the stencil test calling state() after a local binding of that name.
Lint 44799 at 54bb771de4 failed on these alone; rebased onto b1eeec6981 (step 2 as landed).
2026-11-18 03:13:47 -08:00
Anees Iqbal b29fcccdc9 rt: the render encoder's draws, its state, and render states that number their samplers
A render encoder now draws. It holds Metal's render state (a pipeline state, the
vertex and fragment functions' buffers, bytes, textures and sampler states, one
viewport and scissor rectangle, cull mode, winding, a depth-stencil state, the
stencil references and the blend color) and records draw_primitives and
draw_indexed_primitives as one vkCmdDraw or vkCmdDrawIndexed each, setting the
dynamic state that changed and pushing each function's fields in the one push
range. Draws take no barrier, as Metal orders none within an encoder.

- render: a content's Draws (slots with accesses, push fields, vertex bindings),
  derived from the translator's interface; a state numbers its functions'
  samplers through the compute path's numbering (number_samplers), so
  new_render_pipeline_state takes sampler_ids, and RenderPipelineKind::Samplers
  goes; DrawInput refuses what a draw does not supply. Vertex strides are baked
  (the descriptor key holds them): VERTEX_INPUT_BINDING_STRIDE leaves the dynamic
  states, so a per-bind stride is refused by DynamicState. The line class's
  pipeline is made at its first draw, a first-use wait.
- pass: both store actions store, so a pass can end its rendering early (a memory
  barrier after a draw that wrote memory, or a copy a draw needs first) and begin
  it again with LOAD; Pass::begin serves both.
- PUSH_STAGES: one constant for the layout's push range and every push.
- Device::new_depth_stencil_state; IndexBuffer, Viewport, ScissorRect; Refusal
  VertexBufferOffset, IndexBufferOffset, ViewportNotFinite, StencilAttachment;
  Gap::Draw with DrawKind (Points, DepthTest, Viewport, AttachmentFormats,
  AttachmentRead).
- ring: a write answers its block buffer and offset, so set_vertex_bytes feeds
  fixed-function vertex input.
- harness: one sampler_ids for compute and render states.

The census of the gb and b2 render contents (m3-max-44704) set the scope: every
translated content reads only SlotGuestBase and ConstexprSampler fields, facts
AddressAlignment, DeviceAddresses and MovableStorageWrites, no parameter block,
writes no memory; 146 of 267 number samplers; 93 have one vertex binding.

Tests: host tests for the viewport mapping; device tests for triangles where
Metal's clip space puts them (direct, indexed through a scissor, through a
viewport; 3 barriers, no pipeline made, no bytes copied), the line pipeline made
once, stencil replace and test, a constexpr sampler sampling each texel,
stage_in from a buffer and from bytes, and the refusals and gaps. Not yet run.
2026-11-18 03:13:47 -08:00
Anees Iqbal 1b14efb96b matrix: the XTX leg's floors from 8 old runs, whose spread 4 runs did not cover
Three old-against-old pairs on the XTX (m3-max-45492, 45510, 45521) put a row past its 4-run floor
each time, in different rows: sampling at 1.258 against a floor of 1.160 in 45510, and
constexpr_sampling at 1.236 against 1.217 in 45521. Neither the desktop compositor (0.0% CPU across
45510) nor the clock state (sclk and mclk sampled in 45521: one wide row moved with sclk, two did
not) explains it, so the planner ruled the leg's floors measured again with 8 runs.

Measured with the same harness as the other legs (4cc7963005's), in m3-max-45546: 8 runs of
`harness --runtime old`, A B B A twice, each its own process on a fresh driver shader cache and
store; a row's floor is the largest of its 8 times over the smallest. Workload rows now over 1.10:
constexpr_sampling 1.259, frame_5cb 1.258, sampling 1.327, simd_reduce 1.243, image_filter 1.172,
narrow_ints 1.200, threadgroup_scan 1.111. Other legs are unchanged.

Verified: the matrix's Python tests in the check job named in the hand-over.
2026-11-18 03:12:27 -08:00
Anees Iqbal 1088859ec7 rt tests: the submit-infos grouping test counts a try only where no busy completion was seen
The test counted a try's groups where every busy command buffer's status was not yet
Completed once the mix was committed. The completion thread raises its progress
(`Done::completed`) and pokes the submit thread (`Work::completed`), which lets a held group
go, before it reads the calibration and retires the command buffer, which sets the status. So a
busy completion seen mid-mix could send the held group with only part of the mix in it (three
submit infos instead of two) while every status still read Committed: ms01's RTX 3090 counted
such a try (left 3, right 2).

The product follows its hold rule: a queue holds a group only while IN_FLIGHT of its
submissions are not seen complete, so where the group splits turns on when the completion
arrives. The test now reads the completion thread's progress before the busy work and after the
mix's last commit, and counts the try only where it did not move; the doc comment says why.

Verified: built and run under the check job named in the report.
2026-11-18 03:11:27 -08:00
Anees Iqbal f5927f1ff7 rt store tests: the directory walk counts nothing for a file the removal takes while it lists it
tests::cache::a_store_filled_past_its_cap_stays_within_it_and_moves_on panicked on the XTX leg of
the matrix at e060958855 ("its metadata: NotFound"): bytes_under() walks the store's directory
while the store's removal thread deletes the dead generation, so an entry read_dir listed can be
gone by its metadata(). The walk now counts such an entry as nothing (NotFound only; any other
error still fails), which can only count less than the directory held when the walk started, so
the test's bound while a removal runs (at most 1.5 times the cap on disk) stays a sound check,
and its checks after settle() are unchanged.

Verified: the rt store tests and clippy of rt's targets in the check job named in the hand-over.
2026-11-18 03:01:32 -08:00
Anees Iqbal 0bd215eee3 rt tests: the large-buffer file keeps the plain read and write, the release in flight and the encoded hold 2026-11-18 03:00:36 -08:00
Anees Iqbal 701469a516 rt tests: the given-back half of the encoded-hold test takes a length no other given-back block has 2026-11-18 03:00:35 -08:00
Anees Iqbal 65b2ff9023 rt tests: no take gets a block an encoded, uncommitted command buffer holds; one dropped uncommitted gives it back 2026-11-18 03:00:35 -08:00
Anees Iqbal b8ea4b388d rt tests: the release-in-flight test judges by the work's result, not by a count other allocations' frees move 2026-11-18 03:00:35 -08:00
Anees Iqbal 996d580620 rt tests: a buffer of over half a GiB given up while its command buffer is in flight reads its writes, its memory not freed before the work retires 2026-11-18 03:00:35 -08:00
Anees Iqbal 78cb3ec4a0 rt tests: the large buffers take the replayed frame's lengths, and its three (two Shared, one Managed) alive at once 2026-11-18 03:00:35 -08:00
Anees Iqbal 3913d3c39c rt tests: a buffer of most of a GiB read and written at its far pages, also made under other work, blitted into, and two at once
A stream-free repro for the gb r3 fault at frame 1137-1138 (the stream's
first buffer of 512 MiB to 1 GiB, faulting reads across ~959 MiB). In each
class, a block of the buffer's own length, the buffer made zeroed; the very
next commit reads its first, middle and last pages through its address,
then a dispatch writes them and they read back (and through the mapping
for Shared). Variants: made while a 64 MiB fill is in flight on another
queue; a blit into the pages; two such buffers alive at once.
2026-11-18 03:00:35 -08:00
Anees Iqbal 813dd5cfd7 matrix: jobs sized from whole builds' peaks, and a job short of RAM runs again with twice its room up to the default
The UHD leg of matrix e060958855 lost its Windows build twice to memory:
45442 at 3 GiB (137), then the retry 45471 at 6 GiB (rustc-LLVM out of
memory, 137), and the leg failed with no tests run. The sizing took the
last three runs' peaks, incremental builds in a kept workspace that peak
far below a build of most of the tree, and a job short of RAM ran once more
only, at twice its room.

Now a job's RAM is 1.3x the largest peak of the last three runs that
started in a fresh workspace (each run records whether it did), else the
kind's default; minutes still follow the last three runs of either form.
A job short of RAM runs again with twice its room until it reaches the
kind's default (16 GiB for winbuild).

Verified: scripts/matrix tests, 39 OK, run locally. The new test_matrix.py
fails on the old code (it sized from incremental peaks and retried once:
dispatches 4 and 8 GiB, not 4, 8 and 16).
2026-11-18 02:57:17 -08:00
Anees Iqbal 17ce150bbe rt store: a lookup reads no state
What: a lookup read the 24-byte state record (young's number) from the state file each time.
The store now keeps young's number as it last read or wrote the state: read at open, refreshed
by every update under the lock, and only growing. A lookup reads it from memory.

A move to the next generation that another store on the directory made is seen at this store's
next write. Until then its lookups try the generations it knew: a file the other wrote into the
new young is a miss, and a hit in what is now old is not moved into young. Both cost a miss at
worst, and every file still checks itself. In rt a miss is followed by a write in nearly every
case (a lowering or refusal kept; a pipeline's data kept by the reaper, unless more than 64
caches wait for it), and a write reads the state under the lock.

Why: the planner asked for the second render state's own time on the UHD to come down. Probe
job m3-max-45357 (homelab-mac-mini-2018, NTFS) split its 319 us of store lookups: about 50 us
were the state record read once per lookup, over three lookups.

Test: a_lookup_reads_no_state_and_sees_another_stores_move_at_its_next_write counts the state
reads of 20 lookups (none), and shows a move another store made seen after the next write.
2026-11-18 02:53:52 -08:00
Anees Iqbal 3cf9519fce matrix: the 1002:1900 leg's floors, measured as the other seven were
um870's 780M (1002:1900) had no column, so its rows had a floor of 1. Measured with the harness of
4cc7963005 as the other legs were (m3-max-45430): 4 runs of `harness --runtime old`, A B B A,
each its own process on a fresh driver shader cache and store; a row's floor is the largest of
its 4 times over the smallest. Its workload rows over 1.10: burst_160 1.133, frame 1.215,
frame_5cb 1.212; alu is 1.017.

Verified: the matrix's Python tests in the check job named in the report.
2026-11-18 02:42:48 -08:00
Anees Iqbal 56efbd0e13 matrix: the floors measured with the mean statistic on seven legs; the seeded-floor stopgap deleted
scripts/matrix/floors.tsv held floors seeded from old-runtime runs under the nearest-rank
statistic, some of them the old runtime's paired completions read as a fast run (alu 22.066 on
the 780M leg, 19.640 on the Iris). Measured again with the harness of 4cc7963005 (a row's time the
lowest mean of its windows of 10 timed runs, an untimed run after each gauge read): 4 runs of
`harness --runtime old` per leg, A B B A, each its own process on a fresh driver shader cache and
store, a sized row at the first run's size; a row's floor is the largest of its 4 times over the
smallest. Legs: 1002:15bf (gem10's 780M, m3-max-45422), 1002:699f (m3-max-45423), 1002:744c
(m3-max-45424), 10de:1e87 (m3-max-45425), 10de:2204 (um870's 3090, m3-max-45426), 8086:3e9b
(m3-max-45437) and 8086:a7a0 (m3-max-45427). 1002:1900 (um870's 780M) is not measured yet; a leg
the file does not list keeps a floor of 1. The seed's 1002:15bf column came from runs on
1002:1900.

With the table measured, the seeded-floor naming goes: SEEDED_FLOOR_OPEN, seeded_floor() and their
uses in harness_budget, its test, and VALIDATION.md's sentence on the seed.

Verified: the matrix's Python tests in the check job named in the report.
2026-11-18 02:41:31 -08:00
Anees Iqbal 81fa11a105 rt pool: a commit or submission during an idle allocation's free starts the quiet time again where the free ends
The quiet clock was stamped when a commit or submission began. A driver
may hold a submission for a whole vkFreeMemory (NVIDIA in Thunderbolt
enclosures: a 64 MiB free took 57 ms on the 2080 and held a submission
52 ms, probe job m3-max-45391), so when the free ended the device already
looked quiet for longer than 20 ms, and the block-maker thread could start
the next free at once, back to back with the program's next submission.
After each free, where a commit or submission began during it, the quiet
time now starts again at the free's end.

The device test that holds a free open now holds it 30 ms past the
submission it counts, and asserts the next free begins at least 20 ms
after the hold ended. Without the change that free begins as soon as the
hold ends.
2026-11-18 02:35:05 -08:00
Anees Iqbal 5abbd52c0e matrix: the memory pool's blocks gauge fails only on a rise between iterations 100 and 200
The matrix at cbd4644463 failed long_4cb's blocks gauge on the XTX, 2080
and 3090 (9 at iteration 100, 8 at 200). The cause, from the quiet probe
(each idle free logs the time since the last commit): the pool frees an
allocation an earlier workload left idle once the most bytes in use over
its window falls and the device has been quiet for 20 ms, and long_4cb is
the first row after the earlier rows' peak whose runs leave 20 ms gaps
between submissions. On the RTX 5080 (b5080 entry quiet5080, q10
0c0e50688a / q3 6b8cd2b793, 2 runs each) the 10 s window freed a 16 and
two 64 MiB allocations 6.5 and 7.5 s into long_4cb (11 -> 8), the 3 s
window the two 64 MiB ones 0.53 s in (8 -> 8); every free in every run on
the 5080, XTX (m3-max-45392) and 2080 (m3-max-45391) began 20.0 to 52 ms
after the last commit, so the quiet clock saw every commit.

Per the planner's ruling, the pool's gauges (blocks) now fail only if
they rise between @100 and @200; @drop still has to be 0, and every other
gauge stays flat. Verified: scripts/matrix tests, 37 OK, run locally; the
new test fails without the change (a fall of blocks is a problem there).

The commit before this one (1f41099948) shows each row's GPU p50
(store2's harness-gpu-<runtime>/<row> records, parked) beside its time
in the budget's lines and in a list of every row that run and show print
under each leg, and names a row that passes only on a seeded floor over
1.10. Its tests (36 OK at that commit) pin the line formats.
2026-11-18 02:32:53 -08:00
Anees Iqbal 5422cf1825 matrix: every row's GPU p50 beside its time; rows passing only on a seeded floor over 1.10 named 2026-11-18 02:32:53 -08:00
Anees Iqbal e060958855 rt: one StageEntries per device, read by every compute and render creation
What: rt made a fresh StageEntries at three sites:
- every compute creation (Compiled::of);
- the reaper's emulated-variant lowering;
- every render creation (new_render_pipeline_state).
So every creation decoded its module again (the bitstream, the bitcode records and the AIR
metadata ABI) and specialized its stage again. The old runtime gives every creation of a device
one object (pipeline/memo.rs). Core now holds one, and the three sites read it.

The object is the translator's own and is bounded: 32 specialized entries in 64 MiB and 4 module
decodes in 32 MiB, least recently used first. Device::new and the old runtime's use are
unchanged. The translator gains StageEntries::held(), which reads entries, decodes and bytes held.
rt gains two gauges, Gauges::stage_entries and Gauges::stage_entry_bytes. They are set after each
lowering and render creation, zeroed at teardown, and printed on the replay player's end lines as
stage_entries= and stage_entry_bytes=.

A new translator test, an_object_filled_past_its_bounds_keeps_only_the_most_recent, asks one entry
at 40 call-stack depths. It checks that the object holds at most 32 entries and one decode within
its byte bounds, that the latest depth is found again, and that the first depth, evicted, is made
again. Before this, no test filled the object past its entry bound.

Why: store2 timed rt's lowering at 1.5-2.0x old's for the same function. Probe b913909727, on
store2's 0e215f2c80, ran job m3-max-45251 on homelab-gem10-1 (lowering us, median of 3):
- first state: old 711, rt fresh 1144, rt with one object 586;
- second state: old 548, rt fresh 876, rt with one object 434.
The counts showed rt fresh reading one module decode per creation, while old and the shared arm
read it once and copied it after.

Verified: see the jobs named in the landing message.
2026-11-18 02:28:56 -08:00
Anees Iqbal 4cc7963005 harness: an untimed run after each gauge read, so the next timed run waits for a run in flight
The timed loop reads the gauges after its 100th and 200th runs with the device idle. The 101st
run's wait was then for the 100th, already complete, so it timed the encoding alone: on ms01's
Iris Xe 61 us of waves' 2191 us of GPU a run, 196 us of zero_products' 4367 (job m3-max-45380,
probe cb18fded59, every timed wall in order). A median of 10 runs ignored that one short run; the
lowest mean of windows of 10 takes it: the window holding it read 6% under every other unpaired
window (waves 2090, zero_products 4115 against GPU times of 2191 and 4367), on every runtime. An
untimed run after the read puts two runs in flight again, and the next timed run waits for one
the GPU was running. Without the 101st run, the same walls' lowest window mean is 2188 and 4377.

Verified: the arithmetic above on job m3-max-45380's sequences; build, clippy and the harness's
tests in the check job named in the report.
2026-11-18 02:24:58 -08:00
Anees Iqbal d4fe90ab10 harness: each plan workload's GPU time at the 50th percentile as a harness-gpu- record
The matrix shows a row's GPU time beside its wall time: `M2V-MATRIX time
harness-gpu-<runtime>/<row> <us>`, a run's GPU time (its first command buffer's GPUStartTime to
its last's GPUEndTime) at the 50th percentile of the timed runs, scaled to the base size for a row
the device sizes, as its matrix time is. Printed once per row and process, and not for a workload
whose runs wrote no GPU time. A time record under its own prefix, as the matrix's owner asked: a
metric must be an integer count and a rise of one fails its leg, and a key under harness-new/
would be judged against harness-old/; harness_budget, the re-time selection and its sed match
none of harness-gpu-, and the matrix parks it for the cross-GPU time rule.

Verified: the check job named in the report (build, clippy, the harness's tests, rustdoc).
2026-11-18 02:24:58 -08:00
Anees Iqbal 000dfa9a07 harness: a workload's steady time is the lowest mean of its windows of 10 runs
A workload's time was the lowest nearest-rank median of its timed runs' windows of 10. Where a
runtime reports two runs' completions together, one run's wait takes both runs' GPU time and the
next run's wait returns at once, and the nearest-rank median of 10 such alternating runs is the
5th sorted value: the short wait's. On ms01's Iris Xe the old runtime's grouped submissions did
this in whole-harness runs: zero_products recorded 174 us while every run's GPU time was 4367 us
and its 200 timed walls had p10 174, p50 4388, p90 9454 (job m3-max-45343, probe f5be885e3f);
narrow_ints, constant_private and image_filter likewise, on the old runtime only. A window's mean
is the time its 10 runs took over 10, which the pairing does not move; the lowest window still
leaves out a window a clock drop or a hiccup slowed. Fewer than 10 runs take their mean.

Every matrix time record goes through steady (matrix_time, the creation rows), and the matrix's
re-timed pairs are the same records, so one statistic serves both.

Verified: the new unit test's alternating 9454/174 runs give 4814 where a window's nearest-rank
median is 174; the existing cases keep their values. Build, clippy and the harness's tests in the
check job named in the report.
2026-11-18 02:24:57 -08:00
Anees Iqbal 0a894e85fe rt arrays tests: set 1's arrays fill past their capacity through one grant of each class
The index arrays had no fill-past-capacity test. On every device of the cfg's
kind, one grant of the sampler class's whole range takes a sampler state at
each of its 3,999 indices, and one grant of the storage-capable class's whole
range takes a 1x1 shader-write texture at each of its 4,095. Then 128 of each
are dropped one at a time and made again at the index they left, as a
consumer reuses an index: 4,127 sampler states and 4,223 storage-capable
textures in all. Every make is unwrapped, so an index refused as in use
fails the test. The descriptor-slot gauge counts the class's capacity while
the arrays are full and the reuse runs, is zero once the objects are gone,
and the grants are released; after the device, the sampler, texture and
descriptor-slot gauges are zero.

Verified: the next job runs it on lavapipe, then on um790's GPUs from the
archives.
2026-11-18 02:23:46 -08:00
Anees Iqbal 2f362d5f66 replay: a texture its descriptor marks outside takes none of the program's IDs; a gpuResourceID record of one stops the play 2026-11-18 02:22:45 -08:00
Anees Iqbal f1ae24f38d replay: the skipped objects' IDs leave the differing count, beside the compute pipeline states' gap
The new runtime's backend skips render pipeline and depth-stencil states, so nothing in its play reads their IDs; b3's play counted 8,082 of them as differing. It now counts them (skipped_resource_ids) and command-replay leaves them out of differing_ids, as it leaves the compute pipeline states' typed gap. The id lines stay.
2026-11-18 02:18:39 -08:00