[PR #3336] [Other] Exclude refused batch admissions from completion metrics #4575

Open
opened 2026-11-07 15:37:34 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/3336
Author: @oscarlius
Created: 10/20/2026
Status: 🔄 Open

Base: main ← Head: fix/batch-admission-accounting-20261018


📝 Commits (1)

  • 010593d fix(serve): exclude refused batch admissions from completion metrics

📊 Changes

2 files changed (+46 additions, -18 deletions)

View changed files

📝 serve/server.py (+27 -17)
📝 serve/test_parallel.py (+19 -1)

📄 Description

Problem and result

A request refused by every BGEN slot returns HTTP 503, but its history row is still (finish, prompt_tokens, prompt_read) = (length, 51, None), and successful completion/token/latency metrics include it. This fix records an error history row with zero processed prompt tokens and excludes this pre-admission rejection from successful completion and latency totals. The regression also checks Retry-After, Prometheus metrics, slot cleanup and a later successful request.

Continues #3042 after the v0.2.1.4 tracker reset. The original passed the new format check, but GitHub refused to reopen the rebased branch; the reset bot explicitly suggested a new linked pull request.

Closes #3040. This is an accounting follow-up to #1994; admission and retry policy stay the same.

Approach

Classify GpuBusy as a pre-admission refusal only when no DONE segment has settled and no output token was emitted. Preserve accounting for settled or partly generated work.

Validation

Passed:

  • py -3.12 -m ruff check --output-format json serve/server.py serve/test_parallel.py (Ruff 0.2.1): 21 existing diagnostics, same as unmodified main; zero new diagnostics.

  • Windows, Python 3.12.7: python -m unittest serve.test_parallel.ParallelService.test_bgen_refused_for_good_is_a_retryable_503_and_frees_the_slots -v — 1 passed on 010593d6274577bb6ff00200a9890fd84a4da4b9.

  • python -m unittest serve.test_parallel serve.test_prometheus -v — 48 tests, passed; final test result OK.

  • python -m py_compile serve/server.py serve/test_parallel.py and git diff --check 9de04cd44e927a9a3df6bbc0e94fc1be8b844ba4...HEAD passed.

Failed:

  • Expected red baseline: with exact upstream serve/server.py at 9de04cd44e927a9a3df6bbc0e94fc1be8b844ba4 (v0.2.1.4), the same focused test fails: ('length', 51, None) != ('error', 0, None). No candidate test failure observed.

Not run:

  • Real model generation, CUDA/HIP/SYCL/Metal builds or hardware execution. This patch touches only Python server code and its CPU fake-engine tests.

Limits

Fresh Python processes and loopback HTTP prove the server accounting behavior, not native engine admission or model quality. No runtime default is changed.


🔄 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/3336 **Author:** [@oscarlius](https://github.com/oscarlius) **Created:** 10/20/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/batch-admission-accounting-20261018` --- ### 📝 Commits (1) - [`010593d`](https://github.com/Niko1221/Strata/commit/010593d6274577bb6ff00200a9890fd84a4da4b9) fix(serve): exclude refused batch admissions from completion metrics ### 📊 Changes **2 files changed** (+46 additions, -18 deletions) <details> <summary>View changed files</summary> 📝 `serve/server.py` (+27 -17) 📝 `serve/test_parallel.py` (+19 -1) </details> ### 📄 Description ## Problem and result A request refused by every BGEN slot returns HTTP 503, but its history row is still (finish, prompt_tokens, prompt_read) = (length, 51, None), and successful completion/token/latency metrics include it. This fix records an error history row with zero processed prompt tokens and excludes this pre-admission rejection from successful completion and latency totals. The regression also checks Retry-After, Prometheus metrics, slot cleanup and a later successful request. ## Related discussion Continues #3042 after the v0.2.1.4 tracker reset. The original passed the new format check, but GitHub refused to reopen the rebased branch; [the reset bot](https://github.com/Niko1221/Strata/pull/3042#issuecomment-6282593730) explicitly suggested a new linked pull request. Closes #3040. This is an accounting follow-up to #1994; admission and retry policy stay the same. ## Approach Classify GpuBusy as a pre-admission refusal only when no DONE segment has settled and no output token was emitted. Preserve accounting for settled or partly generated work. ## Validation **Passed:** - `py -3.12 -m ruff check --output-format json serve/server.py serve/test_parallel.py` (Ruff 0.2.1): 21 existing diagnostics, same as unmodified main; zero new diagnostics. - Windows, Python 3.12.7: `python -m unittest serve.test_parallel.ParallelService.test_bgen_refused_for_good_is_a_retryable_503_and_frees_the_slots -v` — 1 passed on `010593d6274577bb6ff00200a9890fd84a4da4b9`. - `python -m unittest serve.test_parallel serve.test_prometheus -v` — 48 tests, passed; final test result `OK`. - `python -m py_compile serve/server.py serve/test_parallel.py` and `git diff --check 9de04cd44e927a9a3df6bbc0e94fc1be8b844ba4...HEAD` passed. **Failed:** - Expected red baseline: with exact upstream `serve/server.py` at `9de04cd44e927a9a3df6bbc0e94fc1be8b844ba4` (v0.2.1.4), the same focused test fails: `('length', 51, None) != ('error', 0, None)`. No candidate test failure observed. **Not run:** - Real model generation, CUDA/HIP/SYCL/Metal builds or hardware execution. This patch touches only Python server code and its CPU fake-engine tests. ## Limits Fresh Python processes and loopback HTTP prove the server accounting behavior, not native engine admission or model quality. No runtime default is changed. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#4575
No description provided.