[GH-ISSUE #3937] [Engine] Opt-in API image input for DeepSeek-V4.1-Flash-1017 using the native vision engine #1686

Closed
opened 2026-11-04 01:53:10 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @Tsury on GitHub (Oct 24, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/3937

Area

[Engine]

What do you want to do?

Enable image questions through Strata's existing OpenAI/Anthropic APIs when DeepSeek-V4.1-Flash-1017 is explicitly configured with its matching vision encoder. Keep text-only DeepSeek and the Qwen path unchanged.

Would you want this upstream, and would the scope below fit your plans? I have not started implementation.

What do you do today instead?

Use a supported image-capable model for image requests. The DeepSeek guide says pictures are unavailable through this release's serving path.

Current source and proposed scope

Unconfirmed static analysis, inspected at main 8183c6b67162340c09b67360860177c577a65f2e; this is a feature proposal, not a hardware reproduction or a correctness claim.

  • The native src/dsv41 code already includes the ViT/aligner, image-embedding insertion, image routing/Engram masks, GENI/DSI1 input and image-aware prefix checks.
  • The DeepSeek template already emits <|deepseek_image|>. Service.prepare still uses Qwen image markers and its embedding-file path.
  • Port the narrow Maya MIT image adapter into that boundary: resize, placeholder expansion, pixel payload and capability/configuration wiring. Preserve Strata's template/tool semantics, correct image order after tool-result ordering, cancellation and image-keyed cache invalidation. Retain upstream copyright/license notices.
  • Use Strata's existing tools/dsv41/vision_pack.py with the official 1017 encoder shard/config and range-fetched marker rows. Do not substitute a Qwen projector or import another runtime. No new vision kernels or general serving layer are proposed.

Related: #3917 and #3927 concern selecting an incompatible Qwen projector during setup. This proposal covers the separate API connection after a matching DeepSeek encoder is prepared.

Proposed validation

  1. Before downloading language weights, compare resize grids, BF16 patches, encoder/aligner outputs and marker rows against DeepSeek's official MIT Torch reference. Use an encoder-only fixture; the ordinary pack loader still opens its listed model files.
  2. Exercise API payloads, multiple images, tool-result image order, literal placeholder text, changed/removed-image cache reuse and unchanged text requests with focused transport tests.
  3. Before claiming working image support, run real-checkpoint image questions and image follow-ups, measure memory/latency, and check text/tools on the tested backend. Encoder parity alone cannot prove image understanding. Report passed, failed and unrun checks separately; missing backend checks keep a PR in draft.

Is this focused opt-in adapter port welcome, or is there an existing effort we should coordinate with?

Originally created by @Tsury on GitHub (Oct 24, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/3937 ### Area [Engine] ### What do you want to do? Enable image questions through Strata's existing OpenAI/Anthropic APIs when DeepSeek-V4.1-Flash-1017 is explicitly configured with its matching vision encoder. Keep text-only DeepSeek and the Qwen path unchanged. Would you want this upstream, and would the scope below fit your plans? I have not started implementation. ### What do you do today instead? Use a supported image-capable model for image requests. [The DeepSeek guide](https://github.com/Niko1221/Strata/blob/8183c6b67162340c09b67360860177c577a65f2e/docs/DEEPSEEK41.md#through-the-api) says pictures are unavailable through this release's serving path. ### Current source and proposed scope **Unconfirmed static analysis**, inspected at main `8183c6b67162340c09b67360860177c577a65f2e`; this is a feature proposal, not a hardware reproduction or a correctness claim. - The native `src/dsv41` code already includes the ViT/aligner, image-embedding insertion, image routing/Engram masks, GENI/DSI1 input and image-aware prefix checks. - The DeepSeek template already emits `<|deepseek_image|>`. `Service.prepare` still uses Qwen image markers and its embedding-file path. - Port the narrow [Maya MIT image adapter](https://github.com/mw00/project-maya/blob/f26d8bab43f9b10f0475986b541dc46ada45285e/serve/ds4_vision.py) into that boundary: resize, placeholder expansion, pixel payload and capability/configuration wiring. Preserve Strata's template/tool semantics, correct image order after tool-result ordering, cancellation and image-keyed cache invalidation. Retain upstream copyright/license notices. - Use Strata's existing `tools/dsv41/vision_pack.py` with the official 1017 encoder shard/config and range-fetched marker rows. Do not substitute a Qwen projector or import another runtime. No new vision kernels or general serving layer are proposed. Related: #3917 and #3927 concern selecting an incompatible Qwen projector during setup. This proposal covers the separate API connection after a matching DeepSeek encoder is prepared. ### Proposed validation 1. Before downloading language weights, compare resize grids, BF16 patches, encoder/aligner outputs and marker rows against [DeepSeek's official MIT Torch reference](https://huggingface.co/deepseek-ai/DeepSeek-V4.1-Flash-1017/tree/1bae0e1088993b9b82de08f59de5be5a34e42170/inference). Use an encoder-only fixture; the ordinary pack loader still opens its listed model files. 2. Exercise API payloads, multiple images, tool-result image order, literal placeholder text, changed/removed-image cache reuse and unchanged text requests with focused transport tests. 3. Before claiming working image support, run real-checkpoint image questions and image follow-ups, measure memory/latency, and check text/tools on the tested backend. Encoder parity alone cannot prove image understanding. Report passed, failed and unrun checks separately; missing backend checks keep a PR in draft. Is this focused opt-in adapter port welcome, or is there an existing effort we should coordinate with?
Author
Owner

@hap911 commented on GitHub (Oct 27, 2026):

Implemented locally — native vision via the packed tower + a serve-side bridge.

I have a working implementation of this on 0.2.6 / control 0.1.51, running against the real checkpoint (IST-DAS IQ2_XXS pack of DeepSeek-V4.1-Flash-1017) on Windows/CUDA (RTX 3080 Ti + RTX 5090). Sharing the shape and measurements in case it helps the official one.

Approach

Pack: repacked with the official 1017 vision shard using vision_pack.py + pack_gguf --vision, tower verified bit-for-bit against the checkpoint. Pack grew 0.97 GB; the engine's load_vision places the tower on the first GPU before the layer split — no engine change needed.
Serve: new serve/ds4vision.py (~280 lines, derived from the Maya MIT adapter, attribution in the header) + two small marked hunks in server.py (construct for arch deepseek41; ds4 branch in prepare()). It sizes each image the way the tower wants (sides to multiples of 14, span nh*(nw+1)+2 <= 1024 image tokens, LANCZOS downscale above), replicates the fixture template's message walk (tool-result merge, tool_calls-order sort) so pixel payload order always matches the emitted placeholders — count divergence fails loudly — expands each <|deepseek_image|> (129264) placeholder to its full span, and writes the DSI1 file for the unchanged GENI plumbing. Locally the repack IS the opt-in; upstream would want a CLI/setup flag.
Validation (real checkpoint)

PASSED: single image (7.0 s); two images in one message, correct order (8.9 s); follow-up on the same image in 2.3 s (prefix + pixel-hash span cache, no re-encode); second image mid-conversation cross-compared correctly; swapped pixels under identical token ids -> the engine's FNV pixel hash invalidates the cached span; tool-result images in both send orders pair consistently; literal placeholder text renders as text, no corruption; text-only requests unchanged. Decode 28.8–30.0 tok/s with the tower vs 29.9 baseline — no measurable cost.

FAILED: none.

NOT RUN: encoder parity vs the DeepSeek Torch reference (the pack tool verified the tower bit-for-bit against the official checkpoint instead); AMD/Metal backends (CUDA-only box); upstream CLI/setup wiring.

Findings for the official implementation

serve 0.1.51 drops tool_call_id when building tool messages (server.py:5808, frontend.py:651), so the template's tool_calls-order reorder never fires in practice — arrival order rules on both sides today.
First image request after start pays the one-time tower load.
Limit: 1024 image tokens/picture (~1260x1260 px, downscaled above).
Happy to share the patch if useful.

<!-- gh-comment-id:6450141215 --> @hap911 commented on GitHub (Oct 27, 2026): Implemented locally — native vision via the packed tower + a serve-side bridge. I have a working implementation of this on 0.2.6 / control 0.1.51, running against the real checkpoint (IST-DAS IQ2_XXS pack of DeepSeek-V4.1-Flash-1017) on Windows/CUDA (RTX 3080 Ti + RTX 5090). Sharing the shape and measurements in case it helps the official one. Approach Pack: repacked with the official 1017 vision shard using vision_pack.py + pack_gguf --vision, tower verified bit-for-bit against the checkpoint. Pack grew 0.97 GB; the engine's load_vision places the tower on the first GPU before the layer split — no engine change needed. Serve: new serve/ds4vision.py (~280 lines, derived from the Maya MIT adapter, attribution in the header) + two small marked hunks in server.py (construct for arch deepseek41; ds4 branch in prepare()). It sizes each image the way the tower wants (sides to multiples of 14, span nh*(nw+1)+2 <= 1024 image tokens, LANCZOS downscale above), replicates the fixture template's message walk (tool-result merge, tool_calls-order sort) so pixel payload order always matches the emitted placeholders — count divergence fails loudly — expands each <|deepseek_image|> (129264) placeholder to its full span, and writes the DSI1 file for the unchanged GENI plumbing. Locally the repack IS the opt-in; upstream would want a CLI/setup flag. Validation (real checkpoint) PASSED: single image (7.0 s); two images in one message, correct order (8.9 s); follow-up on the same image in 2.3 s (prefix + pixel-hash span cache, no re-encode); second image mid-conversation cross-compared correctly; swapped pixels under identical token ids -> the engine's FNV pixel hash invalidates the cached span; tool-result images in both send orders pair consistently; literal placeholder text renders as text, no corruption; text-only requests unchanged. Decode 28.8–30.0 tok/s with the tower vs 29.9 baseline — no measurable cost. FAILED: none. NOT RUN: encoder parity vs the DeepSeek Torch reference (the pack tool verified the tower bit-for-bit against the official checkpoint instead); AMD/Metal backends (CUDA-only box); upstream CLI/setup wiring. Findings for the official implementation serve 0.1.51 drops tool_call_id when building tool messages (server.py:5808, frontend.py:651), so the template's tool_calls-order reorder never fires in practice — arrival order rules on both sides today. First image request after start pays the one-time tower load. Limit: 1024 image tokens/picture (~1260x1260 px, downscaled above). Happy to share the patch if useful.
Author
Owner

@Niko1221 commented on GitHub (Oct 29, 2026):

Thank you. Done in 0.2.7: DeepSeek-V4.1 reads pictures through the API by default. The engine's own vision tower (319 MiB of graphics memory) loads with the model, and the server decodes each picture, sizes it (both sides a multiple of 42, at most 1024 image tokens) and sends it on. --vision off turns it off, and a request with a picture then gets a 400 that says so. Details: https://github.com/Niko1221/Strata/blob/main/docs/DEEPSEEK41.md

Release: https://github.com/Niko1221/Strata/releases/tag/v0.2.7

<!-- gh-comment-id:6491927445 --> @Niko1221 commented on GitHub (Oct 29, 2026): Thank you. Done in 0.2.7: DeepSeek-V4.1 reads pictures through the API by default. The engine's own vision tower (319 MiB of graphics memory) loads with the model, and the server decodes each picture, sizes it (both sides a multiple of 42, at most 1024 image tokens) and sends it on. `--vision off` turns it off, and a request with a picture then gets a 400 that says so. Details: https://github.com/Niko1221/Strata/blob/main/docs/DEEPSEEK41.md Release: https://github.com/Niko1221/Strata/releases/tag/v0.2.7
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#1686
No description provided.