<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Inderpal Suthar on Medium]]></title>
        <description><![CDATA[Stories by Inderpal Suthar on Medium]]></description>
        <link>https://medium.com/@inderpalsuthar5911?source=rss-35373755701a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by Inderpal Suthar on Medium</title>
            <link>https://medium.com/@inderpalsuthar5911?source=rss-35373755701a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 20:53:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@inderpalsuthar5911/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[VQE_Final
#quantum30
#day-31]]></title>
            <link>https://medium.com/@inderpalsuthar5911/vqe-final-quantum30-day-31-e4a448bd863c?source=rss-35373755701a------2</link>
            <guid isPermaLink="false">https://medium.com/p/e4a448bd863c</guid>
            <category><![CDATA[vqe]]></category>
            <dc:creator><![CDATA[Inderpal Suthar]]></dc:creator>
            <pubDate>Tue, 31 Oct 2023 12:19:59 GMT</pubDate>
            <atom:updated>2023-10-31T12:23:11.497Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>VQE_Final</strong></p><p>#quantum30<br>#day-31</p><p>In previous 2-days we try to understand the mathematics and logic of VQE. We also saw documentation of qiskit on VQE</p><p>Useful video to understand VQE coding part is from Qiskit Season2 playlist.<br>Link:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FZ-A6G0WVI9w%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DZ-A6G0WVI9w&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FZ-A6G0WVI9w%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/5119cf34a5a28dc42aa54f38193bf889/href">https://medium.com/media/5119cf34a5a28dc42aa54f38193bf889/href</a></iframe><p>Another one for measurement part is :</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FrW1SC95oNaw%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DrW1SC95oNaw&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FrW1SC95oNaw%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/b29f2c08b3e428c6034fb39c44a696b2/href">https://medium.com/media/b29f2c08b3e428c6034fb39c44a696b2/href</a></iframe><p>These are enough to understand VQE proper.</p><p><a href="https://medium.com/u/1b400b39fb87">QuantumComputingIndia</a></p><p>#quantum30<br>#day-31</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e4a448bd863c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[VQE]]></title>
            <link>https://medium.com/@inderpalsuthar5911/vqe-51e063d5ef53?source=rss-35373755701a------2</link>
            <guid isPermaLink="false">https://medium.com/p/51e063d5ef53</guid>
            <category><![CDATA[quantum-computing]]></category>
            <category><![CDATA[vqe]]></category>
            <category><![CDATA[qiskit]]></category>
            <dc:creator><![CDATA[Inderpal Suthar]]></dc:creator>
            <pubDate>Sun, 29 Oct 2023 18:15:37 GMT</pubDate>
            <atom:updated>2023-10-29T18:15:37.615Z</atom:updated>
            <content:encoded><![CDATA[<p>#quantum30<br>#day-29</p><p>The Variational Quantum Eigensolver (VQE) is a prominent quantum algorithm designed to estimate the ground-state energy of quantum systems. This algorithm plays a critical role in the field of quantum computing because it addresses problems that are practically intractable for classical computers, particularly in simulating the behavior of molecules and materials at the quantum level.</p><p>VQE combines classical and quantum computation in a hybrid approach. It leverages a quantum computer to perform part of the computation, specifically, evaluating the expectation value of a Hamiltonian operator representing the system of interest. To do this, VQE uses a quantum variational circuit with tunable parameters, which effectively encodes a quantum state. Classical optimization algorithms then adjust these parameters to minimize the energy expectation value, which converges to the ground-state energy of the system.</p><p>VQE has garnered significant attention in quantum chemistry and material science due to its potential for solving complex problems, such as molecular structure prediction and materials optimization. However, it’s important to note that VQE is sensitive to errors and noise in current quantum hardware, and its true power may be fully realized as quantum devices continue to improve. Researchers are actively working to enhance VQE’s performance and applicability for real-world problems, making it a promising avenue for quantum computation.</p><h3>Ansatz and initial trial function</h3><p>The choice of ansatz state depends on the system of interest. In gate based quantum computing, the ansatz is given by a parametrized qc, whose parameters can be updated after each run. The ansatz has to be adaptable enough to not miss the desired state. A common method to obtain a valid ansatz is given by the unitary coupled cluster (UCC) framework and its extensions.</p><p>If the ansatz is not chosen adequately the procedure may halt at suboptimal parameters that do not correspond to a minima. In this situation, the algorithm is said to have reached a ‘barren plateau’.</p><p>The ansatz can be set to an initial trial function to start the algorithm. For example, for a molecular system, one can use the Hartree Fock Method to provide a starting state that is close to the real ground state.</p><h3>Variational method and optimization</h3><p>Given a parametrized ansatz for the ground state eigenstate, with parameters that can be modified, one is sure to find the parametrized state that is closest to the ground state based on the variational method of quantum mechanics . Using classical algorithms in a digital computer, the parameters of the ansatz can be optimized. For this minimization, it is necessary to find the minima of a multivariable function. Classical optimizers using gradient descent can be used for this purpose.</p><p>By running the circuit many times and constantly updating the parameters to find the global minima of the expectation value of the desired observable, one can approach the ground state of the given system and store it in a quantum processor as a series of quantum gate instructions.<br>Next day we will try to follow these instructions on qiskit .</p><p><a href="https://medium.com/u/1b400b39fb87">QuantumComputingIndia</a></p><p>#quantum30<br>#day-29</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=51e063d5ef53" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bernstein Vazirani Algorithm]]></title>
            <link>https://medium.com/@inderpalsuthar5911/bernstein-vazirani-algorithm-712a08d5c0f1?source=rss-35373755701a------2</link>
            <guid isPermaLink="false">https://medium.com/p/712a08d5c0f1</guid>
            <category><![CDATA[bernstein-vazirani]]></category>
            <category><![CDATA[qiskit]]></category>
            <category><![CDATA[quantum30]]></category>
            <dc:creator><![CDATA[Inderpal Suthar]]></dc:creator>
            <pubDate>Fri, 27 Oct 2023 04:45:56 GMT</pubDate>
            <atom:updated>2023-10-27T04:45:56.964Z</atom:updated>
            <content:encoded><![CDATA[<p>Bernstein Vazirani Algorithm</p><p>#quantum30</p><p>#day-27</p><p>The Bernstein-Vazirani algorithm is a quantum algorithm that solves a specific problem faster than classical algorithms. It’s used to determine a hidden binary string by querying an oracle function that computes the inner product of the hidden string and an input string.To implement the Bernstein-Vazirani algorithm using Qiskit (a Python framework for working with quantum computers), you’ll need to create a quantum circuit. Here’s a basic outline of the steps:</p><p>(1)Import Qiskit and necessary libraries.</p><p>(2)Define the quantum and classical registers.</p><p>(3)Create a quantum circuit.</p><p>(4)Apply Hadamard gates to all qubits to create a superposition.</p><p>(5)Implement the oracle function (representing the hidden string) by applying controlled-X (CNOT) gates based on the hidden string.</p><p>(6)Apply Hadamard gates again.</p><p>(7)Measure the qubits to obtain the result.</p><pre>from qiskit import QuantumCircuit, Aer, transpile, assemble<br><br># Define the hidden string<br>hidden_string = &#39;1010101&#39;<br><br># Step 2: Define quantum and classical registers<br>n = len(hidden_string)<br>quantum_register = QuantumRegister(n, name=&#39;q&#39;)<br>classical_register = ClassicalRegister(n, name=&#39;c&#39;)<br>circuit = QuantumCircuit(quantum_register, classical_register)<br><br># Step 4: Apply Hadamard gates to all qubits<br>circuit.h(quantum_register)<br><br># Step 5: Implement the oracle function<br>for i in range(n):<br>    if hidden_string[i] == &#39;1&#39;:<br>        circuit.cx(quantum_register[i], classical_register[i])<br><br># Step 6: Apply Hadamard gates again<br>circuit.h(quantum_register)<br><br># Step 7: Measure the qubits<br>circuit.measure(quantum_register, classical_register)<br><br># Simulate the circuit<br>simulator = Aer.get_backend(&#39;qasm_simulator&#39;)<br>compiled_circuit = transpile(circuit, simulator)<br>job = assemble(compiled_circuit, shots=1)<br>result = simulator.run(job).result()<br><br># Print the result<br>counts = result.get_counts()<br>print(counts)<br></pre><p>Thanks for reading my article.</p><p><a href="https://medium.com/u/1b400b39fb87">QuantumComputingIndia</a></p><p>#quantum30</p><p>#day-27</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=712a08d5c0f1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hadamard Gate]]></title>
            <link>https://medium.com/@inderpalsuthar5911/hadamard-gate-b7a438beee76?source=rss-35373755701a------2</link>
            <guid isPermaLink="false">https://medium.com/p/b7a438beee76</guid>
            <dc:creator><![CDATA[Inderpal Suthar]]></dc:creator>
            <pubDate>Wed, 25 Oct 2023 13:58:00 GMT</pubDate>
            <atom:updated>2023-10-25T13:58:00.333Z</atom:updated>
            <content:encoded><![CDATA[<p>Hadamard Gate</p><p>#quantum30</p><p>#day-25</p><p>The Hadamard gate (H) is a fundamental quantum gate used in quantum computing to create superposition states. Let&#39;s break down the Hadamard gate step by step:</p><p>1. **Initialize the Quantum State**:<br> - At the beginning of the operation, the qubit is typically in one of the basis states, either |0⟩ (ground state) or |1⟩ (excited state).</p><p>2. **Apply the Hadamard Gate**:<br> - The Hadamard gate (H) is applied to the qubit. Mathematically, it is represented as follows:<br> H = 1/√2 * |0⟩⟨0| + 1/√2 * |0⟩⟨1| + 1/√2 * |1⟩⟨0| - 1/√2 * |1⟩⟨1|<br> - Applying the Hadamard gate transforms the qubit&#39;s state as follows:<br> H|0⟩ = 1/√2 * |0⟩ + 1/√2 * |1⟩<br> H|1⟩ = 1/√2 * |0⟩ - 1/√2 * |1⟩</p><p>3. **Resulting Superposition State**:<br> - After the Hadamard gate is applied, the qubit is in a superposition state. It&#39;s no longer in a definite |0⟩ or |1⟩ state, but rather in a probabilistic combination of both.</p><p>4. **Measurement**:<br> - When you measure the qubit in this superposition state, there&#39;s a 50% chance of obtaining |0⟩ and a 50% chance of obtaining |1⟩. The probabilities are |α|^2 = (1/√2)^2 = 1/2 for |0⟩ and |β|^2 = (1/√2)^2 = 1/2 for |1⟩.</p><p>In essence, the Hadamard gate creates a balanced superposition of the basis states |0⟩ and |1⟩. It&#39;s a crucial operation in quantum algorithms, as it allows quantum computers to explore multiple possibilities in parallel, which can lead to speedups in certain computational tasks.</p><p>Certainly! Here&#39;s a Python code example that demonstrates the application of the Hadamard gate using Qiskit:</p><pre><br>from qiskit import QuantumCircuit, Aer, transpile<br>from qiskit.visualization import plot_bloch_multivector, plot_histogram<br><br># Create a quantum circuit with one qubit<br>circuit = QuantumCircuit(1)<br><br># Apply the Hadamard gate to the qubit<br>circuit.h(0)<br><br># Visualize the circuit<br>print(circuit)<br><br># Simulate the circuit<br>simulator = Aer.get_backend(&#39;statevector_simulator&#39;)<br>compiled_circuit = transpile(circuit, simulator)<br>result = simulator.run(compiled_circuit).result()<br><br># Get the statevector<br>statevector = result.get_statevector()<br>print(&quot;Statevector: &quot;, statevector)<br><br># Plot the Bloch vector of the qubit<br>plot_bloch_multivector(statevector)<br></pre><p>Thanks for reading my article.</p><p><a href="https://medium.com/u/1b400b39fb87">QuantumComputingIndia</a></p><p>#quantum30</p><p>#day-25</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b7a438beee76" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Qiskit]]></title>
            <link>https://medium.com/@inderpalsuthar5911/qiskit-b00c2601ccf4?source=rss-35373755701a------2</link>
            <guid isPermaLink="false">https://medium.com/p/b00c2601ccf4</guid>
            <category><![CDATA[qiskit]]></category>
            <category><![CDATA[ibm-developer]]></category>
            <dc:creator><![CDATA[Inderpal Suthar]]></dc:creator>
            <pubDate>Mon, 23 Oct 2023 16:14:25 GMT</pubDate>
            <atom:updated>2023-10-23T16:14:25.747Z</atom:updated>
            <content:encoded><![CDATA[<p>#quantum30<br>#day-23</p><p>Qiskit is an open-source software development framework for quantum computing. It is developed and maintained by IBM and is designed to work with IBM’s quantum computers, as well as various simulators. Qiskit provides tools for creating, compiling, and running quantum programs, known as quantum circuits. Here are some key aspects of Qiskit:</p><p><strong>1. **Quantum Circuits:**</strong> Qiskit allows you to define quantum circuits using a high-level programming language, typically Python. You can specify gates, qubits, and operations to create quantum programs. Qiskit supports a wide range of quantum gates, including basic quantum gates (e.g., X, Y, Z), entanglement operations, and custom gates.</p><p><strong>2. **Quantum Simulators:** </strong>Qiskit includes quantum simulators that allow you to simulate the behavior of quantum circuits on classical computers. This is useful for testing and debugging quantum algorithms before running them on real quantum hardware. The simulators vary in terms of precision and capabilities.</p><p><strong>3. **Quantum Hardware:**</strong> Qiskit is designed to work with IBM’s cloud-based quantum computers, such as IBM Q Experience. You can use Qiskit to access and run quantum programs on real quantum hardware provided by IBM. This provides an opportunity to experiment with real quantum processors, although they may have limitations in terms of qubit count and error rates.</p><p><strong>4. **Quantum Algorithms:*</strong>* Qiskit includes tools for implementing and running quantum algorithms, such as Grover’s search algorithm and Shor’s factoring algorithm. These algorithms showcase the potential of quantum computing in solving specific problems more efficiently than classical computers.</p><p><strong>5. **Aer:**</strong> Qiskit Aer is a component of Qiskit that provides high-performance quantum simulators for accurate simulation of quantum circuits. It includes state vector simulators, unitary simulators, and more.</p><p><strong>6. **Qiskit Aqua:**</strong> Qiskit Aqua is a domain-specific library in Qiskit for quantum applications in fields like finance, optimization, machine learning, and chemistry. It provides specialized tools and algorithms for <strong>solving problems in these domains.</strong></p><p><strong>7. **Qiskit Terra:**</strong> This is the core component of Qiskit that provides the foundational elements for working with quantum circuits, simulators, and quantum hardware.</p><p><strong>8. **Qiskit Ignis:**</strong> Qiskit Ignis is focused on error mitigation and characterization in quantum computing. It provides tools to study and address the noise and errors that can occur in quantum circuits.</p><p>Qiskit is continuously evolving, and new features and improvements are regularly added. It’s a valuable resource for both beginners and experienced researchers or developers interested in quantum computing. You can find Qiskit’s documentation and tutorials on the official Qiskit website, and it’s usually accompanied by a growing community and support from IBM.</p><p>First quantum circuit using qiskit :</p><pre>from qiskit import QuantumCircuit, Aer, execute<br><br># Create a quantum circuit with 2 qubits<br>qc = QuantumCircuit(2)<br><br># Apply NOT gate (X-gate) on the first qubit (q0)<br>qc.x(0)<br><br># Apply a CNOT gate (controlled-X gate) with q0 as control and q1 as target<br>qc.cx(0, 1)<br><br># Measure the second qubit (q1)<br>qc.measure(1, 1)<br><br># Simulate the quantum circuit<br>simulator = Aer.get_backend(&#39;qasm_simulator&#39;)<br>job = execute(qc, simulator, shots=1024)<br>result = job.result()<br>counts = result.get_counts()<br><br>print(&quot;Measurement results:&quot;, counts)</pre><p>Thanks for reading my article .</p><p><a href="https://medium.com/u/1b400b39fb87">QuantumComputingIndia</a></p><p>#quantum30</p><p>#day-30</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b00c2601ccf4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Qiskit,DWave Ocean,Cirq,C#]]></title>
            <link>https://medium.com/@inderpalsuthar5911/qiskit-dwave-ocean-cirq-c-a6969b2d9fc3?source=rss-35373755701a------2</link>
            <guid isPermaLink="false">https://medium.com/p/a6969b2d9fc3</guid>
            <category><![CDATA[qiskit]]></category>
            <category><![CDATA[c]]></category>
            <category><![CDATA[cirq]]></category>
            <dc:creator><![CDATA[Inderpal Suthar]]></dc:creator>
            <pubDate>Sun, 22 Oct 2023 13:44:34 GMT</pubDate>
            <atom:updated>2023-10-22T13:44:34.527Z</atom:updated>
            <content:encoded><![CDATA[<p>Qiskit,DWave Ocean,Cirq,C#</p><p>#quantum30</p><p>#day-22</p><p>Comparing Qiskit, D-Wave Ocean, Cirq, and C#:</p><p><strong>1. Qiskit:</strong><br> - Qiskit is an open-source quantum computing framework primarily designed for gate-model quantum computing.<br> - It&#39;s written in Python and provides tools for quantum circuit design, quantum algorithm development, and access to various quantum hardware.<br> - Qiskit is a high-level framework suitable for quantum software development and research in the context of gate-model quantum computers.</p><p><strong>2. D-Wave Ocean:</strong><br> - D-Wave Ocean is a collection of tools and libraries developed by D-Wave Systems for quantum annealing, which is a distinct approach to quantum computing.<br> - It&#39;s designed for solving optimization problems and is mainly used with D-Wave&#39;s quantum annealers.<br> - D-Wave Ocean is tailored for hybrid classical-quantum solvers and problem formulation specific to quantum annealing.</p><p><strong>3. Cirq:</strong><br> - Cirq is an open-source quantum computing framework developed by Google, primarily for gate-model quantum computing.<br> - It offers low-level control over quantum circuits and is suitable for researchers who need fine-grained control over quantum algorithms.<br> - Cirq is written in Python and focuses on quantum circuit operations and algorithms.</p><p><strong>4. C#:</strong><br> - C# is a general-purpose, statically typed programming language developed by Microsoft.<br> - It is not a quantum computing framework like the others but can be used to create quantum software through libraries and extensions.<br> - For quantum computing in C#, you can use Microsoft Quantum Development Kit, which integrates with Visual Studio and Q# (Quantum Language).</p><p>Your choice between these options depends on your specific quantum computing needs and your programming language preferences. If you want to work with gate-model quantum computing in Python, Qiskit and Cirq are suitable. If you&#39;re interested in quantum annealing, D-Wave Ocean is designed for that purpose. If you prefer C# and want to explore quantum computing, you can consider the Microsoft Quantum Development Kit.</p><p><a href="https://medium.com/u/1b400b39fb87">QuantumComputingIndia</a></p><p>#quantum30</p><p>#day-22</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a6969b2d9fc3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DWave’s Mode or Aspects]]></title>
            <link>https://medium.com/@inderpalsuthar5911/dwaves-mode-or-aspects-9bac9947ae1f?source=rss-35373755701a------2</link>
            <guid isPermaLink="false">https://medium.com/p/9bac9947ae1f</guid>
            <category><![CDATA[quantum-computing]]></category>
            <category><![CDATA[aspectsofentreneurship]]></category>
            <category><![CDATA[quantum-computing-india]]></category>
            <category><![CDATA[aspects-of]]></category>
            <dc:creator><![CDATA[Inderpal Suthar]]></dc:creator>
            <pubDate>Thu, 19 Oct 2023 17:11:09 GMT</pubDate>
            <atom:updated>2023-10-19T17:12:40.565Z</atom:updated>
            <content:encoded><![CDATA[<p>#quantum30</p><p>#day-19</p><p><strong>D-Wave is having two modes or aspects</strong>: one catering to developers and the other focused on serving business needs. This distinction helps highlight how D-Wave offers resources and solutions for both those interested in quantum development and those seeking practical applications for their businesses.</p><p><strong>For Business:</strong><br>Enterprises today are harnessing the capabilities of D-Wave’s quantum technology to address practical challenges in their operations. This cutting-edge technology is delivering tangible business value by solving complex optimization problems. These problems can range from logistics and supply chain management to financial modeling and beyond. By using D-Wave’s quantum computers, companies can significantly enhance their efficiency, reduce operational costs, and make more informed decisions. This technology is readily available to help businesses tackle the complexities of the modern world.</p><p><strong>For Developers:</strong><br>Developers looking to explore the potential of quantum computing can access D-Wave’s quantum resources through Leap™, the quantum cloud service. This platform offers developers free and immediate access to some of the most powerful quantum computers in the world. With Leap, developers can tap into both quantum and classical computing resources, creating a bridge between the two worlds. They can learn, experiment, and build quantum applications in real-time. This means that developers can start exploring the possibilities of quantum computing without the need for extensive physical hardware or infrastructure, making it more accessible and convenient for them to dive into this cutting-edge field.</p><p>We have already go through some part of technical education.</p><p>Now we are seeing one case study for business model.</p><p>It is also available on Dwave’s official website.</p><p>Drive 🔗</p><p>https://drive.google.com/file/d/191fLvk-iieQrIN5ynlNfdJhci9s79yiA/view?usp=drivesdk</p><p>Ok that’s it for today.</p><p><a href="https://medium.com/u/1b400b39fb87">QuantumComputingIndia</a></p><p>#quantum30</p><p>#day-19</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9bac9947ae1f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Circuit Equivalence (part-2)]]></title>
            <link>https://medium.com/@inderpalsuthar5911/circuit-equivalence-part-2-fc055edda388?source=rss-35373755701a------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc055edda388</guid>
            <category><![CDATA[quantum-annealing]]></category>
            <category><![CDATA[quantum-computing]]></category>
            <category><![CDATA[quantum-mechanics]]></category>
            <category><![CDATA[circuit-design]]></category>
            <category><![CDATA[d-wave-systems]]></category>
            <dc:creator><![CDATA[Inderpal Suthar]]></dc:creator>
            <pubDate>Wed, 18 Oct 2023 17:34:29 GMT</pubDate>
            <atom:updated>2023-10-18T17:35:43.476Z</atom:updated>
            <content:encoded><![CDATA[<p>#quantum30<br>#day-18</p><p>The code provided below is a Python script for finding the equivalence between two electronic circuits represented as graphs. It uses graph isomorphism and additional constraints based on transistor types to determine if two circuits are equivalent and provides a visual representation of the mappings between circuit nodes.</p><p>Here is the python file : equivalence.py</p><pre>import itertools<br>import numpy as np<br>import networkx as nx<br><br># Ignore errors importing matplotlib.pyplot (may not be available in<br># testing framework)<br>try:<br>    import matplotlib.pyplot as plt<br>    import matplotlib.colors as mcolors<br>except ImportError:<br>    pass<br><br>import dimod<br>from dwave.system import LeapHybridDQMSampler<br><br><br>def create_dqm(G1, G2):<br>    &quot;&quot;&quot;Construct DQM based on two graphs<br>    <br>    Create discrete quadratic model to represent the problem of<br>    finding an isomorphism between the two graphs<br>    <br>    Args:<br>        G1 (networkx.Graph)<br>        G2 (networkx.Graph)<br>    <br>    Returns:<br>        DiscreteQuadraticModel<br>    &quot;&quot;&quot;<br>    n = G1.number_of_nodes()<br>    if n != G2.number_of_nodes():<br>        raise ValueError<br><br>    G1_nodes = list(G1.nodes)<br>    G2_nodes = list(G2.nodes)<br><br>    dqm = dimod.DiscreteQuadraticModel()<br><br>    # In this formulation, the offset is equal to the number of nodes (multipled<br>    # by the penalty coefficient A, currently taken to be 1).  Note that in a<br>    # BQM formulation, the offset would be twice this number due to the need to<br>    # use a penalty model for each direction of the bijection constraint.<br>    dqm.offset = n<br><br>    for node in G1.nodes:<br>        # Discrete variable for node i in graph G1, with cases<br>        # representing the nodes in graph G2<br>        dqm.add_variable(n, node)<br><br>    # Set up the coefficients associated with the constraints that<br>    # each node in G2 is chosen once.  This represents the H_A<br>    # component of the energy function.<br><br>    for node in G1.nodes:<br>        dqm.set_linear(node, np.repeat(-1.0, n))<br>    for itarget in range(n):<br>        for ivar,node1 in enumerate(G1_nodes):<br>            for node2 in G1_nodes[ivar+1:]:<br>                dqm.set_quadratic_case(node1, itarget, node2, itarget, 2.0)<br><br>    # Set up the coefficients associated with the constraints that<br>    # selected edges must appear in both graphs, which is the H_B<br>    # component of the energy function.  The penalty coefficient B<br>    # controls the weight of H_B relative to H_A in the energy<br>    # function.  The value was selected by trial and error using<br>    # simple test problems.<br>    B = 2.0<br><br>    # For all edges in G1, penalizes mappings to edges not in G2<br>    for e1 in G1.edges:<br>        for e2_indices in itertools.combinations(range(n), 2):<br>            e2 = (G2_nodes[e2_indices[0]], G2_nodes[e2_indices[1]])<br>            if e2 in G2.edges:<br>                continue<br>            # In the DQM, the discrete variables represent nodes in<br>            # the first graph and are named according to the node<br>            # names.  The cases for each discrete variable represent<br>            # nodes in the second graph and are indices from 0..n-1<br>            dqm.set_quadratic_case(e1[0], e2_indices[0], e1[1], e2_indices[1], B)<br>            dqm.set_quadratic_case(e1[0], e2_indices[1], e1[1], e2_indices[0], B)<br><br>    # For all edges in G2, penalizes mappings to edges not in G1<br>    for e2 in G2.edges:<br>        e2_indices = (G2_nodes.index(e2[0]), G2_nodes.index(e2[1]))<br>        for e1 in itertools.combinations(G1.nodes, 2):<br>            if e1 in G1.edges:<br>                continue<br>            dqm.set_quadratic_case(e1[0], e2_indices[0], e1[1], e2_indices[1], B)<br>            dqm.set_quadratic_case(e1[0], e2_indices[1], e1[1], e2_indices[0], B)<br><br>    return dqm<br><br><br>def find_isomorphism(G1, G2):<br>    &quot;&quot;&quot;Search for isomorphism between two graphs<br><br>    Args:<br>        G1 (networkx.Graph)<br>        G2 (networkx.Graph)<br><br>    Returns:<br>        If no isomorphism is found, returns None.  Otherwise, returns<br>        dict with keys as nodes from graph 1 and values as<br>        corresponding nodes from graph 2.<br>    &quot;&quot;&quot;<br>    if G1.number_of_nodes() != G2.number_of_nodes():<br>        return None<br>    dqm = create_dqm(G1, G2)<br>    sampler = LeapHybridDQMSampler()<br>    results = sampler.sample_dqm(dqm, label=&#39;Example - Circuit Equivalence&#39;)<br><br>    best = results.first<br>    if np.isclose(best.energy, 0.0):<br>        G2_nodes = list(G2.nodes)<br>        return {k: G2_nodes[i] for k,i in best.sample.items()}<br>    else:<br>        # Isomorphism not found<br>        return None<br><br><br>def find_equivalence(C1, C2):<br>    &quot;&quot;&quot;Search for equivalence between two circuits<br><br>    This requires that the corresponding graphs are isomorphic and<br>    that matched nodes are &quot;equivalent&quot;.  In particular, transistor<br>    types must match.<br>    <br>    Args:<br>        C1 (Circuit)<br>        C2 (Circuit)<br>    <br>    Returns:<br>        If no equivalence is found, returns None.  Otherwise, returns<br>        dict with keys as nodes from graph 1 and values as<br>        corresponding nodes from graph 2.<br>    &quot;&quot;&quot;<br>    if C1.G.number_of_nodes() != C2.G.number_of_nodes():<br>        return None<br>    dqm = create_dqm(C1.G, C2.G)<br>    sampler = LeapHybridDQMSampler()<br>    results = sampler.sample_dqm(dqm, label=&#39;Example - Circuit Equivalence&#39;)<br><br>    if not np.isclose(results.first.energy, 0.0):<br>        return None<br><br>    G2_nodes = list(C2.G.nodes)<br><br>    for sample, energy in results.data(fields=[&#39;sample&#39;,&#39;energy&#39;]):<br>        if np.isclose(energy, 0.0):<br>            # Now check that the transistor types match<br>            mapping = {k: G2_nodes[i] for k,i in sample.items()}<br>            valid = True<br>            for n1,n2 in mapping.items():<br>                if (&#39;nMOS&#39; in n1 and &#39;nMOS&#39; not in n2) or (&#39;pMOS&#39; in n1 and &#39;pMOS&#39; not in n2):<br>                    valid = False<br>                    break<br>            if valid:<br>                return mapping<br>        else:<br>            # Sample is not an isomorphism<br>            return None<br><br>    return None<br><br><br>def plot_graphs(G1, G2, node_mapping):<br>    &quot;&quot;&quot;Plot graphs of two circuits<br><br>    The provided mapping specifies how nodes in graph 1 correspond to<br>    nodes in graph 2.  The nodes in each graph are colored using<br>    matching colors based on the specified mapping.<br><br>    Args:<br>        G1 (networkx.Graph)<br>        G2 (networkx.Graph)<br>        node_mapping (dict):<br>            Dictionary that defines the correspondence between nodes<br>            in graph 1 and nodes in graph 2.  The keys are names of<br>            nodes in graph 1, and the values are names of nodes in<br>            graph 2.<br>    &quot;&quot;&quot;<br>    f, axes = plt.subplots(1, 2, figsize=[10,4.5])<br><br>    colors = itertools.cycle(mcolors.TABLEAU_COLORS)<br>    G1_colors = [c for c,i in zip(colors, G1.nodes)]<br>    G2_targets = [node_mapping[n] for n in G1.nodes]<br>    G2_colors = [G1_colors[G2_targets.index(n)] for n in G2.nodes]<br><br>    nx.draw(G1, with_labels=True, ax=axes[0], node_color=G1_colors)<br>    nx.draw(G2, with_labels=True, ax=axes[1], node_color=G2_colors)<br><br>    return axes<br><br><br>if __name__ == &#39;__main__&#39;:<br>    import argparse<br><br>    from circuits import Circuit<br><br>    parser = argparse.ArgumentParser()<br>    parser.add_argument(&quot;netlist1&quot;, nargs=&#39;?&#39;, default=&quot;netlists/cmos_nand_1.txt&quot;, help=&quot;netlist file specifying first circuit (default: %(default)s)&quot;)<br>    parser.add_argument(&quot;netlist2&quot;, nargs=&#39;?&#39;, default=&quot;netlists/cmos_nand_2.txt&quot;, help=&quot;netlist file specifying second circuit (default: %(default)s)&quot;)<br>    parser.add_argument(&quot;--show-plot&quot;,  action=&#39;store_true&#39;, help=&quot;display plot of graphs of the circuits&quot;)<br>    parser.add_argument(&quot;--save-plot&quot;,  action=&#39;store_true&#39;, help=&quot;save plot of graphs of the circuits to file&quot;)<br><br>    args = parser.parse_args()<br><br>    C1 = Circuit(args.netlist1)<br>    C2 = Circuit(args.netlist2)<br><br>    results = find_equivalence(C1, C2)<br><br>    if results is None:<br>        print(&#39;No equivalence found&#39;)<br>    else:<br>        print(&#39;Circuits are equivalent:&#39;)<br>        for n1,n2 in results.items():<br>            print(&#39;  {} -&gt; {}&#39;.format(n1, n2))<br><br>        if args.show_plot or args.save_plot:<br>            axes = plot_graphs(C1.G, C2.G, results)<br>            axes[0].set_title(args.netlist1)<br>            axes[1].set_title(args.netlist2)<br><br>            if args.save_plot:<br>                filename = &#39;circuit_equivalence.png&#39;<br>                plt.savefig(filename, bbox_inches=&#39;tight&#39;)<br>                print(&#39;Plot saved to:&#39;, filename)<br><br>            if args.show_plot:<br>                plt.show()</pre><pre>from collections import namedtuple<br><br>import networkx as nx<br><br>Transistor = namedtuple(&#39;Transistor&#39;, &#39;name,drain,gate,source&#39;)<br><br><br>class Circuit:<br>    def __init__(self, netlist_file):<br>        &quot;&quot;&quot;Create circuit definition from netlist file<br>        <br>        Args:<br>            netlist_file (str)<br>        &quot;&quot;&quot;<br>        with open(netlist_file, &#39;r&#39;) as f:<br>            self.netlist = _parse_netlist(f)<br>        self.G = _create_graph(self.netlist)<br><br><br>def _parse_netlist(file_obj):<br>    &quot;&quot;&quot;Parse netlist file<br>    <br>    Returns:<br>        list: list of Transistor instances<br>    &quot;&quot;&quot;<br>    netlist = []<br>    for line in file_obj:<br>        if not (&#39;nmos&#39; in line or &#39;pmos&#39; in line):<br>            continue<br>        values = line.split()<br>        netlist.append(Transistor(*values[:4]))<br>    return netlist<br><br><br>def _create_graph(netlist):<br>    &quot;&quot;&quot;Construct graph from netlist<br>    <br>    Args:<br>        netlist (list):<br>            List of Transistor instances obtained from _parse_netlist<br>    <br>    Returns:<br>        networkx.Graph<br>    &quot;&quot;&quot;<br>    G = nx.Graph()<br>    for t in netlist:<br>        G.add_edges_from([(t.name, t.drain), (t.name, t.gate), (t.name, t.source)])<br>    return G<br><br><br>if __name__ == &#39;__main__&#39;:<br>    C_nand = Circuit(&quot;netlists/cmos_nand_1.txt&quot;)<br>    C_nor = Circuit(&quot;netlists/cmos_nor_1.txt&quot;)</pre><p>Second file is the circuits.py</p><p>The provided code defines a Python class named Circuit and a script that demonstrates its usage for creating circuit definitions from netlist files.</p><p>Finally we are ending this series of making python project using dwave’s sdk dwave ocean .We have already done 8 projects :<br>1)sudoku.py<br>2)Reservoir Management<br>3)Pegasus Topology <br>4)cryptarithm<br>5)Satellite Placement <br>6)Financial Modelling<br>7)Reverse Annealing <br>8)circuit equivalence</p><p>Next day we will do some more creative to develop our interest.</p><p><a href="https://medium.com/u/1b400b39fb87">QuantumComputingIndia</a><br>#quantum30<br>#day-18</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc055edda388" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Circuit Equivalence]]></title>
            <link>https://medium.com/@inderpalsuthar5911/circuit-equivalence-b8c7096969d6?source=rss-35373755701a------2</link>
            <guid isPermaLink="false">https://medium.com/p/b8c7096969d6</guid>
            <category><![CDATA[electric-circuit]]></category>
            <category><![CDATA[electric-engineering]]></category>
            <category><![CDATA[quantum-computing]]></category>
            <category><![CDATA[d-wave]]></category>
            <category><![CDATA[circuit-design]]></category>
            <dc:creator><![CDATA[Inderpal Suthar]]></dc:creator>
            <pubDate>Tue, 17 Oct 2023 06:08:24 GMT</pubDate>
            <atom:updated>2023-10-17T06:10:18.179Z</atom:updated>
            <content:encoded><![CDATA[<p>Circuit Equivalence</p><p>#quantum30</p><p>#day-17</p><p>Take your inner electric engineer outside and let’s do some interesting with electric circuits using dwave annealers.</p><p>This demonstration addresses the task of verifying the equivalence of two representations of the design of an electronic circuit, which is of interest in the field of electronic design automation. By converting the representation of each circuit into a graph, the problem can be reduced to that of determining whether the two graphs are isomorphic. The two graphs are said to be isomorphic if there is a one-to-one-correspondence between the vertex sets such that the adjacency relationships are identical. Graph isomorphism is a problem of general interest, and it is not currently known whether it is NP complete .</p><p>The following figure depicts the schematic representation of a CMOS NAND gate, along with the corresponding graph:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RCRmambcb5sAP_FjQzrX0Q.png" /></figure><p>Next day we will write some code to check equivalence.</p><p><a href="https://medium.com/u/1b400b39fb87">QuantumComputingIndia</a></p><p>#quantum30</p><p>#day-17</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b8c7096969d6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reverse Annealing (part-2)]]></title>
            <link>https://medium.com/@inderpalsuthar5911/reverse-annealing-part-2-45d48716406d?source=rss-35373755701a------2</link>
            <guid isPermaLink="false">https://medium.com/p/45d48716406d</guid>
            <category><![CDATA[quantum-physics]]></category>
            <category><![CDATA[d-wave-systems]]></category>
            <category><![CDATA[quantum-annealing]]></category>
            <category><![CDATA[quantum-computing]]></category>
            <category><![CDATA[simulated-annealing]]></category>
            <dc:creator><![CDATA[Inderpal Suthar]]></dc:creator>
            <pubDate>Mon, 16 Oct 2023 12:59:02 GMT</pubDate>
            <atom:updated>2023-10-16T12:59:02.160Z</atom:updated>
            <content:encoded><![CDATA[<p>#quantum30 <br>#day-16</p><pre>#generating a random problem<br><br>import numpy as np<br><br>h = {v: 0.0 for v in sampler.nodelist}<br>J = {tuple(c): np.random.choice([-1, 1]) for c in sampler.edgelist}<br><br>print(&quot;Bias 0 assigned to&quot;, len(h), &quot;qubits.&quot;)<br>print(&quot;Strengths -1/+1 assigned randomly to&quot;,len(J),&quot;couplers.&quot;)<br><br>#output Bias 0 assigned to 5627 qubits.<br>#output Strengths -1/+1 assigned randomly to 40279 couplers.<br><br>#defining annealing schedule <br>from helpers.schedule import make_reverse_anneal_schedule # To see helper functions, select Jupyter File Explorer View from the Online Learning page<br><br>reverse_schedule = make_reverse_anneal_schedule(s_target=0.45, hold_time=80, ramp_up_slope=max_slope)<br>time_total = reverse_schedule[3][0]<br><br>print(reverse_schedule)<br>print(&quot;Total anneal-schedule time is {} us&quot;.format(time_total))<br><br>#output [[0.0, 1.0], [2.75, 0.45], [82.75, 0.45], [83.025, 1.0]]<br>#output Total anneal-schedule time is 83.025 us<br><br><br>%matplotlib inline<br>import matplotlib.pyplot as plt<br><br>plt.figure(1, figsize=(3, 3))<br>plt.plot(*np.array(reverse_schedule).T)<br>plt.title(&quot;Reverse Anneal Schedule&quot;)<br>plt.xlabel(&quot;Time [us]&quot;)<br>plt.ylabel(&quot;Annealing Parameter s&quot;)<br>plt.ylim([0.0,1.0])<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/303/1*My7sSJYQDjnH4wTTWNab5A.png" /></figure><pre>#setting the initial states<br>forward_answer = sampler.sample_ising(h, J, <br>                                      num_reads=1000, <br>                                      annealing_time=time_total, <br>                                      label=&#39;Notebook - Reverse Annealing&#39;,<br>                                      answer_mode=&#39;histogram&#39;)<br>forward_solutions, forward_energies = forward_answer.record.sample, forward_answer.record.energy<br>i5 = int(5.0/95*len(forward_answer))  # Index i5 is about a 5% indexial move from the sample of lowest energy<br><br>initial = dict(zip(forward_answer.variables, forward_answer.record[i5].sample))<br><br>print(&quot;Lowest energy found: {}&quot;.format(forward_answer.record.energy[0]))<br>print(&quot;Average energy is {:.2f} with standard deviation {:.2f}&quot;.format(forward_energies.mean(), forward_energies.std()))<br>print(&quot;\nSetting the initial state to a sample with energy: {}&quot;.format(forward_answer.record.energy[i5]))<br><br>#output Lowest energy found: -15677.0<br>#output Average energy is -15639.09 with standard deviation 13.68<br>#output Setting the initial state to a sample with energy: -15659.0<br><br>#running reverse annealing <br>reverse_anneal_params = dict(anneal_schedule=reverse_schedule, initial_state=initial, reinitialize_state=False)<br>reverse_answer = sampler.sample_ising(h, J, <br>                                      num_reads=1000, <br>                                      label=&#39;Notebook - Reverse Annealing&#39;,<br>                                      answer_mode=&#39;histogram&#39;, <br>                                      **reverse_anneal_params)<br>reverse_solutions, reverse_energies = reverse_answer.record.sample, reverse_answer.record.energy<br><br>print(&quot;Lowest energy found:&quot;, reverse_answer.record.energy[0])<br>print(&quot;Average energy is {:.2f} with standard deviation {:.2f}&quot;.format(reverse_energies.mean(), reverse_energies.std()))<br><br>#output Lowest energy found: -15665.0<br>#output Average energy is -15658.42 with standard deviation 3.40</pre><p>Go through complete code and give some review .</p><p>Thanks for reading my article.</p><p><a href="https://medium.com/u/1b400b39fb87">QuantumComputingIndia</a></p><p>#quantum30<br>#day16</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=45d48716406d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>