From 8f2c57a5d0fd9df86a3dd5ca6bf409f7369b86e3 Mon Sep 17 00:00:00 2001 From: Francisco Massa Date: Wed, 11 Mar 2026 07:50:14 +0000 Subject: [PATCH] Add ILP problem size and objective value diagnostics Logs unique variable count, decision variable count, constraint count after ILP construction, and the optimal objective value after solve. Useful for comparing ILP formulations across branches. --- autoparallel/optimize_sharding.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/autoparallel/optimize_sharding.py b/autoparallel/optimize_sharding.py index 215814c..71a79c0 100644 --- a/autoparallel/optimize_sharding.py +++ b/autoparallel/optimize_sharding.py @@ -164,6 +164,8 @@ def __init__( self.prob = pulp.LpProblem("AutoParallel", pulp.LpMinimize) self.add_default_constraints() t3 = time.perf_counter() + n_unique_vars = len(set(id(v) for v in self.pulp_variables.values())) + n_constraints = len(self.prob.constraints) logger.info( "ILP construction took %.3fs " "(decision_vars=%.3fs, validate=%.3fs, constraints=%.3fs)", @@ -172,6 +174,12 @@ def __init__( t2 - t1, t3 - t2, ) + logger.info( + "ILP problem size: %d unique vars, %d decision vars, %d constraints", + n_unique_vars, + len(self.decision_vars), + n_constraints, + ) def _get_next_name(self, prefix): idx = self._name_counters.setdefault(prefix, 0) @@ -681,7 +689,10 @@ def get_solution(self, verbose=False): t0 = time.perf_counter() self._set_objective() self._solve(verbose) - logger.info("ILP solve took %.3fs", time.perf_counter() - t0) + obj_value = pulp.value(self.prob.objective) + logger.info( + "ILP solve took %.3fs (objective=%.4f)", time.perf_counter() - t0, obj_value + ) return self._extract_and_validate_solution() # ---- Logging ----