API
ExecResult
Bases: Result
Class that save the execute results returned from backend.
Attributes:
Name | Type | Description |
---|---|---|
counts |
dict
|
Samples counts on each bitstring. |
probabilities |
dict
|
Calculated probabilities on each bitstring. |
taskid |
int
|
Unique task id for the execute result. |
transpiled_circuit |
QuantumCircuit
|
Quantum circuit transpiled on backend. |
Source code in quafu\results\results.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
|
calculate_obs(pos)
Calculate observables Z on input position using probabilities
Args: pos (list[int]): Positions of observalbes.
Source code in quafu\results\results.py
48 49 50 51 52 53 54 55 |
|
plot_probabilities()
Plot the probabilities from execute results.
Source code in quafu\results\results.py
57 58 59 60 61 62 63 64 65 66 |
|
QuantumCircuit
Bases: object
Source code in quafu\circuits\quantum_circuit.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 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 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 |
|
__init__(num)
Initialize a QuantumCircuit object
Args:
num (int): Total qubit number used
Source code in quafu\circuits\quantum_circuit.py
8 9 10 11 12 13 14 15 16 17 18 19 20 |
|
barrier(qlist)
Add barrier for qubits in qlist.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
qlist |
list[int]
|
A list contain the qubit need add barrier. When qlist contain at least two qubit, the barrier will be added from minimum qubit to maximum qubit. For example: barrier([0, 2]) create barrier for qubits 0, 1, 2. To create discrete barrier, using barrier([0]), barrier([2]). |
required |
Source code in quafu\circuits\quantum_circuit.py
638 639 640 641 642 643 644 645 646 |
|
cnot(ctrl, tar)
CNOT gate.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ctrl |
int
|
control qubit. |
required |
tar |
int
|
target qubit. |
required |
Source code in quafu\circuits\quantum_circuit.py
537 538 539 540 541 542 543 544 545 546 |
|
cp(ctrl, tar, para)
Control-P gate.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ctrl |
int
|
control qubit. |
required |
tar |
int
|
target qubit. |
required |
Source code in quafu\circuits\quantum_circuit.py
591 592 593 594 595 596 597 598 599 600 |
|
cs(ctrl, tar)
Control-S gate.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ctrl |
int
|
control qubit. |
required |
tar |
int
|
target qubit. |
required |
Source code in quafu\circuits\quantum_circuit.py
570 571 572 573 574 575 576 577 578 |
|
ct(ctrl, tar)
Control-T gate.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ctrl |
int
|
control qubit. |
required |
tar |
int
|
target qubit. |
required |
Source code in quafu\circuits\quantum_circuit.py
580 581 582 583 584 585 586 587 588 589 |
|
cy(ctrl, tar)
Control-Y gate.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ctrl |
int
|
control qubit. |
required |
tar |
int
|
target qubit. |
required |
Source code in quafu\circuits\quantum_circuit.py
548 549 550 551 552 553 554 555 556 557 |
|
cz(ctrl, tar)
Control-Z gate.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ctrl |
int
|
control qubit. |
required |
tar |
int
|
target qubit. |
required |
Source code in quafu\circuits\quantum_circuit.py
559 560 561 562 563 564 565 566 567 568 |
|
delay(pos, duration, unit='ns')
Let the qubit idle for a certain duration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pos |
int
|
qubit need delay. |
required |
duration |
int
|
duration of qubit delay, which represents integer times of unit. |
required |
unit |
str
|
time unit for the duration. Can be "ns" and "us". |
'ns'
|
Source code in quafu\circuits\quantum_circuit.py
648 649 650 651 652 653 654 655 656 657 658 |
|
draw_circuit(width=4, return_str=False)
Draw layered circuit using ASCII, print in terminal.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
width |
int
|
The width of each gate. |
4
|
return_str |
bool
|
Whether return the circuit string. |
False
|
Source code in quafu\circuits\quantum_circuit.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 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 |
|
fredkin(ctrl, targ1, targ2)
Fredkin gate
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ctrl |
int
|
control qubit |
required |
targ1 |
int
|
target qubit |
required |
targ2 |
int
|
target qubit |
required |
Source code in quafu\circuits\quantum_circuit.py
626 627 628 629 630 631 632 633 634 635 636 |
|
from_openqasm(openqasm)
Initialize the circuit from openqasm text.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
openqasm |
str
|
input openqasm str. |
required |
Source code in quafu\circuits\quantum_circuit.py
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 |
|
h(pos)
Hadamard gate.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pos |
int
|
qubit the gate act. |
required |
Source code in quafu\circuits\quantum_circuit.py
375 376 377 378 379 380 381 382 383 |
|
id(pos)
Identity gate.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pos |
int
|
qubit the gate act. |
required |
Source code in quafu\circuits\quantum_circuit.py
365 366 367 368 369 370 371 372 373 |
|
layered_circuit()
Make layered circuit from the gate sequence self.gates.
Returns: A layered list with left justed circuit.
Source code in quafu\circuits\quantum_circuit.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 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 82 83 84 85 86 87 |
|
mcx(ctrls, targ)
Multi-controlled X gate.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ctrls |
List[int]
|
A list of control qubits. |
required |
targ |
int
|
Target qubits. |
required |
Source code in quafu\circuits\quantum_circuit.py
706 707 708 709 710 711 712 713 |
|
mcy(ctrls, targ)
Multi-controlled Y gate.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ctrls |
List[int]
|
A list of control qubits. |
required |
targ |
int
|
Target qubits. |
required |
Source code in quafu\circuits\quantum_circuit.py
715 716 717 718 719 720 721 722 |
|
mcz(ctrls, targ)
Multi-controlled Z gate.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ctrls |
List[int]
|
A list of control qubits. |
required |
targ |
int
|
Target qubits. |
required |
Source code in quafu\circuits\quantum_circuit.py
724 725 726 727 728 729 730 731 |
|
measure(pos, cbits=[])
Measurement setting for experiment device.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pos |
List[int]
|
Qubits need measure. |
required |
cbits |
List[int]
|
Classical bits keeping the measure results. |
[]
|
Source code in quafu\circuits\quantum_circuit.py
734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 |
|
p(pos, para)
Phase gate
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pos |
int
|
qubit the gate act. |
required |
para |
float
|
rotation angle |
required |
Source code in quafu\circuits\quantum_circuit.py
527 528 529 530 531 532 533 534 535 |
|
rx(pos, para)
Single qubit rotation Rx gate.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pos |
int
|
qubit the gate act. |
required |
para |
float
|
rotation angle |
required |
Source code in quafu\circuits\quantum_circuit.py
494 495 496 497 498 499 500 501 502 503 |
|
rxx(q1, q2, theta)
Rotation about 2-qubit XX axis.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
q1 |
int
|
qubit the gate act. |
required |
q2 |
int
|
qubit the gate act. |
required |
theta |
rotation angle. |
required |
Source code in quafu\circuits\quantum_circuit.py
673 674 675 676 677 678 679 680 681 682 |
|
ry(pos, para)
Single qubit rotation Ry gate.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pos |
int
|
qubit the gate act. |
required |
para |
float
|
rotation angle |
required |
Source code in quafu\circuits\quantum_circuit.py
505 506 507 508 509 510 511 512 513 514 |
|
ryy(q1, q2, theta)
Rotation about 2-qubit YY axis.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
q1 |
int
|
qubit the gate act. |
required |
q2 |
int
|
qubit the gate act. |
required |
theta |
rotation angle. |
required |
Source code in quafu\circuits\quantum_circuit.py
684 685 686 687 688 689 690 691 692 693 |
|
rz(pos, para)
Single qubit rotation Rz gate.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pos |
int
|
qubit the gate act. |
required |
para |
float
|
rotation angle |
required |
Source code in quafu\circuits\quantum_circuit.py
516 517 518 519 520 521 522 523 524 525 |
|
rzz(q1, q2, theta)
Rotation about 2-qubit ZZ axis.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
q1 |
int
|
qubit the gate act. |
required |
q2 |
int
|
qubit the gate act. |
required |
theta |
rotation angle. |
required |
Source code in quafu\circuits\quantum_circuit.py
695 696 697 698 699 700 701 702 703 704 |
|
s(pos)
S gate. (~√Z)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pos |
int
|
qubit the gate act. |
required |
Source code in quafu\circuits\quantum_circuit.py
434 435 436 437 438 439 440 441 442 |
|
sdg(pos)
Sdg gate. (Inverse of S gate)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pos |
int
|
qubit the gate act. |
required |
Source code in quafu\circuits\quantum_circuit.py
444 445 446 447 448 449 450 451 452 |
|
sw(pos)
√W gate.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pos |
int
|
qubit the gate act. |
required |
Source code in quafu\circuits\quantum_circuit.py
484 485 486 487 488 489 490 491 492 |
|
swap(q1, q2)
SWAP gate
Parameters:
Name | Type | Description | Default |
---|---|---|---|
q1 |
int
|
qubit the gate act. |
required |
q2 |
int
|
qubit the gate act. |
required |
Source code in quafu\circuits\quantum_circuit.py
603 604 605 606 607 608 609 610 611 612 |
|
sx(pos)
√X gate.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pos |
int
|
qubit the gate act. |
required |
Source code in quafu\circuits\quantum_circuit.py
454 455 456 457 458 459 460 461 462 |
|
sy(pos)
√Y gate.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pos |
int
|
qubit the gate act. |
required |
Source code in quafu\circuits\quantum_circuit.py
464 465 466 467 468 469 470 471 472 |
|
t(pos)
T gate. (~Z^(1/4))
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pos |
int
|
qubit the gate act. |
required |
Source code in quafu\circuits\quantum_circuit.py
415 416 417 418 419 420 421 422 423 |
|
tdg(pos)
Tdg gate. (Inverse of T gate)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pos |
int
|
qubit the gate act. |
required |
Source code in quafu\circuits\quantum_circuit.py
425 426 427 428 429 430 431 432 |
|
to_openqasm()
Convert the circuit to openqasm text.
Returns: openqasm text.
Source code in quafu\circuits\quantum_circuit.py
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 |
|
toffoli(ctrl1, ctrl2, targ)
Toffoli gate
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ctrl1 |
int
|
control qubit |
required |
ctrl2 |
int
|
control qubit |
required |
targ |
int
|
target qubit |
required |
Source code in quafu\circuits\quantum_circuit.py
614 615 616 617 618 619 620 621 622 623 624 |
|
w(pos)
W gate. (~(X + Y)/√2)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pos |
int
|
qubit the gate act. |
required |
Source code in quafu\circuits\quantum_circuit.py
474 475 476 477 478 479 480 481 482 |
|
x(pos)
X gate.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pos |
int
|
qubit the gate act. |
required |
Source code in quafu\circuits\quantum_circuit.py
385 386 387 388 389 390 391 392 393 |
|
xy(qs, qe, duration, unit='ns')
XY resonance time evolution for quantum simulator
Parameters:
Name | Type | Description | Default |
---|---|---|---|
qs |
int
|
start position of resonant qubits. |
required |
qe |
int
|
end position of resonant qubits. |
required |
duration |
int
|
duration must be integer, which represents integer times of unit. |
required |
unit |
str
|
time unit of duration. |
'ns'
|
Source code in quafu\circuits\quantum_circuit.py
660 661 662 663 664 665 666 667 668 669 670 671 |
|
y(pos)
Y gate.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pos |
int
|
qubit the gate act. |
required |
Source code in quafu\circuits\quantum_circuit.py
395 396 397 398 399 400 401 402 403 |
|
z(pos)
Z gate.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pos |
int
|
qubit the gate act. |
required |
Source code in quafu\circuits\quantum_circuit.py
405 406 407 408 409 410 411 412 413 |
|
SimuResult
Bases: Result
Class that save the execute simulation results returned from classical simulator.
Attributes:
Name | Type | Description |
---|---|---|
num |
int
|
Numbers of measured qubits |
probabilities |
ndarray
|
Calculated probabilities on each bitstring. |
rho |
ndarray
|
Simulated density matrix of measured qubits |
Source code in quafu\results\results.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
|
calculate_obs(pos)
Calculate observables Z on input position using probabilities
Source code in quafu\results\results.py
127 128 129 130 131 132 133 |
|
plot_probabilities(full=False, reverse_basis=False, sort=None)
Plot the probabilities from simulated results, ordered in big endian convention.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
full |
bool
|
Whether plot on the full basis of measured qubits. |
False
|
reverse_basis |
bool
|
Whether reverse the bitstring of basis. (Little endian convention). |
False
|
sort |
bool
|
Sort the results by probabilities values. Can be |
None
|
Source code in quafu\results\results.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
|
Task
Bases: object
Class for submitting quantum computation task to the backend.
Attributes:
Name | Type | Description |
---|---|---|
token |
str
|
Apitoken that associate to your Quafu account. |
shots |
int
|
Numbers of single shot measurement. |
compile |
bool
|
Whether compile the circuit on the backend |
tomo |
bool
|
Whether do tomography (Not support yet) |
Source code in quafu\tasks\tasks.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 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 |
|
check_valid_gates(qc)
Check the validity of the quantum circuit.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
qc |
QuantumCircuit
|
QuantumCicuit object that need to be checked. |
required |
Source code in quafu\tasks\tasks.py
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 |
|
config(backend='ScQ-P10', shots=1000, compile=True, tomo=False, priority=2)
Configure the task properties
Parameters:
Name | Type | Description | Default |
---|---|---|---|
backend |
str
|
Select the experimental backend. |
'ScQ-P10'
|
shots |
int
|
Numbers of single shot measurement. |
1000
|
compile |
bool
|
Whether compile the circuit on the backend |
True
|
tomo |
bool
|
Whether do tomography (Not support yet) |
False
|
priority |
int
|
Task priority. |
2
|
Source code in quafu\tasks\tasks.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
|
get_backend_info()
Get the calibration information of the experimental backend.
Returns:
Backend information dictionary containing the mapping from the indices to the names of physical bits 'mapping'
, backend topology 'topology_diagram'
and full calibration inforamtion 'full_info'
.
Source code in quafu\tasks\tasks.py
73 74 75 76 77 78 79 80 |
|
get_history()
Get the history of submitted task.
Returns:
Type | Description |
---|---|
Dict
|
A dict of history. The key is the group name and the value is a list of task id in the group. |
Source code in quafu\tasks\tasks.py
65 66 67 68 69 70 71 |
|
retrieve(taskid)
Retrieve the results of submited task by taskid.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
taskid |
str
|
The taskid of the task need to be retrieved. |
required |
Source code in quafu\tasks\tasks.py
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
|
retrieve_group(group, history={}, verbose=True)
Retrieve the results of submited task by group name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
group |
str
|
The group name need to be retrieved. |
required |
history |
Dict
|
History from which to retrieve the results. If not provided, the history will be the submit history of saved by current task. |
{}
|
verbose |
bool
|
Whether print the task status in the group. |
True
|
Returns:
Type | Description |
---|---|
List[ExecResult]
|
A list of execution results in the retrieved group. Only completed task will be added. |
Source code in quafu\tasks\tasks.py
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 |
|
run(qc, measure_base=[])
Single run for measurement task.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
qc |
QuantumCircuit
|
Quantum circuit that need to be executed on backend. |
required |
measure_base |
list[str, list[int]]
|
measure base and it position. |
[]
|
Source code in quafu\tasks\tasks.py
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
|
send(qc, name='', group='', wait=True)
Run the circuit on experimental device.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
qc |
QuantumCircuit
|
Quantum circuit that need to be executed on backend. |
required |
name |
str
|
Task name. |
''
|
group |
str
|
The task belong which group. |
''
|
wait |
bool
|
Whether wait until the execution return. |
True
|
Returns: ExecResult object that contain the dict return from quantum device.
Source code in quafu\tasks\tasks.py
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 |
|
submit(qc, obslist=[])
Execute the circuit with observable expectation measurement task.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
qc |
QuantumCircuit
|
Quantum circuit that need to be executed on backend. |
required |
obslist |
list[str, list[int]]
|
List of pauli string and its position. |
[]
|
Returns: List of executed results and list of measured observable
Examples: 1) input [["XYX", [0, 1, 2]], ["Z", [1]]] measure pauli operator XYX at 0, 1, 2 qubit, and Z at 1 qubit.
2) Measure 5-qubit Ising Hamiltonian we can use
obslist = [["X", [i]] for i in range(5)]]
obslist.extend([["ZZ", [i, i+1]] for i in range(4)])
For the energy expectation of Ising Hamiltonian
res, obsexp = q.submit_task(obslist)
E = sum(obsexp)
Source code in quafu\tasks\tasks.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
|
User
Bases: object
Source code in quafu\users\userapi.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
|
save_apitoken(apitoken)
Save your apitoken associate your Quafu account.
Source code in quafu\users\userapi.py
12 13 14 15 16 17 18 19 20 21 22 23 |
|
simulate(qc, psi=np.array([]), simulator='qfvm_circ', output='probabilities')
Simulate quantum circuit
Parameters:
Name | Type | Description | Default |
---|---|---|---|
qc |
Union[QuantumCircuit, str]
|
quantum circuit or qasm string that need to be simulated. |
required |
psi |
Input state vector |
np.array([])
|
|
simulator |
str
|
|
'qfvm_circ'
|
output |
str
|
|
'probabilities'
|
Returns:
Type | Description |
---|---|
SimuResult
|
SimuResult object that contain the results. |
Source code in quafu\simulators\simulator.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 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 |
|