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

Delayed Phase Correction #397

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
c81eb40
Removed fixed gateset and replaced with parameter.
pehamTom Nov 10, 2023
5eb3747
Check if gateset is Clifford.
pehamTom Nov 10, 2023
8c9d539
Added completens check for single-qubit Gatesets.
pehamTom Nov 10, 2023
1cd55fd
Extracted Gateset in separate file and pass gateset through config.
pehamTom Nov 10, 2023
256f588
Bindings for Gateset.
pehamTom Nov 10, 2023
d218f42
Commit missing file.
pehamTom Nov 13, 2023
af8ee8f
Relax ExactlyOne constraint for depth-optimal synthesis.
pehamTom Nov 13, 2023
eb35989
Always add the none gate.
pehamTom Nov 13, 2023
b2e3a92
Merge branch 'tom-dev' into relax-exactly-one-constraint
pehamTom Nov 13, 2023
848e9d7
Removed templates.
pehamTom Nov 13, 2023
7690afa
Merge branch 'tom-dev' into relax-exactly-one-constraint
pehamTom Nov 13, 2023
d334f58
Made GateSet into an actual set.
pehamTom Nov 13, 2023
267c2b1
Merge branch 'tom-dev' into relax-exactly-one-constraint
pehamTom Nov 13, 2023
f58a738
Can only relax constraints if no Paulis are in the target Gateset.
pehamTom Nov 13, 2023
3b3f028
added setting for delaying paulis.
pehamTom Nov 13, 2023
e6c3348
Extract common functionality of different encoders.
pehamTom Nov 13, 2023
f45ac80
Added new class for handling the encoding for phase correction.
pehamTom Nov 14, 2023
cad2a04
Added files for encoder.
pehamTom Nov 14, 2023
c02c8ed
Encoding and tests for delayed phase correction.
pehamTom Nov 14, 2023
0608ae9
Fixed tests.
pehamTom Nov 14, 2023
e8d4794
🎨 pre-commit fixes
pre-commit-ci[bot] Nov 14, 2023
b8423cc
Fix constexpr error.
pehamTom Nov 14, 2023
995ed9d
Merge remote-tracking branch 'origin/postpone-paulis' into postpone-p…
pehamTom Nov 14, 2023
6a3bafa
🎨 pre-commit fixes
pre-commit-ci[bot] Nov 14, 2023
dac77bb
missing header?
pehamTom Nov 15, 2023
60f64ca
Merge remote-tracking branch 'origin/postpone-paulis' into postpone-p…
pehamTom Nov 15, 2023
4291548
Missing include.
pehamTom Nov 15, 2023
245f55c
🎨 pre-commit fixes
pre-commit-ci[bot] Nov 15, 2023
a0652f0
Linter warnings.
pehamTom Nov 15, 2023
aaeb22f
Merge remote-tracking branch 'origin/postpone-paulis' into postpone-p…
pehamTom Nov 15, 2023
4b48b48
Fixed relation of consistency constraints.
pehamTom Nov 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Check if gateset is Clifford.
pehamTom committed Nov 10, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 5eb37479f6dd2229ee1ca4d3c1dec319ca417a77
29 changes: 27 additions & 2 deletions include/cliffordsynthesis/encoding/GateEncoder.hpp
Original file line number Diff line number Diff line change
@@ -5,18 +5,25 @@

#pragma once

#include "Definitions.hpp"
#include "LogicBlock/LogicBlock.hpp"
#include "cliffordsynthesis/Results.hpp"
#include "cliffordsynthesis/encoding/TableauEncoder.hpp"
#include "operations/OpType.hpp"

#include <algorithm>
#include <cstddef>
#include <memory>
#include <utility>
#include <vector>

namespace cs::encoding {
class GateSet : public std::vector<qc::OpType> {
static constexpr std::array<qc::OpType, 9> SINGLE_QUBIT_CLIFFORDS = {
qc::OpType::I, qc::OpType::H, qc::OpType::X,
qc::OpType::Y, qc::OpType::Z, qc::OpType::S,
qc::OpType::Sdg, qc::OpType::SX, qc::OpType::SXdg};

public:
using std::vector<qc::OpType>::vector;

@@ -34,9 +41,15 @@ class GateSet : public std::vector<qc::OpType> {
[[nodiscard]] bool containsZ() const { return containsGate<qc::OpType::Z>(); }
[[nodiscard]] bool containsH() const { return containsGate<qc::OpType::H>(); }
[[nodiscard]] bool containsS() const { return containsGate<qc::OpType::S>(); }
[[nodiscard]] bool containsSdag() const {
[[nodiscard]] bool containsSdg() const {
return containsGate<qc::OpType::Sdg>();
}
[[nodiscard]] bool containsSX() const {
return containsGate<qc::OpType::SX>();
}
[[nodiscard]] bool containsSXdg() const {
return containsGate<qc::OpType::SXdg>();
}
[[nodiscard]] std::size_t gateToIndex(const qc::OpType type) const {
for (std::size_t i = 0; i < this->size(); ++i) {
if (this->at(i) == type) {
@@ -45,6 +58,14 @@ class GateSet : public std::vector<qc::OpType> {
}
return 0;
}

[[nodiscard]] bool isValidGateSet() const {
return std::all_of(this->begin(), this->end(), [](const auto& g) {
return std::find(SINGLE_QUBIT_CLIFFORDS.begin(),
SINGLE_QUBIT_CLIFFORDS.end(),
g) != SINGLE_QUBIT_CLIFFORDS.end();
});
}
};
class GateEncoder {
public:
@@ -57,7 +78,11 @@ class GateEncoder {
qc::OpType::X, qc::OpType::Y,
qc::OpType::Z})
: N(nQubits), S(tableauSize), T(timestepLimit), tvars(tableauVars),
lb(std::move(logicBlock)), singleQubitGates(std::move(singleQGates)) {}
lb(std::move(logicBlock)), singleQubitGates(std::move(singleQGates)) {
if (!singleQGates.isValidGateSet()) {
throw qc::QFRException("Invalid gate set");
}
}
virtual ~GateEncoder() = default;

struct Variables {
6 changes: 3 additions & 3 deletions src/cliffordsynthesis/encoding/GateEncoder.cpp
Original file line number Diff line number Diff line change
@@ -266,7 +266,7 @@ void GateEncoder::assertSingleQubitGateCancellationConstraints(
disallowed = disallowed && !gSNext[gateIndex][qubit];
}

if (singleQubitGates.containsS() && singleQubitGates.containsSdag()) {
if (singleQubitGates.containsS() && singleQubitGates.containsSdg()) {
const auto gateIndexS = singleQubitGates.gateToIndex(qc::OpType::S);
const auto gateIndexSdg = singleQubitGates.gateToIndex(qc::OpType::Sdg);

@@ -297,7 +297,7 @@ void GateEncoder::assertSingleQubitGateCancellationConstraints(
auto gates = gSNow[gateIndexS][qubit];
auto disallowed = !gSNext[gateIndexS][qubit];

if (singleQubitGates.containsSdag()) {
if (singleQubitGates.containsSdg()) {
auto gateIndexSdag = singleQubitGates.gateToIndex(qc::OpType::Sdg);

// -Sd-Sd- = -Z-
@@ -312,7 +312,7 @@ void GateEncoder::assertSingleQubitGateCancellationConstraints(

lb->assertFormula(LogicTerm::implies(gates, disallowed));
} else {
if (singleQubitGates.containsSdag()) {
if (singleQubitGates.containsSdg()) {
auto gateIndexSdag = singleQubitGates.gateToIndex(qc::OpType::Sdg);

// -S-Sd- = -I-