Skip to content

Reduce SmoothedOctagon peak compiler memory - #1201

Merged
Vilin97 merged 1 commit into
mainfrom
vilin/smoothed-octagon-proof-memory-20261206
Dec 6, 2026
Merged

Vilin97 merged 1 commit into
mainfrom
vilin/smoothed-octagon-proof-memory-20261206

Conversation

@Vilin97

@Vilin97 Vilin97 commented Dec 6, 2026

Copy link
Copy Markdown
Collaborator

Ready for review. The clean SmoothedOctagon build reduced the highest sampled Lean compiler peak by 15.998%.

Scope

SmoothedOctagon formalizes the Reinhardt conjecture and its equality case. The November 30 source profile put about 21 seconds into valueUpper8_eq and 26 seconds into lro_B_F0u_ge. The clean baseline put Costate.lean and the outer-strip Boundaries/Polynomials.lean among the highest-memory modules in the 553-module project.

  • Prove the cleared upper-entry costate identity by exhibiting its numerator difference as a multiple of √3 ^ 2 - 3. Use a single polynomial check for each entry of the matrix conjugation and for the diagonal costate identity.
  • Verify the three upper-strip boundary expansions using the existing polynomial-grid lemma. The degree bounds are 18 and six. Lean checks the 19 × 7 grid over exact rationals and transports the samples to the reals.
  • Clear denominators in the lower-ratio derivative once, then reuse the resulting numerator for all four endpoint expansions.

Declaration audit

Measured base f9dea40d813350b6d37cdf4771c58f5cb6ea7db3, PR base 9caa1b309942e8beaeb9f393cf8d2051d52b8970, and head 4c9016848de2f1a3eb56d7b667475e28f9fd9710. Main advanced during the run. I verified the project sources, Brouwer dependency, project card, dependency pins, and validation code matched between the two bases. I imported the compiled project in Lean's private and exported environment views and compared compressed manifests. All 31,075 existing declarations matched on name, defining module, fully elaborated type, universe parameters, declaration kind, safety, and exported visibility. The comparison also covered non-theorem bodies, kernel reducibility hints, and inductive and recursor data. It found 7 changed theorem proof terms and 11 added private declarations. The generated coefficient equations and costate auxiliary types were included in the comparison. The repository axiom and option audits passed.

Measurements

Both clean runs compiled all 553 project modules with Lean 4.36.0 and Mathlib fc4f59e577feb1a4956671bc04ac18aaaf8cd842. I cleared the project's own Lake outputs for each run and reused the prebuilt external dependencies and compiler plugin. Both runs used taskset -c 0,2,4,6,8,10,12,14 lake --wfail build +LeanPool.SmoothedOctagon.Imports on the Azure VM. I sampled RssAnon + VmSwap from each project compiler approximately every 100 ms. The project-wide maximum moved from StrongTransversality/Costate.lean to LargerNorm/Endpoints.lean.

Measure Base Head Change
Clean project wall time 999.113 s 978.910 s −2.022%
Clean project peak for one Lean compiler 2,231,496 KiB 1,874,492 KiB −15.998%
Clean project peak across concurrent Lean compilers 4,777,160 KiB 4,886,400 KiB +2.287%
Three-module rebuild wall time 48.477 s 32.140 s −33.701%

The focused comparison rebuilt the same three targets against warm dependencies.

Module Sampled compiler duration Sampled peak compiler memory
Costate.lean 18.112 s → 12.060 s 2,240,900 → 802,584 KiB
TestZero1.lean 16.652 s → 8.803 s 863,764 → 588,648 KiB
Boundaries/Polynomials.lean 28.242 s → 17.961 s 1,860,788 → 1,260,352 KiB

Validation

  • lake --wfail build +LeanPool.SmoothedOctagon.Imports and the focused lake --wfail build runs passed.
  • lake env lean --run scripts/ci/lint-project.lean <all 553 SmoothedOctagon modules>, lake exe lint-style LeanPool.SmoothedOctagon.Imports, and lake exe mk_all --module --check passed. The project also passed lake --no-build --wfail build +LeanPool.SmoothedOctagon.Imports after moving to current main.
  • uv run --locked python -m lean_pool.quality --repo .. --static-only passed from python/. The repository's project-card, transitive axiom, compiled option and axiom-injection, and compiler-message checks also passed for the selected project.
  • lake shake --force --keep-public informed the import review. The degree tactic has an explicit shake: keep import. git diff --check and python -m lean_pool.build_time_limits check passed.

The wall times and memory peaks are observations on this VM. The timing includes Lake scheduling with warmed dependencies. The focused comparison captures the changed modules, and the clean project comparison captures the broader build. GitHub runs the cross-project validation.

@greptile-apps

greptile-apps Bot commented Dec 6, 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.

[Low impact] No actionable issue was found in the three proof refactors.

RetriggerView in Greptile

Summary

Changes proof bodies in three SmoothedOctagon modules without changing their public statements or mathematical definitions.

  • Costate identities reduce with smaller algebra steps.
  • The lower-ratio endpoint proof reuses one cleared derivative formula.
  • Upper-strip boundary formulas come from a checked rational grid.

No actionable issues were found. Performance figures come from the PR description; builds and memory measurements were not repeated. The project card and headline statements were checked for consistency with this proof-only scope. External source and license claims were not independently reverified.

Reviews (1) · Last reviewed commit: "Reduce SmoothedOctagon peak compiler mem..." · Reviewed by Greptile

@github-actions

github-actions Bot commented Dec 6, 2026

Copy link
Copy Markdown
Contributor

Proof profile (new / modified Lean files)

Statement changes

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

Also: 8 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 (8)
  • SmoothedOctagon.S0Outer.Boundaries.map_coefficientUpper2 — LeanPool/SmoothedOctagon/Exclusion/Mixed/SmallerShort/LargeRatio/OuterFace/Strip/Boundaries/Polynomials.lean
  • SmoothedOctagon.S0Outer.Boundaries.map_coefficientUpper8 — LeanPool/SmoothedOctagon/Exclusion/Mixed/SmallerShort/LargeRatio/OuterFace/Strip/Boundaries/Polynomials.lean
  • SmoothedOctagon.S0Outer.Boundaries.map_coefficientUpperT — LeanPool/SmoothedOctagon/Exclusion/Mixed/SmallerShort/LargeRatio/OuterFace/Strip/Boundaries/Polynomials.lean
  • SmoothedOctagon.S0Outer.Boundaries.valueUpper2_rational_samples — LeanPool/SmoothedOctagon/Exclusion/Mixed/SmallerShort/LargeRatio/OuterFace/Strip/Boundaries/Polynomials.lean
  • SmoothedOctagon.S0Outer.Boundaries.valueUpper8_rational_samples — LeanPool/SmoothedOctagon/Exclusion/Mixed/SmallerShort/LargeRatio/OuterFace/Strip/Boundaries/Polynomials.lean
  • SmoothedOctagon.S0Outer.Boundaries.valueUpperT_rational_samples — LeanPool/SmoothedOctagon/Exclusion/Mixed/SmallerShort/LargeRatio/OuterFace/Strip/Boundaries/Polynomials.lean
  • SmoothedOctagon.S0Outer.Boundaries.valueUpper_eq_of_grid — LeanPool/SmoothedOctagon/Exclusion/Mixed/SmallerShort/LargeRatio/OuterFace/Strip/Boundaries/Polynomials.lean
  • SmoothedOctagon.lro_F0u_add_sixth — LeanPool/SmoothedOctagon/Exclusion/Mixed/SmallerShort/LowerRatio/OuterFace/SmallShape/TestZero1.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: 671,720 → 856,324 (+184,604, +27.5%). Commands: 31 → 38.

Per-file wall sum: 68.0 s → 88.5 s (+30.1%). 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/SmoothedOctagon/Exclusion/Mixed/SmallerShort/LargeRatio/OuterFace/Strip/Boundaries/Polynomials.lean +168/-21 671,720 856,324 +184,604 +27.5% 67.97 88.46
Total +168/-21 671,720 856,324 +184,604 +27.5% 68.0 88.5

New files — absolute profile

Total heartbeats: 249,088 maxHeartbeats units across 1 valid file (64 added LOC).

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

Count-heartbeats wall-clock total: 44.29 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/SmoothedOctagon/Exclusion/Mixed/SmallerShort/LowerRatio/OuterFace/SmallShape/TestZero1.lean 31 249,088 44.29 — — — 12 0
LeanPool/SmoothedOctagon/SmoothedPolygons/Ch7/StrongTransversality/Costate.lean 33 — — — — — 48 1
Total 64 249,088 44.29 — — — 60 1

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 accepted at 4c901684, pending required CI and the configured review.

  • The three proof changes preserve the existing declarations. The structural audit confirms 31,075 existing declarations, with seven changed proof terms and 11 added private declarations. The boundary proof uses an exact rational grid and checks the degree bounds before transporting the identities to the reals.
  • The normal clean runs measured a 16.0% lower highest sampled per-compiler memory peak and a 2.0% shorter build, with a 2.3% higher concurrent peak. Both normal build comparisons for Polynomials.lean showed lower wall time and memory. The instrumented GitHub profile measured 27.5% more heartbeats in that file, mainly in the added degree and grid checks. I weighed that cost against both normal-build measurements and kept the grid proof.
  • The instrumented Costate profile hits its per-command limit on both base and head. It therefore gives no paired heartbeat result for that file. The clean and focused builds both measured a substantial reduction in Costate compiler memory. Hosted profile

The required build now passes. I kept the checked-in costate proof after reading the configured review. Its grind callback relies on the pinned tactic’s context and compiles in the required build. The direct certificate is easier to read, but the configured review measured higher focused peak RSS for that version. The callback is a maintenance concern. I found no proof or build defect at this head.

@Vilin97

Vilin97 commented Dec 6, 2026

Copy link
Copy Markdown
Collaborator Author

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

Reviewed head: 4c9016848de2f1a3eb56d7b667475e28f9fd9710

Verdict: 🛑 request_changes

The refactor checks the three upper-strip expansions on an exact rational grid, shares one denominator-clearing lemma across four lower-ratio endpoint expansions, and changes the polynomial checks in the costate proof. All three changed modules passed a targeted Lake build. The boundary module compiled faster and used less peak RSS in a local base-to-head comparison, and /profile recorded 27.5% more heartbeats for it. Synchronous profiling of Costate timed out on both revisions.

Aspect Value
Scope proof compilation refactor
Introduces tech debt 🛑 yes
Maintainability 🛑 regressed
Brittleness 🛑 more_brittle
Risk 🟡 medium

The shared lemmas improve reuse, and the upper-entry costate proof needs a direct check of the cleared equality before merge.

Findings (1)

  • brittle-automation — LeanPool/SmoothedOctagon/SmoothedPolygons/Ch7/StrongTransversality/Costate.lean:431
    The callback uses rename_i unequal and assumes grind has introduced the negation of the cleared equality as the last inaccessible hypothesis. The same linear_combination compiled directly after field_simp in a scratch copy. In the focused comparison, peak RSS was 2.74 GiB for the direct proof, 2.58 GiB for the submitted proof, and 3.99 GiB for the base. Apply the certificate directly to the equality and rerun the focused memory measurement.

Tokens: 6,836,097 in / 19,570 out · Tier: codex-subscription · Effort: xhigh · Billing: Codex subscription quota (no API credits) · Estimated cost: $27.6379 (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.
request_changes is an ask, not a close: of the reviewer's past request_changes verdicts, 39% were merged after a human looked. Read the findings before acting on the verdict.

@Vilin97
Vilin97 added this pull request to the merge queue Dec 6, 2026
Merged via the queue into main with commit dfe0ec8 Dec 6, 2026
26 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