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

Note

இந்தப் பக்கம் tutorials/algorithms/01_algorithms_introduction.ipynb இலிருந்து உருவாக்கப்பட்டது.

Qiskit வழிமுறைகளுக்கு ஒரு அறிமுகம்

இது Qiskit-ல் உள்ள வழிமுறைகளுக்கான அறிமுகம் மற்றும் தொடங்குவதற்கான செயல்பாட்டின் பல்வேறு அம்சங்களைப் புரிந்துகொள்ள உதவும் உயர் மட்ட கண்ணோட்டத்தை வழங்குகிறது. பிற பயிற்சிகள் கொடுக்கப்பட்ட வழிமுறைகள் மற்றும் அவற்றைப் பயன்படுத்துவதற்கான வழிகள் போன்றவற்றில் இன்னும் ஆழமான விஷயங்களை வழங்கும்.

எப்படி வழிமுறை நூலகம் வடிவமைக்கப்பட்டுள்ளது?

Qiskit பல அல்காரிதங்களை வழங்குகிறது மேலும் அவை அவர்கள் செய்யக்கூடிய பணியின்படி வகைகளின்படி குழுவாக்கப்படுகின்றன. உதாரணமாக ஒரு ஆபரேட்டரின் மிகச்சிறிய ஈஜென் மதிப்பைக் கண்டறிய குறைந்தபட்ச ஈஜென்சோல்வர்ஸ், எடுத்துக்காட்டாக, வேதியியல் ஹாமில்டோனியனின் தரை நிலை ஆற்றல் அல்லது ஐசிங் ஹாமில்டோனியனாக வெளிப்படுத்தப்படும் போது மேம்படுத்தல் சிக்கலுக்கான தீர்வு. குவாண்டம் அமைப்புகளின் நேரப் பரிணாமத்திற்கு டைம் எவால்வர்ஸ் மற்றும் மதிப்புக் கணிப்பிற்கு அம்ப்லிட்யூட் எஸ்டிமேட்டர் ஆகியவை நிதிப் பயன்பாடுகளில் பயன்படுத்தப்படலாம். வகைகளின் முழு தொகுப்பையும் மேலே உள்ள அல்காரிதம்ஸ் ஆவணப்படுத்தல் இணைப்பில் காணலாம்.

வழிமுறைகள் உள்ளமைக்கக்கூடியவை மற்றும் பெரும்பாலும் உள்ளமைவின் ஒரு பகுதி சிறிய கட்டுமானத் தொகுதிகளின் வடிவத்தில் இருக்கும், அவற்றில் கட்டிடத் தொகுதி வகையின் வெவ்வேறு நிகழ்வுகளை வழங்க முடியும். உதாரணமாக, VQE, மாறுபட்ட குவாண்டம் ஐஜென்சால்வர், இது ஒரு சோதனை அலைவடிவத்தை QuantumCircuit மற்றும் பிறவற்றில் கிளாசிக்கல் ஆப்டிமைசர் வடிவத்தில் எடுக்கிறது.

Let’s take a look at an example to construct a VQE instance. Here TwoLocal is the variational form (trial wavefunction), a parameterized circuit which can be varied, and SLSQP a classical optimizer. These are created as separate instances and passed to VQE when it is constructed. Trying, for example, a different classical optimizer, or variational form is simply a case of creating an instance of the one you want and passing it into VQE.

[1]:
from qiskit.algorithms.optimizers import SLSQP
from qiskit.circuit.library import TwoLocal

num_qubits = 2
ansatz = TwoLocal(num_qubits, "ry", "cz")
optimizer = SLSQP(maxiter=1000)

Let’s draw the ansatz so we can see it’s a QuantumCircuit where θ[0] through θ[7] will be the parameters that are varied as VQE optimizer finds the minimum eigenvalue. We’ll come back to the parameters later in a working example below.

[2]:
ansatz.decompose().draw("mpl", style="iqx")
[2]:
../../_images/tutorials_algorithms_01_algorithms_introduction_4_0.png

But more is needed before we can run the algorithm so let’s get to that next.

ஒரு வழிமுறையை எவ்வாறு இயக்குவது?

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

VQE இல், நாம் எதிர்பார்ப்பு மதிப்புகளை மதிப்பிட வேண்டும், எனவே எடுத்துக்காட்டாக, இயல்புநிலை Qiskit Terra நிறுவலுடன் அனுப்பப்படும் qiskit.primitives.Estimator ஐப் பயன்படுத்தலாம்.

[3]:
from qiskit.primitives import Estimator

estimator = Estimator()

இந்த மதிப்பீட்டாளர் எதிர்பார்ப்பு மதிப்புகளை மதிப்பிடுவதற்கு துல்லியமான, ஸ்டேட்வெக்டர் உருவகப்படுத்துதலைப் பயன்படுத்துகிறார். அதற்குப் பதிலாக நாம் ஷாட் அடிப்படையிலான மற்றும் சத்தமில்லாத சிமுலேட்டர்கள் அல்லது உண்மையான பின்தளங்களையும் பயன்படுத்தலாம். சிமுலேட்டர்கள் பற்றிய கூடுதல் தகவலுக்கு, Qiskit Aer மற்றும் உண்மையான வன்பொருள் Qiskit IBM Runtime.

அனைத்து பொருட்களும் தயாராக இருப்பதால், நாம் இப்போது VQE ஐ நிறுவலாம்:

[4]:
from qiskit.algorithms.minimum_eigensolvers import VQE

vqe = VQE(estimator, ansatz, optimizer)

இப்போது நாம் `compute_mininum_eigenvalue() <https://qiskit.org/documentation/stubs/qiskit.algorithms.minimum_eigensolvers.VQE.compute_minimum_eigenvalue.html#qiskit.algorithms> முறை. பிந்தையது, நேச்சர் மற்றும் ஆப்டிமைசேஷன் போன்ற அப்ளிகேஷன் மாட்யூல்களுக்கான தேர்வுக்கான இடைமுகமாகும், அவை குறிப்பிட்ட வகைக்குள் எந்த அல்காரிதத்துடனும் ஒன்றுக்கொன்று மாற்றாக வேலை செய்ய முடியும்.

ஒரு முழுமையான பணி உதாரணம்

Let’s put what we have learned from above together and create a complete working example. VQE will find the minimum eigenvalue, i.e. minimum energy value of a Hamiltonian operator and hence we need such an operator for VQE to work with. Such an operator is given below. This was originally created by the Nature application module as the Hamiltonian for an H2 molecule at 0.735A interatomic distance. It’s a sum of Pauli terms as below, but for now I am not going to say anything further about it since the goal is to run the algorithm, but further information on operators can be found in other tutorials.

[5]:
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)
])

So let’s run VQE and print the result object it returns.

[6]:
result = vqe.compute_minimum_eigenvalue(H2_op)
print(result)
{   'aux_operators_evaluated': None,
    'cost_function_evals': 102,
    'eigenvalue': -1.857275020719397,
    'optimal_circuit': <qiskit.circuit.library.n_local.two_local.TwoLocal object at 0x7f96da26a470>,
    'optimal_parameters': {   ParameterVectorElement(θ[0]): -2.403507257619715,
                              ParameterVectorElement(θ[5]): 1.7060524493254914,
                              ParameterVectorElement(θ[1]): 3.085467047665086,
                              ParameterVectorElement(θ[2]): -2.1949965223522487,
                              ParameterVectorElement(θ[3]): 4.276089268519914,
                              ParameterVectorElement(θ[4]): -3.098644972035885,
                              ParameterVectorElement(θ[6]): 0.032773583818940334,
                              ParameterVectorElement(θ[7]): 2.8861019033185396},
    'optimal_point': array([-2.40350726,  3.08546705, -2.19499652,  4.27608927, -3.09864497,
        1.70605245,  0.03277358,  2.8861019 ]),
    'optimal_value': -1.857275020719397,
    'optimizer_evals': None,
    'optimizer_result': <qiskit.algorithms.optimizers.optimizer.OptimizerResult object at 0x7f96da2a4d60>,
    'optimizer_time': 0.29071593284606934}

கொடுக்கப்பட்ட H2 மூலக்கூறின் மின்னணு நில நிலை ஆற்றலான \(\approx -1.85727\) இன் குறைந்தபட்ச eigenvalue ஐக் கண்டறியும் வரை, உகப்பாக்கி எடுத்த செலவுச் செயல்பாட்டின் (=ஆற்றல்) மதிப்பீட்டின் எண்ணிக்கையை மேலே உள்ள முடிவிலிருந்து பார்க்கலாம். ansatz இன் உகந்த அளவுருக்கள் குறைந்தபட்ச மதிப்பில் ansatz இல் இருந்த மதிப்புகள் என்பதையும் காணலாம்.

VQE இன் உள்ளே உள்ள பழமையானவற்றைப் புதுப்பிக்கிறது

To close off let’s also change the estimator primitive inside the a VQE. Maybe you’re satisfied with the simulation results and now want to use a shot-based simulator, or run on hardware!

In this example we’re changing to a shot-based estimator, still using Qiskit Terra’s reference primitive. However you could replace the primitive by e.g. Qiskit Aer’s estimator (qiskit_aer.primitives.Estimator) or even a real backend (qiskit_ibm_runtime.Estimator).

சத்தமில்லாத இழப்பு செயல்பாடுகளுக்கு, SPSA ஆப்டிமைசர் பொதுவாக சிறப்பாகச் செயல்படும், எனவே நாங்கள் ஆப்டிமைசரையும் புதுப்பிக்கிறோம். ஷாட் அடிப்படையிலான மற்றும் சத்தமில்லாத உருவகப்படுத்துதல்கள் பற்றிய கூடுதல் விவரங்களுக்கு இரைச்சல் VQE டுடோரியலை பார்க்கவும்.

[7]:
from qiskit.algorithms.optimizers import SPSA

estimator = Estimator(options={"shots": 1000})

vqe.estimator = estimator
vqe.optimizer = SPSA(maxiter=100)
result = vqe.compute_minimum_eigenvalue(operator=H2_op)
print(result)
{   'aux_operators_evaluated': None,
    'cost_function_evals': 200,
    'eigenvalue': -1.8574503552440247,
    'optimal_circuit': <qiskit.circuit.library.n_local.two_local.TwoLocal object at 0x7f96da2f4250>,
    'optimal_parameters': {   ParameterVectorElement(θ[0]): -7.7940259581467375,
                              ParameterVectorElement(θ[5]): 0.28827257835035214,
                              ParameterVectorElement(θ[1]): -1.8091021117029589,
                              ParameterVectorElement(θ[2]): -2.460381278734678,
                              ParameterVectorElement(θ[3]): -7.725013961075425,
                              ParameterVectorElement(θ[4]): -1.3793338621798832,
                              ParameterVectorElement(θ[6]): -2.4148423942537587,
                              ParameterVectorElement(θ[7]): -1.8555574263247812},
    'optimal_point': array([-7.79402596, -1.80910211, -2.46038128, -7.72501396, -1.37933386,
        0.28827258, -2.41484239, -1.85555743]),
    'optimal_value': -1.8574503552440247,
    'optimizer_evals': None,
    'optimizer_result': <qiskit.algorithms.optimizers.optimizer.OptimizerResult object at 0x7f96da26a5f0>,
    'optimizer_time': 0.8142139911651611}

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

இது Qiskit-ல் உள்ள வழிமுறைகளுக்கான இந்த அறிமுகத்தை முடிக்கிறது. இந்த தொடரின் பிற வழிமுறை பயிற்சிகளை பரந்த மற்றும் வழிமுறைகளின் ஆழமான கவரேஜில் பாருங்கள்.

[8]:
import qiskit.tools.jupyter
%qiskit_version_table
%qiskit_copyright

Version Information

Qiskit SoftwareVersion
qiskit-terra0.23.0.dev0+f52bb33
qiskit-aer0.11.1
qiskit-ignis0.7.1
qiskit-ibmq-provider0.19.2
qiskit-nature0.5.0
qiskit-optimization0.5.0
qiskit-machine-learning0.6.0
System information
Python version3.10.4
Python compilerClang 12.0.0
Python buildmain, Mar 31 2022 03:38:35
OSDarwin
CPUs4
Memory (Gb)32.0
Wed Dec 07 11:02:26 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.

[ ]: