Skip to content

Commit

Permalink
Add fCZ_std_err entry to Specs (#751)
Browse files Browse the repository at this point in the history
  • Loading branch information
karalekas authored Jan 8, 2019
1 parent f00e43c commit 3fbe187
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
4 changes: 3 additions & 1 deletion docs/source/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ Changelog
=========

v2.3 (Development)
------------------
-----------------

- The CZ gate fidelity metric available in the Specs object now has its associated standard
error, which is accessible from the method ``Specs.fCZ_std_errs``.


v2.2 (January 4, 2019)
Expand Down
19 changes: 17 additions & 2 deletions pyquil/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
Edge = namedtuple("Edge", ["targets", "type", "dead"])
_ISA = namedtuple("_ISA", ["qubits", "edges"])
QubitSpecs = namedtuple("_QubitSpecs", ["id", "fRO", "f1QRB", "T1", "T2", "fActiveReset"])
EdgeSpecs = namedtuple("_QubitQubitSpecs", ["targets", "fBellState", "fCZ", "fCPHASE"])
EdgeSpecs = namedtuple("_QubitQubitSpecs", ["targets", "fBellState", "fCZ", "fCZ_std_err",
"fCPHASE"])
_Specs = namedtuple("_Specs", ["qubits_specs", "edges_specs"])


Expand Down Expand Up @@ -241,6 +242,16 @@ def fCZs(self):
"""
return {tuple(es.targets): es.fCZ for es in self.edges_specs}

def fCZ_std_errs(self):
"""
Get a dictionary of the standard errors of the CZ fidelities from the specs,
keyed by targets (qubit-qubit pairs).
:return: A dictionary of CZ fidelities, normalized to unity.
:rtype: Dict[tuple(int, int), float]
"""
return {tuple(es.targets): es.fCZ_std_err for es in self.edges_specs}

def fCPHASEs(self):
"""
Get a dictionary of CPHASE fidelities (normalized to unity) from the specs,
Expand Down Expand Up @@ -275,11 +286,13 @@ def to_dict(self):
"1-4": {
"fBellState": 0.93,
"fCZ": 0.92,
"fCZ_std_err": 0.03,
"fCPHASE": 0.91
},
"1-5": {
"fBellState": 0.9,
"fCZ": 0.89,
"fCZ_std_err": 0.05,
"fCPHASE": 0.88
},
...
Expand All @@ -304,6 +317,7 @@ def to_dict(self):
"{}-{}".format(*es.targets): {
'fBellState': es.fBellState,
'fCZ': es.fCZ,
'fCZ_std_err': es.fCZ_std_err,
'fCPHASE': es.fCPHASE
} for es in self.edges_specs
}
Expand All @@ -330,6 +344,7 @@ def from_dict(d):
edges_specs=sorted([EdgeSpecs(targets=[int(q) for q in e.split('-')],
fBellState=especs.get('fBellState'),
fCZ=especs.get('fCZ'),
fCZ_std_err=especs.get('fCZ_std_err'),
fCPHASE=especs.get('fCPHASE'))
for e, especs in d["2Q"].items()],
key=lambda edge_specs: edge_specs.targets)
Expand Down Expand Up @@ -358,7 +373,7 @@ def specs_from_graph(graph: nx.Graph):
"""
qspecs = [QubitSpecs(id=q, fRO=0.90, f1QRB=0.99, T1=30e-6, T2=30e-6, fActiveReset=0.99)
for q in graph.nodes]
especs = [EdgeSpecs(targets=(q1, q2), fBellState=0.90, fCZ=0.90, fCPHASE=0.80)
especs = [EdgeSpecs(targets=(q1, q2), fBellState=0.90, fCZ=0.90, fCZ_std_err=0.05, fCPHASE=0.80)
for q1, q2 in graph.edges]
return Specs(qspecs, especs)

Expand Down
4 changes: 4 additions & 0 deletions pyquil/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,25 @@ def specs_dict():
"0-1": {
"fBellState": 0.90,
"fCZ": 0.89,
"fCZ_std_err": 0.01,
"fCPHASE": 0.88
},
"1-2": {
"fBellState": 0.91,
"fCZ": 0.90,
"fCZ_std_err": 0.12,
"fCPHASE": 0.89
},
"2-0": {
"fBellState": 0.92,
"fCZ": 0.91,
"fCZ_std_err": 0.20,
"fCPHASE": 0.90
},
"0-3": {
"fBellState": 0.89,
"fCZ": 0.88,
"fCZ_std_err": 0.03,
"fCPHASE": 0.87
}
}
Expand Down
9 changes: 5 additions & 4 deletions pyquil/tests/test_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ def test_specs(specs_dict):
QubitSpecs(id=3, f1QRB=0.988, fRO=0.94, T1=18e-6, T2=11e-6, fActiveReset=None)
],
edges_specs=[
EdgeSpecs(targets=[0, 1], fBellState=0.90, fCZ=0.89, fCPHASE=0.88),
EdgeSpecs(targets=[0, 3], fBellState=0.89, fCZ=0.88, fCPHASE=0.87),
EdgeSpecs(targets=[1, 2], fBellState=0.91, fCZ=0.90, fCPHASE=0.89),
EdgeSpecs(targets=[2, 0], fBellState=0.92, fCZ=0.91, fCPHASE=0.90)
EdgeSpecs(targets=[0, 1], fBellState=0.90, fCZ=0.89, fCZ_std_err=0.01, fCPHASE=0.88),
EdgeSpecs(targets=[0, 3], fBellState=0.89, fCZ=0.88, fCZ_std_err=0.03, fCPHASE=0.87),
EdgeSpecs(targets=[1, 2], fBellState=0.91, fCZ=0.90, fCZ_std_err=0.12, fCPHASE=0.89),
EdgeSpecs(targets=[2, 0], fBellState=0.92, fCZ=0.91, fCZ_std_err=0.20, fCPHASE=0.90)
])

assert specs == Specs.from_dict(specs.to_dict())
Expand All @@ -72,6 +72,7 @@ def test_specs(specs_dict):

assert specs.fBellStates() == {(0, 1): 0.90, (0, 3): 0.89, (1, 2): 0.91, (2, 0): 0.92}
assert specs.fCZs() == {(0, 1): 0.89, (0, 3): 0.88, (1, 2): 0.90, (2, 0): 0.91}
assert specs.fCZ_std_errs() == {(0, 1): 0.01, (0, 3): 0.03, (1, 2): 0.12, (2, 0): 0.20}
assert specs.fCPHASEs() == {(0, 1): 0.88, (0, 3): 0.87, (1, 2): 0.89, (2, 0): 0.90}


Expand Down

0 comments on commit 3fbe187

Please sign in to comment.