-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add HybridQ #25
Add HybridQ #25
Conversation
If we can't solve this problem, we may opt to simply remove TFQ. |
This is almost ready, @mlazzarin, @andrea-pasquale you can have a look when you have time. The issues with CI were false alarm as Python 3.9 seems to work okay and there is no confusion with tfq as HybridQ does not depend on tensorflow. This adds two backends: An issue that I still have (other than the from hybridq.circuit import Circuit
from hybridq.gate import Gate
from hybridq.circuit.simulation import simulate
circuit = Circuit()
circuit.append(Gate('RX', params=[0], qubits=(0,)))
circuit.append(Gate('RX', params=[0], qubits=(1,)))
circuit.append(Gate('RX', params=[0], qubits=(2,)))
circuit.append(Gate('H', qubits=(0,)))
circuit.append(Gate('H', qubits=(1,)))
circuit.append(Gate('H', qubits=(2,)))
circuit.append(Gate('CZ', qubits=(1, 2)))
circuit.append(Gate('RZ', params=[0], qubits=(0,)))
circuit.append(Gate('CZ', qubits=(0, 1)))
circuit.append(Gate('RX', params=[0], qubits=(0,)))
circuit.append(Gate('CZ', qubits=(1, 2)))
circuit.append(Gate('CZ', qubits=(1, 2)))
circuit.append(Gate('H', qubits=(1,)))
circuit.append(Gate('H', qubits=(2,)))
initial_state = len(circuit.all_qubits()) * '0'
simulate(circuit, optimize="evolution-einsum", backend="jax",
initial_state=initial_state, compress=0, simplify=False) which gives me the following error
If you could confirm that you also get this it would be great, however I will probably open an issue on hybridq about this as it does not seem to be related to the benchmarks. This is the minimal example I could find that reproduces this, if I remove any gate or any simulation option it works okay! |
I can reproduce it. |
I can also reproduce the issue. I managed to solve this issue, for both the conda and the pip installation, using the following command:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this implementation.
Apart from the two issues (gpu tests and parallel
option) everything else looks good to me.
Concerning the
On the other hand, there is an explicit reference to the
and there is also a reference in the section regarding Clifford expansion (IV.D). In fact, it seems like there are no reference to the |
Thank you both for the input.
I had the same issue with GPU and that's exactly how I solved it. As for the other issue with einsum I opened nasa/hybridq#83 but there is no response yet.
Indeed, that's correct, thank you for finding this. I tried OMP_NUM_THREADS and it seems to work as expected. Since the parallel option is not relevant for us as we do state vector simulation, I will remove it. The only issue is that I am not sure how to use OMP_NUM_THREADS internally in the script so that it is set from from the |
There is a PR in hybridq (nasa/hybridq#85) which fixes this issue. I confirmed that our GPU tests now pass if I install hybridq from source using this branch. The only issue is that, as I wrote above, for me only the conda version installs their CPU custom operators properly so I guess we would have to wait for them to merge the new PR and release to get an optimal version for both CPU and GPU. Otherwise we should use the conda version for CPU (and non-problematic GPU configurations) and install from source if we want to run the supremacy circuit on GPU. Other than that, I believe this PR is complete, right? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Adds the HybridQ library for CPU and GPU. Currently I observe the following issues:
parallel
insimulate
which is supposed to control the number of threads does not seem to work. It is using all threads regardless of the value I pass there.