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.4.tar.gz
.
File metadata
- Download URL: fasthare-1.0.4.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 | 31bc37570398a83a879dcab2480e60c111726b6fde6db334521272cc751fbad8 |
|
MD5 | 02d8283bfa4e84eb8ba0ec1a585ddc49 |
|
BLAKE2b-256 | 77fc85557b0b27baf659b4fe4a90927bbfe96505d3088b3d27bf60253c50b06e |
File details
Details for the file fasthare-1.0.4-cp310-cp310-macosx_13_0_arm64.whl
.
File metadata
- Download URL: fasthare-1.0.4-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 | b7d9b7ad2aa1f72b3ba1c9f8997e202643393a9c364631b4c7a38f9f99517cca |
|
MD5 | 07a542542b10516fe0eee8ae5763b747 |
|
BLAKE2b-256 | dde20a2a085d4205413a7b0b365f30a3e837a0f39a74e8f69dc81c62cd6024ef |