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

fix: improve implicit qubit permutations warning #421

Merged
merged 24 commits into from
Nov 22, 2024
Merged

Conversation

CalMacCQ
Copy link
Contributor

@CalMacCQ CalMacCQ commented Nov 21, 2024

Description

Added the change from #412 back in again with a boolean flag to ensure that unhelpful warnings aren't generated when using AerBackend with optimisation level 2

See discusssion in #411

Driveby: fix invalid table of compilation passes (see df0cda3)

Related issues

closes #411

Checklist

  • I have performed a self-review of my code.
  • I have commented hard-to-understand parts of my code.
  • I have made corresponding changes to the public API documentation.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have updated the changelog with any user-facing changes.

@CalMacCQ CalMacCQ requested a review from cqc-melf as a code owner November 21, 2024 15:41
@CalMacCQ CalMacCQ marked this pull request as draft November 21, 2024 15:41
with pytest.warns(UserWarning, match="The pytket Circuit contains implicit qubit"):
tk_to_qiskit(c)

state_backend = AerStateBackend()
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 wrote this test without the flag added to ensure that it failed.

The warning only appears for AerBackend and not AerStateBackend. I would've expected both to generate a warning (i.e. record to be of length 2)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah its because the state and unitary backends replace implicit swaps with SWAP gates whereas AerBackend does not.

@CalMacCQ CalMacCQ changed the title fix: imporve implcit qubit permutations warning fix: improve implcit qubit permutations warning Nov 21, 2024
@@ -194,7 +194,7 @@ Every {py:class}`~pytket.backends.backend.Backend` in pytket has its own {py:met
2 preserve barriers in a circuit, while optimisation level 3 will remove them.

:::{list-table} **Default compilation pass for the IBMQBackend and IBMQEmulatorBackend**
:widths: 25 25 25
:widths: 25 25 25 25
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This fixes an error due to an invalid number of columns

@CalMacCQ
Copy link
Contributor Author

CalMacCQ commented Nov 21, 2024

Sorry for commit spam. I think the linting settings were broken in my IDE.

@CalMacCQ CalMacCQ marked this pull request as ready for review November 21, 2024 16:55
@CalMacCQ CalMacCQ requested review from cqc-alec and removed request for cqc-melf November 21, 2024 16:56
docs/changelog.md Show resolved Hide resolved
@@ -286,6 +286,7 @@ def process_circuits(
circuit_batches, batch_order = _batch_circuits(circuits, n_shots_list)

replace_implicit_swaps = self.supports_state or self.supports_unitary
perm_warning = False
Copy link
Collaborator

Choose a reason for hiding this comment

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

No need to define a variable, it's only used once.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair enough. Done dd6e973

pytket/extensions/qiskit/qiskit_convert.py Outdated Show resolved Hide resolved
@CalMacCQ CalMacCQ requested a review from cqc-alec November 21, 2024 17:08
@CalMacCQ CalMacCQ changed the title fix: improve implcit qubit permutations warning fix: improve implicit qubit permutations warning Nov 21, 2024
docs/changelog.md Show resolved Hide resolved
docs/changelog.md Outdated Show resolved Hide resolved
pytket/extensions/qiskit/qiskit_convert.py Outdated Show resolved Hide resolved
@CalMacCQ CalMacCQ requested a review from cqc-alec November 22, 2024 13:48
@CalMacCQ CalMacCQ merged commit 55357b4 into main Nov 22, 2024
6 checks passed
@CalMacCQ CalMacCQ deleted the perm_warning branch November 26, 2024 01:20
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

Successfully merging this pull request may close these issues.

Qiskit Conversion ignores implict permutations
2 participants