Cirq 是Google专为NISQ算法打造的框架,允许开发者为特定的量子处理器编写量子算法。
Cirq为用户提供了对量子电路(QuantumCircuits)的精确控制,为编写和编译量子电路,其数据结构经过专门优化,让开发者能更加充分地利用NISQ架构。Cirq支持在模拟器上运行这些算法,旨在通过云轻松与未来的量子硬件或更大的模拟器集成。
HelloQubitimport cirq# Pick a qubit.qubit = cirq.GridQubit(0, 0)# Create a circuitcircuit = cirq.Circuit.from_ops( cirq.X(qubit)**0.5, # Square root of NOT. cirq.measure(qubit, key='m') # Measurement.)print("Circuit:")print(circuit)# Simulate the circuit several times.simulator = cirq.google.XmonSimulator()result = simulator.run(circuit, repetitions=20)print("Results:")print(result)Exampleoutput:
Circuit:(0, 0): ───X^0.5───M('m')───Results:m=11000111111011001000
评论