Skip to content

[Restore] Reconcile audited #292 history with latest main - #352

Merged
yangzhuxinyzx merged 8 commits into
mainfrom
codex/v100-restore-pr292-20260827-145100
Aug 28, 2026
Merged

yangzhuxinyzx merged 8 commits into
mainfrom
codex/v100-restore-pr292-20260827-145100

Conversation

@yangzhuxinyzx

@yangzhuxinyzx yangzhuxinyzx commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Purpose

Preserve the recoverable history and authorship of archived #292 while reconciling it with the audited latest main.

Final audit

  • The in-flight KV eviction accounting from the restored history is already present on current main, with settled-token freeing and admission sizing retained.
  • The explicit DeepSeek-OCR resolution modes, crop bounds, and shared image-token arithmetic are already present on current main.
  • Architecture/model-identity sampling defaults, mandatory serving recipes, identity-keyed repetition defaults, and stale copies of independently repaired files are not restored.
  • The full original restored head 3a8f3a51c1eba9eaa9b8df174330e3f181500496 remains in ancestry, preserving authorship and review provenance.

Test Result

  • In-flight KV/SWA and DeepSeek-OCR resolution-mode focused contracts: 37 passed.
  • Repair and final-branch full remote pre-commit: repair passed; final branch running on the locked head below.
  • Final head: 327e4a37fa55830f58c5e18d86e6c6a3af068e9b.
  • Final tree: a6d9af1056de0db77294f2209f86c39e24eb5def.
  • Current main tree: a6d9af1056de0db77294f2209f86c39e24eb5def.

Decision

This is an intentional zero-source-difference merge: useful generic fixes stay in main, rejected identity defaults stay out, and GitHub records the restored contribution as merged rather than closed.

Repair chain: #383.

kkobold added 5 commits August 25, 2026 09:03
…nder async scheduling

With async scheduling / PP, `num_computed_tokens` optimistically includes
tokens of steps whose output is not yet processed; their attention windows
still read the blocks just below the optimistic boundary, and rejected
speculative tokens can roll it back. Freeing recycling-aware KV (sliding
window, chunked-local, prefix-anchored SWA gap eviction) on that optimistic
basis can release blocks an in-flight step still reads.

Track `Request.num_in_flight_tokens` in the scheduler and free on
`num_computed_tokens - num_in_flight_tokens` in `allocate_slots` and in the
pre-connector prune. Thread the renamed `max_in_flight_tokens` bound
(`max_concurrent_batches * max_num_batched_tokens`) through the KV cache
manager/coordinator and the per-request admission caps so startup pool
sizing reserves for overlapping batches.

Tests: in-flight accounting, sliding-window/chunked-local/prefix-anchored
frees deferred until the in-flight step settles (and unchanged under sync
scheduling), admission caps under overlapping batches, and the
connector-finish prune on the settled basis.

Signed-off-by: kkobold <sabbaghdanilo@gmai.com>
Some models are only correct when served with a specific decoding recipe;
DeepSeek-OCR's documentation makes its anti-repetition logits processor
mandatory for long documents and requires `skip_special_tokens=False` with
greedy decoding. Serving without the recipe produces documented looping
with no visible error.

Add a serving-layer registry keyed by model architecture (extensible by
out-of-tree plugins at import time): registered sampling defaults flow
through the existing `default_sampling_params` channel (with
`skip_special_tokens` now tri-state on the chat request so a model default
can apply), recipe `extra_args` (the processor parameters) are filled in
for requests that omit them, and client-supplied `vllm_xargs` overrides are
validated against registered bounds — out-of-range values return HTTP 400
instead of reaching the engine. Startup fails loudly when a
recipe-required logits processor is not loaded. DeepSeek-OCR's recipe is
registered in-tree.

Signed-off-by: kkobold <sabbaghdanilo@gmai.com>
…CR prompt

The DeepSeek-OCR checkpoint reports model_type "deepseek_vl_v2", so the
chat endpoint resolved the DeepSeek-VL2 fallback template, which inserts
chat role markers and silently changes the OCR prompt relative to the
documented recipe — a quality failure with no error.

Add an architecture-keyed fallback map that takes precedence over the
model_type map (public registration for plugins included) and key
DeepseekOCRForCausalLM to the raw-concatenation OCR template; genuine
DeepSeek-VL2 chat checkpoints keep their template. Golden tests pin the
resolution and the byte-exact rendered prompts for both documented OCR
modes, with a negative control proving the goldens discriminate.

Signed-off-by: kkobold <sabbaghdanilo@gmai.com>
Degeneration patterns longer than the n-gram processor's ban window (e.g.
slow-drift empty-table rows) can still bloat output by thousands of junk
tokens. Registered models may now declare repetition_detection defaults,
applied when the request leaves the field unset; a request-supplied value
always wins. DeepSeek-OCR registers a conservative profile grounded in the
observed failure shape (min_count=8 spares legitimate dense tables).

Signed-off-by: kkobold <sabbaghdanilo@gmai.com>
…ving profile

Plumb the official resolution modes (tiny/small/base/large/gundam) through
DeepseekOCRProcessor as a per-request image_mode selector, with crop bound
plumbing (min_crops/max_crops) and an opt-in multi-image crop safeguard.
Token counting moves to a single shared arithmetic
(count_image_tokens_for) used by both the processor pixel path and the
model's placeholder counter, making the producer/counter contract hold by
construction for every mode, crop cap, and image count.

The serving defaults registry gains per-image-count profiles
(sampling_defaults_multi_image / extra_args_defaults_multi_image); the
chat completion path counts request image items and selects the profile
before merging request overrides.

Signed-off-by: kkobold <sabbaghdanilo@gmai.com>
Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
…-20260828-1334

[Restore] Reconcile #352 with audited latest main
@yangzhuxinyzx yangzhuxinyzx changed the title [Restore][Draft] Re-audit OCR serving defaults from #292 [Restore] Reconcile audited #292 history with latest main Aug 28, 2026
@yangzhuxinyzx

Copy link
Copy Markdown
Contributor Author

Repair #383 has been merged. The final branch preserves the complete restored #292 ancestry but has exactly the current main source tree; useful KV/OCR fixes remain, model-identity defaults remain excluded. Final full pre-commit is running on 327e4a3.

@yangzhuxinyzx
yangzhuxinyzx marked this pull request as ready for review August 28, 2026 05:52
@yangzhuxinyzx
yangzhuxinyzx merged commit edcd072 into main Aug 28, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant