-
Notifications
You must be signed in to change notification settings - Fork 336
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
'Estimator job failed' while using EstimatorQNN to train NN using TorchConnector #669
Comments
Here is the working example and the error message:
error:
|
I am facing the same issue. Can you please share if you found any workaround for it? |
No, I am still facing this issue. |
Hey! I faced a similar issue and thought it had something to do with the Torchconnector and my inputs not being formatted correctly. However, in my circuit, the inputs and weights were not bound properly to the circuit. Have a look into the number of parameters both your feature map and ansatz has and then map that back to the number of inputs and weights you are sending in. |
Hey, thank you for your reply! I checked the number of parameters (both feature map and ansatz params) and they match exactly with the number of input features and weights respectively. Is there something that I am missing? What did you mean when you said the inputs and weights were not bound properly to the circuit ? |
Hey did you find any solution?? |
I am facing this issue for past 3 days and it happens in sampler and estimator only one when i tried to integrate with noise model. In EstimatorQNN with esttimator parameter and in sampler with sampler parameters. |
i was facing the issue when i tried to integrate it with torchconnector |
I am facing the same problem using SamplerQNN and tried to debug. The problem happens in method Can this be fixed in future releases? In my opinion, when using EstimatorQNN or SamplerQNN with the option input_gradients=False, it should be able to calculate gradients with respect to the weights even if RawFeatureVector is used. Please see my example:
|
Hi @Next-di-mension, thanks for opening this issue, it seems a number of people have undergone it as well. I can reproduce your error by switching out the: from qiskit.utils import algorithm_globals to from qiskit_algorithms.utils import algorithm_globals or by using either numpy or random random number generators, as the algorithm_globals from qiskit.utils has been deprecated. Whilst tracing back through your error message I can see that the error is not really with the Estimator (nor would it be with Sampler) or Torch Connector, but with the binding of parameters, which someone in the comments also mentioned. If you look at the Raw Feature Vector class (https://qiskit-community.github.io/qiskit-machine-learning/stubs/qiskit_machine_learning.circuit.library.RawFeatureVector.html) you will see it specifically states that: In the documentation it also states that the circuit resulting from Raw Feature Vector cannot be used with gradient based optimizers as gradients can't be computed. So at the moment we are not going to change EstimatorQNN or SamplerQNN as suggested "with the option input_gradients=False, it should be able to calculate gradients with respect to the weights even if RawFeatureVector is used". If you have other queries or comments let us know, and if you run into other errors related to this you are welcome to open a new issue as well. |
Hello @FrancescaSchiav, thank you for your comments on this issue. I have tried to recreate the qiskit MNIST tutorial https://qiskit-community.github.io/qiskit-machine-learning/tutorials/05_torch_connector.html with the simple change of using Raw Feature Vector. When using either SamplerQNN or EstimatorQNN, I am experiencing the same issue, even when changing option input_gradients=False. Do you know what may be causing this?
I get the error |
Hi @SilverEngineered is your error message the same thing as above where you get the below error? Otherwise can you post it. QiskitError: 'Cannot define a ParameterizedInitialize with unbound parameters' The above exception was the direct cause of the following exception: If my message was unclear before RawFeatureVector is not programmed to work with gradient based optimizers, and it won't work even if you use input_gradients=False. Someone commented that they think this should be changed in the future as a new feature, but it is not currently a bug, and we are not at the moment planning to add this feature. We will keep the suggestion in mind for the future and appreciate the feedback, but for now please let us know if your issue is due to something else rather than the one mentioned above. |
I am using
EstimatorQNN
to train a NN usingTorchConnector
.This is how I define the QNN:
while training it using PyTorch, I am using the
NLLLoss
function. When I give aloss.backward()
command, it throws an error'Estimator job failed'
Can somebody help me with this?The text was updated successfully, but these errors were encountered: