The qsub
package is a Python framework designed for expressing complex quantum algorithms and predicting their costs. At the heart of qsub
is the SubroutineModel
class, which facilitates the hierarchical construction of algorithms. Users can build algorithms by linking together various subroutines and profiling their overall cost.
-
Clone the Repository:
git clone [email protected]:zapatacomputing/qsub.git
-
Navigate to the Cloned Directory:
cd qsub
-
Install the Package:
pip install .
Alternatively, if you're actively developing the package and want to install it in editable mode:
pip install -e .
-
Verify Installation: You can verify that the package has been installed correctly by importing it in a Python interpreter or script:
python >>> import qsub
These steps assume that you have Python and pip installed on your system. If not, please install Python from python.org and follow the instructions to install pip.
Here's a quick example to get you started:
from qsub.quantum_algorithms.general_quantum_algorithms.amplitude_estimation import (
QuantumAmplitudeEstimation,
)
# Initialize your algorithm
amp_est = QuantumAmplitudeEstimation()
# Set requirements
estimation_error = 0.001
failure_tolerance = 0.01
amp_est.set_requirements(
estimation_error=estimation_error,
failure_tolerance=failure_tolerance,
)
# Run the profile for this subroutine
amp_est.run_profile()
amp_est.print_profile()
print("qubits =", amp_est.count_qubits())
print(amp_est.count_subroutines())
For more complex scenarios, see the examples directory.
SubroutineModel
: Core class for creating and managing subroutines.- Cost Analysis Tools: Tools for profiling the cost and resource requirements of algorithms.
- Flexible Subroutine Integration: Easily swap and integrate different subroutines.
We welcome contributions! If you're interested in adding more subroutines or enhancing the framework, please follow these steps:
- Fork the repository.
- Create your feature branch (
git checkout -b feature/AmazingFeature
). - Add file(s) with your chages (
git add path/to/file_1 path/to/file_2
). - Commit your changes (
git commit -m 'commit message'
). - Push to the branch (
git push origin feature/AmazingFeature
). - Open a Pull Request.
First, install development dependencies with
pip install -e '.[dev]'
Then, to run tests, execute the commmand:
pytest tests