Skip to content

Implement Q# circuit generation#363

Draft
RushiGong wants to merge 9 commits intomainfrom
feature/rsg/qsharp-circuit
Draft

Implement Q# circuit generation#363
RushiGong wants to merge 9 commits intomainfrom
feature/rsg/qsharp-circuit

Conversation

@RushiGong
Copy link
Contributor

This PR implements Q# circuit operations for

  • State preparation
  • Controlled time evolution
  • Iterative quantum phase estimation

@RushiGong RushiGong force-pushed the feature/rsg/qsharp-circuit branch from 069cc84 to 590ae25 Compare February 12, 2026 21:52
sparse_circuit = sparse_prep.run(wfn_cas)
print(f"Regular isometry QASM:\n{regular_circuit.get_qasm()}")
print(f"Sparse isometry QASM:\n{sparse_circuit.get_qasm()}")
print(f"Regular isometry circuit:\n{regular_circuit.get_qiskit_circuit()}")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why should this not continue to be QASM?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The current flow generates circuit through Q#, which will go through Q# ->qir -> qiskit, without using QASM as an intermediate.

n_qubits,
prune_classical_qubits=self._settings.get("prune_classical_qubits"),
)
qir = qsharp.compile(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this something we always want? Can it be lazy/memoized in Circuit?


from __future__ import annotations

import pyqir
Copy link
Collaborator

Choose a reason for hiding this comment

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

We will need to add this to the dependencies

def _on_call_instr(self, call: pyqir.Call) -> None:
"""Handle call instructions."""
# Handle CNOT alias (parent only dispatches cx)
if call.callee.name == "__quantum__qis__cnot__body":
Copy link
Collaborator

Choose a reason for hiding this comment

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

@swernli or @idavis what is the QDK convention here? Should we just pass through as well?

Copy link

Choose a reason for hiding this comment

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

This was an oversight on my part. The QDK always generates __quantum__qis__cx__body but there is an older code path in the PyQIR simple builder that produces __quantum__qis__cnot__body. If the intent of this code path is to accept arbitrary QIR then this extra check should be kept. If the intent is just to handle QIR that was compiled from Q# or OpenQASM via the QDK, then you can be sure that only the cx variant is produced.

@RushiGong RushiGong force-pushed the feature/rsg/qsharp-circuit branch from cf19676 to b2bdb2f Compare February 18, 2026 21:36
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.

3 participants

Comments