Tamil
மொழிகள்
English
Bengali
French
German
Japanese
Korean
Portuguese
Spanish
Tamil

Note

இந்த பக்கம் tutorials/simulators/4_custom_gate_noise.ipynb இலிருந்து உருவாக்கப்பட்டது.

வழக்கமான யூனிடேரி கேட்களுக்கு சத்தம் பயன்படுத்துதல்

முன்னுரை

இந்த நோட்புக் ஒரு குவாண்டம் சுற்றுக்கு வழக்கமான யூனிடேரி கேட்களை எவ்வாறு சேர்ப்பது என்பதைக் காட்டுகிறது, மேலும் அவற்றை Qiskit ஏரில் சத்தம் உருவகப்படுத்துதல்களுக்குப் பயன்படுத்தலாம்.

[1]:
from qiskit import transpile, QuantumCircuit
import qiskit.quantum_info as qi

from qiskit_aer import AerSimulator
from qiskit_aer.noise import NoiseModel, amplitude_damping_error

from qiskit.tools.visualization import plot_histogram

மேட்ரிக்ஸ் ஆபரேட்டர்களை உருவாக்குதல்

தன்னிச்சையான மேட்ரிக்ஸ் ஆபரேட்டர்களைக் குறிக்க qiskit.quantum_info இல் Operator வகுப்பைப் பயன்படுத்தலாம். ஆபரேட்டர் யூனிடேரியாக இருந்தால், அதை ஒரு குவாண்டம் சுற்றுக்குச் சேர்த்து Qiskit ஏரில் உருவகப்படுத்துவதற்குப் பயன்படுத்தலாம்.

ஒரு CNOT கேட் மற்றும் iSWAP கேட் ஆகியவற்றிற்காக கீழே இரண்டு ஆபரேட்டர்களை உருவாக்கலாம்:

\[\begin{split}\mbox{CNOT} = \left(\begin{array} & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 \end{array}\right), \quad \mbox{iSWAP} = \left(\begin{array} & 1 & 0 & 0 & 0 \\ 0 & 0 & i & 0 \\ 0 & i & 0 & 0 \\ 0 & 0 & 0 & 1 \end{array}\right)\end{split}\]
[2]:
# CNOT matrix operator with qubit-0 as control and qubit-1 as target
cx_op = qi.Operator([[1, 0, 0, 0],
                     [0, 0, 0, 1],
                     [0, 0, 1, 0],
                     [0, 1, 0, 0]])

# iSWAP matrix operator
iswap_op = qi.Operator([[1, 0, 0, 0],
                        [0, 0, 1j, 0],
                        [0, 1j, 0, 0],
                        [0, 0, 0, 1]])

குறிப்பு: டென்சர் தயாரிப்பு தொடர்பாக மேட்ரிக்ஸ் \(U_{b}\otimes U_{a}\) கியூபிட்களுக்கு [a, b] பட்டியலால் குறிப்பிடப்பட்டுள்ளது.

சுற்றுகளில் ஆபரேட்டர்களைப் பயன்படுத்துதல்

ஒரு சுற்றில் இவை எவ்வாறு பயன்படுத்தப்படலாம் என்பதை நிரூபிப்போம். நாம் உதாரணமாக ஒற்றை-கியூபிட் கேட்கள் மற்றும் iSWAP கேட்கள் ஆகிய கூறுகளாக பிரிக்கப்பட்ட CNOT கேட்டை செயற்படுத்த பின்வருவனவற்றை நாம் கருத்தில் கொள்வோம்.

[3]:
# CNOT in terms of iSWAP and single-qubit gates
cx_circ = QuantumCircuit(2, name='cx<iSWAP>')

# Add gates
cx_circ.sdg(1)
cx_circ.h(1)
cx_circ.sdg(0)
cx_circ.unitary(iswap_op, [0, 1], label='iswap')
cx_circ.sdg(0)
cx_circ.h(0)
cx_circ.sdg(0)
cx_circ.unitary(iswap_op, [0, 1], label='iswap')
cx_circ.s(1)

print(cx_circ)
     ┌─────┐     ┌────────┐┌─────┐┌───┐┌─────┐┌────────┐
q_0: ┤ SDG ├─────┤0       ├┤ SDG ├┤ H ├┤ SDG ├┤0       ├─────
     ├─────┤┌───┐│  iswap │└─────┘└───┘└─────┘│  iswap │┌───┐
q_1: ┤ SDG ├┤ H ├┤1       ├───────────────────┤1       ├┤ S ├
     └─────┘└───┘└────────┘                   └────────┘└───┘

யூனிட்டரி செருகப்படும்போது "iswap" இன் விருப்பமான label ஒதுக்கியுள்ளோம் என்பதை நினைவில் கொள்க. Qiskit ஏர் NoiseModel இந்த யூனிடேரியை அடையாளம் காண இது நம்மை அனுமதிக்கிறது, இதன்மூலம் நாம் இரைச்சல் மிக்க சுற்று உருவகப்படுத்துதல்களில் இந்த வழக்கமான யூனிடேரி கேட்ககளுக்குப் பிழைகளைச் சேர்க்கலாம்.

இந்த சுற்று சுற்றுக்கான சிமுலேட்டராக Operator வகுப்பைப் பயன்படுத்தி சரியான வெளியீட்டை அளிக்கிறது என்பதை நாங்கள் உறுதிப்படுத்த முடியும்:

[4]:
# Simulate the unitary for the circuit using Operator:
unitary = qi.Operator(cx_circ)
print(unitary)
Operator([[1.+0.j, 0.+0.j, 0.+0.j, 0.+0.j],
          [0.+0.j, 0.+0.j, 0.+0.j, 1.+0.j],
          [0.+0.j, 0.+0.j, 1.+0.j, 0.+0.j],
          [0.+0.j, 1.+0.j, 0.+0.j, 0.+0.j]],
         input_dims=(2, 2), output_dims=(2, 2))

வெளியீடு சரியானது என்பதை உறுதிப்படுத்த, சராசரி வாயில் நம்பகத்தன்மையை நாம் கணக்கிடலாம்:

[5]:
f_ave = qi.average_gate_fidelity(cx_op, unitary)
print("Average Gate Fidelity: F = {:f}".format(f_ave))
Average Gate Fidelity: F = 1.000000

இரைச்சல் மாதிரியில் தனிப்பயன் ஒற்றுமையை உருவாக்குதல்

Qiskit ஏர் AerSimulator தன்னிச்சையான ஒற்றையாட்சி ஆபரேட்டர்களை உருவகப்படுத்துவதை ஆதரிக்கிறது.

[6]:
'unitary' in AerSimulator().configuration().basis_gates
[6]:
True

QuantumCircuit.unitary இன் விருப்பமான `` label`` வாதத்தைப் பயன்படுத்தி அடையாளம் காணும்போது, ​​எங்கள் உருவகப்படுத்துதலில் தன்னிச்சையான யூனிடரிகளுக்கு சத்தம் மாதிரிகள் சேர்க்க இது நம்மை அனுமதிக்கிறது.

எங்கள் தனிப்பயன் iSWAP வாயிலில் குவாண்டம் பிழை சேனலை உள்ளடக்கிய `` NoiseModel`` ஐ உருவாக்குவதன் மூலம் இதை இப்போது செய்வோம். எங்கள் எடுத்துக்காட்டுக்கு, இரண்டு ஒற்றை-குவிட் அலைவீச்சு அடர்த்தியான சேனல்களைக் கொண்ட 2-குவிட் பிழையை வெவ்வேறு தணிக்கும் அளவுருக்களுடன் உருவாக்குவோம். இப்போதைக்கு மற்ற அனைத்து சுற்று வழிமுறைகளும் சிறந்தவை என்று கருதுவோம்.

[7]:
# Error parameters
param_q0 = 0.05  # damping parameter for qubit-0
param_q1 = 0.1   # damping parameter for qubit-1

# Construct the error
qerror_q0 = amplitude_damping_error(param_q0)
qerror_q1 = amplitude_damping_error(param_q1)
iswap_error = qerror_q1.tensor(qerror_q0)

# Build the noise model by adding the error to the "iswap" gate
noise_model = NoiseModel()
noise_model.add_all_qubit_quantum_error(iswap_error, 'iswap')

`` "iswap" போன்ற தனிப்பயன் லேபிளில் பிழையைச் சேர்க்கும்போது, ​​`` NoiseModel`` இந்த லேபிள் எந்த வாயிலுக்குப் பொருந்தும் என்று தெரியவில்லை, எனவே நாம் விரும்பிய கேட் சரத்தை கைமுறையாக சேர்க்க வேண்டும் சத்தம் மாதிரி basis_gates. இரைச்சல் மாதிரி உருவகப்படுத்துதலுக்கான சரியான அடிப்படை வாயில்களுக்கு கம்பைலர் அவிழும் என்பதை இது உறுதி செய்கிறது. `` NoiseModel.add_basis_gates`` செயல்பாட்டைப் பயன்படுத்தி இதைச் செய்யலாம்:

[8]:
noise_model.add_basis_gates(['unitary'])
print(noise_model.basis_gates)
['cx', 'id', 'u3', 'unitary']

இயல்பாகவே ஒரு சத்தம் மாதிரியின் அடிப்படை வாயில்கள் `` ['cx', 'id', 'u3'] `` மற்றும் சத்தம் மாதிரியில் சேர்க்கப்படும் எந்தவொரு நிலையான AerSimulator அடிப்படை வாயில்கள்.

தனிப்பயன் ஒற்றுமை இரைச்சல் மாதிரியை உருவகப்படுத்துதல்

முதலில் எங்கள் முந்தைய சிஎக்ஸ் சுற்று எடுத்து, ஒரு ஆரம்ப ஹடாமார்ட் கேட் மற்றும் இறுதி அளவீட்டைச் சேர்ப்போம், பெல்-ஸ்டேட் தயாரிப்பு சுற்று ஒன்றை உருவாக்கலாம், இது சிறந்த மற்றும் சத்தமில்லாத வழக்குக்கு AerSimulator சிமுலேட்டராக இருக்கலாம்:

[9]:
# Bell state circuit where iSWAPS should be inserted at barrier locations
bell_circ = QuantumCircuit(2, 2, name='bell')
bell_circ.h(0)
bell_circ.append(cx_circ, [0, 1])
bell_circ.measure([0,1], [0,1])
print(bell_circ)
     ┌───┐┌────────────┐┌─┐
q_0: ┤ H ├┤0           ├┤M├───
     └───┘│  cx<iSWAP> │└╥┘┌─┐
q_1: ─────┤1           ├─╫─┤M├
          └────────────┘ ║ └╥┘
c: 2/════════════════════╩══╩═
                         0  1

சிறந்த வெளியீடு

Let’s first see the ideal output. Since this generates a Bell-state we expect two peaks for 00 and 11.

[10]:
# Create ideal simulator backend and transpile circuit
sim_ideal = AerSimulator()
tbell_circ = transpile(bell_circ, sim_ideal)

ideal_result = sim_ideal.run(tbell_circ).result()
ideal_counts = ideal_result.get_counts(0)
plot_histogram(ideal_counts,
               title='Ideal output for iSWAP bell-state preparation')
[10]:
../../_images/tutorials_simulators_4_custom_gate_noise_24_0.png

சத்தம் சுற்று செயல்படுத்தல்

Finally, let’s now simulate it with our custom noise model. Since there is a small amplitude damping error on the two-qubit gates we expect small additional peaks for the 01 and 10 outcome probabilities.

[11]:
# Create noisy simulator and transpile circuit
sim_noise = AerSimulator(noise_model=noise_model)
tbell_circ_noise = transpile(bell_circ, sim_noise)

# Run on the simulator without noise
noise_result = sim_noise.run(tbell_circ_noise).result()
noise_counts = noise_result.get_counts(bell_circ)
plot_histogram(noise_counts,
               title='Noisy output for iSWAP bell-state preparation')
[11]:
../../_images/tutorials_simulators_4_custom_gate_noise_26_0.png
[12]:
import qiskit.tools.jupyter
%qiskit_version_table
%qiskit_copyright

Version Information

Qiskit SoftwareVersion
Qiskit0.25.0
Terra0.17.0
Aer0.8.0
Ignis0.6.0
Aqua0.9.0
IBM Q Provider0.12.2
System information
Python3.7.7 (default, May 6 2020, 04:59:01) [Clang 4.0.1 (tags/RELEASE_401/final)]
OSDarwin
CPUs6
Memory (Gb)32.0
Fri Apr 02 12:12:41 2021 EDT

This code is a part of Qiskit

© Copyright IBM 2017, 2021.

This code is licensed under the Apache License, Version 2.0. You may
obtain a copy of this license in the LICENSE.txt file in the root directory
of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.

Any modifications or derivative works of this code must retain this
copyright notice, and modified files need to carry a notice indicating
that they have been altered from the originals.

[ ]: