Skip to content

Fix prefill CP graph overflow with larger bucket search - #33906

Merged
Fridge003 merged 3 commits into
sgl-project:mainfrom
Fridge003:codex/fix-cp-bcg-eager-fallback
Aug 7, 2026
Merged

Fridge003 merged 3 commits into
sgl-project:mainfrom
Fridge003:codex/fix-cp-bcg-eager-fallback

Conversation

@Fridge003

@Fridge003 Fridge003 commented Aug 6, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

The 4-GPU GPT-OSS MXFP4 context-parallel test crashed during prefill BCG replay (failing job). A live multi-request zigzag layout can require more CP-local physical rows than the single-request layout captured for the same global token bucket (for example, 520 live rows versus 512 captured rows).

The first version of this fix fell back to eager immediately. That is safe, but unnecessarily gives up BCG when a slightly larger captured graph can hold the live CP layout.

Modifications

  • Compute the maximum aligned CP-local row requirement inside the CP BCG helper from the live zigzag layout.
  • Record the CP-local row capacity of every captured global token bucket.
  • Starting from the normal lower-bound token bucket, choose the smallest larger capture whose CP-local capacity fits the live layout.
  • Preserve the existing 2x token-padding limit; fall back to eager when no admissible capture fits.
  • Reuse the same bucket selector in graph admission and load_batch(), so replay pads to the graph shape that admission selected.
  • Keep graph admission and replay overrides behind CP-v2-active checks. DP bucket consensus is intentionally out of scope.

Example: a 2048-token batch requiring 520 CP-local rows skips the 2048 capture with capacity 512 and reuses the 2304 capture with capacity 576. Every CP rank chooses 2304 because the selector uses the maximum requirement across all CP ranks.

Accuracy Tests

No model math changes. Relevant CPU regression tests cover:

  • selecting 2304 when 2048 lacks CP-local capacity;
  • identical selection on all four CP ranks;
  • preserving eager fallback when no capture has enough capacity;
  • preserving the 2x padding limit;
  • confirming load_batch() actually pads replay to 2304;
  • existing non-CP 2x padding behavior.

Validation performed locally:

  • 6 registered CPU tests passed;
  • relevant modules passed py_compile;
  • pre-commit passed on all changed files;
  • git diff --check passed.

The original four-GPU test requires CUDA hardware and is delegated to GitHub Actions.

Speed Tests and Profiling

No benchmark run. The new search uses CPU list arithmetic during eligibility and scans the existing capture bucket list. Reusing a larger graph may execute additional padded rows, but candidates remain bounded by the existing 2x limit; otherwise execution falls back to eager.

Checklist

  • Format code with pre-commit
  • Add registered CPU regression coverage
  • Preserve eager fallback and the 2x padding limit
  • Keep DP graph-bucket synchronization out of scope
  • GPU CI rerun of the original 4-GPU test

CI States

Latest PR Test (Base): ❌ Run #31159377670
Latest PR Test (Extra): ❌ Run #31159378115

@Fridge003 Fridge003 changed the title Fix prefill CP graph overflow with eager fallback Fix prefill CP graph overflow with larger bucket search Aug 7, 2026
@Fridge003
Fridge003 marked this pull request as ready for review August 7, 2026 07:56
@Fridge003

Copy link
Copy Markdown
Collaborator Author

/rerun-test test/registered/cp/test_gpt_oss_4gpu_mxfp4_cp.py

2 similar comments
@Fridge003

Copy link
Copy Markdown
Collaborator Author

/rerun-test test/registered/cp/test_gpt_oss_4gpu_mxfp4_cp.py

@Fridge003

Copy link
Copy Markdown
Collaborator Author

/rerun-test test/registered/cp/test_gpt_oss_4gpu_mxfp4_cp.py

@Fridge003

Copy link
Copy Markdown
Collaborator Author

/rerun-test test/registered/cp/test_gqa_prefill_cp.py

@github-actions

github-actions Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Results for /rerun-test test/registered/cp/test_gpt_oss_4gpu_mxfp4_cp.py:

🚀 4-gpu-b200 (1 test): ✅ View workflow run

cd test/ && python3 registered/cp/test_gpt_oss_4gpu_mxfp4_cp.py

2 similar comments
@github-actions

github-actions Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Results for /rerun-test test/registered/cp/test_gpt_oss_4gpu_mxfp4_cp.py:

🚀 4-gpu-b200 (1 test): ✅ View workflow run

cd test/ && python3 registered/cp/test_gpt_oss_4gpu_mxfp4_cp.py

@github-actions

github-actions Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Results for /rerun-test test/registered/cp/test_gpt_oss_4gpu_mxfp4_cp.py:

🚀 4-gpu-b200 (1 test): ✅ View workflow run

cd test/ && python3 registered/cp/test_gpt_oss_4gpu_mxfp4_cp.py

@Fridge003

Copy link
Copy Markdown
Collaborator Author

/rerun-test test/registered/cp/test_cp_strategy_unit.py

@github-actions

github-actions Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Results for /rerun-test test/registered/cp/test_gqa_prefill_cp.py:

🚀 4-gpu-h100 (1 test): ❌ View workflow run

cd test/ && python3 registered/cp/test_gqa_prefill_cp.py

@github-actions

github-actions Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Results for /rerun-test test/registered/cp/test_cp_strategy_unit.py:

🚀 ubuntu-latest (1 test): ✅ View workflow run

cd test/ && python3 registered/cp/test_cp_strategy_unit.py

@Fridge003
Fridge003 merged commit 5e60363 into sgl-project:main Aug 7, 2026
102 of 118 checks passed
saturn-acc pushed a commit to saturn-acc/sglang that referenced this pull request Aug 16, 2026
Atituiset pushed a commit to Atituiset/sglang that referenced this pull request Sep 10, 2026
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.

1 participant