Skip to content

fix(dflash): resolve target split prefill OOM from full-prompt logits - #118

Merged
davide221 merged 1 commit into
Luce-Org:mainfrom
weicj:bench-dflash-target-split-prefill-last-logits
May 7, 2026
Merged

davide221 merged 1 commit into
Luce-Org:mainfrom
weicj:bench-dflash-target-split-prefill-last-logits

Conversation

@weicj

@weicj weicj commented May 7, 2026

Copy link
Copy Markdown
Contributor

Summary

This fixes an unnecessary full-prompt logits allocation in the target layer-split prefill path.

Background

Normal prefill only needs the final token's next-token argmax. The previous target layer-split path still ran output norm + lm_head + argmax over the whole prompt activation, which materialized a [vocab, prompt_len] logits workspace.

For Qwen3.6-27B, that temporary workspace is about 7.9 GiB at an 8K prompt and about 15.8 GiB at a 16K prompt. As a result, split target runs could OOM even when the target weights and KV cache fit.

Changes

This PR only changes dflash/test/test_dflash.cpp.

  • Update compute_target_split_argmax() to accept a token_offset.
  • Build the final activation input with ggml_view_2d() from the requested token range instead of always viewing the full prompt.
  • In run_target_layer_split_forward(), compute logits and argmax only for the last token in normal prefill, replay, and autoregressive decode calls.
  • In run_target_layer_split_forward(), keep full-range argmax when argmax_out != nullptr, which preserves the DFlash verify path where each candidate token still needs its own argmax.
  • Keep target weights, target cache allocation, layer ownership, and target layer-split execution unchanged.

Rationale

The normal prefill path only consumes the last token's argmax as the seed for the next generation step. Computing logits for every prompt token does not change the result, but it creates a large temporary allocation for large-vocab models.

DFlash verification is different: it compares multiple candidate positions, so it still needs multi-token argmax. This change keeps that behavior intact while removing the unused full-prompt logits allocation from the ordinary prefill path.

Validation

State Target split prefill path Qwen3.6-27B Q8_0 / 2x RTX 2080 Ti result
Before Full-prompt logits / argmax over the whole prompt activation 8K prompt OOM
After Last-token-only logits / argmax for normal prefill; multi-token argmax preserved for DFlash verify 127K prompt passed

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

@davide221
davide221 merged commit 7c847d1 into Luce-Org:main May 7, 2026
1 check passed
smpurkis pushed a commit to smpurkis/lucebox-hub that referenced this pull request May 10, 2026
…prefill-last-logits

fix(dflash): resolve target split prefill OOM from full-prompt logits
oliveagle pushed a commit to oliveagle/lucebox-hub that referenced this pull request May 22, 2026
…prefill-last-logits

fix(dflash): resolve target split prefill OOM from full-prompt logits
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.

2 participants