agentleFS
topprismdatatopprismdata/cultivating-ml-agent/skills/examples/onnx-minimal-network-design/SKILL.md

onnx-minimal-network-design

Skill5 starsChanged 36 days agoMITView on GitHub

Use when: (1) Competing in ONNX-based competitions (NeuroGolf, model compression), (2) Need to design minimal neural networks as ONNX graphs, (3) Want to replace verbose agent-generated circuits with compact hand-designed nets. Key principles: single-node graphs have zero memory cost (output is free), Conv is a linear classifier (cannot separate nonlinear rules), Gather implements color permutations (10 params), use LogisticRegression to solve Conv weights for local 3×3 rules. Sparse initializers are rejected by ONNX strict checker for Conv nodes. Validated on NeuroGolf 2026 (7228 baseline, independent toolkit).

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 3 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Verify the rule is deterministic (same neighborhood → same output)

    line 47
  2. Distinctive:

    Verify ONNX runtime output matches ground truth on ALL examples

    line 50
  3. Very specific:

    Limitation: If LogReg accuracy < 100%, the rule is NOT linearly separable.

    line 52
  4. Distinctive:

    Only use sparse for ops that explicitly support it (not Conv/MatMul in practice).

    line 70

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

ONNX Minimal Network Design

Problem

Neural network golf competitions require the smallest possible ONNX network that correctly implements a transformation. Score = max(1, 25 - ln(memory + params)).

Smaller networks → exponentially higher scores. The key insight: memory dominates cost (intermediate tensor bytes), not parameters.

Solution

Core Scoring Formula

memory = Σ(bytes of all intermediate tensors)  # input/output are FREE
params = Σ(initializer element counts)
score  = max(1, 25 - ln(memory + params))

Design Principle 1: Single-Node = Zero Memory

A single-node graph (1 Conv/Gather/Transpose) has zero intermediate memory (output tensor is free). Only params count.

Implication: A 1-node Conv with 900 params (cost=900, score=18.2) beats a 4-node net with 200 params + 5000 memory (cost=5200, score=16.3).

Design Principle 2: Conv is a Linear Classifier

A Conv node maps 3×3 one-hot neighborhoods → output channels. This is a linear classifier on 90-dim features (9 positions × 10 colors).

To find Conv weights for a local rule:

  1. Collect all (3×3 neighborhood, output color) pairs from training data
  2. Verify the rule is deterministic (same neighborhood → same output)
  3. Train LogisticRegression (multi-class, C=1e4, solver='newton-cg') on the pairs
  4. Extract coef_ as Conv W[10,10,3,3], intercept_ as B[10]
  5. Verify ONNX runtime output matches ground truth on ALL examples

Limitation: If LogReg accuracy < 100%, the rule is NOT linearly separable. Need nonlinear ops (Cast/Equal/Where) — a single Conv cannot implement it.

Design Principle 3: Gather for Color Permutations

A pixel-wise color map (e.g., swap color 3↔4) is a 1-node Gather:

  • idx = [0,5,6,4,3,1,2,7,9,8] (10-element lookup table)
  • Gather(input, idx, axis=1) maps each one-hot vector to the permuted one
  • Cost: 10 params, 0 memory → score ≈ 22.7

Design Principle 4: Sparse Initializers REJECTED

Converting dense sparse weights to sparse_initializer reduces params but onnx.checker.check_model(full_check=True) rejects sparse Conv weights:

W typestr: T, has unsupported type: sparse_tensor(float)

Only use sparse for ops that explicitly support it (not Conv/MatMul in practice).

Independent Toolkit Architecture

# Grid encoder: ARC grid [[c,...]] → one-hot [1,10,30,30] float32
grid_to_onehot(grid, size=30)

# ONNX builders:
design_gather_colormap(color_map)  # 1-node Gather, 10 params
design_transpose()                  # 1-node Transpose, 0 params  
design_border(color=8)             # 1-node Conv border detection

# Verifier: onnxruntime on ALL train + arc-gen examples
verify(model_bytes, task_json)

# Scorer: compute params + memory → points
score_model(model_bytes)

Evidence (NeuroGolf 2026)

  • task171 border: independently designed 1-Conv (19/19 correct, matches existing bundle)
  • task222: LogReg solver achieved 99.95% (not 100% — rule is nonlinear)
  • 87 tasks had sparse-able weights but sparse rejected by strict checker
  • 400-task scan: all simple rules already 1-node in community bundle

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.