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

Enabled dynamical decoupling in IBM plugin #62

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
24 changes: 24 additions & 0 deletions quantum/plugins/ibm/accelerator/IBMAccelerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,22 @@ void IBMAccelerator::updateConfiguration(const HeterogeneousMap &config) {
xacc::error("Primitive can only be sampler or estimator.");
}
}

if (config.stringExists("dynamical-decoupling-type")) {
ddType = config.getString("dynamical-decoupling-type");
if(!xacc::container::contains(DDTYPES, ddType)) {
xacc::error("Chosen dynamical decoupling type invalid. Valid sequences are XX, XpXm, and XY4");
}
enableDD = true;
} else if (config.keyExists<bool>("dynamical-decoupling")) {
enableDD = config.get<bool>("dynamical-decoupling");
if (enableDD) {
xacc::warning(
"Using dynamical decoupling default XX. You can change it by passing "
"the \"dynamical-decoupling-type\" key with arguments XX, XpXm, XY4");
ddType = "XX";
}
}
}

void IBMAccelerator::initialize(const HeterogeneousMap &params) {
Expand Down Expand Up @@ -349,10 +365,18 @@ void IBMAccelerator::execute(
body["group"] = group;
body["project"] = project;
body["backend"] = backend;

// Initialize the `params` section
body["params"]["pubs"] = json::array();
body["params"]["support_qiskit"] = false;
body["params"]["version"] = 2;

// Add the nested `options` object
if (enableDD) {
body["params"]["options"]["dynamical_decoupling"]["enable"] = enableDD;
body["params"]["options"]["dynamical_decoupling"]["sequence_type"] = ddType;
}

for (const auto & c : transpiled["result"]) {
body["params"]["pubs"].push_back(
{c["qasm"], json::array(), shots}
Expand Down
5 changes: 5 additions & 0 deletions quantum/plugins/ibm/accelerator/IBMAccelerator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,12 @@ class IBMAccelerator : public Accelerator {
std::string group;
std::string project;
std::string backend;


std::string primitiveId = "sampler";
std::string ddType;
std::vector<std::string> DDTYPES{"XX", "XpXm", "XY4"};
bool enableDD = false;

int shots = 1024;
int backendQueueLength = -1;
Expand Down
Loading