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

Setting noise_info to false in GenericBackendV2 creates issues later in the transpiler pipeline #12769

Merged
merged 4 commits into from
Jul 26, 2024

Conversation

sbrandhsn
Copy link
Contributor

Summary

Fixes bugs introduced in #12747

Details and comments

I added some tests to check whether transpiling with noise-less and/or pulse-channel-less backends still works and noticed test failures. I fixed these bugs and added the corresponding test cases. I don't think this warrants a new release note but let me know if you disagree. :-)

@sbrandhsn sbrandhsn requested review from jyu00 and a team as code owners July 12, 2024 12:40
@qiskit-bot
Copy link
Collaborator

One or more of the following people are relevant to this code:

  • @Qiskit/terra-core

@coveralls
Copy link

coveralls commented Jul 12, 2024

Pull Request Test Coverage Report for Build 10109907875

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 2 of 2 (100.0%) changed or added relevant lines in 1 file are covered.
  • 899 unchanged lines in 55 files lost coverage.
  • Overall coverage decreased (-0.2%) to 89.72%

Files with Coverage Reduction New Missed Lines %
qiskit/qobj/common.py 1 95.83%
qiskit/circuit/library/standard_gates/swap.py 1 98.18%
qiskit/primitives/backend_sampler.py 1 98.86%
qiskit/circuit/duration.py 1 70.27%
crates/accelerate/src/synthesis/permutation/utils.rs 1 99.02%
qiskit/primitives/base/base_estimator.py 1 97.3%
qiskit/transpiler/passes/layout/sabre_pre_layout.py 1 98.88%
qiskit/circuit/random/utils.py 1 94.87%
qiskit/circuit/library/standard_gates/x.py 1 98.25%
qiskit/transpiler/passes/routing/commuting_2q_gate_routing/commuting_2q_gate_router.py 1 99.12%
Totals Coverage Status
Change from base Build 9895663732: -0.2%
Covered Lines: 66679
Relevant Lines: 74319

💛 - Coveralls

Copy link
Contributor

@ElePT ElePT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @sbrandhsn for looking into this. I am guessing that the root of the issue was related to the instructions being global (i.e. properties=None), but what was exactly failing, was it the pm construction or specific passes? Because as far as I understand it global instructions should be allowed too in the pipeline (so maybe the bug is down the line, not here).

@sbrandhsn
Copy link
Contributor Author

Sure, they might be another issue down the line. However, if the user specifies a backend with a coupling map but without noise info, I guess we should not return a target with global instructions. :-) This is the current behavior of the code I pushed last week.

@ElePT
Copy link
Contributor

ElePT commented Jul 16, 2024

Both options should be valid (target with global instructions and with local instructions but properties=None) as long as they are properly documented, I guess I was asking whether this was just unexpected behavior for you or whether you saw any failure caused by global instructions that motivated this PR. That being said, I am not against the "unexpected behavior" argument.

Comment on lines 414 to 419
if is_fully_connected:
self._target.add_instruction(gate, properties=None, name=name)
else:
qarg_set = self._coupling_map if gate.num_qubits > 1 else range(self.num_qubits)
props = {(qarg,) if isinstance(qarg, int) else qarg: None for qarg in qarg_set}
self._target.add_instruction(gate, properties=props, name=name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm what makes the fully connected cmap special in this case? Is this purely an efficiency matter?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, it is much more efficient to set `properties=None' here in that case, otherwise we create a dictionary with entries for each edge of the fully connected coupling map that all point to None...

Copy link
Contributor

@ElePT ElePT Jul 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, but I am not sure I like this approach. This would make the behavior differ "arbitrarily" depending on the connectivity of the coupling map used, right? Some times the instructions would be global, some times they would be local with no properties... I think that the behavior should be consistent independently of the connectivity (plus, if having properties=None does introduce issues in the pipeline, then the issues aren't being fixed for the case of fully-connected cmaps, right?).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see - the issue here is that the memory overhead is quite large when representing an all-to-all connected by local instructions without properties. It can be up to ~2 GB for large backends whereas a backend with global instructions and no properties needs a couple of MB. Granted, one should likely not create a large all-to-all connected backend but if a user does, he will be surprised by that memory overhead.

However, I agree that a discrete change based on that fully-connected flag is similarly confusing - a backend missing only one edge to be all-to-all connected would exhibit a different memory behaviour than a fully-connected backend. Should I remove the optimizations based on is_fully_connected? I think the pre-PR behaviour of noiseless BackendV2 is definitely incorrect...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that it's safer to remove the optimizations for is_fully_connected. It's the default behavior of the class and I can see how users would get confused if specifying a custom cmap suddenly affects the gate properties.

@sbrandhsn
Copy link
Contributor Author

Both options should be valid (target with global instructions and with local instructions but properties=None) as long as they are properly documented, I guess I was asking whether this was just unexpected behavior for you or whether you saw any failure caused by global instructions that motivated this PR. That being said, I am not against the "unexpected behavior" argument.

Sorry for not being clear in my first response. :-/ I was getting an intermittent error that I can not replicate easily right now. I think the gist was that build_coupling_map was called by something in the transpiler which returned None because self.qargs is None. Then some code expected None to be a valid coupling map and called size on it. Interestingly this did not occur for all instance of CouplingMap.from_heavy_hex that I was running. Maybe something in main fixes that behaviour right now.

@sbrandhsn sbrandhsn added this to the 1.2.0 milestone Jul 23, 2024
@ElePT ElePT self-assigned this Jul 23, 2024
Copy link
Contributor

@ElePT ElePT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sbrandhsn I have added some suggestions not to separate out the behavior of the fully connected cmap. Let me know if you agree with the approach.

qiskit/providers/fake_provider/generic_backend_v2.py Outdated Show resolved Hide resolved
qiskit/providers/fake_provider/generic_backend_v2.py Outdated Show resolved Hide resolved
sbrandhsn and others added 2 commits July 26, 2024 12:34
Copy link
Contributor

@ElePT ElePT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ElePT ElePT added Changelog: None Do not include in changelog mod: fake_provider Related to the fake_provider module and fake backends stable backport potential The bug might be minimal and/or import enough to be port to stable labels Jul 26, 2024
@ElePT ElePT added this pull request to the merge queue Jul 26, 2024
Merged via the queue into Qiskit:main with commit edf0b53 Jul 26, 2024
15 checks passed
mergify bot pushed a commit that referenced this pull request Jul 26, 2024
…in the transpiler pipeline (#12769)

* up

* fix

* Apply suggestions from code review

Co-authored-by: Elena Peña Tapia <[email protected]>

* lint

---------

Co-authored-by: Elena Peña Tapia <[email protected]>
(cherry picked from commit edf0b53)
github-merge-queue bot pushed a commit that referenced this pull request Jul 26, 2024
…in the transpiler pipeline (#12769) (#12823)

* up

* fix

* Apply suggestions from code review

Co-authored-by: Elena Peña Tapia <[email protected]>

* lint

---------

Co-authored-by: Elena Peña Tapia <[email protected]>
(cherry picked from commit edf0b53)

Co-authored-by: Sebastian Brandhofer <[email protected]>
Procatv pushed a commit to Procatv/qiskit-terra-catherines that referenced this pull request Aug 1, 2024
…in the transpiler pipeline (Qiskit#12769)

* up

* fix

* Apply suggestions from code review

Co-authored-by: Elena Peña Tapia <[email protected]>

* lint

---------

Co-authored-by: Elena Peña Tapia <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: None Do not include in changelog mod: fake_provider Related to the fake_provider module and fake backends stable backport potential The bug might be minimal and/or import enough to be port to stable
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants