-
Notifications
You must be signed in to change notification settings - Fork 17
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Feature Description
Currently, the squin visitor always returns None from the converted QIR function. We need to implement support for returning measurement results from specified qubits when the return_measurements parameter is provided.
Blocked by:
- Measurement operations need to be stable in the
squinpackage before this can be implemented
Implementation (Optional)
Location: qbraid_qir/squin/visitor.py (lines 124-154)
Proposed changes:
-
Validate qubit indices - Ensure requested qubits are within valid range
[0, num_qubits) -
Check measurement existence - Verify that the requested qubits were actually measured during the circuit execution
-
Return measurement results:
- Single qubit: Return the measurement result directly
- Multiple qubits: Create a
py.tuple.Newwith all measurement results and return the tuple
-
Track measurements - The
targetobject needs to maintain ameasurement_resultsdictionary mapping qubit IDs to their measurement result values
Code outline:
if return_measurements and len(return_measurements) > 0:
measurement_results = []
for qid in return_measurements:
# Validate qubit index
# Check if qubit was measured
# Append result to measurement_results
if len(measurement_results) == 1:
return_value = measurement_results[0]
else:
tuple_stmt = py.tuple.New(values=tuple(measurement_results))
body.blocks[0].stmts.append(tuple_stmt)
return_value = tuple_stmt.result
else:
return_value = func.ConstantNone()Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request