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

Qubit stop time #8729

Closed
ewoutvandenberg opened this issue Sep 12, 2022 · 3 comments · Fixed by #11097
Closed

Qubit stop time #8729

ewoutvandenberg opened this issue Sep 12, 2022 · 3 comments · Fixed by #11097
Labels
bug Something isn't working

Comments

@ewoutvandenberg
Copy link

Environment

Latest Qiskit Terra version (v.0.21.2)

What is happening?

In the qubit_stop_time function, the maximum stop time is returned when all qubits are flagged as completed (current line 4971). If one of the provided qubits only has delays on it, this condition is never satisfied and zero will be returned at the end of the function. The stop time of two qubits, one with gates and one with only delays, will therefore be zero.

How can we reproduce the issue?

See source code.

What should happen?

Not sure if the behavior described in the "What is happening" section is correct, the docstring says the function should "Return the stop time of the last instruction, excluding delays, over the supplied qubits."

Any suggestions?

Perhaps return the maximum stop time of all qubits marked as done at the end of the instruction loop, and zero if none of the qubits is marked as done. Using a set of completed qubits rather than a dictionary may make it easier to determine the length of completed qubits. A similar change may be needed in determining the qubit start time.

@ewoutvandenberg ewoutvandenberg added the bug Something isn't working label Sep 12, 2022
@jakelishman
Copy link
Member

Please can you provide a minimal code example that shows this function not working as you expect, and what output you would expect to receive from it?

@ewoutvandenberg
Copy link
Author

ewoutvandenberg commented Sep 12, 2022

import qiskit

circuit = qiskit.QuantumCircuit(2)
circuit.x(0)

durations = qiskit.transpiler.InstructionDurations([('x',(0,), 80, 'dt')])
transpiled = qiskit.transpile(circuit,
                              initial_layout=[0,1],
                              basis_gates=['x'],
                              optimization_level=0,
                              scheduling_method='asap',
                              instruction_durations = durations)

print(transpiled.qubit_stop_time(0))   # 80
print(transpiled.qubit_stop_time(1))   # 0
print(transpiled.qubit_stop_time(0,1)) # Should be 80?

JustinWoodring added a commit to JustinWoodring/qiskit that referenced this issue Oct 24, 2023
@JustinWoodring
Copy link
Contributor

Here is a PR that addresses this issue, #11097.

github-merge-queue bot pushed a commit that referenced this issue Feb 13, 2025
* Fix incorrect stop time bug #8729

* Apply suggestions from code review

Minor update on the release note

* Update qiskit/circuit/quantumcircuit.py

Co-authored-by: Luciano Bello <bel@zurich.ibm.com>

* Update releasenotes/notes/fix-incorrect-qubit-stop-time-d0e056f60a01dd52.yaml

Co-authored-by: Luciano Bello <bel@zurich.ibm.com>

---------

Co-authored-by: Toshinari Itoko <15028342+itoko@users.noreply.github.com>
Co-authored-by: Luciano Bello <bel@zurich.ibm.com>
mergify bot pushed a commit that referenced this issue Feb 13, 2025
* Fix incorrect stop time bug #8729

* Apply suggestions from code review

Minor update on the release note

* Update qiskit/circuit/quantumcircuit.py

Co-authored-by: Luciano Bello <bel@zurich.ibm.com>

* Update releasenotes/notes/fix-incorrect-qubit-stop-time-d0e056f60a01dd52.yaml

Co-authored-by: Luciano Bello <bel@zurich.ibm.com>

---------

Co-authored-by: Toshinari Itoko <15028342+itoko@users.noreply.github.com>
Co-authored-by: Luciano Bello <bel@zurich.ibm.com>
(cherry picked from commit 6842268)
github-merge-queue bot pushed a commit that referenced this issue Feb 14, 2025
* Fix incorrect stop time bug #8729

* Apply suggestions from code review

Minor update on the release note

* Update qiskit/circuit/quantumcircuit.py

Co-authored-by: Luciano Bello <bel@zurich.ibm.com>

* Update releasenotes/notes/fix-incorrect-qubit-stop-time-d0e056f60a01dd52.yaml

Co-authored-by: Luciano Bello <bel@zurich.ibm.com>

---------

Co-authored-by: Toshinari Itoko <15028342+itoko@users.noreply.github.com>
Co-authored-by: Luciano Bello <bel@zurich.ibm.com>
(cherry picked from commit 6842268)

Co-authored-by: Justin Woodring <jwoodrg@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants