Skip to content

Shaders: share verified compute blobs across preparation worker counts - #3086

Merged
Prime1997 merged 1 commit into
xcl-dev:mainfrom
Royalflamejlh:fix/prepare-compute-receipts
Nov 28, 2026
Merged

Prime1997 merged 1 commit into
xcl-dev:mainfrom
Royalflamejlh:fix/prepare-compute-receipts

Conversation

@Royalflamejlh

@Royalflamejlh Royalflamejlh commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

The launch pass keeps a receipt of the compute blobs it validated on this adapter and driver (warm_blobs::Verified), so a later launch takes them without validating them again. The receipt's file name hashed XCL_PRECOMPILE_SLICE, the worker's i/count, into its key. A launch with another worker count (another machine, a different XCL_PREPARE_WORKERS, or the count #2705's fix changes) found none of its receipts and validated every blob again.

This keeps one receipt per native identity (verified-compute-v2-<native>.bin), imports the v1 files of every slice of the same identity once, merges concurrent writers under a lock file before it replaces the receipt, and saves every 64 new entries so an interrupted pass keeps what it validated (a failed save is tried again after 64 more).

What is in it

  • crates/xcl/src/shaders/warm_blobs.rs: the v2 receipt, the v1 import, the locked merge and the checkpoints; a test with two workers opened before either writes, a v1 slice file to import, another device's identity, and the checkpoint a dropped worker leaves.
  • README.md: one line.

Tested

  • Linux, Wine 11.21 Staging, Mesa lavapipe (no GPU), Rust 1.98.0, release, x86_64-pc-windows-gnu: cargo test -p xcl --lib warm_blobs -- --test-threads=4 at fdbac840: 3 passed, 0 failed, 0 ignored (1408 filtered out), with a_failed_checkpoint_is_tried_again_after_64_more_entries

Regression run

  • not made: scripts/smoke.ps1 needs Windows (see Not tested).

Not tested

  • Windows; the whole suite; scripts/smoke.ps1 on main and on this head; a launch with and without it, to count the validations it saves.

AI use

  • The change was written with OpenAI Codex (the model is to be added by the author). Claude Code (Claude Opus 5.5) ran the tests and wrote this description.

@Royalflamejlh
Royalflamejlh marked this pull request as ready for review November 28, 2026 02:45
Royalflamejlh added a commit to Royalflamejlh/xcl that referenced this pull request Nov 28, 2026
Royalflamejlh added a commit to Royalflamejlh/xcl that referenced this pull request Nov 28, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@andrewDoing

Copy link
Copy Markdown
Contributor

I checked the checkpoint failure path at head f147360f with a deterministic Windows Rust probe. It uses the exact receipt open/record/save/flush/merge methods, real per-receipt file locking and disk reads, and a mocked final writer that either succeeds or persistently fails. Each arm records 1,024 distinct synthetic keys.

Final writer Checkpoint attempts Bytes serialized
Success 16 209,024
Persistent failure 961 12,554,504

After the first failed checkpoint, the dirty count remains at or above the threshold, so every subsequent record serializes and retries while taking the locks. When the writer was restored, an explicit final save succeeded and all keys, including the last, were present on reopen in both arms.

This is failure-path amplification, not observed title timing or evidence of data loss in the successful final-save control. A separate next-attempt threshold or backoff could bound retries while keeping unsaved entries dirty and preserving the final save; any change needs to retain recovery semantics. The final replacement failure was injected in the probe, not produced by a real filesystem failure.

AI use: OpenAI Codex with GPT-6.2 Astra built and ran the probe; Codex reviewed and prepared this report.

@fromthemoonx

Copy link
Copy Markdown

Windows run (listed under Not tested): the whole suite passes. The new test passes 40 of 40, and it catches each part of the change when that part is removed.

Tested: f147360 (its base is current main 753e8b1, so head = merged). RTX 3060 12 GB (driver 610.88), Ryzen 7 5700X, Windows 11 Pro 26300, Rust 1.100.0 MSVC, debug.

result
cargo test --workspace --no-fail-fast -- --test-threads=4 1513 passed, 0 failed, 47 ignored; 25 SKIPPED lines (no wave64, refused per-lane f16/f32 forms, heap_window_out_of_memory_falls_back_to_the_switch_form)
the 2 warm_blobs tests alone, 40 runs each; shaders:: (41 tests) at --test-threads=8, 40 runs 40 of 40 each; 40 of 40

Scratch mutations, 10 runs of each test (warm_receipt_matches_only_the_validated_blob_and_layout passes under all four):

mutation workers_reuse_previous_slices_and_merge_concurrent_checkpoints
merge_and_save does not read the saved receipt before writing fails 10 of 10 (merged.contains(&[2, i, 0]) && merged.contains(&[3, i, 0]))
lock.lock() removed fails 10 of 10 (same assertion)
no checkpoint at 64 unsaved entries fails 10 of 10 (contains(&[4, 63, 0]))
v1 slice files not imported fails 10 of 10 (a.contains(&first))

So on Windows the lock holds between two handles in one process, and the replace under it works.

Not tested: a launch with and without the change (no title here), a release build.

AI use: Claude Code (Claude Opus 5.5) ran the tests and the scratch mutations and wrote this report.

Keep the validated blobs under the native preparation identity. Import previous worker slices, merge concurrent updates under a file lock, and checkpoint successful validations during a long preparation.

A checkpoint that fails is tried again after 64 more entries, not on every one: a receipt that cannot be replaced made each later record take the lock and write the whole list again (961 attempts for 1,024 entries in a probe on xcl-dev#3086).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Royalflamejlh
Royalflamejlh force-pushed the fix/prepare-compute-receipts branch from f147360 to fdbac84 Compare November 28, 2026 03:16
@Royalflamejlh

Copy link
Copy Markdown
Contributor Author

Confirmed and fixed in fdbac840 (squashed into the PR's commit): after a failed checkpoint, record tries again only once 64 more entries are unsaved (Entries::failed_at), and a successful save clears it. The final save still writes whatever is unsaved.

New test a_failed_checkpoint_is_tried_again_after_64_more_entries: a directory sits where the receipt goes, so its replacement fails; after 100 records the only attempt was at 64; with the directory gone, the next attempt at 128 saves all of them. With the old unsaved >= 64 it fails (left: 100, right: 64: an attempt on every record from 64 on).

cargo test -p xcl --lib warm_blobs -- --test-threads=4 under Wine 11.21 (Linux, no GPU, Rust 1.98.0, release): 3 passed, 0 failed.

AI use: Claude Code (Claude Opus 5.5) wrote the fix and the test, ran them and wrote this reply.

Royalflamejlh added a commit to Royalflamejlh/xcl that referenced this pull request Nov 28, 2026
…64 more entries

# Conflicts:
#	crates/xcl/src/shaders/warm_blobs.rs
@andrewDoing

Copy link
Copy Markdown
Contributor

I retested the checkpoint retry fix with a real Windows replacement failure, comparing original f147360f and updated fdbac840. The probe uses each revision's exact receipt methods and production temp-create/write/rename/cleanup path, with two test-only counters.

Each run seeded one key, then held the existing receipt open with read/write sharing but without delete sharing while recording 1,024 new keys. Under that lock:

Revision Replacement attempts Bytes serialized
Original 961 12,577,568
Updated 16 209,408

Healthy controls were 16 attempts / 209,408 bytes on both revisions. The locked on-disk receipt remained at its seeded key; after closing the handle and explicitly saving, all 1,025 exact keys were present on reopen in both cases.

This verifies bounded checkpoint retries and eventual explicit-save recovery under the tested sharing violation. It does not measure retail startup time or other filesystem failure modes.

AI use: OpenAI Codex with GPT-6.2 Astra ran the tests; Codex reviewed and prepared this report.

@Prime1997
Prime1997 merged commit e429936 into xcl-dev:main Nov 28, 2026
1 of 3 checks passed
@thehollowedone

Copy link
Copy Markdown
Contributor

Independent Windows check of #3086 head fdbac840, completed as the PR merged. Windows 11 build 26300, RTX 3080 Ti (driver 621.35), rustc 1.99.1 MSVC, DXC/DXIL 1.8.2502.11.

Tested

  • cargo build --offline --locked -j 4 --workspace: passed.
  • cargo test --offline --locked -j 4 --workspace --no-fail-fast -- --test-threads=4: 1,513 passed, 1 failed, 47 ignored, with 25 SKIPPED GPU notices. All three shaders::warm_blobs::tests passed, including the new failed-checkpoint retry test.
  • The sole failure was gpu::recomp::pso::shader_cache_tests::console_mesh_caches_hlsl_compute_pass_in_memory_and_on_disk (cached_only console_mesh hit: "DXIL not compiled yet"). I ran that fully qualified test alone on the PR's untouched parent 753e8b1a: 0 passed, 1 failed, 0 ignored, with the same error. The full-suite failure is therefore not introduced by this PR.

Regression run
Clean cargo build --release --offline --locked -j 4 -p xcl builds, same local title, adapter, XCL_PREPARE=0, XCL_ADAPTER=nvidia, and 60-second duration in both runs. These are the blocks printed by scripts/smoke.ps1:

xcl-smoke v1
commit: d85f2c6c34a7a349def5893d9af22bb79614e774
gpu: NVIDIA GeForce RTX 3080 Ti
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1364 (PresentX 1364)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14286 MB
xcl-smoke v1
commit: fdbac840ba68b1706136564fbcfa8ddffb1d5b8d
gpu: NVIDIA GeForce RTX 3080 Ti
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1672 (PresentX 1673)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14169 MB

The pair is a runtime regression check, not a measurement of this PR's startup saving: XCL_PREPARE=0 bypassed shader preparation, and the two commits include other upstream changes. No input was supplied, so progress beyond the initial screens was not verified. I did not run a prepared title launch or measure receipt reuse across different worker counts on this hardware.

AI use: Codex (GPT-6.2 Sol) ran the builds, suite, parent control and paired smoke, checked the outputs, and drafted this report.

@JJAutoCompare

Copy link
Copy Markdown

Tested — post-merge verification of the final PR head

I reran the pinned CPU test executable for fdbac840ba68b1706136564fbcfa8ddffb1d5b8d on native Windows 11 25H2 build 26200.9974, AMD Ryzen 7 3800X, Rust 1.100.1 MSVC x64 debug. The binary used the verified Git archive with a private test fixture appended to the unchanged production module. warm_blobs.rs has the same Git blob in merge commit e429936c10a5b8aa09470ff99dfc8c8d3d8c56fd. The executable was built from the PR head.

  • <libtest.exe> --exact shaders::warm_blobs::cross_process_probe::native_receipt_child --nocapture --test-threads=1 ran as two writers and a fresh reader. Both writer PIDs opened empty snapshots before the harness released them. Each recorded 65 disjoint keys, with zero unsaved entries after its automatic 64-key checkpoint and again after its final explicit save. The reader found the exact 130-key union and zero keys for a second synthetic identity. A separate parse checked 130 unique rows in the 3,128-byte receipt.
  • <libtest.exe> --exact shaders::warm_blobs::tests::workers_reuse_previous_slices_and_merge_concurrent_checkpoints --nocapture --test-threads=1 passed as the stock merge control.

4 passed, 0 failed, 0 ignored, 0 runtime skips. All four native processes and the harness exited 0.

Not tested

Simultaneous lock contention, forced write failure, real driver identities, GPU execution, retail launch, performance, and the full workspace suite.

AI use

T3 Code through the Codex harness (gpt-6.2-sol) verified the source and executable, ran the native processes, checked the receipt and wrote this report.

Royalflamejlh added a commit to Royalflamejlh/xcl that referenced this pull request Nov 28, 2026
main gained 345 commits since 753e8b1, most of them bmjask's stack (xcl-dev#2959),
plus xcl-dev#2872, xcl-dev#3085 and xcl-dev#3086 from this branch. Conflicts, per PR:

- xcl-dev#2404 + xcl-dev#2633 (split chained ExecuteIndirect): main's xcl-dev#2959 took both over
  (ed98461, a05fbc4, 8626d5b: IndirectBuild/IndirectChain on a CBV root,
  one-command slicer, separate cache namespace). Main's side kept in
  dispatch_chain.rs, pso.rs (slicer, command signature, chain root),
  bind.rs (ExecuteIndirect path), device_x.rs (signature traits),
  pso_async.rs (no background whole build, so no build_waited_on), real.rs
  (ComputeBuild, driver_cache names) and shaders.rs (blob names). Dropped
  with them: slab_count, record_slicer, abi_signature_id names, the direct
  root-CBV constant blocks, list_x::predicated, the split.rs/runner.rs
  ExecuteIndirect test and the list_x chain-scratch test. Not in main: xcl-dev#2404
  ran the pieces before any whole form was built; main runs the whole form
  (built on the title's thread) until the indirect set is ready.
- xcl-dev#2707 (allocator reclaim): main has it (31930d8, 057f463, 8e7b566).
  alloc_pool.rs is main's, with xcl-dev#867's changes on top; bind.rs takes main's
  native_backing; xcl-dev#2707's tests and bind::push_uma_for_test go.
- xcl-dev#867 + xcl-dev#2477 (Wine vtables and fences), adapted to main's new code:
  real.rs keeps the in-place patching, UnadoptGuard and FenceProxy beside
  main's native_queue_* helpers; guards in cl_reset, bind_pipeline_exact,
  clear_pipeline_exact, reset_pc_allocator, the title ExecuteCommandLists
  closure and native_queue_execute; Signal/Wait unwrap the title's fence
  (also in native_queue_signal/wait); list_x guards in
  reset_reserved_segment and KickoffX's submit closures; create_raw_fence
  for main's new internal fences in alloc_pool.rs (SubmissionGate),
  title_textures.rs, present.rs, vram.rs, sparse.rs, cpu_writes.rs; tests
  as xcl-dev#2477 had them; runner.rs is main's plus submit_list.
- xcl-dev#1803 (heap addresses): kept, carried into main's PreparedSplit and
  PreparedAbiState (prepared_abi_io takes the heaps).
- xcl-dev#1368 (NodeMask 0): kept in compute_container, before main's per-node
  blob names, so names and pipeline use node 0.
- xcl-dev#1860, xcl-dev#2082 (cfg.rs, module/opt.rs): cfg.rs is 1567f72's version
  (xcl-dev#1860 on main's Succs); opt.rs is that plus xcl-dev#2082's arm and test.
- xcl-dev#2229 (rodata): kept through main's kernel.rs entry points;
  translate_entry_rodata loses wave32_only as main dropped per-GPU tables
  (3cde0cc); pso.rs and coverage.rs call it with main's options
  (no_remap, split for graphics); recomp Options keeps rodata and no_remap.
- xcl-dev#1975: kept in emit.rs and lower_valu.rs; its mesh barrier guard and its
  test dropped, main's wider guard (2ca9127) covers it; the now-unused
  lower::has_non_uniform_barrier goes.
- xcl-dev#2070 (64 MB stacks): pso_async::WORKER_STACK on main's worker, helper
  and preload threads; shaders.rs's piece threads on worker_thread.
- xcl-dev#2551 (whole forms prebuilt): split_whole_roots(false) is DirectChain,
  so the precompile builds every split program's whole form; main built it
  only for programs an earlier run used through ExecuteIndirect.
- xcl-dev#688 (dxc.rs imports), xcl-dev#2762 (host.rs log line), xcl-dev#3090 (list_x tests),
  arch/window-title-commit (present.rs with_commit on main's
  compiling_text), README.md: both sides.
- list_x.rs: main dropped title_textures::list_reset; main's side.
- sparse.rs, vram.rs: main's quarantine_tiles_for and per-device retire
  state, with create_raw_fence.
- xcl-dev#3090, xcl-dev#3092 tests: runner::device and Uma::block_len added from
  nvidia-dev (5 and 12 lines) so the lib tests compile.
- xcl-dev#751: its commit is already in main (b84e037, via xcl-dev#2844); it leaves the
  README table with xcl-dev#2404, xcl-dev#2633, xcl-dev#2707, xcl-dev#2872, xcl-dev#3085 and xcl-dev#3086.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Prime1997 pushed a commit that referenced this pull request Nov 28, 2026
Brings nvidia-dev's low-VRAM memory model, pipeline preparation and NVIDIA fixes into main,
carried on main's submission rework (#2959-#2965, #3086, #3149) and pipeline libraries (#3100).

Each of the 33 files that conflicted was 3-way merged from 4577f09 and resolved per hunk by
job. Where both sides did one job two ways, one implementation stays and the other's callers
use it. RESOLUTIONS.md lists every dropped mechanism with its PR, the replacement and the reason.

Kept from main whole:
- submission plan, receipts and native queue slots;
- retained pipeline generations;
- DriverBlobs exact-generation blob cache;
- preparation corpus and pipeline libraries;
- shared-view epochs and the queue-lifetime registry.

Brought in from nvidia-dev:
- 16 windows, mirror tiles, lazy sparse, pack pools, texture level pages and the mixed UMA
  driver window;
- the used-only startup preparation and preparation worker processes;
- driver-blob keep rules: small-program disk keep, compute threshold, per-adapter file names;
- dispatch folding and the split-wave64 LDS order;
- late_release holding;
- the watch, submit_cost, capture and look_stats diagnostics.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants