fix(dflash): scale DeepSeek4 graph sizing for large chunks#490
Conversation
4f4af26 to
1196f23
Compare
There was a problem hiding this comment.
2 issues found across 4 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="server/src/deepseek4/deepseek4_graph.cpp">
<violation number="1" location="server/src/deepseek4/deepseek4_graph.cpp:2794">
P2: `full_graph_build_us` telemetry only measures `ggml_init`, not the full graph build. The timing starts right before `ggml_init(params)` and ends immediately after it, missing the actual graph construction work — creating all layer tensors (RMS norms, MLA attention, MoE FFNs, output head), calling `ggml_new_graph_custom`, and `ggml_build_forward_expand(gf, logits)`. The reported value will be a few microseconds per step (just context allocation), while graph construction is the real cost. Either extend the timing window to end after `ggml_build_forward_expand` (before `full_alloc_t0`), or rename the field to `full_graph_init_us` to match what it actually measures.</violation>
</file>
<file name="server/src/common/backend_factory.cpp">
<violation number="1" location="server/src/common/backend_factory.cpp:218">
P0: The new code unconditionally routes non-layer-split deepseek4 requests to DeepSeek4Backend (line +235), dropping the old fallback-to-LayerSplitAdapter path when remote_target_shard is enabled without layer splitting. DeepSeek4Backend has no remote_target_shard support (zero references in its codebase), so a request with --remote-target-bip-bin set but only one GPU will silently ignore the remote shard configuration. This breaks the remote-HIP-target flow that used to work through the adapter.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| cfg.chunk = args.chunk; | ||
|
|
||
| auto backend = std::make_unique<DeepSeek4Backend>(cfg); | ||
| if (args.device.is_layer_split()) { |
There was a problem hiding this comment.
P0: The new code unconditionally routes non-layer-split deepseek4 requests to DeepSeek4Backend (line +235), dropping the old fallback-to-LayerSplitAdapter path when remote_target_shard is enabled without layer splitting. DeepSeek4Backend has no remote_target_shard support (zero references in its codebase), so a request with --remote-target-bip-bin set but only one GPU will silently ignore the remote shard configuration. This breaks the remote-HIP-target flow that used to work through the adapter.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At server/src/common/backend_factory.cpp, line 218:
<comment>The new code unconditionally routes non-layer-split deepseek4 requests to DeepSeek4Backend (line +235), dropping the old fallback-to-LayerSplitAdapter path when remote_target_shard is enabled without layer splitting. DeepSeek4Backend has no remote_target_shard support (zero references in its codebase), so a request with --remote-target-bip-bin set but only one GPU will silently ignore the remote shard configuration. This breaks the remote-HIP-target flow that used to work through the adapter.</comment>
<file context>
@@ -215,44 +215,33 @@ std::unique_ptr<ModelBackend> create_backend(const BackendArgs & args) {
- cfg.chunk = args.chunk;
-
- auto backend = std::make_unique<DeepSeek4Backend>(cfg);
+ if (args.device.is_layer_split()) {
+ DeepSeek4LayerSplitAdapterConfig cfg;
+ cfg.target_path = args.model_path;
</file context>
| params.mem_size = cached_sg ? full_step_cache.meta_arena.size() : ctx_size; | ||
| params.mem_buffer = cached_sg ? full_step_cache.meta_arena.data() : nullptr; | ||
| params.no_alloc = true; | ||
| const auto full_build_t0 = Ds4TimingClock::now(); |
There was a problem hiding this comment.
P2: full_graph_build_us telemetry only measures ggml_init, not the full graph build. The timing starts right before ggml_init(params) and ends immediately after it, missing the actual graph construction work — creating all layer tensors (RMS norms, MLA attention, MoE FFNs, output head), calling ggml_new_graph_custom, and ggml_build_forward_expand(gf, logits). The reported value will be a few microseconds per step (just context allocation), while graph construction is the real cost. Either extend the timing window to end after ggml_build_forward_expand (before full_alloc_t0), or rename the field to full_graph_init_us to match what it actually measures.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At server/src/deepseek4/deepseek4_graph.cpp, line 2794:
<comment>`full_graph_build_us` telemetry only measures `ggml_init`, not the full graph build. The timing starts right before `ggml_init(params)` and ends immediately after it, missing the actual graph construction work — creating all layer tensors (RMS norms, MLA attention, MoE FFNs, output head), calling `ggml_new_graph_custom`, and `ggml_build_forward_expand(gf, logits)`. The reported value will be a few microseconds per step (just context allocation), while graph construction is the real cost. Either extend the timing window to end after `ggml_build_forward_expand` (before `full_alloc_t0`), or rename the field to `full_graph_init_us` to match what it actually measures.</comment>
<file context>
@@ -2678,23 +2766,71 @@ bool deepseek4_step(
+ params.mem_size = cached_sg ? full_step_cache.meta_arena.size() : ctx_size;
+ params.mem_buffer = cached_sg ? full_step_cache.meta_arena.data() : nullptr;
params.no_alloc = true;
+ const auto full_build_t0 = Ds4TimingClock::now();
ggml_context * ctx = ggml_init(params);
if (!ctx) return false;
</file context>
1196f23 to
7a34502
Compare
Summary
This PR follows on #489 , which continues the current DeepSeek4 mainline from #353 and the direct pure-UMA runtime route, and scales DeepSeek4 graph and metadata sizing for large prefill chunks so
--chunkbehaves as a real throughput knob instead of hitting small-graph limits from the older defaults.In the current runtime, larger chunk sizes could fail in three different ways:
This PR makes those capacities token-count aware. It does not change backend selection, placement policy, or execution semantics.
Changes
Validation
gfx1151environment withmax_ctx=1048576Native
1M ctxruntime checks:4096 / 128512222.2615.4026.7 s1024230.7415.4526.0 s2048241.0215.5025.3 s4096262.9315.5023.8 s8192 / 256512192.6914.7059.9 s1024200.3014.7058.3 s2048208.7314.7056.7 s4096224.3814.6054.0 s16384 / 512512150.6213.30147.2 s1024154.5613.27144.6 s2048162.7113.30139.2 s4096172.6013.30133.5 sThese checks show the prefill side scaling upward as chunk size increases, while decode remains effectively flat.