diff --git a/CHANGELOG.md b/CHANGELOG.md index ed080aa9a..64f3a9e50 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ Changelog - Fixed the QCS access request link in the README (@amyfbrown, gh-1171). - Fix the SDK download link and instructions in the docs (@amyfbrown, gh-1173). +- Removed HALT from valid Protoquil / supported Quil. (@kilimanjaro, gh-1176). [v2.17](https://github.com/rigetti/pyquil/compare/v2.16.0...v2.17.0) (January 30, 2020) --------------------------------------------------------------------------------------- diff --git a/pyquil/quil.py b/pyquil/quil.py index 06d6f1279..15526e1a4 100644 --- a/pyquil/quil.py +++ b/pyquil/quil.py @@ -68,7 +68,6 @@ JumpUnless, JumpWhen, Declare, - Halt, Reset, ResetQubit, DefPermutationGate, @@ -609,8 +608,7 @@ def is_supported_on_qpu(self) -> bool: """ Whether the program can be compiled to the hardware to execute on a QPU. These Quil programs are more restricted than Protoquil: for instance, RESET must be before any - gates or MEASUREs, MEASURE on a qubit must be after any gates on that qubit, and - no instructions can occur after HALT. + gates or MEASUREs, and MEASURE on a qubit must be after any gates on that qubit. :return: True if the Program is supported Quil, False otherwise """ @@ -1109,7 +1107,7 @@ def validate_protoquil(program: Program) -> None: :param program: The Quil program to validate. """ - valid_instruction_types = tuple([Pragma, Declare, Halt, Gate, Reset, ResetQubit, Measurement]) + valid_instruction_types = tuple([Pragma, Declare, Gate, Reset, ResetQubit, Measurement]) for instr in program.instructions: if not isinstance(instr, valid_instruction_types): # Instructions like MOVE, NOT, JUMP, JUMP-UNLESS will fail here @@ -1120,18 +1118,15 @@ def validate_supported_quil(program: Program) -> None: """ Ensure that a program is supported Quil which can run on any QPU, otherwise raise a ValueError. We support a global RESET before any gates, and MEASUREs on each qubit after any gates - on that qubit. PRAGMAs and DECLAREs are always allowed, and a final HALT instruction is allowed. + on that qubit. PRAGMAs and DECLAREs are always allowed. :param program: The Quil program to validate. """ gates_seen = False measured_qubits: Set[int] = set() - for i, instr in enumerate(program.instructions): + for instr in program.instructions: if isinstance(instr, Pragma) or isinstance(instr, Declare): continue - elif isinstance(instr, Halt): - if i != len(program.instructions) - 1: - raise ValueError(f"Cannot have instructions after HALT") elif isinstance(instr, Gate): gates_seen = True if any(q.index in measured_qubits for q in instr.qubits): diff --git a/pyquil/tests/test_quil.py b/pyquil/tests/test_quil.py index bdf9485f1..3000cfc74 100755 --- a/pyquil/tests/test_quil.py +++ b/pyquil/tests/test_quil.py @@ -1235,7 +1235,6 @@ def test_validate_supported_quil_suite(): CZ 2 3 MEASURE 2 ro[2] MEASURE 3 ro[3] -HALT """ ) ) @@ -1252,7 +1251,6 @@ def test_validate_supported_quil_suite(): MEASURE 2 ro[2] X 3 MEASURE 3 ro[3] -HALT """ ) )