Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reimplement QAlpha internals and expand benchmarking #159

Merged
merged 76 commits into from
Apr 2, 2024

Conversation

edenfrenkel
Copy link
Collaborator

@edenfrenkel edenfrenkel commented Feb 22, 2024

This pull request performs the following changes.

In inference:

  • Reimplement and reorganize the QAlpha code:
    • Rename subsume.rs -> language.rs, lemma.rs -> frame.rs, weaken.rs -> lemmas.rs, and move all QAlpha-related code into inference/src/qalpha.
    • Remove the Not language constructor and add dedicated constructors for And, Or, and quantification.
    • Define weakening recursively together with language construction.
    • Use the total order over canonical formulas to minimize sets.
  • Implement a custom parallelism scheme in parallel.rs:
    • Actually run threads / solvers simultaneously (with rayon this was often not the case). This also lead to some changes in solver/src/basics.rs, namely replacing rayon with standard library threading.
    • Allow prioritization of tasks, as well as adding tasks / cancelling remaining tasks mid-run.

In bounded:

  • In simulator.rs, implement two bounded simulators, one based on explicit-state (using set.rs) and another on SAT solving (using sat.rs), which given a universe size can produce all initial states, as well as all successors of a given state.
  • Implement dynamic solvers which can handle multiple universe sizes.
  • Expand the preprocessing in fly/src/rets.rs by implementing flattening to eliminate nested function applications.
  • Perform some minor changes, mainly to do with typing / lifetimes, to enable the above.
  • Use the above to replace the SMT-based simulations in QAlpha.

In benchmarking:

  • Add QAlpha benchmarks.
  • Add more detailed reporting, and save the stdout and stderr of each run.

edenfrenkel and others added 30 commits February 21, 2024 19:23
To avoid cloning terms, the previous implementation used a single shared vector of atoms (terms) which could be indexed by many parts of the algorithm, so that atoms could be represented by integer indices. However, this indirection creates an overcomplication and doesn't seem to have any effect in practice. Also, terms are still cloned many times even in the previous implementation, which means it would make little difference anyhow. Another consideration is that Ord, Eq and Hash implementations for Terms might be less efficient than for usize indices; however, this too seems to have no empirical effect.

Signed-off-by: edenfrenkel <[email protected]>
This replaces the ad-hoc implementations for each case (CNF/DNF/pDNF), and is more scalable, safe and easy to test, as well as being more systematic theoretically.

Signed-off-by: edenfrenkel <[email protected]>
Due to the use of rayon's parallel iterators and the way they prioritize tasks, the previous implementation of parallel solvers rarely ever ran the solvers concurrently, but almost always used the first one in the vector. This change fixes that by using `thread::scope` instead.

Signed-off-by: edenfrenkel <[email protected]>
Signed-off-by: edenfrenkel <[email protected]>
Also modifies parallelism and simulations infrastructure.

Signed-off-by: edenfrenkel <[email protected]>
Signed-off-by: edenfrenkel <[email protected]>
Signed-off-by: Tej Chajed <[email protected]>
Signed-off-by: Tej Chajed <[email protected]>
Signed-off-by: edenfrenkel <[email protected]>
Signed-off-by: edenfrenkel <[email protected]>
Signed-off-by: edenfrenkel <[email protected]>
Signed-off-by: edenfrenkel <[email protected]>
Signed-off-by: edenfrenkel <[email protected]>
Signed-off-by: edenfrenkel <[email protected]>
@edenfrenkel edenfrenkel marked this pull request as ready for review February 22, 2024 17:31
edenfrenkel and others added 6 commits February 22, 2024 20:12
Signed-off-by: edenfrenkel <[email protected]>
The upstream CVC4/CVC4 repo has been removed, which is where we were
getting the 1.8 binary release.
This commit also collapses all time-limit parameters into one, and removes the unsused scalability tests.

Signed-off-by: edenfrenkel <[email protected]>
@tchajed
Copy link
Collaborator

tchajed commented Apr 1, 2024

If this is at a stable point, let's merge it. It's too big to review at this point so I'd rather merge it now and start splitting up future features when possible.

@edenfrenkel
Copy link
Collaborator Author

I agree, you can go ahead and merge

@tchajed tchajed added this pull request to the merge queue Apr 2, 2024
Merged via the queue into main with commit 5a16ff0 Apr 2, 2024
2 checks passed
@tchajed tchajed deleted the qalpha-simulations branch April 2, 2024 12:06
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.

2 participants