Skip to content

Skip global gradient propagation when no source can contribute - #196

Closed
genixpro wants to merge 1 commit into
codex/simplify-global-gradientfrom
codex/skip-inert-global-gradients
Closed

Skip global gradient propagation when no source can contribute#196
genixpro wants to merge 1 commit into
codex/simplify-global-gradientfrom
codex/skip-inert-global-gradients

Conversation

@genixpro

@genixpro genixpro commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Stacked on #195; merge that PR first. This diff contains a five-line production fast path, focused tests, and the performance/equivalence evidence report.

A freshly seeded global gradient containing only values 0, 1 and 2 cannot change during propagation: zero is immutable, and neither 1 nor 2 can raise a free cell above its seed of 1. Return immediately when no input byte is at least 3, avoiding the two full-map sweeps that would otherwise discover this fixed point.

The comment states that invariant. The check deliberately accepts contributing seeds of 3 and 254 as well as 255-valued goals. It changes neither seed construction nor when callers refresh gradients, and introduces no cache or new persistent state.

Measured performance

Fresh measurements of the exact clean patches against master at b47c7d23b, on an Apple M3 with an optimized Apple Clang build. Median core simulation CPU time over three serial 15,000-tick runs:

Scenario Baseline #195 only Both PRs Additional reduction vs #195 Total reduction vs baseline
G2 4.134 s 3.614 s 3.510 s 2.9% 15.1%
Playground, eight Numbi AIs 3.981 s 3.430 s 3.108 s 9.4% 21.9%

The timer covers advancing Game::syncStep calls, excluding AI order generation, order execution, startup and replay I/O. It was identical in all timed binaries and is absent from these commits. Runs were serial, variant order alternated, and competing compiler/game jobs triggered retries. The Playground setup uses Numbi on all eight teams, seed 424242, plus the headless passive local controller on team 0. These are CPU-time measurements on one machine, not FPS claims.

The evidence report and raw samples/checksum digests include methodology and reproduction steps. They distinguish these results from the earlier 22–24% combined exploratory results on a different base, which also included a local-gradient rewrite. The experimental cache and local rewrite are not part of either PR.

Validation

  • Extended the maintained production harness with all-zero, all-one, all-two and mixed 0/1/2 fields, including one-cell inputs. Added seeds of 3, 254 and 255 at the last input position to check the threshold and full-buffer scan.
  • The independent priority-frontier oracle still matches every byte for 3,000 random fields, toroidal seams, diagonals, thin dimensions, winding obstacles, mixed seeds, cutoff and idempotence.
  • Both exact clean patches independently match the unmodified baseline on six 15,000-tick games: G2, gd-small-2ai, gd-large-4ai, gd-archipelago, gd-bigarena-long and fixed-seed eight-AI Playground. Replay bytes and complete per-tick unit/building checksum sidecars match across all 90,000 ticks per executable. Timed runs also match baseline replays.
  • Both kernel variants passed with the harness and gradient translation unit instrumented by AddressSanitizer/UndefinedBehaviorSanitizer; other linked engine objects were uninstrumented.
  • Optimized client and final global-gradient-test builds pass. The harness is wired into Linux CI by Reduce work in global gradient sweeps without changing results #195; hosted CI is pending.
scons -j8 release=1 server=0 global-gradient-test
./build/src/GlobalGradientHarness

@genixpro

genixpro commented Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

Closing in favor of the weighted pathfinder in #184, which we have decided to adopt. Its main propagation path already avoids running without queued sources. Further performance work is going onto #184; this branch and its benchmark evidence remain available for reference.

@genixpro genixpro closed this Sep 8, 2026
@genixpro genixpro mentioned this pull request Sep 8, 2026
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