নোট
এই পেজটির উৎস tutorials/circuits_advanced/2_operators_overview.ipynb ।
শিডিউলারের ব্যবহার¶
শিডিউলারটি QuantumCircuit
কে একটি পালস Schedule
এ পরিনত করবে যা ব্যবহার করে তা হল মেজারমেন্ট calibrations: নির্দিষ্ট কোনো কিউবিটসমুহের ওপর ক্রিয়াশীলতার একটি উন্নীত পালস লেভেলের মাপকাঠি।
OpenPulse চালু থাকলে সেসব ব্যাকএন্ডে সাধারণত পরিমাপ এবং এর প্রত্যেক বেসিস গেইটের জন্য ক্যালিব্রেশন সংজ্ঞায়িত থাকে। ব্যবহারকারী ইচ্ছা করলে সে ক্যালিব্রেশন সংজ্ঞায়িত বা পরিবর্তন করতে পারে।
প্রাথমিক ব্যবহার¶
প্রথমে আপনি যেভাবে কোয়ান্টাম সার্কিট নির্মাণ করতেন সেভাবে সাধারণ একটা সার্কিট নির্মাণ করুন। উদাহরণের জন্য আমরা একটা সিম্পল বেল স্টেট বানাবো।
[1]:
from qiskit import QuantumCircuit
circ = QuantumCircuit(2, 2)
circ.h(0)
circ.cx(0, 1)
circ.measure([0, 1], [0, 1])
circ.draw("mpl")
[1]:

We’ll use the mocked backend, FakeHanoi
, to demonstrate how to use the scheduler. It contains default calibrations for measurement and for its basis gates. The Hadamard operation is not one of those basis gates, so we use the transpiler to compile our input circuit to an equivalent circuit in terms of the basis gates of the device.
[2]:
from qiskit import transpile, schedule as build_schedule
from qiskit.providers.fake_provider import FakeHanoi
backend = FakeHanoi()
transpiled_circ = transpile(circ, backend) # Undefined Hadamard is replaced by U1
schedule = build_schedule(transpiled_circ, backend)
Let’s see how our schedule schedule
built from the circuit transpiled_circ
looks.
[3]:
schedule.draw()
[3]:

That covers the basics! We used the transpiler to rewrite the circuit in terms of the basis gates, and then used the backend’s default calibrations to schedule the transpiled circuit. Next we will go through scheduling with calibrations we will build ourselves.
কাস্টম গেইট দ্বারা সময়সূচী বানানো¶
যদি ইনপুট বর্তনীতে (সার্কিট) আগে থেকে ক্রমাঙ্কন (ক্যালিব্রেশন) সংজ্ঞায়িত থাকে তাহলে বর্তনী (সার্কিট) সূচিত করার সময় ওই ক্রমাঙ্কন (ক্যালিব্রেশন) গুলো ব্যবহৃত হবে।
[4]:
from qiskit import pulse
with pulse.build() as h_q0:
pulse.play(pulse.library.Gaussian(duration=256, amp=0.2, sigma=50, name='custom'),
pulse.DriveChannel(0))
circ.add_calibration('h', [0], h_q0)
schedule = build_schedule(circ, backend)
schedule.draw()
[4]:

লক্ষ্য করো, D0
হ্যাডামার্ড গেটে প্রাথমিক তড়িৎস্পন্দনটি আমাদের কাস্টম পালস দিয়ে বানানো হয়েছে।
শিডিউলারের ম্যাথডসমুহ¶
শিডিউলার অসংখ্য পদ্ধতি ব্যাবহার করতে পারে। তবে প্রাথমিকভাবে, এটি as late as possible (ALAP) পদ্ধতি ব্যাবহার করে। এছাড়া আরেকটি পদ্ধতি হল as soon as possible বা (ASAP)। দুই পদ্ধতিতেই আউটপট শিডিউল হল নুন্যতম হয়: ইনপুট সার্কিটের বেশি সময় ধরে অপারেশনের ক্ষেত্রে প্রত্যেকটি অপারেশনের শুরুর সময় পূর্বে চলা অপারেশোনের শেষের সময়ের সমান। পদ্ধতিগুলো মূলত বেশি সময়ের অপারেশনের বাইরে কিভাবে সার্কিটগুলোকে শিডিউল করতে হবে তা বোঝায়।
উদাহরণের মাধ্যমে এটা সহজ করা হল:
[5]:
circ = QuantumCircuit(2, 2)
circ.x(0)
circ.x(0)
circ.x(1)
circ.measure([0, 1], [0, 1])
circ.draw("mpl")
[5]:

আমাদের পরিবর্তিত ব্যাকেন্ডের জন্য, প্রত্যেক \(X\) গেটের অপারেশনগুলোর সময় একই (duration = 160 dt
) । এবার শিডিউলকে সরবনিম্ন বা নুন্যতম হতে হলে কিউবিট 0 এর ওপর দুটি \(X\) অপারেশন একের পর এক পর্যায়ক্রমে হবে এবং মেজারমেন্ট পালস তাৎক্ষনিকভাবেই ওই পালসগুলর সময় সেকেন্ডে খেয়াল করা শুরু করেব।
এএলএপি কম সীমাবদ্ধ ক্রিয়াকলাপ (অপারেশন) গুলো একদম সর্বশেষ সময় নির্বাচন করে, যাতে কিউবিট ১ এ \(X\) যুক্তিবর্তনী (গেইট) এবং কিউবিট ০ এর দ্বিতীয় \(X\) যুক্তিবর্তনী (গেইট) সময়ের সাথে সুসংহত থাকে।
[6]:
schedule = build_schedule(circ, backend, method="as_late_as_possible")
schedule.filter(channels=[pulse.DriveChannel(0), pulse.DriveChannel(1)]).draw()
[6]:

অন্যদিকে, নাম অনুযায়ী ASAP এর রিসোর্স ফাকা হওয়ার সাথে সাথে অপারেশন সিডিউল করবে। এইভাবেই তাল মিলিয়ে কিউবিট 0 এর ওপর প্রথমে \(X\) হয়ে তারপর কিউবিট 1 এর ওপর \(X\) গেট time=0
সময়ে শিডিউল হবে।
[7]:
schedule = build_schedule(circ, backend, method="as_soon_as_possible")
schedule.filter(channels=[pulse.DriveChannel(0), pulse.DriveChannel(1)]).draw()
[7]:

ALAP হল মৌলিক কারন এটা কিইউবিটগুলোকে যথাসম্ভব স্থায়ী হতে সাহায্য করে। এক্ষেত্রে, ALAP এবং ASAP এর মধ্যে তুলনা উপেক্ষণীয় হতে পারে, কিন্তু কেবলমাত্র ALAP তে কিউবিট 0 এর মেজারমেন্টের আগে উত্তেজিত শক্তিস্তর হতে বিচ্যুত হয়ে আসার কোন সময় থাকেনা।
[8]:
import qiskit.tools.jupyter
%qiskit_version_table
%qiskit_copyright
Version Information
Qiskit Software | Version |
---|---|
qiskit-terra | 0.20.2 |
qiskit-aer | 0.10.4 |
qiskit-ignis | 0.7.1 |
qiskit-ibmq-provider | 0.19.1 |
qiskit | 0.36.2 |
System information | |
Python version | 3.9.9 |
Python compiler | GCC 11.1.0 |
Python build | main, Dec 29 2021 22:19:36 |
OS | Linux |
CPUs | 32 |
Memory (Gb) | 125.64827728271484 |
Wed Sep 21 09:33:41 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.