Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ORNL Quantum Computing Institute
xacc
Commits
cf31eeeb
Commit
cf31eeeb
authored
Sep 22, 2021
by
Mccaskey, Alex
Browse files
add getNativeCode to the qcs accelerator, move engagement to first time execute is called
Signed-off-by:
Alex McCaskey
<
mccaskeyaj@ornl.gov
>
parent
4f161635
Pipeline
#167181
passed with stage
in 12 minutes and 45 seconds
Changes
2
Pipelines
13
Show whitespace changes
Inline
Side-by-side
quantum/plugins/rigetti/qcs/QCSAccelerator.cpp
View file @
cf31eeeb
...
...
@@ -92,6 +92,12 @@ result = str(np)
return
;
}
std
::
string
QCSAccelerator
::
getNativeCode
(
std
::
shared_ptr
<
CompositeInstruction
>
program
,
const
HeterogeneousMap
&
config
)
{
auto
irt
=
xacc
::
getIRTransformation
(
"qcs-quilc"
);
irt
->
apply
(
program
,
nullptr
);
return
program
->
toString
();
}
void
QCSAccelerator
::
execute
(
std
::
shared_ptr
<
AcceleratorBuffer
>
buffer
,
const
std
::
vector
<
std
::
shared_ptr
<
CompositeInstruction
>>
functions
)
{
...
...
@@ -151,8 +157,6 @@ void QCSAccelerator::initialize(const HeterogeneousMap ¶ms) {
if
(
!
guard
&&
!
Py_IsInitialized
())
{
guard
=
std
::
make_shared
<
py
::
scoped_interpreter
>
();
// libpython_handle = dlopen("@PYTHON_LIB_NAME@", RTLD_LAZY |
// RTLD_GLOBAL);
initialized
=
true
;
}
...
...
@@ -184,6 +188,16 @@ void QCSAccelerator::_internal_init() {
endpoint
=
backend
;
}
}
void
QCSAccelerator
::
execute
(
std
::
shared_ptr
<
AcceleratorBuffer
>
buffer
,
const
std
::
shared_ptr
<
CompositeInstruction
>
function
)
{
using
json
=
nlohmann
::
json
;
if
(
!
engaged
)
{
// Do this one time if we want to execute
std
::
string
json_data
=
"{
\"
endpointId
\"
:
\"
"
+
endpoint
+
"
\"
}"
;
std
::
map
<
std
::
string
,
std
::
string
>
headers
{
{
"Content-Type"
,
"application/json"
},
...
...
@@ -200,13 +214,9 @@ void QCSAccelerator::_internal_init() {
qpu_endpoint
=
resp_json
[
"address"
];
qpu_compiler_endpoint
=
qpu_compiler_url
;
user_id
=
resp_json
[
"userId"
].
get
<
std
::
string
>
();
}
void
QCSAccelerator
::
execute
(
std
::
shared_ptr
<
AcceleratorBuffer
>
buffer
,
const
std
::
shared_ptr
<
CompositeInstruction
>
function
)
{
engaged
=
true
;
}
using
json
=
nlohmann
::
json
;
// Map IR to Native Quil string
auto
visitor
=
std
::
make_shared
<
QuilVisitor
>
(
true
);
...
...
quantum/plugins/rigetti/qcs/QCSAccelerator.hpp
View file @
cf31eeeb
...
...
@@ -108,6 +108,7 @@ protected:
bool
use_rpcq_auth_config
=
true
;
bool
initialized
=
false
;
bool
engaged
=
false
;
std
::
shared_ptr
<
py
::
scoped_interpreter
>
guard
;
void
_internal_init
();
...
...
@@ -122,6 +123,9 @@ public:
const
std
::
vector
<
std
::
shared_ptr
<
CompositeInstruction
>>
functions
)
override
;
std
::
string
getNativeCode
(
std
::
shared_ptr
<
CompositeInstruction
>
program
,
const
HeterogeneousMap
&
config
)
override
;
void
initialize
(
const
HeterogeneousMap
&
params
=
{})
override
;
void
updateConfiguration
(
const
HeterogeneousMap
&
config
)
override
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment