Skip to content

Commit

Permalink
add phi nodes (#163)
Browse files Browse the repository at this point in the history
* add second step of phi node

* Update pytket/qir/conversion/api.py

Co-authored-by: Alec Edgington <54802828+cqc-alec@users.noreply.github.com>

* replace register/int functions

* add link to adaptive profile

* clean up

---------

Co-authored-by: Alec Edgington <54802828+cqc-alec@users.noreply.github.com>
  • Loading branch information
cqc-melf and cqc-alec committed Aug 20, 2024
1 parent c86df01 commit 8010236
Show file tree
Hide file tree
Showing 46 changed files with 7,741 additions and 7 deletions.
2 changes: 1 addition & 1 deletion _metadata.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__extension_version__ = "0.12.0"
__extension_version__ = "0.13.0"
__extension_name__ = "pytket-qir"
5 changes: 5 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Changelog
~~~~~~~~~

0.13.0
------

* Add option to generate profile compatible QIR

0.12.0 (July 2024)
------------------

Expand Down
29 changes: 25 additions & 4 deletions pytket/qir/conversion/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

from .conversion import QirGenerator
from .module import tketqirModule
from .pconversion import PQirGenerator


class QIRFormat(Enum):
Expand All @@ -47,6 +48,7 @@ def pytket_to_qir(
wfh: Optional[wasm.WasmFileHandler] = None,
int_type: int = 64,
cut_pytket_register: bool = False,
profile: bool = False,
) -> Union[str, bytes, None]:
"""converts given pytket circuit to qir
Expand All @@ -58,6 +60,11 @@ def pytket_to_qir(
:param int_type: size of each integer, allowed value 32 and 64
:param cut_pytket_register: breaks up the internal scratch bit registers
into smaller registers, default value false
:param profile: generates QIR corresponding to the adaptive profile
You can find more details about the adaptive profile under:
https://github.com/qir-alliance/qir-spec/pull/35
and soon at:
https://github.com/qir-alliance/qir-spec/tree/main/specification/under_development/profiles/Adaptive_Profile.md
"""

if cut_pytket_register:
Expand All @@ -71,12 +78,26 @@ def pytket_to_qir(
num_qubits=circ.n_qubits,
num_results=circ.n_qubits,
)
if not profile:
qir_generator = QirGenerator(
circuit=circ,
module=m,
wasm_int_type=int_type,
qir_int_type=int_type,
wfh=wfh,
)

qir_generator = QirGenerator(
circuit=circ, module=m, wasm_int_type=int_type, qir_int_type=int_type, wfh=wfh
)
populated_module = qir_generator.circuit_to_module(qir_generator.circuit, True)
else:
qir_generator = PQirGenerator( # type: ignore
circuit=circ,
module=m,
wasm_int_type=int_type,
qir_int_type=int_type,
wfh=wfh,
)

populated_module = qir_generator.circuit_to_module(qir_generator.circuit, True)
populated_module = qir_generator.circuit_to_module(qir_generator.circuit, True)

if wfh is not None:
wasm_sar_dict: dict[str, str] = qir_generator.get_wasm_sar()
Expand Down
Loading

0 comments on commit 8010236

Please sign in to comment.