Skip to content

compute: publish every compute pack record across numbered parts - #3484

Merged
R0Y00 merged 2 commits into
R0Y00:mainfrom
Not-Saii:claude/compute-pack-parts-3473-916534
Nov 30, 2026
Merged

R0Y00 merged 2 commits into
R0Y00:mainfrom
Not-Saii:claude/compute-pack-parts-3473-916534

Conversation

@Not-Saii

Copy link
Copy Markdown
Contributor

Fixes #3473. Follows #3091.

compile_dxil --prepare-compute-pack left out every record past 256 MiB. A pack is now written as numbered parts, each under that limit, so every record is published. The shared cache lookup and its 256 MiB cap are unchanged.

Writer (build_compute_frontend_pack)

  • When the next record would cross the limit, a new part is started. Records stay in the sorted request order.
  • Part 0 keeps the name compute-<entry>.pack. Later parts are compute-<entry>.<n>.pack.
  • Every part starts with a 72-byte header: part count, record count, and the id of the next part (zeros in the last part).
  • Part 0 is published under pack_version. Part n > 0 is published under the digest of pack_version and its payload's SHA-256, and the previous part names that id. So the existing lookup refuses a missing, stale or swapped part without hashing a payload twice.
  • Parts are written last to first, with part 0 last. Parts left from an earlier, larger pack are removed before part 0 is published. Nothing is written or removed when every request fails, so an existing pack is kept as before.
  • Only a single record over the limit still fails with invalid compute pack size.
  • pack_version moves to prepared-2.
  • The limit is a writer parameter (part_limit, default compute_pack_part_limit). Only the test lowers it. The command line is unchanged.

Reader (ComputeFrontendPack::load; the runtime caller is unchanged)

  • Loads every part named by the count into one record map.
  • Refuses the whole pack, as it refuses a damaged one today, when:
    • a part is missing, stale or swapped;
    • the part count differs between parts;
    • a key repeats across parts;
    • a part has trailing data;
    • a part file exists past the count.
  • X2W_NATIVE_COMPUTE_PACK still names part 0.

Tests (new native_compute_pack_parts, tests/cmake/native_compute_pack_parts.cmake)

The fixture is 13 source-built requests: 1 prepared and 12 refused. The prepared record sits between refused ones in the sorted order. native_compute_pack_check gains three modes: --build (the writer with a lowered limit), --same (per-key comparison of two packs) and --old (writes a prepared-1 file).

  • Positive.

    • The test sets the limit to the largest record plus the header (9401 bytes here). That gives 3 parts, which match the test's own greedy split exactly.
    • Result: prepared=1 unsupported=12 errors=0.
    • The parts' records, concatenated, are byte-identical to the unlimited pack's.
    • The existing checker accepts the parts against the live frontend (other=0).
    • --same gives the same lookup result for all 13 keys as the one-part pack built by compile_dxil with no limit.
  • Single record over the limit (limit − 1): prepared=0 unsupported=12 errors=1, with exactly one invalid compute pack size.

  • Negative controls. Each is refused with the stated message, and the restored pack loads again:

    Control Message
    missing middle part missing, stale or damaged compute pack
    a valid part 1 from another pack missing, stale or damaged compute pack
    key duplicated into the last part invalid compute pack record
    trailing byte in part 1 trailing compute pack data
    part 1 claims one part more than part 0 invalid compute pack part count
    last part names a next part invalid compute pack part
    stale extra part past the count stale compute pack part, and --build removes it
    prepared-1 pack under this build's revision missing, stale or damaged compute pack, and a rebuild loads
    • Each refusal is matched against the checker's whole stderr line, not a substring.
    • The crafted files are re-chained with correct checksums and ids. The test first checks that its chain writer reproduces the writer's bytes, so each control differs only as intended.
    • A one-part rebuild in the same cache removes the other parts. Its part 0 is byte-identical to the unlimited pack.
  • Revert controls (run locally, not committed):

    • Writer split reverted (a crossing record fails, as before; the limit parameter kept): --build gives prepared=0 unsupported=12 errors=1, with the crossing record reported as invalid compute pack size and left out.
    • prepared-2 reverted to prepared-1: the prepared-1 file passes the version check and is parsed as the new layout. It fails only because a request-key word exceeds the count bound (invalid frontend cache count).
cmake --build --preset dev --target compile_dxil native_compute_pack_check
ctest --preset dev --no-tests=error -R '^native_compute_pack(_parts)?$'

Result: 2/2 passed (native_compute_pack, native_compute_pack_parts). Windows 11 build 26300, MSVC (VS 2022, dev preset), Windows SDK 10.0.26100, Python 3.12. No GPU used. native_compute_pack_hardware was not run. The PR check skips native_* tests, so this local run is the evidence for both until a full workflow run.

Measurement. Counts only. None of my own captures was rerun. The synthetic test above is the evidence. A rerun of the 2,689-request set from #3472, before and after, would show the 28 left-out records published as a second part.

Interaction with #3472 (open). Both change build_compute_frontend_pack.

AI-assisted.

🤖 Generated with Claude Code

Not-Saii and others added 2 commits November 29, 2026 19:15
A pack file holds at most 256 MiB, the limit the shared cache lookup reads.
When the next record would cross it, build_compute_frontend_pack now starts
compute-<entry>.<n>.pack instead of leaving the record out. Part 0 keeps its
name and records the part count; each part names the next part's id, so a
missing, stale or swapped part, a key repeated across parts, trailing data or
a part left past the count refuses the pack. Parts are written last to first,
leftovers from a larger pack are removed, and pack_version moves to
prepared-2. Only a single record over the limit still fails.

The part limit is a writer parameter so native_compute_pack_parts crosses it
with 13 source-built requests.

Refs R0Y00#3473

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…essages

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@Leyukaka Leyukaka left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve at 8d25453a. Reviewed by reading the diff only; nothing was built or run here.

Checked: part naming and the split are deterministic (sorted requests, greedy); a record goes into exactly one part, none lost or duplicated at a boundary; the single-record bound part_limit - 72 - 80 keeps every file within lookup's 256 MiB cap; the next-id chain and the part-past-the-count check refuse a missing, stale or swapped part; the reader and the prepared-2 bump refuse old packs; nothing changes when X2W_NATIVE_COMPUTE_PACK is unset.

Should:

  • tests/native_compute_pack_check.cpp:30 passes the limit as the 4th positional argument, where #3472 adds unsigned jobs = 1. If the rebase misses that call it still compiles (size_t to unsigned) and the limit becomes the thread count. Suggest landing #3472 first, then the signature (requests, cache, entry, jobs, part_limit) with the test passing both.
  • A publish or fs::remove that fails after a later part has been replaced leaves no loadable pack: the old part 0 then names a part whose id differs. That is safe (the load is refused and every request is a miss), but the doc only covers "every input fails"; one sentence would do.

Nits:

  • The loader keeps the records of all parts, so the loaded pack is no longer bounded by one 256 MiB file. The doc could say so.
  • tests/native_compute_pack_check.py:177 matches stale compute pack part as a substring, while the PR body says every refusal is matched against the whole stderr line.
  • lookup compares a part's stored id with the id named by the previous part, but the id is not re-derived from the stored checksum. Hardening only.

@lukaslw-lab

Copy link
Copy Markdown
Contributor

Thanks for taking #3473. A real-data point for it: 4,352 compute requests from one local capture, through the current single-file writer (with #3472), gave 887 prepared, 2,742 unsupported and 723 left out as invalid compute pack size.

Agreed with Leyukaka on the order: #3472 first, then (requests, cache, entry, jobs, part_limit) here.

@R0Y00
R0Y00 merged commit d54a705 into R0Y00:main Nov 30, 2026
5 checks passed
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.

compute pack: a startup capture of 2689 compute requests exceeds the 256 MiB pack limit; 28 requests are left out

4 participants