mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #3841] [CLOSED] [Engine] q36: STRATA_Q36_SINGLE_STAGE=1 keeps one staging buffer, and STRATA_Q36_NO_MMQ takes a number #4799
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#4799
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/3841
Author: @ggeorgovassilis
Created: 10/23/2026
Status: ❌ Closed
Base:
main← Head:q36-single-staging📝 Commits (2)
2802555q36: STRATA_Q36_SINGLE_STAGE=1 streams a prompt chunk through one staging buffer, halving that VRAM907a145q36 docs: the staging switch's measurement and what the numeric NO_MMQ changes for a script that set it to 0📊 Changes
2 files changed (+25 additions, -12 deletions)
View changed files
📝
docs/QWEN36.md(+7 -0)📝
src/qwen35/q36_engine.cu(+18 -12)📄 Description
Problem and result
In the hybrid mode a prompt chunk streams each layer's experts into a staging buffer, and two are kept so one layer copies while the other computes. On a card whose free VRAM only just holds the experts plus that staging, the second buffer is the difference between starting and
cudaMalloc(&E.stage[b], ...) failed: out of memory- and there was no way to ask for one.STRATA_Q36_NO_MMQwas on/off by presence, so0turned MMQ off, which reads wrong in a script or a launcher that passes0for "off".After:
STRATA_Q36_SINGLE_STAGE=1keeps one staging buffer (staging 1.10 -> 0.55 GiB measured below) andSTRATA_Q36_NO_MMQtakes a number (0/ unset = MMQ on,1= off). Both are opt-in: unset, the engine takes the same path as before (two buffers, MMQ on) and the tokens are identical (measured below).Related discussion
3a9e6c88.Of the three items the issue asks for, two are still needed and are here. The third, and
STRATA_Q36_PLACE_DEBUG, are already upstream and are not in this PR:shrink_att()with themtp_onlypath;STRATA_Q36_PLACE_DEBUGis upstream.Approach
src/qwen35/q36_engine.cu:int n_stage = 2;on the engine, read once ininit()fromSTRATA_Q36_SINGLE_STAGE(any number above0= 1 buffer).stream_begin()prefetchesn_stagelayers,stream_kick()/stream_take()/stream_done()indexi % n_stage,place_experts()sizes the reservation and thecudaMallocloop from it.use_mmqreadsSTRATA_Q36_NO_MMQwithstd::atoiinstead of testing the presence of the variable.Compatibility: with the variable unset nothing changes.
STRATA_Q36_NO_MMQset to anything non-numeric or1still turns MMQ off; set to0it now leaves it on (it used to turn it off). That is the point of the numeric form, anddocs/QWEN36.mdsays it.Validation
Revision:
907a1452onq36-single-staging(over upstream5c8dd322). Machine: RTX 4060 Laptop 8 GB, Linux, CUDA 13.0, modelQwen3.6-35B-A3B-UD-Q4_K_XL(22.9 GB, so the hybrid mode is the one in use),--max-context 4096 --chunk 512, a 1,400-token prompt (three prompt chunks, so the stream runs three times) and 24 greedy tokens, driven through the serve protocol.Passed:
C++ build, CUDA 13.0, sm_89 -
docker build --target engine-build --build-arg CUDA_ARCHITECTURES=89 --build-arg BUILD_VISION=0 .->[165/165] Linking CXX executable strata, exit 0, warnings only, all pre-existing (the four inq36_engine.cuare at lines 199, 233, 1652 and 1889 - untouched code, the same ones the base build prints).C++ build, HIP 7.14 (ROCm dev image), gfx1201 -
cmake -DSTRATA_ENABLE_HIP=ON -DCMAKE_HIP_ARCHITECTURES=gfx1201 ...thencmake --build build-hip --target strata->Linking HIP static library libstrata_qwen35.a,Linking HIP executable strata,HIP_BUILD_OK, exit 0 (warnings as above:iq_kernels.cuand the same pre-existing four inq36_engine.cu).Tokens, staging on (default) against the unmodified upstream build (
engine-build-q36-base, same source otherwise): identical, 13 of 13 tokens (tools/qwen35/q36_cmp_gate.py->p00 identical).Tokens,
STRATA_Q36_SINGLE_STAGE=1against the default: identical, 13 of 13. Staging size from the engine's own placement line:1.10 GiB stagingwith the default,0.55 GiB stagingwith the switch - half, as intended.Tokens,
STRATA_Q36_NO_MMQ=0against unset: identical, 13 of 13, and staging stays at1.10 GiB(MMQ on).STRATA_Q36_NO_MMQ=1: MMQ off (0.00 GiB staging, the prompt has no streamed path then), prompt 1400 tokens in 13.57 s against 4.46 s, tokens still identical 13 of 13.Before/after of the compatibility note: the unmodified build with
STRATA_Q36_NO_MMQ=0prints0.00 GiB stagingand reads the prompt in 12.36 s (MMQ off, the old meaning); this branch with the same variable reads it in 4.46 s with1.10 GiB staging(MMQ on).Python suites, unrelated to this change but run on this branch:
python -m pytest tests/terminal-> 1518 passed, 47 skipped, 17 failed;python -m pytest tools/test_setup_*.py-> 733 passed, 1 skipped, 49 failed. The same 17 and the same 49 fail on a cleanupstream/mainworktree here (git worktree add /tmp/strata-base upstream/main), with the same names - checked by diffing the two failure lists: identical, so they are this machine's (no CUDA device names in their fixtures, hostname/paths) and not this change.Failed:
none observed.
Not run:
tools/qwen35/that need many prompts (q36_batch_gate.py,q36_proto_edge.py,q36_par_bench.py): the 8 GB card in the hybrid mode was used for the token-parity runs above, not those.Limits
STRATA_Q36_NO_MMQ=1, there is no staging and it does nothing.STRATA_Q36_NO_MMQ=0changed meaning as described; a script that relied on=0turning MMQ off needs=1.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.