[PR #3676] [CLOSED] [Serve] a greedy request no longer inherits the model card's penalties (MTP stays on) #4744

Closed
opened 2026-11-07 15:38:45 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/3676
Author: @yang478
Created: 10/22/2026
Status: ❌ Closed

Base: main ← Head: pr/serve-greedy-keep-mtp


📝 Commits (1)

  • 2290346 serve: a greedy request no longer inherits the model card's penalties (MTP stays on)

📊 Changes

2 files changed (+105 additions, -4 deletions)

View changed files

📝 serve/server.py (+49 -4)
➕ serve/test_sampling_merge.py (+56 -0)

📄 Description

Area: [Serve]

Problem and result

A greedy request (temperature 0) inherited the model card's sampling defaults, penalties included. A presence / frequency / repetition penalty makes the engine score the last penalty_last_n logits and turns its speculation (MTP) off for that request — and at temperature 0 a penalty cannot change which token wins. So a card like Qwen3.6-35B-A3B's non-thinking one (presence_penalty 1.5) silently disabled MTP on every greedy request, for nothing.

With this PR the penalty defaults are not merged under greedy unless the request itself asks for a penalty. An explicit request penalty is kept (with a one-line note in the server window); the neutral case notes that MTP stays on. Sampling at temperature above 0 is unchanged.

none

Approach

  • serve/server.py: the hand-rolled defaults merge in generate_events becomes merge_sampling(defaults, request) -> (merged, note). The request's own fields still win over the defaults; a null still falls back to the default.
  • merge_sampling: under temperature <= 0 the three penalties stay at the engine's neutral values (0.0 / 0.0 / 1.0) unless the request names one of them. The rule matches what the MTP path needs: neutral penalties keep speculation on.
  • serve/test_sampling_merge.py: 5 offline tests (no engine, no GPU): greedy neutralizes the card's penalties, an explicit penalty is kept with the note, temperature > 0 is untouched, a config-level greedy default is covered too.

The diff is 2 files, +105/-4. Merges cleanly with main 011c9e6.

Validation

Environment: Windows 11 (10.0.26200), Python 3.12.14, serve/ only, no GPU needed. Branch head 2290346 on main 011c9e6.

  • Passed: python -m pytest serve/test_sampling_merge.py -q → 5 passed.
  • Passed: python -m pytest serve/test_sampling_merge.py serve/test_tool_call_envelope.py serve/test_answer_speed.py serve/test_ready_timeout.py -q → 22 passed, 2 skipped, 36 subtests passed (the existing serve tests on the same tree, no regression).
  • Not run: an end-to-end MTP counter on a live engine. The engine turning MTP off when penalties are present is existing behavior this PR relies on; the offline tests pin the merge rule that guards it.

Limits

Behavior change: under greedy, a config-level or model-card penalty no longer reaches the engine unless the request asks for it. That is the point of the change, but it is a change. Everything outside greedy sampling is byte-identical.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/3676 **Author:** [@yang478](https://github.com/yang478) **Created:** 10/22/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `pr/serve-greedy-keep-mtp` --- ### 📝 Commits (1) - [`2290346`](https://github.com/Niko1221/Strata/commit/229034673809288888c83ad21f76b8fc2248b04d) serve: a greedy request no longer inherits the model card's penalties (MTP stays on) ### 📊 Changes **2 files changed** (+105 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `serve/server.py` (+49 -4) ➕ `serve/test_sampling_merge.py` (+56 -0) </details> ### 📄 Description **Area:** [Serve] ## Problem and result A greedy request (temperature 0) inherited the model card's sampling defaults, penalties included. A presence / frequency / repetition penalty makes the engine score the last `penalty_last_n` logits and turns its speculation (MTP) off for that request — and at temperature 0 a penalty cannot change which token wins. So a card like Qwen3.6-35B-A3B's non-thinking one (`presence_penalty` 1.5) silently disabled MTP on every greedy request, for nothing. With this PR the penalty defaults are not merged under greedy unless the request itself asks for a penalty. An explicit request penalty is kept (with a one-line note in the server window); the neutral case notes that MTP stays on. Sampling at temperature above 0 is unchanged. ## Related discussion none ## Approach - `serve/server.py`: the hand-rolled defaults merge in `generate_events` becomes `merge_sampling(defaults, request) -> (merged, note)`. The request's own fields still win over the defaults; a null still falls back to the default. - `merge_sampling`: under `temperature <= 0` the three penalties stay at the engine's neutral values (`0.0 / 0.0 / 1.0`) unless the request names one of them. The rule matches what the MTP path needs: neutral penalties keep speculation on. - `serve/test_sampling_merge.py`: 5 offline tests (no engine, no GPU): greedy neutralizes the card's penalties, an explicit penalty is kept with the note, temperature > 0 is untouched, a config-level greedy default is covered too. The diff is 2 files, +105/-4. Merges cleanly with main `011c9e6`. ## Validation Environment: Windows 11 (10.0.26200), Python 3.12.14, serve/ only, no GPU needed. Branch head `2290346` on main `011c9e6`. - **Passed:** `python -m pytest serve/test_sampling_merge.py -q` → 5 passed. - **Passed:** `python -m pytest serve/test_sampling_merge.py serve/test_tool_call_envelope.py serve/test_answer_speed.py serve/test_ready_timeout.py -q` → 22 passed, 2 skipped, 36 subtests passed (the existing serve tests on the same tree, no regression). - **Not run:** an end-to-end MTP counter on a live engine. The engine turning MTP off when penalties are present is existing behavior this PR relies on; the offline tests pin the merge rule that guards it. ## Limits Behavior change: under greedy, a config-level or model-card penalty no longer reaches the engine unless the request asks for it. That is the point of the change, but it is a change. Everything outside greedy sampling is byte-identical. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 15:38:45 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#4744
No description provided.