Commit Graph
4 Commits
Author SHA1 Message Date
lotherk c8c3ca492c Sampler: DRY anti-repetition penalty, exposed end to end
The sampler chain gains llama.cpp's dry stage (penalties -> DRY -> top_k -> ...): a token that would extend a
repeat longer than dry_allowed_length over the last dry_penalty_last_n history tokens loses
dry_multiplier * dry_base^(repeat - allowed_length), with tokenized restart sequences capping the scan.

- kernels/cuda/sampler.cu: dry_window/dry_build/apply_dry in the greedy, old, one-block, split and coupled
  penalize kernels; the DRY window is the same history row the penalties count, clamped to kDryWindowCap=512;
  the membership bitmap spans the wider of the two windows and gates both.  Off (the default) the neutral path
  is unchanged: shmem 0, the cluster argmax still runs, the parity fixtures pin every path against a host
  reference (sampler_parity, 19 fixtures).
- include/strata/kernels/sampler.hpp: the dry_* fields, DryBreakers (device flat/off), dry_enabled.
- verify / mtp: Verifier::set_breakers and MtpDrafter::set_draft_breakers thread the tokenized breakers to the
  head sampling and the captured coupled-draft graph (stable device arrays).
- generate.cpp (engine): dry_multiplier / dry_base / dry_allowed_length / dry_penalty_last_n / dry_breakers GEN
  keys; the breaker arrays are allocated once at the cap on the head device, the request refills them; a
  DRY-only request still stages history (the wider of the two windows).
- front end: --dry-multiplier / --dry-base / --dry-allowed-length / --dry-penalty-last-n / --dry-breakers
  defaults and dry_* / dry_sequence_breakers request fields; the front end tokenizes the restart sequences
  (the engine has no tokenizer) and sends them as ids.  The defaults are llama.cpp's: multiplier 0.8, base
  1.75, allowed length 2, window 256, breakers newline, colon, quote, asterisk when unset.
2026-10-14 22:44:58 +01:00
lotherk 7505a9d102 Front end: a hard thinking cap (--reasoning-budget-tokens / reasoning_budget_tokens)
Port upstream Strata's reasoning_budget_tokens to this fork's front end: when the thinking reaches the budget it is closed with a configurable message and the template's end-of-thinking tag, and the engine is asked again with prompt + generated + wrap-up, continuing from the prefix it already holds. Off unless thinking is on and a budget is set (a request's own value wins over the command line). The wrap-up tokens are charged to the response so the context fit is unchanged; usage reports completion_tokens_details.reasoning_tokens. --reasoning-budget-message sets the wrap-up wording (default: upstream's own line).
2026-10-14 07:31:17 +01:00
Robert KarlandClaude Opus 5.5 c3b41cc46a Front end: the answer's content streams as it is written (REGINA-110)
With "stream": true the front end sent reasoning_content per token and the
answer as one delta before the final chunk.  The cause was in run(): every
partial parse had its content cleared together with its tool calls, a rule
added with the image commit (46c46ec) so that partial tool-call JSON, which
the parser closes and normalizes on each token, could never change text
already sent.  That reason holds for tool-call arguments, not for the
answer: the Qwen3-Coder parser's partial content only grows.

The parse of a growing response is now StreamParse: reasoning and content
are published as they arrive, tool calls once from the complete parse.  A
partial parse whose content does not extend what was sent publishes nothing
for the content until it does, and the complete parse cannot take back
streamed text.  A non-streaming request is parsed once, at the end, instead
of after every token.

make test-chat-parser feeds seven responses a character at a time (reasoning
on and off, tools declared and not called, text before a call, one and two
calls) and requires the streamed pieces to add up to the whole parse, the
content to arrive in many deltas, and each call in one.

Checked on the RTX 4090 (VM 221), Q4_K_XL: 212 content deltas for the
ticket's 213-token request, first at 76 ms, largest gap 11.5 ms.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
2026-10-13 02:17:55 -07:00
Robert KarlandClaude Fable 5.1 46c46ecfc1 Front end: image input through the model's vision encoder; engine child supervision; tests
Images: --mmproj PATH loads the Qwen3.8 Flash-Next projector through llama.cpp's mtmd
library and encodes image_url parts on the CPU (frontend/vision.hpp). The embeddings go to
the engine as a GENI request, its existing vision path, with the prompt's <|image_pad|>
runs standing in for each image. --vision-tokens caps the tokens per image. GET /v1/models
lists "image" under input_modalities when the encoder is loaded. Checked on an RTX 4090:
screenshots, photos, several images in one message, and pi's file attachments and
clipboard paste.

Engine process: the engine is started and watched from frontend/engine.hpp; when it exits
or its stall watchdog fires, the front end exits too, for a supervisor to restart. Stall
reports add the current stage and thread wait channels. Reasoning streams; content and
tool calls are sent once the whole message is parsed, so partial JSON never changes
arguments already sent.

Tests: make test-frontend (child exit, protocol, backpressure; no model needed) and
make test-chat-parser MODEL=<gguf> (template and tool-call parsing against the real GGUF).

The image path and the supervision were written by a Codex session; this commit finishes,
documents and checks them.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-08 15:54:53 -07:00