Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
12 KiB
Remaining Strata port: status, divergences and call sites
Everything here is verified without a GPU. Items are numbered as in the port brief. Oracle = the Python server and
engine under engine/strata.
1. Vision over HTTP
| Piece | Rust | Oracle |
|---|---|---|
| Image parts, three dialects | control-plane/src/chat.rs (image_url), messages.rs (image blocks), responses.rs (input_image) |
serve/frontend.py _parts_of, _image_source, images_of |
| Template with picture items | prompt.rs (Part, render_with_images) |
serve/chat_template.jinja |
Encoder client, cache, ENC protocol |
control-plane/src/vision.rs |
serve/server.py Vision, tools/vision/strata_vision.cpp |
| Pad expansion, SVE1 files, M-RoPE positions | crates/serving-policy/src/vision.rs (existing) |
Service.prepare, generate.cpp |
GENI line |
wire.rs (existing) |
StrataEngine.generate |
Flow of a request with pictures: parse the part in the dialect adapter (all three reduce to a Responses
input_image), render_request writes <|vision_start|><|image_pad|><|vision_end|> per picture and returns the
sources in prompt order, the prompt is tokenized, expand_images encodes the pictures (holding Vision::gate, the
mutex the worker also holds for every generation, so encoder and engine never share the GPU), turns each pad that
follows <|vision_start|> into one pad per image token (a pad anywhere else stays literal text), concatenates the SVE1
files into a per-request req-*.sve and puts its path in Generate.embeddings (GENI). The reasoning-budget
wrap-up pass re-sends the same embeddings. The file is removed when the last clone of the request is dropped.
Configuration: a top-level vision object {exe, mmproj, model, gpu, threads, max_tokens, cuda_device} (as in the
Python config). It needs an engine and refuses lazy_load (lazy loading is text-only). strata-vision starts
before the engine, stops when the engine is unloaded and starts again before the next load. /props, /v1/status,
/api/health and /v1/models report images/modalities/architecture accordingly.
Goldens: control-plane/tests/fixtures/golden/vision_dialects.json is recorded from the real Python handlers and
template by gen_goldens.py vision_dialects; tests/vision_http.rs replays all fourteen requests over HTTP against
the mock engine and a stand-in encoder (tests/fixtures/fake_vision.sh) and compares prompt text and picture order.
crates/serving-policy already golden-tests the base64 decoder, sources, expansion and position table.
Deliberate divergences:
- WebP, TIFF, AVIF and other formats
stb_imagecannot read are refused with a clear 400. Python converts them with Pillow; the Python-free serving path has no decoder for them. - A fetched
http(s)image is capped at 64 MiB and a network failure is a 400 naming it (Python: no cap, an unhandledURLError). req-*.svefiles are deleted with the request (Python leaves them in its temp directory).count_tokens/input_tokensrender the prompt with one pad per picture and never start the encoder, as the Python_count_tokensdoes; the true count only exists after encoding.- Local file paths are accepted as image sources exactly as in Python. This lets an API client name any file the server can read as an image (the bytes only reach the encoder), so run the server behind an API key.
- The Chat adapter is stricter than Python's: image parts only in user messages, unknown part keys rejected.
An image beside a
tool_resultin a Messages user turn is kept (Python drops it).
2. Reasoning budget on the live path
The budget was already wired when this item started (wire::ReasoningPlan built by responses.rs::reasoning_plan,
executed in worker.rs::generate: count thinking tokens with serving_policy::reasoning::BudgetTracker, send STOP
at a clean point, discard the tokens until that pass's DONE, deliver the wrap-up tokens, re-submit `prompt + segment
- wrap-up
withmax_new - generated, report one combinedDONE);docs/offline-port.mdstill called it open. What was missing was evidence on that path, becausereasoning_budget_oracle.rsreplays the pure port (reasoning_budget::run`), not the worker:
control-plane/tests/reasoning_budget_live.rs::the_live_worker_matches_python_service_runplays the 288 non-cancel, non-empty-prompt cases of the real-Service.rungolden through the real worker supervisor and a scripted engine process (tests/fixtures/scripted_engine.rs, compiled withrustcat test time; it honoursSTOPbetween tokens) and compares every engine request (prompt,max_new), the finish reason, the completion tokens and the delivered text with Python. A mutation of the budget comparison fails it at case 2.the_budget_applies_on_the_responses_http_pathruns/v1/responses(buffered and streamed) through the real router, tokenizer and template: reasoning, wrap-up text, answer,output_tokens, and the second engine request.
Not applicable: the Chat and Messages adapters pin thinking off (reasoning: none), so reasoning_budget_tokens
has no effect there; the Python server accepts it in every dialect because it thinks by default.
3. MTP with non-greedy sampling (host side)
Oracle: engine/strata/src/program/generate.cpp (the --serve request setup at 5362-5382, the verify loop at
5489-5620), include/strata/core/coupled_draft.hpp, MtpDrafter::set_draft_sampling/set_draft_history.
Already in the tree (not touched): Philox, the sampler chain and the coupled draft arithmetic
(crates/sampler-ref, fixture-tested against the Original headers), original_sampler.rs host helpers, the actor's
CoupledDraftHost, OriginalSpecController (coupled flag, exact-match acceptance), OriginalServeEngine's
history-staged check.
New:
crates/sampler-ref/src/serve.rs-ServeSampling:req_spconstruction (greedy ifftemperature <= 0,seed == 0takes one steady-clock tick,min_pclamped,penalty_last_n >= 0,counter = 0),window(p, consumed, window)(counterp, theT x hist_nliteral penalty rows),draft_history_due(the exacthist_n > 0 && mtp.coupled() && !eos && produced < max_newcondition),draft_history(ring base),draft_params(coupled_ready && !greedy && temperature > 0),draft_counter, pluswindow_rows(theTrule with the confidence floor) andsettle_window(acceptance and the emit loop with eos andmax_new).crates/sampler-ref/tests/serve_loop.rs- the whole serve loop on a toy model with a noisy, optionally subset-headed draft: 768 combinations of sampler settings (top_k / top_p / min_p / the four penalties up to the 4096 cap), prompts, window sizes, draft chains with and without a confidence floor, coupled and argmax drafts, and the seed-0 clock fallback. The speculative token stream equals plain sampled decoding in every one; with a draft equal to the target every coupled draft is accepted and argmax drafts are not. Mutating the window counter or the draft counter (cell + 1) fails the suite.crates/leleka-runtime/src/qwen_forward/original_sampled_serve.rs-SampledServe: the same for the cuda-driver types (SamplerParamsblob,DriverWindowwith the history to upload), cross-checked againstoriginal_sampler.rs(penalty_rows,coupled_hist_base,target_params,request_params). Its tests run incrates/sampler-ref/oracle/run_port_host_tests.sh(macOS) and as ordinary crate tests on Linux.
Call sites for the serve host (nothing in backend.rs or original_serve_*.rs was edited):
| Where | Call |
|---|---|
request start, after request_sampler(..) |
SampledServe::new(¶ms, clock_seed(), actor.coupled()); verifier.set_sampling(s.driver_params()); verifier.set_history(s.hist_n()); actor.set_draft_sampling(s.driver_params()) |
OriginalServePort::run_window |
s.window(position, consumed, inputs) -> NativeHeadSampling { position, params, history, history_len: hist_n, enabled: true } |
OriginalServePort::stage_draft_history |
only when s.draft_history_due(eos, produced, max_new): actor.set_draft_history(consumed, next) |
OriginalServePort::draft_committed(.., coupled) |
coupled = s.coupled_active() |
backend.rs generate_mtp_resume |
drop the sampling is unavailable with MTP branch and pass the request_sampler result to the port |
Still GPU-bound: the device sampler and verifier assets were sealed on 2026-10-15 (nvcc 13.2.86), but nothing above has run on a device yet; the
host sampler of the plain path (step_sampler.rs) remains the only live sampled path.
4. Rust owners for the kernels no Rust code launched
| Kernel | Pure half (existing) | New |
|---|---|---|
native_flash_attn.cu |
native_flash_attn.rs (admission, geometry, FP64 spec) |
ClosedKernels::native_flash_attn_short: literal native_flash_attn::admit on the operands, then <<<24, (32, 4)>>> |
s_gemv.cu, s2_gemv*.cu (17 entries) |
s_gemv_legacy.rs (planners, summation-order models, shim-executed golden) |
ClosedKernels::s_gemv / s2_gemv over a planner Plan, including the dynamic shared memory of the split kernels |
device.cu poison_kernel |
device_arena.rs (poison_launches) |
ClosedKernels::poison_f32, sliced at 0x7FFFFFFF blocks, one drain |
crates/cuda-driver/src/closed_kernels.rs(any host): programs, zero PTX pins (Unpinnedrefusal), the entry signature tables, argument slots (flash_slots,s_gemv_slots,poison_slots), operand byte counts. Tests check every entry against the checked-in.cutext (parameter kinds,__launch_bounds__, the macro-generated S-form entries) and every planner output against its entry (crates/cuda-driver/oracle/run_closed_kernels_host_tests.shruns them on macOS through a shim crate; on Linux they are ordinary crate tests).closed_kernels_gpu.rs(Linux +cuda-driver): the driver half on the generic KAR launcher. The only FFI change isApi::launch_closed(adds the dynamic shared-memory argument;launch_kar_levelscalls it with 0). A block of up to three dimensions was already supported there, so the "2D block" extension in the brief reduced to this.cargo check --target x86_64-unknown-linux-gnu --all-targets -p leleka-cuda-driver --features cuda-driverpasses.closed_kernels_gpu_smoke.rs: three#[ignore]d smokes (closed_gpu_*): the poison pattern; flash attention against the FP64 specification for eleven widths with and without mask plus the invalid-step refusal; the S-form GEMVs replaying the shim-executed golden (bit-exact on the exact cases, 1e-4 relative otherwise, because nvcc may contract the multiply-adds the host shim does not).docs/cuda-seal-plan-additions.json: the three entries now listclosed_kernels.rs/closed_kernels_gpu.rsas consumers andPINS[0..=2]as the fields to fill. The recorded file hashes must be recomputed when sealing.
Everything is OFF: no engine path selects these programs and every pin is zero, so the first open fails closed
before any driver call. Not done (needs nvcc and a GPU): compiling the three .cu files, freezing the pins, running
the smokes. The "misc" kernels of mmq_original_prefill_misc.cu already have their owner
(mmq_original_prefill_misc.rs), so only the poison fill of device.cu was open.
5-7. Not started
- 5 (KAR routed/prefill experts):
engine/strata/src/core/experimental_routed.hppandprefill/experimental_experts.hppare not in the imported tree (onlydocs/experiments/2026-10-14-experimental-modes-port.mdnames them as unported local patches), so there is no source to transcribe; the local-patch source has to be located first. - 6 (multi-GPU verify stage handoff) and 7 (
/api/requestsmonitor, extra/metricsfields): open.