Skip to content

Reduce SuzukiCancellation coefficient replay memory - #1061

Merged
Vilin97 merged 1 commit into
mainfrom
vilin/optimize-suzuki-cancellation-20261127
Nov 28, 2026
Merged

Vilin97 merged 1 commit into
mainfrom
vilin/optimize-suzuki-cancellation-20261127

Conversation

@Vilin97

@Vilin97 Vilin97 commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Ready for review. SuzukiCancellation cuts peak compiler memory by 36.6% and clean-build wall time by 14.6%, using medians of three runs.

Changes

  • Check the ordered exponential in three stages through degree five. Apply the three inner factors to the existing five-factor tail, certify the resulting eight-factor suffix, and reuse its rows for the final three factors. The append lemma relates both staged checks to the original recurrence. The additional 292 integer rows are checked by the kernel at every build.
  • Compare the stages with Boolean row equality and recover propositional equality with eq_of_beq. Keep the original per-degree equality certificates.
  • Use the missing logarithm degrees two through four to rule out products near the minimum degree. Separate the all-linear term and compute the two orderings of the linear–quintic product at degree six. Remove the now-unused private Mathlib.Tactic.Module import and mark the remaining direct tactic dependencies for Shake.

Declaration audit

The baseline came from bf11e8085efe1edbea05c2e093be80c3616bade6 before editing. The PR base is 03eb2d5240860e41d7ebc71891311d07c0d6e282 and the head is a5e7c870554cf276340e8148d743f7178a37febf. The project, its dependency pins, and its compiler-linter inputs are byte-identical between the measured and PR bases.

A Lean environment inspector loaded the private and exported module views and serialized the kernel declarations into compressed manifests. It compared names, owners, universe parameters, elaborated types, safety, declaration kinds and metadata, and non-proof values structurally, ignoring expression annotations and theorem proof terms. All 1,677 private-view entries and 1,256 exported-view entries matched across 99 modules. The 24 new declarations are private helpers and their generated declarations.

Measurements

The existing source profile identified 21.46 s in SuzukiSeries.lean and 7.49 s in QuinticJet.lean. These concentrated costs made the 99-module project a suitable target.

Each run rebuilt all 99 project modules with Lean 4.36.0 and Mathlib fc4f59e577feb1a4956671bc04ac18aaaf8cd842. I cleared only the project's Lake compiler outputs between runs, kept dependency artifacts warm, and used the same four VM cores.

LEAN_NUM_THREADS=4 taskset -c 8,10,12,14 lake --wfail --no-ansi build LeanPool.SuzukiCancellation.Imports
Measure Baseline runs Optimized runs Median change
Clean project build wall time 76.852 s, 81.126 s, 78.729 s 61.657 s, 67.212 s, 80.478 s 78.729 → 67.212 s (14.6% lower)
Largest sampled compiler anonymous memory 1,968,564 KiB, 1,974,848 KiB, 1,980,400 KiB 1,251,924 KiB, 1,247,996 KiB, 1,253,680 KiB 1,974,848 → 1,251,924 KiB (36.6% lower)
Lake time for SuzukiSeries 31 s, 32 s, 29 s 23 s, 30 s, 30 s
Lake time for QuinticJet 12 s, 14 s, 14 s 1.6 s, 1.3 s, 1.9 s

RAM is the maximum per Lean process sampled at 50 ms intervals using RssAnon + VmSwap. SuzukiSeries accounted for the peak in every run. The measurements apply to cached dependencies on this shared VM, and the wall times reflect contention.

Local validation

  • lake env lean --run scripts/ci/lint-project.lean … over all 99 owned modules, with the compiler plugin and warnings-as-errors in the targeted build.
  • lake exe lint-style LeanPool.SuzukiCancellation.Imports and lake shake --force --keep-public --keep-implied LeanPool.SuzukiCancellation.Imports for import review. The import review is advisory. The explicit tactic imports are retained for their proof uses.
  • python -m lean_pool.quality --repo . --static-only and the repository's project-scoped axiom, backdoor, declaration-resolution, and compiler-message audits.
  • lake exe mk_all --module --check, python -m lean_pool.rebase_fastpath check-index, python -m lean_pool.build_time_limits check, and git diff --check.

@greptile-apps

greptile-apps Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Advisory cross-file review against Lean Pool's supervisory rubric. This is not by itself a significance, source-verification, or merge verdict.

No actionable issue was found in this proof-only refactor.RetriggerView in Greptile

[Medium impact] No actionable issue was found in this proof-only refactor.

Summary

This refactor stages the coefficient checks in SuzukiSeries.lean and uses the missing logarithm degrees to simplify QuinticJet.lean.

  • Suzuki coefficient checks now reuse a smaller suffix calculation.
  • Quintic-jet proofs use missing degrees to skip unnecessary terms.

Reviews (1) · Last reviewed commit: "Reduce SuzukiCancellation coefficient re..." · Reviewed by Greptile

@github-actions

Copy link
Copy Markdown
Contributor

Proof profile (new / modified Lean files)

Statement changes

✅ No statements changed — all 45 tracked declarations across 2 modified files kept their type; only proofs / definition bodies changed.

Also: 6 declarations added, 0 removed. A reorganization moves declarations between files, which shows up here as an add in one file and a remove in another.

➕ Declarations added (6)
  • FQFP.BCH.argumentExpTable_beq — LeanPool/SuzukiCancellation/Analysis/Normed/Algebra/ProductFormula/SuzukiSeries.lean
  • FQFP.BCH.argumentSuffix — LeanPool/SuzukiCancellation/Analysis/Normed/Algebra/ProductFormula/SuzukiSeries.lean
  • FQFP.BCH.argumentSuffixTable — LeanPool/SuzukiCancellation/Analysis/Normed/Algebra/ProductFormula/SuzukiSeries.lean
  • FQFP.BCH.argumentSuffix_eq — LeanPool/SuzukiCancellation/Analysis/Normed/Algebra/ProductFormula/SuzukiSeries.lean
  • FQFP.BCH.tableExpFrom_append — LeanPool/SuzukiCancellation/Analysis/Normed/Algebra/ProductFormula/SuzukiSeries.lean
  • FQFP.positivePowerCoeff_eq_zero_of_gap — LeanPool/SuzukiCancellation/RingTheory/PowerSeries/Noncommutative/QuinticJet.lean

Statements are compared textually against the merge base (comments and whitespace ignored; by proof terms embedded in a type are treated as proof-irrelevant), the same method as physlib's /check-golf. Anonymous instances and examples are not tracked.

Compile cost of modified files — base → head

Heartbeats: 669,231 → 772,512 (+103,281, +15.4%). Commands: 74 → 82.

Per-file wall sum: 48.4 s → 49.6 s (+2.5%). Wall clock is measured under parallel load and is noisy; heartbeats are deterministic and are the regression signal.

Files: 1 compared — 0 cheaper, 1 costlier, 0 within noise (threshold: |Δ heartbeats| ≥ 1,000 and ≥ 1%).

Both sides are elaborated against the merge-base build of the pool — sound when only proofs and definition bodies change; a file whose statements changed may fail there and is flagged ⚠. Heartbeats come from disjoint root command traces with trace.profiler.useHeartbeats and synchronous elaboration, converted to maxHeartbeats units. Failed measurements are not classified as cheaper or costlier. Δ lines counts added/deleted lines from this PR diff.

File Δ lines HB base HB head Δ HB Δ HB % Wall base (s) Wall head (s)
LeanPool/SuzukiCancellation/Analysis/Normed/Algebra/ProductFormula/SuzukiSeries.lean +339/-16 669,231 772,512 +103,281 +15.4% 48.39 49.58
Total +339/-16 669,231 772,512 +103,281 +15.4% 48.4 49.6

New files — absolute profile

Total heartbeats: 15,849 maxHeartbeats units across 1 valid file (37 added LOC).

Sum of lean --profile: — across 0 valid files. Import-excluded time: —.

Count-heartbeats wall-clock total: 4.13 s. Repeated import cost inside lean --profile: —.

Heartbeat values sum disjoint root command traces with trace.profiler.useHeartbeats and synchronous elaboration, converted from raw allocations to maxHeartbeats units by dividing by 1000. They include command elaboration and kernel checking, exclude imports, and include profiler overhead; they are not comparable to the deprecated linter's totals. Per-file wall clocks are measured under parallel load and are noisier than heartbeats.

LOC counts added lines in the profiled Lean files from this PR diff.

File LOC Heartbeats (maxHB) Count wall (s) lean --profile (s) Without import (s) Import (s) Commands Errors
LeanPool/SuzukiCancellation/RingTheory/PowerSeries/Noncommutative/QuinticJet.lean 37 15,849 4.13 — — — 10 0
Total 37 15,849 4.13 — — — 10 0

Aggregate phase totals

Phase Time
Unavailable —

Advisory only — never blocks merge. Full log uploaded as the proof-profile artifact.

@Vilin97 Vilin97 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Source review passed for a5e7c870554cf276340e8148d743f7178a37febf.

  • The three public theorem statements are unchanged. The split coefficient replay preserves the order of the noncommutative factors and checks each table through degree five in the kernel. An independent integer convolution reproduced all 292 new suffix entries.
  • The quintic jet proof uses the existing degree gap to eliminate the middle terms. It retains both degree-six products, G * L and L * G, with the original factor of 1/2.
  • The three reported matched project builds show 36.6% lower median peak sampled private memory and 14.6% lower median wall time. The hosted profile measured 15.4% more heartbeats for SuzukiSeries. It recorded 15,849 heartbeats for the new QuinticJet proof after the baseline profiler hit its 200,000-heartbeat limit, so the profile does not provide a project-wide comparison. Hosted proof profile

The required pool build was still running at review time. Lean Action CI

@Vilin97

Vilin97 commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator Author

🤖 LLM review — refactor (gpt-6.2-sol)

Reviewed head: a5e7c870554cf276340e8148d743f7178a37febf

Verdict: ✅ approve

The refactor checks the ordered exponential in stages through degree five and gives the quintic jet proof explicit steps for the vanishing coefficients and the two ordered mixed products. The warnings-as-errors build through SuzukiJet passed. In single-module runs, SuzukiSeries peak RSS fell from 3.19 to 2.50 GiB, and QuinticJet elapsed time fell from 9.68 to 1.51 seconds. The PR’s /profile recorded 15.4% more heartbeats for SuzukiSeries, and a scratch variant that kept the old grouping and used Boolean equality still peaked at 3.18 GiB.

Aspect Value
Scope coefficient certificate staging and jet proof rewrite
Introduces tech debt 🛑 yes
Maintainability ✅ improved
Brittleness ✅ more_robust
Risk ✅ low

The lower peak memory and clearer jet proof outweigh the small maintenance cost of one more kernel-checked coefficient table.

Findings (1)

  • certificate-regeneration — LeanPool/SuzukiCancellation/Analysis/Normed/Algebra/ProductFormula/SuzukiSeries.lean:450
    Changes to the suffix factors or collection order can require refreshing all 292 rows, and a failed Boolean check identifies the degree without showing the differing row. Record a regeneration recipe beside the table. A scratch #reduce of (List.range 6).map (tableExpFrom ((argumentTables.take 6).drop 3) argumentTail) reproduced every row in order with increased recursion depth and deep-term printing enabled.

Tokens: 3,049,617 in / 17,410 out · Tier: codex-subscription · Effort: xhigh · Billing: Codex subscription quota (no API credits) · Estimated cost: $12.4596 (Standard API equivalent; uncached input) (long-context rate)
Automated review against .github/REFACTOR_REVIEW_RULES.md. Disagree? Reply on the PR; rules can be updated in a PR of their own.

@Vilin97
Vilin97 added this pull request to the merge queue Nov 28, 2026
Merged via the queue into main with commit 996a8e1 Nov 28, 2026
27 checks passed
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