Skip to content

FENCE should block qubits, not frames #143

@kalzoo

Description

@kalzoo

Per the Quil-T spec:

Fence ensures that all operations involving the specified qubits that follow the fence statement happen after all operations involving the specified qubits that preceed the fence statement. If no qubits are specified, the FENCE operation implicitly applies to all qubits on the device.

However, this is not how quil-rs works today. Instead, it considers that FENCE blocks frames:

            Instruction::Fence(Fence { qubits }) => Some(if qubits.is_empty() {
                FrameMatchCondition::All
            } else {
                FrameMatchCondition::AnyOfQubits(Cow::Borrowed(qubits))
            }),

and then it treats them the same as any other pulse-control instruction:

            InstructionRole::RFControl => {
                  let used_frames = program
                      .get_frames_for_instruction(instruction, false)
                      .unwrap_or_default();

                  let blocked_frames = program
                      .get_frames_for_instruction(instruction, true)
                      .unwrap_or_default();

                  let blocked_but_not_used_frames = blocked_frames.difference(&used_frames);

                  for frame in &used_frames {
                      let previous_node_ids = last_instruction_by_frame
                          .entry((*frame).clone())
                          .or_default()
                          .get_dependencies_for_next_user(node);

                      for previous_node_id in previous_node_ids {
                          add_dependency!(graph, previous_node_id => node, ExecutionDependency::ReferenceFrame);
                      }
                  }

                  for frame in blocked_but_not_used_frames {
                      if let Some(previous_node_id) = last_instruction_by_frame
                          .entry((*frame).clone())
                          .or_default()
                          .get_dependency_for_next_blocker(node)
                      {
                          add_dependency!(graph, previous_node_id => node, ExecutionDependency::ReferenceFrame);
                      }
                  }

                  Ok(())
              }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions