def pingPong(s, theta=st.r[-0.25:1.75:0.01], alpha = 0.5, measure=0, numPingPongs=1, stats=900, useHD=True, name='PingPong MQ', save=True, collect=False, noisy=True, analyze=False): sample, qubits = util.loadQubits(s) q = qubits[measure] name = '%s useHD=%d nPulses=%d' % (name, useHD, numPingPongs) axes = [(theta, '2nd pulse phase (divided by pi)'),(alpha, 'alpha')] deps = [('Probability', '%d identities' % i, '') for i in range(numPingPongs+1)] kw = {'stats': stats, 'useHD': useHD, 'numPingPongs': numPingPongs} dataset = sweeps.prepDataset(sample, name, axes, dependents=deps, measure=measure, kw=kw) if useHD: def pfunc(t0, phase=0, alpha=0.5): return eh.piHalfPulseHD(q, t0, phase=phase, alpha=alpha) else: def pfunc(t0, phase=0, alpha=0.0): #The alpha parameter is just there for call signature compatibility. I know this is stupid. Sorry. DTS return env.gaussian(t0, q['piFWHM'], amp=q['piAmp']/2.0, phase=phase) def func(server, theta, alpha): dt = q['piLen'] reqs = [] for i in range(numPingPongs+1): q.xy = eh.mix(q, pfunc(-dt) + sum(pfunc(2*k*dt, alpha=alpha) - pfunc((2*k+1)*dt, alpha=alpha) for k in range(i)) + pfunc(2*i*dt, phase=theta*np.pi, alpha = alpha) ) tm = 2*i*dt + dt/2.0 q.z = eh.measurePulse(q, tm) q['readout'] = True reqs.append(runQubits(server, qubits, probs=[1], stats=stats)) probs = yield FutureList(reqs) returnValue([p[0] for p in probs]) return sweeps.grid(func, axes, dataset=save and dataset, collect=collect, noisy=noisy)
def lztest_theta(Sample, measure=0, theta=st.r[0:2 * np.pi:0.1], state=1, stats=1200, delta=1.0, name='lz theta test', save=True, noisy=True, prob=True): sample, devs, qubits, Qubits = gc.loadQubits(Sample, measure, True) axes = [(theta, 'Geometric phase')] if prob: deps = readout.genProbDeps(qubits, measure) else: deps = [("Mag", "|%s>" % state, ""), ("Phase", "|%s>" % state, "rad")] kw = {'stats': stats, 'prob': prob} dataset = sweeps.prepDataset(sample, name, axes, deps, measure, kw=kw) def func(server, currphase): alg = gc.Algorithm(devs) q0 = alg.q0 k0 = np.sqrt(delta**2 / (1 + np.tan(currphase)**2)) #alg[gates.MoveToState([q0], 0, state-1)] alg[LZ_gate([q0], k0=k0, k1=k0 * np.tan(currphase))] #alg[gates.MoveToState([q0], state-1, 0)] alg[gates.Measure([q0])] alg.compile() data = yield runQubits(server, alg.agents, stats, dataFormat='iqRaw') if prob: probs = readout.iqToProbs(data, alg.qubits) probs = np.squeeze(probs) returnValue(probs) else: data = readout.parseDataFormat(data, 'iq') mag, phase = readout.iqToPolar(data) returnValue([mag, phase]) data = sweeps.grid(func, axes=axes, save=save, dataset=dataset, noisy=noisy) return data
def visibility(sample, mpa=st.r[0:2:0.05], stats=300, measure=0, save=True, name='Visibility MQ', collect=True, update=False, noisy=True): sample, qubits = util.loadQubits(sample) q = qubits[measure] axes = [(mpa, 'Measure pulse amplitude')] deps = [('Probability', '|0>', ''), ('Probability', '|1>', ''), ('Visibility', '|1> - |0>', ''), ('Probability', '|2>', ''), ('Visibility', '|2> - |1>', '') ] kw = {'stats': stats} dataset = sweeps.prepDataset(sample, name, axes, deps, measure=measure, kw=kw) def func(server, mpa): t_pi = 0 t_meas = q['piLen']/2.0 # without pi-pulse q['readout'] = True q['measureAmp'] = mpa q.xy = env.NOTHING q.z = eh.measurePulse(q, t_meas) req0 = runQubits(server, qubits, stats, probs=[1]) # with pi-pulse q['readout'] = True q['measureAmp'] = mpa q.xy = eh.mix(q, eh.piPulseHD(q, t_pi)) q.z = eh.measurePulse(q, t_meas) req1 = runQubits(server, qubits, stats, probs=[1]) # |2> with pi-pulse q['readout'] = True q['measureAmp'] = mpa q.xy = eh.mix(q, eh.piPulseHD(q, t_pi-q.piLen))+eh.mix(q, env.gaussian(t_pi, q.piFWHM, q.piAmp21, df=q.piDf21), freq = 'f21') q.z = eh.measurePulse(q, t_meas) req2 = runQubits(server, qubits, stats, probs=[1]) probs = yield FutureList([req0, req1, req2]) p0, p1, p2 = [p[0] for p in probs] returnValue([p0, p1, p1-p0, p2, p2-p1]) return sweeps.grid(func, axes, dataset=save and dataset, collect=collect, noisy=noisy)
def lztest_tauc(Sample, measure=0, delay=st.r[100:120:0.1, ns], state=1, stats=1200, name='lz tauc test', save=True, noisy=True, prob=True): sample, devs, qubits, Qubits = gc.loadQubits(Sample, measure, True) axes = [(delay, 'tauc')] if prob: deps = readout.genProbDeps(qubits, measure) else: deps = [("Mag", "|%s>" % state, ""), ("Phase", "|%s>" % state, "rad")] kw = {'stats': stats, 'prob': prob} dataset = sweeps.prepDataset(sample, name, axes, deps, measure, kw=kw) def func(server, currdelay): alg = gc.Algorithm(devs) q0 = alg.q0 taup = q0['lztaup'] currtau1 = (currdelay - taup) / 2 alg[LZ_gate([q0], tau1=currtau1)] alg[gates.Measure([q0])] alg.compile() data = yield runQubits(server, alg.agents, stats, dataFormat='iqRaw') if prob: probs = readout.iqToProbs(data, alg.qubits) probs = np.squeeze(probs) returnValue(probs) else: data = readout.parseDataFormat(data, 'iq') mag, phase = readout.iqToPolar(data) returnValue([mag, phase]) data = sweeps.grid(func, axes=axes, save=save, dataset=dataset, noisy=noisy) return data
def pingPongFrac(s, phase=st.r[-0.125:0.875:0.02], alphas=st.r[0.4:0.6:0.005], angle=np.pi/2.0, measure=0, numPulses=1, stats=1200, useHD=True, name='PingPongVsAlpha', save=True, collect=False, noisy=True, message=False): sample, qubits = util.loadQubits(s) q = qubits[measure] name = '%s useHD=%d nPulses=%d' % (name, useHD, numPulses) axes = [(phase, '2nd pulse phase'),(alphas, 'drag alpha')] deps = [('Probability', '%d pseudo-identities' %numPulses, '')] kw = {'stats': stats, 'useHD': useHD, 'nPulses': numPulses} dataset = sweeps.prepDataset(sample, name, axes, dependents=deps, measure=measure, kw=kw) if useHD: def pfunc(t0, angle, phase=0, alpha=0.5): return eh.rotPulseHD(q, t0, angle, phase=phase, alpha=alpha) else: def pfunc(t0, phase=0): return env.gaussian(t0, q['piFWHM'], amp=q['piAmp']/2.0, phase=phase) def func(server, currPhase, currAlpha): dt = q['piLen'] n = numPulses q.xy = eh.mix(q, pfunc(-dt, angle, alpha=currAlpha) + sum(pfunc(2*k*dt, angle, alpha=currAlpha) - pfunc((2*k+1)*dt, angle, alpha=currAlpha) for k in range(n)) + pfunc(2*n*dt, angle, alpha=currAlpha, phase=2*np.pi*currPhase) ) tm = 2*n*dt + dt/2.0 q.z = eh.measurePulse(q, tm) q['readout'] = True return runQubits(server, qubits, probs=[1], stats=stats) data = sweeps.grid(func, axes, dataset=save and dataset, collect=collect, noisy=noisy) if message: s._cxn.telecomm_server.send_sms('scan done','Scan %s has finished.' %name, s._dir[1]) if collect: return data
def lztest_theta_with_k2(Sample, measure=0, k2=st.r[0.1:5:0.2], theta=st.r[0:2 * np.pi:0.2], delta=5.0, state=1, tBuf=0 * ns, stats=600, name='lz k2', save=True, noisy=True): sample, devs, qubits = gc.loadQubits(Sample, measure) axes = [(k2, 'k2'), (theta, 'Geometric phase')] deps = readout.genProbDeps(qubits, measure, range(1 + state)) kw = {"stats": stats, 'tBuf': tBuf, "state": state} name += ' with delta=' + np.str(delta) dataset = sweeps.prepDataset(sample, name, axes, deps, measure, kw=kw) def func(server, currk, currphase): alg = gc.Algorithm(devs) q0 = alg.q0 k0 = np.sqrt(delta**2 / (1 + np.tan(currphase)**2)) alg[gates.MoveToState([q0], 0, state - 1)] alg[gates.Wait([q0], waitTime=tBuf)] alg[LZ_gate([q0], k0=k0, k1=k0 * np.tan(currphase), k2=currk)] alg[gates.Wait([q0], waitTime=tBuf)] alg[gates.Measure([q0])] alg.compile() data = yield runQubits(server, alg.agents, stats, dataFormat='iqRaw') probs = readout.iqToProbs(data, alg.qubits, states=range(1 + state)) returnValue(np.squeeze(probs)) data = sweeps.grid(func, axes=axes, save=save, dataset=dataset, noisy=noisy) return data
def lztest_amp(Sample, measure=0, amp=st.r[0:1:0.02], stats=1200, name='lz amp test', dataFormat='Amp', save=True, noisy=True): sample, devs, qubits = gc.loadQubits(Sample, measure=measure) axes = [(amp, "swiphtAmp")] if dataFormat == 'Amp': deps = [("Mag", "", ""), ("Phase", "", "")] else: deps = [("I", "", ""), ("Q", "", "")] kw = {'stats': stats} dataset = sweeps.prepDataset(sample, name, axes, deps, measure, kw=kw) def func(server, curramp): alg = gc.Algorithm(devs) q0 = alg.q0 alg[LZ_gate([q0], amp=curramp)] alg[gates.Wait([q0], 0 * ns)] alg[gates.PiPulse([q0])] alg[gates.Readout([q0])] alg.compile() data = yield runQubits(server, alg.agents, stats, dataFormat='iqRaw') if dataFormat == 'Amp': mag, ang = readout.iqToPolar(readout.parseDataFormat(data, 'iq')) else: data = readout.parseDataFormat(data, 'iq') mag, ang = data[0], data[1] returnValue([mag, ang]) data = sweeps.grid(func, axes=axes, save=save, dataset=dataset, noisy=noisy) return data
def randomNums(s, measure, mpa, repsPerFile, delay=4*ns, stats=300, name='Random Numbers', save=True, collect=False, noisy=False): """Generate a string of random numbers by measuring a state on the equator""" sample, qubits, Qubits = util.loadQubits(s,write_access=True) q = qubits[measure] Q = Qubits[measure] q['measureAmp'] = mpa q['readout'] = True q.z = eh.measurePulse(q, 0) iterations = st.r[0:repsPerFile:1] axes = [(iterations, 'iteration')] deps = [('Tunnelled','','')] kw = {} dataset = sweeps.prepDataset(sample, name, axes, deps, measure=measure, kw=kw) def func(server,arg): result = yield runQubits(server, qubits, stats, dataFormat = 'phases') returnValue(np.vstack(result).T) data = sweeps.grid(func, axes, save=save, dataset=save and dataset, noisy=noisy, collect=collect) if collect: return data
for i, (q, zpa) in enumerate(zip(qubits, zpas)): q['uwavePhase'] = 0 # turn off automatic phase correction if i == adjust: xy = eh.piHalfPulse(q, tp0) * np.exp(1j*phase) elif i == ref: xy = eh.piHalfPulse(q, tp0) else: xy = env.NOTHING q.xy = eh.mix(q, xy) q.z = env.rect(tz, t_couple, zpa, overshoot=q['wZpulseOvershoot']) eh.correctCrosstalkZ(qubits) return measure(server, qubits, tm, stats=stats) return sweeps.grid(func, axes, dataset=save and dataset, collect=collect, noisy=noisy) def swap_dphase_adjust(sample, dphase, stats=600L, adjust=0, ref=1, name='Swap phase adjust', save=True, collect=True, noisy=True): sample, qubits = util.loadQubits(sample) axes = [(dphase, 'dphase')] measure = measurement.Simult(len(qubits), adjust) kw = {'stats': stats, 'adjust qubit': adjust, 'ref qubit': ref} dataset = sweeps.prepDataset(sample, name, axes, measure=measure, kw=kw) def func(server, dphase): qa = qubits[adjust] qr = qubits[ref]
def func(server, curr): start = 0 q0.xy = eh.mix(q0, eh.piPulseHD(q0, start)) start += q0['piLen']/2 q0.z = env.rect(start, curr, q0.cZControlAmp)#amplitude for an iSWAP start += q0.cZControlLen+curr q1.z = env.rect(start, q1.cZControlLen, q1.cZControlAmp)#amplitude & length for an iSWAP start += q1.cZControlLen q0.z += eh.measurePulse(q0, start) q1.z += eh.measurePulse(q1, start) q0['readout'] = True q1['readout'] = True return runQubits(server, qubits, stats=stats) return sweeps.grid(func, axes, dataset=save and dataset, noisy=noisy) def bellStateiSwap(sample, reps=5, measure=[0,1], stats=1500L, corrAmp=None, name='Bell State with an iSwap MQ', save=True, collect=False, noisy=True): """Make any of the four Bell states by varying the corrAmplitude (empirically for now) TODO: make this a function of Zpi amplitude so there is some meaning to the amplitude and consequent phase shift. """ sample, qubits = util.loadQubits(sample) q0 = qubits[measure[0]] q1 = qubits[measure[1]] measurement = meas.Octomo(4, measure) if corrAmp is None:
measureFunc = measurement.Simult(N, measure, tBuf=tBuf,) name = '%s useHD=%d useTomo=%d' % (name, useHD, useTomo) axes = [(fraction, 'fraction of Pi-pulse')] kw = {'stats': stats, 'useHD': useHD, 'phase':phase, 'tBuf':tBuf} dataset = sweeps.prepDataset(sample, name, axes, measure=measureFunc, kw=kw) def func(server, fraction): if useHD: pulse = eh.mix(q, eh.rotPulseHD(q, 0, angle=fraction*np.pi, phase=phase, alpha=alpha)) else: pulse = eh.mix(q, env.gaussian(0, q['piFWHM'], amp=fraction*q['piAmp'])) q.xy = pulse return measureFunc(server, qubits, tBuf+q['piLen']/2, stats=stats) return sweeps.grid(func, axes, dataset=save and dataset, collect=collect, noisy=noisy, pipesize=1) def hadamardTrajectory(sample, fraction=st.r[0.0:1.0:0.01], measure=0, stats=1500L, useHD=True, useTomo=True, tBuf=0*ns, name='Hadamard Trajectory', save=True, collect=False, noisy=True): #TODO Add flag to plot trajectory on bloch sphere #TODO add line in qstSweep to grab the most recent dataset from datavault see Ramsey for example sample, qubits = util.loadQubits(sample) q = qubits[measure] N= len(s['config']) if useTomo: print 'measuring qubit %d out %d with Octomography ' %(measure,N) measureFunc = measurement.Octomo(N, measure, tBuf=tBuf) else: print 'measuring qubit %d out %d with Simultaneous measurement' %(measure,N)
'stats': stats, } dataset = sweeps.prepDataset(sample, name, axes, measure=measure, kw=kw) def func(server, stage, delay, phase0, phase2, dphase0, dphase2): if retune == 'freq': for i in range(3): mq.freqtuner(sample, measure=i, noisy=False) qubits[0]['uwavePhase'] = phase0 qubits[2]['uwavePhase'] = phase2 qubits[0]['swapDphase'] = dphase0 qubits[2]['swapDphase'] = dphase2 qs, tm = seq_ghz_simult(qubits, delay, stage) return measurement.do(measure, server, qs, tm, stats=stats) return sweeps.grid(func, axes, dataset=dataset, **kwargs) def seq_ghz_simult(qubits, delay=0*ns, stage=3, ref=1): """GHZ sequence using simultaneous coupling.""" dt = max(q['piLen'] for q in qubits) tswap = sum(q['swapLen'] for q in qubits) / 2 # compute times for various stages tp0 = 0 tz = dt/2 tp1 = tz + tswap + dt/2 # compute measurement time based on number of stages if stage < 0: raise Exception('stage must be >= 0')
if swapLen is None: swapLen = q.swapLen if swapAmp is None: swapAmp = q.swapAmp axes = [(swapAmp, 'swap pulse amplitude'), (swapLen, 'swap pulse length')] kw = {'stats': stats} dataset = sweeps.prepDataset(sample, name, axes, measure=measure, kw=kw) def func(server, currAmp, currLen): q.xy = eh.mix(q, eh.piPulseHD(q, 0)) q.z = env.rect(q['piLen']/2, currLen, currAmp) + eh.measurePulse(q, q['piLen']/2 + currLen) q['readout'] = True return runQubits(server, qubits, stats=stats, probs=[1]) return sweeps.grid(func, axes, save=save, dataset=dataset, collect=collect, noisy=noisy) def swap21(sample, swapLen=None, swapAmp=None, measure=0, stats=1500L, name='coupling resonator swap MQ', save=True, collect=False, noisy=True): sample, qubits = util.loadQubits(sample) q = qubits[measure] if swapLen is None: swapLen = q.swapLen if swapAmp is None: swapAmp = q.swapAmp axes = [(swapAmp, 'swap pulse amplitude'), (swapLen, 'swap pulse length')] kw = {'stats': stats} dataset = sweeps.prepDataset(sample, name, axes, measure=measure, kw=kw)