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

Note

இந்த பக்கம் `tutorials/algorithms/03_vqe_simulation_with_noise.ipynb`__ இதிலிருந்து உருவாக்கப்பட்டது.

விக்யூஇ உடன் கிஸ்கிட் ஏர் பிரிமிடிவ்ஸ்

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

Qiskit Aer இரைச்சல் மாதிரிபற்றிய கூடுதல் தகவலுக்கு, நீங்கள் Qiskit Aer ஆவணங்களை மற்றும் `பில்டிங் இரைச்சல் மாடல்களுக்கான டுடோரியலைப் பார்க்கவும். /simulators/3_building_noise_models.ipynb>`__.

தேர்வின் வழிமுறை மீண்டும் VQE ஆகும், அங்கு பணியானது ஹாமில்டோனியனின் குறைந்தபட்ச (தரையில்) ஆற்றலைக் கண்டறிவதாகும். முந்தைய பயிற்சிகளில் காட்டப்பட்டுள்ளபடி, VQE ஆனது ஒரு குவிட் ஆபரேட்டரை உள்ளீடாக எடுத்துக்கொள்கிறது. இங்கே, SparsePauliOp வகுப்பைப் பயன்படுத்தி, H2 மூலக்கூறுக்காக Qiskit Nature மூலம் முதலில் கணக்கிடப்பட்ட பாலி ஆபரேட்டர்களின் தொகுப்பை நீங்கள் எடுப்பீர்கள்.

[1]:
from qiskit.quantum_info import SparsePauliOp

H2_op = SparsePauliOp.from_list(
    [
        ("II", -1.052373245772859),
        ("IZ", 0.39793742484318045),
        ("ZI", -0.39793742484318045),
        ("ZZ", -0.01128010425623538),
        ("XX", 0.18093119978423156),
    ]
)

print(f"Number of qubits: {H2_op.num_qubits}")
Number of qubits: 2

மேலே உள்ள பிரச்சனையானது பாரம்பரியமாக இன்னும் எளிதில் தீர்க்கக்கூடியதாக இருப்பதால், முடிவுகளைப் பின்னர் ஒப்பிடுவதற்கு ஒரு குறிப்பு மதிப்பைக் கணக்கிட NumPyMinimumEigensolver ஐப் பயன்படுத்தலாம்.

[2]:
from qiskit.algorithms import NumPyMinimumEigensolver
from qiskit.opflow import PauliSumOp

numpy_solver = NumPyMinimumEigensolver()
result = numpy_solver.compute_minimum_eigenvalue(operator=PauliSumOp(H2_op))
ref_value = result.eigenvalue.real
print(f"Reference value: {ref_value:.5f}")
Reference value: -1.85728

பின்வரும் எடுத்துக்காட்டுகள் அனைத்தும் ஒரே அன்சாட்ஸ் மற்றும் ஆப்டிமைசரைப் பயன்படுத்தும், பின்வருமாறு வரையறுக்கப்படுகிறது:

[3]:
# define ansatz and optimizer
from qiskit.circuit.library import TwoLocal
from qiskit.algorithms.optimizers import SPSA

iterations = 125
ansatz = TwoLocal(rotation_blocks="ry", entanglement_blocks="cz")
spsa = SPSA(maxiter=iterations)

*ஒலி இல்லாமல் செயல் *

Let’s first run the VQE on the default Aer simulator without adding noise, with a fixed seed for the run and transpilation to obtain reproducible results. This result should be relatively close to the reference value from the exact computation.

[4]:
# define callback
# note: Re-run this cell to restart lists before training
counts = []
values = []


def store_intermediate_result(eval_count, parameters, mean, std):
    counts.append(eval_count)
    values.append(mean)
[5]:
# define Aer Estimator for noiseless statevector simulation
from qiskit.utils import algorithm_globals
from qiskit_aer.primitives import Estimator as AerEstimator

seed = 170
algorithm_globals.random_seed = seed

noiseless_estimator = AerEstimator(
    run_options={"seed": seed, "shots": 1024},
    transpile_options={"seed_transpiler": seed},
)
[6]:
# instantiate and run VQE
from qiskit.algorithms.minimum_eigensolvers import VQE

vqe = VQE(
    noiseless_estimator, ansatz, optimizer=spsa, callback=store_intermediate_result
)
result = vqe.compute_minimum_eigenvalue(operator=H2_op)

print(f"VQE on Aer qasm simulator (no noise): {result.eigenvalue.real:.5f}")
print(
    f"Delta from reference energy value is {(result.eigenvalue.real - ref_value):.5f}"
)
VQE on Aer qasm simulator (no noise): -1.84322
Delta from reference energy value is 0.01406

ஒருங்கிணைப்பின்போது மேலே உள்ள ஆற்றல் மதிப்புகளை நீங்கள் கைப்பற்றியுள்ளீர்கள், எனவே கீழே உள்ள வரைபடத்தில் செயல்முறையை நீங்கள் கண்காணிக்கலாம்.

[7]:
import pylab

pylab.rcParams["figure.figsize"] = (12, 4)
pylab.plot(counts, values)
pylab.xlabel("Eval count")
pylab.ylabel("Energy")
pylab.title("Convergence with no noise")
[7]:
Text(0.5, 1.0, 'Convergence with no noise')
../../_images/tutorials_algorithms_03_vqe_simulation_with_noise_12_1.png

சத்தத்துடன் செயல்திறன்

Now, let’s add noise to our simulation. In particular, you will extract a noise model from a (fake) device. As stated in the introduction, it is also possible to create custom noise models from scratch, but this task is beyond the scope of this notebook.

முதலில், நீங்கள் ஒரு உண்மையான சாதனத்தின் பின்தளத்தைப் பெற வேண்டும் மற்றும் அதன் configuration மற்றும் properties ஆகியவற்றிலிருந்து சாதனத்துடன் பொருந்தக்கூடிய இணைப்பு வரைபடத்தையும் இரைச்சல் மாதிரியையும் அமைக்கலாம். குறிப்பு: இந்த இணைப்பு வரைபடத்தை நீங்கள் தேர்வுசெய்தால், மாறுபாடு வடிவத்திற்கான சிக்கல் வரைபடமாகவும் பயன்படுத்தலாம்.

[8]:
from qiskit_aer.noise import NoiseModel
from qiskit.providers.fake_provider import FakeVigo

# fake providers contain data from real IBM Quantum devices stored in Qiskit Terra,
# and are useful for extracting realistic noise models.
device = FakeVigo()

coupling_map = device.configuration().coupling_map
noise_model = NoiseModel.from_backend(device)

print(noise_model)
NoiseModel:
  Basis gates: ['cx', 'id', 'rz', 'sx', 'x']
  Instructions with noise: ['id', 'measure', 'sx', 'x', 'cx']
  Qubits with noise: [0, 1, 2, 3, 4]
  Specific qubit errors: [('id', (0,)), ('id', (1,)), ('id', (2,)), ('id', (3,)), ('id', (4,)), ('sx', (0,)), ('sx', (1,)), ('sx', (2,)), ('sx', (3,)), ('sx', (4,)), ('x', (0,)), ('x', (1,)), ('x', (2,)), ('x', (3,)), ('x', (4,)), ('cx', (3, 4)), ('cx', (4, 3)), ('cx', (3, 1)), ('cx', (1, 3)), ('cx', (1, 2)), ('cx', (2, 1)), ('cx', (0, 1)), ('cx', (1, 0)), ('measure', (0,)), ('measure', (1,)), ('measure', (2,)), ('measure', (3,)), ('measure', (4,))]

இரைச்சல் மாதிரி வரையறுக்கப்பட்டவுடன், நீங்கள் ஏர் Estimator ஐப் பயன்படுத்தி VQE ஐ இயக்கலாம், அங்கு backend_options அகராதியைப் பயன்படுத்தி இரைச்சல் மாதிரியை அடிப்படை சிமுலேட்டருக்கு அனுப்பலாம். இந்த உருவகப்படுத்துதல் சத்தமில்லாத ஒன்றை விட அதிக நேரம் எடுக்கும் என்பதை நினைவில் கொள்ளவும்.

[9]:
noisy_estimator = AerEstimator(
    backend_options={
        "method": "density_matrix",
        "coupling_map": coupling_map,
        "noise_model": noise_model,
    },
    run_options={"seed": seed, "shots": 1024},
    transpile_options={"seed_transpiler": seed},
)

VQE வகுப்பின் புதிய நிகழ்வை வரையறுப்பதற்குப் பதிலாக, நீங்கள் இப்போது எங்களின் முந்தைய VQE நிகழ்விற்கு புதிய மதிப்பீட்டை ஒதுக்கலாம். திரும்ப அழைக்கும் முறை மீண்டும் பயன்படுத்தப்படுவதால், பின்னர் ஒன்றிணைக்கும் வரைபடத்தைத் திட்டமிடுவதற்கு நீங்கள் counts மற்றும் values மாறிகளை மீண்டும் தொடங்க வேண்டும்.

[10]:
# re-start callback variables
counts = []
values = []
[11]:
vqe.estimator = noisy_estimator

result1 = vqe.compute_minimum_eigenvalue(operator=H2_op)

print(f"VQE on Aer qasm simulator (with noise): {result1.eigenvalue.real:.5f}")
print(
    f"Delta from reference energy value is {(result1.eigenvalue.real - ref_value):.5f}"
)
VQE on Aer qasm simulator (with noise): -1.74645
Delta from reference energy value is 0.11083
[12]:
if counts or values:
    pylab.rcParams["figure.figsize"] = (12, 4)
    pylab.plot(counts, values)
    pylab.xlabel("Eval count")
    pylab.ylabel("Energy")
    pylab.title("Convergence with noise")
../../_images/tutorials_algorithms_03_vqe_simulation_with_noise_20_0.png

சுருக்கம்

இந்த சுற்றுச்சூழல், நீங்கள் H2 மூலக்கூறு நிலையில் மூன்று கணக்கீடுகள் ஒப்பிடுகையில். முதலில், நீங்கள் ஒரு சாத்தியமான குறைந்த eigensolver பயன்படுத்தி ஒரு குறிப்பு மதிப்பு தயாரித்தார். அப ் பொழுது, நீங ் கள ் ` ` VQE ` ` Estimator ` ` Estimator ` ` ஐ 1024 சுட்டுகளுடன் இயக்க சென்றது. இறுதியாக, நீங்கள் ஒரு ஒளி மாதிரி ஒரு பின்னணியில் இருந்து பிரித்தெடுத்து அதை பயன்படுத்தி புதிய ` ` Estimator ` ` எச்சரிக்கை சிரமங்களுக்காக வரையறுக்கவும். முடிவுகள்:

[13]:
print(f"Reference value: {ref_value:.5f}")
print(f"VQE on Aer qasm simulator (no noise): {result.eigenvalue.real:.5f}")
print(f"VQE on Aer qasm simulator (with noise): {result1.eigenvalue.real:.5f}")
Reference value: -1.85728
VQE on Aer qasm simulator (no noise): -1.84322
VQE on Aer qasm simulator (with noise): -1.74645

You can notice that, while the noiseless simulation’s result is closer to the exact reference value, there is still some difference. This is due to the sampling noise, introduced by limiting the number of shots to 1024. A larger number of shots would decrease this sampling error and close the gap between these two values.

உண்மையான சாதனங்கள் (அல்லது உருவகப்படுத்தப்பட்ட இரைச்சல் மாதிரிகள்) மூலம் அறிமுகப்படுத்தப்பட்ட இரைச்சலைப் பொறுத்தவரை, பல்வேறு வகையான பிழைத் தணிப்பு நுட்பங்கள் மூலம் அதைச் சமாளிக்க முடியும். Qiskit Runtime Primitives ஆனது resilience_level விருப்பத்தின் மூலம் பிழையைக் குறைக்கும். இந்த விருப்பம் தற்போது ரிமோட் சிமுலேட்டர்கள் மற்றும் ரன்டைம் ப்ரிமிட்டிவ்ஸ் வழியாக அணுகப்படும் உண்மையான பின்தளங்களுக்குக் கிடைக்கிறது, நீங்கள் இந்த டுடோரியலைப் பார்க்கவும் மேலும் தகவலுக்கு.

[14]:
import qiskit.tools.jupyter

%qiskit_version_table
%qiskit_copyright

Version Information

Qiskit SoftwareVersion
qiskit-terra0.22.2
qiskit-aer0.11.1
qiskit-ignis0.7.1
qiskit-ibmq-provider0.19.2
qiskit0.39.2
System information
Python version3.10.2
Python compilerClang 13.0.0 (clang-1300.0.29.30)
Python buildv3.10.2:a58ebcc701, Jan 13 2022 14:50:16
OSDarwin
CPUs8
Memory (Gb)64.0
Fri Nov 18 01:03:00 2022 CET

This code is a part of Qiskit

© Copyright IBM 2017, 2022.

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.