Depth calculation can be improved
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 15/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- python
- Domain
- compilers, quantum-computing
Research direction
Start with the linked Catalyst pull request #3426 and PennyLane pull request #10440; both contain candidate implementations, and the issue says they are large and AI-generated. Check the proposed dependency summaries against the two examples, especially the expected depths of 100 and 44, then review the stated platform, version, and workload coverage gaps. The issue considers the work done when the metric semantics and analysis cost have been reviewed and integration coverage is added.
Written by the indexing model from the issue text.
Description
The PBC resource analysis can overestimate circuit depth. In particular, adding subroutine depths can incorrectly serialize operations on independent qubits. To unlock my work, I have created two branches that potentially solve this issue (AI generated, very big PR 😅). I'm sharing the details in case this is useful.
- Catalyst implementation: https://github.com/PennyLaneAI/catalyst/pull/3426
- PennyLane integration: https://github.com/PennyLaneAI/pennylane/pull/10440
Example 1: Independent sequences on two qubits
import pennylane as qp
from catalyst import qjit
from catalyst.passes import to_ppr
@qjit(
target="mlir",
pipelines=[("pipe", ["quantum-compilation-stage"])],
)
@to_ppr
@qp.qnode(qp.device("lightning.qubit", wires=2))
def circuit():
for _ in range(100):
qp.T(0)
for _ in range(100):
qp.T(1)
resources = qp.analyze(circuit, level=1)().resources
print(resources.qubit_disjoint_depth)
For the sequence of 100 gates on each wire, the expected qubit-disjoint depth is 100, rather than 200.
Each qubit has 100 sequential operations, but the two sequences are independent and can occupy the same 100 logical layers. Their order in the Python source does not introduce a quantum dependency between the wires.
Example 2: Deterministic synthesis
The same principle should apply when the independent sequences are generated by synthesis.
import numpy as np
import pennylane as qp
from catalyst import qjit
from catalyst.passes import to_ppr
PBC = {
"PPR_8": 100,
"PPR_4": 10,
"PPR_2": 1,
"GlobalPhase": 0,
"PauliMeasure": 2,
"PauliMeasureMP": 2,
"MidMeasure": 2,
"MidMeasureMP": 2,
"MidCircuitMeasure": 2,
}
epsilon = 1e-4
syllables_per_rz = 0.58 * np.log2(1 / epsilon) + 3.7
PBC_RZ = PBC | {"RZ": 110 * syllables_per_rz}
@qjit(
capture=True,
target="mlir",
pipelines=[("pipe", ["quantum-compilation-stage"])],
)
@to_ppr
@qp.transforms.gridsynth(
method="deterministic",
epsilon=epsilon,
ppr_basis=True,
)
@qp.transform(pass_name="symbol-dce")
@qp.decompose(gate_set=PBC_RZ)
@qp.qnode(qp.device("null.qubit", wires=2))
def circuit():
qp.RX(0.2, wires=0)
qp.RY(0.2, wires=1)
resources = qp.analyze(circuit, level="user")().resources
assert resources.extra["qubit_disjoint_depth_status"] == "exact"
print(resources.qubit_disjoint_depth)
With the tested PR revisions, this prints 44 with status exact. Placing both rotations on the same qubit gives 86, reflecting the additional sequential dependencies.
This example deliberately uses method="deterministic". The original mixed-fallback variant is not covered by this deterministic-depth guarantee.
Proposed solution
Catalyst tracks per-qubit dependencies and composes them across function calls and supported loops. This preserves parallelism between independent operations while respecting dependencies on shared qubits.
The implementation:
- Replaces scalar depth aggregation with dependency summaries.
- Reuses summaries across compatible function calls.
- Composes invariant loop summaries without fully unrolling the loop.
- Resolves supported classical computations when their values determine the quantum dependency graph.
- Supports deterministic PPR synthesis by analyzing the sequence produced by the synthesis runtime.
- Reports
exactwhen the complete logical depth can be determined, andunavailableotherwise.
PennyLane consumes the certified total instead of reconstructing depth by summing child results. Unsupported cases return None with an explicit status. The new path also leaves any_commuting_depth unavailable, since an exact qubit-disjoint schedule does not establish commuting depth.
Larger workflow validation
The tested ODMR configuration reports exact depths of:
to-ppr: 3,034,595,019ppr-to-ppm: 6,046,959,517
These results demonstrate the application of dependency analysis to a larger workflow. They do not establish a compilation-speed improvement.
Scope and tradeoffs
The intended metric is the logical depth of the emitted PBC dependency graph. It measures the parallelism already present in that graph; it does not optimize the circuit or predict physical execution time.
Exact analysis requires additional computation and memory. Dense dependency summaries retain quadratic storage and cubic composition time in the general worst case, although summary reuse improves important repeated patterns.
Resolving classical computations and synthesis also introduces integration and maintenance requirements. Unknown inputs, unsupported control flow, or analysis limits can produce unavailable, so downstream consumers must handle missing depth values explicitly.
Before merging, the implementation should receive integration coverage across supported platforms and PennyLane/Catalyst versions, together with review of the metric's semantics and analysis cost on representative workloads.
- Dominant language
- Python
- Stars
- 234
- Forks
- 84
- Avg merge
- 3d 11h
- Merged PRs (30d)
- 78
Getting set up
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from PennyLaneAI/catalyst
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
PennyLaneAI/catalyst#3489 ·
Maintainers usually reply within 1 day
-
Fix platform tag for macOS wheelsMay be free again @sarehaskari17 claimed this 107 days ago, and no pull request is open. OpenCI/Build enhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
PennyLaneAI/catalyst#2907 · 2 comments ·
Maintainers usually reply within 1 day
-
The docs page for `CompileOptions` is missing a description for the `target` attributePossibly taken @daxsh2803 claimed this 68 days ago. Opendocumentation
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
PennyLaneAI/catalyst#2653 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 68/100
PennyLaneAI/catalyst#3550 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 57/100
PennyLaneAI/catalyst#3497 ·
Maintainers usually reply within 1 day
All issues in PennyLaneAI/catalyst
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
521xueweihan/HelloGitHub#4729 ·
-
auto-reported bug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
needs-triage type:bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
pollen-robotics/reachy_mini_conversation_app#631 ·
Maintainers usually reply within 7 days
-
stix-atlas.json: the same relationship id is used for several different mitigates relationshipsOpen
Difficulty 2/5 1-3 hours Newbie friendliness 76/100