perf(scheduler): avoid repeated route scans - #10
Open
Glitchfix wants to merge 1 commit into
Open
Conversation
Glitchfix
force-pushed
the
perf/linear-time-scheduler
branch
from
August 7, 2026 13:30
1eaa8dc to
274f83a
Compare
Count each peer route once and prefix per-thread counts to preserve the existing deterministic schedule order. Signed-off-by: Shivanjan Chakravorty <schakravorty846@gmail.com>
Glitchfix
force-pushed
the
perf/linear-time-scheduler
branch
from
August 7, 2026 13:45
274f83a to
79b320a
Compare
Author
|
@StuartSul @HuiyingLi would appreciate a review |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR tightens the routed-token scheduler:
Four 256-thread blocks cover each peer's fixed 1,024 logical scheduler threads. The output order and 256-token expert padding remain unchanged.
The old scheduler assigned a block to each expert/peer pair and scanned that peer's routes twice. For
Eglobal experts,Ppeers, andRroutes per peer, this change reduces route reads fromP*R + 2*E*Rto2*P*R. The added scratch space isE*1024int32 counters.For the 384-expert, EP8, 7,168-token, top-8 case, route reads fall from 44,498,944 to 917,504, plus a 393,216-counter prefix scan.
Benchmarks
Environment: H200 (SM90),
torch==2.11.0+cu129. The scheduler was compiled separately for SM90 because the full MoK extension targets SM100/SM103.EP8, 7,168 local tokens, median of 9 runs with 200 calls each:
With 384 experts and 512 local tokens, EP8 through EP64 ranged from 0.97x to 1.03x. EP4 was slower at 32.1 us to 38.6 us (0.83x). Target-hardware performance still needs an SM100/SM103 run.
Tests