Skip to content

[GG] fix(dcp): build one-shard indexer query-split topology - #245

Merged
lukealonso merged 2 commits into
local-inference-lab:dev/gilded-gnosisfrom
voipmonitor:codex/pr244-regression-test-20260807
Aug 11, 2026
Merged

lukealonso merged 2 commits into
local-inference-lab:dev/gilded-gnosisfrom
voipmonitor:codex/pr244-regression-test-20260807

Conversation

@voipmonitor

@voipmonitor voipmonitor commented Aug 7, 2026

Copy link
Copy Markdown

Supersedes #244. This keeps Koush's functional commit unchanged and adds focused regression coverage. A replacement PR was necessary because GitHub denied direct maintainer writes to the fork head branch even though maintainer_can_modify is enabled.

Purpose

VLLM_DCP_INDEXER_SHARDS=1 fully replicates the sparse-indexer K cache on every DCP rank. The process-group initialization gate previously excluded this valid layout, so the dedicated singleton owner groups and DCP-wide query-split group were never created.

That had two consequences:

  • without query split, every rank redundantly scored every query row against the full replicated cache;
  • with VLLM_DCP_QUERY_SPLIT=1, lookup of the missing one-shard query-split group failed.

The existing _build_indexer_replica_group_ranks implementation already produces the correct topology for one shard. This PR lets that path run for 1 <= indexer_shards < DCP. It also extracts the gate into a pure helper so the boundary behavior is covered without initializing distributed backends.

There is no behavior change for disabled replication (0), existing partial layouts, or indexer_shards == DCP.

Test plan

python -m pytest -q tests/distributed/test_indexer_parallel_groups.py
ruff check vllm/distributed/parallel_state.py tests/distributed/test_indexer_parallel_groups.py
ruff format --check vllm/distributed/parallel_state.py tests/distributed/test_indexer_parallel_groups.py

The parametrized regression test covers shard counts 0, 1, 2, 4, 8 at DCP8. In particular, it fails if the one-shard boundary is changed back to 1 < indexer_shards.

The runtime path was also validated with a model-free TP4/DCP4 process-group test and an E2E GLM-5.2 prefill A-B-A comparison.

Test results

Unit and static checks

  • 22 passed
  • Ruff lint passed
  • Ruff format check passed
  • git diff --check passed

TP4/DCP4 topology

With VLLM_DCP_INDEXER_SHARDS=1 and VLLM_DCP_QUERY_SPLIT=1:

  • initialization completed;
  • indexer_query_split:0 was created;
  • the runtime reported one sparse-indexer KV shard across DCP4;
  • API correctness sanity completed without a worker failure.

E2E prefill A-B-A

Test profile: TP4/DCP4, MTP off, MAX_NUM_SEQS=1, graph cap 6, CKV gather enabled, owner merge disabled, unique uncached prompts, three samples per point. The available GLM-5.2 EXL3 3.25bpw checkpoint was used because the validation host did not contain the release NVFP4 checkpoint. Absolute throughput is therefore not an NVFP4 release claim.

Variant Prefill ~8K Prefill ~64K
r28 baseline, query split off 3,695 tok/s 3,433 tok/s
This PR, run A1 3,682 tok/s 3,488 tok/s
This PR, run A2 3,673 tok/s 3,497 tok/s
This PR, mean 3,678 tok/s 3,493 tok/s
Delta -0.5% +1.7%

The short-context difference is measurement noise. The 64K result was repeatably faster with the now-functional replicated query-split topology.

The root-port validation host required both variants to use the same Torch-NCCL fallback because its custom-AR/PyNCCL startup path has an unrelated environment-specific failure. This does not affect the process-group boundary fixed here and was held constant across the comparison.

Checklist

  • Purpose and affected configuration described
  • Focused regression test added
  • Unit and formatting checks passed
  • TP4/DCP4 topology and E2E behavior validated
  • No documentation change required

Summary by CodeRabbit

  • Bug Fixes
    • Corrected distributed indexer setup for partial shard layouts, including single-shard configurations.
    • Ensured replica groups are created only when the shard count is positive and smaller than the data parallel size.
    • Improved initialization behavior across supported shard counts.

VLLM_DCP_INDEXER_SHARDS=1 replicates the sparse-indexer K cache on every
DCP rank, but the indexer topology was only built for
1 < shards < DCP, so one-shard runs fell back to _QUERY_SPLIT, which is
singleton at TP == DCP. Every rank then scored every query row against
the full indexer cache during prefill: DCP-wide redundant compute (~8x
at DCP8, measurable as a long-context prefill throughput loss). With
VLLM_DCP_QUERY_SPLIT=1 it was worse than redundant, since
get_indexer_query_split_group(1) had no group to return and raised
"No indexer query-split group matches the requested KV shard count".

_build_indexer_replica_group_ranks already yields the correct layout for
shards=1 -- single-rank owner groups and one TP-wide query-split group --
so let it run. Each rank scores totalQ/TP rows against the full
replicated cache, and the existing indices-only all-gather restores the
shared top-k buffer. No merge is needed or attempted: dcp_world_size
stays 1 for a replicated cache, so every candidate-merge path still
early-returns.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J4BQPVrK6LdTUbXudyPkga
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@voipmonitor, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 53 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6999d724-3e50-4c80-9bc3-6773db4e77d5

📥 Commits

Reviewing files that changed from the base of the PR and between 3003860 and 9dbd6d0.

📒 Files selected for processing (2)
  • tests/distributed/test_indexer_parallel_groups.py
  • vllm/distributed/parallel_state.py
📝 Walkthrough

Walkthrough

The change centralizes detection of partial indexer replica-group layouts. It enables initialization when indexer_shards is 1 and adds parametrized tests for shard counts from 0 through 8.

Changes

Indexer replica-group initialization

Layer / File(s) Summary
Replica-group gate
vllm/distributed/parallel_state.py
Adds _needs_indexer_replica_groups, which returns true when indexer shards are positive and fewer than the DCP size.
Initialization wiring and coverage
vllm/distributed/parallel_state.py, tests/distributed/test_indexer_parallel_groups.py
Replaces the inline condition with the helper and tests initialization behavior for shard counts 0, 1, 2, 4, and 8 with DCP size 8.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: lukealonso, koush

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: fixing one-shard indexer query-split topology construction for DCP.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
vllm/distributed/parallel_state.py (1)

1545-1547: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add Google-style sections to the helper docstring.

The new helper has two arguments and a boolean return value. Add Args: and Returns: sections to document them.

As per coding guidelines, use Google-style docstrings with Args:/Returns:/Raises: sections instead of reStructuredText/Sphinx fields.

Proposed docstring update
 def _needs_indexer_replica_groups(indexer_shards: int, dcp_size: int) -> bool:
-    """Return whether the indexer needs replica-specific process groups."""
+    """Return whether the indexer needs replica-specific process groups.
+
+    Args:
+        indexer_shards: Number of indexer shards.
+        dcp_size: Decode-context parallel size.
+
+    Returns:
+        True when indexer_shards is positive and smaller than dcp_size.
+    """
     return 1 <= indexer_shards < dcp_size
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@vllm/distributed/parallel_state.py` around lines 1545 - 1547, Update the
_needs_indexer_replica_groups docstring with Google-style Args and Returns
sections, documenting indexer_shards, dcp_size, and the boolean condition
indicating whether replica-specific process groups are needed. Keep the helper
logic unchanged.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/distributed/test_indexer_parallel_groups.py`:
- Line 62: Wrap the signature of
test_indexer_replica_group_initialization_gate_for_dcp8 across multiple lines so
no line exceeds the 88-character limit; keep the function name, parameters, and
behavior unchanged.

---

Nitpick comments:
In `@vllm/distributed/parallel_state.py`:
- Around line 1545-1547: Update the _needs_indexer_replica_groups docstring with
Google-style Args and Returns sections, documenting indexer_shards, dcp_size,
and the boolean condition indicating whether replica-specific process groups are
needed. Keep the helper logic unchanged.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3a25989e-2f30-4a84-9313-e89b3a48d91d

📥 Commits

Reviewing files that changed from the base of the PR and between 3003860 and 6d6d71a436e85957227f1c5c2ac2bea8c4abfd7f.

📒 Files selected for processing (2)
  • tests/distributed/test_indexer_parallel_groups.py
  • vllm/distributed/parallel_state.py

("indexer_shards", "expected"),
[(0, False), (1, True), (2, True), (4, True), (8, False)],
)
def test_indexer_replica_group_initialization_gate_for_dcp8(indexer_shards, expected):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Wrap the test definition to meet the line-length limit.

Line 62 is 90 characters long. Split the function signature across lines.

As per coding guidelines, Python code must follow an 88-character line length limit.

Proposed line wrap
-def test_indexer_replica_group_initialization_gate_for_dcp8(indexer_shards, expected):
+def test_indexer_replica_group_initialization_gate_for_dcp8(
+    indexer_shards, expected
+):
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
def test_indexer_replica_group_initialization_gate_for_dcp8(indexer_shards, expected):
def test_indexer_replica_group_initialization_gate_for_dcp8(
indexer_shards, expected
):
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/distributed/test_indexer_parallel_groups.py` at line 62, Wrap the
signature of test_indexer_replica_group_initialization_gate_for_dcp8 across
multiple lines so no line exceeds the 88-character limit; keep the function
name, parameters, and behavior unchanged.

Source: Coding guidelines

@voipmonitor
voipmonitor force-pushed the codex/pr244-regression-test-20260807 branch from 6d6d71a to 9dbd6d0 Compare August 7, 2026 00:44
@lukealonso
lukealonso merged commit a891f74 into local-inference-lab:dev/gilded-gnosis Aug 11, 2026
2 of 3 checks passed
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.

3 participants