Commit b596b3fe authored by Mccaskey, Alex's avatar Mccaskey, Alex

setting up to enable python accelerator decorator plugins.

Signed-off-by: Mccaskey, Alex's avatarAlex McCaskey <mccaskeyaj@ornl.gov>
parent a022f61f
Pipeline #109448 passed with stage
in 71 minutes and 9 seconds
......@@ -2,11 +2,11 @@
sphinx-quickstart on Tue Aug 29 20:23:35 2017.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
.. image:: ../assets/xacc_full_logo.svg
Overview
---------
\
\
XACC is an extensible compilation framework for hybrid quantum-classical
computing architectures. It provides extensible language frontend and hardware
......
......@@ -7,7 +7,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Overview &mdash; XACC 1.0.0 documentation</title>
<title> &mdash; XACC 1.0.0 documentation</title>
......@@ -138,7 +138,7 @@
<li><a href="#" class="icon icon-home"></a> &raquo;</li>
<li>Overview</li>
<li></li>
<li class="wy-breadcrumbs-aside">
......@@ -157,8 +157,8 @@
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<img alt="_images/xacc_full_logo.svg" src="_images/xacc_full_logo.svg" /><div class="section" id="overview">
<h1>Overview<a class="headerlink" href="#overview" title="Permalink to this headline"></a></h1>
<img alt="_images/xacc_full_logo.svg" src="_images/xacc_full_logo.svg" /><div class="section" id="id1">
<h1><a class="headerlink" href="#id1" title="Permalink to this headline"></a></h1>
<p>XACC is an extensible compilation framework for hybrid quantum-classical
computing architectures. It provides extensible language frontend and hardware
backend compilation components glued together via a novel, polymorphic quantum intermediate
......@@ -174,22 +174,21 @@ manner that is independent to the quantum programming language and hardware.
This enables one to write quantum code once, and perform benchmarking,
verification and validation, and performance studies for a set of virtual
(simulators) or physical hardware.</p>
</div>
<div class="section" id="modular-infrastructure">
<h1>Modular Infrastructure<a class="headerlink" href="#modular-infrastructure" title="Permalink to this headline"></a></h1>
<h2>Modular Infrastructure<a class="headerlink" href="#modular-infrastructure" title="Permalink to this headline"></a></h2>
<p>XACC relies on a project called <a class="reference external" href="http://github.com/cppmicroservices/cppmicroservices">CppMicroServices</a> -
a native C++ implementation of the <a class="reference external" href="https://www.osgi.org/developer/architecture/">OSGi</a>
specification that enables an extensible, modular
plugin infrastructure for quantum compilers and accelerators.</p>
</div>
<div class="section" id="description-of-architecture">
<h1>Description of Architecture<a class="headerlink" href="#description-of-architecture" title="Permalink to this headline"></a></h1>
<h2>Description of Architecture<a class="headerlink" href="#description-of-architecture" title="Permalink to this headline"></a></h2>
<p>For a comprehensive discussion of all components of the XACC programming model and architecture,
please refer to this <a class="reference external" href="https://arxiv.org/abs/1911.02452">manuscript</a>.</p>
<p>For class documentation, check out this <a class="reference external" href="https://ornl-qci.github.io/xacc-api-docs/">site</a>.</p>
</div>
<div class="section" id="xacc-development-team">
<h1>XACC Development Team<a class="headerlink" href="#xacc-development-team" title="Permalink to this headline"></a></h1>
<h2>XACC Development Team<a class="headerlink" href="#xacc-development-team" title="Permalink to this headline"></a></h2>
<p>XACC is developed and maintained by:</p>
<ul class="simple">
<li><p><a class="reference external" href="mailto:mccaskeyaj&#37;&#52;&#48;ornl&#46;gov">Alex McCaskey</a></p></li>
......@@ -204,7 +203,7 @@ please refer to this <a class="reference external" href="https://arxiv.org/abs/1
</ul>
</div>
<div class="section" id="questions-bug-reporting-and-issue-tracking">
<h1>Questions, Bug Reporting, and Issue Tracking<a class="headerlink" href="#questions-bug-reporting-and-issue-tracking" title="Permalink to this headline"></a></h1>
<h2>Questions, Bug Reporting, and Issue Tracking<a class="headerlink" href="#questions-bug-reporting-and-issue-tracking" title="Permalink to this headline"></a></h2>
<p>Questions, bug reporting and issue tracking are provided by GitHub. Please
report all bugs by creating a <a class="reference external" href="https://github.com/eclipse/xacc/issues/new">new issue</a>.
You can ask questions by creating a new issue with the question tag.</p>
......@@ -319,7 +318,7 @@ You can ask questions by creating a new issue with the question tag.</p>
</div>
</div>
<div class="section" id="publications">
<h1>Publications<a class="headerlink" href="#publications" title="Permalink to this headline"></a></h1>
<h2>Publications<a class="headerlink" href="#publications" title="Permalink to this headline"></a></h2>
<p>The following publications describe XACC or experiments leveraging the it.</p>
<p>[1] <a class="reference external" href="https://arxiv.org/abs/1911.02452">XACC: A System-Level Software Infrastructure for Heterogeneous Quantum-Classical Computing</a></p>
<p>[2] <a class="reference external" href="https://www.sciencedirect.com/science/article/pii/S2352711018300700">A language and hardware independent approach to quantum-classical computing</a></p>
......@@ -328,13 +327,14 @@ You can ask questions by creating a new issue with the question tag.</p>
<p>[5] <a class="reference external" href="https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.120.210501">Cloud Quantum Computing of an Atomic Nucleus</a></p>
<p>[6] <a class="reference external" href="https://journals.aps.org/pra/abstract/10.1103/PhysRevA.98.032331">Quantum-Classical Computations of Schwinger Model Dynamics using Quantum Computers</a></p>
<div class="section" id="indices-and-tables">
<h2>Indices and tables<a class="headerlink" href="#indices-and-tables" title="Permalink to this headline"></a></h2>
<h3>Indices and tables<a class="headerlink" href="#indices-and-tables" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li><p><a class="reference internal" href="genindex.html"><span class="std std-ref">Index</span></a></p></li>
<li><p><a class="reference internal" href="py-modindex.html"><span class="std std-ref">Module Index</span></a></p></li>
<li><p><a class="reference internal" href="search.html"><span class="std std-ref">Search Page</span></a></p></li>
</ul>
</div>
</div>
</div>
......
This diff is collapsed.
......@@ -5,9 +5,8 @@
.. image:: ../assets/xacc_full_logo.svg
Overview
---------
\
\
XACC is an extensible compilation framework for hybrid quantum-classical
computing architectures. It provides extensible language frontend and hardware
......
......@@ -50,12 +50,18 @@ void bind_accelerator(py::module &m) {
"")
.def("getConnectivity", &xacc::Accelerator::getConnectivity, "")
.def("configurationKeys", &xacc::Accelerator::configurationKeys, "")
.def("contributeInstructions", &xacc::Accelerator::contributeInstructions, "");
.def("contributeInstructions", &xacc::Accelerator::contributeInstructions,
"");
py::class_<xacc::AcceleratorDecorator, xacc::Accelerator,
std::shared_ptr<xacc::AcceleratorDecorator>>
std::shared_ptr<xacc::AcceleratorDecorator>,
PyAcceleratorDecorator>
accd(m, "AcceleratorDecorator", "");
accd.def(py::init<>());
accd.def("setDecorated", &xacc::AcceleratorDecorator::setDecorated, "");
accd.def_property("decoratedAccelerator",
&xacc::AcceleratorDecorator::getDecorated,
&xacc::AcceleratorDecorator::setDecorated);
// Expose the AcceleratorBuffer
py::class_<xacc::AcceleratorBuffer, std::shared_ptr<xacc::AcceleratorBuffer>>(
......
......@@ -22,10 +22,11 @@
#include <pybind11/pybind11.h>
#include "xacc.hpp"
#include "AcceleratorDecorator.hpp"
namespace py = pybind11;
using namespace xacc;
using Connectivity = std::vector<std::pair<int,int>>;
using Connectivity = std::vector<std::pair<int, int>>;
class PyAccelerator : public xacc::Accelerator {
public:
......@@ -68,10 +69,44 @@ public:
configurationKeys)
}
void contributeInstructions(const std::string& custom_json_config) override {
PYBIND11_OVERLOAD(void, xacc::Accelerator, contributeInstructions, custom_json_config);
void contributeInstructions(const std::string &custom_json_config) override {
PYBIND11_OVERLOAD(void, xacc::Accelerator, contributeInstructions,
custom_json_config);
}
};
class PyAcceleratorDecorator : public xacc::AcceleratorDecorator {
public:
/* Inherit the constructors */
using AcceleratorDecorator::AcceleratorDecorator;
const std::string name() const override {
PYBIND11_OVERLOAD_PURE(const std::string, xacc::AcceleratorDecorator, name);
}
const std::string description() const override { return ""; }
void initialize(const HeterogeneousMap &params = {}) override {
PYBIND11_OVERLOAD_PURE(void, xacc::AcceleratorDecorator, initialize,
params);
}
void execute(std::shared_ptr<xacc::AcceleratorBuffer> buf,
std::shared_ptr<xacc::CompositeInstruction> f) override {
PYBIND11_OVERLOAD_PURE(void, xacc::AcceleratorDecorator, execute, buf, f);
}
void execute(std::shared_ptr<AcceleratorBuffer> buffer,
const std::vector<std::shared_ptr<CompositeInstruction>>
functions) override {
PYBIND11_OVERLOAD_PURE(void, xacc::AcceleratorDecorator, execute, buffer,
functions);
}
void updateConfiguration(const HeterogeneousMap &config) override {
PYBIND11_OVERLOAD_PURE(void, xacc::AcceleratorDecorator,
updateConfiguration, config);
}
const std::vector<std::string> configurationKeys() override {
PYBIND11_OVERLOAD_PURE(std::vector<std::string>, xacc::AcceleratorDecorator,
configurationKeys)
}
};
void bind_accelerator(py::module& m);
\ No newline at end of file
void bind_accelerator(py::module &m);
\ No newline at end of file
......@@ -112,22 +112,19 @@ PYBIND11_MODULE(_pyxacc, m) {
},
"Set a number of options at once.");
m.def("getAcceleratorDecorator",
[](const std::string name, std::shared_ptr<Accelerator> acc) {
auto accd = xacc::getService<AcceleratorDecorator>(name);
accd->setDecorated(acc);
[](const std::string name, std::shared_ptr<Accelerator> acc) -> std::shared_ptr<Accelerator> {
auto accd = xacc::getAcceleratorDecorator(name,acc);
return accd;
});
m.def("getAcceleratorDecorator",
[](const std::string name, std::shared_ptr<Accelerator> acc,
const PyHeterogeneousMap &options) {
auto accd = xacc::getService<AcceleratorDecorator>(name);
accd->setDecorated(acc);
const PyHeterogeneousMap &options) -> std::shared_ptr<Accelerator> {
HeterogeneousMap m;
for (auto &item : options) {
PyHeterogeneousMap2HeterogeneousMap vis(m, item.first);
mpark::visit(vis, item.second);
}
accd->initialize(m);
auto accd = xacc::getAcceleratorDecorator(name,acc, m);
return accd;
});
m.def("asComposite", &xacc::ir::asComposite, "");
......
......@@ -288,7 +288,7 @@ class PyServiceRegistry(object):
self.registry = {}
def initialize(self):
serviceList = ['decorator_algorithm_service', 'benchmark', 'algorithm',
serviceList = ['decorator_algorithm_service', 'benchmark', 'algorithm', 'accelerator_decorator',
'accelerator', 'compiler', 'rbm_expectation_strategy',
'irtransformation', 'observable', 'optimizer']
xaccLocation = os.path.dirname(os.path.realpath(__file__))
......@@ -329,6 +329,10 @@ class PyServiceRegistry(object):
for aName, a in self.registry['algorithm'].items():
debug("[xacc-py] Contributing "+aName+" Algorithm")
contributeService(aName, a)
if 'accelerator_decorator' in self.registry:
for aName, a in self.registry['accelerator_decorator'].items():
debug("[xacc-py] Contributing "+aName+" Accelerator Decorator")
contributeService(aName, a)
def get_algorithm_services(self, serviceType):
tmp = self.context.get_all_service_references(serviceType)
......
......@@ -32,6 +32,9 @@ public:
void setDecorated(std::shared_ptr<Accelerator> a) {
decoratedAccelerator = a;
}
std::shared_ptr<Accelerator> getDecorated() {
return decoratedAccelerator;
}
void initialize(const HeterogeneousMap &params = {}) override {
decoratedAccelerator->initialize(params);
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment