Skip to content

Fix ApplyLayout with empty layout (backport #14606)#14615

Merged
jakelishman merged 5 commits intostable/1.4from
mergify/bp/stable/1.4/pr-14606
Aug 15, 2025
Merged

Fix ApplyLayout with empty layout (backport #14606)#14615
jakelishman merged 5 commits intostable/1.4from
mergify/bp/stable/1.4/pr-14606

Conversation

@mergify
Copy link
Copy Markdown
Contributor

@mergify mergify Bot commented Jun 16, 2025

Summary

It's unlikely to ever be useful, but strictly there still is a well-defined behaviour for ApplyLayout on a zero-qubit circuit and backend. Previously, the pass errored out falsely asserting user error.

Details and comments


This is an automatic backport of pull request #14606 done by [Mergify](https://mergify.com).

It's unlikely to ever be useful, but strictly there still is a
well-defined behaviour for `ApplyLayout` on a zero-qubit circuit and
backend.  Previously, the pass errored out falsely asserting user error.

(cherry picked from commit d0630fd)
@mergify mergify Bot requested a review from a team as a code owner June 16, 2025 14:24
@qiskit-bot
Copy link
Copy Markdown
Collaborator

Thank you for opening a new pull request.

Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient.

While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone.

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

  • @Qiskit/terra-core

@github-actions github-actions Bot added the Changelog: Fixed Add a "Fixed" entry in the GitHub Release changelog. label Jun 16, 2025
@github-actions github-actions Bot added this to the 2.1.0 milestone Jun 16, 2025
@github-actions github-actions Bot added the mod: transpiler Issues and PRs related to Transpiler label Jun 16, 2025
mtreinish
mtreinish previously approved these changes Jun 16, 2025
@mtreinish mtreinish enabled auto-merge June 16, 2025 14:26
@mtreinish mtreinish modified the milestones: 2.1.0, 1.4.4 Jun 16, 2025
@kevinhartman
Copy link
Copy Markdown
Contributor

Looks like this is failing due to an actual issue:

test.python.transpiler.test_apply_layout.TestApplyLayout.test_empty_post_layout
-------------------------------------------------------------------------------

Captured traceback:
~~~~~~~~~~~~~~~~~~~
    Traceback (most recent call last):

      File "/Users/runner/work/qiskit/qiskit/test/python/transpiler/test_apply_layout.py", line 64, in test_empty_post_layout
    self.assertEqual(out.layout.initial_virtual_layout(), Layout())
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    AttributeError: 'NoneType' object has no attribute 'initial_virtual_layout'

@jakelishman
Copy link
Copy Markdown
Member

Kevin: it's probably because the test is written under the assumption that #13820 was available. The tests probably need rewriting to instead construct a PassManager with an explicit SetLayout/whatever call followed by an ApplyLayout, and run that.

Comment thread test/python/transpiler/test_apply_layout.py Outdated
kevinhartman
kevinhartman previously approved these changes Aug 14, 2025
@coveralls
Copy link
Copy Markdown

coveralls commented Aug 14, 2025

Pull Request Test Coverage Report for Build 16980897218

Details

  • 2 of 2 (100.0%) changed or added relevant lines in 1 file are covered.
  • 20 unchanged lines in 4 files lost coverage.
  • Overall coverage decreased (-0.01%) to 88.505%

Files with Coverage Reduction New Missed Lines %
crates/accelerate/src/unitary_synthesis.rs 1 91.83%
crates/qasm2/src/expr.rs 1 93.78%
crates/qasm2/src/lex.rs 6 91.24%
crates/qasm2/src/parse.rs 12 97.1%
Totals Coverage Status
Change from base Build 16975764228: -0.01%
Covered Lines: 77324
Relevant Lines: 87367

💛 - Coveralls

@mtreinish mtreinish added this pull request to the merge queue Aug 15, 2025
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Aug 15, 2025
@jakelishman jakelishman added this pull request to the merge queue Aug 15, 2025
Merged via the queue into stable/1.4 with commit d8486e2 Aug 15, 2025
19 checks passed
@jakelishman jakelishman deleted the mergify/bp/stable/1.4/pr-14606 branch August 15, 2025 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Changelog: Fixed Add a "Fixed" entry in the GitHub Release changelog. mod: transpiler Issues and PRs related to Transpiler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants