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

FENCE should block qubits, not frames #143

Open
kalzoo opened this issue Jan 24, 2023 · 0 comments · May be fixed by #144
Open

FENCE should block qubits, not frames #143

kalzoo opened this issue Jan 24, 2023 · 0 comments · May be fixed by #144

Comments

@kalzoo
Copy link
Contributor

kalzoo commented Jan 24, 2023

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(())
              }
@kalzoo kalzoo linked a pull request Jan 25, 2023 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant