Skip to content
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

Noiseless setup - why it doesn't work? #129

Closed
martinellop opened this issue Jan 27, 2025 · 2 comments
Closed

Noiseless setup - why it doesn't work? #129

martinellop opened this issue Jan 27, 2025 · 2 comments

Comments

@martinellop
Copy link

Hello,
I'm exploring the code from the first tutorial 01_chemistry_hamiltonian.ipynb, either under different molecule or parameter scenarios.
The code is very clear and well structured, so first of all I want to thank you for the clean job.

Still, I'm stuck on a problem that I'm struggling to understand:
I was curious to see how different the results would be if i ran the circuit in a noiseless scenario vs. a realistic one. As far as I know, this is not possible using a fake_provider, while it should be possible using AerSimulator.
I have tried to implement this:

backend = AerSimulator.from_backend(target_backend)
backend.set_options(noise_model=None)

spin_a_layout = [0, 14, 18, 19, 20, 33, 39, 40, 41, 53, 60, 61, 62, 72, 81, 82][:num_orbitals]
spin_b_layout = [2, 3, 4, 15, 22, 23, 24, 34, 43, 44, 45, 54, 64, 65, 66, 73][:num_orbitals]
layout = spin_a_layout + spin_b_layout

pass_manager = generate_preset_pass_manager(optimization_level=3, backend=backend, initial_layout=layout)

pass_manager.pre_init = ffsim.qiskit.PRE_INIT
isa_circuit = pass_manager.run(circuit)

shots = 10000
sampler = Sampler(mode=backend)
job = sampler.run([isa_circuit], shots=shots)

primitive_result = job.result()
pub_result = primitive_result[0]
counts = pub_result.data.meas.get_counts()

print(counts)

The code runs, but what I do not understand is why I only get vectors of zeros in this noiseless setup:
{'00000000000000': 10000}
which of course causes problems with the code that follows.
When I comment the line backend.set_options(noise_model=None), the code works as expected, returning many different bitstrings. So it looks to me like the problem is the noiseless simulation. I have tried to construct a noiseless simulator in other ways, playing with the preset manager, layout, etc.. but I always end up with this problem.

From my perspective, it doesn't make sense that this method shouldn't work with a noiseless simulator, as I'm expecting bitstrings about the physical electronic configurations.

Is this a bug or am I wrong in something?
Thank you for your time!

@caleb-johnson
Copy link
Collaborator

Hi @martinellop , thanks for writing this up.

qiskit-aer is probably going to struggle with an exact calculation on a 32-qubit circuit. As far as I know, that's too large for Aer. That beingh said, I don't see why you're just getting 10_000 0's rather than some runtime error telling you your circuit is too large. If you could come up with a minimal reproducible example, you might consider submitting an issue to qiskit-aer.

This issue is out of scope for this package, as qiskit-addon-sqd does not deal with the ansatze and doing the sampling -- only the post-processing. We only include that example in the tutorial so that SQD users have more documentation regarding the LUCJ ansatz (mostly from ffsim).

I'm going to close this, but I'd encourage you to submit an issue to Aer if you think it is behaving unexpectedly.

@martinellop
Copy link
Author

Hello @caleb-johnson ,
thank you for your quick answer.

I confirm the presence of the same behavior on a minimal circuit (H2 molecule, 4 qubits).
I'll try to dive deeper in aer code, and eventually report the issue to qiskit-aer, since this looks to me like something important.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants