On this page

For developers

BNL Contraction Order Performance Notes

Archived · partially reproduciblePerformance investigation · 2026-05-27 to 2026-05-28archived

A 2026-05-27 to 2026-05-28 contraction-order comparison with retained input atoms and example code, but incomplete machine and dependency controls.

View the source note

Lifecycle
archived
Owner
Ownership decision required
Review
No review record
Freshness
frozen-evidence
Evidence
captured 2026-05-27 to 2026-05-28 · 4fdbf430b29edd24b9e1292c07ab24a151427dc7
Verified scopes
No verified code scopes recorded

Status: Archived, partially reproducible performance evidence

These measurements were captured on 2026-05-27 and 2026-05-28 at evidence revision 4fdbf430b29edd24b9e1292c07ab24a151427dc7. The two input atoms and the bnl_evaluator_atom_mwe example remain, but the original note did not identify the machine, operating system, Nix closure, or Symbolica revision. Re-run the commands to establish a new baseline; do not compare current timings directly with these values.

Input:

examples/cli/BNL/profiling/bnl_integrated_evaluator_atom_exact.sym first:1 --alias-scalars 4096

The runs below used an isolated target directory and low cargo parallelism to avoid competing with background cargo checks and to reduce OOM risk:

env CARGO_TARGET_DIR=/private/tmp/gammaloop-codex-target CARGO_BUILD_JOBS=2 \
  cargo run -p gammalooprs --example bnl_evaluator_atom_mwe --profile dev-optim -- \
  examples/cli/BNL/profiling/bnl_integrated_evaluator_atom_exact.sym first:1 \
  --alias-scalars 4096 --contraction-order ORDER

The first dev-optim build took 18m 34s. The table timings below are from the example’s own stage timers, so compile time is excluded.

Direct Concrete Network

OrderNetwork parseNetwork execute
sparse-atom-aware65.897583ms1.52775ms
atom-aware63.773667ms1.630291ms
entry-aware62.855959ms2.201458ms
result-rank-only60.812834ms6.8265ms
OrderEntriesTermsTotal entry bytes
sparse-atom-aware569928374721
atom-aware569928374721
entry-aware569928374721
result-rank-only5579209262914
OrderLargest entry bytesResult bytes
sparse-atom-aware157199157216
atom-aware157199157216
entry-aware157199157216
result-rank-only25812082581225

sparse-atom-aware and atom-aware choose the non-blowing contraction shape for this term. The old rank-only score still produces a single huge scalar entry: about 24.7x more post-execute tensor scalar bytes and 16.4x larger result bytes than sparse-atom-aware.

Symbolic Then Concrete Baseline

Command:

env CARGO_TARGET_DIR=/private/tmp/gammaloop-codex-target CARGO_BUILD_JOBS=2 \
  cargo run -p gammalooprs --example bnl_evaluator_atom_mwe --profile dev-optim -- \
  examples/cli/BNL/profiling/bnl_integrated_evaluator_atom_exact.sym first:1 \
  --alias-scalars 4096 --contraction-order sparse-atom-aware --symbolic-then-concrete
stageelapsedtermsbytesdetails
symbolic network parse4.722125ms--nodes=49 edges=91 tensors=22
symbolic network execute0.475375ms--aliases retained
symbolic aliased root-11754aliases=1
concrete network parse56.123666ms--nodes=49 edges=91 tensors=15
concrete network execute1.21825ms--sparse-atom-aware
concrete tensor entries after execute-928374721entries=569 max_entry_bytes=157199
concrete aliased root-1157216aliases=1

At capture time, the direct sparse-aware order reached the same post-execute scalar-growth class as the symbolic-then-concrete path for first:1: 569 entries, 928 terms, 374721 total tensor-entry bytes, and 157216 result bytes.

Notes

  • I did not run first:4 or all in this pass. The purpose here was to validate the scoring change without deliberately triggering the known four-term memory pressure.
  • At evidence revision 4fdbf430b29edd24b9e1292c07ab24a151427dc7, the sparse-aware score was the default MinResultRank preset. The EvaluatorSettings::tensor_network_contraction_order setting can select the other presets for comparison.

Direct All Follow-Up

Date: 2026-05-28

Command:

env CARGO_TARGET_DIR=/private/tmp/gammaloop-codex-target CARGO_BUILD_JOBS=2 RAYON_NUM_THREADS=1 \
  cargo run -p gammalooprs --example bnl_evaluator_atom_mwe --profile dev-optim -- \
  examples/cli/BNL/profiling/bnl_integrated_evaluator_atom_exact.sym all \
  --alias-scalars 4096 --contraction-order sparse-atom-aware

first:4 is not a meaningful selector for this saved exact atom: Symbolica parses it as one top-level term. Running all directly, without expanding first, completed without memory pressure.

MetricValue
Selectionall
Network parse169.562583ms
Network execute2.275083ms
After-execute entries569
After-execute terms928
After-execute bytes374721
Largest entry bytes157199
Result bytes157216

Unfiltered Pre-Network Follow-Up

Date: 2026-05-28

The exact atom above is already a single factored top-level term, so all and first:1 select the same expression. The larger four-alias case is represented by bnl_integrated_evaluator_atom_unfiltered_pre_network.sym.

Command:

env CARGO_TARGET_DIR=/private/tmp/gammaloop-codex-target CARGO_BUILD_JOBS=2 RAYON_NUM_THREADS=1 \
  cargo run -p gammalooprs --example bnl_evaluator_atom_mwe --profile dev-optim -- \
  examples/cli/BNL/profiling/bnl_integrated_evaluator_atom_unfiltered_pre_network.sym all \
  --alias-scalars 4096 --contraction-order sparse-atom-aware
MetricValue
Inputunfiltered pre-network
Aliases4
Network parse173.041791ms
Network execute4.331541ms
After-execute entries1669
After-execute terms2460
After-execute bytes1493281
Largest entry bytes545943
Result bytes545960

The unfiltered case completes without resolving aliases and without the previous runaway scalar growth: the largest final entry is about 546kB, and the aliased root stays at 546kB with four retained scalar aliases.

Developer architecture · documented revision e51747446aa7