rogermt commited on
Commit
cb1c8af
·
verified ·
1 Parent(s): c785d35

Update NEXT_AGENT.md with V5 results and corrected strategy

Browse files
Files changed (1) hide show
  1. 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: 5560.70 (V3). Gap: +483 pts.**
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 on line 514:
12
  ```python
13
  points = max(1.0, 25.0 - math.log(max(1.0, memory + params)))
14
  ```
15
 
16
  Where:
17
- - `memory` = `calculate_memory()` using ORT Profiler JSON trace = sum of ALL intermediate tensor bytes
18
- - `params` = `calculate_params()` = sum of all initializer + Constant element counts
19
- - **NO MACs.** MACs were removed May 4, 2026 after an exploit allowed LB 10000.
20
 
21
- ## Current State (V3, LB 5560.70, 400/400 tasks)
22
 
23
- - V90 solver produces 400 models (385 solved + 15 fallback)
24
- - V3 optimizer post-processes: merges with 5743 (80 tasks), rebuilds trivial tasks (6 tasks)
25
- - +238 pts over V90 purely from reducing intermediate tensor count
26
 
27
- ## The Math
28
 
29
- Cost = memory + params. Score = 25 - ln(cost).
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
- **Main cost driver: intermediate tensor memory.**
35
- Each node output (1,10,30,30) float32 = 36,000 bytes added to cost.
36
- A model with 5 such intermediates: cost ≈ 180,000 → score ≈ 12.8.
37
- Reduce to 2 intermediates: cost ≈ 72,000 → score ≈ 13.8. Gain: +1.0.
38
 
39
- ## Strategy (Proven by V3 Results)
 
 
40
 
41
- ### Priority 1: Reduce intermediate tensor count [+150-250 pts]
 
 
 
42
 
43
- The V3 result PROVED this works: replacing models with fewer-node equivalents = big score gains.
 
 
44
 
45
- **Technique A: OneHot op replacement**
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
- Replace with single OneHot op:
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
- **Technique B: Direct output pattern**
61
- If the model's last op feeds directly into graph output 'output',
62
- that tensor is NOT counted in memory. Saves 36,000 bytes.
 
 
63
 
64
- **Technique C: Fuse operations**
65
- Consecutive Slice nodes → merge into one Slice.
66
- Cast(fp32→fp16) → Cast(fp16→fp32) → eliminate both.
67
- Pad(0) then Pad(0) → single Pad.
68
 
69
- ### Priority 2: fp16 weights WITHOUT adding Cast nodes [+50-100 pts]
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
- ### Priority 3: SVD factorization for 6 largest-weight tasks [+20-50 pts]
 
 
 
 
 
76
 
77
- Tasks 182, 158, 277, 387, 285, 324 have 50-462 KB weights.
78
- Factor W → U @ V to reduce both memory and params.
79
 
80
  ## Critical Rules
81
 
82
  1. **READ neurogolf_utils.py** — it IS the scoring formula
83
- 2. **NEVER add nodes that create large intermediates** (Cast, Reshape to bigger shape)
84
- 3. **NEVER use task numbers in solver names or variables**
85
- 4. **NEVER load reference ONNX files at runtime** — embed weights
86
- 5. **NEVER use Resize op** — crashes profiler
87
- 6. **ALWAYS validate** against train+test+arc-gen before accepting
88
- 7. **Output types**: FLOAT(1), UINT8(2), BOOL(9), FLOAT16(10) — must match reference
 
89
 
90
  ## What's Already Built
91
 
92
- | File | Purpose |
93
- |------|---------|
94
- | `neurogolf_utils.py` | Official Kaggle scoring (May 14) — READ THIS |
95
- | `sign_corrected_conv.py` | Direct Conv→output for 6 conv_var tasks |
96
- | `stage1_trivial_optimizer.py` | Rebuild transpose/color_map for 18-25 pts |
97
- | `merge_best_of_both.py` | Pick best model from 5743 vs V90 per task |
98
- | `fp16_optimizer.py` | fp16 weight conversion (has Cast bug — needs fix) |
99
- | `PLAN_TO_6043.md` | Full analysis with score projections |
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
- > Every node you add to a model costs 3,600-36,000 bytes in the score formula.
117
- > The path to 6043 is making models with FEWER nodes while preserving correctness.
118
- > This is a graph compression problem, not a training problem.
 
 
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.