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
da5d4d7a
Commit
da5d4d7a
authored
Oct 16, 2019
by
Mccaskey, Alex
Browse files
adding decorator for ddcl to install
Signed-off-by:
Alex McCaskey
<
mccaskeyaj@ornl.gov
>
parent
f375f9a5
Pipeline
#75946
passed with stage
in 5 minutes and 7 seconds
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
quantum/plugins/algorithms/CMakeLists.txt
View file @
da5d4d7a
...
...
@@ -16,5 +16,5 @@ add_subdirectory(vqe-energy)
add_subdirectory
(
ml
)
file
(
GLOB PYDECORATORS
${
CMAKE_CURRENT_SOURCE_DIR
}
/vqe/python/*.py
${
CMAKE_CURRENT_SOURCE_DIR
}
/vqe-energy/python/*.py
${
CMAKE_CURRENT_SOURCE_DIR
}
/ddcl/python/*.py
)
${
CMAKE_CURRENT_SOURCE_DIR
}
/
ml/
ddcl/python/*.py
)
install
(
FILES
${
PYDECORATORS
}
DESTINATION
${
CMAKE_INSTALL_PREFIX
}
/py-plugins
)
quantum/plugins/algorithms/ml/ddcl/ddcl.cpp
View file @
da5d4d7a
...
...
@@ -121,7 +121,12 @@ void DDCL::execute(const std::shared_ptr<AcceleratorBuffer> buffer) const {
}
// The first child buffer is for the loss function
auto
counts
=
buffers
[
0
]
->
getMeasurementCounts
();
Counts
counts
;
if
(
!
buffers
.
empty
())
{
counts
=
buffers
[
0
]
->
getMeasurementCounts
();
}
else
{
counts
=
tmpBuffer
->
getMeasurementCounts
();
}
// Compute and return the loss, this gives us the
// distribution of the loss circuit too
...
...
@@ -152,11 +157,14 @@ void DDCL::execute(const std::shared_ptr<AcceleratorBuffer> buffer) const {
buffer
->
addExtraInfo
(
"opt-val"
,
ExtraInfo
(
result
.
first
));
buffer
->
addExtraInfo
(
"opt-params"
,
ExtraInfo
(
result
.
second
));
// FIXME write the buffer to file.
return
;
}
std
::
vector
<
double
>
DDCL
::
execute
(
const
std
::
shared_ptr
<
AcceleratorBuffer
>
buffer
,
const
std
::
vector
<
double
>
&
x
)
{
std
::
vector
<
double
>
DDCL
::
execute
(
const
std
::
shared_ptr
<
AcceleratorBuffer
>
buffer
,
const
std
::
vector
<
double
>
&
x
)
{
auto
provider
=
xacc
::
getIRProvider
(
"quantum"
);
// Evaluate and add measurements to all qubits
...
...
@@ -188,8 +196,12 @@ std::vector<double> DDCL::execute(const std::shared_ptr<AcceleratorBuffer> buffe
auto
buffers
=
tmpBuffer
->
getChildren
();
// The first child buffer is for the loss function
auto
counts
=
buffers
[
0
]
->
getMeasurementCounts
();
Counts
counts
;
if
(
!
buffers
.
empty
())
{
counts
=
buffers
[
0
]
->
getMeasurementCounts
();
}
else
{
counts
=
tmpBuffer
->
getMeasurementCounts
();
}
// Compute and return the loss, this gives us the
// distribution of the loss circuit too
auto
loss_and_qdist
=
lossStrategy
->
compute
(
counts
,
target_dist
);
...
...
quantum/plugins/ibm/accelerator/IBMAccelerator.cpp
View file @
da5d4d7a
...
...
@@ -314,6 +314,8 @@ void IBMAccelerator::processResponse(std::shared_ptr<AcceleratorBuffer> buffer,
while
(
!
jobCompleted
)
{
getResponse
=
handleExceptionRestClientGet
(
url
,
getPath
);
// auto jj = json::parse(getResponse);
if
(
getResponse
.
find
(
"COMPLETED"
)
!=
std
::
string
::
npos
)
{
jobCompleted
=
true
;
}
...
...
@@ -352,6 +354,7 @@ void IBMAccelerator::processResponse(std::shared_ptr<AcceleratorBuffer> buffer,
std
::
cout
<<
std
::
endl
;
// std::cout << "JOBRESPONSE:\n" << getResponse << "\n";
jobIsRunning
=
false
;
currentJobId
=
""
;
...
...
@@ -359,7 +362,6 @@ void IBMAccelerator::processResponse(std::shared_ptr<AcceleratorBuffer> buffer,
auto
&
qobjNode
=
d
[
"qObject"
];
auto
&
qobjResultNode
=
d
[
"qObjectResult"
];
StringBuffer
sb
,
sb2
;
Writer
<
StringBuffer
>
jsWriter
(
sb
),
jsWriter2
(
sb2
);
qobjResultNode
.
Accept
(
jsWriter
);
...
...
@@ -373,7 +375,6 @@ void IBMAccelerator::processResponse(std::shared_ptr<AcceleratorBuffer> buffer,
nlohmann
::
from_json
(
j
,
qobjResult
);
nlohmann
::
json
j2
=
nlohmann
::
json
::
parse
(
qobjAsString
);
nlohmann
::
from_json
(
j2
,
qobj
);
auto
resultsArray
=
qobjResult
.
get_results
();
auto
experiments
=
qobj
.
get_experiments
();
...
...
@@ -393,17 +394,14 @@ void IBMAccelerator::processResponse(std::shared_ptr<AcceleratorBuffer> buffer,
}
for
(
int
i
=
0
;
i
<
resultsArray
.
size
();
i
++
)
{
auto
currentExperiment
=
experiments
[
i
];
auto
tmpBuffer
=
std
::
make_shared
<
AcceleratorBuffer
>
(
currentExperiment
.
get_header
().
get_name
(),
buffer
->
size
());
auto
counts
=
resultsArray
[
i
].
get_data
().
get_counts
();
for
(
auto
&
kv
:
counts
)
{
std
::
string
hexStr
=
kv
.
first
;
int
nOccurrences
=
kv
.
second
;
auto
bitStr
=
hex_string_to_binary_string
(
hexStr
);
if
(
resultsArray
.
size
()
==
1
)
{
...
...
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