mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2663] [Issue]: top_p = 0 is mishandled — schema rejects the save and normalizers rewrite 0 to 1 (inverts the sampler) #1316
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#1316
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @kolacheee on GitHub (Jun 20, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2663
Originally assigned to: @SpicyMarinara on GitHub.
Summary
top_p = 0is handled inconsistently across the stack: the shared schema's exclusive lower bound rejects it (failing the entire preset save), while two normalizers silently rewrite a stored0to1— the opposite sampler behavior.Expected behavior
top_pshould be treated consistently with sibling samplers (temperature,topK,minPall allow0). A0value should either be accepted and preserved, or rejected — but not both rejected on save in one place and rewritten to1in another.Actual behavior
topP: z.number().gt(0).max(1).default(1); the exclusive.gt(0)makes0invalid, while the client editor's slider allows0and includes it in the PATCH body. The server route parses with no try/catch, sotopP: 0throws aZodErrorand the entire preset update is rejected.normalizeChatTopP(and OpenAI'snormalizeTopP) return1whenever the value is<= 0, so a stored0that reaches the request becomes1(no nucleus filtering — the opposite of the near-greedy behavior0implies).How it breaks the pipeline
Code trace (staging @
b826f8f4):packages/shared/src/schemas/prompt.schema.ts—topPuses.gt(0)(siblings use.min(0)).topP: 0fails validation and the whole update is rejected.packages/server/src/services/generation/generation-parameters.ts:31–35(normalizeChatTopPreturns1whenvalue <= 0);packages/server/src/services/llm/providers/openai.provider.ts:187–191(normalizeTopPreturns1whentopP <= 0, used at:868/:1102/:1536). A presettopP: 0that bypasses the schema (e.g. via import) is sent as1.Steps to reproduce
A — save rejected:
top_pto0and save.gt(0)) and the whole preset update is rejected.B — silent inversion:
topP: 0into a preset/params via a path that bypasses the schema (e.g. import).top_p: 1instead of0.Suggested fix
topP: z.number().min(0).max(1).default(1)to match the inclusive lower bound used bytemperature/minP/topK.top_p = 0handling consistent everywhere: either preserve0(and let provider-layer normalization decide the API-valid value), or treat it as "unset" by returningundefinedso it falls through to the prior value — but do not silently rewrite0→1. AlignnormalizeChatTopPand the preset assembler path on the same rule.Environment
b826f8f4)Additional context
Identified via systematic source review on staging (refs @
b826f8f4).top_p = 0is a degenerate/niche value, but the inconsistency (rejected on save vs. silently inverted at send) is a real correctness gap. Related to the parameter-salvage issue filed concurrently.Template check
Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:
@SpicyMarinara commented on GitHub (Jun 20, 2026):
Implemented on branch codex/spicymarinara-assigned-issues: top_p=0 is accepted by schema and preserved by normalizers instead of being rewritten to 1. Final validation will run after the full assigned sweep per maintainer request.