-
Notifications
You must be signed in to change notification settings - Fork 29
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
ConjugationEnvironment error #46
Comments
Hi Diego, |
The following in-place function should do :)
|
Thank you for the fix. I get what you mean for the QuantumVariable res, but r is indeed uncomputed within the algorithm. Do you mean something else? |
With the line |
Ah yes, indeed, and in this case you won't need to allocate it prior the conjugation |
The following code raises Exception: Tried to perform operation cswap on unallocated qubit qbl_392.0, which seems to be a bug
ERROR:
File ~\Documents\GitHub\Qrisp\src\qrisp\environments\conjugation_environment.py:163, in ConjugationEnvironment.enter(self)
161 instr = temp_data.pop(i)
162 if isinstance(instr, QuantumEnvironment):
--> 163 instr.compile()
164 else:
165 self.env_qs.data.append(instr)
File ~\Documents\GitHub\Qrisp\src\qrisp\environments\control_environment.py:336, in ControlEnvironment.compile(self)
332 instruction.qubits = [self.condition_truth_value] + list(
333 instruction.qubits
334 )
335 # Append instruction
--> 336 self.env_qs.append(instruction)
338 perm_unlock(ctrl_qubits)
340 if inversion_tracker == -1:
File ~\Documents\GitHub\Qrisp\src\qrisp\core\quantum_session.py:446, in QuantumSession.append(self, operation_or_instruction, qubits, clbits)
444 if issubclass(operation_or_instruction.class, Instruction):
445 instruction = operation_or_instruction
--> 446 self.append(instruction.op, instruction.qubits, instruction.clbits)
447 return
450 elif issubclass(operation_or_instruction.class, Operation):
File ~\Documents\GitHub\Qrisp\src\qrisp\core\quantum_session.py:496, in QuantumSession.append(self, operation_or_instruction, qubits, clbits)
490 raise Exception(
491 f"Tried to perform operation {operation.name} on "
492 f"unallocated qubit {input}"
493 )
495 if operation.name not in ["qb_alloc", "barrier"]:
--> 496 check_alloc(qubits)
499 # We now need to merge the sessions and treat their differing environment
500 # levels. The idea here is that if a quantum session A is not identical to the
501 # environment session B, there have been no gates applied within that
502 # environment so far (otherwise merging would have occured). Thus, all data of A
503 # belongs into the original_data attribute of the environment with the highest
504 # level environment, where the environment quantum session isn't identical to A.
505 flattened_qubits = []
File ~\Documents\GitHub\Qrisp\src\qrisp\core\quantum_session.py:486, in QuantumSession.append..check_alloc(input, res)
484 if isinstance(input, list):
485 for item in input:
--> 486 check_alloc(item)
487 else:
488 if not input.allocated:
489 # pass
File ~\Documents\GitHub\Qrisp\src\qrisp\core\quantum_session.py:490, in QuantumSession.append..check_alloc(input, res)
487 else:
488 if not input.allocated:
489 # pass
--> 490 raise Exception(
491 f"Tried to perform operation {operation.name} on "
492 f"unallocated qubit {input}"
493 )
Exception: Tried to perform operation cswap on unallocated qubit qbl_400.0
}
The text was updated successfully, but these errors were encountered: