-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5366dea
commit f12f604
Showing
1 changed file
with
49 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,117 +1,83 @@ | ||
# Qamomile | ||
|
||
`Qamomile` is a transpiler from model written in [JijModeling]() to quantum optimization algorithms on variaous quantum platform. | ||
[](https://badge.fury.io/py/qamomile) | ||
 | ||
|
||
- [Qiskit](#qiskit) | ||
- [QURI-Parts](#quri-parts) | ||
Qamomile is a powerful SDK designed for quantum optimization algorithms, specializing in the conversion of mathematical models into quantum circuits. It serves as a bridge between classical optimization problems and quantum computing solutions. | ||
|
||
Documentation: [https://jij-inc.github.io/Qamomile/](https://jij-inc.github.io/Qamomile/) | ||
|
||
```mermaid | ||
graph LR | ||
JijModeling --> Instance | ||
subgraph JijModelingTranspiler | ||
Instance | ||
end | ||
subgraph Qiskit | ||
QSKT[Hamiltonian] | ||
QSKT --> QSKTCIRC[Q Circuit] --> QSKTR[Results] | ||
end | ||
subgraph Quri-Parts | ||
QP[Hamiltonian] | ||
QP --> QPCIRC[Q Circuit] --> QURIR[Results] | ||
end | ||
subgraph Qamomile | ||
Instance --> Encode | ||
Encode{Encode} | ||
Encode --> QH[Quantum Hamiltonian] | ||
end | ||
QH --> QSKT | ||
QH --> QP | ||
subgraph Qamomile | ||
QSKTR --> Decode{Decode} | ||
QURIR --> Decode | ||
end | ||
Decode --> Solutions | ||
``` | ||
## Features | ||
|
||
## Qiskit | ||
- **Versatile Compatibility**: Supports leading quantum circuit SDKs including Qiskit and QuriParts. | ||
- **Advanced Algorithm Support**: Implements sophisticated encoding and algorithms like QAOA and QRAO. | ||
- **Flexible Model Conversion**: Utilizes JijModeling for describing mathematical models and converting them to various quantum circuit SDKs. | ||
- **Intermediate Representation**: Capable of representing both Hamiltonians and quantum circuits as intermediate forms. | ||
- **Standalone Functionality**: Can implement quantum circuits independently, similar to other quantum circuit SDKs. | ||
|
||
[Qiskit](https://qiskit.org/) is an open-source SDK for working with quantum computers at the level of circuits, algorithms, and application modules. | ||
## Installation | ||
|
||
### Installation | ||
To install Qamomile, use pip: | ||
|
||
```bash | ||
pip install "qamomile[qiskit]" | ||
pip install qamomile | ||
``` | ||
|
||
### Quantum Approximate Optimization Algorithm (QAOA) | ||
|
||
```python | ||
import jijmodeling as jm | ||
import jijmodeling_transpiler as jmt | ||
import qamomile as qamo | ||
|
||
# Create model | ||
problem = jm.Problem("model") | ||
... # Modeling ... | ||
|
||
# Compile | ||
compiled_instance = jmt.compile_model(problem, instance_data, fixed_vars) | ||
|
||
# Transpile to QAOA of qikit | ||
qaoa_builder = qamo.qiskit.transpile_to_qaoa(compiled_instance) | ||
``` | ||
|
||
|
||
## QURI-Parts | ||
|
||
[QURI Parts](https://quri-parts.qunasys.com/) is an open source library suite for creating and executing quantum algorithms on various quantum computers and simulators. | ||
For optional dependencies: | ||
|
||
```bash | ||
pip install "qamomile[quri-parts]" | ||
pip install qamomile[qiskit] # For Qiskit integration | ||
pip install qamomile[quri-parts] # For QuriParts integration | ||
``` | ||
|
||
### Quantum Approximate Optimization Algorithm (QAOA) | ||
## Quick Start | ||
|
||
Here's a simple example of how to use Qamomile with QAOA: | ||
|
||
```python | ||
import jijmodeling as jm | ||
import jijmodeling_transpiler as jmt | ||
import qamomile as qamo | ||
from qamomile.core.qaoa import QAOAConverter | ||
from qamomile.qiskit.transpiler import QiskitTranspiler | ||
|
||
# Create model | ||
problem = jm.Problem("model") | ||
... # Modeling ... | ||
# Define QUBO problem | ||
Q = jm.Placeholder("Q", ndim=2) | ||
n = Q.len_at(0, latex="n") | ||
x = jm.BinaryVar("x", shape=(n,)) | ||
problem = jm.Problem("qubo") | ||
i, j = jm.Element("i", n), jm.Element("j", n) | ||
problem += jm.sum([i, j], Q[i, j] * x[i] * x[j]) | ||
|
||
# Compile | ||
compiled_instance = jmt.compile_model(problem, instance_data, fixed_vars) | ||
# Prepare instance data | ||
instance_data = {"Q": [[0.1, 0.2, -0.1], [0.2, 0.3, 0.4], [-0.1, 0.4, 0.0]]} | ||
|
||
# Transpile to QAOA of qikit | ||
qaoa_builder = qamo.quri.transpile_to_qaoa(compiled_instance) | ||
``` | ||
# Compile the problem | ||
compiled_instance = jmt.compile_model(problem, instance_data) | ||
|
||
# Create QAOA converter | ||
qaoa_converter = QAOAConverter(compiled_instance) | ||
|
||
## Contributing | ||
# Create Qiskit transpiler | ||
qiskit_transpiler = QiskitTranspiler() | ||
|
||
### Setup | ||
# Get QAOA circuit | ||
p = 2 # Number of QAOA layers | ||
qaoa_circuit = qaoa_converter.get_qaoa_ansatz(p) | ||
|
||
```bash | ||
pip install poetry | ||
poetry install --all-extras | ||
poetry shell | ||
# Convert to Qiskit circuit | ||
qiskit_circuit = qiskit_transpiler.transpile_circuit(qaoa_circuit) | ||
|
||
# ... (continue with quantum execution and result processing) | ||
``` | ||
|
||
### Test | ||
## Documentation | ||
|
||
```bash | ||
pytest tests | ||
``` | ||
For more detailed information, please refer to our [documentation](https://qamomile.readthedocs.io). | ||
|
||
## Contributing | ||
|
||
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for more details. | ||
|
||
## License | ||
|
||
Qamomile is released under the [Apache 2.0 License](LICENSE). |