Open nquetschlich opened 9 months ago
Update: I have played around a little more and would like to examine the effect different compilations have on the result quality. Therefore, I tried to execute the following:
from qiskit import transpile
ansatz_transpiled = transpile(ansatz, backend=FakeMontreal())
qaoa = SamplingVQE(sampler=BackendSampler(FakeMontreal(), skip_transpilation=True), optimizer=COBYLA(maxiter=200), ansatz=ansatz_transpiled)
qubitOp = get_maxcut_qubo(maxcut)[0]
res = qaoa.compute_minimum_eigenvalue(qubitOp)
Here, I get an AlgorithmError: 'The number of qubits of the ansatz does not match the operator, and the ansatz does not allow setting the number of qubits using num_qubits.'
Is there any way to circumvent this error while using already compiled ansatz circuits and skip the default transpilation?
Environment
What is happening?
Hi there,
I would like to run
SamplingVQE
with different ansatz circuits and compilation options to evaluate their performance for aFakeBackend
. For that, I run something likeHere, I experienced that I could enter an
ansatz_qc
that has not been compiled to the usedFakeBackend
yet and still get a valid result when running compute_minimum_eigenvalue when using theskip_transpilation=True
parameter.In the example below, an QAOA ansatz is created for a sample MaxCut problem for an instance with four nodes.
How can we reproduce the issue?
What should happen?
I would have expected an assertion error that checks whether the to-be-executed
ansatz_qc
actually is transpiled according to the used backend. Am I overlooking something here? How is the underlying noise model of theFakeBackend
considered when the quantum gates are not part of its basis gateset?Any suggestions?
No response