-
Notifications
You must be signed in to change notification settings - Fork 26
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
Feature/TwoQubitEncoding #342
Draft
avelsh
wants to merge
38
commits into
cda-tum:main
Choose a base branch
from
avelsh:feature/avelsh
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
5a32776
set the main structure
014f075
Merge branch 'main' into feature/avelsh
avelsh 9c9256e
🎨 pre-commit fixes
pre-commit-ci[bot] a7822e0
add SQG and TQG encoding
59393a8
🎨 pre-commit fixes
pre-commit-ci[bot] cdd566e
update comments
716b8a6
Merge remote-tracking branch 'origin/feature/avelsh' into feature/avelsh
499b06e
🎨 pre-commit fixes
pre-commit-ci[bot] d283ef8
update according to comments, rename two qubit encoder
77cc2a5
Merge remote-tracking branch 'origin/feature/avelsh' into feature/avelsh
7c7d542
🎨 pre-commit fixes
pre-commit-ci[bot] 9b0155a
correct asssertTwoQubitGateConstr
c9c1a44
Merge remote-tracking branch 'origin/feature/avelsh' into feature/avelsh
0266b24
🎨 pre-commit fixes
pre-commit-ci[bot] 122dd5d
fix two qubit encoding
1c0a309
rename from STDepth to TQDepth
7ca3ec7
sync with upstream
dfea58a
🎨 pre-commit fixes
pre-commit-ci[bot] cf12bef
remove addIdentityGateToTQGVariables func
c095997
set a new func for founding of a two qubit depth
b6e11dd
Merge remote-tracking branch 'origin/feature/avelsh' into feature/avelsh
b128086
🎨 pre-commit fixes
pre-commit-ci[bot] e37653d
fix founding of phase and set the last layer of paulis
8d1da8f
remove irrelevant tests
d042b11
set bindings and small fixes
92c5df6
optimize the using of variables
727fba8
Merge branch 'main' into feature/avelsh
pehamTom 0425bfc
Merge remote-tracking branch 'avelsh/feature/avelsh' into feature/avelsh
pehamTom bd9af05
🎨 pre-commit fixes
pre-commit-ci[bot] 3a4c206
Added parsing of target metric for two_qubit_depth
pehamTom 247e276
Merge remote-tracking branch 'avelsh/feature/avelsh' into feature/avelsh
pehamTom 1b39f2b
update according comments
c8bb1d6
Merge remote-tracking branch 'origin/feature/avelsh' into feature/avelsh
a80fd55
🎨 pre-commit fixes
pre-commit-ci[bot] 098d4d6
set a new extra SQG layer
caafb46
🎨 pre-commit fixes
pre-commit-ci[bot] 31090be
create a new func pauliGateToIndex
292052b
Merge remote-tracking branch 'origin/feature/avelsh' into feature/avelsh
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Submodule mqt-core
updated
19 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,8 +40,8 @@ class GateEncoder { | |
}; | ||
|
||
// variable creation | ||
void createSingleQubitGateVariables(); | ||
void createTwoQubitGateVariables(); | ||
virtual void createSingleQubitGateVariables(); | ||
virtual void createTwoQubitGateVariables(); | ||
|
||
// encode the relation between the tableaus and the gates | ||
virtual void encodeGates() { | ||
|
@@ -52,13 +52,17 @@ class GateEncoder { | |
virtual void encodeSymmetryBreakingConstraints(); | ||
|
||
// extracting the circuit | ||
void extractCircuitFromModel(Results& res, logicbase::Model& model); | ||
virtual void extractCircuitFromModel(Results& res, logicbase::Model& model); | ||
|
||
[[nodiscard]] auto* getVariables() { return &vars; } | ||
|
||
static constexpr std::array<qc::OpType, 7> SINGLE_QUBIT_GATES = { | ||
qc::OpType::None, qc::OpType::X, qc::OpType::Y, qc::OpType::Z, | ||
qc::OpType::H, qc::OpType::S, qc::OpType::Sdag}; | ||
// TODO: set back | ||
static constexpr std::array<qc::OpType, 4> SINGLE_QUBIT_GATES = { | ||
qc::OpType::None, qc::OpType::H, qc::OpType::S, qc::OpType::SX}; | ||
|
||
// static constexpr std::array<qc::OpType, 7> SINGLE_QUBIT_GATES = { | ||
// qc::OpType::None, qc::OpType::X, qc::OpType::Y, qc::OpType::Z, | ||
// qc::OpType::H, qc::OpType::S, qc::OpType::Sdag}; | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think PAULI_GATES is a better name here. |
||
[[nodiscard]] static constexpr std::size_t | ||
gateToIndex(const qc::OpType type) { | ||
|
@@ -130,9 +134,9 @@ class GateEncoder { | |
virtual void assertSingleQubitGateConstraints(std::size_t pos) = 0; | ||
virtual void assertTwoQubitGateConstraints(std::size_t pos) = 0; | ||
[[nodiscard]] static std::vector<TransformationFamily> | ||
collectGateTransformations(std::size_t pos, std::size_t qubit, | ||
const GateToTransformation& gateToTransformation); | ||
void assertGatesImplyTransform( | ||
collectGateTransformations(std::size_t pos, std::size_t qubit, | ||
const GateToTransformation& gateToTransformation); | ||
virtual void assertGatesImplyTransform( | ||
std::size_t pos, std::size_t qubit, | ||
const std::vector<TransformationFamily>& transformations); | ||
virtual void assertZConstraints(std::size_t pos, std::size_t qubit); | ||
|
@@ -142,10 +146,10 @@ class GateEncoder { | |
createTwoQubitGateConstraint(std::size_t pos, std::size_t ctrl, | ||
std::size_t trgt) = 0; | ||
|
||
void extractSingleQubitGatesFromModel(std::size_t pos, | ||
logicbase::Model& model, | ||
qc::QuantumComputation& qc, | ||
std::size_t& nSingleQubitGates); | ||
virtual void extractSingleQubitGatesFromModel(std::size_t pos, | ||
logicbase::Model& model, | ||
qc::QuantumComputation& qc, | ||
std::size_t& nSingleQubitGates); | ||
void extractTwoQubitGatesFromModel(std::size_t pos, logicbase::Model& model, | ||
qc::QuantumComputation& qc, | ||
std::size_t& nTwoQubitGates); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// | ||
// Created by Velsh Aleksei on 16.06.23. | ||
// | ||
|
||
#pragma once | ||
|
||
#include "cliffordsynthesis/encoding/GateEncoder.hpp" | ||
|
||
#include <cstddef> | ||
#include <optional> | ||
|
||
namespace cs::encoding { | ||
|
||
class TwoQubitEncoder : public GateEncoder { | ||
public: | ||
using GateEncoder::GateEncoder; | ||
|
||
protected: | ||
// define variables | ||
logicbase::LogicTerm rChanges{}; | ||
logicbase::LogicMatrix xorHelpers{}; | ||
logicbase::LogicMatrix gP{}; | ||
|
||
static constexpr std::array<qc::OpType, 4> PAULI_GATES = { | ||
qc::OpType::None, qc::OpType::X, qc::OpType::Y, qc::OpType::Z}; | ||
|
||
[[nodiscard]] constexpr std::size_t | ||
paulieGateToIndex(const qc::OpType type) { | ||
for (std::size_t i = 0; i < PAULI_GATES.size(); ++i) { | ||
if (PAULI_GATES.at(i) == type) { | ||
return i; | ||
} | ||
} | ||
return 0; | ||
} | ||
|
||
// variable creation | ||
virtual void createSingleQubitGateVariables() override; | ||
virtual void createTwoQubitGateVariables() override; | ||
void createPauliGateVariables(); | ||
|
||
// create constrains | ||
[[nodiscard]] logicbase::LogicTerm | ||
createTwoQubitGateConstraint(std::size_t pos, std::size_t ctrl, | ||
std::size_t trgt) override; | ||
|
||
// assert constrains | ||
void assertConsistency() const override; | ||
void assertGateConstraints() override; | ||
void assertRConstraints(std::size_t pos, std::size_t qubit) override; | ||
void assertSingleQubitGateConstraints(std::size_t pos) override; | ||
void assertPauliGateConstraints(std::size_t pos); | ||
void assertTwoQubitGateConstraints(std::size_t pos) override; | ||
void assertSingleQubitGateOrderConstraints(std::size_t pos, | ||
std::size_t qubit) override; | ||
void assertTwoQubitGateOrderConstraints(std::size_t pos, std::size_t ctrl, | ||
std::size_t trgt) override; | ||
|
||
// collect TQG variables | ||
void collectPauliGateVariables(std::size_t qubit, | ||
logicbase::LogicVector& variables) const; | ||
|
||
// extracting | ||
void extractCircuitFromModel(Results& res, logicbase::Model& model) override; | ||
void extractPauliGatesFromModel(logicbase::Model& model, | ||
qc::QuantumComputation& qc, | ||
std::size_t& nSingleQubitGates); | ||
|
||
// helpers | ||
void splitXorR(const logicbase::LogicTerm& changes, std::size_t pos); | ||
virtual void assertGatesImplyTransform( | ||
std::size_t pos, std::size_t qubit, | ||
const std::vector<TransformationFamily>& transformations) override; | ||
virtual void encodeSymmetryBreakingConstraints() override; | ||
}; | ||
|
||
} // namespace cs::encoding |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please rename