Repository navigation
Drop sharding strategies whose cost estimation raises - #598
schmidt-jake wants to merge 1 commit into
Conversation
Estimating a strategy's cost runs the op on the sharded fake inputs, and a kernel can refuse a shape that only some placements produce (_grouped_mm needs 16-byte aligned strides). That was fatal for the whole solve. The strategy is now dropped, before the node's consumers read its strategy list, logged once per (op, error); a node left with no strategy raises. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Hi @schmidt-jake! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
Problem
Estimating a strategy's cost runs the op on its sharded fake inputs. A kernel can reject a shape that only some placements produce. For example,
_grouped_mmrequires 16-byte-aligned strides, and one candidate sharding of a small expert width left 12 bytes. The error propagated and killed the whole solve, though that strategy was simply unavailable and the others were fine.Change
ShardingOptimizernow filters each node's strategy list through_drop_invalid_strategiesbefore its consumers read it, so redistribute costs stay aligned with the strategy list.RuntimeErrororValueErroris dropped and logged once per (op, error).Trade-offs for review:
RuntimeError/ValueErrorbroadly could hide a genuine bug in an op's fake implementation. The warning makes such drops visible. A narrower contract, e.g. a dedicated exception type for "invalid placement", may be preferable, and I'm happy to change it.Test
tests/test_invalid_strategy_skip.pydefines an op whose fake implementation rejects one sharded shape. The solve picks the remaining strategy with the fix and fails without it. Lint passes with the repo's pinned black, isort and flake8. In this environment,tests/test_conservative_operator_strategies.pyshows the same 4 failures with and without this change. The full suite wasn't run.🤖 Generated with Claude Code