From 2c4fc13573cfc99808afbcf50d1bc897b13aed83 Mon Sep 17 00:00:00 2001 From: ashhart <71890694+ashhart@users.noreply.github.com> Date: Sun, 29 Nov 2026 21:40:04 +0000 Subject: [PATCH] Add bounded request logit bias to native serving --- docs/api.md | 8 +- zig/build/cuda.zig | 4 + zig/build/cuda_server_host.zig | 1 + zig/build/hip.zig | 1 + zig/kernels/cuda/sample_penalties.cuh | 10 ++ zig/src/core/contract/logit_bias_records.zig | 5 + zig/src/core/contract/registry_joins.zig | 2 +- zig/src/core/engine_api.zig | 4 + zig/src/core/engine_api_test.zig | 1 + zig/src/core/engine_bias_test.zig | 58 ++++++ zig/src/core/engine_capabilities.zig | 1 + zig/src/core/engine_request.zig | 1 + zig/src/core/lane_host_lone.zig | 20 ++- zig/src/core/lane_stream.zig | 1 + zig/src/core/lanes/backend.zig | 1 + zig/src/core/lanes/drafted.zig | 2 +- zig/src/core/lanes/drafted_test.zig | 2 + zig/src/core/lanes/lanes.zig | 1 + zig/src/core/lanes/logit_bias.zig | 169 ++++++++++++++++++ zig/src/core/lanes/penalty_rows.zig | 28 +++ zig/src/core/lanes/recorder.zig | 2 +- zig/src/core/lanes/recorder_test.zig | 2 + zig/src/core/lanes/stream.zig | 12 +- zig/src/core/lanes/stream_test.zig | 23 +++ zig/src/cuda/sample.zig | 13 +- zig/src/families/nemotron_parse/backend.zig | 4 +- zig/src/families/qwen3_5/backend.zig | 10 +- zig/src/families/qwen3_5/cuda_native.zig | 16 +- zig/src/families/qwen3_5/cuda_penalties.zig | 91 +++++++++- zig/src/families/qwen3_5/cuda_pick.zig | 4 +- zig/src/families/qwen3_5/draw.zig | 27 +++ zig/src/hip_serve/draw.zig | 89 ++++++++- zig/src/native/cuda.zig | 3 +- zig/src/native/hip.zig | 2 +- zig/src/native/qwen35.zig | 2 +- zig/src/server/chat.zig | 1 + zig/src/server/fields.zig | 2 + zig/src/server/kept_probs.zig | 4 + zig/src/server/logit_bias.zig | 38 ++++ zig/src/server/logit_bias_request_test.zig | 148 +++++++++++++++ zig/src/server/openai.zig | 2 +- zig/src/server/responses_translate.zig | 2 +- zig/src/server/root.zig | 1 + zig/src/server/witness_fixture.zig | 2 +- zig/src/server/witness_reply.zig | 13 ++ zig/src/server/witness_reply_test.zig | 25 +++ zig/tests/cuda/contract_elementwise.zig | 8 + zig/tests/cuda/contract_penalize.zig | 19 +- zig/tests/fixtures/gradient-serving.tsv | 2 +- .../server/golden/framing/chunked-bytes.json | 4 +- .../golden/framing/connection-close.json | 4 +- .../golden/framing/extensions-trailers.json | 4 +- .../golden/framing/keepalive-three.json | 4 +- .../server/golden/framing/pipelined.json | 4 +- .../server/golden/keys/full-model-id.json | 4 +- .../server/golden/keys/full-then-none.json | 4 +- zig/tests/server/golden/keys/models-bare.json | 4 +- zig/tests/server/golden/keys/models-cli.json | 4 +- zig/tests/server/golden/keys/models-env.json | 4 +- zig/tests/server/golden/keys/models-file.json | 4 +- .../server/golden/keys/pooled-identity.json | 4 +- zig/tests/server/golden/keys/rotated-new.json | 4 +- zig/tests/server/golden/models/alias.json | 4 +- zig/tests/server/golden/models/bare.json | 4 +- zig/tests/server/golden/models/served.json | 4 +- .../golden/models/slash-escaped-lower.json | 4 +- .../server/golden/models/slash-escaped.json | 4 +- zig/tests/server/golden/models/slash-raw.json | 4 +- .../server/golden/models/suffix-lists.json | 4 +- .../server/golden/scopes/app-model-id.json | 4 +- .../server/golden/scopes/read-model-id.json | 4 +- .../server/golden/scopes/read-models.json | 4 +- .../server/golden/status/get-models.json | 4 +- .../golden/status/get-v1-models%3Fx=1.json | 4 +- .../server/golden/status/get-v1-models.json | 4 +- .../server/golden/status/get-x-models.json | 4 +- zig/tests/server/logit_bias_served.py | 108 +++++++++++ 77 files changed, 1005 insertions(+), 98 deletions(-) create mode 100644 zig/src/core/contract/logit_bias_records.zig create mode 100644 zig/src/core/engine_bias_test.zig create mode 100644 zig/src/core/lanes/logit_bias.zig create mode 100644 zig/src/server/logit_bias.zig create mode 100644 zig/src/server/logit_bias_request_test.zig create mode 100644 zig/tests/server/logit_bias_served.py diff --git a/docs/api.md b/docs/api.md index dba4d3e9bdc..581ce33894d 100644 --- a/docs/api.md +++ b/docs/api.md @@ -176,7 +176,7 @@ Unsupported image input, audio, video and non-text output requests receive HTTP Each native GET /v1/models entry, including every configured alias, includes a capabilities object. It reports the loaded engine's boolean Info flags: text_generation, context_fitted, call_gates, loop_guard, -thinking_budget, reasoning, reasoning_optional, answer_limit, structures, logprobs, penalties, prompt_logprobs, +thinking_budget, reasoning, reasoning_optional, answer_limit, structures, logprobs, penalties, logit_bias, prompt_logprobs, prompt_cache, cache_salt ([salts](#prompt-cache-salts)), warm_turns, plain_only, decides, pictures, greedy_only, slide_conversations, folded_memory and pocket_usage. folded_memory is true when `--slide` has attached the engine's folded memory weights (living weights), and false when learning is off. The vision, speech, embeddings, readouts and rerank fields @@ -601,6 +601,7 @@ delete runs gets 503, an id that is not a number 400, and an id the graph does n | `max_tokens`, `max_completion_tokens` | Explicit reply limit; rejected if prompt plus reply exceeds the window | Both | | `temperature`, `top_p`, `top_k`, `min_p` | Sampling overrides; zero temperature is greedy | Both | | `presence_penalty`, `frequency_penalty` | OpenAI's, from -2 to 2: before each draw, greedy or sampled, a token the reply already holds loses `presence_penalty` from its logit and `frequency_penalty` once for each time it holds it; the prompt's tokens do not count. Drafted replies equal undrafted ones with them. Applied by Qwen3.8-27B and Qwen3.5-MoE on CUDA, and Qwen3.8-27B and Qwen3.8-Flash-Next on Metal; other engines refuse nonzero values with 400; zero, null and omitted values keep working | Native | +| `logit_bias` | OpenAI's: an object of decimal token IDs (within the tokenizer's vocabulary) to numbers from -100 to 100, at most 300 entries. Before each draw, greedy or sampled, a listed token's logit gains its number; exactly -100 bans the token, so it is never emitted (a forced thinking close or EOS conflicting with a ban fails the reply). Drafted replies equal undrafted ones with it. Applied by Qwen3.8-27B and Qwen3.5-MoE on CUDA (a kernel set built with `tf_bias_rows`), Qwen3.5-2B on Metal and Nemotron Parse on HIP; other engines refuse a non-empty object, even one of zeros, with 400; `{}`, null and omitted keep working | Native | | `seed` | Explicit sampling key; native fallback uses configured defaults, then a fresh key (see below) | Both | | `stream` | Server-sent events; the last event carries usage | Both | | `stream_options.include_usage` | Usage in its own final event with `"choices": []`, not on the finish event | Both | @@ -675,7 +676,8 @@ one token, the best, at probability 1. The server computes them from each token' own cut, so they cost no engine work beyond asking for all 20 alternatives; `top_logprobs` still shows the count asked for, and the reply's tokens and every other field are the same with the option on or off. A sampled request needs `top_k` from 1 to 20, so the kept set always fits inside the 20 alternatives a row carries; other `top_k` -values (including none), a grammar, or a nonzero `presence_penalty` or `frequency_penalty` return HTTP 400. +values (including none), a grammar, non-empty `logit_bias`, or a nonzero `presence_penalty` or `frequency_penalty` +return HTTP 400. The kept set is computed from the rows' 32-bit values, so a token whose cumulative `top_p` sum or `min_p` floor falls within about 1e-6 of its cut can be listed on the other side of it, and a GPU sampler may skip a kept token more than 24 below the best in logit over temperature, whose listed probability is under 4e-11. @@ -1930,7 +1932,7 @@ key may always ask. Only these two routes carry the binding: `/v1/responses`, `/ | `prompt_sha256` | The prompt's token ids after the template, hashed as `tensorfold.token_sha256` hashes the reply's | | `token_sha256` | The reply's token ids, equal to `tensorfold.token_sha256` | | `finish_reason` | The reply's | -| `request` | The resolved request the engine read: `max_tokens` after the window's clamp; `sampling` (null when greedy, else the `seed` actually used, `temperature`, `top_k`, `top_p` and `min_p`); `presence_penalty`, `frequency_penalty`; `eos` and `stop`; `drafts`; `think_budget`, `think_close`, `think_end`, `answer_max`; `loop_guard`, `loop_stop`; `call` (a required tool call's gate); `structure` (the grammar's `kind`, `text_sha256`, `after`, `budget`); `logprobs`, `prompt_logprobs`, `decide` and `untaught` | +| `request` | The resolved request the engine read: `max_tokens` after the window's clamp; `sampling` (null when greedy, else the `seed` actually used, `temperature`, `top_k`, `top_p` and `min_p`); `presence_penalty`, `frequency_penalty`; `eos` and `stop`; `logit_bias` (nonempty requests only: each entry's `token`, `value` and `ban`); `drafts`; `think_budget`, `think_close`, `think_end`, `answer_max`; `loop_guard`, `loop_stop`; `call` (a required tool call's gate); `structure` (the grammar's `kind`, `text_sha256`, `after`, `budget`); `logprobs`, `prompt_logprobs`, `decide` and `untaught` | | `request_sha256` | SHA-256 over `request`, walked in order as below | Every field is length-prefixed: its byte length as a little-endian u64, then its bytes. `request_sha256` hashes the field diff --git a/zig/build/cuda.zig b/zig/build/cuda.zig index 0b5a37e07ba..970e3742610 100644 --- a/zig/build/cuda.zig +++ b/zig/build/cuda.zig @@ -383,6 +383,10 @@ pub fn hostTests(b: *std.Build, draft_ids: *std.Build.Module, build_options: *st const drama3 = @import("drama3_host.zig").hostTests(b, step, cuda, mods.core); const native_modules = engines(b, host, .debug, cuda, mods.core, mods.lanes, mods.nemotron, mods.heat, mods.qwen35, mods.qwen_vision); @import("zonos3.zig").hostTests(b, step, cuda, mods.core, mods.lanes, native_modules.api); + const bias_host = b.step("test-logit-bias-host", "Sparse biases, hard bans, path rows and wrapper propagation without devices"); + bias_host.dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = native_modules.api, .filters = &.{"bias admission:"} })).step); + bias_host.dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = mods.lanes, .filters = &.{ "bias", "recorded backend preserves", "committed first crosses" } })).step); + bias_host.dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = mods.qwen35, .filters = &.{ "bias rows", "bias defaults:" } })).step); b.step("test-qwen-grants-host", "Qwen MTP head-cost and copy grants without a GPU").dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = mods.qwen35, .filters = &.{"shared head costs:"} })).step); b.step("test-nemotron-grants-host", "Nemotron shared head-cost and copy grants without a GPU").dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = mods.nemotron, .filters = &.{"Nemotron shared prices:"} })).step); b.step("test-nemotron-cuda-steps-host", "Nemotron CUDA's stepped prompt pass on the lanes, stopped before GPU work").dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = mods.nemotron, .filters = &.{"nemotron cuda steps:"} })).step); diff --git a/zig/build/cuda_server_host.zig b/zig/build/cuda_server_host.zig index 4ef6323af31..7a44735b85d 100644 --- a/zig/build/cuda_server_host.zig +++ b/zig/build/cuda_server_host.zig @@ -119,6 +119,7 @@ pub fn steps(b: *std.Build, host: std.Build.ResolvedTarget, cuda: *std.Build.Mod prefill.has_side_effects = true; // reads TF_TOKENIZER_DIRS on every run prefill.setCwd(b.path(".")); b.step("test-prefill-host", "Continued final assistant messages on Messages and chat routes and real templates, no devices").dependOn(&prefill.step); + b.step("test-server-logit-bias-host", "Real HTTP token bias forwarding, refusal and sparse parsing").dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = server_tests, .filters = &.{"logit_bias:"} })).step); b.step("test-cors-template-host", "Exact CORS and special-preserving template route regressions").dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = server_tests, .filters = &.{ "CORS", "apply-template:" } })).step); const salts = b.step("test-cache-salt-host", "Salted state, disk, Recall and per-key route isolation"); salts.dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = server_tests, .filters = &.{ "salts:", "salts per key:", "two salts never", "a salted text prompt", "the routes:", "cache salt isolation:" } })).step); diff --git a/zig/build/hip.zig b/zig/build/hip.zig index 8425ac30021..c03b60a589d 100644 --- a/zig/build/hip.zig +++ b/zig/build/hip.zig @@ -167,6 +167,7 @@ pub fn steps(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.buil native_ocr.dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = host.native, .filters = &.{"GLM-OCR native flags:"} })).step); native_ocr.dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = host.native.import_table.get("glm_ocr").?, .filters = &.{"GLM-OCR native admission:"} })).step); b.step("test-hip-family-offers-host", "HIP optional native family metadata without device execution").dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = host.native, .filters = &.{"HIP optional family offers:"} })).step); + b.step("test-hip-logit-bias-host", "Host bias and ban draws without a HIP device").dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = host.serve, .filters = &.{"logit_bias"} })).step); b.step("test-hip-native-options-host", "Shared HIP native open settings without device execution").dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = host.serve, .filters = &.{"HIP native options:"} })).step); @import("hip_followers.zig").steps(b, &.{ host.serve, host.flashnext, host.nemotron }); @import("dots_mocr.zig").hipTests(b, host.hip, test_step); diff --git a/zig/kernels/cuda/sample_penalties.cuh b/zig/kernels/cuda/sample_penalties.cuh index 102a29c12c6..3226df3d288 100644 --- a/zig/kernels/cuda/sample_penalties.cuh +++ b/zig/kernels/cuda/sample_penalties.cuh @@ -8,3 +8,13 @@ extern "C" __global__ void __launch_bounds__(256) tf_penalize_rows(__nv_bfloat16 __nv_bfloat16* x = L + static_cast(ROW[i]) * V + TOK[i]; *x = __float2bfloat16(__bfloat162float(*x) - SUB[i]); } + +// Bias entries use the same subtraction, with +inf as an unconditional hard ban (including nonfinite input). +extern "C" __global__ void __launch_bounds__(256) tf_bias_rows(__nv_bfloat16* L, unsigned V, const unsigned* ROW, + const unsigned* TOK, const float* SUB, unsigned n) { + const unsigned i = blockIdx.x * blockDim.x + threadIdx.x; + if (i >= n) return; + __nv_bfloat16* x = L + static_cast(ROW[i]) * V + TOK[i]; + *x = __float2bfloat16(SUB[i] == __int_as_float(0x7f800000) ? -__int_as_float(0x7f800000) + : __bfloat162float(*x) - SUB[i]); +} diff --git a/zig/src/core/contract/logit_bias_records.zig b/zig/src/core/contract/logit_bias_records.zig new file mode 100644 index 00000000000..343cb536aeb --- /dev/null +++ b/zig/src/core/contract/logit_bias_records.zig @@ -0,0 +1,5 @@ +//! The new sparse bias launch needs measured resource receipts before landing. +const registry = @import("registry.zig"); +pub const records = [_]registry.CudaRecord{ + .{ .launch = .{ .name = "sample tf_bias_rows", .symbol = "tf_bias_rows", .image = "sample", .threads = 256 }, .usage = registry.none }, +}; diff --git a/zig/src/core/contract/registry_joins.zig b/zig/src/core/contract/registry_joins.zig index f0db713325b..ab71ccc0760 100644 --- a/zig/src/core/contract/registry_joins.zig +++ b/zig/src/core/contract/registry_joins.zig @@ -63,7 +63,7 @@ pub const nvcc_133_after = @import("flashnext_tile_records.zig").cuda_133 ++ @import("experts_bf16_records.zig").cuda_133 ++ @import("int4_records.zig").cuda_133; pub const cuda_sets_after = [_]registry.CudaSet{.{ .release = .{ .major = 13, .minor = 4 }, .usage = &@import("mhc_cuda_records.zig").cuda_134 }}; -pub const cuda_pending = @import("mhc_cuda_records.zig").cuda ++ @import("qwen_whole_records.zig").records ++ +pub const cuda_pending = @import("mhc_cuda_records.zig").cuda ++ @import("logit_bias_records.zig").records ++ @import("qwen_whole_records.zig").records ++ @import("qwen_prompt_split_records.zig").records ++ @import("flashnext_tile_records.zig").pending ++ @import("int4_records.zig").records ++ diff --git a/zig/src/core/engine_api.zig b/zig/src/core/engine_api.zig index 20975aa3dca..10e8c66607a 100644 --- a/zig/src/core/engine_api.zig +++ b/zig/src/core/engine_api.zig @@ -12,6 +12,7 @@ pub const Id = u64; pub const Sampling = lanes.Sampling; /// presence_penalty and frequency_penalty, applied where ``Info.penalties``. pub const Penalties = lanes.Penalties; +pub const LogitBias = lanes.logit_bias.Entry; pub const EmbeddingInfo = lanes.embedding.Info; pub const EmbeddingBatch = lanes.embedding.Batch; pub const embedding_vector = @import("embedding_vector.zig"); @@ -154,6 +155,7 @@ pub const Info = struct { logprobs: bool = false, /// Requests' presence_penalty and frequency_penalty change the draws (false: nonzero is refused). penalties: bool = false, + logit_bias: bool = false, // sparse request token biases, including hard bans at -100 /// Requests may ask for ``prompt_logprobs`` (a prompt pass from 0 that reads every row). prompt_logprobs: bool = false, /// Prompt rows a prefill chunk at most, for the server's chunk starts (0: the engine cuts prompts itself). @@ -426,6 +428,8 @@ pub const Engine = struct { pub fn submit(e: Engine, id: Id, request: *const Request, sink: Sink) SubmitError!void { try @import("cache_modes.zig").validate(request.decode_spans); const info_ = e.info(); + if (request.logit_bias.len > 0 and (!info_.logit_bias or request.promptOnly())) return error.InvalidRequest; + lanes.logit_bias.check(request.logit_bias) catch return error.InvalidRequest; if (request.embedding != null and request.readout != null) return error.InvalidRequest; if (request.readout != null) { lanes.readout.admit(info_, request) catch return error.InvalidRequest; diff --git a/zig/src/core/engine_api_test.zig b/zig/src/core/engine_api_test.zig index 34fb2079360..5a28fcf7837 100644 --- a/zig/src/core/engine_api_test.zig +++ b/zig/src/core/engine_api_test.zig @@ -1,5 +1,6 @@ //! Host behavior checks for the shared engine API. test { + _ = @import("engine_bias_test.zig"); _ = @import("lane_embedding_test.zig"); _ = @import("lane_readout_test.zig"); _ = @import("speech_guard.zig"); diff --git a/zig/src/core/engine_bias_test.zig b/zig/src/core/engine_bias_test.zig new file mode 100644 index 00000000000..57f30ff0157 --- /dev/null +++ b/zig/src/core/engine_bias_test.zig @@ -0,0 +1,58 @@ +//! Native submission refuses malformed biases and prompt-only work before calling a backend. +const std = @import("std"); +const api = @import("engine_api.zig"); + +const Spy = struct { + offered: bool = true, + submissions: usize = 0, + fn engine(s: *Spy) api.Engine { + return .{ .ctx = s, .vtable = &.{ .info = info, .submit = submit, .cancel = cancel, .status = status, .memory = memory } }; + } + fn info(ctx: *anyopaque) api.Info { + const s: *Spy = @ptrCast(@alignCast(ctx)); + return .{ .context_window = 8, .logit_bias = s.offered }; + } + fn submit(ctx: *anyopaque, _: api.Id, _: *const api.Request, _: api.Sink) api.SubmitError!void { + const s: *Spy = @ptrCast(@alignCast(ctx)); + s.submissions += 1; + } + fn cancel(_: *anyopaque, _: api.Id) void {} + fn status(_: *anyopaque, out: *api.Status, _: []u32) void { + out.* = .{}; + } + fn memory(_: *anyopaque, _: bool) ?api.Memory { + return null; + } + fn event(_: *anyopaque, _: api.Id, _: *const api.Event) void {} +}; + +test "bias admission: malformed native entries and prompt-only requests never reach the backend" { + var spy: Spy = .{}; + const engine = spy.engine(); + const sink: api.Sink = .{ .ctx = &spy, .event = Spy.event }; + var request: api.Request = .{ .prompt = &.{1}, .max_tokens = 1 }; + for ([_][]const api.LogitBias{ + &.{ .{ .token = 1, .value = 0 }, .{ .token = 1, .value = 2 } }, + &.{ .{ .token = 2, .value = 0 }, .{ .token = 1, .value = 2 } }, + &.{.{ .token = 1, .value = std.math.nan(f32) }}, + &.{.{ .token = 1, .value = 101 }}, + }) |entries| { + request.logit_bias = entries; + try std.testing.expectError(error.InvalidRequest, engine.submit(1, &request, sink)); + } + request.logit_bias = &.{.{ .token = 1, .value = 2 }}; + spy.offered = false; + try std.testing.expectError(error.InvalidRequest, engine.submit(1, &request, sink)); + spy.offered = true; + var vector: [1]f32 = undefined; + request.embedding = .{ .ends = &.{1}, .dimensions = 1, .output = &vector }; + try std.testing.expectError(error.InvalidRequest, engine.submit(1, &request, sink)); + try std.testing.expectEqual(@as(usize, 0), spy.submissions); + request.embedding = null; + try engine.submit(1, &request, sink); + try std.testing.expectEqual(@as(usize, 1), spy.submissions); + spy.offered = false; + request.logit_bias = &.{}; + try engine.submit(2, &request, sink); + try std.testing.expectEqual(@as(usize, 2), spy.submissions); +} diff --git a/zig/src/core/engine_capabilities.zig b/zig/src/core/engine_capabilities.zig index 5439e617508..2cf73da4308 100644 --- a/zig/src/core/engine_capabilities.zig +++ b/zig/src/core/engine_capabilities.zig @@ -13,6 +13,7 @@ pub const Capability = enum { structures, logprobs, penalties, + logit_bias, prompt_logprobs, prompt_cache, cache_salt, diff --git a/zig/src/core/engine_request.zig b/zig/src/core/engine_request.zig index a15fa3d5428..51b65365c68 100644 --- a/zig/src/core/engine_request.zig +++ b/zig/src/core/engine_request.zig @@ -24,6 +24,7 @@ pub const Request = struct { max_tokens: u32, sampling: ?Sampling = null, penalties: Penalties = .{}, + logit_bias: []const lanes.logit_bias.Entry = &.{}, /// Tokens that end the reply as ``stop`` (the token is delivered); empty when the request ignores EOS. eos: []const u32 = &.{}, stop: ?Stop = null, diff --git a/zig/src/core/lane_host_lone.zig b/zig/src/core/lane_host_lone.zig index 7c568c63f81..289be8dc954 100644 --- a/zig/src/core/lane_host_lone.zig +++ b/zig/src/core/lane_host_lone.zig @@ -16,7 +16,25 @@ fn takes(h: *LaneHost, job: *Job) bool { const r = job.request; const lone = h.lone orelse return false; const think = lone.min_budget > 0 and (r.think_budget == 0 or r.think_budget > lone.min_budget); - return !((r.sampling != null and !lone.sampled) or (!r.drafts and !lone.plain) or ((r.think_budget > 0 or r.loop_guard) and !think) or r.call != null or (r.structure != null and !lone.structures) or r.penalties.active() or (r.images.len > 0 and !lone.images) or r.audios.len > 0 or (r.logprobs != null and !lone.logprobs) or r.prompt_logprobs != null); + return !((r.sampling != null and !lone.sampled) or (!r.drafts and !lone.plain) or ((r.think_budget > 0 or r.loop_guard) and !think) or r.call != null or (r.structure != null and !lone.structures) or r.penalties.active() or r.logit_bias.len > 0 or (r.images.len > 0 and !lone.images) or r.audios.len > 0 or (r.logprobs != null and !lone.logprobs) or r.prompt_logprobs != null); +} + +test "logit_bias: a request cannot enter a lone driver that has no bias contract" { + const std = @import("std"); + const api = @import("engine_api.zig"); + const Driver = struct { + fn run(_: *anyopaque, _: *@import("lanes").Stream, _: api.LoneHooks) anyerror!bool { + return error.UnexpectedLoneRun; + } + }; + var h: LaneHost = undefined; + h.lone = .{ .ctx = &h, .run = Driver.run }; + var request: api.Request = .{ .prompt = &.{1}, .max_tokens = 1 }; + var job: Job = undefined; + job.request = &request; + try std.testing.expect(takes(&h, &job)); + request.logit_bias = &.{.{ .token = 1, .value = 0 }}; + try std.testing.expect(!takes(&h, &job)); } /// After a round: the lane core's last live stream goes back to the driver when nothing else waits or is due. diff --git a/zig/src/core/lane_stream.zig b/zig/src/core/lane_stream.zig index 641ecd43ba8..c11845cda05 100644 --- a/zig/src/core/lane_stream.zig +++ b/zig/src/core/lane_stream.zig @@ -91,6 +91,7 @@ pub fn open(h: *LaneHost, job: *Job) bool { .eos = r.eos, .sampling = r.sampling, .penalties = r.penalties, + .logit_bias = r.logit_bias, .drafts = r.drafts, .proposer = job.custom orelse job.proposer.proposer(), .recall = recall, diff --git a/zig/src/core/lanes/backend.zig b/zig/src/core/lanes/backend.zig index 38b57f855cc..963e0a0c1a8 100644 --- a/zig/src/core/lanes/backend.zig +++ b/zig/src/core/lanes/backend.zig @@ -91,6 +91,7 @@ pub const Backend = struct { keep_full_lone: bool = false, /// Every draw (first, queue and verify rows) takes `Stream.penalties` from the reply's tokens; wrappers copy it. penalties: bool = false, + logit_bias: bool = false, // every target draw honours Stream.logit_bias /// Prompt fill gives the same tokens at any chunk cut, so --decode-share may cap its chunk rows; wrappers copy it. chunk_invariant: bool = false, /// Whether image requests may run a background warm prefill; wrappers preserve the target policy. diff --git a/zig/src/core/lanes/drafted.zig b/zig/src/core/lanes/drafted.zig index 1581b79bef3..31df6d565c5 100644 --- a/zig/src/core/lanes/drafted.zig +++ b/zig/src/core/lanes/drafted.zig @@ -72,7 +72,7 @@ pub const Drafted = struct { }; pub fn backend(x: *Drafted) be.Backend { const planned = if (x.drafter.proposal_head) |service| service.mode != .legacy and x.drafter.vtable.hold_planned != null and x.drafter.vtable.clear_proposals != null else false; - return .{ .proposal_head = x.drafter.proposal_head, .ptr = x, .round_observer = x.target.round_observer, .first_before_draft = x.target.first_before_draft, .keep_full_lone = x.target.keep_full_lone, .penalties = x.target.penalties, .chunk_invariant = x.target.chunk_invariant, .warm_images = x.target.warm_images, .vtable = vtableFor(planned, x.target.vtable.prefill_step != null and x.target.vtable.reports_fill and x.target.vtable.features != null, x.target.vtable.cancel_prefill != null, x.first_rows) }; + return .{ .proposal_head = x.drafter.proposal_head, .ptr = x, .round_observer = x.target.round_observer, .first_before_draft = x.target.first_before_draft, .keep_full_lone = x.target.keep_full_lone, .penalties = x.target.penalties, .logit_bias = x.target.logit_bias, .chunk_invariant = x.target.chunk_invariant, .warm_images = x.target.warm_images, .vtable = vtableFor(planned, x.target.vtable.prefill_step != null and x.target.vtable.reports_fill and x.target.vtable.features != null, x.target.vtable.cancel_prefill != null, x.first_rows) }; } const cancellable: [4]be.Backend.VTable = blk: { diff --git a/zig/src/core/lanes/drafted_test.zig b/zig/src/core/lanes/drafted_test.zig index f8ac1008761..d7962c260b4 100644 --- a/zig/src/core/lanes/drafted_test.zig +++ b/zig/src/core/lanes/drafted_test.zig @@ -283,10 +283,12 @@ pub fn run(cases: []const Case, mode: Mode, batched: bool) !Out { var target_backend = strict.backend(); target_backend.first_before_draft = mode == .wrapped_early; target_backend.penalties = mode == .wrapped_early; + target_backend.logit_bias = mode == .wrapped_early; var wrapped = try Drafted.init(gpa, target_backend, head.drafter()); defer wrapped.deinit(); try std.testing.expectEqual(mode == .wrapped_early, wrapped.backend().first_before_draft); try std.testing.expectEqual(mode == .wrapped_early, wrapped.backend().penalties); + try std.testing.expectEqual(mode == .wrapped_early, wrapped.backend().logit_bias); var m = base(); m.root_copies = cases[0].root_copies; var cfg = try Config.init(gpa, if (mode != .plain) wrapped.facts(m) else m, 16, 15); diff --git a/zig/src/core/lanes/lanes.zig b/zig/src/core/lanes/lanes.zig index a12eb104d88..72d21d0b125 100644 --- a/zig/src/core/lanes/lanes.zig +++ b/zig/src/core/lanes/lanes.zig @@ -65,6 +65,7 @@ pub fn cutPoints(s: *const Stream) []const u32 { } pub const Sampling = sampling.Sampling; +pub const logit_bias = @import("logit_bias.zig"); pub const Penalties = sampling.Penalties; pub const SuffixLookup = proposer.SuffixLookup; pub const LogprobRow = logprob.Row; diff --git a/zig/src/core/lanes/logit_bias.zig b/zig/src/core/lanes/logit_bias.zig new file mode 100644 index 00000000000..2a4653660b5 --- /dev/null +++ b/zig/src/core/lanes/logit_bias.zig @@ -0,0 +1,169 @@ +//! Sparse request scores. -100 is a hard ban; other values add to FP32 logits before sampling. +const std = @import("std"); +const sampling = @import("sampling.zig"); +const grammar = @import("grammar.zig"); +// This module is also built as the independent lanes root, so keep the wire conversion here. +const bf = struct { + fn value(word: u16) f32 { + return @bitCast(@as(u32, word) << 16); + } + fn bits(x: f32) u16 { + const u: u32 = @bitCast(x); + if (std.math.isNan(x)) return @truncate((u >> 16) | 0x40); + return @truncate((u +% 0x7fff +% ((u >> 16) & 1)) >> 16); + } + fn round32(x: f32) f32 { + return value(bits(x)); + } +}; + +/// A request's list is sorted by token, each token once, as the server's parse leaves it. +pub const Entry = struct { token: u32, value: f32, ban: bool = false }; + +/// The entry for `token` in a sorted list: a binary search, since a host draw asks once a vocabulary token. +pub fn find(entries: []const Entry, token: u32) ?Entry { + var lo: usize = 0; + var hi: usize = entries.len; + while (lo < hi) { + const mid = lo + (hi - lo) / 2; + if (entries[mid].token == token) return entries[mid]; + if (entries[mid].token < token) lo = mid + 1 else hi = mid; + } + return null; +} + +/// The existing subtract kernel's amount: combine once per cell, so no concurrent writers touch one logit. +pub fn subtract(penalty: f32, value: ?Entry) f32 { + const b = value orelse return penalty; + return if (b.ban) std.math.inf(f32) else penalty - b.value; +} + +/// Every entry must address the row before any scoring or forced-token return. +pub fn validate(vocab: usize, entries: []const Entry) !void { + for (entries) |e| if (e.token >= vocab) return error.BadLogitBiasToken; + try check(entries); +} + +/// Native callers have the same bounded, finite, uniquely ordered request contract as HTTP callers. +pub fn check(entries: []const Entry) error{BadLogitBias}!void { + if (entries.len > 300) return error.BadLogitBias; + var previous: ?u32 = null; + for (entries) |e| { + if (!std.math.isFinite(e.value) or e.value < -100 or e.value > 100) return error.BadLogitBias; + if (e.ban and e.value != -100) return error.BadLogitBias; + if (previous) |p| if (e.token <= p) return error.BadLogitBias; + previous = e.token; + } +} + +pub fn apply(values: []f32, entries: []const Entry) !void { + try validate(values.len, entries); + for (entries) |e| { + const x = &values[e.token]; + x.* = if (e.ban) -std.math.inf(f32) else x.* - subtract(0, e); + } +} + +/// Host draws of raw BF16 rows apply a bias and round as the CUDA sparse launch does, without editing cached logits. +pub fn draw(a: std.mem.Allocator, words: []const u16, settings: ?sampling.Sampling, position: u64, mask: []const u32, entries: []const Entry) !u32 { + try validate(words.len, entries); + const values = try a.alloc(f64, words.len); + defer a.free(values); + const ids = try a.alloc(u64, words.len); + defer a.free(ids); + var n: usize = 0; + for (words, 0..) |word, id| { + var x = bf.value(word); + if (entries.len > 0) { + const b = find(entries, @intCast(id)); + if (b != null and b.?.ban) continue; + if (!std.math.isFinite(x)) return error.NonfiniteLogits; + if (b != null) x = bf.round32(x - subtract(0, b)); + } + // Empty entries also draws an already processed CUDA row, with bans encoded as -inf. + if (x == -std.math.inf(f32)) continue; + if (!std.math.isFinite(x)) return error.NonfiniteLogits; + if (mask.len > 0 and !grammar.allows(mask, id)) continue; + values[n] = x; + ids[n] = id; + n += 1; + } + if (n == 0) return error.NoAllowedToken; + return @intCast(try sampling.choose(a, values[0..n], ids[0..n], position, settings orelse .{ .seed = 0, .temperature = 0 })); +} + +test "bias shifts greedy picks, bans exclude even a nonfinite maximum and grammar cannot restore a ban" { + const a = std.testing.allocator; + const words = [_]u16{ bf.bits(10), bf.bits(9), bf.bits(0) }; + try std.testing.expectEqual(@as(u32, 1), try draw(a, &words, null, 0, &.{}, &.{.{ .token = 1, .value = 2 }})); + const entries = [_]Entry{ .{ .token = 0, .value = -100, .ban = true }, .{ .token = 2, .value = 20 } }; + for (0..128) |position| { + const s: sampling.Sampling = .{ .seed = position, .top_k = 0, .top_p = 1 }; + try std.testing.expect(try draw(a, &words, s, position, &.{}, &entries) != 0); + } + try std.testing.expectError(error.NoAllowedToken, draw(a, &words, null, 0, &.{1}, &entries)); + try std.testing.expectEqual(@as(u32, 1), try draw(a, &.{ 0x7f80, bf.bits(1) }, null, 0, &.{}, entries[0..1])); + var values = [_]f32{ 10000, 1, 0 }; + try apply(&values, &entries); + try std.testing.expectEqual(-std.math.inf(f32), values[0]); + try std.testing.expectEqual(@as(f32, 20), values[2]); +} + +test "bias draws equal main's row draw over the processed row, raw or as the device leaves it, and never take a ban" { + const a = std.testing.allocator; + const rowDraw = @import("sampling_row.zig").draw; + var raw: [64]u16 = undefined; + for (&raw, 0..) |*w, i| w.* = bf.bits(@as(f32, @floatFromInt((i * 37) % 61)) / 8.0 - 4.0); + const entries = [_]Entry{ .{ .token = 3, .value = 1.25 }, .{ .token = 17, .value = -100, .ban = true }, .{ .token = 40, .value = -0.75 } }; + var processed = raw; // tf_bias_rows: the amount taken in fp32, rounded once to bf16; a ban is -inf + var reference = raw; // main's row draw refuses -inf, so a ban there is bf16's lowest finite value + for (entries) |e| { + processed[e.token] = if (e.ban) 0xff80 else bf.bits(bf.value(raw[e.token]) - subtract(0, e)); + reference[e.token] = if (e.ban) 0xff7f else processed[e.token]; + } + const mask = [_]u32{ 0xffff_fffe, 0xffff_ffff }; // token 0 disallowed + for ([_]u32{ 0, 1, 20 }) |top_k| for (0..32) |position| { + const s: sampling.Sampling = .{ .seed = 99, .temperature = 0.8, .top_k = top_k, .top_p = 0.95 }; + for ([_]?sampling.Sampling{ null, s }) |settings| for ([_][]const u32{ &.{}, &mask }) |m| { + const want = try rowDraw(a, &reference, settings, position, m); + try std.testing.expect(want != 17); + try std.testing.expectEqual(want, try draw(a, &raw, settings, position, m, &entries)); + try std.testing.expectEqual(want, try draw(a, &processed, settings, position, m, &.{})); + }; + }; + try std.testing.expectEqual(@as(?Entry, null), find(&entries, 4)); + try std.testing.expectEqual(@as(u32, 40), find(&entries, 40).?.token); +} + +fn allocationCase(a: std.mem.Allocator) !void { + _ = try draw(a, &.{ 0x3f80, 0x4000 }, null, 0, &.{}, &.{.{ .token = 0, .value = 3 }}); +} + +test "bias host draws refuse an entry past the row's words, as the CUDA sparse launch does" { + const a = std.testing.allocator; + const words = [_]u16{ 0, 0, 0, 0 }; + _ = try draw(a, &words, null, 0, &.{}, &.{.{ .token = 3, .value = 1 }}); + try std.testing.expectError(error.BadLogitBiasToken, draw(a, &words, null, 0, &.{}, &.{.{ .token = 4, .value = 1 }})); + try std.testing.expectError(error.BadLogitBiasToken, draw(a, &words, null, 0, &.{}, &.{ .{ .token = 9, .value = 0 }, .{ .token = 0, .value = 1 } })); +} + +test "bias host allocations release both arrays on every allocation failure" { + try std.testing.checkAllAllocationFailures(std.testing.allocator, allocationCase, .{}); +} + +test "bias native entries reject duplicates, unordered IDs, nonfinite scores and inconsistent hard bans" { + for ([_][]const Entry{ + &.{ .{ .token = 1, .value = 0 }, .{ .token = 1, .value = 1 } }, + &.{ .{ .token = 2, .value = 0 }, .{ .token = 1, .value = 1 } }, + &.{.{ .token = 1, .value = std.math.nan(f32) }}, + &.{.{ .token = 1, .value = std.math.inf(f32) }}, + &.{.{ .token = 1, .value = 101 }}, + &.{.{ .token = 1, .value = -101 }}, + &.{.{ .token = 1, .value = 0, .ban = true }}, + }) |entries| try std.testing.expectError(error.BadLogitBias, check(entries)); + var many: [301]Entry = undefined; + for (&many, 0..) |*e, i| e.* = .{ .token = @intCast(i), .value = 0 }; + try std.testing.expectError(error.BadLogitBias, check(&many)); + try check(many[0..300]); + try check(&.{.{ .token = 1, .value = -100 }}); // rounded near-ban scores stay finite additions +} diff --git a/zig/src/core/lanes/penalty_rows.zig b/zig/src/core/lanes/penalty_rows.zig index fc2d1adcf0a..8cfff0a5e21 100644 --- a/zig/src/core/lanes/penalty_rows.zig +++ b/zig/src/core/lanes/penalty_rows.zig @@ -3,6 +3,7 @@ const std = @import("std"); const Stream = @import("stream.zig").Stream; const Window = @import("backend.zig").Window; const Penalties = @import("sampling.zig").Penalties; +const logit_bias = @import("logit_bias.zig"); /// A window's rows at most here: its pending row and its drafts. pub const most_rows = 256; @@ -14,6 +15,8 @@ pub const Entries = struct { subs: std.ArrayList(f32) = .empty, /// The current window's counts: the reply's tokens before it, then its pending token. counts: std.AutoArrayHashMapUnmanaged(u32, u32) = .empty, + /// Set when a staged row carries a request bias; the CUDA draw then uses the bias kernel. + biased: bool = false, pub fn deinit(self: *Entries, gpa: std.mem.Allocator) void { self.rows.deinit(gpa); @@ -30,6 +33,7 @@ pub const Entries = struct { self.rows.clearRetainingCapacity(); self.toks.clearRetainingCapacity(); self.subs.clearRetainingCapacity(); + self.biased = false; } /// A window's reply so far: `stream`'s committed tokens before `cache_len`, then `next`, the token at `cache_len`. @@ -56,6 +60,30 @@ pub const Entries = struct { }; } + /// Row `at`'s entries under `p` and `bias`; an empty list stages exactly `row`'s entries. + pub fn rowBias(self: *Entries, gpa: std.mem.Allocator, at: u32, p: Penalties, path: []const u32, bias: []const logit_bias.Entry) !void { + if (bias.len == 0) return self.row(gpa, at, p, path); + for (path) |t| try bump(gpa, &self.counts, t, 1); + defer for (path) |t| bump(gpa, &self.counts, t, -1) catch unreachable; + const n = self.counts.count() + bias.len; + self.biased = true; + try self.rows.ensureUnusedCapacity(gpa, n); + try self.toks.ensureUnusedCapacity(gpa, n); + try self.subs.ensureUnusedCapacity(gpa, n); + for (self.counts.keys(), self.counts.values()) |t, c| if (c > 0 and p.active()) { + self.rows.appendAssumeCapacity(at); + self.toks.appendAssumeCapacity(t); + self.subs.appendAssumeCapacity(logit_bias.subtract(p.of(c), logit_bias.find(bias, t))); + }; + for (bias) |b| { + const count = self.counts.get(b.token) orelse 0; + if (p.active() and count > 0) continue; + self.rows.appendAssumeCapacity(at); + self.toks.appendAssumeCapacity(b.token); + self.subs.appendAssumeCapacity(logit_bias.subtract(0, b)); + } + } + /// A verify window's rows from row `first`: `drafts` are its rows 1.. (held or host), drawn at `w.positions`. pub fn stageWindow(self: *Entries, gpa: std.mem.Allocator, w: Window, drafts: []const u32, first: usize) !void { if (!w.stream.penalties.active()) return; diff --git a/zig/src/core/lanes/recorder.zig b/zig/src/core/lanes/recorder.zig index 6625017c115..f7f8d363703 100644 --- a/zig/src/core/lanes/recorder.zig +++ b/zig/src/core/lanes/recorder.zig @@ -239,7 +239,7 @@ pub const Recorded = struct { pub fn backend(x: *Recorded) be.Backend { const v = x.inner.vtable; x.table = .{ .prefill = prefill, .prefill_step = if (v.prefill_step != null) prefillStep else null, .cancel_prefill = if (v.cancel_prefill != null) cancelPrefill else null, .prefill_many = if (v.prefill_many != null) prefillMany else null, .first = first, .queue = queue, .read = read, .verify = verify, .keep = keep, .draft = draft, .draft_capacity = if (v.draft_capacity != null) draftCapacity else null, .proposal_draft = if (v.proposal_draft != null) plannedDraft else null, .clear_proposals = if (v.clear_proposals != null) clearProposals else null, .unspeculate = if (v.unspeculate != null) unspeculate else null, .probabilities = if (v.probabilities != null) probabilities else null, .tree = if (v.tree != null) tree else null, .alternatives = if (v.alternatives != null) alternatives else null, .prepare_features = if (v.prepare_features != null) prepareFeatures else null, .features = features, .first_row = if (v.first_row != null) firstRow else null, .first_masked = if (v.first_masked != null) firstMasked else null, .score = if (v.score != null) score else null, .held = if (v.held != null) held else null, .prompt_rows = v.prompt_rows, .release = release }; - return .{ .proposal_head = x.inner.proposal_head, .ptr = x, .round_observer = x.inner.round_observer, .vtable = &x.table, .first_before_draft = x.inner.first_before_draft, .keep_full_lone = x.inner.keep_full_lone, .penalties = x.inner.penalties, .chunk_invariant = x.inner.chunk_invariant, .warm_images = x.inner.warm_images }; + return .{ .proposal_head = x.inner.proposal_head, .ptr = x, .round_observer = x.inner.round_observer, .vtable = &x.table, .first_before_draft = x.inner.first_before_draft, .keep_full_lone = x.inner.keep_full_lone, .penalties = x.inner.penalties, .logit_bias = x.inner.logit_bias, .chunk_invariant = x.inner.chunk_invariant, .warm_images = x.inner.warm_images }; } fn of(p: *anyopaque) *Recorded { diff --git a/zig/src/core/lanes/recorder_test.zig b/zig/src/core/lanes/recorder_test.zig index 43bb3b004f2..4835b632967 100644 --- a/zig/src/core/lanes/recorder_test.zig +++ b/zig/src/core/lanes/recorder_test.zig @@ -282,11 +282,13 @@ test "recorded backend preserves first-before-draft, penalties, chunk invariance var inner = target.backend(); inner.first_before_draft = enabled; inner.penalties = enabled; + inner.logit_bias = enabled; inner.chunk_invariant = enabled; inner.keep_full_lone = enabled; var recorded = try rec.Recorded.init(inner, &recorder); try std.testing.expectEqual(enabled, recorded.backend().first_before_draft); try std.testing.expectEqual(enabled, recorded.backend().penalties); + try std.testing.expectEqual(enabled, recorded.backend().logit_bias); try std.testing.expectEqual(enabled, recorded.backend().chunk_invariant); try std.testing.expectEqual(enabled, recorded.backend().keep_full_lone); } diff --git a/zig/src/core/lanes/stream.zig b/zig/src/core/lanes/stream.zig index 89cc3f98d6a..ec3fad51ec8 100644 --- a/zig/src/core/lanes/stream.zig +++ b/zig/src/core/lanes/stream.zig @@ -22,7 +22,6 @@ pub const Reason = enum { return if (r == .none) "" else @tagName(r); } }; - pub const Mode = enum { pipe, drain, verify, exit }; pub const loop_max_period: usize = 8; pub const loop_min_run: usize = 256; @@ -49,7 +48,6 @@ fn cycleAt(head: []const u32, tail: []const u32, n: usize) ?u32 { } return null; } - /// Return the first token index in a candidate batch that would fire the guard. pub fn loopCut(s: *const Stream, tokens: []const u32) ?usize { if (!s.loop_guard or !s.think_open or s.think_end < 0 or s.loop_period != null) return null; @@ -60,7 +58,6 @@ pub fn loopCut(s: *const Stream, tokens: []const u32) ?usize { } return null; } - /// Return the detected period at the end of committed tokens, or null. pub fn detectLoop(emitted: []const u32) ?u32 { return cycleAt(emitted, &.{}, emitted.len); @@ -123,6 +120,7 @@ pub const Spec = struct { max_new: u32, eos: []const u32 = &.{}, sampling: ?Sampling = null, + logit_bias: []const @import("logit_bias.zig").Entry = &.{}, penalties: Penalties = .{}, // where the backend applies them (Backend.VTable.penalties) drafts: bool = true, proposer: ?Proposer = null, @@ -163,6 +161,7 @@ pub const Stream = struct { max_new: u32, eos: []const u32, sampling: ?Sampling, + logit_bias: []const @import("logit_bias.zig").Entry = &.{}, penalties: Penalties = .{}, drafts: bool, proposer: ?Proposer, @@ -268,6 +267,7 @@ pub const Stream = struct { .eos = spec.eos, .sampling = spec.sampling, .penalties = spec.penalties, + .logit_bias = spec.logit_bias, .drafts = spec.drafts, .proposer = if (spec.drafts) spec.proposer else null, .recall = if (spec.drafts) spec.recall else null, @@ -482,6 +482,12 @@ pub const Stream = struct { var landed: usize = 0; for (tokens, 0..) |t, i| { if (s.finished) break; + if (@import("logit_bias.zig").find(s.logit_bias, t)) |bias| if (bias.ban) { + s.finished = true; + s.reason = .@"error"; + s.problem = "logit_bias bans a forced or chosen token"; + break; + }; if (s.grammar) |g| { if (!try g.follow(t)) { s.finished = true; diff --git a/zig/src/core/lanes/stream_test.zig b/zig/src/core/lanes/stream_test.zig index 2fb38653b8c..dbf24b190b3 100644 --- a/zig/src/core/lanes/stream_test.zig +++ b/zig/src/core/lanes/stream_test.zig @@ -15,6 +15,29 @@ test "commit stops at eos and length" { try std.testing.expect(s.finished and s.reason == .stop); } +test "logit_bias: forced thinking closes and EOS never emit a hard-banned token" { + const gpa = std.testing.allocator; + for ([_]u32{ 8, 9 }) |banned| { + var s = try Stream.init(gpa, .{ + .id = "bias", + .prompt = &.{1}, + .max_new = 4, + .eos = &.{9}, + .think_budget = 1, + .think_close = &.{ 8, 9 }, + .think_end = 9, + .logit_bias = &.{.{ .token = banned, .value = -100, .ban = true }}, + }); + defer s.deinit(gpa); + const first = try s.startClose(gpa); + _ = try s.commit(gpa, &.{first}, &.{}); + if (!s.finished) _ = try s.commit(gpa, &.{s.popForce().?}, &.{}); + try std.testing.expect(s.finished and s.reason == .@"error"); + try std.testing.expect(std.mem.indexOfScalar(u32, s.emitted(), banned) == null); + try std.testing.expectEqualSlices(u32, if (banned == 8) &.{} else &.{8}, s.emitted()); + } +} + test "a logprob stream lands a row with each token it lands, and refuses tokens without rows" { const gpa = std.testing.allocator; var s = try Stream.init(gpa, .{ .id = "a", .prompt = &.{ 1, 2 }, .max_new = 3, .eos = &.{9}, .logprobs = 0 }); diff --git a/zig/src/cuda/sample.zig b/zig/src/cuda/sample.zig index c29fbe18011..a769a303b2d 100644 --- a/zig/src/cuda/sample.zig +++ b/zig/src/cuda/sample.zig @@ -75,6 +75,7 @@ pub const Draws = struct { slices: ?[2]Function = null, /// tf_penalize_rows; null in a kernel set built before it, where penalties are not offered. penalize_fn: ?Function = null, + bias_fn: ?Function = null, // tf_bias_rows; old images keep refusing logit_bias /// sample.cu's SW: a slice's entries. pub const draw_slice = 8192; @@ -85,7 +86,7 @@ pub const Draws = struct { pub const topk_slice = 4096; pub fn resolve(mod: Module) !Draws { - return .{ .draw_fn = try mod.function("tf_draw"), .draw_ids_fn = try mod.function("tf_draw_ids"), .logprob_rows_fn = try mod.function("tf_logprob_rows"), .topk_slices_fn = try mod.function("tf_topk_slices"), .topk_merge_fn = try mod.function("tf_topk_merge"), .draw_rows_fn = mod.function("tf_draw_rows") catch null, .draw_ids_rows_fn = mod.function("tf_draw_ids_rows") catch null, .slices = slicesOf(mod), .penalize_fn = mod.function("tf_penalize_rows") catch null }; + return .{ .draw_fn = try mod.function("tf_draw"), .draw_ids_fn = try mod.function("tf_draw_ids"), .logprob_rows_fn = try mod.function("tf_logprob_rows"), .topk_slices_fn = try mod.function("tf_topk_slices"), .topk_merge_fn = try mod.function("tf_topk_merge"), .draw_rows_fn = mod.function("tf_draw_rows") catch null, .draw_ids_rows_fn = mod.function("tf_draw_ids_rows") catch null, .slices = slicesOf(mod), .penalize_fn = mod.function("tf_penalize_rows") catch null, .bias_fn = mod.function("tf_bias_rows") catch null }; } fn slicesOf(mod: Module) ?[2]Function { @@ -183,7 +184,15 @@ pub const Draws = struct { /// `n` entries at `entries` (n rows, n tokens, then n fp32 amounts): each takes its amount from its row's logit. pub fn penalize(d: *const Draws, s: Stream, logits: u64, vocab: usize, entries: u64, n: usize) !void { if (n == 0) return; - const f = d.penalize_fn orelse return error.PenaltiesUnsupported; + return sparse(d.penalize_fn orelse return error.PenaltiesUnsupported, s, logits, vocab, entries, n); + } + + pub fn biasRows(d: *const Draws, s: Stream, logits: u64, vocab: usize, entries: u64, n: usize) !void { + if (n == 0) return; + return sparse(d.bias_fn orelse return error.LogitBiasUnsupported, s, logits, vocab, entries, n); + } + + fn sparse(f: Function, s: Stream, logits: u64, vocab: usize, entries: u64, n: usize) !void { var a: launch_.Args = .{}; inline for (.{ logits, @as(u32, @intCast(vocab)), entries, entries + n * 4, entries + n * 8, @as(u32, @intCast(n)) }) |v| a.add(v); try launch_.launch(f, .{ .grid = .{ .x = @intCast((n + 255) / 256), .y = 1, .z = 1 }, .block = .{ .x = 256 } }, s, &a); diff --git a/zig/src/families/nemotron_parse/backend.zig b/zig/src/families/nemotron_parse/backend.zig index 0e534adeb41..59edee89837 100644 --- a/zig/src/families/nemotron_parse/backend.zig +++ b/zig/src/families/nemotron_parse/backend.zig @@ -66,7 +66,7 @@ pub const Backend = struct { } pub fn backend(h: *Backend) be.Backend { - return .{ .ptr = h, .vtable = &vtable, .penalties = true, .chunk_invariant = true }; + return .{ .ptr = h, .vtable = &vtable, .penalties = true, .logit_bias = true, .chunk_invariant = true }; } const vtable: be.Backend.VTable = .{ .reports_fill = true, .prefill = fillAll, .prefill_step = fillStep, .first = first, .first_masked = firstMasked, .queue = queue, .read = read, .verify = verify, .keep = keep, .draft = draft, .tree = tree, .held = held, .release = release }; @@ -117,7 +117,7 @@ pub const Backend = struct { const history = try a.alloc(u32, base.len + extra.len); @memcpy(history[0..base.len], base); @memcpy(history[base.len..], extra); - return .{ .sampling = s.sampling, .position = position, .repetition = 1.1, .forced = if (s.max_new > 0 and position == s.prompt_len + s.max_new - 1) 2 else null, .history = history, .reply = history[s.prompt_len - image_rows ..], .penalties = s.penalties }; + return .{ .sampling = s.sampling, .position = position, .repetition = 1.1, .forced = if (s.max_new > 0 and position == s.prompt_len + s.max_new - 1) 2 else null, .history = history, .reply = history[s.prompt_len - image_rows ..], .penalties = s.penalties, .logit_bias = s.logit_bias }; } fn settle(l: *Lane, rows: ?usize) !void { diff --git a/zig/src/families/qwen3_5/backend.zig b/zig/src/families/qwen3_5/backend.zig index 5595f163d65..d2f8afbc462 100644 --- a/zig/src/families/qwen3_5/backend.zig +++ b/zig/src/families/qwen3_5/backend.zig @@ -69,7 +69,7 @@ pub const Metal = struct { } pub fn backend(self: *Metal) be.Backend { - return .{ .ptr = self, .vtable = &.{ .prefill = prefillFn, .prefill_step = prefillStepFn, .cancel_prefill = cancelPrefillFn, .first = firstFn, .first_masked = firstMaskedFn, .queue = queueFn, .read = readFn, .verify = verifyFn, .keep = keepFn, .draft = draftFn, .release = releaseFn, .reports_fill = true } }; + return .{ .ptr = self, .logit_bias = true, .vtable = &.{ .prefill = prefillFn, .prefill_step = prefillStepFn, .cancel_prefill = cancelPrefillFn, .first = firstFn, .first_masked = firstMaskedFn, .queue = queueFn, .read = readFn, .verify = verifyFn, .keep = keepFn, .draft = draftFn, .release = releaseFn, .reports_fill = true } }; } fn cast(ptr: *anyopaque) *Metal { @@ -166,14 +166,14 @@ pub const Metal = struct { const self = cast(ptr); const cache = try self.cacheOf(stream); if (position != cache.len) return error.InvalidQwenPosition; - return try draw(self.gpa, cache.logits.slice(u16, c.vocab), stream.sampling, position, &.{}); + return try @import("draw.zig").biased(self.gpa, cache.logits.slice(u16, c.vocab), stream.sampling, position, &.{}, stream.logit_bias); } fn firstMaskedFn(ptr: *anyopaque, stream: *lanes.Stream, position: u64, mask: []const u32) !u64 { const self = cast(ptr); const cache = try self.cacheOf(stream); if (position != cache.len) return error.InvalidQwenPosition; - return try draw(self.gpa, cache.logits.slice(u16, c.vocab), stream.sampling, position, mask); + return try @import("draw.zig").biased(self.gpa, cache.logits.slice(u16, c.vocab), stream.sampling, position, mask, stream.logit_bias); } fn queueFn(ptr: *anyopaque, stream: *lanes.Stream, feed: be.Feed, position: u64) !u64 { @@ -186,7 +186,7 @@ pub const Metal = struct { }; try coverRows(cache, cache.len + 1); try fwd.run(self.model, &self.scratch, &.{.{ .cache = cache, .rows = 1 }}, &.{token}, false, .all); - return try draw(self.gpa, cache.logits.slice(u16, c.vocab), stream.sampling, position, &.{}); + return try @import("draw.zig").biased(self.gpa, cache.logits.slice(u16, c.vocab), stream.sampling, position, &.{}, stream.logit_bias); } fn readFn(_: *anyopaque, handle: u64) !u32 { @@ -219,7 +219,7 @@ pub const Metal = struct { if (o.sampled.len != w.rows() or o.drafts.len != w.tokens.len) return error.InvalidQwenOutputs; for (o.sampled, w.positions, 0..) |*t, p, r| { const mask = if (w.masks.len > 0) w.masks[r * mask_words ..][0..mask_words] else &.{}; - t.* = try draw(self.gpa, logits[(base + r) * c.vocab ..][0..c.vocab], w.stream.sampling, p, mask); + t.* = try @import("draw.zig").biased(self.gpa, logits[(base + r) * c.vocab ..][0..c.vocab], w.stream.sampling, p, mask, w.stream.logit_bias); } @memcpy(o.drafts, w.tokens); base += w.rows(); diff --git a/zig/src/families/qwen3_5/cuda_native.zig b/zig/src/families/qwen3_5/cuda_native.zig index afbed419efd..57b8182fa66 100644 --- a/zig/src/families/qwen3_5/cuda_native.zig +++ b/zig/src/families/qwen3_5/cuda_native.zig @@ -216,7 +216,7 @@ pub fn openLanes(gpa: std.mem.Allocator, io: std.Io, ctx: *const cuda.Context, d const trace = try round_timing.Trace.create(gpa, timing_on and e.g.hidden == 5120 and e.g.layers == 64 and e.g.experts == 0); errdefer if (trace) |x| gpa.destroy(x); const l = try gpa.create(Lanes); - l.* = .{ .gpa = gpa, .io = io, .e = e, .capacity = o.context, .mtp_drafts = o.mtp_drafts, .page_tokens = page_tokens, .engine_paged = engine_paged, .page_test = page_test, .share_snaps = share_snaps, .cost_context = ctx, .room = o.room, .startup = e.startup, .vision = v, .target = undefined, .timing_on = timing_on, .trace = trace }; + l.* = .{ .gpa = gpa, .io = io, .e = e, .bias = e.draws.bias_fn != null, .capacity = o.context, .mtp_drafts = o.mtp_drafts, .page_tokens = page_tokens, .engine_paged = engine_paged, .page_test = page_test, .share_snaps = share_snaps, .cost_context = ctx, .room = o.room, .startup = e.startup, .vision = v, .target = undefined, .timing_on = timing_on, .trace = trace }; try @import("cuda_lane_startup.zig").open(l, ctx); errdefer gpa.destroy(l); return .{ @@ -272,6 +272,7 @@ pub const Lanes = struct { gpa: std.mem.Allocator, io: std.Io, e: *E.Engine, + bias: bool = false, // the kernel set has tf_bias_rows, read at open: backend() never reads the engine capacity: usize, /// TF_QWEN_KV_PAGES's positions a page (0: no pool) and the pool `attach` made. page_tokens: usize = 0, @@ -382,7 +383,7 @@ pub const Lanes = struct { }; fn backend(self: *Lanes) be.Backend { - return @import("cuda_prefill_trace.zig").wrapBackend(Lanes, .{ .ptr = self, .round_observer = if (self.trace) |x| x.observer() else null, .first_before_draft = true, .penalties = true, .chunk_invariant = true, .vtable = if (self.readout.readout != null) &read_vtable else &text_vtable }); + return @import("cuda_prefill_trace.zig").wrapBackend(Lanes, .{ .ptr = self, .round_observer = if (self.trace) |x| x.observer() else null, .first_before_draft = true, .penalties = true, .logit_bias = self.bias and self.readout.readout == null, .chunk_invariant = true, .vtable = if (self.readout.readout != null) &read_vtable else &text_vtable }); } /// Readout streams from now on fill through `r` (one rank; before the first stream): the backend to hand on. @@ -450,7 +451,7 @@ pub const Lanes = struct { const self = cast(ptr); const cache = try self.cacheOf(stream); if (position != cache.len) return error.InvalidQwenPosition; - return try draws.draw(self.gpa, cache.logits, stream.sampling, position, mask); + return try draws.biased(self.gpa, cache.logits, stream.sampling, position, mask, stream.logit_bias); } fn queueFn(ptr: *anyopaque, stream: *lanes.Stream, feed: be.Feed, position: u64) !u64 { @@ -461,9 +462,9 @@ pub const Lanes = struct { .value => |v| v, .handle => |h| @intCast(h), }; - if (stream.penalties.active()) { + if (stream.penalties.active() or stream.logit_bias.len > 0) { try self.e.penalties.window(self.gpa, stream, cache.len, token); - try self.e.penalties.row(self.gpa, 0, stream.penalties, &.{}); + try self.e.penalties.rowBias(self.gpa, 0, stream.penalties, &.{}, stream.logit_bias); } try self.e.forward(&.{.{ .cache = cache, .rows = 1, .undo = self.e.learning != null }}, &.{token}, .{ .draws = &.{pick(stream.sampling, position)} }); cache.last = null; @@ -511,7 +512,7 @@ pub const Lanes = struct { ids[total] = w.pending; @memcpy(ids[total + 1 ..][0..w.tokens.len], w.tokens); for (w.positions, 0..) |p, r| picks[total + r] = pick(w.stream.sampling, p); - if (w.stream.penalties.active()) try self.e.penalties.stageWindow(self.gpa, w, parts[n].cache.len, total); + if (w.stream.penalties.active() or w.stream.logit_bias.len > 0) try self.e.penalties.stageWindow(self.gpa, w, parts[n].cache.len, total); masked = masked or w.masks.len != 0; total += w.rows(); } @@ -527,7 +528,7 @@ pub const Lanes = struct { for (windows[at..][0..n], out[at..][0..n]) |w, o| { for (o.sampled, w.positions, 0..) |*t, p, r| { const mask = if (w.masks.len > 0) w.masks[r * draws.mask_words ..][0..draws.mask_words] else &.{}; - t.* = if (masked) try draws.draw(self.gpa, self.e.rowLogits(row + r), w.stream.sampling, p, mask) else self.e.tokens[row + r]; + t.* = if (masked) try draws.processed(self.gpa, self.e.rowLogits(row + r), w.stream.sampling, p, mask, w.stream.logit_bias.len > 0) else self.e.tokens[row + r]; } @memcpy(o.drafts, w.tokens); row += w.rows(); @@ -540,7 +541,6 @@ pub const Lanes = struct { fn keepFn(ptr: *anyopaque, windows: []const be.Window, paths: []const []const u32) !void { return @call(.always_inline, @import("cuda_native_keep.zig").keep, .{ cast(ptr), windows, paths }); } - fn draftFn(_: *anyopaque, requests: []const be.DraftRequest) !void { for (requests) |r| if (r.depth != 0) return error.QwenCheckpointHasNoDraftHead; } diff --git a/zig/src/families/qwen3_5/cuda_penalties.zig b/zig/src/families/qwen3_5/cuda_penalties.zig index da3c1491c96..c68f6951f43 100644 --- a/zig/src/families/qwen3_5/cuda_penalties.zig +++ b/zig/src/families/qwen3_5/cuda_penalties.zig @@ -30,11 +30,17 @@ pub const Rows = struct { return self.entries.row(gpa, at, p, path); } + pub fn rowBias(self: *Rows, gpa: std.mem.Allocator, at: u32, p: lanes.Penalties, path: []const u32, bias: []const lanes.logit_bias.Entry) !void { + return self.entries.rowBias(gpa, at, p, path, bias); + } + /// The staged entries taken from `logits` (rows of `vocab` bf16 words) on `stream`; none staged: nothing runs. pub fn apply(self: *Rows, d: *const cuda.Driver, draws: *const cuda.sample.Draws, stream: cuda.Stream, logits: u64, vocab: usize) !void { const n = self.len(); if (n == 0) return; defer self.clear(); + // the server checks IDs against the tokenizer's vocabulary; the launch writes rows of the head's, unchecked + if (self.entries.biased) for (self.entries.toks.items) |t| if (t >= vocab) return error.BadLogitBiasToken; const bytes = n * 12; if (self.host == null or self.host.?.bytes.len < bytes) { if (self.host) |*h| h.free(); @@ -52,17 +58,98 @@ pub const Rows = struct { @memcpy(h[n * 8 .. n * 12], std.mem.sliceAsBytes(self.entries.subs.items)); // the forward waits on its stream before the next one stages, so the pinned bytes are not reused early try self.dev.?.uploadAsync(0, h[0..bytes], stream.handle); - try draws.penalize(stream, logits, vocab, self.dev.?.ptr, n); + if (self.entries.biased) try draws.biasRows(stream, logits, vocab, self.dev.?.ptr, n) else try draws.penalize(stream, logits, vocab, self.dev.?.ptr, n); } pub fn stageWindow(self: *Rows, gpa: std.mem.Allocator, w: anytype, cache_len: usize, first: usize) !void { try self.window(gpa, w.stream, cache_len, w.pending); var buf: [most_path]u32 = undefined; if (w.rows() > most_path + 1) return error.UnsupportedQwenWindow; - for (0..w.rows()) |r| try self.row(gpa, @intCast(first + r), w.stream.penalties, lanes.penalty_rows.pathOf(&buf, w.tokens, w.parents, r)); + for (0..w.rows()) |r| try self.entries.rowBias(gpa, @intCast(first + r), w.stream.penalties, lanes.penalty_rows.pathOf(&buf, w.tokens, w.parents, r), w.stream.logit_bias); } pub fn clear(self: *Rows) void { self.entries.clear(); } }; + +fn fakeStream(context: []const u32, prompt_len: usize) lanes.Stream { + var s: lanes.Stream = undefined; + s.context = .fromOwnedSlice(@constCast(context)); + s.prompt_len = prompt_len; + return s; +} + +test "a row's entries count the reply, the pending token and its own path once each" { + const gpa = std.testing.allocator; + var rows: Rows = .{}; + defer rows.deinit(gpa); + // prompt 9 9 (not counted), reply 5 7 5, pending 7 at cache_len 5 + const s = fakeStream(&.{ 9, 9, 5, 7, 5, 7 }, 2); + try rows.window(gpa, &s, 5, 7); + const p: lanes.Penalties = .{ .presence = 1, .frequency = 0.5 }; + try rows.row(gpa, 0, p, &.{}); + try rows.row(gpa, 1, p, &.{ 5, 3 }); + try std.testing.expectEqualSlices(u32, &.{ 0, 0, 1, 1, 1 }, rows.entries.rows.items); + try std.testing.expectEqualSlices(u32, &.{ 5, 7, 5, 7, 3 }, rows.entries.toks.items); + try std.testing.expectEqualSlices(f32, &.{ 2, 2, 2.5, 2, 1.5 }, rows.entries.subs.items); +} + +test "the window's counts drop a path's tokens after its row" { + const gpa = std.testing.allocator; + var rows: Rows = .{}; + defer rows.deinit(gpa); + const s = fakeStream(&.{ 1, 4 }, 1); + try rows.window(gpa, &s, 2, 6); + const p: lanes.Penalties = .{ .frequency = 1 }; + try rows.row(gpa, 0, p, &.{8}); + rows.clear(); + try rows.row(gpa, 1, p, &.{}); + try std.testing.expectEqualSlices(u32, &.{ 4, 6 }, rows.entries.toks.items); + try std.testing.expectEqualSlices(f32, &.{ 1, 1 }, rows.entries.subs.items); +} + +test "a position before the reply or past the committed tokens is refused" { + const gpa = std.testing.allocator; + var rows: Rows = .{}; + defer rows.deinit(gpa); + const s = fakeStream(&.{ 1, 2, 3 }, 2); + try std.testing.expectError(error.InvalidQwenPosition, rows.window(gpa, &s, 1, 0)); + try std.testing.expectError(error.InvalidQwenPosition, rows.window(gpa, &s, 4, 0)); +} + +test "a tree row's path follows its parents from the first row" { + var buf: [8]u32 = undefined; + const tokens = [_]u32{ 10, 11, 12, 13 }; + const parents = [_]i32{ -1, 0, 0, 1, 3 }; + try std.testing.expectEqualSlices(u32, &.{}, lanes.penalty_rows.pathOf(&buf, &tokens, &parents, 0)); + try std.testing.expectEqualSlices(u32, &.{11}, lanes.penalty_rows.pathOf(&buf, &tokens, &parents, 2)); + try std.testing.expectEqualSlices(u32, &.{ 10, 12, 13 }, lanes.penalty_rows.pathOf(&buf, &tokens, &parents, 4)); + try std.testing.expectEqualSlices(u32, &.{ 10, 11 }, lanes.penalty_rows.pathOf(&buf, &tokens, null, 2)); +} + +test "bias rows merge each cell once, preserve path penalties and leave another stream unchanged" { + const a = std.testing.allocator; + var rows: Rows = .{}; + defer rows.deinit(a); + const s = fakeStream(&.{ 9, 9, 5, 7, 5, 7 }, 2); + try rows.window(a, &s, 5, 7); + const p: lanes.Penalties = .{ .presence = 1, .frequency = 0.5 }; + // sorted, as parsed + const bias = [_]lanes.logit_bias.Entry{ .{ .token = 3, .value = -100, .ban = true }, .{ .token = 5, .value = 3 } }; + try rows.rowBias(a, 4, p, &.{5}, &bias); + try rows.rowBias(a, 5, p, &.{3}, &bias); + try rows.row(a, 6, p, &.{}); + try std.testing.expectEqualSlices(u32, &.{ 4, 4, 4, 5, 5, 5, 6, 6 }, rows.entries.rows.items); + try std.testing.expectEqualSlices(u32, &.{ 5, 7, 3, 5, 7, 3, 5, 7 }, rows.entries.toks.items); + try std.testing.expectEqualSlices(f32, &.{ -0.5, 2, std.math.inf(f32), -1, 2, std.math.inf(f32), 2, 2 }, rows.entries.subs.items); + for (rows.entries.rows.items, rows.entries.toks.items, 0..) |at, token, i| { + for (rows.entries.rows.items[0..i], rows.entries.toks.items[0..i]) |other_row, other_token| + try std.testing.expect(at != other_row or token != other_token); + } + rows.clear(); + try std.testing.expect(!rows.entries.biased); + try rows.rowBias(a, 0, .{}, &.{5}, &bias); + try std.testing.expectEqualSlices(u32, &.{ 3, 5 }, rows.entries.toks.items); + try std.testing.expectEqualSlices(f32, &.{ std.math.inf(f32), -3 }, rows.entries.subs.items); +} diff --git a/zig/src/families/qwen3_5/cuda_pick.zig b/zig/src/families/qwen3_5/cuda_pick.zig index 896dcd93aaa..75e21339085 100644 --- a/zig/src/families/qwen3_5/cuda_pick.zig +++ b/zig/src/families/qwen3_5/cuda_pick.zig @@ -5,7 +5,5 @@ const E = @import("cuda_engine.zig"); /// The device draw of a stream's rule at `position`: sample.cu's keyed rule, greedy at temperature 0 or without one. pub fn pick(sampling: ?lanes.Sampling, position: u64) E.Draw { - const s = sampling orelse return .{ .rule = null, .position = position }; - if (s.temperature <= 0) return .{ .rule = null, .position = position }; - return .{ .rule = cuda.sample.Rule.from(lanes.gpu_rule.rule(s)), .position = position }; + return .{ .rule = cuda.sample.ruleFor(sampling), .position = position }; } diff --git a/zig/src/families/qwen3_5/draw.zig b/zig/src/families/qwen3_5/draw.zig index cbf2450cef3..4621923c6a4 100644 --- a/zig/src/families/qwen3_5/draw.zig +++ b/zig/src/families/qwen3_5/draw.zig @@ -17,6 +17,18 @@ pub fn draw(gpa: std.mem.Allocator, logits: []const u16, settings: ?lanes.Sampli }; } +/// A raw row's draw under a request's biases (none: `draw` itself); the row's words stay as they are. +pub fn biased(gpa: std.mem.Allocator, words: []const u16, settings: ?lanes.Sampling, position: u64, mask: []const u32, entries: []const lanes.logit_bias.Entry) !u32 { + if (entries.len == 0) return draw(gpa, words, settings, position, mask); + return lanes.logit_bias.draw(gpa, words, settings, position, mask, entries); +} + +/// A row the device already penalized and biased: a biased stream's bans are -inf there, skipped rather than refused. +pub fn processed(gpa: std.mem.Allocator, words: []const u16, settings: ?lanes.Sampling, position: u64, mask: []const u32, has_bias: bool) !u32 { + if (!has_bias) return draw(gpa, words, settings, position, mask); + return lanes.logit_bias.draw(gpa, words, settings, position, mask, &.{}); +} + test "candidate selection preserves full-vocabulary keyed draws and tie order" { const gpa = std.testing.allocator; const words = try gpa.alloc(u16, c.vocab); @@ -157,3 +169,18 @@ test "bounded keyed draws refuse every nonfinite BF16 encoding even behind a mas try std.testing.expectError(error.NoAllowedQwenToken, draw(std.testing.allocator, &words, s, 0, &.{0})); try std.testing.expectError(error.NoAllowedQwenToken, draw(std.testing.allocator, &.{}, s, 0, &.{})); } + +test "bias defaults: Qwen Metal raw and CUDA processed draws retain main tokens and cached words" { + const a = std.testing.allocator; + const raw = [_]u16{ 0x3f80, 0x4000, 0x4040, 0x4040, 0x8000, 0 }; + const mask = [_]u32{0b110011}; + for ([_]?lanes.Sampling{ null, .{ .seed = 987, .temperature = 0 }, .{ .seed = 123, .temperature = 0.8, .top_k = 3, .top_p = 0.95 } }) |settings| { + for (0..64) |position| for ([_][]const u32{ &.{}, &mask }) |m| { + var words = raw; + const want = try draw(a, &raw, settings, position, m); + try std.testing.expectEqual(want, try biased(a, &words, settings, position, m, &.{})); + try std.testing.expectEqual(want, try processed(a, &words, settings, position, m, false)); + try std.testing.expectEqualSlices(u16, &raw, &words); + }; + } +} diff --git a/zig/src/hip_serve/draw.zig b/zig/src/hip_serve/draw.zig index 9ad5e677676..061fb317cb5 100644 --- a/zig/src/hip_serve/draw.zig +++ b/zig/src/hip_serve/draw.zig @@ -24,11 +24,12 @@ pub const Request = struct { /// OpenAI penalties count reply tokens only; history may also contain prompt tokens. reply: []const u32 = &.{}, penalties: lanes.sampling.Penalties = .{}, + logit_bias: []const lanes.logit_bias.Entry = &.{}, }; /// Whether a row is drawn on the host from the whole row. fn whole(r: Request) bool { - return r.mask.len > 0 or r.keep != null or r.repetition != 1 or r.penalties.active() or r.forced != null; + return r.mask.len > 0 or r.keep != null or r.repetition != 1 or r.penalties.active() or r.logit_bias.len > 0 or r.forced != null; } fn greedy(s: ?lanes.Sampling) bool { @@ -163,12 +164,14 @@ pub const Drawer = struct { /// A host row's token per `r`: its mask applied in place, then greedy or the keyed draw. pub fn drawHost(w: *const Drawer, row: []u16, r: Request) !u32 { if (r.forced) |id| { + try lanes.logit_bias.validate(row.len, r.logit_bias); if (id >= row.len) return error.BadForcedToken; + if (lanes.logit_bias.find(r.logit_bias, id)) |b| if (b.ban) return error.NoAllowedToken; if (r.mask.len > 0 and (id / 32 >= r.mask.len or (r.mask[id / 32] >> @intCast(id % 32)) & 1 == 0)) return error.NoAllowedToken; return id; } if (r.mask.len > 0) sample.mask(row, w.dtype, r.mask); - if (r.repetition == 1 and !r.penalties.active()) return sample.draw(w.gpa, row, w.dtype, r.sampling, r.position); + if (r.repetition == 1 and !r.penalties.active() and r.logit_bias.len == 0) return sample.draw(w.gpa, row, w.dtype, r.sampling, r.position); const values = try w.gpa.alloc(f32, row.len); defer w.gpa.free(values); for (values, 0..) |*v, i| v.* = sample.widen(row, w.dtype, i); @@ -202,6 +205,15 @@ pub fn process(a: std.mem.Allocator, values: []f32, r: Request) !void { v.* -= r.penalties.of(count); }; } + try lanes.logit_bias.apply(values, r.logit_bias); + if (r.logit_bias.len > 0) { + var allowed = false; + for (values) |v| if (std.math.isFinite(v)) { + allowed = true; + break; + }; + if (!allowed) return error.NoAllowedToken; + } } test "repetition keeps FP32 ranking and counts prompt tokens once, OpenAI penalties count only reply tokens" { @@ -213,3 +225,76 @@ test "repetition keeps FP32 ranking and counts prompt tokens once, OpenAI penalt try std.testing.expectEqual(@as(u32, 1), try sample.drawWide(std.testing.allocator, values[0..2], null, 0)); try std.testing.expectError(error.BadHistoryToken, process(std.testing.allocator, &values, .{ .sampling = null, .position = 0, .repetition = 1.1, .history = &.{4} })); } + +test "logit_bias draws ban a token at every seed and shift greedy picks without changing a solo row" { + const a = std.testing.allocator; + const drawer: Drawer = .{ .gpa = a, .d = undefined, .dtype = .bf16, .vocab = 3, .rows = 1, .host = undefined, .dev = undefined, .row = undefined }; + var words = [_]u16{ 0x4120, 0x4110, 0 }; + const bias = [_]lanes.logit_bias.Entry{ .{ .token = 0, .value = -100, .ban = true }, .{ .token = 2, .value = 20 } }; + try std.testing.expectEqual(@as(u32, 2), try drawer.drawHost(&words, .{ .sampling = null, .position = 0, .logit_bias = &bias })); + for (0..128) |seed| { + try std.testing.expect(try drawer.drawHost(&words, .{ .sampling = .{ .seed = seed, .top_k = 0, .top_p = 1 }, .position = seed, .logit_bias = &bias }) != 0); + } + try std.testing.expectEqual(@as(u32, 0), try drawer.drawHost(&words, .{ .sampling = null, .position = 0 })); + try std.testing.expectError(error.NoAllowedToken, drawer.drawHost(&words, .{ .sampling = null, .position = 0, .logit_bias = &bias, .forced = 0 })); +} + +test "logit_bias forced draws validate every entry" { + const drawer: Drawer = .{ .gpa = std.testing.allocator, .d = undefined, .dtype = .bf16, .vocab = 3, .rows = 1, .host = undefined, .dev = undefined, .row = undefined }; + var words = [_]u16{ 0, 0, 0 }; + const bias = [_]lanes.logit_bias.Entry{.{ .token = 9, .value = 0 }}; + try std.testing.expectError(error.BadLogitBiasToken, drawer.drawHost(&words, .{ .sampling = null, .position = 0, .forced = 1, .logit_bias = &bias })); +} + +test "logit_bias banned forced draws still validate every entry" { + const drawer: Drawer = .{ .gpa = std.testing.allocator, .d = undefined, .dtype = .bf16, .vocab = 3, .rows = 1, .host = undefined, .dev = undefined, .row = undefined }; + var words = [_]u16{ 0, 0, 0 }; + const bias = [_]lanes.logit_bias.Entry{ .{ .token = 0, .value = -100, .ban = true }, .{ .token = 9, .value = 0 } }; + try std.testing.expectError(error.BadLogitBiasToken, drawer.drawHost(&words, .{ .sampling = null, .position = 0, .forced = 0, .logit_bias = &bias })); +} + +test "logit_bias masked forced draws still validate every entry" { + const drawer: Drawer = .{ .gpa = std.testing.allocator, .d = undefined, .dtype = .bf16, .vocab = 3, .rows = 1, .host = undefined, .dev = undefined, .row = undefined }; + var words = [_]u16{ 0, 0, 0 }; + const bias = [_]lanes.logit_bias.Entry{.{ .token = 9, .value = 0 }}; + const mask = [_]u32{0}; + try std.testing.expectError(error.BadLogitBiasToken, drawer.drawHost(&words, .{ .sampling = null, .position = 0, .forced = 1, .mask = &mask, .logit_bias = &bias })); +} + +test "logit_bias defaults: Parse HIP absent and empty requests keep main draws and device routing" { + const a = std.testing.allocator; + const raw = [_]u16{ 0x3f80, 0x4000, 0x4040, 0x4040, 0x8000, 0 }; + const drawer: Drawer = .{ .gpa = a, .d = undefined, .dtype = .bf16, .vocab = raw.len, .rows = 1, .host = undefined, .dev = undefined, .row = undefined }; + for ([_]?lanes.Sampling{ null, .{ .seed = 987, .temperature = 0 }, .{ .seed = 123, .temperature = 0.8, .top_k = 3, .top_p = 0.95 } }) |settings| { + for (0..64) |position| { + var words = raw; + const absent: Request = .{ .sampling = settings, .position = position }; + var empty = absent; + empty.logit_bias = &.{}; + try std.testing.expect(!whole(absent) and !whole(empty)); + const want = try sample.draw(a, &raw, .bf16, settings, position); + try std.testing.expectEqual(want, try drawer.drawHost(&words, absent)); + try std.testing.expectEqual(want, try drawer.drawHost(&words, empty)); + try std.testing.expectEqualSlices(u16, &raw, &words); + } + } +} + +test "logit_bias defaults: Parse repetition and forced EOS keep the earlier host scores and tokens" { + const a = std.testing.allocator; + const raw = [_]u16{ 0x3f80, 0x4000, 0x4040, 0x4080 }; + const drawer: Drawer = .{ .gpa = a, .d = undefined, .dtype = .bf16, .vocab = raw.len, .rows = 1, .host = undefined, .dev = undefined, .row = undefined }; + const scores = [_]f32{ @as(f32, 1) / @as(f32, 1.1), 2, 3, @as(f32, 4) / @as(f32, 1.1) }; + for ([_]?lanes.Sampling{ null, .{ .seed = 123, .temperature = 0.8, .top_k = 3, .top_p = 0.95 } }) |settings| for (0..64) |position| { + var words = raw; + const absent: Request = .{ .sampling = settings, .position = position, .repetition = 1.1, .history = &.{ 0, 3, 3 } }; + var empty = absent; + empty.logit_bias = &.{}; + const want = try sample.drawWide(a, &scores, settings, position); + try std.testing.expectEqual(want, try drawer.drawHost(&words, absent)); + try std.testing.expectEqual(want, try drawer.drawHost(&words, empty)); + empty.forced = 2; + try std.testing.expectEqual(@as(u32, 2), try drawer.drawHost(&words, empty)); + try std.testing.expectEqualSlices(u16, &raw, &words); + }; +} diff --git a/zig/src/native/cuda.zig b/zig/src/native/cuda.zig index b4dd519a76d..433e730afeb 100644 --- a/zig/src/native/cuda.zig +++ b/zig/src/native/cuda.zig @@ -146,7 +146,7 @@ pub const Host = struct { // One loaded model behind the lane host: everything t /// The family's backend, each call made with the context current on the calling thread. fn backend(h: *Host) lanes.backend.Backend { h.vtable = lane_backend.vtable(Host, h.inner.vtable.*); - return .{ .ptr = h, .round_observer = h.inner.round_observer, .vtable = &h.vtable, .first_before_draft = h.inner.first_before_draft, .penalties = h.inner.penalties, .chunk_invariant = h.inner.chunk_invariant, .warm_images = h.inner.warm_images }; + return .{ .ptr = h, .round_observer = h.inner.round_observer, .vtable = &h.vtable, .first_before_draft = h.inner.first_before_draft, .penalties = h.inner.penalties, .logit_bias = h.inner.logit_bias, .chunk_invariant = h.inner.chunk_invariant, .warm_images = h.inner.warm_images }; } }; pub const refusals = @import("cuda_refusal.zig"); @@ -481,6 +481,7 @@ fn openWith(comptime F: type, a: Allocator, gpa: Allocator, io: std.Io, asked: a .logprobs = served.backend.vtable.first_row != null, .prompt_logprobs = served.backend.vtable.prompt_rows, .penalties = served.backend.penalties, + .logit_bias = served.backend.logit_bias, .structures = served.backend.vtable.first_masked != null, .vision = if (@hasField(@TypeOf(loaded), "vision")) vision_offer.offer(loaded.vision, o.vision) else null, .audio = if (@hasField(@TypeOf(loaded), "audio")) vision_offer.audio(loaded.audio) else null, diff --git a/zig/src/native/hip.zig b/zig/src/native/hip.zig index ba097b2bedb..83895c548f2 100644 --- a/zig/src/native/hip.zig +++ b/zig/src/native/hip.zig @@ -82,7 +82,6 @@ const Ready = struct { policy_line: []const u8, const Options = serve.Options; - fn deinit(r: Ready, gpa: Allocator) void { gpa.free(r.policy_line); if (r.dev.group) |g| g.close(gpa); @@ -332,6 +331,7 @@ fn openWith(comptime F: type, a: Allocator, gpa: Allocator, io: std.Io, o: api.O .rerank = offer.rerank, .readouts = offer.readouts, .penalties = loaded.backend.penalties, + .logit_bias = loaded.backend.logit_bias, .reasoning = reasoning(F), .vision = offer.vision, .ocr = offer.ocr, diff --git a/zig/src/native/qwen35.zig b/zig/src/native/qwen35.zig index d28a9fd76e8..7ae8d6846b6 100644 --- a/zig/src/native/qwen35.zig +++ b/zig/src/native/qwen35.zig @@ -176,7 +176,7 @@ pub fn open(a: std.mem.Allocator, gpa: std.mem.Allocator, io: std.Io, o: api.Ope h.clock = .{ .io = io }; h.core = lanes.Engine.init(gpa, &h.config, h.metal.backend(), h.clock.clock()); errdefer h.core.deinit(); - h.host = api.LaneHost.init(gpa, io, &h.core, .{ .lanes = served, .context_window = @intCast(window), .prefill_step = chunk_u32, .decode_share = o.decode_share, .structures = true, .witness = metal_witness.source(bound) }); + h.host = api.LaneHost.init(gpa, io, &h.core, .{ .lanes = served, .context_window = @intCast(window), .prefill_step = chunk_u32, .decode_share = o.decode_share, .structures = true, .logit_bias = true, .witness = metal_witness.source(bound) }); h.host.memory = .{ .ctx = h, .read = readMemory }; h.cache = null; if (o.prompt_cache_gib) |budget_gib| { diff --git a/zig/src/server/chat.zig b/zig/src/server/chat.zig index faed8494aff..0c3be470cc0 100644 --- a/zig/src/server/chat.zig +++ b/zig/src/server/chat.zig @@ -295,6 +295,7 @@ pub fn prepare(srv: *Server, cx: *Cx, input: Input, gone: anytype) Failure!Prepa .max_tokens = @intCast(@min(limit, std.math.maxInt(u32))), .sampling = sampling, .penalties = try srv.resolvePenalties(cx, f, instruct), + .logit_bias = try fields_mod.logitBias(cx, f, srv.info.capability(.logit_bias), srv.text.vocabSize()), .eos = if (stops_opt.ignore_eos) &.{} else srv.eos, .drafts = drafts, .background = background, diff --git a/zig/src/server/fields.zig b/zig/src/server/fields.zig index b63c5f9c3e5..cc999bbba3a 100644 --- a/zig/src/server/fields.zig +++ b/zig/src/server/fields.zig @@ -6,6 +6,8 @@ const Value = json.Value; const Cx = errors.Cx; const Allocator = std.mem.Allocator; +pub const logitBias = @import("logit_bias.zig").parse; + pub const efforts = [_][]const u8{ "none", "minimal", "low", "medium", "high", "xhigh", "max" }; const effort_order = [_][]const u8{ "max", "xhigh", "high", "medium", "low", "minimal" }; // highest first diff --git a/zig/src/server/kept_probs.zig b/zig/src/server/kept_probs.zig index 9320545dd12..a50fb82206b 100644 --- a/zig/src/server/kept_probs.zig +++ b/zig/src/server/kept_probs.zig @@ -30,6 +30,7 @@ pub fn asked(cx: *Cx, body: json.Value, logprobs: ?u8) errors.Refused!bool { /// The rows a kept_probs request asks the engine for (all 20), or its refusal when the rows can't hold the kept set. pub fn admit(cx: *Cx, request: *const api.Request) errors.Refused!u8 { + if (request.logit_bias.len > 0) return cx.refuse("kept_probs can't be used with logit_bias: the rows are the model's distribution before token biases"); if (request.penalties.active()) return cx.refuse("kept_probs can't be used with presence_penalty or frequency_penalty: send both as 0"); if (request.structure != null) return cx.refuse("kept_probs can't be used with a grammar: the rows are the model's distribution before the grammar's mask"); if (request.sampling) |s| if (s.temperature > 0 and (s.top_k == 0 or s.top_k > max_top)) @@ -246,6 +247,9 @@ test "admit: 20 rows asked; sampled top_k must fit them, and penalties or a gram try std.testing.expectError(error.Refused, admit(&cx, &req)); } req.penalties = .{}; + req.logit_bias = &.{.{ .token = 0, .value = 1 }}; + try std.testing.expectError(error.Refused, admit(&cx, &req)); + req.logit_bias = &.{}; req.structure = .{ .kind = .json }; try std.testing.expectError(error.Refused, admit(&cx, &req)); } diff --git a/zig/src/server/logit_bias.zig b/zig/src/server/logit_bias.zig new file mode 100644 index 00000000000..80c99c66079 --- /dev/null +++ b/zig/src/server/logit_bias.zig @@ -0,0 +1,38 @@ +//! Request token IDs are decimal object keys; only explicitly capable engines accept a nonempty bias. +const std = @import("std"); +const json = @import("json"); +const api = @import("engine_api"); +const errors = @import("errors.zig"); + +pub fn parse(cx: *errors.Cx, fields: json.Value, supported: bool, vocab: u32) errors.Refused![]const api.LogitBias { + const v = fields.field("logit_bias") orelse return &.{}; + if (v != .object) return cx.refuse("logit_bias must be an object of token IDs and finite numbers, or null"); + if (v.object.count() == 0) return &.{}; + if (!supported) return cx.refuse("logit_bias is not supported by this model or backend"); + if (v.object.count() > 300) return cx.refuse("logit_bias must contain at most 300 entries"); + const out = try cx.a.alloc(api.LogitBias, v.object.count()); + var bans: usize = 0; + for (v.object.keys(), v.object.values(), out) |key, value, *entry| { + if (key.len == 0) return cx.refuse("logit_bias keys must be decimal token IDs in the vocabulary"); + for (key) |ch| if (!std.ascii.isDigit(ch)) + return cx.refuse("logit_bias keys must be decimal token IDs in the vocabulary"); + const token = std.fmt.parseInt(u32, key, 10) catch + return cx.refuse("logit_bias keys must be decimal token IDs in the vocabulary"); + if (token >= vocab) return cx.refuse("logit_bias token ID is outside the vocabulary"); + if (value != .int and value != .float) return cx.refuse("logit_bias values must be finite numbers between -100 and 100"); + const amount = value.float64() orelse return cx.refuse("logit_bias values must be finite numbers between -100 and 100"); + if (!std.math.isFinite(amount) or amount < -100 or amount > 100) + return cx.refuse("logit_bias values must be finite numbers between -100 and 100"); + entry.* = .{ .token = token, .value = @floatCast(amount), .ban = amount == -100 }; + if (amount == -100) bans += 1; + } + std.mem.sort(api.LogitBias, out, {}, struct { + fn less(_: void, a: api.LogitBias, b: api.LogitBias) bool { + return a.token < b.token; + } + }.less); + for (out[1..], out[0 .. out.len - 1]) |a, b| if (a.token == b.token) + return cx.refuse("logit_bias contains duplicate token IDs"); + if (bans == vocab) return cx.refuse("logit_bias cannot ban every token in the vocabulary"); + return out; +} diff --git a/zig/src/server/logit_bias_request_test.zig b/zig/src/server/logit_bias_request_test.zig new file mode 100644 index 00000000000..7ceee8137bd --- /dev/null +++ b/zig/src/server/logit_bias_request_test.zig @@ -0,0 +1,148 @@ +//! Bias refusal and parsing travel through the real completion request to the engine. +const std = @import("std"); +const api = @import("engine_api"); +const json = @import("json"); +const openai = @import("openai.zig"); +const Server = @import("server.zig").Server; +const Conn = @import("http_conn.zig").Conn; +const fixture = @import("hf_eos_fixture.zig"); +const HfText = @import("hf_text.zig").HfText; +const Allocator = std.mem.Allocator; + +const Script = struct { + supported: bool = false, + seen: ?[]const api.LogitBias = null, + + fn engine(s: *Script) api.Engine { + return .{ .ctx = s, .vtable = &.{ .info = info, .submit = submit, .cancel = cancel, .status = status, .memory = memory } }; + } + fn info(ctx: *anyopaque) api.Info { + const s: *Script = @ptrCast(@alignCast(ctx)); + return .{ .context_window = 262144, .logit_bias = s.supported }; + } + fn submit(ctx: *anyopaque, id: api.Id, request: *const api.Request, sink: api.Sink) api.SubmitError!void { + const s: *Script = @ptrCast(@alignCast(ctx)); + s.seen = request.logit_bias; + sink.event(sink.ctx, id, &.{ .prefilled = 0 }); + sink.event(sink.ctx, id, &.{ .tokens = &.{2} }); + sink.event(sink.ctx, id, &.{ .finished = .{ .reason = .stop } }); + } + fn cancel(_: *anyopaque, _: api.Id) void {} + fn status(_: *anyopaque, out: *api.Status, _: []u32) void { + out.* = .{}; + } + fn memory(_: *anyopaque, _: bool) ?api.Memory { + return null; + } +}; + +const Reply = struct { + a: Allocator, + whole: ?json.Value = null, + status: ?u16 = null, + + fn out(r: *Reply) openai.Out { + return .{ .ctx = r, .vt = &.{ .open = open, .event = event, .reply = reply } }; + } + fn open(ctx: *anyopaque, _: usize) error{Closed}!void { + _ = ctx; + } + fn event(ctx: *anyopaque, value: ?json.Value) error{Closed}!void { + _ = ctx; + _ = value; + } + fn reply(ctx: *anyopaque, status_code: u16, value: json.Value) void { + const r: *Reply = @ptrCast(@alignCast(ctx)); + r.whole = value; + r.status = status_code; + } +}; + +fn check(supported: bool, defaults: ?[]const u8, extra: []const u8, status_code: u16, want: []const api.LogitBias) !void { + const t = std.testing; + var arena = std.heap.ArenaAllocator.init(t.allocator); + defer arena.deinit(); + const a = arena.allocator(); + var f = try fixture.Fixture.init(t.allocator, t.io, null); + defer f.deinit(); + var problem: []const u8 = ""; + const text = try HfText.load(t.allocator, t.io, f.path, null, a, &problem); + defer text.deinit(); + var script: Script = .{ .supported = supported }; + const srv = try Server.init(t.allocator, t.io, script.engine(), text.text(), .{ + .served_name = "m", + .model_ids = &.{"m"}, + .enable_thinking = false, + .use_drafts = false, + .default_sampling = if (defaults) |d| (try json.parse(a, d)).ok else null, + }, null); + defer srv.deinit(); + const body = (try json.parse(a, try std.fmt.allocPrint(a, "{{\"model\":\"m\",\"prompt\":[0],\"max_tokens\":4{s}}}", .{extra}))).ok; + var conn: Conn = .{ .fd = -1, .peer = "", .buf = &.{}, .gpa = a }; + var response: Reply = .{ .a = a }; + openai.run(srv, a, response.out(), .{ .conn = &conn }, false, body); + try t.expectEqual(@as(?u16, status_code), response.status); + const whole = response.whole.?; + if (status_code == 400) { + try t.expect(script.seen == null); + const message = whole.get("error").?.strField("message").?; + try t.expect(std.mem.indexOf(u8, message, "logit_bias") != null); + } else { + try t.expectEqualDeep(want, script.seen.?); + try t.expectEqualStrings("K", whole.get("choices").?.array[0].strField("text").?); + } +} + +test "logit_bias: unsupported requests refuse by name before submission, even zero entries" { + try check(false, null, ",\"logit_bias\":{\"1\":0}", 400, &.{}); + try check(false, null, ",\"logit_bias\":{\"1\":-100}", 400, &.{}); + for ([_][]const u8{ "", ",\"logit_bias\":null", ",\"logit_bias\":{}" }) |extra| + try check(false, null, extra, 200, &.{}); +} + +test "logit_bias: accepted sparse entries carry sorted IDs, signed scores and a hard ban" { + try check(true, null, ",\"logit_bias\":{\"2\":2.5,\"1\":-100}", 200, &.{ .{ .token = 1, .value = -100, .ban = true }, .{ .token = 2, .value = 2.5 } }); +} + +test "logit_bias: malformed keys, values and duplicate IDs refuse by name" { + for ([_][]const u8{ "[]", "1", "{\"-1\":0}", "{\"x\":1}", "{\"4294967296\":0}", "{\"999999999\":0}", "{\"1\":101}", "{\"1\":-101}", "{\"1\":\"1\"}", "{\"1\":null}", "{\"1\":true}", "{\"1\":1e999}", "{\"01\":1,\"1\":2}" }) |value| { + var arena: std.heap.ArenaAllocator = .init(std.testing.allocator); + defer arena.deinit(); + try check(true, null, try std.fmt.allocPrint(arena.allocator(), ",\"logit_bias\":{s}", .{value}), 400, &.{}); + } +} + +test "logit_bias: 300-entry cap, finite boundaries, all-banned refusal and near-ban rounding" { + var arena: std.heap.ArenaAllocator = .init(std.testing.allocator); + defer arena.deinit(); + const a = arena.allocator(); + const object = try json.newObject(a); + for (0..301) |i| try object.put(a, try std.fmt.allocPrint(a, "{d}", .{i}), .{ .float = 0 }); + const fields = try json.newObject(a); + try fields.put(a, "logit_bias", .{ .object = object }); + var cx: @import("errors.zig").Cx = .{ .a = a }; + const parse = @import("fields.zig").logitBias; + try std.testing.expectError(error.Refused, parse(&cx, .{ .object = fields }, true, 400)); + _ = object.swapRemove("300"); + try std.testing.expectEqual(@as(usize, 300), (try parse(&cx, .{ .object = fields }, true, 400)).len); + const near = (try json.parse(a, "{\"logit_bias\":{\"0\":-99.999999999,\"1\":100}}")).ok; + const entries = try parse(&cx, near, true, 2); + try std.testing.expect(!entries[0].ban); + const all = (try json.parse(a, "{\"logit_bias\":{\"0\":-100,\"1\":-100}}")).ok; + try std.testing.expectError(error.Refused, parse(&cx, all, true, 2)); +} + +test "logit_bias: kept_probs refuses a biased row and keeps empty-bias admission unchanged" { + const t = std.testing; + var arena: std.heap.ArenaAllocator = .init(t.allocator); + defer arena.deinit(); + var cx: @import("errors.zig").Cx = .{ .a = arena.allocator() }; + var request: api.Request = .{ .prompt = &.{0}, .max_tokens = 1, .logprobs = 1 }; + const admit = @import("kept_probs.zig").admit; + try t.expectEqual(@as(u8, 20), try admit(&cx, &request)); + request.logit_bias = &.{.{ .token = 1, .value = 0 }}; + try t.expectError(error.Refused, admit(&cx, &request)); + try t.expect(std.mem.indexOf(u8, cx.message, "logit_bias") != null); + request.logit_bias = &.{}; + try t.expectEqual(@as(u8, 20), try admit(&cx, &request)); +} diff --git a/zig/src/server/openai.zig b/zig/src/server/openai.zig index 3da1be11ba3..f43efbb3d35 100644 --- a/zig/src/server/openai.zig +++ b/zig/src/server/openai.zig @@ -144,7 +144,7 @@ pub fn plan(srv: *Server, cx: *Cx, is_chat: bool, raw: Value, format: ?[]const u input.temperature = if (t == .float) t.float else std.fmt.parseFloat(f64, t.int) catch 0; }; const sampling = try json.newObject(cx.a); - for ([_][]const u8{ "temperature", "top_p", "top_k", "min_p", "presence_penalty", "frequency_penalty", "seed", "priority", "model", "draft", "thinking_budget", "ignore_eos", "return_token_ids", "return_progress", "stop", "grammar_budget", "deadline_s" } ++ grammar.fields) |k| if (body.get(k)) |v| try sampling.put(cx.a, k, v); + for ([_][]const u8{ "temperature", "top_p", "top_k", "min_p", "presence_penalty", "frequency_penalty", "logit_bias", "seed", "priority", "model", "draft", "thinking_budget", "ignore_eos", "return_token_ids", "return_progress", "stop", "grammar_budget", "deadline_s" } ++ grammar.fields) |k| if (body.get(k)) |v| try sampling.put(cx.a, k, v); try grammar.refusal(cx, body); if (input.tools.len > 0 and try tool_specs.choiceRequiresCall(cx.a, body.get("tool_choice"))) try sampling.put(cx.a, "tool_call_required", .{ .bool = true }); if (body.field("parallel_tool_calls")) |p| if (p == .bool and !p.bool) try sampling.put(cx.a, "tool_call_single", .{ .bool = true }); diff --git a/zig/src/server/responses_translate.zig b/zig/src/server/responses_translate.zig index ef4750fe3ad..55ca0051a2a 100644 --- a/zig/src/server/responses_translate.zig +++ b/zig/src/server/responses_translate.zig @@ -9,7 +9,7 @@ const Value = json.Value; const Cx = errors.Cx; const Allocator = std.mem.Allocator; /// Fields a chat completion reads as they are: OpenAI's and this server's own. -const passed = [_][]const u8{ "model", "temperature", "top_p", "top_k", "min_p", "seed", "stream", "parallel_tool_calls", "stop", "draft", "thinking_budget", "ignore_eos", "priority", "return_token_ids", "return_progress", "chat_template_kwargs", "grammar_budget", "cache_salt" }; +const passed = [_][]const u8{ "model", "temperature", "top_p", "top_k", "min_p", "logit_bias", "seed", "stream", "parallel_tool_calls", "stop", "draft", "thinking_budget", "ignore_eos", "priority", "return_token_ids", "return_progress", "chat_template_kwargs", "grammar_budget", "cache_salt" }; const refused = [_][2][]const u8{ .{ "conversation", "conversations are not supported: send previous_response_id or the items" }, .{ "prompt", "prompt templates are not supported: send input and instructions" }, diff --git a/zig/src/server/root.zig b/zig/src/server/root.zig index e182290e98f..944d85a7888 100644 --- a/zig/src/server/root.zig +++ b/zig/src/server/root.zig @@ -383,6 +383,7 @@ test { _ = @import("models_idle_audit_test.zig"); _ = @import("penalty_request_test.zig"); _ = @import("choices_test.zig"); + _ = @import("logit_bias_request_test.zig"); _ = @import("cors_test.zig"); _ = @import("deepseek_fixture_test.zig"); _ = @import("uocr_chat_test.zig"); diff --git a/zig/src/server/witness_fixture.zig b/zig/src/server/witness_fixture.zig index 7ff3a85d508..6229ce60f50 100644 --- a/zig/src/server/witness_fixture.zig +++ b/zig/src/server/witness_fixture.zig @@ -35,7 +35,7 @@ pub const Engine = struct { } fn info(ptr: *anyopaque) api.Info { const e = cast(ptr); - return .{ .context_window = 4096, .witness = if (e.hooked) .{ .ctx = e, .read = read, .begin = begin } else null }; + return .{ .context_window = 4096, .logit_bias = true, .witness = if (e.hooked) .{ .ctx = e, .read = read, .begin = begin } else null }; } fn begin(ptr: *anyopaque) void { _ = cast(ptr).begins.fetchAdd(1, .monotonic); diff --git a/zig/src/server/witness_reply.zig b/zig/src/server/witness_reply.zig index 6f3bc190977..76dfc6638ea 100644 --- a/zig/src/server/witness_reply.zig +++ b/zig/src/server/witness_reply.zig @@ -38,6 +38,7 @@ fn resolvedOf(a: Allocator, r: *const api.Request, stops: []const []const u8) Al try o.put(a, "frequency_penalty", .{ .float = r.penalties.frequency }); try o.put(a, "eos", try idsOf(a, r.eos)); try o.put(a, "stop", try stringsOf(a, stops)); + if (r.logit_bias.len > 0) try o.put(a, "logit_bias", try biasOf(a, r.logit_bias)); try o.put(a, "drafts", .{ .bool = r.drafts }); try o.put(a, "think_budget", try json.intValue(a, r.think_budget)); try o.put(a, "think_close", try idsOf(a, r.think_close)); @@ -54,6 +55,18 @@ fn resolvedOf(a: Allocator, r: *const api.Request, stops: []const []const u8) Al return .{ .object = o }; } +fn biasOf(a: Allocator, entries: []const api.LogitBias) Allocator.Error!Value { + const out = try a.alloc(Value, entries.len); + for (entries, out) |e, *slot| { + const o = try json.newObject(a); + try o.put(a, "token", try json.intValue(a, e.token)); + try o.put(a, "value", .{ .float = e.value }); + try o.put(a, "ban", .{ .bool = e.ban }); + slot.* = .{ .object = o }; + } + return .{ .array = out }; +} + fn samplingOf(a: Allocator, s: api.Sampling) Allocator.Error!Value { const o = try json.newObject(a); try o.put(a, "seed", try json.intValue(a, s.seed)); diff --git a/zig/src/server/witness_reply_test.zig b/zig/src/server/witness_reply_test.zig index 4a4e46e5a4c..08ca6ec9f53 100644 --- a/zig/src/server/witness_reply_test.zig +++ b/zig/src/server/witness_reply_test.zig @@ -149,6 +149,31 @@ test "execution witness reply: known binds the read route's witness, the prompt try t.expectEqualStrings(b.strField("prompt_sha256").?, longer.strField("prompt_sha256").?); } +test "execution witness reply: a bias-only request change moves request_sha256, and unbiased requests omit the field" { + var c = try fixture.Checkpoint.init(); + defer c.deinit(); + var engine: fixture.Engine = .{}; + var h: fixture.Harness = .{}; + try ready(&h, &engine, &c, .{}); + defer h.deinit(); + var arena: std.heap.ArenaAllocator = .init(t.allocator); + defer arena.deinit(); + const a = arena.allocator(); + const plain = (try post(&h, a, "/v1/completions", ids_prompt)).get("execution_witness").?; + try t.expect(plain.get("request").?.get("logit_bias") == null); + try expectConsistent(plain); + const biased = (try post(&h, a, "/v1/completions", open_body ++ ",\"logit_bias\":{\"17\":-2.5}}")).get("execution_witness").?; + const entries = biased.get("request").?.get("logit_bias").?.array; + try t.expectEqual(@as(usize, 1), entries.len); + try t.expectEqual(@as(?i64, 17), entries[0].get("token").?.int64()); + try t.expectEqual(@as(?f64, -2.5), entries[0].get("value").?.float); + try t.expectEqual(false, entries[0].get("ban").?.bool); + try expectConsistent(biased); + try t.expect(!std.mem.eql(u8, plain.strField("request_sha256").?, biased.strField("request_sha256").?)); + try t.expect(!std.mem.eql(u8, plain.strField("binding").?, biased.strField("binding").?)); + try t.expectEqualStrings(plain.strField("prompt_sha256").?, biased.strField("prompt_sha256").?); +} + test "execution witness reply: an unsupported path or an excluded flag binds unknown with the digests" { var c = try fixture.Checkpoint.init(); defer c.deinit(); diff --git a/zig/tests/cuda/contract_elementwise.zig b/zig/tests/cuda/contract_elementwise.zig index d96ac58a5da..fad76d1c0af 100644 --- a/zig/tests/cuda/contract_elementwise.zig +++ b/zig/tests/cuda/contract_elementwise.zig @@ -23,6 +23,8 @@ pub const Set = struct { sample: ?cuda.Module = null, draws: cuda.sample.Draws = undefined, penalize: ?penalize_k.Penalize = null, + bias: [2]penalize_k.Penalize = undefined, + n_bias: usize = 0, lfm2m: lfm2m_k.Set = .{}, // LFM2.5-24B-A2B's router, Liquid's 3-tap conv and commit (rows with sums, beside these) paged: paged_k.Set = .{}, // paged attention: Liquid's head 64 decode and prompt rows, LFM3's head 128 prompt rows dots: dots_k.Set = .{}, // dots.mocr's q|k|v bias and Torch-order RoPE @@ -48,6 +50,11 @@ pub const Set = struct { self.draws = try cuda.sample.Draws.resolve(self.sample.?); self.penalize = .{ .rig = .{ .gpu = gpu, .s = s }, .draws = &self.draws }; try kernels.append(a, self.penalize.?.kernel()); + for (&self.bias, 0..) |*p, i| { + p.* = .{ .rig = .{ .gpu = gpu, .s = s }, .draws = &self.draws, .bias = true, .bad = i == 1 }; + self.n_bias += 1; + try kernels.append(a, p.kernel()); + } try self.lfm2m.add(gpu, s, ctl_mod, kernels); try self.paged.add(gpu, s, ctl_mod, kernels); try self.dots.add(gpu, s, ctl_mod, kernels); @@ -65,6 +72,7 @@ pub const Set = struct { self.dots.deinit(); self.paged.deinit(); self.lfm2m.deinit(); + for (self.bias[0..self.n_bias]) |*p| p.deinit(); if (self.penalize) |*p| p.deinit(); if (self.sample) |*m| m.unload(); for (self.embeds[0..self.n_embeds]) |*x| x.deinit(); diff --git a/zig/tests/cuda/contract_penalize.zig b/zig/tests/cuda/contract_penalize.zig index 69ef6682487..212e55e18e8 100644 --- a/zig/tests/cuda/contract_penalize.zig +++ b/zig/tests/cuda/contract_penalize.zig @@ -29,6 +29,8 @@ pub const spec: c.Spec = .{ pub const Penalize = struct { rig: rig_.Rig, + bias: bool = false, + bad: bool = false, // planted control: the old subtract fails to ban +inf and NaN draws: *const cuda.sample.Draws, arena: ?std.heap.ArenaAllocator = null, rows: usize = 0, @@ -48,7 +50,9 @@ pub const Penalize = struct { const vt = g.hooks(Penalize); pub fn kernel(self: *Penalize) g.Kernel { - return .{ .spec = spec, .ctx = self, .vt = &vt }; + var selected = spec; + if (self.bias) selected.name = if (self.bad) "cuda sample bias ban control" else "cuda sample tf_bias_rows"; + return .{ .spec = selected, .ctx = self, .vt = &vt, .control = if (self.bad) .nonfinite else null }; } pub fn prepare(self: *Penalize, shape: c.Shape, fill: g.Fill, seed: u64) !bool { @@ -86,6 +90,12 @@ pub const Penalize = struct { if (fill == .stress) for (self.sub) |*s| { // bf16's largest values: the difference rounds, or overflows s.* = 0x1p127; }; + if (self.bias) { + for (self.sub, 0..) |*s, i| if (i % 3 == 0) { + s.* = std.math.inf(f32); + }; + if (fill == .nonfinite) self.logits[self.row[0] * vocab + self.tok[0]] = bfr.bits(std.math.inf(f32)); + } self.out = try self.rig.output(self.logits.len * 2); const bytes = try a.alloc(u8, shape.n * 12); @memcpy(bytes[0 .. shape.n * 4], std.mem.sliceAsBytes(self.row)); @@ -99,7 +109,7 @@ pub const Penalize = struct { pub fn run(self: *Penalize) !void { const b: cuda.DeviceBuffer = .{ .d = self.rig.gpu.d, .ptr = self.out, .len = self.logits.len * 2 }; try b.upload(0, std.mem.sliceAsBytes(self.logits)); - try self.draws.penalize(self.rig.s, self.out, vocab, self.entries, self.n); + if (self.bias and !self.bad) try self.draws.biasRows(self.rig.s, self.out, vocab, self.entries, self.n) else try self.draws.penalize(self.rig.s, self.out, vocab, self.entries, self.n); try self.rig.s.synchronize(); } @@ -110,7 +120,10 @@ pub const Penalize = struct { /// Every logit as it was, except each entry's, less its amount; no sums, so no magnitude. pub fn reference(self: *Penalize, want: []f64, mag: []f64) !void { for (want, self.logits) |*w, x| w.* = bfr.value(x); - for (self.row, self.tok, self.sub) |r, t, s| want[r * vocab + t] -= s; + for (self.row, self.tok, self.sub) |r, t, s| { + const x = &want[r * vocab + t]; + x.* = if (self.bias and s == std.math.inf(f32)) -std.math.inf(f64) else x.* - s; + } @memset(mag, 0); } }; diff --git a/zig/tests/fixtures/gradient-serving.tsv b/zig/tests/fixtures/gradient-serving.tsv index 498e6a4ed07..7cbff6de488 100644 --- a/zig/tests/fixtures/gradient-serving.tsv +++ b/zig/tests/fixtures/gradient-serving.tsv @@ -109,7 +109,7 @@ zig/src/cuda/qmmf.zig 2d1ab1d6c2cf636a20427b93839a902df01cf54962f77bc9ff96b49040 zig/src/cuda/rank_scatter.zig 303fd707713af732dd1d31c6a940dd4eeed44e9b26fe202919da5925654fc212 raw zig/src/cuda/root.zig b0f15d5624ce83fe0c98b4b35a9e496f79ff42f8b9e4656afdd57bf0681facc9 raw main 42735f94f0 (#2335: cuda.mla exported), (cuda.affine_experts exported for Hy4-flash); main 42735f94f0 (#2335: cuda.mla exported); #3518 (exports roce_pair_rule; the test block imports roce_layout, roce_pairs and roce_pair_rule); #4493 (opt-in paired prompt experts, 128-row items); #4533 exports qmmf_half; #5051: cuda.topk_rows and cuda.sparse_index exported; slice 1 of #4846: cuda.sparse_attention exported; main 32c4e3d8f (#3368: the fn_int4 image registered, the int4 module exported and its tests listed); #5442: cuda.tfq4 exported; TFQ5+TP: cuda.tfq3_tp and cuda.tfq5 exported zig/src/cuda/route_rows.zig e23257dea1f244ebba4399d7bc0730953f75eebbd7789819d5785e88a8907206 raw -zig/src/cuda/sample.zig 9e3a31bd0480284ff069148b2d3c92f1e2ba24f16c18362dae9de48ec7fc65fe raw series patches 02-cuda-rounds.patch; HELD: must be re-qualified by the LW device gates on the 1.1.1 candidate; main 37b0776ce (#2680: adds ruleFor and rule, which reach the same core rule, byte-equal over a 25,480-setting grid; existing code unchanged), #3124 +zig/src/cuda/sample.zig 99c58a3e4413a9675baef4cc9303d4286cba6b1523554a7ce8ddd771b4364320 raw series patches 02-cuda-rounds.patch; HELD: must be re-qualified by the LW device gates on the 1.1.1 candidate; main 37b0776ce (#2680: adds ruleFor and rule, which reach the same core rule, byte-equal over a 25,480-setting grid; existing code unchanged), #3124, #3146 zig/src/cuda/segments.zig 8d029a27a7b2a77916c91c9e650cee07c25aec317efacfdb3f8f8967744899a9 raw zig/src/cuda/stream.zig 02c1879e72a35927466ab462d6b2a461691d1f5196da770decd1125db2199fa6 raw commits e9bf05ffd, ef23b5934; series patches 14-runtime-foundation.patch; HELD: must be re-qualified by the LW device gates on the 1.1.1 candidate zig/src/cuda/tp_group.zig 1a2acbdf2de6b827218deb45df5b5845beecde4eb718a4e4b3966582db51d7a7 raw commits b8d45ded3, 80afaf959; series patches 14-runtime-foundation.patch; HELD: must be re-qualified by the LW device gates on the 1.1.1 candidate; main c8ad9872da (#2205: RoCE small gathers at any world up to roce.max_world when every rank asks; TF_ROCE's default unchanged, two ranks on, three or more on NCCL), 61a2651577 (#2789: a call failing after the group's abort ends as Aborted, not fatally); #2918 (communicator abort through its owner) diff --git a/zig/tests/server/golden/framing/chunked-bytes.json b/zig/tests/server/golden/framing/chunked-bytes.json index 4acd96fef23..4851e0fb010 100644 --- a/zig/tests/server/golden/framing/chunked-bytes.json +++ b/zig/tests/server/golden/framing/chunked-bytes.json @@ -25,10 +25,10 @@ ], [ "Content-Length", - "1862" + "1904" ] ], - "body": "{\"object\": \"list\", \"data\": [{\"id\": \"fake-model\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}, {\"id\": \"fake-alias\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}]}", + "body": "{\"object\": \"list\", \"data\": [{\"id\": \"fake-model\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"logit_bias\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}, {\"id\": \"fake-alias\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"logit_bias\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}]}", "interim": "" } ] diff --git a/zig/tests/server/golden/framing/connection-close.json b/zig/tests/server/golden/framing/connection-close.json index 52d5870dbb5..de4b17285f5 100644 --- a/zig/tests/server/golden/framing/connection-close.json +++ b/zig/tests/server/golden/framing/connection-close.json @@ -10,14 +10,14 @@ ], [ "Content-Length", - "1862" + "1904" ], [ "Connection", "close" ] ], - "body": "{\"object\": \"list\", \"data\": [{\"id\": \"fake-model\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}, {\"id\": \"fake-alias\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}]}", + "body": "{\"object\": \"list\", \"data\": [{\"id\": \"fake-model\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"logit_bias\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}, {\"id\": \"fake-alias\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"logit_bias\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}]}", "interim": "" } ] diff --git a/zig/tests/server/golden/framing/extensions-trailers.json b/zig/tests/server/golden/framing/extensions-trailers.json index 4acd96fef23..4851e0fb010 100644 --- a/zig/tests/server/golden/framing/extensions-trailers.json +++ b/zig/tests/server/golden/framing/extensions-trailers.json @@ -25,10 +25,10 @@ ], [ "Content-Length", - "1862" + "1904" ] ], - "body": "{\"object\": \"list\", \"data\": [{\"id\": \"fake-model\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}, {\"id\": \"fake-alias\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}]}", + "body": "{\"object\": \"list\", \"data\": [{\"id\": \"fake-model\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"logit_bias\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}, {\"id\": \"fake-alias\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"logit_bias\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}]}", "interim": "" } ] diff --git a/zig/tests/server/golden/framing/keepalive-three.json b/zig/tests/server/golden/framing/keepalive-three.json index 2ccf66d2a0d..808267cd1ea 100644 --- a/zig/tests/server/golden/framing/keepalive-three.json +++ b/zig/tests/server/golden/framing/keepalive-three.json @@ -40,10 +40,10 @@ ], [ "Content-Length", - "1862" + "1904" ] ], - "body": "{\"object\": \"list\", \"data\": [{\"id\": \"fake-model\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}, {\"id\": \"fake-alias\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}]}", + "body": "{\"object\": \"list\", \"data\": [{\"id\": \"fake-model\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"logit_bias\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}, {\"id\": \"fake-alias\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"logit_bias\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}]}", "interim": "" } ] diff --git a/zig/tests/server/golden/framing/pipelined.json b/zig/tests/server/golden/framing/pipelined.json index 249e9100aa1..bc6b6072881 100644 --- a/zig/tests/server/golden/framing/pipelined.json +++ b/zig/tests/server/golden/framing/pipelined.json @@ -25,10 +25,10 @@ ], [ "Content-Length", - "1862" + "1904" ] ], - "body": "{\"object\": \"list\", \"data\": [{\"id\": \"fake-model\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}, {\"id\": \"fake-alias\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}]}", + "body": "{\"object\": \"list\", \"data\": [{\"id\": \"fake-model\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"logit_bias\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}, {\"id\": \"fake-alias\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"logit_bias\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}]}", "interim": "" } ] diff --git a/zig/tests/server/golden/keys/full-model-id.json b/zig/tests/server/golden/keys/full-model-id.json index b2cd08e88e4..9a984b3b677 100644 --- a/zig/tests/server/golden/keys/full-model-id.json +++ b/zig/tests/server/golden/keys/full-model-id.json @@ -10,10 +10,10 @@ ], [ "Content-Length", - "915" + "936" ] ], - "body": "{\"id\": \"fake-alias\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}", + "body": "{\"id\": \"fake-alias\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"logit_bias\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}", "interim": "" } ] diff --git a/zig/tests/server/golden/keys/full-then-none.json b/zig/tests/server/golden/keys/full-then-none.json index 96d1c601d61..1e63690b725 100644 --- a/zig/tests/server/golden/keys/full-then-none.json +++ b/zig/tests/server/golden/keys/full-then-none.json @@ -10,10 +10,10 @@ ], [ "Content-Length", - "1862" + "1904" ] ], - "body": "{\"object\": \"list\", \"data\": [{\"id\": \"fake-model\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}, {\"id\": \"fake-alias\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}]}", + "body": "{\"object\": \"list\", \"data\": [{\"id\": \"fake-model\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"logit_bias\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}, {\"id\": \"fake-alias\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"logit_bias\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}]}", "interim": "" }, { diff --git a/zig/tests/server/golden/keys/models-bare.json b/zig/tests/server/golden/keys/models-bare.json index f37e9ca002c..665983b297d 100644 --- a/zig/tests/server/golden/keys/models-bare.json +++ b/zig/tests/server/golden/keys/models-bare.json @@ -10,10 +10,10 @@ ], [ "Content-Length", - "1862" + "1904" ] ], - "body": "{\"object\": \"list\", \"data\": [{\"id\": \"fake-model\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}, {\"id\": \"fake-alias\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}]}", + "body": "{\"object\": \"list\", \"data\": [{\"id\": \"fake-model\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"logit_bias\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}, {\"id\": \"fake-alias\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"logit_bias\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}]}", "interim": "" } ] diff --git a/zig/tests/server/golden/keys/models-cli.json b/zig/tests/server/golden/keys/models-cli.json index f37e9ca002c..665983b297d 100644 --- a/zig/tests/server/golden/keys/models-cli.json +++ b/zig/tests/server/golden/keys/models-cli.json @@ -10,10 +10,10 @@ ], [ "Content-Length", - "1862" + "1904" ] ], - "body": "{\"object\": \"list\", \"data\": [{\"id\": \"fake-model\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}, {\"id\": \"fake-alias\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}]}", + "body": "{\"object\": \"list\", \"data\": [{\"id\": \"fake-model\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"logit_bias\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}, {\"id\": \"fake-alias\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"logit_bias\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}]}", "interim": "" } ] diff --git a/zig/tests/server/golden/keys/models-env.json b/zig/tests/server/golden/keys/models-env.json index f37e9ca002c..665983b297d 100644 --- a/zig/tests/server/golden/keys/models-env.json +++ b/zig/tests/server/golden/keys/models-env.json @@ -10,10 +10,10 @@ ], [ "Content-Length", - "1862" + "1904" ] ], - "body": "{\"object\": \"list\", \"data\": [{\"id\": \"fake-model\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}, {\"id\": \"fake-alias\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}]}", + "body": "{\"object\": \"list\", \"data\": [{\"id\": \"fake-model\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"logit_bias\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}, {\"id\": \"fake-alias\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"logit_bias\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}]}", "interim": "" } ] diff --git a/zig/tests/server/golden/keys/models-file.json b/zig/tests/server/golden/keys/models-file.json index f37e9ca002c..665983b297d 100644 --- a/zig/tests/server/golden/keys/models-file.json +++ b/zig/tests/server/golden/keys/models-file.json @@ -10,10 +10,10 @@ ], [ "Content-Length", - "1862" + "1904" ] ], - "body": "{\"object\": \"list\", \"data\": [{\"id\": \"fake-model\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}, {\"id\": \"fake-alias\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}]}", + "body": "{\"object\": \"list\", \"data\": [{\"id\": \"fake-model\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"logit_bias\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}, {\"id\": \"fake-alias\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"logit_bias\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}]}", "interim": "" } ] diff --git a/zig/tests/server/golden/keys/pooled-identity.json b/zig/tests/server/golden/keys/pooled-identity.json index 96d1c601d61..1e63690b725 100644 --- a/zig/tests/server/golden/keys/pooled-identity.json +++ b/zig/tests/server/golden/keys/pooled-identity.json @@ -10,10 +10,10 @@ ], [ "Content-Length", - "1862" + "1904" ] ], - "body": "{\"object\": \"list\", \"data\": [{\"id\": \"fake-model\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}, {\"id\": \"fake-alias\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}]}", + "body": "{\"object\": \"list\", \"data\": [{\"id\": \"fake-model\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"logit_bias\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}, {\"id\": \"fake-alias\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"logit_bias\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}]}", "interim": "" }, { diff --git a/zig/tests/server/golden/keys/rotated-new.json b/zig/tests/server/golden/keys/rotated-new.json index f37e9ca002c..665983b297d 100644 --- a/zig/tests/server/golden/keys/rotated-new.json +++ b/zig/tests/server/golden/keys/rotated-new.json @@ -10,10 +10,10 @@ ], [ "Content-Length", - "1862" + "1904" ] ], - "body": "{\"object\": \"list\", \"data\": [{\"id\": \"fake-model\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}, {\"id\": \"fake-alias\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}]}", + "body": "{\"object\": \"list\", \"data\": [{\"id\": \"fake-model\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"logit_bias\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}, {\"id\": \"fake-alias\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"logit_bias\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}]}", "interim": "" } ] diff --git a/zig/tests/server/golden/models/alias.json b/zig/tests/server/golden/models/alias.json index b2cd08e88e4..9a984b3b677 100644 --- a/zig/tests/server/golden/models/alias.json +++ b/zig/tests/server/golden/models/alias.json @@ -10,10 +10,10 @@ ], [ "Content-Length", - "915" + "936" ] ], - "body": "{\"id\": \"fake-alias\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}", + "body": "{\"id\": \"fake-alias\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"logit_bias\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}", "interim": "" } ] diff --git a/zig/tests/server/golden/models/bare.json b/zig/tests/server/golden/models/bare.json index 2e37b78060a..551179e8a6c 100644 --- a/zig/tests/server/golden/models/bare.json +++ b/zig/tests/server/golden/models/bare.json @@ -10,10 +10,10 @@ ], [ "Content-Length", - "915" + "936" ] ], - "body": "{\"id\": \"fake-model\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}", + "body": "{\"id\": \"fake-model\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"logit_bias\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}", "interim": "" } ] diff --git a/zig/tests/server/golden/models/served.json b/zig/tests/server/golden/models/served.json index 2e37b78060a..551179e8a6c 100644 --- a/zig/tests/server/golden/models/served.json +++ b/zig/tests/server/golden/models/served.json @@ -10,10 +10,10 @@ ], [ "Content-Length", - "915" + "936" ] ], - "body": "{\"id\": \"fake-model\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}", + "body": "{\"id\": \"fake-model\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"logit_bias\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}", "interim": "" } ] diff --git a/zig/tests/server/golden/models/slash-escaped-lower.json b/zig/tests/server/golden/models/slash-escaped-lower.json index 0392a1d32b9..c5b56bffad3 100644 --- a/zig/tests/server/golden/models/slash-escaped-lower.json +++ b/zig/tests/server/golden/models/slash-escaped-lower.json @@ -10,10 +10,10 @@ ], [ "Content-Length", - "927" + "948" ] ], - "body": "{\"id\": \"example-org/fake-model\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}", + "body": "{\"id\": \"example-org/fake-model\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"logit_bias\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}", "interim": "" } ] diff --git a/zig/tests/server/golden/models/slash-escaped.json b/zig/tests/server/golden/models/slash-escaped.json index 0392a1d32b9..c5b56bffad3 100644 --- a/zig/tests/server/golden/models/slash-escaped.json +++ b/zig/tests/server/golden/models/slash-escaped.json @@ -10,10 +10,10 @@ ], [ "Content-Length", - "927" + "948" ] ], - "body": "{\"id\": \"example-org/fake-model\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}", + "body": "{\"id\": \"example-org/fake-model\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"logit_bias\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}", "interim": "" } ] diff --git a/zig/tests/server/golden/models/slash-raw.json b/zig/tests/server/golden/models/slash-raw.json index 0392a1d32b9..c5b56bffad3 100644 --- a/zig/tests/server/golden/models/slash-raw.json +++ b/zig/tests/server/golden/models/slash-raw.json @@ -10,10 +10,10 @@ ], [ "Content-Length", - "927" + "948" ] ], - "body": "{\"id\": \"example-org/fake-model\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}", + "body": "{\"id\": \"example-org/fake-model\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"logit_bias\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}", "interim": "" } ] diff --git a/zig/tests/server/golden/models/suffix-lists.json b/zig/tests/server/golden/models/suffix-lists.json index 62c30188430..f3b63e95db9 100644 --- a/zig/tests/server/golden/models/suffix-lists.json +++ b/zig/tests/server/golden/models/suffix-lists.json @@ -10,10 +10,10 @@ ], [ "Content-Length", - "2791" + "2854" ] ], - "body": "{\"object\": \"list\", \"data\": [{\"id\": \"fake-model\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}, {\"id\": \"fake-alias\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}, {\"id\": \"example-org/fake-model\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}]}", + "body": "{\"object\": \"list\", \"data\": [{\"id\": \"fake-model\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"logit_bias\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}, {\"id\": \"fake-alias\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"logit_bias\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}, {\"id\": \"example-org/fake-model\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"logit_bias\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}]}", "interim": "" } ] diff --git a/zig/tests/server/golden/scopes/app-model-id.json b/zig/tests/server/golden/scopes/app-model-id.json index b2cd08e88e4..9a984b3b677 100644 --- a/zig/tests/server/golden/scopes/app-model-id.json +++ b/zig/tests/server/golden/scopes/app-model-id.json @@ -10,10 +10,10 @@ ], [ "Content-Length", - "915" + "936" ] ], - "body": "{\"id\": \"fake-alias\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}", + "body": "{\"id\": \"fake-alias\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"logit_bias\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}", "interim": "" } ] diff --git a/zig/tests/server/golden/scopes/read-model-id.json b/zig/tests/server/golden/scopes/read-model-id.json index 2e37b78060a..551179e8a6c 100644 --- a/zig/tests/server/golden/scopes/read-model-id.json +++ b/zig/tests/server/golden/scopes/read-model-id.json @@ -10,10 +10,10 @@ ], [ "Content-Length", - "915" + "936" ] ], - "body": "{\"id\": \"fake-model\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}", + "body": "{\"id\": \"fake-model\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"logit_bias\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}", "interim": "" } ] diff --git a/zig/tests/server/golden/scopes/read-models.json b/zig/tests/server/golden/scopes/read-models.json index f37e9ca002c..665983b297d 100644 --- a/zig/tests/server/golden/scopes/read-models.json +++ b/zig/tests/server/golden/scopes/read-models.json @@ -10,10 +10,10 @@ ], [ "Content-Length", - "1862" + "1904" ] ], - "body": "{\"object\": \"list\", \"data\": [{\"id\": \"fake-model\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}, {\"id\": \"fake-alias\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}]}", + "body": "{\"object\": \"list\", \"data\": [{\"id\": \"fake-model\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"logit_bias\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}, {\"id\": \"fake-alias\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"logit_bias\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}]}", "interim": "" } ] diff --git a/zig/tests/server/golden/status/get-models.json b/zig/tests/server/golden/status/get-models.json index f37e9ca002c..665983b297d 100644 --- a/zig/tests/server/golden/status/get-models.json +++ b/zig/tests/server/golden/status/get-models.json @@ -10,10 +10,10 @@ ], [ "Content-Length", - "1862" + "1904" ] ], - "body": "{\"object\": \"list\", \"data\": [{\"id\": \"fake-model\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}, {\"id\": \"fake-alias\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}]}", + "body": "{\"object\": \"list\", \"data\": [{\"id\": \"fake-model\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"logit_bias\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}, {\"id\": \"fake-alias\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"logit_bias\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}]}", "interim": "" } ] diff --git a/zig/tests/server/golden/status/get-v1-models%3Fx=1.json b/zig/tests/server/golden/status/get-v1-models%3Fx=1.json index f37e9ca002c..665983b297d 100644 --- a/zig/tests/server/golden/status/get-v1-models%3Fx=1.json +++ b/zig/tests/server/golden/status/get-v1-models%3Fx=1.json @@ -10,10 +10,10 @@ ], [ "Content-Length", - "1862" + "1904" ] ], - "body": "{\"object\": \"list\", \"data\": [{\"id\": \"fake-model\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}, {\"id\": \"fake-alias\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}]}", + "body": "{\"object\": \"list\", \"data\": [{\"id\": \"fake-model\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"logit_bias\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}, {\"id\": \"fake-alias\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"logit_bias\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}]}", "interim": "" } ] diff --git a/zig/tests/server/golden/status/get-v1-models.json b/zig/tests/server/golden/status/get-v1-models.json index f37e9ca002c..665983b297d 100644 --- a/zig/tests/server/golden/status/get-v1-models.json +++ b/zig/tests/server/golden/status/get-v1-models.json @@ -10,10 +10,10 @@ ], [ "Content-Length", - "1862" + "1904" ] ], - "body": "{\"object\": \"list\", \"data\": [{\"id\": \"fake-model\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}, {\"id\": \"fake-alias\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}]}", + "body": "{\"object\": \"list\", \"data\": [{\"id\": \"fake-model\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"logit_bias\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}, {\"id\": \"fake-alias\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"logit_bias\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}]}", "interim": "" } ] diff --git a/zig/tests/server/golden/status/get-x-models.json b/zig/tests/server/golden/status/get-x-models.json index f37e9ca002c..665983b297d 100644 --- a/zig/tests/server/golden/status/get-x-models.json +++ b/zig/tests/server/golden/status/get-x-models.json @@ -10,10 +10,10 @@ ], [ "Content-Length", - "1862" + "1904" ] ], - "body": "{\"object\": \"list\", \"data\": [{\"id\": \"fake-model\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}, {\"id\": \"fake-alias\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}]}", + "body": "{\"object\": \"list\", \"data\": [{\"id\": \"fake-model\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"logit_bias\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}, {\"id\": \"fake-alias\", \"object\": \"model\", \"created\": , \"owned_by\": \"tensorfold\", \"capabilities\": {\"text_generation\": true, \"context_fitted\": false, \"call_gates\": true, \"loop_guard\": false, \"thinking_budget\": true, \"reasoning\": true, \"reasoning_optional\": false, \"answer_limit\": false, \"structures\": false, \"logprobs\": false, \"penalties\": false, \"logit_bias\": false, \"prompt_logprobs\": false, \"prompt_cache\": false, \"cache_salt\": false, \"warm_turns\": false, \"plain_only\": false, \"decides\": false, \"pictures\": false, \"greedy_only\": false, \"slide_conversations\": false, \"folded_memory\": false, \"pocket_usage\": false, \"vision\": false, \"speech\": false, \"embeddings\": false, \"readouts\": false, \"rerank\": false, \"thinking_switch\": true, \"thinking_applicable\": true}, \"context_length\": 1024, \"max_model_len\": 1024, \"reasoning\": {\"default_enabled\": true, \"supported_efforts\": [\"xhigh\", \"medium\", \"low\", \"none\"]}, \"input_types\": [\"text\"]}]}", "interim": "" } ] diff --git a/zig/tests/server/logit_bias_served.py b/zig/tests/server/logit_bias_served.py new file mode 100644 index 00000000000..cfb3cbeab21 --- /dev/null +++ b/zig/tests/server/logit_bias_served.py @@ -0,0 +1,108 @@ +"""Compare bias, draft and concurrent replies; record a baseline to keep one model process at a time.""" +import argparse +from concurrent.futures import ThreadPoolExecutor +import json +from pathlib import Path +from urllib.request import Request, urlopen +from wire import normal + + +def draw(url, model, prompt, bias=None, draft=False, sampled=False, drafted=None, details=None): + body = {"model": model, "prompt": prompt, "max_tokens": 64, "seed": 1234, + "temperature": 0.7 if sampled else 0, "top_k": 20, "top_p": 0.95, + "draft": draft, "return_token_ids": True} + if bias is not None: + body["logit_bias"] = bias + req = Request(url.rstrip("/") + "/v1/completions", json.dumps(body).encode(), + {"Content-Type": "application/json"}) + with urlopen(req, timeout=300) as response: + raw = response.read() + value = json.loads(raw) + if details is not None: + reply = normal({"status": f"HTTP/1.1 {response.status} {response.reason}", + "headers": list(response.headers.items()), "body": raw, "interim": b""}) + reply["headers"] = [list(h) for h in reply["headers"]] + details.append(reply) + runtime = value["tensorfold"] + if drafted is not None: # a plain-only engine's equality is no draft evidence + rounds = value.get("speculative", {}).get("drafted", 0) + assert runtime.get("drafts") is drafted and (rounds > 0) is drafted, ("drafts", drafted, rounds) + return runtime["token_ids"], runtime["token_sha"] + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("--base") + parser.add_argument("--baseline", type=Path) + parser.add_argument("--record-baseline", type=Path) + parser.add_argument("--revision", default="") + parser.add_argument("--candidate") + parser.add_argument("--model", required=True) + parser.add_argument("--require-drafts", action="store_true", help="Require actual drafted rounds on a loaded drafter") + args = parser.parse_args() + prompts = ["Continue: 1, 2, 3,", "Explain matrix multiplication in three sentences."] + key = lambda prompt, sampled, draft: json.dumps([prompt, sampled, draft]) + if args.record_baseline: + if not args.base: + parser.error("--record-baseline needs --base") + saved = {} + for sampled in [False, True]: + for prompt in prompts: + for draft in [False, True]: + draw(args.base, args.model, prompt, draft=draft, sampled=sampled) + details = [] + tokens = draw(args.base, args.model, prompt, draft=draft, sampled=sampled, details=details) + saved[key(prompt, sampled, draft)] = {"tokens": tokens, "wire": details} + args.record_baseline.write_text(json.dumps({"model": args.model, "revision": args.revision, "cases": saved}, indent=2) + "\n") + print("PASS baseline recorded; stop that model process before starting the candidate") + return + stored = json.loads(args.baseline.read_text()) if args.baseline else None + if not args.candidate or (stored is None and not args.base): + parser.error("give --candidate and either --baseline or --base") + if stored is not None: + assert stored["model"] == args.model + def base_draw(prompt, sampled, draft=False, details=None): + if stored is None: + return draw(args.base, args.model, prompt, draft=draft, sampled=sampled, details=details) + case = stored["cases"][key(prompt, sampled, draft)] + if details is not None: + details.extend(case["wire"]) + return tuple(case["tokens"]) + checks = 0 + for sampled in [False, True]: + for prompt in prompts: + base_draw(prompt, sampled) + draw(args.candidate, args.model, prompt, sampled=sampled) + before, after = [], [] + base = base_draw(prompt, sampled, details=before) + plain = draw(args.candidate, args.model, prompt, sampled=sampled, details=after) + assert before == after, ("default response bytes changed after nonce/timing normalization", sampled, prompt) + empty = [] + assert draw(args.candidate, args.model, prompt, {}, sampled=sampled, details=empty) == plain + assert after == empty, ("empty bias changed response bytes", sampled, prompt) + assert plain == base, ("default token IDs/hash changed", sampled, prompt) + assert draw(args.candidate, args.model, prompt, draft=True, sampled=sampled) == \ + base_draw(prompt, sampled, draft=True), ("default drafted tokens changed", sampled) + assert plain[0], "test requires at least one generated token" + # Ban the first ordinary pick, ensuring the test changes a draw in this checkpoint. + banned = plain[0][0] + bias = {str(banned): -100} + solo = draw(args.candidate, args.model, prompt, bias, sampled=sampled, drafted=False) + assert banned not in solo[0], ("banned token drawn", banned) + drafted = draw(args.candidate, args.model, prompt, bias, draft=True, sampled=sampled, drafted=True if args.require_drafts else None) + assert drafted == solo, ("drafted differs from serial", sampled, prompt) + with ThreadPoolExecutor(max_workers=2) as pool: + biased_future = pool.submit(draw, args.candidate, args.model, prompt, bias, False, sampled) + plain_future = pool.submit(draw, args.candidate, args.model, prompts[1], None, False, sampled) + together = biased_future.result() + other = plain_future.result() + assert together == solo, "concurrent biased request differs from solo" + assert other == draw(args.candidate, args.model, prompts[1], sampled=sampled), "bias leaked across streams" + assert draw(args.candidate, args.model, prompt, sampled=sampled) == plain, "bias changed cached prompt logits" + checks += 1 + print(f"PASS {checks} cases: default bytes/IDs/hash, bans, requested-draft equality, concurrency and cache reuse; " + f"actual drafted rounds required: {args.require_drafts}") + + +if __name__ == "__main__": + main()