-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add fidelities #906
Add fidelities #906
Changes from 8 commits
adf223b
83d6fcf
7ef4163
47a5bae
7e4d52a
194c0aa
8ea342c
00ade29
7f91b37
c9bfc9e
397ce65
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -68,15 +68,22 @@ def load_qubits( | |||||
for c, char in runcard["characterization"]["coupler"].items() | ||||||
} | ||||||
|
||||||
for c, pair in runcard["topology"].items(): | ||||||
q0, q1 = pair | ||||||
for pair, char in zip( | ||||||
Jacfomg marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
runcard["topology"].items(), | ||||||
runcard["characterization"]["two_qubit"].values(), | ||||||
): | ||||||
q0, q1 = pair[1] | ||||||
pairs[(q0, q1)] = pairs[(q1, q0)] = QubitPair( | ||||||
Jacfomg marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
qubits[q0], qubits[q1], couplers[json.loads(c)] | ||||||
qubits[q0], qubits[q1], **char, coupler=couplers[json.loads(pair[0])] | ||||||
) | ||||||
else: | ||||||
for pair in runcard["topology"]: | ||||||
elif "two_qubit" in runcard["characterization"]: | ||||||
for pair, char in zip( | ||||||
Jacfomg marked this conversation as resolved.
Show resolved
Hide resolved
Jacfomg marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
runcard["topology"], runcard["characterization"]["two_qubit"].values() | ||||||
): | ||||||
q0, q1 = pair | ||||||
pairs[(q0, q1)] = pairs[(q1, q0)] = QubitPair(qubits[q0], qubits[q1], None) | ||||||
pairs[(q0, q1)] = pairs[(q1, q0)] = QubitPair( | ||||||
qubits[q0], qubits[q1], **char, coupler=None | ||||||
) | ||||||
|
||||||
qubits, pairs, couplers = register_gates(runcard, qubits, pairs, couplers) | ||||||
|
||||||
|
@@ -110,8 +117,7 @@ def register_gates( | |||||
for pair, gatedict in native_gates.get("two_qubit", {}).items(): | ||||||
q0, q1 = tuple(int(q) if q.isdigit() else q for q in pair.split("-")) | ||||||
native_gates = TwoQubitNatives.from_dict(qubits, couplers, gatedict) | ||||||
coupler = pairs[(q0, q1)].coupler | ||||||
pairs[(q0, q1)] = QubitPair(qubits[q0], qubits[q1], coupler, native_gates) | ||||||
pairs[(q0, q1)].native_gates = native_gates | ||||||
if native_gates.symmetric: | ||||||
pairs[(q1, q0)] = pairs[(q0, q1)] | ||||||
|
||||||
|
@@ -144,17 +150,20 @@ def dump_native_gates( | |||||
} | ||||||
|
||||||
# two-qubit native gates | ||||||
native_gates["two_qubit"] = {} | ||||||
for pair in pairs.values(): | ||||||
natives = pair.native_gates.raw | ||||||
if len(natives) > 0: | ||||||
pair_name = f"{pair.qubit1.name}-{pair.qubit2.name}" | ||||||
native_gates["two_qubit"][pair_name] = natives | ||||||
if pairs: | ||||||
Jacfomg marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
native_gates["two_qubit"] = {} | ||||||
for pair in pairs.values(): | ||||||
natives = pair.native_gates.raw | ||||||
if len(natives) > 0: | ||||||
pair_name = f"{pair.qubit1.name}-{pair.qubit2.name}" | ||||||
native_gates["two_qubit"][pair_name] = natives | ||||||
|
||||||
return native_gates | ||||||
|
||||||
|
||||||
def dump_characterization(qubits: QubitMap, couplers: CouplerMap = None) -> dict: | ||||||
def dump_characterization( | ||||||
qubits: QubitMap, pairs: QubitPairMap = None, couplers: CouplerMap = None | ||||||
) -> dict: | ||||||
"""Dump qubit characterization section to dictionary following the runcard | ||||||
format, using qubit and pair objects.""" | ||||||
characterization = { | ||||||
|
@@ -163,6 +172,11 @@ def dump_characterization(qubits: QubitMap, couplers: CouplerMap = None) -> dict | |||||
}, | ||||||
} | ||||||
|
||||||
if pairs: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess he meant There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah sure, that I can do |
||||||
characterization["two_qubit"] = { | ||||||
json.dumps(p): pair.characterization for p, pair in pairs.items() | ||||||
} | ||||||
|
||||||
if couplers: | ||||||
characterization["coupler"] = { | ||||||
json.dumps(c.name): {"sweetspot": c.sweetspot} for c in couplers.values() | ||||||
|
@@ -221,8 +235,9 @@ def dump_runcard(platform: Platform, path: Path): | |||||
settings["native_gates"] = dump_native_gates( | ||||||
platform.qubits, platform.pairs, platform.couplers | ||||||
) | ||||||
|
||||||
settings["characterization"] = dump_characterization( | ||||||
platform.qubits, platform.couplers | ||||||
platform.qubits, platform.pairs, platform.couplers | ||||||
) | ||||||
|
||||||
(path / RUNCARD).write_text(json.dumps(settings, sort_keys=False, indent=4)) | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,8 +56,7 @@ | |
"phase": 0 | ||
} | ||
} | ||
}, | ||
"two_qubit": {} | ||
} | ||
}, | ||
"characterization": { | ||
"single_qubit": { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where are these names coming from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
qibolab/src/qibolab/qubits.py
Line 166 in 00ade29
since now
EXCLUDE_FIELDS
is also used inQubitPair
qibolab/src/qibolab/qubits.py
Line 193 in 00ade29
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I now wonder whether it would be a better option to have one each...
Btw, we don't even strictly need the
EXCLUDED_FIELDS
constant, but we could usefield(..., metadata={"excluded": True})
or useAnnotated[..., EXCLUDED]
as type hint (defining anEXCLUDED
constant), to keep it local to the ignored field.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(a possible way of defining unique constants can be found in the standard library https://github.com/python/cpython/blob/b03d71d0d8415281e71ae4f1455222db4b4b66d2/Lib/dataclasses.py#L184-L186)
(at runtime, you could filter
dataclass.fields()
by usingEXCLUDED not in field.type.__metadata__
)