Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider removing pyqir_0_6_compatibility code #65

Closed
qartik opened this issue Aug 8, 2023 · 4 comments
Closed

Consider removing pyqir_0_6_compatibility code #65

qartik opened this issue Aug 8, 2023 · 4 comments
Assignees

Comments

@qartik
Copy link
Member

qartik commented Aug 8, 2023

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:

@qartik
Copy link
Member Author

qartik commented Aug 9, 2023

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

@cqc-melf
Copy link
Collaborator

cqc-melf commented Aug 9, 2023

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?

@qartik
Copy link
Member Author

qartik commented Aug 9, 2023

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.

@cqc-melf
Copy link
Collaborator

solved by #66

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

No branches or pull requests

2 participants