[PR #2627] [CLOSED] native dense: count the STRATA_Q8_PACKED copies and allocate them after the required weights #4175

Closed
opened 2026-11-07 15:33:48 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/2627
Author: @justincinmd
Created: 10/15/2026
Status: ❌ Closed

Base: main ← Head: pr/q8-packed-alloc


📝 Commits (1)

  • 17968b6 native dense: price the STRATA_Q8_PACKED copies and place them after the required allocations

📊 Changes

5 files changed (+351 additions, -41 deletions)

View changed files

📝 CMakeLists.txt (+5 -0)
📝 include/strata/core/native_dense.hpp (+4 -2)
➕ include/strata/core/optional_alloc.hpp (+78 -0)
📝 src/core/native_dense.cpp (+105 -39)
➕ tests/core/optional_alloc_test.cpp (+159 -0)

📄 Description

Summary

STRATA_Q8_PACKED=1 (on by default on gfx1151) keeps a second, packed copy of each eligible Q8_0 dense matrix in VRAM. The layer split search did not count that copy. A copy that did not fit also aborted the load. This PR counts the copies and makes them optional.

What changed

  • NativeDense::weight_bytes_for prices each packed copy with the same test that load uses. The split search no longer under-prices a stage with such matrices.
  • NativeDense::load makes every required allocation first (the matrices, the STRATA_HC_Q8 copies, the q8_1 scratch) and the packed copies after them. Before, it made each copy right after its matrix.
  • The first copy that does not fit is dropped with one stderr line. The copies after it are not tried. A matrix without a copy uses the GGUF layout, as with the switch off. Any other failure is still an error.
  • include/strata/core/optional_alloc.hpp (new, header-only): the required-then-optional sequencer that load uses.
  • tests/core/optional_alloc_test.cpp (new, CPU only).

Runs with Q8 packing off keep the same allocations in the same order. On gfx1151 the default path changes: a stage with eligible Q8_0 matrices is priced higher, so an automatic split can place layers differently, and a copy that does not fit no longer stops the load.

Testing

  • optional_alloc_test drives the sequencer in load's call order against a fake VRAM budget. Cases: 13 MiB free with three 4 MiB matrices (fails in the old order, loads now), room for some or all copies, a required allocation out of memory, a copy upload failure, and a required allocation after finish().
  • HIP (ROCm 7.2.4, gfx1201) builds. CUDA 13.0.2 (sm_120) and oneAPI DPC++ 2026.1.1 (SYCL) build with no new diagnostics. Compile only.

Extra Notes

Not run on a GPU with an eligible matrix: no pack I have contains a Q8_0 dense matrix wide enough to pack. I found the problem while testing the gfx1151 decode switches on gfx12 (a separate PR). A gfx1151 run with a Q8_0 pack would confirm it.


🔄 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/2627 **Author:** [@justincinmd](https://github.com/justincinmd) **Created:** 10/15/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `pr/q8-packed-alloc` --- ### 📝 Commits (1) - [`17968b6`](https://github.com/Niko1221/Strata/commit/17968b643c66321844548e0c07f2c489c1c6fcfe) native dense: price the STRATA_Q8_PACKED copies and place them after the required allocations ### 📊 Changes **5 files changed** (+351 additions, -41 deletions) <details> <summary>View changed files</summary> 📝 `CMakeLists.txt` (+5 -0) 📝 `include/strata/core/native_dense.hpp` (+4 -2) ➕ `include/strata/core/optional_alloc.hpp` (+78 -0) 📝 `src/core/native_dense.cpp` (+105 -39) ➕ `tests/core/optional_alloc_test.cpp` (+159 -0) </details> ### 📄 Description ## Summary `STRATA_Q8_PACKED=1` (on by default on gfx1151) keeps a second, packed copy of each eligible Q8_0 dense matrix in VRAM. The layer split search did not count that copy. A copy that did not fit also aborted the load. This PR counts the copies and makes them optional. ## What changed - `NativeDense::weight_bytes_for` prices each packed copy with the same test that `load` uses. The split search no longer under-prices a stage with such matrices. - `NativeDense::load` makes every required allocation first (the matrices, the `STRATA_HC_Q8` copies, the q8_1 scratch) and the packed copies after them. Before, it made each copy right after its matrix. - The first copy that does not fit is dropped with one stderr line. The copies after it are not tried. A matrix without a copy uses the GGUF layout, as with the switch off. Any other failure is still an error. - `include/strata/core/optional_alloc.hpp` (new, header-only): the required-then-optional sequencer that `load` uses. - `tests/core/optional_alloc_test.cpp` (new, CPU only). Runs with Q8 packing off keep the same allocations in the same order. On gfx1151 the default path changes: a stage with eligible Q8_0 matrices is priced higher, so an automatic split can place layers differently, and a copy that does not fit no longer stops the load. ## Testing - `optional_alloc_test` drives the sequencer in `load`'s call order against a fake VRAM budget. Cases: 13 MiB free with three 4 MiB matrices (fails in the old order, loads now), room for some or all copies, a required allocation out of memory, a copy upload failure, and a required allocation after `finish()`. - HIP (ROCm 7.2.4, gfx1201) builds. CUDA 13.0.2 (sm_120) and oneAPI DPC++ 2026.1.1 (SYCL) build with no new diagnostics. Compile only. ## Extra Notes Not run on a GPU with an eligible matrix: no pack I have contains a Q8_0 dense matrix wide enough to pack. I found the problem while testing the gfx1151 decode switches on gfx12 (a separate PR). A gfx1151 run with a Q8_0 pack would confirm it. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 15:33:48 +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#4175
No description provided.