Repository navigation
Conversation
This was referenced Nov 4, 2026
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.
Fixes #30.
rebalance_expertsworks with CPU float32 weights, but the greedy packingloop currently performs individual PyTorch tensor indexing and arithmetic for
each item. Convert the sorted indices and weights to Python lists once for
this path, and use an
array('f')for the pack sums so each accumulationrounds to float32 as before. Keep the existing implementation for other dtypes
and devices. The placement policy and tie-breaking are unchanged.
Validation
They compare the placement and rank outputs against the original
tensor-scalar algorithm across random, tied, very large, and non-contiguous
weights; exercise the hierarchical and global public policies; and check
other dtypes, empty batches, and a non-CPU default device.
32-GPU simulated topology; one CPU thread, A/B/B/A order, PyTorch 2.14.1:
on the B300 host CPU the base runs were 0.652/0.652 s and this change
0.0439/0.0435 s; on the GH200 CPU the base runs were 0.879/0.884 s and this
change 0.0341/0.0338 s. All three output tensors matched exactly in these
runs. These are host-side planning timings, not distributed or model
inference performance results.
git diff --checkand Python syntax compilation pass. No GPU execution ormulti-node communication was required for these tests.
PRs #27 and #28 change the packing policy to address a separate placement
constraint. This change retains the current policy, and may need coordination
if either of those PRs is accepted first.