Skip to content

Conversation

@kim-em
Copy link
Collaborator

@kim-em kim-em commented Nov 26, 2025

This PR parallelizes exact? and apply?.

  • Use MetaM.parIterWithCancel to try all candidate lemmas in parallel while preserving deterministic result ordering
  • When a complete solution is found, remaining tasks are cancelled and the result is returned immediately
  • Removes old sequential tryOnEach implementation and heartbeat-based abortion mechanism

🤖 Generated with Claude Code

@kim-em kim-em requested a review from leodemoura as a code owner November 26, 2025 02:38
@github-actions github-actions bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Nov 26, 2025
@leanprover-community-bot
Copy link
Collaborator

leanprover-community-bot commented Nov 26, 2025

Mathlib CI status (docs):

  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase e1f8c147e72504b88f7275005df32e892e19a08b --onto b0e6db322421ce368999f08870fd747e45242f86. You can force Mathlib CI using the force-mathlib-ci label. (2025-11-26 03:35:29)
  • ✅ Mathlib branch lean-pr-testing-11369 has successfully built against this PR. (2025-11-26 06:08:56) View Log
  • ✅ Mathlib branch lean-pr-testing-11369 has successfully built against this PR. (2025-12-02 09:43:26) View Log

@leanprover-bot
Copy link
Collaborator

leanprover-bot commented Nov 26, 2025

Reference manual CI status:

  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase e1f8c147e72504b88f7275005df32e892e19a08b --onto d3dda9f6d4428a906c096067ecb75e432afc4615. You can force reference manual CI using the force-manual-ci label. (2025-11-26 03:35:31)
  • ❗ Reference manual CI can not be attempted yet, as the nightly-testing-2025-11-25 tag does not exist there yet. We will retry when you push more commits. If you rebase your branch onto nightly-with-manual, reference manual CI should run now. You can force reference manual CI using the force-manual-ci label. (2025-11-26 05:04:36)
  • ❗ Reference manual CI can not be attempted yet, as the nightly-testing-2025-12-01 tag does not exist there yet. We will retry when you push more commits. If you rebase your branch onto nightly-with-manual, reference manual CI should run now. You can force reference manual CI using the force-manual-ci label. (2025-12-02 08:39:50)

@kim-em kim-em force-pushed the parallel-library-search branch from d2be87c to 53ec504 Compare November 26, 2025 04:06
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Nov 26, 2025
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4-nightly-testing that referenced this pull request Nov 26, 2025
@kim-em kim-em marked this pull request as draft November 26, 2025 05:28
@kim-em
Copy link
Collaborator Author

kim-em commented Nov 26, 2025

It's not clear this is a win. The overhead of parallelisation could easily exceed the gains. Measurements (perhaps with chunking?) are probably warranted.

@leanprover-community-bot leanprover-community-bot added the builds-mathlib CI has verified that Mathlib builds against this PR label Nov 26, 2025
kim-em and others added 3 commits December 2, 2025 18:22
This PR adds optional chunking support to the `par` and `par'` functions in
`Lean.Elab.Parallel` for CoreM, MetaM, TermElabM, and TacticM. This reduces
task creation overhead when there are many small jobs by grouping them into
chunks that run sequentially within each parallel task.

New optional parameters:
- `maxTasks : Nat := 0` - Maximum number of parallel tasks (0 = no limit)
- `minChunkSize : Nat := 1` - Minimum jobs per chunk

Example: With 1000 jobs and `maxTasks := 128, minChunkSize := 8`:
- Chunk size = max(8, ceil(1000/128)) = 8
- Creates ~125 parallel tasks instead of 1000

Default behavior (maxTasks = 0) is unchanged - one task per job.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Add `parIterWithCancelChunked` functions for CoreM, MetaM, TermElabM, and TacticM that support chunking jobs into groups to reduce task creation overhead.

The original `parIterWithCancel` functions remain unchanged for backward compatibility. The new chunked variants accept `maxTasks` and `minChunkSize` parameters to control parallelism.

This enables PRs that use `parIterWithCancel` (like parallel library search and rewrites) to benefit from chunking by switching to the new `parIterWithCancelChunked` function with `maxTasks := 128`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Use `MetaM.parIterWithCancel` to try all candidate lemmas in parallel
while preserving deterministic result ordering. When a complete solution
is found, remaining tasks are cancelled and the result is returned
immediately.

This removes the old sequential `tryOnEach` implementation along with
the heartbeat-based abortion mechanism (`abortSpeculation`,
`mkHeartbeatCheck`).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@kim-em kim-em force-pushed the parallel-library-search branch 2 times, most recently from f012657 to 4713811 Compare December 2, 2025 07:42
@kim-em kim-em changed the base branch from master to nightly-with-mathlib December 2, 2025 07:43
@kim-em kim-em force-pushed the parallel-library-search branch from 5563a75 to 4713811 Compare December 2, 2025 07:46
@kim-em kim-em added changelog-tactics User facing tactics and removed builds-mathlib CI has verified that Mathlib builds against this PR toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN labels Dec 2, 2025
@github-actions github-actions bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Dec 2, 2025
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Dec 2, 2025
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4-nightly-testing that referenced this pull request Dec 2, 2025
@leanprover-community-bot leanprover-community-bot added the builds-mathlib CI has verified that Mathlib builds against this PR label Dec 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

builds-mathlib CI has verified that Mathlib builds against this PR changelog-tactics User facing tactics toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants