Skip to content
This repository has been archived by the owner on Apr 25, 2024. It is now read-only.

Parallel prover implementation for APRProofs #727

Open
wants to merge 188 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 161 commits
Commits
Show all changes
188 commits
Select commit Hold shift + click to select a range
b21b2fd
Add interface for Proof and Prover class, test prove_parallel impleme…
nwatson22 Oct 31, 2023
f9aaba4
Merge branch 'master' into noah/parallel-prover
nwatson22 Oct 31, 2023
31e3a95
Merge f9aaba4dd881dc10f1c8f417083aaa8c9e4169b3 into 12c67b1f9458595ea…
nwatson22 Oct 31, 2023
71eb0a3
Set Version: 0.1.489
Oct 31, 2023
fa0f4d0
Keep track of begun nodes
nwatson22 Oct 31, 2023
2f45ff4
Merge branch 'noah/parallel-prover' of https://github.com/runtimeveri…
nwatson22 Oct 31, 2023
f644aec
Separate new Prover/Proof interface from existing classes
nwatson22 Nov 1, 2023
3dea9e4
Merge f644aecbc250bfbc8905bf0d472f53f5e833bb40 into f7283bae60c9ec530…
nwatson22 Nov 1, 2023
de48482
Set Version: 0.1.490
Nov 1, 2023
06438ec
Change interface to use return steps from commit
nwatson22 Nov 1, 2023
c4a4c5a
Merge branch 'noah/parallel-prover' of https://github.com/runtimeveri…
nwatson22 Nov 1, 2023
3ddda2d
Simplify TreeExploreProver
nwatson22 Nov 1, 2023
68bd89d
Use steps
nwatson22 Nov 2, 2023
34d2442
Update to match new interface plan
nwatson22 Nov 3, 2023
76e239b
Add testing module
nwatson22 Nov 4, 2023
a60290c
Change interface to use ProofStep
nwatson22 Nov 6, 2023
1d3b9af
Add documentation comments, assertions and tests for TreeExploreProve…
nwatson22 Nov 7, 2023
89527d3
Update src/pyk/proof/parallel.py
nwatson22 Nov 7, 2023
a064486
Update src/tests/integration/proof/test_parallel_prove.py
nwatson22 Nov 7, 2023
5132864
Update src/tests/integration/proof/test_parallel_prove.py
nwatson22 Nov 7, 2023
62ac147
Merge branch 'master' into noah/parallel-prover
nwatson22 Nov 7, 2023
05f8d56
Merge 62ac14736b215c604551ae916f767fea7aaaca5c into 11ec5230566ec2b83…
nwatson22 Nov 7, 2023
9517856
Set Version: 0.1.492
Nov 7, 2023
08c0e81
Remove unused import
nwatson22 Nov 7, 2023
2c5b42f
Address comments
nwatson22 Nov 7, 2023
ff9d0c8
Remove unused typevar
nwatson22 Nov 7, 2023
c8072a4
Address comments
nwatson22 Nov 7, 2023
9bd1e71
Merge c8072a49d0dde5f5c10ffe5e941f090feb917e1c into 263f2f58fb07a772d…
nwatson22 Nov 7, 2023
fdb4233
Set Version: 0.1.493
Nov 7, 2023
ae3aa28
Merge branch 'master' into noah/parallel-prover
nwatson22 Nov 8, 2023
4057a69
Merge ae3aa28a716bc4d21588051237e6baa9285d4294 into fd2cd65b01919ac60…
nwatson22 Nov 8, 2023
7a63164
Set Version: 0.1.494
Nov 8, 2023
296e6f8
Address comments
nwatson22 Nov 9, 2023
6e47134
Merge branch 'noah/parallel-prover' of https://github.com/runtimeveri…
nwatson22 Nov 9, 2023
6a9d3b5
Merge 6e471343e6096866307ba0af38d96bd33e5cf5e7 into edc297774f4ce99d4…
nwatson22 Nov 9, 2023
7945c7e
Set Version: 0.1.495
Nov 9, 2023
a95458b
Remove log messages
nwatson22 Nov 9, 2023
b991065
Merge branch 'noah/parallel-prover' of https://github.com/runtimeveri…
nwatson22 Nov 9, 2023
7c8c538
Fix formatting
nwatson22 Nov 9, 2023
17ea417
Add APRProof/Prover implementations of Prover interface
nwatson22 Nov 9, 2023
544962e
Merge branch 'noah/parallel-prover' into noah/experimental
nwatson22 Nov 9, 2023
4445d29
Address comments
nwatson22 Nov 9, 2023
0cda3c4
Fix working with multiple proofs at once
nwatson22 Nov 10, 2023
a3c210f
Add missing requirements for status
nwatson22 Nov 10, 2023
366e89e
Improve typing on prove_parallel
nwatson22 Nov 10, 2023
199e46f
Add fail_fast and max_iterations, and tests for these
nwatson22 Nov 10, 2023
0d7e523
Remove test cases
nwatson22 Nov 10, 2023
5777bc6
Add to AprProofStep exec
nwatson22 Nov 10, 2023
f293736
Merge noah/parallel-prover into branch
nwatson22 Nov 10, 2023
c65709a
Merge branch 'master' into noah/parallel-prover
nwatson22 Nov 10, 2023
7799541
Merge c65709a0353b7618cb0b113abbf3d78bdc69ecd8 into dd40fd82582773603…
nwatson22 Nov 10, 2023
e659928
Set Version: 0.1.497
Nov 10, 2023
c2744a5
Fix possibility of TreeExloreProof to switch status after passing/fai…
nwatson22 Nov 10, 2023
ed26199
Merge branch 'noah/parallel-prover' of https://github.com/runtimeveri…
nwatson22 Nov 10, 2023
536d0cf
Merge branch 'noah/parallel-prover' into noah/experimental
nwatson22 Nov 10, 2023
8ba6f63
Merge branch 'master' into noah/parallel-prover
nwatson22 Nov 13, 2023
543d911
Merge 8ba6f630ccf747182e8145c2e08ed31f2ff8e77b into 91c78ef6eaa9e6ee9…
nwatson22 Nov 13, 2023
4c22193
Set Version: 0.1.499
Nov 13, 2023
95f230b
Merge branch 'noah/parallel-prover' into noah/experimental
nwatson22 Nov 13, 2023
0f5a6b3
Add APRProver Implementations
nwatson22 Nov 14, 2023
1950f60
Create interface for ProcessData
nwatson22 Nov 14, 2023
2436234
Switch to using 1 server per prover and sharing between threads, init…
nwatson22 Nov 14, 2023
a3db6ee
Parameterize imp parallel tests, add test to catch check_terminal ord…
nwatson22 Nov 16, 2023
5b86dfb
Fix check_terminal bug
nwatson22 Nov 16, 2023
923a8d7
Remove parameters fromm prove_parallel and make shutdown() into destr…
nwatson22 Nov 17, 2023
75e955d
Merge master into branch
nwatson22 Nov 17, 2023
640e3ee
Merge master into branch
nwatson22 Nov 17, 2023
66d321a
Merge 640e3eeb66c87eb5b345d380c4c92e4604156dc3 into 314a6603716d96c9e…
nwatson22 Nov 17, 2023
a682b22
Set Version: 0.1.505
Nov 17, 2023
1f46262
Add ParallelAPRBMCProver
nwatson22 Nov 17, 2023
e029479
Display profiling information
nwatson22 Nov 17, 2023
26e162f
Merge e029479a9e695b6c1b684151114e986e95f35a46 into 714e709aaae4fb441…
nwatson22 Nov 17, 2023
5b82535
Set Version: 0.1.506
Nov 17, 2023
b7cd7e1
Reduce subsumption checking
nwatson22 Nov 18, 2023
daaf030
Merge branch 'noah/apr-proof-parallel' of https://github.com/runtimev…
nwatson22 Nov 18, 2023
fc4bf6d
Merge daaf030160f0efcc6b10bf441d20203c842af126 into 5d9e84673c79f2bad…
nwatson22 Nov 18, 2023
fcd2d14
Set Version: 0.1.507
Nov 18, 2023
426486d
Fix formatting
nwatson22 Nov 18, 2023
66220d8
Merge branch 'noah/apr-proof-parallel' of https://github.com/runtimev…
nwatson22 Nov 18, 2023
e85a70c
Profile cterm_implies and extend_cterm in ParallelAPRProver
nwatson22 Nov 20, 2023
5de5299
Use Process and Queue to keep data between workers on the same process
nwatson22 Nov 20, 2023
1e7be75
Merge 5de5299ea94dcbac366f93d852dd0319a3c5f56e into f6c9126b05d7f1e7f…
nwatson22 Nov 20, 2023
caec071
Set Version: 0.1.508
Nov 20, 2023
53431a5
Fix time calculation
nwatson22 Nov 20, 2023
57cdf34
Merge branch 'noah/apr-proof-parallel' of https://github.com/runtimev…
nwatson22 Nov 20, 2023
b86f9d8
Dont consider terminal nodes failling
nwatson22 Nov 21, 2023
d9bf236
make node failing different from node terminal. a node is failing onc…
nwatson22 Nov 21, 2023
9da8fa9
Use 1 server per prover per thread
nwatson22 Nov 21, 2023
a9cc7e5
Merge master into branch
nwatson22 Nov 22, 2023
7f8981f
Merge a9cc7e532285ab358d5ee44f0c759684d0ea5696 into 0535c6b136a08b905…
nwatson22 Nov 22, 2023
5c105ca
Set Version: 0.1.511
Nov 22, 2023
81958c5
Add cleanup method to ProcessData
nwatson22 Nov 22, 2023
10e6391
Merge branch 'noah/apr-proof-parallel' of https://github.com/runtimev…
nwatson22 Nov 22, 2023
04bfed1
Add checked attribute to printer
nwatson22 Nov 22, 2023
f83dc88
Merge remote-tracking branch 'origin/master' into update-apr-proof-pa…
h0nzZik Dec 3, 2023
c057b3a
Merge f83dc88ecc05d8c661bebf69b1460359e1e54a68 into 04bfed1f4dbe0df52…
h0nzZik Dec 3, 2023
83b87c6
Set Version: 0.1.512
Dec 3, 2023
174d0ad
Merge remote-tracking branch 'origin/master' into update-apr-proof-pa…
h0nzZik Dec 12, 2023
7a7d965
Merge 174d0adc0a4253f295fd82e7d9c41f783fbe6ffb into 04bfed1f4dbe0df52…
h0nzZik Dec 12, 2023
4354d19
Set Version: 0.1.512
Dec 12, 2023
a5bd37f
fix a typo
h0nzZik Dec 12, 2023
d3eee58
Merge a5bd37f065b8bc63a226a96db0d9723032707ba1 into f9a2da504dd4d4b36…
nwatson22 Dec 12, 2023
c977298
Set Version: 0.1.544
Dec 12, 2023
fdfd752
Update noah/apr-proof-parallel with support of dependencies between p…
h0nzZik Dec 18, 2023
af9b608
Merge branch 'master' into noah/apr-proof-parallel
h0nzZik Dec 18, 2023
b0d8a4a
Merge branch 'master' into noah/apr-proof-parallel
h0nzZik Dec 18, 2023
7719405
Merge branch 'master' into noah/apr-proof-parallel
nwatson22 Dec 19, 2023
5b71610
Merge 771940531add662143ebb59b4e0ae7beb200c5d2 into f9c0c63d2e25ba22e…
nwatson22 Dec 19, 2023
cc271a4
Set Version: 0.1.556
Dec 19, 2023
75932a2
Merge branch 'master' into noah/apr-proof-parallel
h0nzZik Dec 19, 2023
7fde3d2
Merge 75932a2ae3f6b70428be2e7b55c662592398d644 into 4f31ecff518dd5aa4…
nwatson22 Dec 19, 2023
ef08872
Set Version: 0.1.558
Dec 19, 2023
316abe3
Merge branch 'master' into noah/apr-proof-parallel
nwatson22 Dec 19, 2023
eeeefac
Merge 316abe37a8ba4bf1ece6e519465297b60b720c15 into a2e14f0f48381034e…
nwatson22 Dec 19, 2023
18f370a
Set Version: 0.1.559
Dec 19, 2023
6bd6845
Merge master into branch
nwatson22 Jan 25, 2024
d6f628d
Merge 6bd68452b5fe9d577ecf020e123e2e515f7a70a3 into afb5306f1bcf135bf…
nwatson22 Jan 25, 2024
02836d3
Set Version: 0.1.596
Jan 25, 2024
daa74a5
Update module adding
nwatson22 Jan 25, 2024
0f4e561
Merge branch 'noah/apr-proof-parallel' of https://github.com/runtimev…
nwatson22 Jan 25, 2024
cccc706
Use single server
nwatson22 Jan 26, 2024
3d69680
Fix too many servers being started
nwatson22 Jan 26, 2024
6d95c12
Work on debugging parallel prover crash
nwatson22 Jan 30, 2024
2b62e41
Merge master into branch
nwatson22 Jan 30, 2024
59d77a8
Merge 2b62e41b0bc55b7844e66dfc0b9a6762892ace0c into ac44eb6918ba9abf0…
nwatson22 Jan 30, 2024
2378e88
Set Version: 0.1.605
Jan 30, 2024
be877a3
Clean up
nwatson22 Feb 3, 2024
518273d
Merge branch 'noah/apr-proof-parallel' of https://github.com/runtimev…
nwatson22 Feb 3, 2024
6e7dde5
Clean up
nwatson22 Feb 3, 2024
f53b0a9
Clean up
nwatson22 Feb 3, 2024
7307862
Clean up
nwatson22 Feb 3, 2024
9eaf1a2
Merge master into branch
nwatson22 Feb 3, 2024
d2b484d
Merge 9eaf1a24adfa959e06e431455936c2b71ebc7456 into 4493d41e3d24de34c…
nwatson22 Feb 3, 2024
31dcc46
Set Version: 0.1.613
Feb 3, 2024
597d280
Fix formatting
nwatson22 Feb 5, 2024
66a6dfa
Merge branch 'noah/apr-proof-parallel' of https://github.com/runtimev…
nwatson22 Feb 5, 2024
9f30962
Clean up parallel.py
nwatson22 Feb 5, 2024
f16161d
Clean up reachability.py
nwatson22 Feb 6, 2024
95f560d
Remove extra inject_modules
nwatson22 Feb 7, 2024
b4ae907
Revert formatting changes with specific black version
nwatson22 Feb 7, 2024
7bb8775
Revert changes relating to newer flake8-bugbear changes
nwatson22 Feb 7, 2024
dc4d66d
Revert poetry.lock
nwatson22 Feb 7, 2024
4d67d17
Revert changes relating to newer flake8-bugbear changes
nwatson22 Feb 7, 2024
39b7cb1
Revert changes relating to newer flake8-bugbear changes
nwatson22 Feb 7, 2024
ab95cbe
Remove unnecessary class
nwatson22 Feb 8, 2024
3476c15
Remove print messages
nwatson22 Feb 8, 2024
58f865b
Encapsulate profiling info for parallel_prove
nwatson22 Feb 8, 2024
21c1679
Remove commented lines
nwatson22 Feb 8, 2024
c1dbe97
Remove commented lines
nwatson22 Feb 8, 2024
3330c1c
Merge master into branch
nwatson22 Feb 8, 2024
48039a4
Merge 3330c1ca4d6f4f1e9e135e0df2016defe31cd4d5 into 03ea742571765dc45…
nwatson22 Feb 8, 2024
215514e
Set Version: 0.1.618
Feb 8, 2024
e43535c
Integrate max_iterations into APRParallelProver
nwatson22 Feb 8, 2024
e8123c1
Merge branch 'noah/apr-proof-parallel' of https://github.com/runtimev…
nwatson22 Feb 8, 2024
a8e5041
Fix test case
nwatson22 Feb 8, 2024
37df3d1
Implement fail_fast
nwatson22 Feb 8, 2024
1bcab8b
Merge 37df3d152766d50648dd076ea8932f9eb04c3e9a into e1519523721e84eec…
nwatson22 Feb 8, 2024
e0fda99
Set Version: 0.1.619
Feb 8, 2024
afde47c
Merge branch 'master' into noah/apr-proof-parallel
nwatson22 Feb 9, 2024
97460b2
Merge afde47c39960c9511a5cd9744fde0e2eb63c1bdc into e68db42142d1e03d2…
nwatson22 Feb 9, 2024
6c797c2
Set Version: 0.1.620
Feb 9, 2024
24a472f
Update src/pyk/proof/reachability.py
nwatson22 Feb 9, 2024
fd177cc
reimplement bmc checking for parallel proofs
nwatson22 Feb 10, 2024
d3d24a6
Merge branch 'noah/apr-proof-parallel' of https://github.com/runtimev…
nwatson22 Feb 10, 2024
238ffb0
Fix formatting
nwatson22 Feb 10, 2024
47bfa4a
Set haskell option in the tests
nwatson22 Feb 10, 2024
4c745a7
proof/reachability: inline BMC logic into APRProof and APRProver
ehildenb Feb 10, 2024
c155cdc
proof/{proof,show,__init__}: cleanup remaining references to BMC provers
ehildenb Feb 10, 2024
220bb7b
tests/unit/test_proof: update unit tests for unified BMC prover
ehildenb Feb 10, 2024
b8baa48
tests/integration/proof/test_imp: update for unified BMC prover
ehildenb Feb 10, 2024
5dda1cc
tests/integration/proof/test_goto: migrate to unified BMC prover
ehildenb Feb 10, 2024
d5ace85
Merge 5dda1cc36b45f85679e19059d9e1efdd7de19ce3 into e68db42142d1e03d2…
ehildenb Feb 10, 2024
c8ec74c
Set Version: 0.1.620
Feb 10, 2024
9a5ad26
proof/reachability: inline tiny method
ehildenb Feb 10, 2024
1a3dce6
Consolidate ParallelAPRBMCProver into ParallelAPRProver
nwatson22 Feb 12, 2024
76e1703
Merge 1a3dce65c029a0c922a9854ad6fb801ecd82041c into c33340c65005e17b0…
nwatson22 Feb 12, 2024
237a1c5
Set Version: 0.1.621
Feb 12, 2024
2abb345
Merge unify-bmc-prover into branch
nwatson22 Feb 13, 2024
4ab9d8f
Merge branch 'noah/apr-proof-parallel' of https://github.com/runtimev…
nwatson22 Feb 13, 2024
c70e967
Fix process data being locked to one instance for all proofs
nwatson22 Feb 14, 2024
10359d6
Merge master into branch
nwatson22 Feb 14, 2024
912e033
Merge 10359d6f12b9bf254b9011bc790fb837067d2245 into d7b42ff37b5054a6c…
nwatson22 Feb 14, 2024
f36524d
Set Version: 0.1.624
Feb 14, 2024
1d38ad7
Readd queues system
nwatson22 Feb 15, 2024
d94404e
Merge branch 'noah/apr-proof-parallel' of https://github.com/runtimev…
nwatson22 Feb 15, 2024
3a43525
Merge master into branch
nwatson22 Feb 15, 2024
f3ac4a0
Merge 3a435254f16f474623ff1579ba5284bd718deab6 into d7b05c1de94620720…
nwatson22 Feb 15, 2024
e545bd8
Set Version: 0.1.628
Feb 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
project = 'pyk'
author = 'Runtime Verification, Inc'
copyright = '2024, Runtime Verification, Inc'
version = '0.1.619'
release = '0.1.619'
version = '0.1.620'
release = '0.1.620'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
2 changes: 1 addition & 1 deletion package/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.619
0.1.620
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "pyk"
version = "0.1.619"
version = "0.1.620"
description = ""
authors = [
"Runtime Verification, Inc. <contact@runtimeverification.com>",
Expand Down
144 changes: 93 additions & 51 deletions src/pyk/proof/parallel.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
from __future__ import annotations

import time
from abc import ABC, abstractmethod
from concurrent.futures import CancelledError, ProcessPoolExecutor, wait
from dataclasses import dataclass
from multiprocessing import Process, Queue

# from concurrent.futures import CancelledError, ProcessPoolExecutor, wait
from typing import TYPE_CHECKING, Any, Generic, TypeVar

from pyk.proof.proof import ProofStatus

if TYPE_CHECKING:
from collections.abc import Iterable, Mapping
from concurrent.futures import Executor, Future


P = TypeVar('P', bound='Proof')
U = TypeVar('U')
D = TypeVar('D')


class Prover(ABC, Generic[P, U]):
class Prover(ABC, Generic[P, U, D]):
"""
Should contain all data needed to make progress on a `P` (proof).
May be specific to a single `P` (proof) or may be able to handle multiple.
Expand All @@ -28,7 +32,7 @@ class Prover(ABC, Generic[P, U]):
"""

@abstractmethod
def steps(self, proof: P) -> Iterable[ProofStep[U]]:
def steps(self, proof: P) -> Iterable[ProofStep[U, D]]:
"""
Return a list of `ProofStep[U]` which represents all the computation jobs as defined by `ProofStep`, which have not yet been computed and committed, and are available given the current state of `proof`. Note that this is a requirement which is not enforced by the type system.
If `steps()` or `commit()` has been called on a proof `proof`, `steps()` may never again be called on `proof`.
Expand Down Expand Up @@ -66,7 +70,7 @@ def status(self) -> ProofStatus:
...


class ProofStep(ABC, Generic[U]):
class ProofStep(ABC, Generic[U, D]):
"""
Should be a description of a computation needed to make progress on a `Proof`.
Must be hashable.
Expand All @@ -76,7 +80,7 @@ class ProofStep(ABC, Generic[U]):
"""

@abstractmethod
def exec(self) -> U:
def exec(self, data: D) -> U:
Copy link
Collaborator

Choose a reason for hiding this comment

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

My understanding is that data is fixed for a given run of prove_parallel. What's the advantage of providing data as an argument to exec and not in __init__ of the Prover implementation?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it is now fixed, but I'm still using at as a way to only pass in large objects to the worker threads once at the beginning. With the way you suggest is there a different way exec could get access to the data?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Prover instantiates ProofStep, so if Prover has access to data, then it can also pass it to ProofStep during instantiation. The exec method then reads data from its instance.

"""
Should perform some nontrivial computation given by `self`, which can be done independently of other calls to `exec()`.
Allowed to be nondeterministic.
Expand All @@ -85,59 +89,97 @@ def exec(self) -> U:
...


@dataclass
class ProfilingInfo:
total_commit_time = 0
total_steps_time = 0
total_wait_time = 0
total_time = 0


def prove_parallel(
proofs: Mapping[str, Proof],
provers: Mapping[str, Prover],
max_workers: int,
) -> Iterable[Proof]:
pending: dict[Future[Any], str] = {}
process_data: Any,
) -> tuple[Iterable[Proof], ProfilingInfo]:
explored: set[tuple[str, ProofStep]] = set()

def submit(proof_id: str, pool: Executor) -> None:
in_queue: Queue = Queue()
out_queue: Queue = Queue()

pending_jobs: int = 0

profile = ProfilingInfo()

total_init_time = time.time_ns()

def run_process(data: Any) -> None:
while True:
dequeued = in_queue.get()
if dequeued == 0:
break
proof_id, proof_step = dequeued
update = proof_step.exec(data)
out_queue.put((proof_id, update))

def submit(proof_id: str) -> None:
proof = proofs[proof_id]
prover = provers[proof_id]
for step in prover.steps(proof): # <-- get next steps (represented by e.g. pending nodes, ...)
steps_init_time = time.time_ns()
steps = prover.steps(proof)
profile.total_steps_time += time.time_ns() - steps_init_time
for step in steps: # <-- get next steps (represented by e.g. pending nodes, ...)
if (proof_id, step) in explored:
continue
explored.add((proof_id, step))
future = pool.submit(step.exec) # <-- schedule steps for execution
pending[future] = proof_id

with ProcessPoolExecutor(max_workers=max_workers) as pool:
for proof_id in proofs:
submit(proof_id, pool)

while pending:
done, _ = wait(pending, return_when='FIRST_COMPLETED')
future = done.pop()

proof_id = pending[future]
proof = proofs[proof_id]
prover = provers[proof_id]
try:
update = future.result()
except CancelledError as err:
raise RuntimeError(f'Task was cancelled for proof {proof_id}') from err
except TimeoutError as err:
raise RuntimeError(
f"Future for proof {proof_id} was not finished executing and timed out. This shouldn't happen since this future was already waited on."
) from err
except Exception as err:
raise RuntimeError('Exception was raised in ProofStep.exec() for proof {proof_id}.') from err

prover.commit(proof, update) # <-- update the proof (can be in-memory, access disk with locking, ...)

match proof.status:
# terminate on first failure, yield partial results, etc.
case ProofStatus.FAILED:
...
case ProofStatus.PENDING:
if not list(prover.steps(proof)):
raise ValueError('Prover violated expectation. status is pending with no further steps.')
case ProofStatus.PASSED:
if list(prover.steps(proof)):
raise ValueError('Prover violated expectation. status is passed with further steps.')

submit(proof_id, pool)
pending.pop(future)
return proofs.values()
in_queue.put((proof_id, step))
nonlocal pending_jobs
pending_jobs += 1

processes = [Process(target=run_process, args=(process_data,)) for _ in range(max_workers)]
for process in processes:
process.start()

for proof_id in proofs.keys():
submit(proof_id)

while pending_jobs > 0:
wait_init_time = time.time_ns()
proof_id, update = out_queue.get()
profile.total_wait_time += time.time_ns() - wait_init_time
pending_jobs -= 1

proof = proofs[proof_id]
prover = provers[proof_id]

commit_init_time = time.time_ns()
prover.commit(proof, update) # <-- update the proof (can be in-memory, access disk with locking, ...)
profile.total_commit_time += time.time_ns() - commit_init_time

match proof.status:
# terminate on first failure, yield partial results, etc.
case ProofStatus.FAILED:
...
case ProofStatus.PENDING:
steps_init_time = time.time_ns()
if not list(prover.steps(proof)):
raise ValueError('Prover violated expectation. status is pending with no further steps.')
profile.total_steps_time += time.time_ns() - steps_init_time
case ProofStatus.PASSED:
steps_init_time = time.time_ns()
if list(prover.steps(proof)):
raise ValueError('Prover violated expectation. status is passed with further steps.')
profile.total_steps_time += time.time_ns() - steps_init_time

submit(proof_id)

for _ in range(max_workers):
in_queue.put(0)

for process in processes:
process.join()

profile.total_time = time.time_ns() - total_init_time

return proofs.values(), profile
Loading
Loading