Repository navigation
fix(paro): join mixed-shape calibration captures on the row axis (#5198) - #5234
Merged
Merged
Conversation
`_layer_input_features` concatenated per-batch captures on the batch axis and silently fell back to `tensors[0]` when the shapes differed, so every routed MoE expert (and any dense layer with one short calibration row) was optimized on the first batch only. Flatten each capture to rows and join them on the row axis instead; empty captures are skipped rather than forcing the fallback.
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.
What
ParoProcessor._layer_input_featuresjoined per-batch captures withtorch.cat(tensors, dim=0)and, on the resultingRuntimeError, silently kepttensors[0].Each capture is
[1, rows_b, hidden](or[bs, seq_b, hidden]), sodim=0only lines up when every batch has the same row count. Routed MoE experts always have different token counts per batch, and any dense layer with one calibration row shorter than the per-batch quota (#5175) hits it too. The module was then optimized on the first calibration batch only — no error, no warning.Change
Flatten every non-empty capture to
rows x hiddenand join on the row axis, then let the existingtarget_rowscap apply:[1, rows, hidden], so the downstream optimizer contract is unchanged.Tests
tests/test_paro_mixed_batch_rows_5198.py(new): mixed row counts keep every batch in calibration order, thetarget_rowscap still applies after joining, and empty captures are skipped.tests/test_paro_capture_order.py: updated to the row-axis contract (order and values unchanged).tests/test_paro*.pypass except pre-existing JIT/CUDA tests that need a local CUDA toolkit (this host has none).Follow-up (not in this PR)
The issue also notes that the fixed per-batch quota under-fills rare experts; a per-module reservoir is a separate change and is left for a follow-up.
Fixes #5198