[PR #2486] [CLOSED] sycl: Alchemist expert cache in segments, so borrowed prompt GEMM operands are not staged (A770 prompt +8-12%, output identical) #4069

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

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/2486
Author: @aslater3
Created: 10/14/2026
Status: ❌ Closed

Base: main ← Head: a770/up-arena-segmented


📝 Commits (1)

  • 9734b8e sycl: Alchemist expert cache in segments, so borrowed prompt GEMM operands are not staged

📊 Changes

4 files changed (+161 additions, -1 deletions)

View changed files

📝 sycl/include/strata/sycl_queue.hpp (+96 -0)
➕ sycl/probe/a770/gemm_far_probe.cpp (+57 -0)
📝 sycl/src/core/expert_cache.cpp (+6 -0)
📝 sycl/src/prefill/gemm.dp.cpp (+2 -1)

📄 Description

Title

sycl: Alchemist expert cache in segments, so borrowed prompt GEMM operands are not staged (A770 prompt +8-12%, output identical)

Summary

The prompt path borrows the top expert-cache slots, 5.4-7.6 GiB into the ~8.6 GiB arena. oneMKL misreads a GEMM operand that lies more than 4 GiB into one allocation, so staged_gemm copied nearly every expert GEMM operand first. In an 8K prompt that is 24,576 staged GEMMs and about 200 GB of device copies.

On Alchemist, the arena is now allocated as equal physical segments behind one reserved address range (sycl_ext_oneapi_virtual_mem). The rest of the engine still sees one contiguous range. The arena is not registered for staging, because the same GEMMs read right in a segmented range at any offset.

What changed

  • sycl/include/strata/sycl_queue.hpp: malloc_device_segmented / free_device_segmented and arena_segmented_wanted. Segments are 512 MiB (whole 2 MiB pages, all equal: Level Zero refused a smaller last segment).
  • sycl/src/core/expert_cache.cpp: ExpertCache::open takes that path on Alchemist, and close() frees it.
  • sycl/src/prefill/gemm.dp.cpp: a comment.
  • sycl/probe/a770/gemm_far_probe.cpp: the probe that places the misread.
  • Switches: STRATA_ARENA_SEGMENTED=0 gives one allocation as before; =1 opts in other devices. STRATA_ARENA_SEGMENT_MIB sets the segment size.
  • No virtual-memory support or any failure falls back to the previous allocation.

Extra Notes

Probe (gemm_far_probe, A770, xe, compute runtime 26.05, oneAPI 2026.1):

  • One 8 GiB malloc_device, T = 7987: X past 4 GiB gives a wrong last partial tile; W and X past 4 GiB gives nearly every element wrong.
  • Physical segments behind one range: every case reads right. This held for 0.25, 0.5 and 2 GiB segments, fp16 and bf16, with W, X or Y anywhere, and across segment boundaries.

Engine (Coder IQ1_M, --resident-experts, learned24, --prefill-borrow, spec 4, greedy, STRATA_PF_XMX=2), same-day A/B against itself with STRATA_ARENA_SEGMENTED=0:

prompt segmented one allocation output
8K 678.8 tok/s prefill, 27.17 decode 627.4, 27.31 identical ids
32K 720.7 tok/s prefill, 22.90 decode 649.1, 22.98 identical ids

Default path elsewhere. Battlemage and every other device are byte-identical. The gate is intel_gpu_gen(dev) == IntelGpuGen::Alchemist.

Not tested: A750 / A580 (i915), Windows, --vram-elastic, a layer split, prompts without borrowing.

🤖 Generated with Claude Code


🔄 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/2486 **Author:** [@aslater3](https://github.com/aslater3) **Created:** 10/14/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `a770/up-arena-segmented` --- ### 📝 Commits (1) - [`9734b8e`](https://github.com/Niko1221/Strata/commit/9734b8e35c77e3b38735ddaec0278a0c5acf3a77) sycl: Alchemist expert cache in segments, so borrowed prompt GEMM operands are not staged ### 📊 Changes **4 files changed** (+161 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `sycl/include/strata/sycl_queue.hpp` (+96 -0) ➕ `sycl/probe/a770/gemm_far_probe.cpp` (+57 -0) 📝 `sycl/src/core/expert_cache.cpp` (+6 -0) 📝 `sycl/src/prefill/gemm.dp.cpp` (+2 -1) </details> ### 📄 Description ## Title sycl: Alchemist expert cache in segments, so borrowed prompt GEMM operands are not staged (A770 prompt +8-12%, output identical) ## Summary The prompt path borrows the top expert-cache slots, 5.4-7.6 GiB into the ~8.6 GiB arena. oneMKL misreads a GEMM operand that lies more than 4 GiB into **one** allocation, so `staged_gemm` copied nearly every expert GEMM operand first. In an 8K prompt that is 24,576 staged GEMMs and about 200 GB of device copies. On Alchemist, the arena is now allocated as equal physical segments behind one reserved address range (`sycl_ext_oneapi_virtual_mem`). The rest of the engine still sees one contiguous range. The arena is not registered for staging, because the same GEMMs read right in a segmented range at any offset. ## What changed - `sycl/include/strata/sycl_queue.hpp`: `malloc_device_segmented` / `free_device_segmented` and `arena_segmented_wanted`. Segments are 512 MiB (whole 2 MiB pages, all equal: Level Zero refused a smaller last segment). - `sycl/src/core/expert_cache.cpp`: `ExpertCache::open` takes that path on Alchemist, and `close()` frees it. - `sycl/src/prefill/gemm.dp.cpp`: a comment. - `sycl/probe/a770/gemm_far_probe.cpp`: the probe that places the misread. - Switches: `STRATA_ARENA_SEGMENTED=0` gives one allocation as before; `=1` opts in other devices. `STRATA_ARENA_SEGMENT_MIB` sets the segment size. - No virtual-memory support or any failure falls back to the previous allocation. ## Extra Notes **Probe** (`gemm_far_probe`, A770, xe, compute runtime 26.05, oneAPI 2026.1): - One 8 GiB `malloc_device`, T = 7987: X past 4 GiB gives a wrong last partial tile; W and X past 4 GiB gives nearly every element wrong. - Physical segments behind one range: every case reads right. This held for 0.25, 0.5 and 2 GiB segments, fp16 and bf16, with W, X or Y anywhere, and across segment boundaries. **Engine** (Coder IQ1_M, `--resident-experts`, learned24, `--prefill-borrow`, spec 4, greedy, `STRATA_PF_XMX=2`), same-day A/B against itself with `STRATA_ARENA_SEGMENTED=0`: | prompt | segmented | one allocation | output | |---|---|---|---| | 8K | 678.8 tok/s prefill, 27.17 decode | 627.4, 27.31 | identical ids | | 32K | 720.7 tok/s prefill, 22.90 decode | 649.1, 22.98 | identical ids | **Default path elsewhere.** Battlemage and every other device are byte-identical. The gate is `intel_gpu_gen(dev) == IntelGpuGen::Alchemist`. Not tested: A750 / A580 (i915), Windows, `--vram-elastic`, a layer split, prompts without borrowing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 15:32:57 +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#4069
No description provided.