Repository navigation
fix(server): let a package's declared sampling stand when the caller is silent (replaces #1236) - #1250
Merged
Conversation
…is silent `temperature` and `top_p` carried the OpenAI schema's documented 1.0 defaults, so serde could not tell a caller who chose 1.0 from a caller who said nothing. Both were then forwarded to the engine as explicit overrides, and a package that declares its own sampling regime — this model declares top_p 0.95 — had it silently replaced by the full distribution. An agent client sends neither field. OpenCode's requests carry no sampling controls at all, so every turn it drove was sampled from the whole tail rather than from the nucleus the package asked for, which is how a long agent turn degenerates. Both fields are now optional, and an absent one is passed to `resolve_sampling_defaults` as "no opinion" so the declared value wins, exactly as `top_k` already did. Validation likewise judges only what the caller actually sent. `temperature: 0` still means greedy, and an explicit value still beats the package. The same defect and the same fix apply to legacy `/v1/completions`, whose doc comment had recorded the mistaken premise outright: that the schema "has no unspecified state". Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0190e2eb-abe4-451f-b36d-44a035a99b7e
…rrides the package Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
justinchuby
added a commit
that referenced
this pull request
Aug 18, 2026
CI's format lane had fallen behind — `cargo fmt --all -- --check` was failing on `main` at `7d669c76`. The drift came from several changes landing in the same window: the session-state unification (#1255), the server stack (#1197/#1249/#1250/#1254), and the native CUDA vision kernels (#1251). **No logic changes.** This is `cargo fmt --all` and nothing else — 7 source files, plus two `.squad/decisions/inbox` notes that were already sitting uncommitted in the tree. Verified locally: `cargo fmt --all -- --check` exits clean on this branch. Co-authored-by: justinchuby <223556219+Copilot@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1250 +/- ##
=======================================
Coverage 79.93% 79.94%
=======================================
Files 360 360
Lines 158320 158333 +13
Branches 158320 158333 +13
=======================================
+ Hits 126554 126577 +23
+ Misses 27151 27142 -9
+ Partials 4615 4614 -1
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
🔴 Benchmark Regression DetectedComparison of criterion micro-benchmarks: PR head vs merge-base, measured on the same runner in the same job (base first → PR second).
Visual flags: Host infoWhat this cannot catch
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replacement for #1236, rebased onto current
mainafter #1197/#1224 landed as squashes (the stacked base diverged). Same fix, plus one added guard test, re-validated on top of the merged stack.The defect
temperatureandtop_pcarried the OpenAI schema's documented1.0defaults via#[serde(default = ...)], so the server could not tell a caller who chose 1.0 from a caller who said nothing. Both were then handed toresolve_sampling_defaultsas explicit overrides, so a model that declares its own sampling regime lost it on every request. An absent field is "no opinion", not the documented default.The fix
Both fields become
Option<f32>; an absent one is passed asNone, so the package's declared value wins — the same treatmenttop_kalready had. An explicit value (includingtemperature: 0, greedy) still wins. Validation (validate_sampling_range) now judges only what the caller actually sent. The same fix applies to legacy/v1/completions.Verification (mine, on this branch atop merged #1197 + #1224)
cargo clippy -p onnx-genai-server --all-targets -- -D warningsclean.chat_sampling_overridesto forwardSome(1.0)for an absent field madea_silent_request_keeps_the_declared_temperature_and_top_pseeSome(1.0)instead ofNone, andsilent_chat_request_honors_model_do_sampleoverride the declared0.6with1.0; restored, the declared value survives.an_explicit_default_valued_temperature_still_overrides_the_packageasserts a caller that explicitly sendstemperature: 1.0(equal to the old schema default) still overrides a package declaring0.6. This documents that absence (None→ package wins) and an explicitly-sent default (Some(1.0)→ caller wins) are now distinct — the exact distinction this PR exists to make.qwen05b-q4, native): a silent request answers normally; legacy/v1/completionsattemperature: 0is bit-identical across two runs, so the greedy path is untouched; an explicittemperature: 1.0is accepted and a negative one rejected.Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com