Repository navigation
Speed up FastDynamo resolvent and cutoff compilation - #1073
Conversation
|
Advisory cross-file review against Lean Pool's supervisory rubric. This is not by itself a significance, source-verification, or merge verdict. [Medium impact] The proof-only changes appear safe to merge; no actionable regression was found. SummaryThis PR speeds up existing FastDynamo proofs without changing their mathematical statements.
The supplied paired measurements report faster builds. Those measurements and the declaration audit were not independently rerun. External source and license claims were not reverified; this PR changes neither. Reviews (1) · Last reviewed commit: "Speed up FastDynamo resolvent and cutoff..." · Reviewed by Greptile |
Vilin97
left a comment
There was a problem hiding this comment.
Source review passed at 69558659b266a4722fc617dad0172622161e25e4.
- The resolvent and cutoff changes preserve the existing statements. The pencil identity, linear-map identities, and explicit norm inequalities replace repeated elaboration work. The reducibility attributes are local to the proof modules. There are no import, project-card, or attribution changes.
- The FastDynamo tree, toolchain, Lake inputs, and build scripts match at the benchmark base and PR base. The reported paired incremental run improves from 301.46 s to 258.06 s, a 14.4% reduction. Both reported clean pairs also improved.
- The right-inverse proof could reuse the same private pencil identity, and two
hfbindings became unused. These are optional cleanups. Resolvent source
Required Lean CI and the advisory Proof Profile are running. Lean Action CI · Proof Profile
Proof profile (new / modified Lean files)Statement changes✅ No statements changed — all 690 tracked declarations across 22 modified files kept their type; only proofs / definition bodies changed. Also: 1 declaration 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 (1)
Statements are compared textually against the merge base (comments and whitespace ignored; Compile cost of modified files — base → headHeartbeats: 2,451,050 → 2,130,984 (-320,066, -13.1%). Commands: 365 → 373. Per-file wall sum: 222.2 s → 221.7 s (-0.2%). Wall clock is measured under parallel load and is noisy; heartbeats are deterministic and are the regression signal. Files: 4 compared — 3 cheaper, 0 costlier, 1 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
New files — absolute profileTotal heartbeats: 2,446,615 maxHeartbeats units across 6 valid files (93 added LOC). Sum of Count-heartbeats wall-clock total: 300.56 s. Repeated import cost inside Heartbeat values sum disjoint root command traces with LOC counts added lines in the profiled Lean files from this PR diff.
Aggregate phase totals
Advisory only — never blocks merge. Full log uploaded as the |
🤖 LLM review — refactor (
|
| Aspect | Value |
|---|---|
| Scope | elaboration performance refactor |
| Introduces tech debt | 🛑 yes |
| Maintainability | ✅ improved |
| Brittleness | ✅ more_robust |
| Risk | ✅ low |
The explicit proof steps and lower elaboration cost improve maintainability, with minor cleanup remaining in the transparency overrides and pencil helper reuse.
Findings (3)
- duplicated-proof —
LeanPool/FastDynamo/Local/HorizontalFormResolvent.lean:128
The right inverse still proves the same pencil formula asassociatedFormProdOperator_pencil_apply, leaving two places to update if the pencil representation changes. Use the helper here too and drop the unusedwith hfbindings in its two existing callers. This cleanup elaborated in a scratch copy. - unnecessary-opacity —
LeanPool/FastDynamo/Analysis/TransverseSmoothH2CutoffMultiplier.lean:623
The two localMeasureTheory.Lpoverrides affect conversion across the cutoff module. Removing both still elaborated and took about 4,500 fewer heartbeats, with almost all of the difference in the second section. Drop the overrides or scope them to proofs where they show a measured benefit. - dead-leftover —
LeanPool/FastDynamo/Local/HorizontalFormCompactness.lean:64
Removing the localassociatedFormProdGraphDefectoverride here and inHorizontalSeedWitnessleft both files compiling and changed each count by about 11 heartbeats. Drop these two copies so the workaround identifies modules where keeping the defect bundled materially affects elaboration.
Tokens: 5,572,680 in / 23,387 out · Tier: codex-subscription · Effort: xhigh · Billing: Codex subscription quota (no API credits) · Estimated cost: $22.6415 (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.
Ready for review. The controlled 151-module incremental rebuild is 14.4% faster.
Scope
FastDynamo has 412 modules. The scouting profile showed concentrated costs on the import chain
through the horizontal form operator, its contour resolvent, and the seed perturbation. In the
baseline,
HorizontalRieszPerturbationrepeatedly compared normed-space instances for thesame graph domains.
irreducibility where those bodies are expensive to unfold.
inverse directly in the norm estimates.
and use the scalar Young inequality and norm bounds directly in the diffusion estimates.
Declaration audit
Lean loaded the full project with private olean data and recorded the exported view separately.
The compressed manifests contain the elaborated expression graphs, universe parameters,
declaration kinds, safety, reducibility, non-theorem values, and constructor and recursor data.
All 14,260 pre-existing declarations matched, including private and generated declarations.
The single added declaration is a private pencil identity used by the optimized proofs.
The comparison permits updated proof terms for existing theorems.
The measured baseline is
432e18b03cfb58eca4e6ee9b3244d6bd6657140e. The PR base isa81b589c8a852c75d03cff1ac873920cb8bc8441. The FastDynamo sources,build plugin, and dependency pins match at both base commits. The PR head is
69558659b266a4722fc617dad0172622161e25e4.Measurements
Both clean pairs rebuilt all 412 project modules on the same Azure VM with pinned Lean and
Mathlib v4.36.0 and cached dependencies. The memory sampler recorded the largest per-compiler
RssAnon + VmSwapapproximately every 250 ms.The incremental run retained cached outputs outside the 151-module set of edited modules and their transitive importers. Both revisions rebuilt that same set through the whole-project
Importstarget.Each row reports one paired run on the shared VM. An earlier four-thread scouting baseline
took 447.68 s with partial memory sampling. The cumulative typeclass
measurement uses Lean's
--profilewith Lake's per-module setup.Validation
LEAN_NUM_THREADS=4 /usr/bin/time -v lake --no-cache --wfail build LeanPool.FastDynamo.Importsand the equivalent two-thread command
lake env lean --run scripts/ci/lint-project.leanover all 412 modules andlake exe lint-style LeanPool.FastDynamo.Importslake exe mk_all --module --checkanduv run --locked python -m lean_pool.quality --repo .. --static-onlyfrom
python/python -m lean_pool.build_time_limits checkagainst the optimized build log for all 22 edited moduleslake shake --force --keep-public LeanPool.FastDynamo.Importsfor import analysis