CQCL / pytket-qir

Public repo for the pytket-qir package

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Consider removing `pyqir_0_6_compatibility` code

qartik opened this issue · comments

We explicitly require pyqir 0.8.2 at

"pyqir == 0.8.2",

So the bit below and other pyqir_0_6_compatibility code is unneeded.

if pyqir_0_6_compatibility:
if len(circ.c_registers) > 1:
raise ValueError(
"""The qir optimised for pyqir 0.6 can only contain
one classical register"""
)
initial_result = str(populated_module.module.ir()) # type: ignore
initial_result = (
initial_result.replace("entry_point", "EntryPoint")
.replace("num_required_qubits", "requiredQubits")
.replace("num_required_results", "requiredResults")
)
def keep_line(line: str) -> bool:
return (
("@__quantum__qis__read_result__body" not in line)
and ("@set_one_bit_in_reg" not in line)
and ("@reg2var" not in line)
and ("@read_bit_from_reg" not in line)
and ("@set_all_bits_in_reg" not in line)
)
result = "\n".join(filter(keep_line, initial_result.split("\n")))
# replace the use of the removed register variable with i64 0
result = result.replace("i64 %0", "i64 0")
for _ in range(10):
result = result.replace("\n\n\n\n", "\n\n")
bitcode = pyqir.Module.from_ir(pyqir.Context(), result).bitcode # type: ignore
if qir_format == QIRFormat.BINARY:
return bitcode # type: ignore
elif qir_format == QIRFormat.STRING:
return result # type: ignore
else:
assert not "unsupported return type" # type: ignore
else:

@cqc-melf any objections? I can go ahead and remove this dead code if you agree.

We have added this in the past because we wanted to be compatible with older versions used on your side, if you don't need this it can be removed. Are you using now 0.8.x as well?

Yes, we are. There is no support for PyQIR below 0.8.2 in the backend compiler, AFAIK.

Just to confirm, @peter-campora do you think old versions are still in use and may require compatibility with pytket-qir?

Update (2023-08-15): We agreed that it can be removed.

solved by #66