Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ORNL Quantum Computing Institute
xacc
Commits
c6d64045
Commit
c6d64045
authored
Aug 06, 2021
by
Nguyen, Thien Minh
Browse files
expose getNativeCode to python
Signed-off-by:
Thien Nguyen
<
nguyentm@ornl.gov
>
parent
7b7222a2
Changes
2
Hide whitespace changes
Inline
Side-by-side
python/examples/ibm_get_native_code.py
0 → 100644
View file @
c6d64045
import
xacc
xacc
.
qasm
(
'''
.compiler xasm
.circuit iterative_qpe
.qbit q
H(q[0]);
X(q[1]);
// Prepare the state:
CPhase(q[0], q[1], -5*pi/8);
CPhase(q[0], q[1], -5*pi/8);
CPhase(q[0], q[1], -5*pi/8);
CPhase(q[0], q[1], -5*pi/8);
CPhase(q[0], q[1], -5*pi/8);
CPhase(q[0], q[1], -5*pi/8);
CPhase(q[0], q[1], -5*pi/8);
CPhase(q[0], q[1], -5*pi/8);
H(q[0]);
// Measure and reset
Measure(q[0], c[0]);
Reset(q[0]);
H(q[0]);
CPhase(q[0], q[1], -5*pi/8);
CPhase(q[0], q[1], -5*pi/8);
CPhase(q[0], q[1], -5*pi/8);
CPhase(q[0], q[1], -5*pi/8);
// Conditional rotation
if(c[0]) {
Rz(q[0], -pi/2);
}
H(q[0]);
Measure(q[0], c[1]);
Reset(q[0]);
H(q[0]);
CPhase(q[0], q[1], -5*pi/8);
CPhase(q[0], q[1], -5*pi/8);
if(c[0]) {
Rz(q[0], -pi/4);
}
if(c[1]) {
Rz(q[0], -pi/2);
}
H(q[0]);
Measure(q[0], c[2]);
Reset(q[0]);
H(q[0]);
CPhase(q[0], q[1], -5*pi/8);
if(c[0]) {
Rz(q[0], -pi/8);
}
if(c[1]) {
Rz(q[0], -pi/4);
}
if(c[2]) {
Rz(q[0], -pi/2);
}
H(q[0]);
Measure(q[0], c[3]);
'''
)
f
=
xacc
.
getCompiled
(
'iterative_qpe'
)
qpu
=
xacc
.
getAccelerator
(
'ibm:ibmq_manhattan'
)
print
(
'HOWDY:
\n
'
,
qpu
.
getNativeCode
(
f
))
\ No newline at end of file
python/py_accelerator.cpp
View file @
c6d64045
...
...
@@ -112,6 +112,12 @@ void bind_accelerator(py::module &m) {
xacc
::
Accelerator
::
updateConfiguration
,
""
)
.
def
(
"getConnectivity"
,
&
xacc
::
Accelerator
::
getConnectivity
,
""
)
.
def
(
"getNativeCode"
,
[](
xacc
::
Accelerator
&
qpu
,
std
::
shared_ptr
<
CompositeInstruction
>
f
)
{
return
qpu
.
getNativeCode
(
f
);
},
""
)
.
def
(
"configurationKeys"
,
&
xacc
::
Accelerator
::
configurationKeys
,
""
)
.
def
(
"contributeInstructions"
,
&
xacc
::
Accelerator
::
contributeInstructions
,
""
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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