[DSv4 fix proposal — pending upstream support] deepseek4 - #2
Draft
leon7609 wants to merge 1 commit into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR #2: deepseek4: handle multi-slot SWA cache 4D views
Description
Follow-up to DeepSeek V4 Flash support work (nisparks PR ggml-org#22378) and companion to
fix/deepseek4-fa-reserve-kv-cast. With-np >= 2, the SWA (sliding window attention) cache produces a 4D view that the legacy reshape-to-3D codepath can't accept. Crash is a 4-vs-3 dimension mismatch the moment the second slot is exercised, after the FA reserve fix in the companion PR.Patch updates the SWA cache handling in
src/models/deepseek4.cppto retain the 4D view rather than collapse it to 3D whenn_seq_max > 1.Reproduction (before fix)
After applying the F32-cast fix from the companion PR but before this one:
Server now passes
graph_reserve, butnp=2decode trips a 4D-vs-3D dimension assertion the moment a second concurrent request is scheduled (i.e. only when both slots are active simultaneously and the SWA cache materializes a per-slot view).After fix
Same command, both slots can be active concurrently.
np=2parallel-load smoke test fires 2 simultaneous requests and both complete correctly. With Phase 5 stream-concurrency batching (separate work) layered on top, this drops the N=2 wall/baseline ratio from 1.948 to 1.283 and lifts aggregate decode throughput from 50.3 to 73.2 tok/s. This PR is the necessary stability prerequisite for that optimization to be possible.Hardware tested
cmake -DGGML_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES=120 -DGGML_CUDA_FA=ONWhy upstream
Independent of the broader batched-prefill chain in nisparks PR ggml-org#22378. Without this fix, multi-slot DSv4 simply cannot serve concurrent requests on the SWA path. Should apply cleanly to whichever branch eventually upstreams DSv4 support, alongside the F32-cast fix.
Related
fix/deepseek4-fa-reserve-kv-cast(separate F32 cast issue on the FA reserve path)