Skip to content

deepseek_v41: reply logprobs normalize over all TP head columns (#1324) - #2125

Open
ashhart wants to merge 2 commits into
mainfrom
lead/t505
Open

ashhart wants to merge 2 commits into
mainfrom
lead/t505

Conversation

@ashhart

@ashhart ashhart commented Nov 4, 2026

Copy link
Copy Markdown
Owner

Refs #1324, blocker 2. Draft until it has run on two GB10s. Nothing here has run on a device.

What this changes

DeepSeek-V4.1 at TP>1 returned reply logprobs from one rank's share of the head. Scored requests now snapshot the raw FP32 head columns before sampling or grammar masks. All ranks enter one new plan-link operation, rank zero rebuilds vocabulary order without the unequal-shard padding, then computes float64 normalization and global top-k, with ties to the lower id.

  • The chosen token is scored even when it's outside the requested alternatives, including top_logprobs: 0.
  • NaN, positive infinity and an all-minus-infinity row refuse by name. A minus-infinity shard beside finite values works.
  • prompt_logprobs stays refused.
  • No new GPU kernel. Requests without logprobs keep the same launches, sampling and collectives, and allocate no logprob buffers.
  • Requests with logprobs pay a full head readback plus CPU float64 work.

Checks

  • test-dsv41-draft: 134 of 134 pass, five of them new, against a host float64 reference.
  • Linux device-host and server compiles pass; lean adds nothing.
  • The broad host gate was stopped part way: 184 passes, 2 skips, the rest not run. CI covers it here.
  • Not run: any TP=2 pair. We'll run replies against main, drafted against "draft": false, and logprobs against the reference before this lands.

@ashhart ashhart added kind:feature Classified by Synthena as feature addition synthena:needs-changes Reviewed by Synthena; changes requested labels Dec 3, 2026
@ashhart

ashhart commented Dec 3, 2026

Copy link
Copy Markdown
Owner Author

Synthena Initial Review — Needs changes (kind:feature)

Adds reply logprobs for DeepSeek-V4.1 at TP>1 by snapshotting raw FP32 head columns before sampling/grammar masks, gathering them across ranks, and computing float64 normalization and global top-k on rank zero. Includes new tests against a host float64 reference, but the PR explicitly states no TP=2 device run has occurred.

Findings:

  • [BLOCKER] zig/src/families/deepseek_v41/logprob_pipe.zig: All ranks allocate the receive scratch buffer of size 4worldstride even though only rank 0 downloads it; non-zero ranks never use recv, wasting device memory on every rank for a buffer only rank zero reads. Suggested fix: Only allocate recv on rank 0 (or size it to own.len on non-zero ranks) so follower ranks do not reserve world*stride floats.
  • [BLOCKER] zig/src/families/deepseek_v41/logprob_gpu.zig: capture() recomputes the rank's vocabulary partition on every call, and the pointer arithmetic assumes the shard layout matches partition.share exactly; if the head weight is bound with different padding than partition.share produces, rows read out of bounds silently. Suggested fix: Assert or verify the bound w.logits buffer length equals own.len*rows and cache the partition per Forward instead of recomputing per capture.
  • [WARNING] zig/src/families/deepseek_v41/logprob_pipe.zig: Non-zero ranks call comm.check() only implicitly through allGather; if rank 0's download or copy fails, followers may proceed before the collective error is observed, leaving captured state inconsistent across ranks. Suggested fix: Call comm.check() on all ranks after the allGather loop, not only inside the rank-0 branch.
  • [WARNING] zig/src/families/deepseek_v41/forward_follow.zig: The follower-side bounds check caps rows and row0 at 4096 but does not validate against the actual forward row count, so a leader plan with row0+n beyond the real buffer passes validation and reads out of bounds on the follower. Suggested fix: Validate msg[1]+msg[2] against the follower's actual last_rows/runner.rows bound (as capture() does) rather than a fixed 4096 constant.
  • [WARNING] zig/src/families/deepseek_v41/target.zig: When a scored request hits the resume_first fast path the code returns error.LogprobsNoHeadSnapshot, refusing the whole request instead of computing the row; a resumed slot could otherwise serve logprobs correctly. Suggested fix: Compute the logprob row from the cached head state on the resume path, or document that resumed slots refuse logprobs and ensure the scheduler retries without the resume fast path.
  • Synthena

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind:feature Classified by Synthena as feature addition synthena:needs-changes Reviewed by Synthena; changes requested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant