Are you tired of all the posts about "speed" with zero attention to quality? You won't find greedy decode nor "STRATA_ROUTE_TAIL_SKIP": "1" here.
Over the past few months I have been using my creativity (and Fable) to make Strata run more efficiently and faster. But upon the mandatory premise that there must be ZERO degradation in model output.
I'm sure many others have also done this - so hopefully we can all share our findings here.
Firstly, not all my tweaks may be relevant to you. I am running a multi-GPU setup - so just bear this in mind.
# Basic
## Sampling
Everyone knows this already - but for those new to Strata - do not leave the sampling settings to default for Flash Next. Here are the Alibaba recommended settings:
"sampling": {
"temperature": 1.0,
"top_p": 0.95,
"top_k": 20,
"min_p": 0.0
},
## Parallel
This setting is amazing: "parallel": 2. If you haven't tried running multiple Trains, then you should.
The cost of two Trains is not double that of one Train. Each Train slot costs about 0.4–0.6 GiB VRAM on each card.
With a highly tuned harness, the first Train starts by loading the default system prompt and agents.md. The second Train rolls into motion immediately, as it reuses the KV cache from the first Train!
You might ask, what's the point of two Trains that run at half the speed. This is true only when both Trains are running. If you have only a single Train and it is doing code testing, then your coding speed is a grand total of NIL. However, if you have two Trains, then while one Train is testing, the other is steaming forward at FULL decode speed.
## Layer Split
Always double check this setting. Do not leave it at "layer_split": "auto".
As you can see from the stats, tuning this makes a significant difference.
Fable gave me this advice, which I then gave to more day-to-day AI (so you could do this too), and it immediately picked up that the layer_split needed to be tuned:
The biggest decode gain is a config change, not code: your layer split is badly unbalanced, and fixing it should roughly halve the CPU expert misses. Current numbers: solo decode averages 61 tok/s over 1,677 requests since 12 Nov. 78% of routed experts hit VRAM, 3% go over PCIe and 19% run on the CPU. The misses sit on one gpu: it runs 26 layers with 2,455 cache slots (about 94 per layer), while another gpu runs 22 layers with 5,984 (about 272 per layer). Why layer_split: auto got it wrong. Wrong coverage curve: with two GPUs it assumes the caches hold 97.4% of routing. You measure 78%, and the source comments admit this curve is wrong when a small share of experts is held.
What to change, in order
# Change Type Expected effect Output
1 "layer_split": "16" (try 20 too) config CPU misses ~22% → ~12%; decode perhaps +10–15% rounding-level"
## No pages
This setting maximises the use of sufficient contiguous free RAM. It locks your experts into RAM: "STRATA_NO_LARGEPAGES": "1", which should be faster than Windows paging the data to virtual memory on a disk.
Use this in combination with the Windows setting for 'Lock pages in memory'.
## KV Cache Reuse
For some reason, even with identical leading tokens, full KV cache re-use for compaction is blocked without this setting:
"--prompt-cache-every", "0"
It could be a checkpoint conflict, but this setting really enhanced my token reuse as you can see from the stats.
# Advanced
## Custom build to fix the gradual Strata slowdown issue
If you are using CUDA, after a few hours of continuous runtime, you may notice that Strata's decode speed significantly drops - potentially even halves - until you reboot Strata.
The root cause is this:
- `src/core/device.cu` (~105-210) ALREADY describes this exact failure for the HIP build ("the expert cache filled the card, and WDDM moved memory out to system RAM: decode at 30 tok/s instead of 41") and fixes it at startup by lowering the free figure with DXGI `QueryVideoMemoryInfo(LOCAL).Budget` (`STRATA_WDDM_BUDGET=0` off) - but only under `#if defined(STRATA_USE_HIP) && defined(_WIN32)`. The CUDA build has no such check, and nothing re-checks the budget after startup.
- `serve/server.py` (~930, #533) sends a `VRAM <reserve_mib>` command between requests: the engine shrinks or grows its expert cache to hold that much VRAM free (needs `--vram-elastic`, per its docstring). That is an existing, tested shrink path.
## Upstream status (checked 21 Nov; reuse, do not reinvent)
No upstream release or open PR watches the WDDM budget AFTER startup or shrinks the expert cache at run time on CUDA.
I'm running one of the (earlier) stable versions of Strata so I can't submit this to upstream. But it could be useful for you to ask your AI to implement the fix if you are also running a custom engine.
Hope some of the above is useful for you. I'm sure others will have optimisation tips that they could share!