Update NEXT_AGENT.md with V5 results and corrected strategy
Browse files- own-solver/NEXT_AGENT.md +64 -80
own-solver/NEXT_AGENT.md
CHANGED
|
@@ -1,118 +1,102 @@
|
|
| 1 |
# Instructions for Next Agent
|
| 2 |
|
| 3 |
> Read this FIRST. Then read LEARNING.md for mistakes to avoid.
|
| 4 |
-
> **PRIMARY GOAL: Get LB > 6043. Current:
|
| 5 |
|
| 6 |
## ⚠️ READ neurogolf_utils.py FIRST
|
| 7 |
|
| 8 |
The file `own-solver/neurogolf_utils.py` is the OFFICIAL Kaggle scoring kernel (May 14, 2026 version).
|
| 9 |
-
**Every previous agent ignored it and wasted time optimizing wrong metrics.**
|
| 10 |
|
| 11 |
-
The scoring formula is
|
| 12 |
```python
|
| 13 |
points = max(1.0, 25.0 - math.log(max(1.0, memory + params)))
|
| 14 |
```
|
| 15 |
|
| 16 |
Where:
|
| 17 |
-
- `memory` =
|
| 18 |
-
- `params` =
|
| 19 |
-
- **NO MACs
|
| 20 |
|
| 21 |
-
## Current State (
|
| 22 |
|
| 23 |
-
|
| 24 |
-
-
|
| 25 |
-
-
|
| 26 |
|
| 27 |
-
|
| 28 |
|
| 29 |
-
|
| 30 |
-
Need +483 pts across 400 tasks = avg +1.2 pts/task.
|
| 31 |
-
Each +1 pt = dividing cost by e (2.718).
|
| 32 |
-
Current avg cost ≈ 80,000. Need avg cost ≈ 30,000.
|
| 33 |
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
Reduce to 2 intermediates: cost ≈ 72,000 → score ≈ 13.8. Gain: +1.0.
|
| 38 |
|
| 39 |
-
##
|
|
|
|
|
|
|
| 40 |
|
| 41 |
-
###
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
-
|
|
|
|
|
|
|
| 44 |
|
| 45 |
-
|
| 46 |
-
Current `add_onehot_block()` in `onnx_helpers.py` creates:
|
| 47 |
-
```
|
| 48 |
-
Equal(argmax, classes) → eq (1,10,30,30) bool = 9,000 bytes
|
| 49 |
-
Cast(eq, FLOAT) → oh_out (1,10,30,30) float32 = 36,000 bytes
|
| 50 |
-
```
|
| 51 |
-
That's 2 intermediate tensors = 45,000 bytes.
|
| 52 |
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
OneHot(argmax, depth=10, values=[0,1]) → oh_out
|
| 56 |
-
```
|
| 57 |
-
Saves 1 intermediate = 9,000-36,000 bytes per task.
|
| 58 |
-
OneHot is NOT banned (not in _EXCLUDED_OP_TYPES).
|
| 59 |
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
|
|
|
|
|
|
| 63 |
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
|
| 69 |
-
##
|
| 70 |
-
|
| 71 |
-
Store weights as fp16 (halves their memory contribution).
|
| 72 |
-
Do NOT add Cast(input→fp16) — it creates a new 18KB intermediate.
|
| 73 |
-
ORT handles mixed-precision (fp16 weights + fp32 input) natively.
|
| 74 |
|
| 75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
|
| 77 |
-
|
| 78 |
-
|
| 79 |
|
| 80 |
## Critical Rules
|
| 81 |
|
| 82 |
1. **READ neurogolf_utils.py** — it IS the scoring formula
|
| 83 |
-
2. **NEVER
|
| 84 |
-
3. **NEVER use
|
| 85 |
-
4. **NEVER
|
| 86 |
-
5. **
|
| 87 |
-
6. **
|
| 88 |
-
7. **
|
|
|
|
| 89 |
|
| 90 |
## What's Already Built
|
| 91 |
|
| 92 |
-
| File | Purpose |
|
| 93 |
-
|------|---------|
|
| 94 |
-
| `
|
| 95 |
-
| `
|
| 96 |
-
| `
|
| 97 |
-
| `
|
| 98 |
-
| `fp16_optimizer.py` | fp16 weight conversion
|
| 99 |
-
| `
|
| 100 |
-
|
| 101 |
-
## Running
|
| 102 |
-
|
| 103 |
-
```bash
|
| 104 |
-
# V90 solver (generates 400 models):
|
| 105 |
-
python -m neurogolf_solver.main --device cpu --conv_budget 5 \
|
| 106 |
-
--data_dir $DATA_DIR --kaggle --output_dir submission --fallback_zip fallback_unsolved.zip
|
| 107 |
-
|
| 108 |
-
# Post-processing pipeline (apply in order):
|
| 109 |
-
python sign_corrected_conv.py --data_dir $DATA_DIR --output_dir submission
|
| 110 |
-
python stage1_trivial_optimizer.py --input_zip submission.zip --data_dir $DATA_DIR --output_zip submission.zip
|
| 111 |
-
python merge_best_of_both.py --sub_5743 <5743.zip> --sub_v90 submission.zip --data_dir $DATA_DIR --output_zip submission.zip
|
| 112 |
-
```
|
| 113 |
|
| 114 |
## Key Insight
|
| 115 |
|
| 116 |
-
>
|
| 117 |
-
> The
|
| 118 |
-
>
|
|
|
|
|
|
| 1 |
# Instructions for Next Agent
|
| 2 |
|
| 3 |
> Read this FIRST. Then read LEARNING.md for mistakes to avoid.
|
| 4 |
+
> **PRIMARY GOAL: Get LB > 6043. Current best: V5 merger (estimated ≥6043).**
|
| 5 |
|
| 6 |
## ⚠️ READ neurogolf_utils.py FIRST
|
| 7 |
|
| 8 |
The file `own-solver/neurogolf_utils.py` is the OFFICIAL Kaggle scoring kernel (May 14, 2026 version).
|
|
|
|
| 9 |
|
| 10 |
+
The scoring formula is:
|
| 11 |
```python
|
| 12 |
points = max(1.0, 25.0 - math.log(max(1.0, memory + params)))
|
| 13 |
```
|
| 14 |
|
| 15 |
Where:
|
| 16 |
+
- `memory` = intermediate tensor bytes (NOT initializer bytes!)
|
| 17 |
+
- `params` = initializer element counts + Constant node element counts
|
| 18 |
+
- **NO MACs** (removed May 4, 2026)
|
| 19 |
|
| 20 |
+
## Current State (V5 merger, estimated ≥6043)
|
| 21 |
|
| 22 |
+
The V5 submission (`submission-v5-merged.zip`) takes the lowest-cost model per task from:
|
| 23 |
+
- `submission-6043.zip` (356 tasks) — scored 6043 on Kaggle
|
| 24 |
+
- `submission-5743.zip` (44 tasks) — scored 5743 on Kaggle
|
| 25 |
|
| 26 |
+
This should score ≥6043 since every model comes from a Kaggle-validated submission.
|
| 27 |
|
| 28 |
+
## Key Findings from This Session
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
+
### 1. The cost model was WRONG in V3
|
| 31 |
+
V3 merged V90+5743 by intermediate count, but this is a poor proxy for actual cost.
|
| 32 |
+
The correct approach: compute `memory + params` using shape inference, pick lowest.
|
|
|
|
| 33 |
|
| 34 |
+
### 2. fp16 weight conversion DOES NOT WORK
|
| 35 |
+
All fp16 models fail validation on arc-gen examples due to precision loss.
|
| 36 |
+
The comparison `(out > 0.0)` is too sensitive to small weight changes.
|
| 37 |
|
| 38 |
+
### 3. Direct Conv→output is the key technique for conv tasks
|
| 39 |
+
The 6043 submission uses single `Conv(W, B)→output` with 0 intermediates for 8+ tasks.
|
| 40 |
+
This gives score = 18.19 (cost = 910 = 900 W elements + 10 B elements).
|
| 41 |
+
The weights are trained so correct channel > 0 and wrong channels ≤ 0.
|
| 42 |
|
| 43 |
+
### 4. Static estimate ≠ Kaggle score (gap ~400-600 pts)
|
| 44 |
+
The ORT profiler takes MAX tensor size across all examples, making real costs higher
|
| 45 |
+
than shape-inference estimates. Use static estimates for RELATIVE comparisons only.
|
| 46 |
|
| 47 |
+
## Strategy to Beat 6043
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
+
### Already done:
|
| 50 |
+
- [x] Merge best-of(6043+5743) = V5 submission
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
+
### Next priorities:
|
| 53 |
+
1. **Submit V5 to Kaggle** to confirm score ≥6043
|
| 54 |
+
2. **Improve direct Conv fitting** for more tasks (currently 6043 has 8+ tasks with Conv→output that 5743 doesn't, need to replicate their fitting approach for more tasks)
|
| 55 |
+
3. **Reduce node count in high-cost tasks** (tasks 370, 205, 382 with 300-800 nodes)
|
| 56 |
+
4. **Find better architectures** for large-weight tasks (182, 158, 285)
|
| 57 |
|
| 58 |
+
### How 6043 achieves its score:
|
| 59 |
+
- 8 conv tasks at 18.19 pts (direct Conv+Bias, 0 intermediates)
|
| 60 |
+
- Several tasks with fp16 weights that DO validate (different from our approach)
|
| 61 |
+
- Some tasks with fewer nodes than 5743 (better graph optimization)
|
| 62 |
|
| 63 |
+
## Running
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
|
| 65 |
+
```bash
|
| 66 |
+
# V5 merger (produces final submission):
|
| 67 |
+
python merge_best_v5.py \
|
| 68 |
+
--s6043 submission-6043.zip \
|
| 69 |
+
--s5743 submission-5743.zip \
|
| 70 |
+
--output submission_v5.zip
|
| 71 |
|
| 72 |
+
# The output is already at: submission-v5-merged.zip in the repo root
|
| 73 |
+
```
|
| 74 |
|
| 75 |
## Critical Rules
|
| 76 |
|
| 77 |
1. **READ neurogolf_utils.py** — it IS the scoring formula
|
| 78 |
+
2. **NEVER use fp16 weight conversion** — it fails arc-gen validation
|
| 79 |
+
3. **NEVER use SVD** — approximation error breaks exact matching
|
| 80 |
+
4. **NEVER merge with V90** — V90 is worse than 5743 for nearly all tasks
|
| 81 |
+
5. **Initializers are NOT in memory** — only in params (element count)
|
| 82 |
+
6. **Direct Conv→output = 0 intermediates = best possible for conv tasks**
|
| 83 |
+
7. **Always validate on train+test+arc-gen before accepting any model**
|
| 84 |
+
8. **Static estimates are optimistic** — use for relative comparison only
|
| 85 |
|
| 86 |
## What's Already Built
|
| 87 |
|
| 88 |
+
| File | Purpose | Status |
|
| 89 |
+
|------|---------|--------|
|
| 90 |
+
| `merge_best_v5.py` | Best-of(6043+5743) merger | ✅ CURRENT BEST |
|
| 91 |
+
| `neurogolf_utils.py` | Official Kaggle scoring | ✅ Reference |
|
| 92 |
+
| `sign_corrected_conv.py` | Direct Conv→output for conv_var | ⚠️ Works for 3/18 tasks |
|
| 93 |
+
| `stage1_trivial_optimizer.py` | Rebuild trivial tasks | ✅ Working |
|
| 94 |
+
| `fp16_optimizer.py` | fp16 weight conversion | ❌ BROKEN (precision loss) |
|
| 95 |
+
| `merge_best_of_both.py` | V3: V90+5743 merge | ❌ SUPERSEDED by V5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
|
| 97 |
## Key Insight
|
| 98 |
|
| 99 |
+
> The path to beating 6043 further requires FITTING better Conv weights.
|
| 100 |
+
> The 6043 submission has weights that pass validation on ALL examples.
|
| 101 |
+
> Our lstsq fitting only works for 3/18 ks=3 conv tasks.
|
| 102 |
+
> Need: better optimization (e.g., gradient descent with margin) for sign-corrected weights.
|