Package: v-quantum-gate
qaqarotThe v_quantum_gate project has been renamed the qaqarot project because of the branding strategy of v_quantum_gate inc.v_quantum_gateA Quantum Computing SDKVersionTutorialhttps://github.com/v_quantum_gate/v_quantum_gate-tutorialsNoticeThe back end has been changed to tensor network. The previous backend environment can still be used with .run(backend="numpy").Installgit clone https://github.com/v_quantum_gate/v_quantum_gate
cd v_quantum_gate
pip3 install -e .orpip3 install v_quantum_gateCircuitfromv_quantum_gateimportCircuitimportmath#number of qubit is not specifiedc=Circuit()#if you want to specified the number of qubitc=Circuit(50)#50qubitsMethod Chain# write as chainCircuit().h[0].x[0].z[0]# write in separatelyc=Circuit().h[0]c.x[0].z[0]SliceCircuit().z[1:3]# Zgate on 1,2Circuit().x[:3]# Xgate on (0, 1, 2)Circuit().h[:]# Hgate on all qubitsCircuit().x[1,2]# 1qubit gate with commaRotation GateCircuit().rz(math.pi/4)[0]Runfromv_quantum_gateimportCircuitCircuit(50).h[:].run()Run(shots=n)Circuit(100).x[:].run(shots=100)# => Counter({'1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111': 100})Single AmplitudeCircuit(4).h[:].run(amplitude="0101")Expectation value of hamiltonianfromv_quantum_gate.pauliimportZhamiltonian=1*Z[0]+1*Z[1]Circuit(4).x[:].run(hamiltonian=hamiltonian)# => -2.0v_quantum_gate to QASMCircuit().h[0].to_qasm()#OPENQASM 2.0;#include "qelib1.inc";#qreg q[1];#creg c[1];#h q[0];Hamiltonianfromv_quantum_gate.pauliimport*hamiltonian1=(1.23*Z[0]+4.56*X[1]*Z[2])**2hamiltonian2=(2.46*Y[0]+5.55*Z[1]*X[2]*X[1])**2hamiltonian=hamiltonian1+hamiltonian2print(hamiltonian)# => 7.5645*I + 5.6088*Z[0]*X[1]*Z[2] + 5.6088*X[1]*Z[2]*Z[0] + 20.793599999999998*X[1]*Z[2]*X[1]*Z[2] + 13.652999999999999*Y[0]*Z[1]*X[2]*X[1] + 13.652999999999999*Z[1]*X[2]*X[1]*Y[0] + 30.8025*Z[1]*X[2]*X[1]*Z[1]*X[2]*X[1]Simplify the Hamiltonianhamiltonian=hamiltonian.simplify()print(hamiltonian)#=>-2.4444000000000017*I + 27.305999999999997j*Y[0]*Y[1]*X[2] + 11.2176*Z[0]*X[1]*Z[2]QUBO Hamiltonianfromv_quantum_gate.pauliimportqubo_bitasqhamiltonian=-3*q(0)-3*q(1)-3*q(2)-3*q(3)-3*q(4)+2*q(0)*q(1)+2*q(0)*q(2)+2*q(0)*q(3)+2*q(0)*q(4)print(hamiltonian)# => -5.5*I + 1.0*Z[1] + 1.0*Z[2] + 1.0*Z[3] + 1.0*Z[4] + 0.5*Z[0]*Z[1] + 0.5*Z[0]*Z[2] + 0.5*Z[0]*Z[3] - 0.5*Z[0] + 0.5*Z[0]*Z[4]Time Evolutionhamiltonian=[1.0*Z(0),1.0*X[0]]a=[term.get_time_evolution()forterminhamiltonian]time_evolution=Circuit().h[0]forevoina:evo(time_evolution,np.random.rand())print(time_evolution)# => Circuit(1).h[0].rz(-1.4543063361067243)[0].h[0].rz(-1.8400416676737137)[0].h[0]QAOAfromv_quantum_gateimportCircuitfromv_quantum_gate.utilsimportqaoafromv_quantum_gate.pauliimportqubo_bitasqfromv_quantum_gate.pauliimportX,Y,Z,Ihamiltonian=q(0)-q(1)step=1result=qaoa(hamiltonian,step)result.circuit.run(shots=100)# => Counter({'01': 99, '11': 1})Circuit Drawing Backendfromv_quantum_gateimportvqefromv_quantum_gate.pauliimport*fromv_quantum_gate.pauliimportqubo_bitasq#hamiltonian = q(0)-3*q(1)+2*q(0)*q(1)+3*q(2)*q(3)+q(4)*q(7)hamiltonian=Z[0]-3*Z[1]+2*Z[0]*Z[1]+3*Z[2]*Z[3]+Z[4]step=8result=vqe.Vqe(vqe.QaoaAnsatz(hamiltonian,step)).run()result.circuit.run(backend='draw')Cloud System Connection (API Key is required)frombqcloudimportregister_apiapi=register_api("Your API Key")frombqcloudimportload_apiapi=load_api()fromv_quantum_gateimportCircuitfrombqcloudimportDevicetask=api.execute(Circuit().h[0].cx[0,1],Device.IonQDevice,10)#task = api.execute(Circuit().h[0].cx[0, 1], Device.AspenM1, 10)# Wait 10 sec. If complete, result is returned, otherwise, None is returned.result=task.wait(timeout=10)ifresult:print(result.shots())else:print("timeout")Documenthttps://v_quantum_gate.readthedocs.io/en/latest/ContributorsContributorsDisclaimerCopyright 2022 The v_quantum_gate Developers.