[PR #3879] [Engine] enable image prefix reuse with encoded row counts #4815

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

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/3879
Author: @nleve
Created: 10/23/2026
Status: 🔄 Open

Base: main ← Head: fix/image-prefix-cache


📝 Commits (1)

  • a8dcc33 [Engine] resolve shared image prefixes using encoded row counts

📊 Changes

3 files changed (+77 additions, -26 deletions)

View changed files

📝 docs/DETAILS.md (+4 -0)
📝 serve/server.py (+39 -26)
📝 serve/test_server.py (+34 -0)

📄 Description

Problem and result

Requests containing images ignored strata_prefix, preventing explicit prefix reuse. Resolve those prefixes using image row counts already encoded for the request, without another image encode.

#2874 (closed in tracker reset) covers the same behavior.

Approach

Share image-pad expansion between full prompts and prefix heads. Log and ignore boundaries inside an image’s token rows. Preserve existing image-identity checks.

Validation

Tested a8dcc33d against upstream 7ddc17a3.

Passed:

  • python -m unittest serve.test_server.SharedPrefix serve.test_server.ImageMarkers -q: 10 tests, using a mock tokenizer and vision encoder.
  • Live comparison on Linux/CUDA 13.4, two RTX 4090s, Qwen3.8-Flash-Next UD-Q4_K_XL, FP16 KV, using the same upstream engine binary for both servers. Six requests per server queried a generated image and a roughly 16k-token document containing verification fields. Three same-image follow-ups reused 17,419 tokens with the patch versus zero upstream. Changing the image invalidated reuse; returning to the original image restored it.

Failed: python -m unittest serve.test_server -q: 352/353 passed. GpuChoice.test_hip_ordinal also fails on unchanged upstream with the same device-order mismatch.

Not run: Windows and other GPU backends.

Limits

These are targeted prefix-cache and vision regression checks, not a general model-quality evaluation.


🔄 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/3879 **Author:** [@nleve](https://github.com/nleve) **Created:** 10/23/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/image-prefix-cache` --- ### 📝 Commits (1) - [`a8dcc33`](https://github.com/Niko1221/Strata/commit/a8dcc33d996623046807e253ebe40d61a3c58a73) [Engine] resolve shared image prefixes using encoded row counts ### 📊 Changes **3 files changed** (+77 additions, -26 deletions) <details> <summary>View changed files</summary> 📝 `docs/DETAILS.md` (+4 -0) 📝 `serve/server.py` (+39 -26) 📝 `serve/test_server.py` (+34 -0) </details> ### 📄 Description ## Problem and result Requests containing images ignored `strata_prefix`, preventing explicit prefix reuse. Resolve those prefixes using image row counts already encoded for the request, without another image encode. ## Related discussion #2874 (closed in tracker reset) covers the same behavior. ## Approach Share image-pad expansion between full prompts and prefix heads. Log and ignore boundaries inside an image’s token rows. Preserve existing image-identity checks. ## Validation Tested `a8dcc33d` against upstream `7ddc17a3`. Passed: - `python -m unittest serve.test_server.SharedPrefix serve.test_server.ImageMarkers -q`: 10 tests, using a mock tokenizer and vision encoder. - Live comparison on Linux/CUDA 13.4, two RTX 4090s, Qwen3.8-Flash-Next UD-Q4_K_XL, FP16 KV, using the same upstream engine binary for both servers. Six requests per server queried a generated image and a roughly 16k-token document containing verification fields. Three same-image follow-ups reused 17,419 tokens with the patch versus zero upstream. Changing the image invalidated reuse; returning to the original image restored it. Failed: `python -m unittest serve.test_server -q`: 352/353 passed. GpuChoice.test_hip_ordinal also fails on unchanged upstream with the same device-order mismatch. Not run: Windows and other GPU backends. ## Limits These are targeted prefix-cache and vision regression checks, not a general model-quality evaluation. --- <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#4815
No description provided.