-
Notifications
You must be signed in to change notification settings - Fork 9
Native Gateset
If you are on a 64 bit macOS or Linux, you can install via pip3 install search_compiler[native]
. As of version 1.2.0, the Rust code should be installed automatically when you install search_compiler
.
On Linux or MacOS, you can also build and install scrs from source using a system installation of openblas
.
- Install the blas library if needed. If you want to use Apple Accelerate, it should come with macOS. For openblas,
on Debian based Linux distros you will need to install
libopenblas-dev
. You will also need thelibgfortran-<version>-dev
package (for whatever version your distro supplies). For openblas on macOS, you can install these via Homebrew asbrew install openblas gcc
. - Install rustup via https://rustup.rs. The defaults for platform should be fine.
- Switch to the nightly toolchain using
rustup default nightly
. You may need to dosource ~/.cargo/env
first. - If you are not using openblas, uncomment the corresponding line in the
pyproject.toml
file for Accelerate or MKL. In thenative/
directory runpip install .
Make sure the version of pip you have is at least 20.0.2. You can check viapip -V
. - Done! You should now be able to use the any of the
*_SolverNative
solvers fromsearch_compiler.solver
. Verify your install is working by runningpython3 -c 'import search_compiler_rs'
On Linux, you can also build wheels with Docker, staticly linking a custom built openblas
.
Incidently, this is how the packages on PyPi are built.
- Install docker https://docs.docker.com/install/
- Run the container to build wheels:
docker run --rm -v $(pwd):/io ethanhs/maturin-manylinux-2010:0.1 build --cargo-extra-args="--no-default-features --features static" --release --manylinux 2010
- Install the correct wheel for your Python version in
native/target/wheels
(e.g.scrs-0.6.0-cp37-cp37m-manylinux2010_x86_64.whl
for Python 3.7)
You can use the native gateset in order to achieve significantly faster synthesis speeds.
A "supported gateset" is one that uses only some combination of constant gates, QiskitU3QubitStep
, XZXZPartialQubitStep
, and ZXZXZQubitStep
. Currently if you use any of the
following solvers with a supported gateset, you should get the speed advantage. These solvers will be chosen automatically when available if the default solver setting has not been overridden:
COBYLA_SolverNative
BFGS_Jac_SolverNative
LeastSquares_Jac_SolverNative
import search_compiler as sc
# Use with a project (remember to use the default sc.QubitCNOTLinear() gateset or one that uses only supported gates)
p = sc.Project("myproject")
p["solver"] = sc.solver.LeastSquares_Jac_SolverNative()
# Use with SearchCompiler directly
compiler = sc.SearchCompiler(solver=sc.solver.LeastSquares_Jac_SolverNative())