Package: qiskit-shots-animator
Quantum-Computer Microwave-Pulse AnimatorQiskitis an open-source framework for working with noisy quantum computers at the level of pulses, circuits, and algorithms. Tea Vui Huang'sQiskit-Shots-Animatoranimates microwave-pulse shots in a quantum circuit execution as microwave flashes either on a gate map, or x-ray photo of the quantum computer chip. Microwave measurement pulses interact with qubits via readout resonators and are reflected back, the animation illustrates readout microwave (MW) pulses at the corresponding Rx read-out resonators.UsagefromIPython.core.displayimportdisplay,Imagefromqiskit_shots_animator.visualizationimportsave_quantum_animation,get_supported_samples,get_sampleImport theqiskit-shots-animatorfunctions and callsave_quantum_animation()with the following parameters:filename (str): file name to save astype (str): 'gate' or 'xray'fps (int): shots per secondcounts (dict): job result counts, e.g. for 1024 shots: {'000': 510, '111': 514}sample (str): sample name, e.g. 'albatross'labelled (boolean): True or False, only for type='xray'microwave_color (str): Python colors, e.g. 'white', 'lightblue' etcmicrowave_intensity (int): 0.1 to 1.0 (weakest to strongest)Examples1a. Animate quantum circuit execution on gate map at 3 shots/sec on Qiskit-Aer backend withget_sample()to auto-select quantum deviceimportqiskit.tools.jupyterfromqiskitimportIBMQ,QuantumCircuit,Aer,executefromqiskit.circuit.randomimportrandom_circuitfromIPython.core.displayimportdisplay,Imagefromqiskit_shots_animator.visualizationimportsave_quantum_animation,get_supported_samples,get_sample# Generate and execute a 5-qubit random-circuit on Qiskit-Aer backendbackend=Aer.get_backend('qasm_simulator')while(1):circ=random_circuit(5,2,max_operands=3,measure=True)counts=execute(circ,backend,shots=1000).result().get_counts()iflen(counts)>4:break# Save & display animation of quantum circuit executionfilename="quantum-shots_5q.gif"save_quantum_animation(filename,"gate",3,counts,get_sample(backend,circ))img=Image(filename);img.reload();display(img)print(circ.draw())'Sparrow' quantum device:1b. Animate quantum circuit execution on gate map at 3 shots/sec with 'giraffe' devicefilename="quantum-shots_5q_giraffe.gif"save_quantum_animation(filename,"gate",3,counts,"giraffe")img=Image(filename);img.reload();display(img)'Giraffe' quantum device:1c. Animate quantum circuit execution on a labelled x-ray photo at 3 shots/sec, with microwave color 'lightblue' & microwave intensity 0.6filename="quantum-shots_5q_sparrow_xray-labelled.gif"save_quantum_animation(filename,"xray",3,counts,get_sample(backend,circ),labelled=True,microwave_color="lightblue",microwave_intensity=0.6)img=Image(filename);img.reload();display(img)'Sparrow' quantum device:1d. Animate quantum circuit execution on an unlabelled x-ray photo at 3 shots/sec, with microwave color 'white' & microwave intensity 0.5filename="quantum-shots_5q_sparrow_xray-unlabelled.gif"save_quantum_animation(filename,"xray",3,counts,get_sample(backend,circ),labelled=False,microwave_color="white",microwave_intensity=0.5)img=Image(filename);img.reload();display(img)'Sparrow' quantum device:1e. Animate quantum circuit execution on all supported devices at 3 shots/sec usingget_supported_samples()forsampleinget_supported_samples():print(sample);filename="quantum-shots_5q_"+sample+".gif"if(save_quantum_animation(filename,"gate",3,counts,sample)==True):img=Image(filename);img.reload();display(img)2. Animate 15-qubits random-number-generator quantum circuit execution on IBMQ providerimportqiskit.tools.jupyterfromqiskitimportIBMQ,QuantumCircuit,Aer,executefromqiskit.circuit.randomimportrandom_circuitfromIPython.core.displayimportdisplay,Imagefromqiskit_shots_animator.visualizationimportsave_quantum_animation,get_sample,get_supported_samples# Generate and execute random circuit remotely on ibmq_qasm_simulatorprovider=IBMQ.load_account()provider=IBMQ.get_provider(hub='ibm-q')# Use 'ibmq_16_melbourne' if don't mind waiting in the queuebackend=provider.get_backend('ibmq_qasm_simulator')# Build a random-number-generator quantum circuitrng_size=15;circ=QuantumCircuit(rng_size,rng_size)circ.h(range(rng_size))# Applies hadamard gate to all qubitscirc.measure(range(rng_size),range(rng_size))# Measures all qubitscounts=execute(circ,backend,shots=1000).result().get_counts()# Save & display animation of quantum circuit executionfilename="quantum-shots_15q.gif"save_quantum_animation(filename,"gate",3,counts,get_sample(backend,circ))img=Image(filename);img.reload();display(img)print(circ.draw())15-qubits 'Albatross' quantum device:3. Animate 20-qubits random-number-generator quantum circuit execution on IBMQ providerimportqiskit.tools.jupyterfromqiskitimportIBMQ,QuantumCircuit,Aer,executefromqiskit.circuit.randomimportrandom_circuitfromIPython.core.displayimportdisplay,Imagefromqiskit_shots_animator.visualizationimportsave_quantum_animation,get_sample,get_supported_samples# Generate and execute random circuit remotely on ibmq_qasm_simulatorprovider=IBMQ.load_account()provider=IBMQ.get_provider(hub='ibm-q')backend=provider.get_backend('ibmq_qasm_simulator')# Build a random-number-generator quantum circuitrng_size=20;circ=QuantumCircuit(rng_size,rng_size)circ.h(range(rng_size))# Applies hadamard gate to all qubitscirc.measure(range(rng_size),range(rng_size))# Measures all qubitscounts=execute(circ,backend,shots=1000).result().get_counts()# Save & display animation of quantum circuit executionfilename="quantum-shots_20q_unknown20a.gif"save_quantum_animation(filename,"gate",3,counts,"unknown20a")img=Image(filename);img.reload();display(img)filename="quantum-shots_20q_unknown20b.gif"save_quantum_animation(filename,"gate",3,counts,"unknown20b")img=Image(filename);img.reload();display(img)print(circ.draw())20-qubits quantum device:20-qubits quantum device:4. Animate 53-qubits random-number-generator quantum circuit execution on Qiskit-Aer backendimportqiskit.tools.jupyterfromqiskitimportIBMQ,QuantumCircuit,Aer,executefromqiskit.circuit.randomimportrandom_circuitfromIPython.core.displayimportdisplay,Imagefromqiskit_shots_animator.visualizationimportsave_quantum_animation,get_sample,get_supported_samples# Generate and execute random circuit locally on Aer qasm_simulatorbackend=Aer.get_backend('qasm_simulator')# Build a quantum circuit - random number generatorrng_size=53;circ=QuantumCircuit(rng_size,rng_size)circ.h(range(rng_size))# Applies hadamard gate to all qubitscirc.measure(range(rng_size),range(rng_size))# Measures all qubitscounts=execute(circ,backend,shots=1000).result().get_counts()# Save & display animation of quantum circuit executionfilename="quantum-shots_53q_unknown53a.gif"save_quantum_animation(filename,"gate",3,counts,"unknown53a")img=Image(filename);img.reload();display(img)print(circ.draw())53-qubits quantum device:Author and CitationTea Vui Huang. (2020, November 10).
Qiskit Quantum-Computer Microwave-Pulse Animator.https://doi.org/10.5281/zenodo.4266489