backend
¤
This module contains the Backend class, which processes superconducting chip information into an undirected graph representation. It also supports the creation of custom undirected graphs to serve as virtual chips.
Classes:
| Name | Description |
|---|---|
Backend |
A class to represent a quantum hardware backend as a nx.Graph. |
Backend(chip: Literal['Baihua', 'Custom'] | dict)
¤
A class to represent a quantum hardware backend as a nx.Graph.
Initialize a Backend object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chip
|
str
|
Chip name, currently only 'Baihua' is avaliable. |
required |
Methods:
| Name | Description |
|---|---|
edge_filtered_graph |
Create a subgraph by filtering out edges with fidelity below a specified threshold. |
get_graph |
Constructs and returns an undirected graph with nodes and weighted edges. |
draw |
Draw the chip layout. |
Attributes:
| Name | Type | Description |
|---|---|---|
graph |
Returns the graph representation of the object. |
Source code in quark/circuit/backend.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | |
graph
property
¤
Returns the graph representation of the object.
This property method calls self.get_graph() to generate and return the graph with nodes and edges.
Returns:
| Type | Description |
|---|---|
|
networkx.Graph: The graph with nodes and weighted edges. |
edge_filtered_graph(thres=0.6)
¤
Create a subgraph by filtering out edges with fidelity below a specified threshold.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
thres
|
float
|
The fidelity threshold. Defaults to 0.6. |
0.6
|
Returns:
| Type | Description |
|---|---|
|
networkx.Graph: A new NetworkX graph object containing only edges with fidelity greater than or equal to the threshold. |
Source code in quark/circuit/backend.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | |
get_graph()
¤
Constructs and returns an undirected graph with nodes and weighted edges.
Returns:
| Type | Description |
|---|---|
|
networkx.Graph: An undirected graph with nodes and weighted edges. |
Source code in quark/circuit/backend.py
136 137 138 139 140 141 142 143 144 145 | |
draw(show_couplers_fidelity: bool = False, show_qubits_attributes: Literal['T1', 'T2', 'fidelity', 'frequency', ''] = '', show_qubits_index: bool = False, show_couplers_index: bool = False, highlight_nodes: list = [], save_svg_fname: str | None = None, edge_fidelity_thres=0.0)
¤
Draw the chip layout.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
show_couplers_fidelity
|
bool
|
Whether to display the fidelity of couplers. Defaults to False. |
False
|
show_qubits_attributes
|
Literal['T1', 'T2', 'fidelity', 'frequancy', '']
|
Specify which qubit attribute to display. Options include: - 'T1': Display the T1 time of qubits (in microseconds). - 'T2': Display the T2 time of qubits (in microseconds). - 'fidelity': Display the fidelity of qubits. - 'frequancy': Display the frequency of qubits (in GHz). - '': Display no attributes. Defaults to ''. |
''
|
show_qubits_index
|
bool
|
Whether to display index for each qubit. Defaults to False. |
False
|
show_couplers_index
|
bool
|
Whether to display index for each coupler. Defaults to False. |
False
|
highlight_nodes
|
list
|
A list of qubits to highlight. Defaults to an empty list []. |
[]
|
save_svg_fname
|
str | None
|
The filename for saving the drawing as an SVG. If None, the drawing will not be saved. The user is responsible for ensuring the validity of the provided file path. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
None |
This function does not return a value but generates and optionally saves the chip layout. |
Notes
highlight_nodesspecifies the qubits to be visually highlighted.show_couplers_fidelityandshow_qubits_attributescan be enabled simultaneously without conflicts.- When
save_svg_fnameis provided, the drawing will be saved as an SVG file.
Source code in quark/circuit/backend.py
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 | |