Skip to content

Add NeuralAllocator, a learned score-and-sort allocator#33

Open
fpedd wants to merge 1 commit into
mainfrom
neural-allocator
Open

Add NeuralAllocator, a learned score-and-sort allocator#33
fpedd wants to merge 1 commit into
mainfrom
neural-allocator

Conversation

@fpedd

@fpedd fpedd commented Jul 11, 2026

Copy link
Copy Markdown
Owner

A permutation-equivariant Transformer (~360k params, PyTorch, optional
"ml" extra with a CPU-only wheel source) scores every allocation of a
problem; placing the allocations first-fit in descending score order
yields the full solution, since the placement order alone determines
the outcome. The scores define a Plackett-Luce distribution over
permutations, so inference takes the best of the deterministic decode,
the classic greedy orders (portfolio floor: never worse than
greedy_by_all), and up to 1024 Gumbel-perturbed policy samples within
the shared 3 s budget.

Features are scale-invariant per instance: normalized sizes, times,
areas, conflict degrees, their ranks, plus instance-level context
(each classic greedy order's relative peak and a winner one-hot)
broadcast to every allocation.

Training (training/train_neural.py) runs on CPU in under an hour:
Plackett-Luce behavior cloning of the tie-consistent best greedy order
per instance, then self-imitation (expert iteration) toward
per-instance incumbent orders found by policy sampling, with peak
memory evaluated by the C++ FirstFitPlacer and normalized by the
max-live-load lower bound. Problems are freshly generated from the
generator sources with randomized parameters; the minimalloc CSV
datasets stay held out for evaluation. The fp16 checkpoint (487 KB)
ships with the package.

On 90 held-out problems (unseen generator seeds, minimalloc small and
challenging) the mean peak over lower bound is 1.058, ahead of every
heuristic and metaheuristic (greedy_by_all 1.080, simulated annealing
1.082, telamalloc 1.083, hillclimb 1.146) and behind only the exact
supermalloc solver (1.008); training/eval_neural.py reproduces the
comparison, including decode-only and sampling-only ablations.

A permutation-equivariant Transformer (~360k params, PyTorch, optional
"ml" extra with a CPU-only wheel source) scores every allocation of a
problem; placing the allocations first-fit in descending score order
yields the full solution, since the placement order alone determines
the outcome. The scores define a Plackett-Luce distribution over
permutations, so inference takes the best of the deterministic decode,
the classic greedy orders (portfolio floor: never worse than
greedy_by_all), and up to 1024 Gumbel-perturbed policy samples within
the shared 3 s budget.

Features are scale-invariant per instance: normalized sizes, times,
areas, conflict degrees, their ranks, plus instance-level context
(each classic greedy order's relative peak and a winner one-hot)
broadcast to every allocation.

Training (training/train_neural.py) runs on CPU in under an hour:
Plackett-Luce behavior cloning of the tie-consistent best greedy order
per instance, then self-imitation (expert iteration) toward
per-instance incumbent orders found by policy sampling, with peak
memory evaluated by the C++ FirstFitPlacer and normalized by the
max-live-load lower bound. Problems are freshly generated from the
generator sources with randomized parameters; the minimalloc CSV
datasets stay held out for evaluation. The fp16 checkpoint (487 KB)
ships with the package.

On 90 held-out problems (unseen generator seeds, minimalloc small and
challenging) the mean peak over lower bound is 1.058, ahead of every
heuristic and metaheuristic (greedy_by_all 1.080, simulated annealing
1.082, telamalloc 1.083, hillclimb 1.146) and behind only the exact
supermalloc solver (1.008); training/eval_neural.py reproduces the
comparison, including decode-only and sampling-only ablations.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant