Reduce QUBO/Hamiltonian (exact reduction). Source code for the paper 'FastHare: Fast Hamiltonian Reduction for Large-scale Quantum Annealing, IEEE Int. Conf. on Quantum Computing and Engineering (QCE) 2022' https://arxiv.org/abs/2205.05004
Project description
Python Interface for FastHare
Installation
This requires Python 3.10+ and c++14
- clone this repository
pip install ./python_package
Test
import fasthare as m
print("Using list of triples i, j, h_ij")
sk_ising = [(0, 1, -3)] # SK Hamiltonian: min - (-3 * x_0 * x_1 )
print(m.fasthare_reduction(sk_ising) )
# Or using the exp3.net in the "tests" folder
print("Reading triples i, j, h_ij from file")
rh, map, sign, time = m.fasthare_reduction(file ="exp3.net",alpha=0.2)
print(rh)
print(map)
print(sign)
print(time)
Output
Using list of triples i, j, h_ij
([], [0, 0], [1, -1], 1.9e-05)
Reading triples i, j, h_ij from file
[(0, 1, 1.0), (0, 2, 3.0), (1, 2, 3.0)]
[2, 2, 2, 2, 2, 2, 2, 1, 0, 1]
[1, -1, -1, 1, 1, 1, 1, 1, 1, 1]
4.4e-05
The output is a tuple of <compressed_hamiltonian, spin_mapping, spin_sign, running_time>.
- compressed_hamiltonian: triples of (i, j, h_ij)
- spin_mapping: The ith entry indicates which spin in the compressed hamiltonian that the ith spin in the input Hamiltonian mapped to
- spin_sign: The ith entry is -1 if the ith spin in the input Hamiltonian is reversed (+1 otherwise)
- running_time: run time in second(s)
Explanation for the output of "exp3.net"
exp3.net | compressed_hamiltonian | spin_mapping/spin_sign |
---|---|---|
10 14 0 1 -2 0 2 -4 1 2 2 1 3 -1 2 3 -6 3 4 3 4 5 4 4 6 4 5 6 -1 6 7 3 6 8 3 7 8 -1 7 9 3 8 9 2 |
[(0, 1, 1.0), (0, 2, 3.0), (1, 2, 3.0)] |
[2, 2, 2, 2, 2, 2, 2, 1, 0, 1] [1, -1, -1, 1, 1, 1, 1, 1, 1, 1] |
... | Compressed into the below Hamiltonian with $n'=3$ nodes and $m'=3$ edges. $\displaystyle\min_{\mathbf{x}\in{-1,+1}^3} -[ s_0 s_1 + 3 s_0 s_2 + 3 s_1 s_2]$ |
$s_8= s_0'$ $s_9= s_7=s_1'$ $s_6= s_5=s_4 =s_3 = - s_2 = -s_1 = s_0= s_2'$ The qubits $s_1$ and $s_2$ are flipped before the compression. |
Remark: Since the version 1.0, the Hamiltonian will be compressed into a single node.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file fasthare-1.0.3.tar.gz
.
File metadata
- Download URL: fasthare-1.0.3.tar.gz
- Upload date:
- Size: 11.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b317a224083d2c4427d1b1fef2da8d136cc71ea6ea64924e57035ab164c3a513 |
|
MD5 | c7a5789ccce1e05504ba8534c075bcfe |
|
BLAKE2b-256 | e0c94df2e4fd8e9602bd6471dcc7a5fe5924b4cee295ed282cec07a6f9b9a5da |
File details
Details for the file fasthare-1.0.3-cp310-cp310-macosx_13_0_arm64.whl
.
File metadata
- Download URL: fasthare-1.0.3-cp310-cp310-macosx_13_0_arm64.whl
- Upload date:
- Size: 92.0 kB
- Tags: CPython 3.10, macOS 13.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 278c44c1d5098c1a38cd3f37150bc3678be8ab849594bdc5c294f7b08eb6fe0e |
|
MD5 | c131089dd28b8d36b1c820157504321d |
|
BLAKE2b-256 | a98545bd28ad7b18f996509750ccaf699b028470b4159ee7afeb4b2d819047ea |