Fix 3: solver_registry — score_network gate after validate, reject if (None,None,None)
Browse files
neurogolf_solver/solvers/solver_registry.py
CHANGED
|
@@ -15,6 +15,7 @@ from .mode import s_mode_fill
|
|
| 15 |
from .conv import solve_conv_fixed, solve_conv_variable, solve_conv_diffshape, solve_conv_var_diff
|
| 16 |
from ..data_loader import get_exs, fixed_shapes
|
| 17 |
from ..validators import validate
|
|
|
|
| 18 |
from ..constants import EXCLUDED_TASKS, MAX_ONNX_FILESIZE
|
| 19 |
|
| 20 |
# Analytical solvers registry — order matters (cheaper first)
|
|
@@ -53,6 +54,27 @@ def _check_size(path):
|
|
| 53 |
return False
|
| 54 |
|
| 55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
def solve_task(tn, td, outdir, providers, conv_budget=30.0, excluded_tasks=None):
|
| 57 |
"""Solve a single ARC-AGI task.
|
| 58 |
|
|
@@ -75,9 +97,7 @@ def solve_task(tn, td, outdir, providers, conv_budget=30.0, excluded_tasks=None)
|
|
| 75 |
if model is None:
|
| 76 |
continue
|
| 77 |
onnx.save(model, path)
|
| 78 |
-
if
|
| 79 |
-
continue # oversized, skip to next solver
|
| 80 |
-
if validate(path, td, providers):
|
| 81 |
return True, sname, os.path.getsize(path), time.time() - t_start, path
|
| 82 |
except:
|
| 83 |
pass
|
|
@@ -94,12 +114,12 @@ def solve_task(tn, td, outdir, providers, conv_budget=30.0, excluded_tasks=None)
|
|
| 94 |
if fixed_in:
|
| 95 |
result = solve_conv_fixed(td, path, providers, time_budget=conv_time / 2)
|
| 96 |
if result is not None:
|
| 97 |
-
if _check_size(path):
|
| 98 |
sname, model = result
|
| 99 |
return True, sname, os.path.getsize(path), time.time() - t_start, path
|
| 100 |
result = solve_conv_variable(td, path, providers, time_budget=conv_time)
|
| 101 |
if result is not None:
|
| 102 |
-
if _check_size(path):
|
| 103 |
sname, model = result
|
| 104 |
return True, sname, os.path.getsize(path), time.time() - t_start, path
|
| 105 |
else:
|
|
@@ -109,13 +129,13 @@ def solve_task(tn, td, outdir, providers, conv_budget=30.0, excluded_tasks=None)
|
|
| 109 |
if OH <= IH and OW <= IW:
|
| 110 |
result = solve_conv_diffshape(td, path, providers, time_budget=conv_time)
|
| 111 |
if result is not None:
|
| 112 |
-
if _check_size(path):
|
| 113 |
sname, model = result
|
| 114 |
return True, sname, os.path.getsize(path), time.time() - t_start, path
|
| 115 |
|
| 116 |
result = solve_conv_var_diff(td, path, providers, time_budget=conv_time)
|
| 117 |
if result is not None:
|
| 118 |
-
if _check_size(path):
|
| 119 |
sname, model = result
|
| 120 |
return True, sname, os.path.getsize(path), time.time() - t_start, path
|
| 121 |
|
|
|
|
| 15 |
from .conv import solve_conv_fixed, solve_conv_variable, solve_conv_diffshape, solve_conv_var_diff
|
| 16 |
from ..data_loader import get_exs, fixed_shapes
|
| 17 |
from ..validators import validate
|
| 18 |
+
from ..profiler import score_network
|
| 19 |
from ..constants import EXCLUDED_TASKS, MAX_ONNX_FILESIZE
|
| 20 |
|
| 21 |
# Analytical solvers registry — order matters (cheaper first)
|
|
|
|
| 54 |
return False
|
| 55 |
|
| 56 |
|
| 57 |
+
def _check_scoreable(path):
|
| 58 |
+
"""Return True if score_network returns valid scores (not None).
|
| 59 |
+
A model that can't be scored will be REJECTED by Kaggle."""
|
| 60 |
+
macs, memory, params = score_network(path)
|
| 61 |
+
if macs is None or memory is None or params is None:
|
| 62 |
+
return False
|
| 63 |
+
return True
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
def _accept_model(path, td, providers):
|
| 67 |
+
"""Full acceptance check: size + validate (outputs) + scoreable.
|
| 68 |
+
Returns True only if model would be accepted by Kaggle."""
|
| 69 |
+
if not _check_size(path):
|
| 70 |
+
return False
|
| 71 |
+
if not validate(path, td, providers):
|
| 72 |
+
return False
|
| 73 |
+
if not _check_scoreable(path):
|
| 74 |
+
return False
|
| 75 |
+
return True
|
| 76 |
+
|
| 77 |
+
|
| 78 |
def solve_task(tn, td, outdir, providers, conv_budget=30.0, excluded_tasks=None):
|
| 79 |
"""Solve a single ARC-AGI task.
|
| 80 |
|
|
|
|
| 97 |
if model is None:
|
| 98 |
continue
|
| 99 |
onnx.save(model, path)
|
| 100 |
+
if _accept_model(path, td, providers):
|
|
|
|
|
|
|
| 101 |
return True, sname, os.path.getsize(path), time.time() - t_start, path
|
| 102 |
except:
|
| 103 |
pass
|
|
|
|
| 114 |
if fixed_in:
|
| 115 |
result = solve_conv_fixed(td, path, providers, time_budget=conv_time / 2)
|
| 116 |
if result is not None:
|
| 117 |
+
if _check_size(path) and _check_scoreable(path):
|
| 118 |
sname, model = result
|
| 119 |
return True, sname, os.path.getsize(path), time.time() - t_start, path
|
| 120 |
result = solve_conv_variable(td, path, providers, time_budget=conv_time)
|
| 121 |
if result is not None:
|
| 122 |
+
if _check_size(path) and _check_scoreable(path):
|
| 123 |
sname, model = result
|
| 124 |
return True, sname, os.path.getsize(path), time.time() - t_start, path
|
| 125 |
else:
|
|
|
|
| 129 |
if OH <= IH and OW <= IW:
|
| 130 |
result = solve_conv_diffshape(td, path, providers, time_budget=conv_time)
|
| 131 |
if result is not None:
|
| 132 |
+
if _check_size(path) and _check_scoreable(path):
|
| 133 |
sname, model = result
|
| 134 |
return True, sname, os.path.getsize(path), time.time() - t_start, path
|
| 135 |
|
| 136 |
result = solve_conv_var_diff(td, path, providers, time_budget=conv_time)
|
| 137 |
if result is not None:
|
| 138 |
+
if _check_size(path) and _check_scoreable(path):
|
| 139 |
sname, model = result
|
| 140 |
return True, sname, os.path.getsize(path), time.time() - t_start, path
|
| 141 |
|