mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #4777] [Engine] Dynamic route_prior runtime control via API, per-request params, and engine protocol #5176
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#5176
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/4777
Author: @code-martin
Created: 10/31/2026
Status: 🔄 Open
Base:
main← Head:feature/dynamic-route-prior-v028📝 Commits (1)
55ec585feat(routing): dynamic route_prior control via API, per-request params, and engine protocol📊 Changes
6 files changed (+142 additions, -8 deletions)
View changed files
📝
include/strata/core/verify.hpp(+6 -0)📝
serve/server.py(+25 -0)📝
serve/web/app.js(+10 -2)📝
serve/web/index.html(+5 -0)📝
src/core/verify.cpp(+65 -6)📝
src/program/generate.cpp(+31 -0)📄 Description
Problem and result
Before:
Residency-biased MoE routing (
STRATA_ROUTE_PRIOR) was read once from the environment at startup or locked to static hardware heuristics. Calibrating or sweeping\lambdarequired terminating the server, restarting the process, reloading ~40 GB of model weights and expert caches, and dropping active KV/session contexts.After:
Dynamic runtime control over
route_prior\lambdaacross the full Strata stack:stdinprotocol command:ROUTE_PRIOR <val>.stage_ver(st).set_route_prior(v)) with automatic CUDA graph invalidation (clear_graphs()) so new priors take effect on the next window without engine restart."route_prior": 0.5or"strata_tune": {"route_prior": 0.5}).GET /v1/route_priorandPOST /v1/route_prior.Related discussion
@telegram
Approach
src/core/verify.cpp,include/strata/core/verify.hpp): Added thread-safe atomicg_dyn_route_priorand per-instanceroute_prior_field onVerifier. AddedVerifier::set_route_prior(float rp)andVerifier::clear_graphs()to flush captured CUDA graphs when\lambdachanges.src/program/generate.cpp): HandledROUTE_PRIORcommand on stdin and parsed per-requestroute_priorparameters inGENprotocol lines across both primary and draft stages.serve/server.py): Added/v1/route_priorREST endpoints and forwarded per-requestroute_priordown to the engine runner.Validation
Passed:
c3066e1confeature/dynamic-route-prior-v028(based onv0.2.8), Windows 11 x64 (Build 26100), NVIDIA GeForce RTX 3080 10GB (Driver 610.88, CUDA 13.1), 64GB DDR4 RAM,Qwen3.8-Flash-Next-GSQ-RCO-IQ2_XS(262kcontext, int8 KV,--expert-cache -1,--spec 2,--suffix-draft 3).cmake --build M:/Strata/build --config Release --target strata— builtstrata.exewith 0 errors.curl -s http://127.0.0.1:8080/v1/route_prior->{"route_prior": 0.0}curl -s -X POST http://127.0.0.1:8080/v1/route_prior -H "Content-Type: application/json" -d '{"route_prior": 0.5}'->{"ok": true, "route_prior": 0.5}< 2\text{ ms}without dropping running server state or reloading model weights.\sqrt{55463},x_0 = 100, 10 iterations):"Compute square root of 55463 using 10 iterations of Newton's method with initial guess=100. List all iterations."(seed = 42,max_tokens = 8192, 1 warm-up run, randomized order[1.0, 0.5, 1.5, 0.0], reference\sqrt{55463} \approx 235.505838569).\lambda(route_prior)predicted_per_second)predicted_n)x_{10}x^2 = 55463.0000)Failed:
none observed
Not run:
Limits
\lambda, requiring a single graph recapture on the first subsequent window.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.