Update neurogolf_solver.py
Browse files- neurogolf_solver.py +61 -32
neurogolf_solver.py
CHANGED
|
@@ -681,6 +681,43 @@ def solve_task(tn, td, outdir, conv_budget=30.0):
|
|
| 681 |
|
| 682 |
return False, None, None, time.time() - t_start, path
|
| 683 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 684 |
def main():
|
| 685 |
parser = argparse.ArgumentParser()
|
| 686 |
parser.add_argument('--data_dir', default='ARC-AGI/data/training/')
|
|
@@ -689,7 +726,7 @@ def main():
|
|
| 689 |
parser.add_argument('--conv_budget', type=float, default=30.0)
|
| 690 |
parser.add_argument('--tasks', type=str, default='')
|
| 691 |
parser.add_argument('--device', type=str, default='auto', choices=['auto','cpu','cuda'])
|
| 692 |
-
parser.add_argument('--
|
| 693 |
args = parser.parse_args()
|
| 694 |
global ORT_PROVIDERS
|
| 695 |
config = {
|
|
@@ -712,38 +749,30 @@ def main():
|
|
| 712 |
print("=" * 70)
|
| 713 |
t0 = time.time()
|
| 714 |
results = {}
|
| 715 |
-
|
| 716 |
-
|
| 717 |
-
|
| 718 |
-
|
| 719 |
-
|
| 720 |
-
|
| 721 |
-
|
| 722 |
-
|
| 723 |
-
|
| 724 |
-
|
| 725 |
-
|
| 726 |
-
|
| 727 |
-
|
| 728 |
-
|
| 729 |
-
|
| 730 |
-
|
| 731 |
-
|
| 732 |
-
|
| 733 |
-
|
| 734 |
-
|
| 735 |
-
|
| 736 |
-
|
| 737 |
-
|
| 738 |
-
"onnx_bytes": sz if ok else 0,
|
| 739 |
-
"task_time_sec": t_task,
|
| 740 |
-
"macs": macs,
|
| 741 |
-
"memory": memory,
|
| 742 |
-
"params": params,
|
| 743 |
-
"score": score,
|
| 744 |
-
})
|
| 745 |
|
| 746 |
-
|
| 747 |
elapsed = time.time() - t0
|
| 748 |
print(f"\n{'='*70}")
|
| 749 |
print(f"Solved: {len(results)}/{len(task_nums)} in {elapsed:.0f}s")
|
|
|
|
| 681 |
|
| 682 |
return False, None, None, time.time() - t_start, path
|
| 683 |
|
| 684 |
+
def run_tasks(task_nums, tasks, output_dir, conv_budget, use_wandb):
|
| 685 |
+
results = {}
|
| 686 |
+
|
| 687 |
+
for tn in task_nums:
|
| 688 |
+
if tn not in tasks:
|
| 689 |
+
continue
|
| 690 |
+
|
| 691 |
+
td = tasks[tn]['data']
|
| 692 |
+
ok, sname, sz, t_task, model_path = solve_task(tn, td, output_dir, conv_budget)
|
| 693 |
+
|
| 694 |
+
if ok:
|
| 695 |
+
macs, memory, params = score_network(model_path)
|
| 696 |
+
if macs is None:
|
| 697 |
+
macs, memory, params = 0, 0, 0
|
| 698 |
+
score = macs + memory + params
|
| 699 |
+
|
| 700 |
+
results[tn] = (sname, t_task, sz)
|
| 701 |
+
print(f"Task {tn:3d}: {sname:20s} {score} {t_task:7.3f}s ({sz:>8,} bytes)")
|
| 702 |
+
else:
|
| 703 |
+
print(f"Task {tn:3d}: UNSOLVED {t_task:7.3f}s")
|
| 704 |
+
macs, memory, params, score = 0, 0, 0, 0
|
| 705 |
+
|
| 706 |
+
if use_wandb:
|
| 707 |
+
wandb.log({
|
| 708 |
+
"task_id": tn,
|
| 709 |
+
"solver": sname if ok else "unsolved",
|
| 710 |
+
"onnx_bytes": sz if ok else 0,
|
| 711 |
+
"task_time_sec": t_task,
|
| 712 |
+
"macs": macs,
|
| 713 |
+
"memory": memory,
|
| 714 |
+
"params": params,
|
| 715 |
+
"score": score,
|
| 716 |
+
})
|
| 717 |
+
|
| 718 |
+
return results
|
| 719 |
+
|
| 720 |
+
|
| 721 |
def main():
|
| 722 |
parser = argparse.ArgumentParser()
|
| 723 |
parser.add_argument('--data_dir', default='ARC-AGI/data/training/')
|
|
|
|
| 726 |
parser.add_argument('--conv_budget', type=float, default=30.0)
|
| 727 |
parser.add_argument('--tasks', type=str, default='')
|
| 728 |
parser.add_argument('--device', type=str, default='auto', choices=['auto','cpu','cuda'])
|
| 729 |
+
parser.add_argument('--use_wandb', action='store_true')
|
| 730 |
args = parser.parse_args()
|
| 731 |
global ORT_PROVIDERS
|
| 732 |
config = {
|
|
|
|
| 749 |
print("=" * 70)
|
| 750 |
t0 = time.time()
|
| 751 |
results = {}
|
| 752 |
+
|
| 753 |
+
if args.use_wandb:
|
| 754 |
+
with wandb.init(
|
| 755 |
+
project="neurogolf",
|
| 756 |
+
name="solver_run",
|
| 757 |
+
config=config,
|
| 758 |
+
):
|
| 759 |
+
results = run_tasks(
|
| 760 |
+
task_nums,
|
| 761 |
+
tasks,
|
| 762 |
+
args.output_dir,
|
| 763 |
+
args.conv_budget,
|
| 764 |
+
use_wandb=True
|
| 765 |
+
)
|
| 766 |
+
|
| 767 |
+
else:
|
| 768 |
+
results = run_tasks(
|
| 769 |
+
task_nums,
|
| 770 |
+
tasks,
|
| 771 |
+
args.output_dir,
|
| 772 |
+
args.conv_budget,
|
| 773 |
+
use_wandb=False
|
| 774 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 775 |
|
|
|
|
| 776 |
elapsed = time.time() - t0
|
| 777 |
print(f"\n{'='*70}")
|
| 778 |
print(f"Solved: {len(results)}/{len(task_nums)} in {elapsed:.0f}s")
|