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

Feature Request: Add TQDM Progress Bar to Qiskit Transpiler Passes #13664

Open
blannix opened this issue Jan 14, 2025 · 1 comment
Open

Feature Request: Add TQDM Progress Bar to Qiskit Transpiler Passes #13664

blannix opened this issue Jan 14, 2025 · 1 comment
Labels
type: feature request New feature or request

Comments

@blannix
Copy link

blannix commented Jan 14, 2025

What should we add?

Context and Motivation
In the current implementation of Qiskit, the transpilation process can often take significant time, especially for large quantum circuits targeting complex backends. Users typically experience uncertainty about the progress of the transpilation process, as the output provides no real-time updates or estimates of completion time. This lack of feedback can lead to a frustrating user experience, particularly when debugging or optimizing transpilation workflows.

By integrating a progress bar such as TQDM into the transpiler passes, users can gain better visibility into the progress of transpilation. This would:

  • Improve Usability: Provide real-time feedback on the progress of individual passes and the overall transpilation process.
  • Enhance Debugging: Help users identify bottlenecks in specific passes by showing their durations.
  • Increase Productivity: Allow users to estimate completion time for long-running transpilation tasks, enabling better resource allocation.

Proposed Implementation

  • TQDM Integration: Add TQDM progress bars within the transpiler to visually track the progress of individual passes and the overall pass manager flow.
  • Configurable Output: Allow users to enable or disable the progress bar via a parameter in the PassManager object, e.g., show_progress=True.
  • Detailed Information:
    • Display the name of the current pass being executed.
    • Show the percentage of completion for the overall pass manager flow.
    • Optionally, include the estimated time remaining.

Example Usage

from qiskit import QuantumCircuit
from qiskit.transpiler import PassManager
from qiskit.providers.fake_provider import FakeGuadalupe
from qiskit.transpiler.passes import Unroll3qOrMore, CXDirection, LayoutSelection

# Create a circuit
circuit = QuantumCircuit(4)
circuit.h(0)
circuit.cx(0, 1)
circuit.cx(1, 2)
circuit.measure_all()

# Choose backend
backend = FakeGuadalupe()

# Create a Pass Manager with progress tracking enabled
passes = [
    Unroll3qOrMore(),
    CXDirection(backend.properties()),
    LayoutSelection()
]
pass_manager = PassManager(passes, show_progress=True)

# Run the circuit through the Pass Manager
optimized_circuit = pass_manager.run(circuit)

Output Example:

Transpilation Progress:
[Pass 1/3: Unroll3qOrMore] ████▊                         30%  ETA: 00:10
[Pass 2/3: CXDirection]    ██████████▌                   50%  ETA: 00:05
...

Impact
This feature would significantly enhance the developer and user experience for Qiskit, particularly for those working with large-scale circuits or conducting extensive performance optimizations. Adding a progress bar aligns with modern usability expectations for long-running computational processes and demonstrates Qiskit’s commitment to developer-friendly tools.

@blannix blannix added the type: feature request New feature or request label Jan 14, 2025
@jakelishman
Copy link
Member

Users typically experience uncertainty about the progress of the transpilation process, as the output provides no real-time updates or estimates of completion time.

The compiler doesn't know these things either - it's not calculable, and any estimate would be a completely wild stab in the dark. There's no real measure of "how much work is left", in most cases. We generally don't even know how many tasks are left: many optimisations run in a loop until a fixed point is hit, so the number of iterations is indeterminate; some passes only run if a precondition is violated by the optimisation loop, which can't be known ahead of time.

You can observe passes completing by passing an arbitrary Python callable to the callback argument of PassManager.run, so if you wanted, you could print out each pass name as it completed, but PassManager can't tell you reliably at any point how many more passes there are to run (dynamically deciding when passes need to be inserted is part of its job).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants