নোট
এই পৃষ্ঠাটি tutorials/circuits_advanced/05_pulse_gates.ipynb থেকে উৎপন্ন হয়েছে।
পাউলি যুক্তিবর্তনী (গেইট)¶
অধিকাংশ কোয়ান্টাম সমাধান পদ্ধতি শুধু বর্তনী (সার্কিট) ক্রিয়াকলাপ (অপারেশন) দিয়ে বোঝানো যায়। আমাদের প্রোগ্রামের নিম্নস্তর রূপের ওপর আরো নিয়ন্ত্রণ পেতে হলে আমরা তড়িৎস্পন্দন বা পালস যুক্তিবর্তনী (গেইট) ব্যবহার করতে পারি। বর্তনী (সার্কিট) শুধু বেসিস বা ভিত্তি যুক্তিবর্তনী (গেইট) দিয়ে চালাতে হবে এমন নিষেধাজ্ঞা তড়িৎস্পন্দন বা পালস যুক্তিবর্তনী (গেইট) তুলে দেয় এবং যেকোনো বেসিস বা ভিত্তি যুক্তিবর্তনী (গেইট) এর সাধারণ রূপায়নকে পরিবর্তন করতে দেয়।
তড়িৎস্পন্দন বা পালস যুক্তিবর্তনী (গেইট) এর দ্বারা একটা যুক্তিবর্তনীকে (লজিক গেট) (যেমন, X
) Qiskit তড়িৎস্পন্দন বা পালস প্রোগ্রামের (যাকে Schedule
বলে) উপর চিত্রিত করা যায়। এই ম্যাপিংকে (চিত্রায়ন) ক্রমাঙ্কন (ক্যালিব্রেশন) বলে। একটা উচ্চ ক্রমাঙ্কন (ক্যালিব্রেশন) হলো যেটা উৎস ক্রিয়াকলাপকে (অপারেশন) বিশ্বস্তভাবে বানায় (যেমন X
যুক্তিবর্তনী (গেইট) ক্রমাঙ্কন (ক্যালিব্রেশন) \(|0\rangle\) -কে \(|1\rangle\) -তে পরিবর্তন করে)।
একটা সময়সূচীতে বর্ণনা করা থাকে কখন কোন ইনপুট চ্যানেলে কিভাবে কোন ইনপুট সংকেত দেওয়া হবে। প্রত্যেক কিউবিটের জন্য একাধিক চ্যানেল থাকে, যেমন ড্রাইভ এবং পরিমাপ (মেসার). এই উপস্থাপনটি আরো শক্তিশালী এবং এর জন্য যন্ত্রের অভ্যন্তরীন ক্রিয়াকলাপের গভীর জ্ঞান প্রয়োজন।
It’s important to note that Pulse programs operate on physical qubits. A drive pulse on qubit \(a\) will not enact the same logical operation on the state of qubit \(b\) – in other words, gate calibrations are not interchangeable across qubits. This is in contrast to the circuit level, where an X
gate is defined independent of its qubit operand.
এই পৃষ্ঠা থেকে কিভাবে আপনার বর্তনীতে (সার্কিট) ক্রমাঙ্কন (ক্যালিব্রেশন) গঠন করতে হয় তা দেখতে পারেন।
Note: Not all providers support pulse gates.
আপনার বর্তনী (সার্কিট) তৈরি করুন¶
Let’s start with a very simple example, a Bell state circuit.
[1]:
from qiskit import QuantumCircuit
circ = QuantumCircuit(2, 2)
circ.h(0)
circ.cx(0, 1)
circ.measure(0, 0)
circ.measure(1, 1)
circ.draw('mpl')
[1]:

আপনার ক্রমাঙ্কন (ক্যালিব্রেশন) গঠন করুন¶
Now that we have our circuit, let’s define a calibration for the Hadamard gate on qubit 0.
কার্যকালীন, তড়িৎস্পন্দনের (পালস) আকার ও প্যারামিটারগুলো বিভিন্ন রবি গবেষণার মাধ্যমে স্থির করা হয়। বিশদে জানতে Qiskit Textbook দেখো। এই প্রদর্শনীর জন্য আমাদের হ্যাডম্যার্ড একটা গসীয়ান তড়িৎস্পন্দন (পালস) হবে। আমরা ০ কিউবিটের ড্রাইভ চ্যানেলে তড়িৎস্পন্দনটি (পালস) চালাবো।
Don’t worry too much about the details of building the calibration itself; you can learn all about this on the following page: building pulse schedules.
[2]:
from qiskit import pulse
from qiskit.pulse.library import Gaussian
from qiskit.providers.fake_provider import FakeValencia
backend = FakeValencia()
with pulse.build(backend, name='hadamard') as h_q0:
pulse.play(Gaussian(duration=128, amp=0.1, sigma=16), pulse.drive_channel(0))
Let’s draw the new schedule to see what we’ve built.
[3]:
h_q0.draw()
[3]:

বর্তনীর (সার্কিট) সাথে ক্রমাঙ্কন (ক্যালিব্রেশন) এর সংযোগস্থাপন¶
এখন শুধু নিবন্ধীকরণ সম্পুর্ণ করা বাকি। বর্তনী (সার্কিট) পদ্ধতি add_calibration
ম্যাপিং (চিত্রায়ন) সম্পূর্ণ করার জন্য, যুক্তিবর্তনীর (গেইট) বিবরণ এবং সময়সূচীর তথ্যসূত্র (রেফারেন্স) প্রয়োজন:
QuantumCircuit.add_calibration(gate, qubits, schedule, parameters)
The gate
can either be a circuit.Gate
object or the name of the gate. Usually, you’ll need a different schedule for each unique set of qubits
and parameters
. Since the Hadamard gate doesn’t have any parameters, we don’t have to supply any.
[4]:
circ.add_calibration('h', [0], h_q0)
মনে রেখো, ট্রান্সপাইলার তোমার করা ক্রমাঙ্কন (ক্যালিব্রেশন) গুলো কাজে লাগায়। এটাকে সাধারণ ভাবেই ব্যবহার করবে। আমাদের উদাহরণটা অনুকূলিত করা ট্রান্সপাইলারের জন্য খুবই সহজ। তাই ফলাফলে কোনো পরিবর্তন হয়নি।
[5]:
from qiskit import transpile
from qiskit.providers.fake_provider import FakeHanoi
backend = FakeHanoi()
circ = transpile(circ, backend)
print(backend.configuration().basis_gates)
circ.draw('mpl', idle_wires=False)
['id', 'rz', 'sx', 'x', 'cx', 'reset']
[5]:

Notice that h
is not a basis gate for the mock backend FakeHanoi
. Since we have added a calibration for it, the transpiler will treat our gate as a basis gate; but only on the qubits for which it was defined. A Hadamard applied to a different qubit would be unrolled to the basis gates.
That’s it!
বিশেষায়িত (কাস্টম) যুক্তিবর্তনী (গেইট)¶
We’ll briefly show the same process for nonstandard, completely custom gates. This demonstration includes a gate with parameters.
[6]:
from qiskit import QuantumCircuit
from qiskit.circuit import Gate
circ = QuantumCircuit(1, 1)
custom_gate = Gate('my_custom_gate', 1, [3.14, 1])
# 3.14 is an arbitrary parameter for demonstration
circ.append(custom_gate, [0])
circ.measure(0, 0)
circ.draw('mpl')
[6]:

[7]:
with pulse.build(backend, name='custom') as my_schedule:
pulse.play(Gaussian(duration=64, amp=0.2, sigma=8), pulse.drive_channel(0))
circ.add_calibration('my_custom_gate', [0], my_schedule, [3.14, 1])
# Alternatively: circ.add_calibration(custom_gate, [0], my_schedule)
ক্রমাঙ্কন (ক্যালিব্রেশন) করার জন্য যদি আমরা Gate
-এর দৃষ্টান্ত (ইনস্ট্যান্স) চল রাশি custom_gate
ব্যবহার করি, পরামিতির (প্যারামিটার) মানগুলো সেখান থেকে নেওয়া হবে। মনে রাখতে হবে পরামিতি (প্যারামিটার) এর ক্রম অর্থপূর্ণ।
[8]:
circ = transpile(circ, backend)
circ.draw('mpl', idle_wires=False)
[8]:

Normally, if we tried to transpile our circ
, we would get an error. There was no functional definition provided for "my_custom_gate"
, so the transpiler can’t unroll it to the basis gate set of the target device. We can show this by trying to add "my_custom_gate"
to another qubit which hasn’t been calibrated.
[9]:
circ = QuantumCircuit(2, 2)
circ.append(custom_gate, [1])
from qiskit import QiskitError
try:
circ = transpile(circ, backend)
except QiskitError as e:
print(e)
"Cannot unroll the circuit to the given basis, ['id', 'rz', 'sx', 'x', 'cx', 'reset']. Instruction my_custom_gate not found in equivalence library and no rule found to expand."
[10]:
import qiskit.tools.jupyter
%qiskit_version_table
%qiskit_copyright
Version Information
Qiskit Software | Version |
---|---|
qiskit-terra | 0.21.2 |
qiskit-aer | 0.10.4 |
qiskit-ibmq-provider | 0.19.2 |
qiskit | 0.37.2 |
System information | |
Python version | 3.10.7 |
Python compiler | GCC 12.2.0 |
Python build | main, Sep 6 2022 21:22:27 |
OS | Linux |
CPUs | 32 |
Memory (Gb) | 125.64828109741211 |
Mon Sep 12 15:28:25 2022 EDT |
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.