-
Notifications
You must be signed in to change notification settings - Fork 583
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
ERROR: _tfq_simulate_ops.so on python 3.7.7 #805
Comments
Support for windows was dropped after 0.3. I think the TF dependency of 0.3 was like tf 2.1.0 or something, but that's probably an error. Also see: #798 |
Thanks for the answer @lockwo . I migrated to Linux (CentOS Linux release 7.9.2009) to try solving the issue, but I still get an error with the simulate_ops:
The installed packages and versions in python 3.7.7 are:
|
I would then suggest not to specify in the installation guide (https://www.tensorflow.org/quantum/install) to install TF2.11 if it ends up not being compatible with the current TFQ version, it is misleading. |
If this repo were not abandoned, I'm sure that would be taken into consideration |
Why is it abandoned? |
Not sure why it is abandoned, you would have to ask Google. You can make a PR, but it won't get merged, because there are no active maintainers. You can see there is a PR very similar to what you want that's been open for months: #803 |
That's a pity then. Changing topics. Do you know how to integrate a PQC into a Sequential block of Dense layers? I'm not an expert on quantum computing so I'm not sure if this even makes any sense, but I've seen a paper doing this (on a different library tho). I created a dummy code (inspired from the Hello_many_worlds tutorial) to fit the line y=x, but get an error in the interface between Dense and PQC layers. Any idea how to implement this?
|
Sure its possible, like fig 12 of https://arxiv.org/pdf/2003.02989.pdf. Feeding the outputs of a QVC into a NN is straightforward (just pass the layer outputs into sequential). To pass classical outputs to quantum requires a little work but is doable, e.g. https://www.tensorflow.org/quantum/tutorials/hello_many_worlds#2_hybrid_quantum-classical_optimization. |
Thanks for the answer.
Unfortunately it loses the batch dimension and thus does not work (i.e. dense_2_cat_str ends up being a tf.string of shape () instead of (None,)). Any idea if this strategy could work somehow?
to: |
Yes, if you want to use DNNs upstream of a PQC, you would probably want to use ControlledPQC or a custom layer (my go to approach, it gives you a lot of flexibility, see: https://github.com/lockwo/quantum_computation/blob/master/TFQ/data_reupload/reup.py). ControlledPQC will always have quantum data input, because that is simply the starting state of the quantum circuit (which must exist). You could always just initialize it to the |0>^N state, which I often do. Simply creating a cirq.Circuit is sufficient for those purposes most of the time as you have. There isn't any set of default for converting data, but doing encodings is very possible (see: https://github.com/lockwo/quantum_computation/blob/master/TFQ/vqc/boston_housing.py). In general, QML on classical data is probably much less potent/capable of giving any meaningful speedups/results than QML on quantum data, which is probably why there isn't a big emphasis on tooling for it. |
Thank you so much for the answer.
|
|
I see. It's a pity Google has abandoned it. It might be because it has grown to its full potential for now, or maybe because on classical data, QML does not outperform classical algorithms. What was your role in the development of TFQ?
Again, thank you very much for your help, it's highly appreciated in such a complex field. |
Most people wouldn't consider QML deterministic (although there are some philosophical interpretations of quantum mechanics that might).
|
If the output of the circuit can be different for the same input, how does the concept of QML make sense? For training I assume you run the circuit several times for each sample and epoch, and then you backpropagate comparing histograms. However, for testing I don't see how can you circumvent this issue. Should the circuit be run several times for each sample of the test set, and then average those samples to check the accuracy? (I've seen sometimes the argument repetition, probably it has to do with it. Since I don't always see it then I assumed it was not needed) |
Yes, in order to get an expectation value of any operator you want to sample the circuit many times (10-10,000) on real hardware. This is not unique to QML though, all of quantum computation requires this |
I see. How do you usually handle this issue when using TFQ? I see that for the PQC layer, for instance, repetitions is set to None by default. Does it mean that the circuit is only evaluated once? |
No, None means that it is evaluated analytically. Ie given the state vector or density matrix we just exactly compute the values. 1 shot would be repetitions = 1 |
But if they are computed analytically, doesn't it lose the probabilistic nature of the measurement? |
I mean, yes and no. Give a probability density, instead of sampling from it to compute an expected value of some operator, you just analytically compute it. It's still probabilistic, it just loses the shot noise. If we could in real quantum devices we would do this. The shot noise of measurement gives us no value (almost always) and hinders our accuracy of what we want to compute unless we do enough repetitions |
Hi! Sorry to pick up this thread again, but I got a question regarding your last answer and you might be able to solve it! :) |
The output of a "shot" is just a bit string in a given basis from your circuit. If you tried to approximate a density matrix from a single shot, you would just get a very bad approximation of the density matrix (you need exponentially many shots to estimate the density matrix, see https://en.wikipedia.org/wiki/Quantum_tomography).
One is a circuit executed without noise 1000 times and the other is a circuit executed with noise 1000 times.
It only simulates the noise you program it to simulate, see https://www.tensorflow.org/quantum/tutorials/noise. So if you increase or decrease the noise, then you can see the effects. And you can add any hardware noise you want to simulate. |
@101AlexMartin were you able to get TFQ working eventually? Is this issue still relevant, or should it be closed? |
After installing (on a Windows machine) tensorflow and tensorflow-quantum as explained in the repository, I don't manage to import tensorflow_quantum, since I get the _tfq_simulate_ops.so error (tensorflow_quantum\core\ops_tfq_simulate_ops.so not found). I installed version 2.11 of tensorflow and 0.3.1 of tensorflow quantum (I see the current version of the repository is already 0.7, so I'm also not sure why I get 0.3 when running pip install). Should I downgrade tensorflow?
These are the installed packages and versions of the virtual environment I'm using to import tensorflow-quantum:
absl-py==2.1.0
astunparse==1.6.3
cachetools==5.3.2
certifi==2023.11.17
charset-normalizer==3.3.2
cirq==0.8.0
cycler==0.11.0
dill==0.3.7
flatbuffers==23.5.26
fonttools==4.38.0
freezegun==0.3.15
gast==0.4.0
google-api-core==1.34.0
google-auth==2.26.2
google-auth-oauthlib==0.4.6
google-pasta==0.2.0
googleapis-common-protos==1.62.0
grpcio==1.60.0
grpcio-status==1.60.0
h5py==3.8.0
idna==3.6
importlib-metadata==6.7.0
keras==2.11.0
kiwisolver==1.4.5
libclang==16.0.6
Markdown==3.4.4
MarkupSafe==2.1.3
matplotlib==3.5.3
mpmath==1.3.0
multiprocess==0.70.15
networkx==2.6.3
numpy==1.21.6
oauthlib==3.2.2
opt-einsum==3.3.0
packaging==23.2
pandas==1.3.5
pathos==0.2.5
Pillow==9.5.0
pox==0.3.3
ppft==1.7.6.7
protobuf==3.19.6
pyasn1==0.5.1
pyasn1-modules==0.3.0
pyparsing==3.1.1
python-dateutil==2.8.2
pytz==2023.3.post1
requests==2.31.0
requests-oauthlib==1.3.1
rsa==4.9
scipy==1.7.3
six==1.16.0
sortedcontainers==2.4.0
sympy==1.4
tensorboard==2.11.2
tensorboard-data-server==0.6.1
tensorboard-plugin-wit==1.8.1
tensorflow==2.11.0
tensorflow-estimator==2.11.0
tensorflow-intel==2.11.0
tensorflow-io-gcs-filesystem==0.31.0
tensorflow-quantum==0.3.1
termcolor==2.3.0
typing-extensions==4.7.1
urllib3==2.0.7
Werkzeug==2.2.3
wrapt==1.16.0
zipp==3.15.0
The text was updated successfully, but these errors were encountered: