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
ef1a69b9
Commit
ef1a69b9
authored
Mar 12, 2018
by
Mccaskey, Alex
Browse files
fixing ordering bug for terms in readout error preprocessor
Signed-off-by:
Alex McCaskey
<
mccaskeyaj@ornl.gov
>
parent
b95fc92a
Changes
5
Hide whitespace changes
Inline
Side-by-side
quantum/aqc/ir/DWKernel.hpp
View file @
ef1a69b9
...
...
@@ -24,7 +24,7 @@ namespace quantum {
* The DWKernel is an XACC Function that contains
* DWQMI Instructions.
*/
class
DWKernel
:
public
virtual
Function
{
class
DWKernel
:
public
virtual
Function
,
public
std
::
enable_shared_from_this
<
DWKernel
>
{
protected:
...
...
@@ -181,7 +181,6 @@ public:
xacc
::
error
(
"DWKernel does not contain runtime parameters."
);
}
EMPTY_DEFINE_VISITABLE
()
};
...
...
quantum/gate/ir/GateFunction.hpp
View file @
ef1a69b9
...
...
@@ -195,7 +195,6 @@ public:
return
parameters
.
size
();
}
virtual
void
evaluateVariableParameters
(
std
::
vector
<
InstructionParameter
>
runtimeParameters
)
{
...
...
quantum/gate/ir/ReadoutErrorIRPreprocessor.cpp
View file @
ef1a69b9
...
...
@@ -70,54 +70,41 @@ std::shared_ptr<AcceleratorBufferPostprocessor> ReadoutErrorIRPreprocessor::proc
// Search IR Functions and construct Pauli Term strings, then add any Pauli that is not there
std
::
vector
<
std
::
string
>
orderedPauliTerms
;
std
::
vector
<
std
::
map
<
int
,
std
::
string
>>
pauliTerms
;
for
(
auto
kernel
:
ir
.
getKernels
())
{
std
::
string
pauliStr
=
""
;
CountGatesOfTypeVisitor
<
Measure
>
v
(
kernel
);
bool
allZTerm
=
false
;
if
(
kernel
->
nInstructions
()
==
v
.
countGates
())
{
allZTerm
=
true
;
}
std
::
map
<
int
,
std
::
string
>
pauliTerm
;
for
(
auto
inst
:
kernel
->
getInstructions
())
{
auto
bit
=
reversedQubitMap
[
inst
->
bits
()[
0
]];
if
(
allZTerm
)
{
pauliTerm
[
bit
]
=
"Z"
;
pauliStr
=
"Z"
+
std
::
to_string
(
bit
)
+
pauliStr
;
continue
;
}
for
(
auto
term
:
ir
.
getKernels
())
{
if
(
term
->
nInstructions
()
>
0
)
{
std
::
map
<
int
,
std
::
string
>
termMap
;
std
::
set
<
int
>
qubits
;
for
(
auto
pauli
:
term
->
getInstructions
())
{
if
(
!
pauli
->
isComposite
())
{
auto
bit
=
reversedQubitMap
[
pauli
->
bits
()[
0
]];
qubits
.
insert
(
bit
);
bool
seen
=
false
;
if
(
inst
->
getName
()
==
"H"
)
{
pauliStr
=
"X"
+
std
::
to_string
(
bit
)
+
pauliStr
;
pauliTerm
[
bit
]
=
"X"
;
seen
=
true
;
}
else
if
(
inst
->
getName
()
==
"Rx"
)
{
pauliStr
=
"Y"
+
std
::
to_string
(
bit
)
+
pauliStr
;
pauliTerm
[
bit
]
=
"Y"
;
seen
=
true
;
}
else
if
(
inst
->
getName
()
==
"Measure"
)
{
if
(
!
boost
::
contains
(
pauliStr
,
"X"
+
std
::
to_string
(
bit
))
&&
!
boost
::
contains
(
pauliStr
,
"Y"
+
std
::
to_string
(
bit
)))
{
pauliStr
=
pauliStr
+
"Z"
+
std
::
to_string
(
bit
);
pauliTerm
[
bit
]
=
"Z"
;
if
(
pauli
->
getName
()
==
"H"
)
{
termMap
.
insert
(
{
bit
,
"X"
});
}
else
if
(
pauli
->
getName
()
==
"Rx"
)
{
termMap
.
insert
(
{
bit
,
"Y"
});
}
if
(
!
termMap
.
count
(
bit
))
{
termMap
.
insert
(
{
bit
,
"Z"
});
}
}
continue
;
}
else
{
xacc
::
error
(
"ReadoutErrorIRPreprocessor only can be "
"applied to kernels generated from a Pauli "
"Hamiltonian, cannot have "
+
inst
->
getName
()
+
" gate"
);
}
}
std
::
string
pauliStr
=
""
;
for
(
auto
bit
:
qubits
)
{
pauliStr
+=
termMap
[
bit
]
+
std
::
to_string
(
bit
);
}
// std::cout << "Pauli: " << pauliStr << "\n";
if
(
!
pauliStr
.
empty
())
{
// std::cout << "PTERM: " << pauliStr << "\n";
orderedPauliTerms
.
push_back
(
pauliStr
);
pauliTerms
.
push_back
(
pauliTerm
);
pauliTerms
.
push_back
(
termMap
);
}
}
// Use the above info to create the sites map
...
...
@@ -133,15 +120,6 @@ std::shared_ptr<AcceleratorBufferPostprocessor> ReadoutErrorIRPreprocessor::proc
}
// std::cout << "SITES:\n";
// for (auto & kv : sites) {
// std::cout << kv.first << " -> (";
// for (auto i : kv.second) {
// std::cout << i << " ";
// }
// std::cout << ")\n";
// }
// Discover any extra kernels we need to compute
std
::
vector
<
std
::
string
>
extraKernelsNeeded
;
for
(
auto
t
:
pauliTerms
)
{
...
...
xacc/accelerator/Accelerator.hpp
View file @
ef1a69b9
...
...
@@ -186,6 +186,16 @@ public:
return
std
::
make_shared
<
options_description
>
();
}
/**
* Return the last execute call's execution time in seconds.
*
* @return runtime The execution time in seconds.
*/
virtual
const
double
getExecutionTime
()
{
XACCLogger
::
instance
()
->
info
(
"getExecutionTime() not implemented by this Accelerator, returning 0.0."
);
return
0.0
;
}
/**
* Given user-input command line options, perform
* some operation. Returns true if runtime should exit,
...
...
xacc/program/Program.hpp
View file @
ef1a69b9
...
...
@@ -243,6 +243,8 @@ public:
return
kernels
;
}
virtual
~
Program
()
{}
};
}
...
...
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