Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emulator readout module #942

Draft
wants to merge 1 commit into
base: 0.1
Choose a base branch
from
Draft

Emulator readout module #942

wants to merge 1 commit into from

Conversation

sorewachigauyo
Copy link
Collaborator

@sorewachigauyo sorewachigauyo commented Jul 27, 2024

As discussed in #941, to enable the emulation of the readout pulse.

This relies on knowing the bare resonator frequency, SNR of the syst-em, ADC sampling rate, Q factors of the resonator (which can be acquired from qiboteam/qibocal#917), qubit-resonator coupling, qubit frequency and anharmonicity. Though, the Q factors are power dependent, so these would only hold true for the calibrated readout amplitude.

Here is some sample code using this module to measure the transmission of the readout resonator for the ground and excited states across different readout frequencies.

import numpy as np
import matplotlib.pyplot as plt
from qibolab.qubits import Qubit
from qibolab.instruments.emulator.readout import ReadoutSimulator

bare_resonator_frequency = 5.045e9

qb = Qubit(0, bare_resonator_frequency=bare_resonator_frequency, drive_frequency=3.99e9, anharmonicity=-191.78e6)
readout = ReadoutSimulator(qubit=qb, g=30e6, noise_model=None, internal_Q=2.5e6, coupling_Q=6e4, sampling_rate=1966.08e6)

span = 1e6
center_frequency = bare_resonator_frequency + 0.75e6
freq_sweep = np.linspace(center_frequency - span / 2, center_frequency + span / 2, 1000)
y_gnd = np.abs(readout.ground_s21(freq_sweep))
y_exc = np.abs(readout.excited_s21(freq_sweep))

freq_sweep /= 1e9
plt.plot(freq_sweep, y_gnd, label=r"$|0\rangle$")
plt.plot(freq_sweep, y_exc, label=r"$|1\rangle$")
plt.ylabel("|S21| [arb. units]")
plt.xlabel("Readout Frequency [GHz]")
plt.legend()
plt.grid()
plt.tight_layout()
plt.savefig("S21.png", dpi=300)
plt.show()

image

Here is some sample code of using the readout module to emulate single shot readout for 100 shots.

import numpy as np
import matplotlib.pyplot as plt
from qibolab.qubits import Qubit
from qibolab.instruments.emulator.readout import ReadoutSimulator
from qibolab.pulses import ReadoutPulse

bare_resonator_frequency = 5.045e9
nshots = 100

SNR = 50 # dB
READOUT_AMPLITUDE = 1
NOISE_AMP = np.power(10, -SNR / 20)
AWGN = lambda t: np.random.normal(loc=0, scale=NOISE_AMP, size=len(t))

qb = Qubit(0, bare_resonator_frequency=bare_resonator_frequency, drive_frequency=3.99e9, anharmonicity=-191.78e6)
readout = ReadoutSimulator(qubit=qb, g=10e6, noise_model=AWGN, internal_Q=2.5e6, coupling_Q=6e4, sampling_rate=1966.08e6)
ro_pulse = ReadoutPulse(start=0, duration=1000, amplitude=READOUT_AMPLITUDE, frequency=5.04585e9, shape="Rectangular()", relative_phase=0)

rgnd = [readout.simulate_ground_state_iq(ro_pulse) for k in range(nshots)]
rexc = [readout.simulate_excited_state_iq(ro_pulse) for k in range(nshots)]
plt.scatter(np.real(rgnd), np.imag(rgnd), label=r"$|0\rangle$")
plt.scatter(np.real(rexc), np.imag(rexc), label=r"$|1\rangle$")
plt.xlabel("I")
plt.ylabel("Q")
plt.legend()
plt.tight_layout()
plt.savefig("IQ.png", dpi=300)
plt.show()

image

Checklist:

  • Reviewers confirm new code works as expected.
  • Tests are passing.
  • Coverage does not decrease.
  • Documentation is updated.
  • Connect the results emulator to this readout module
  • Add the relevant parameters needed to the Qubit object
  • Add tests
  • Use readout IF frequency instead of exact frequency for systems with mixers

@alecandido Just to confirm that this is what you mean by readout emulation.

Copy link

codecov bot commented Jul 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.32%. Comparing base (c566eac) to head (cbd462a).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #942   +/-   ##
=======================================
  Coverage   70.32%   70.32%           
=======================================
  Files          64       64           
  Lines        6679     6679           
=======================================
  Hits         4697     4697           
  Misses       1982     1982           
Flag Coverage Δ
unittests 70.32% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@alecandido alecandido changed the base branch from main to 0.1 August 21, 2024 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant