From e108592c258b7d74b2c38d47fb04260c01ac392b Mon Sep 17 00:00:00 2001 From: Neal Erickson Date: Wed, 4 Oct 2023 16:56:29 -0600 Subject: [PATCH] Initial approach outline --- pytket/phir/api.py | 22 ++++++++++++++++++++++ pytket/phir/main.py | 29 ----------------------------- 2 files changed, 22 insertions(+), 29 deletions(-) create mode 100644 pytket/phir/api.py delete mode 100644 pytket/phir/main.py diff --git a/pytket/phir/api.py b/pytket/phir/api.py new file mode 100644 index 0000000..65b513b --- /dev/null +++ b/pytket/phir/api.py @@ -0,0 +1,22 @@ +from pytket.circuit import Circuit + +from .sharding.sharder import Sharder + + +def pytket_to_phir( + circuit: Circuit, +) -> str: + """Converts a pytket circuit into its PHIR representation + + :param circuit: Circuit object to be converted + """ + + # TODO: Process circuit according to desired machine architecture + + sharder = Sharder(circuit) + shards = sharder.shard() # noqa: F841 + + # TODO: Pass shards[] into placement, routing, etc + # TODO: Convert to PHIR JSON spec and return + + return "{ phir json, someday }" diff --git a/pytket/phir/main.py b/pytket/phir/main.py deleted file mode 100644 index a8d37c1..0000000 --- a/pytket/phir/main.py +++ /dev/null @@ -1,29 +0,0 @@ -""" -NOTE: Just a placeholder to allow convenient testing of the flows -""" - -from pytket.circuit import Circuit -from pytket.qasm.qasm import circuit_from_qasm - -from .sharding.sharder import Sharder - -# Load a qasm circuit and parse -# ,=""=, -# c , _,{ -# /\ @ ) __ -# / ^~~^\ <=.,__/ '}= -# (_/ ,, ,,) \_ _>_/~ -# ~\_(/-\)'-,_,_,_,-'(_)-(_) -circuit: Circuit = circuit_from_qasm("tests/data/qasm/baby.qasm") - -# https://cqcl.github.io/tket/pytket/api/circuit_class.html - -# Just a little debugging fun -print("Input circuit:") -print(circuit) -print() - -sharding_output = Sharder(circuit).shard() - -print("Sharding output:") -print(sharding_output)