[PR #632] [CLOSED] expert profile: refuse a header version other than 1, naming both numbers and the file #2729

Closed
opened 2026-11-04 02:02:43 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/632
Author: @Avicennasis
Created: 10/3/2026
Status: ❌ Closed

Base: main ← Head: fix/expert-profile-version


📝 Commits (10+)

  • b0dda4b AMD: gfx1101 (RX 7800 XT, #254 by jhohertz) and gfx1200 (RX 9060 XT, #256 by Efeisot) as community-validated cards
  • cc97fcd setup: AMD layer splits with --gpus (every chosen card a supported AMD arch; the engine compiled for each)
  • e9e2ba3 pinned (#243 follow-up): the shared-memory-budget cap on the sliced pin is opt-in (STRATA_ARENA_PIN_GIB=auto) - by default the arena pins as in 0.1.30; on this 64 GB PC the cap pinned 26 instead of 30 GiB and cost ~20% prompt speed and 2-4% IQ3_S decode
  • cacffa9 CS-T speed: the file tier fetched in parallel, PCIe planning without file reads, a partial pin of the RAM tier, bit-exact AVX2 multi-token kernels for Q4_K / Q5_1 / Q8_0 experts, decode-only tier stats
  • a348c7a Merge branch 'f-131-srv' into r131-q4
  • b93a00c Merge branch 'f-q4-on242' into r131-q4
  • 8f5148c CS-T: the partial pin at most 24 GiB (STRATA_PARTIAL_PIN_GIB), the Q4_K/Q5_1/Q8_0 multi-token kernels from two tokens on
  • 5ffda19 CS-T: the GGUF-in-place prefetch asks Windows for all of a layer's missed slices at once (PrefetchVirtualMemory)
  • ed6c124 #253: the 8 GiB arena pin cap only under WDDM; STRATA_ARENA_PIN_GIB; the split's prompt chunk steps down
  • 450149d --split-skip-if-fits (opt-in): an auto split runs on the main card alone when it holds every profiled expert + KV

📊 Changes

3 files changed (+93 additions, -1 deletions)

View changed files

📝 CMakeLists.txt (+8 -0)
📝 src/core/expert_cache.cpp (+12 -1)
➕ tests/core/expert_profile_version_test.cpp (+73 -0)

📄 Description

One fail-closed change on the expert-profile reader, with a test that runs without a model or a GPU. Reader side only: tools/make_profile.py and the cache policy are untouched (#589 / #587 are on the writer).

expert_cache.cpp: a profile whose header version is not 1 is refused, naming both numbers and the file

read_expert_profile (src/core/expert_cache.cpp:33) reads the header's version field and then discards it ((void) version; at :68, "a future format bumps it; the layout check above is what protects this reader today"). The layout check compares n_layers x n_expert, but those fields are only known to sit where they do in a version 1 file: a later format that moves or widens anything after the version would be read as version 1 and either pass the geometry check with the wrong numbers or fail it with a message about the wrong thing ("is 0x2 but this model is 48x512"). Two writers now produce these files - tools/make_profile.py and --expert-profile-save (#477) - so a version bump is a real possibility rather than a note.

The reader now refuses any version other than 1 right after the magic, before the geometry check, naming the version it found, the version it reads, and the file:

read_expert_profile: <path> is a version 2 profile but this engine reads version 1 - it was written by a different release's tools/make_profile.py or --expert-profile-save

Same error shape as the file's other refusals (read_expert_profile: ... prefix, the path in the message, false with err set). A version 1 file is read exactly as before. 12 lines in the reader, 8 in CMakeLists.txt.

Test: tests/core/expert_profile_version_test.cpp (registered beside expert_profile_save_test, same EXISTS guard, links strata_engine, CPU only). It writes a version 1 profile with write_expert_profile and reads it back, then rewrites the 4-byte version field in place:

  • version 1: loads, the ranking and the slot count come back;
  • version 2: refused; the message names the file, "version 2" and "version 1";
  • version 0 (a zeroed header): refused by its number;
  • version 2 with the wrong geometry: refused as version 2, not as the wrong geometry (the version is checked first);
  • back to version 1: loads again, so the version field was the only thing refused.

11 checks. On main the version 2 file loads as if it were version 1 (read_expert_profile returns true, err empty) and 5 of the 11 fail; with the change all 11 pass.

What I ran, and where

Linux x86_64 (Ubuntu 24.04, AMD Ryzen 7 5800X - no AVX-512, no NVIDIA GPU, no CUDA or HIP toolkit), gcc 13.3.0, CMake 3.28.3. This is a claim about my machine, not yours.

  • strata_engine (and so expert_profile_save_test and this test's ctest target) is only configured with STRATA_ENABLE_CUDA or STRATA_ENABLE_HIP, and expert_cache.cpp includes cuda_runtime.h, so I could not run the new target through ctest here. Instead I compiled the same two files directly - g++ -std=c++20 -Wall -Wextra src/core/expert_cache.cpp tests/core/expert_profile_version_test.cpp against a declarations-only cuda_runtime.h stub (its functions abort if called; the profile tests call none) - with no warnings: expert_profile_version_test: OK (exit 0). The same harness on main's expert_cache.cpp prints the 5 FAIL: lines above and exits 1. expert_profile_save_test through the same harness: OK on both. The CMake registration is a copy of the save test's block, so it should configure wherever that one does; please run it through ctest on a GPU build, I have not.
  • cmake -B build-cpu -DSTRATA_ENABLE_CUDA=OFF -DSTRATA_BUILD_TESTS=ON -G Ninja configures cleanly on this tree (the #93 items are fixed), cmake --build build-cpu: 72 of 72 targets. ctest: 13 tests, 12 passed; expert_multi_test fails with the kernel's own refusal (missing AVX512F ... AVX512-VBMI), which is this CPU, not the branch - nothing under src/kernels is touched.
  • git diff --check clean.

Branch is on 99f3dbd (0.1.38); happy to rebase if it has moved by the time you look.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/632 **Author:** [@Avicennasis](https://github.com/Avicennasis) **Created:** 10/3/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/expert-profile-version` --- ### 📝 Commits (10+) - [`b0dda4b`](https://github.com/Niko1221/Strata/commit/b0dda4b14886293575e5fe5c92e5ba6636adc4a1) AMD: gfx1101 (RX 7800 XT, #254 by jhohertz) and gfx1200 (RX 9060 XT, #256 by Efeisot) as community-validated cards - [`cc97fcd`](https://github.com/Niko1221/Strata/commit/cc97fcde526e1b2d4cbee39ba21e54a0ef7505b1) setup: AMD layer splits with --gpus (every chosen card a supported AMD arch; the engine compiled for each) - [`e9e2ba3`](https://github.com/Niko1221/Strata/commit/e9e2ba31abdc211a618b5faf7226732d40bbcf2b) pinned (#243 follow-up): the shared-memory-budget cap on the sliced pin is opt-in (STRATA_ARENA_PIN_GIB=auto) - by default the arena pins as in 0.1.30; on this 64 GB PC the cap pinned 26 instead of 30 GiB and cost ~20% prompt speed and 2-4% IQ3_S decode - [`cacffa9`](https://github.com/Niko1221/Strata/commit/cacffa95aff016939edd7c15534c0067ec0ee93c) CS-T speed: the file tier fetched in parallel, PCIe planning without file reads, a partial pin of the RAM tier, bit-exact AVX2 multi-token kernels for Q4_K / Q5_1 / Q8_0 experts, decode-only tier stats - [`a348c7a`](https://github.com/Niko1221/Strata/commit/a348c7a4ed64f5f7f24ce3f1cba2d1439f673fed) Merge branch 'f-131-srv' into r131-q4 - [`b93a00c`](https://github.com/Niko1221/Strata/commit/b93a00c65a21fcc5b6431b8091e348d2976259f0) Merge branch 'f-q4-on242' into r131-q4 - [`8f5148c`](https://github.com/Niko1221/Strata/commit/8f5148c14d34c404e8a2d6a45188088714f3c9bb) CS-T: the partial pin at most 24 GiB (STRATA_PARTIAL_PIN_GIB), the Q4_K/Q5_1/Q8_0 multi-token kernels from two tokens on - [`5ffda19`](https://github.com/Niko1221/Strata/commit/5ffda19098202b82943fc80281ce0eb34d8e08a3) CS-T: the GGUF-in-place prefetch asks Windows for all of a layer's missed slices at once (PrefetchVirtualMemory) - [`ed6c124`](https://github.com/Niko1221/Strata/commit/ed6c1244dcd31789007540cb9d8498fbd4134b7f) #253: the 8 GiB arena pin cap only under WDDM; STRATA_ARENA_PIN_GIB; the split's prompt chunk steps down - [`450149d`](https://github.com/Niko1221/Strata/commit/450149d3f248438d8a2526c600b5a75c3dbea6c6) --split-skip-if-fits (opt-in): an auto split runs on the main card alone when it holds every profiled expert + KV ### 📊 Changes **3 files changed** (+93 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `CMakeLists.txt` (+8 -0) 📝 `src/core/expert_cache.cpp` (+12 -1) ➕ `tests/core/expert_profile_version_test.cpp` (+73 -0) </details> ### 📄 Description One fail-closed change on the expert-profile reader, with a test that runs without a model or a GPU. Reader side only: `tools/make_profile.py` and the cache policy are untouched (#589 / #587 are on the writer). ## `expert_cache.cpp`: a profile whose header version is not 1 is refused, naming both numbers and the file `read_expert_profile` (`src/core/expert_cache.cpp:33`) reads the header's `version` field and then discards it (`(void) version;` at `:68`, "a future format bumps it; the layout check above is what protects this reader today"). The layout check compares `n_layers x n_expert`, but those fields are only known to sit where they do in a version 1 file: a later format that moves or widens anything after the version would be read as version 1 and either pass the geometry check with the wrong numbers or fail it with a message about the wrong thing ("is 0x2 but this model is 48x512"). Two writers now produce these files - `tools/make_profile.py` and `--expert-profile-save` (#477) - so a version bump is a real possibility rather than a note. The reader now refuses any version other than 1 right after the magic, before the geometry check, naming the version it found, the version it reads, and the file: ``` read_expert_profile: <path> is a version 2 profile but this engine reads version 1 - it was written by a different release's tools/make_profile.py or --expert-profile-save ``` Same error shape as the file's other refusals (`read_expert_profile: ...` prefix, the path in the message, `false` with `err` set). A version 1 file is read exactly as before. 12 lines in the reader, 8 in `CMakeLists.txt`. Test: `tests/core/expert_profile_version_test.cpp` (registered beside `expert_profile_save_test`, same `EXISTS` guard, links `strata_engine`, CPU only). It writes a version 1 profile with `write_expert_profile` and reads it back, then rewrites the 4-byte version field in place: - version 1: loads, the ranking and the slot count come back; - version 2: refused; the message names the file, "version 2" and "version 1"; - version 0 (a zeroed header): refused by its number; - version 2 with the wrong geometry: refused as version 2, not as the wrong geometry (the version is checked first); - back to version 1: loads again, so the version field was the only thing refused. 11 checks. On `main` the version 2 file loads as if it were version 1 (`read_expert_profile` returns true, `err` empty) and 5 of the 11 fail; with the change all 11 pass. ## What I ran, and where Linux x86_64 (Ubuntu 24.04, AMD Ryzen 7 5800X - no AVX-512, no NVIDIA GPU, no CUDA or HIP toolkit), gcc 13.3.0, CMake 3.28.3. This is a claim about my machine, not yours. - `strata_engine` (and so `expert_profile_save_test` and this test's ctest target) is only configured with `STRATA_ENABLE_CUDA` or `STRATA_ENABLE_HIP`, and `expert_cache.cpp` includes `cuda_runtime.h`, so I could not run the new target through ctest here. Instead I compiled the same two files directly - `g++ -std=c++20 -Wall -Wextra src/core/expert_cache.cpp tests/core/expert_profile_version_test.cpp` against a declarations-only `cuda_runtime.h` stub (its functions abort if called; the profile tests call none) - with no warnings: `expert_profile_version_test: OK` (exit 0). The same harness on `main`'s `expert_cache.cpp` prints the 5 `FAIL:` lines above and exits 1. `expert_profile_save_test` through the same harness: `OK` on both. The CMake registration is a copy of the save test's block, so it should configure wherever that one does; please run it through ctest on a GPU build, I have not. - `cmake -B build-cpu -DSTRATA_ENABLE_CUDA=OFF -DSTRATA_BUILD_TESTS=ON -G Ninja` configures cleanly on this tree (the #93 items are fixed), `cmake --build build-cpu`: 72 of 72 targets. `ctest`: 13 tests, 12 passed; `expert_multi_test` fails with the kernel's own refusal (`missing AVX512F ... AVX512-VBMI`), which is this CPU, not the branch - nothing under `src/kernels` is touched. - `git diff --check` clean. Branch is on `99f3dbd` (0.1.38); happy to rebase if it has moved by the time you look. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-04 02:02:43 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#2729
No description provided.