Skip to content

fix(test): remove dead num_worst_tokens test from internode file - #697

Open
Syan-Lin wants to merge 1 commit into
deepseek-ai:mainfrom
Syan-Lin:fix-670-num-worst-tokens-internode
Open

fix(test): remove dead num_worst_tokens test from internode file#697
Syan-Lin wants to merge 1 commit into
deepseek-ai:mainfrom
Syan-Lin:fix-670-num-worst-tokens-internode

Conversation

@Syan-Lin

@Syan-Lin Syan-Lin commented Jul 24, 2026

Copy link
Copy Markdown

Problem

test_internode.py included a copy-pasted num_worst_tokens != 0
test block from test_intranode.py. This block was dead code —
Buffer::dispatch asserts num_worst_tokens == 0 for multi-RDMA-rank
internode dispatch (legacy.py:378-379), so the test could never run.
When triggered, it crashed the test suite.

Fix

Remove the block entirely from test_internode.py. Coverage is
preserved in test_intranode.py where the feature is supported.

References

Comment thread tests/legacy/test_internode.py Outdated
if with_topk:
# Test `num_worst_tokens != 0` (intranode only; multi-RDMA-rank
# internode dispatch does not support this feature — see Buffer::dispatch)
if with_topk and buffer.runtime.get_num_rdma_ranks() <= 1:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🔵 suggestion: The internode test always runs multi-RDMA-rank (num_ranks > 8), where this block is now skipped entirely, so it is dead code in this file. The same block in test_intranode.py already covers the supported single-RDMA case. Consider either deleting the block from the internode test, or narrowing it to a documented single-RDMA-rank scenario, and exposing a public buffer.num_rdma_ranks/buffer.is_internode instead of the private buffer.runtime.

🤖 v4

@ds-review-bot

Copy link
Copy Markdown
Collaborator

🤖 ds-review-bot Code Review

v6

The guard matches Buffer.dispatch's existing restriction and prevents the unsupported internode test path. Static compilation and diff checks pass.

v4

Verification/cleanup complete for the num_worst_tokens test in test_internode.py. The internode (multi-RDMA-rank) dispatch hard-asserts num_worst_tokens == 0 (legacy.py:378-379) because the flag is intranode-only. The copy-pasted intranode-only test block was running unconditionally for with_topk, so it crashed CI in every multi-node/multi-RDMA internode run. The applied fix adds the guard with_topk and buffer.runtime.get_num_rdma_ranks() &lt;= 1. I verified the guard exactly mirrors the dispatch's own internode criterion (get_num_rdma_ranks() &gt; 1), the runtime call exists/exposes the same value the dispatch uses, and the intranode feature remains fully exercised by test_intranode.py. No residual/unsupported branch is left running into the assert; state is clean. Overall the change is correct and minimal.

v3

The change adds a buffer.runtime.get_num_rdma_ranks() &lt;= 1 guard to the num_worst_tokens != 0 test block in tests/legacy/test_internode.py, preventing the test from exercising an intranode-only feature under multi-RDMA-rank internode dispatch. This is correct and aligns precisely with the runtime assertion in deep_ep/buffers/legacy.py:379 (assert num_worst_tokens == 0, 'Internode dispatch does not support num_worst_tokens &gt; 0'), which is reached whenever get_num_rdma_ranks() &gt; 1 (see legacy.py:378), and with the documented behavior in deep_ep/buffers/legacy.py:354-355 and docs/legacy.md:172 ("this flag is for intranode only"). The new condition is correctly combined with the existing with_topk gate so the intranode / single-RDMA-rank path continues to run the full test block unchanged, while multi-RDMA-rank internode correctly skips the unsupported feature. An explanatory comment referencing Buffer::dispatch was added, documenting the rationale for future maintainers. The fix is minimal, scoped to a single test file, and has no impact on production code. No correctness, safety, or style concerns were found; the change is approved.

Files reviewed: 1
Issues found: 🔵 1 suggestion
Inline comments posted: 1

The num_worst_tokens feature is documented as intranode-only:
- legacy.py docstring: 'this flag is for intranode only'
- docs/legacy.md: 'this flag is for intranode only'
- Buffer::dispatch asserts num_worst_tokens == 0 when
  runtime.get_num_rdma_ranks() > 1

The test_internode.py file included a copy-pasted num_worst_tokens test
block from test_intranode.py. Since the internode test always runs
with multi-RDMA-rank (num_ranks > 8), this block was dead code that
crashed when triggered.

Remove the block entirely. Coverage remains in test_intranode.py where
the feature is supported.

Fixes: deepseek-ai#670
@Syan-Lin
Syan-Lin force-pushed the fix-670-num-worst-tokens-internode branch from 54566d3 to df07e62 Compare July 24, 2026 09:04
@Syan-Lin Syan-Lin changed the title fix(test): skip num_worst_tokens test for multi-RDMA-rank internode fix(test): remove dead num_worst_tokens test from internode file Jul 24, 2026
@Syan-Lin

Syan-Lin commented Aug 6, 2026

Copy link
Copy Markdown
Author

Hi @sphish @LyricZhao, gentle ping on this PR. It's a small test-only cleanup: the num_worst_tokens block in test_internode.py is dead code, since the feature is documented as intranode-only and Buffer::dispatch asserts it to be 0 for multi-RDMA-rank runs. Coverage stays in test_intranode.py, and this would also close #670. The branch is up to date with main. Happy to rebase or adjust anything if needed. Thanks for your time!

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.

[BUG] DeepEPv2 internode num_worst_tokens tests

2 participants