Repository navigation
Add HiGHS as an opt-in MILP backend for the sharding solve - #599
schmidt-jake wants to merge 1 commit into
Conversation
The placement MILP of a large graph can be out of CBC's reach in practical time. On one whole-training-step problem (1.83M binaries) with a 900 s limit, CBC found its first integer point after 938 s and proved nothing, while HiGHS found a feasible point at 68 s and proved the same objective optimal at 108 s. ShardingOptimizer and AutoParallel take milp_backend="cbc" (the default, unchanged) or "highs", which solves in process through PuLP's highspy interface; highspy is an optional extra. The deadline semantics stay as they are: an unproven incumbent at the time limit is still a TimeoutError. Two changes are needed for HiGHS and are harmless for CBC. HiGHS returns binaries within its integrality tolerance (0.9999999), so a variable is selected when its value is above 0.5 rather than equal to 1. And because a missed selection previously surfaced only later, as a KeyError in apply_sharding, the solution check now also refuses a node with decision variables but no selected strategy. HiGHS proves infeasibility without returning a point, so the violated-constraint walk runs for CBC only. Authored with Claude. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UwthrTQxLK9UDaYTG4tAie
|
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
The sharding MILP is always solved with PuLP's bundled CBC. For large graphs this can be out of reach in practical time. We hit this on one whole-training-step placement problem from a large MoE model: 1.83M binary variables and about 1M rows, with a 900 s limit.
highspy)PuLP 3.2.1, which AutoParallel already pins, ships an in-process HiGHS interface (
pulp.HiGHS, backed byhighspy), so supporting it is a small change.Change
ShardingOptimizer(..., milp_backend="cbc" | "highs")andAutoParallel(..., milp_backend=...). The default stays"cbc", so existing behaviour does not change."highs"raises a clear error whenhighspyis not importable.highspyis added as an optional extra (autoparallel[highs]) and torequirements-test.txt. The backend is saved and loaded with the optimizer, next tosolver_time_limit_seconds.(Optimal, IntegerFeasible)/(NotSolved, NoSolutionFound)pairs as CBC's, so an unproven incumbent is still aTimeoutError. The error message now names the backend.0.9999999), anddv.var.value() == 1dropped those selections. A variable is now selected when its value is> 0.5._extract_and_validate_solutioncaught a node selected twice, but not a node with decision variables and no selection. That case only surfaced later, as aKeyErrorinapply_sharding. It now raises with the node names.Tests
The new file
tests/test_milp_backend.pycovers:highspyis missing;ShardingOptimizer._solve, with one strategy per node;== 1);tests/test_solver_time_limit.pyonly gets the new attribute on its stub. Locally, on macOS with a CPU-only torch nightly (2.16.0.dev20261128), these two files pass (16 tests). The CUDA-dependent suites, includingtest_serialization.py, fail identically before and after this change on that machine because torch is not built with CUDA, so CI is the check for those.Lint: black 22.3.0, isort and flake8 pass on the changed files. mypy reports one existing error in
autoparallel/shardings/propagation_rules.py:60, which is unrelated and also present on main.Open questions for reviewers
mip_rel_gapis 1e-4, so its "optimal" means optimal within 0.01%. CBC through PuLP uses its own defaults. I left HiGHS at its default. Should the solve pin the gap to 0 for both backends?highspyis installed? I kept it opt-in so that nothing changes for existing users.This PR was authored with Claude (Claude Code).
🤖 Generated with Claude Code
https://claude.ai/code/session_01UwthrTQxLK9UDaYTG4tAie