Controlling the way light interacts with material excitations is at the heart of cavity quantum electrodynamics (QED). In the strong-coupling regime, quantum emitters in a microresonator absorb and spontaneously re-emit a photon many times before dissipation becomes effective, giving rise to mixed light–matter eigenmodes1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12. Recent experiments13 in semiconductor microcavities reached a new limit of ultrastrong coupling14, where photon exchange occurs on timescales comparable to the oscillation period of light. In this limit, ultrafast modulation of the coupling strength has been suggested to lead to unconventional QED phenomena14, 15. Although sophisticated light–matter coupling has been achieved in all three spatial dimensions, control in the fourth dimension, time, is little developed. Here we use a quantum-well waveguide structure to optically tune light–matter interaction from weak to ultrastrong and turn on maximum coupling within less than one cycle of light. In this regime, a class of extremely non-adiabatic phenomena becomes observable. In particular, we directly monitor how a coherent photon population converts to cavity polaritons during abrupt switching. This system forms a promising laboratory in which to study novel sub-cycle QED effects and represents an efficient room-temperature switching device operating at unprecedented speed.