{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Crosstalk Diagnostics\n\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The quality of gates in a device may depend on whether the gates are occurring\nsimultaneously or in isolation. This can be due to quantum or classical crosstalk. In\nthis example we use :py:func:`~trueq.make_crosstalk_diagnostics` to measure this\ndiscrepancy. See also :tqdoc:`CTD`.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import trueq as tq\nfrom trueq.simulation.noise_source import NoiseSource\n\n# create circuits for crosstalk diagnostics on qubits 5, 6, and 7 for single-qubit gates\ncircuits = tq.make_crosstalk_diagnostics([5, 6, 7], [4, 16, 32], 50)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Next, we define a CrossTalk noise source as a subclass of NoiseSource\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "class CrossTalk(NoiseSource):\n # this is a simple crosstalk simulator (not based on realistic device physics),\n # where adjacent qubits add a fraction of their own gate to the other qubit\n def __init__(self, rotation_profile, match=None):\n self.rotation_profile = rotation_profile\n super().__init__(match=match)\n\n def apply(self, cycle_wrapper, state, circuit_cache):\n for labels, gate in self.match.iter_gates(cycle_wrapper, noise_only=False):\n for label in state.labels:\n if abs(label - labels[0]) == 1:\n # if qubit labels are 1 apart, multiply the other qubit by a small\n # fraction of this qubit's gate\n state.apply_matrix(\n labels, (gate ** self.rotation_profile[labels[0]]).mat\n )\n elif label == labels[0]:\n # simulate the entire gate on this qubit\n state.apply_matrix(labels, gate.mat)\n\n\ncycle_crosstalk = CrossTalk(rotation_profile={5: 0.01, 6: 0.045, 7: 0.03})\nsim = tq.Simulator().add_stochastic_pauli(pz=0.02)\nsim.append_noise_source(cycle_crosstalk)\nsim.run(circuits)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Show all of the decay curves.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "circuits.plot.raw()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Compare the fitted results on a plot. We see that process infidelities (SRB) in the\nsimultaneous case are higher because of the crosstalk noise added by our simulator.\nHowever, the stochastic infidelity (XRB) is the same for both simultaneous and\nisolated experiments. This is due to the shared stochastic noise model\n``add_stochastic_pauli(pz=0.02)``.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "circuits.plot.compare_rb()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.8" } }, "nbformat": 4, "nbformat_minor": 0 }