Cirq vs. Qiskit vs. Q#: 3 Quantum Programming Languages. Which should you choose?

Cirq Vs. Qiskit Vs. Q#: 3 Quantum Programming Languages. Which Should You Choose?

We briefly examine three quantum computing frameworks, focusing on Cirq and Qiskit and mentioning Q#. Cirq, developed by Google’s Quantum AI team, is designed for creating and editing quantum circuits. One of its strengths is accurately modeling quantum noise, which is crucial for simulating real-world quantum computing behavior.

Quantum computing is a rapidly evolving field, and choosing the proper framework can significantly impact computation efficiency, effectiveness, and developer experience.

Understanding Quantum Computing Frameworks

Cirq and Qiskit are two leading contenders in quantum computing, each with unique features and capabilities.

Cirq, developed by Google’s Quantum AI team, is designed to create, edit, and invoke Noisy Intermediate Scale Quantum (NISQ) circuits. Its primary strength lies in its ability to accurately model quantum noise, a crucial aspect of real-world quantum computing. This feature allows researchers to simulate the behavior of quantum algorithms in the presence of errors, providing a more realistic representation of quantum computation.

Qiskit, an open-source framework developed by IBM, offers a comprehensive suite of tools for quantum computing. It supports various quantum computations, from basic quantum gates to more complex quantum algorithms. One of its key features is the ability to run quantum programs on real quantum hardware, providing researchers with invaluable hands-on experience.

Another Q#, developed by Microsoft, is a high-level, domain-specific programming language for quantum computing. It integrates quantum algorithms into classical workflows, a feature advantageous for hybrid quantum-classical computations.

Qiskit: A Comprehensive Toolkit for Quantum Computing

IBM’s Qiskit is designed to enable researchers and developers to work with quantum computers at the level of pulses, circuits, and algorithms. Its architecture is divided into four elements: Terra, Aer, Ignis, and Aqua, each designed to handle different aspects of quantum computing.

One of Qiskit’s standout features is its ability to run quantum programs on actual quantum hardware. This is facilitated through IBM Quantum Experience, a cloud-based platform that provides public access to a set of IBM’s prototype quantum processors. It is perhaps the most popular Quantum Computing Framework, with many academic and other users. It certainly has great support and interest and is often considered the “go-to” Quantum Programming Framework. Of course, while open source, the framework has the backing of tech giant IBM, which builds hardware on which users can run their Quantum Circuits.

from qiskit import QuantumCircuit, Aer, execute

# Create a quantum circuit with two qubits
qc = QuantumCircuit(2)

# Apply a Hadamard gate to the first qubit
qc.h(0)

# Apply a controlled-X (CNOT) gate with the first qubit as control and the second qubit as target
qc.cx(0, 1)

# Display the quantum circuit
print("Quantum Circuit:")
print(qc.draw())

# Simulate the circuit to observe the entangled state
simulator = Aer.get_backend('statevector_simulator')
result = execute(qc, simulator).result()
statevector = result.get_statevector()

# Display the final statevector
print("\nFinal Statevector:")
print(statevector)

Cirq, Ideal for NISQ

Cirq is an open-source quantum computing framework developed by Google. It provides tools for writing, simulating, and running quantum algorithms on quantum computers and simulators. Cirq is designed to be flexible and scalable, allowing researchers and developers to experiment with various quantum computing concepts and algorithms. It supports a wide range of quantum hardware platforms, including gate-based quantum computers, and offers high-level abstractions for defining quantum circuits and operations. Cirq also includes built-in simulators for testing and debugging quantum algorithms before running them on actual hardware.

Cirq’s architecture is designed to reflect the realities of the noisy quantum processors currently available. It supports various quantum gates, including those specific to Google’s quantum hardware.

import cirq

# Define two qubits
qubit1 = cirq.GridQubit(0, 0)
qubit2 = cirq.GridQubit(0, 1)

# Create a circuit
circuit = cirq.Circuit()

# Add a Hadamard gate to the first qubit to create a superposition
circuit.append(cirq.H(qubit1))

# Add a controlled-NOT (CNOT) gate to entangle the qubits
circuit.append(cirq.CNOT(qubit1, qubit2))

# Display the circuit
print(circuit)

Q#: A High-Level Language for Quantum Computing

Q#, developed by Microsoft, is a high-level, domain-specific programming language designed specifically for quantum computing. It offers a unique approach to quantum programming, integrating quantum algorithms into classical workflows, which can benefit hybrid quantum-classical computations.

Q# is designed to work with a classical host program, typically written in a .NET language like C# or F#. The host program controls the quantum program, sending it operations to perform and receiving results.

namespace EntangledPair {
    operation CreateEntangledPair() : (Result, Result) {
        // Allocate two qubits
        using (qubits = Qubit[2]) {
           
            H(qubits[0]);

            CNOT(qubits[0], qubits[1]);

            // Measure the qubits
            let result1 = M(qubits[0]);
            let result2 = M(qubits[1]);

            // Return the measurement results
            return (result1, result2);
        }
    }
}

Evaluating Performance and Usability: Qiskit vs Cirq

Choosing a quantum computing framework or language is a critical decision that can significantly impact computation efficiency and effectiveness. Several factors should guide the choice, including the specific requirements of the quantum computation task, the need for noise modeling, the complexity of the quantum computations, and the availability of quantum hardware.

The choice between Cirq, Qiskit, and other frameworks, such as Q#, depends mainly on the specific requirements of the quantum computation task. Each framework has its strengths and weaknesses, and the choice should be guided by factors such as the need for noise modeling, the complexity of the quantum computations, and the availability of quantum hardware. We put some considerations below. However, one of our previous articles examines the relative popularity of different quantum programming languages and frameworks.

Learning Resources

Sorry, but there are more resources for learning Qiksit than any other framework. That means that Visit is something like the modern-day equivalent of the FORTRAN programming language, which dates back to the 1950s and is still used today. Microsoft is busy pushing Q#, but we don’t think it’s pushing as hard as possible. The language Q# is a language and not a framework that has been popular but appears to be losing ground to the might of Qiskit in terms of interest, whether that is in books published or tutorials. Cirq doesn’t seem as well backed as theirs despite coming from the Google stable. However, the now head of Sandbox AQ did write a book on Quantum Computing with Cirq.

The Community

The developer community plays an important role in the framework or language choice. Qiskit is the winner, with a massive installed base and developer accreditation. IBM is doing a lot to ensure that Qiskit becomes “THE” Quantum Programming Language. However, despite all the muscle of Google and Microsoft, who are pretty strong in developer tools and languages, you’d have expected perhaps more in-raods into the quantum community.

References

  • “Quantum Algorithm Implementations for Beginners.” Coles, P.J., et al. (2018). arXiv:1804.03719 [quant-ph]. 
  • “Quantum Computing: Progress and Prospects.” National Academies Press, 2019.
  • “Programming Quantum Computers: Essential Algorithms and Code Samples”, Johnston, E., Harrigan, N., Gimeno-Segovia, M., O’Reilly Media, 2019. 
  • “Quantum Computing in the NISQ era and beyond.” Preskill, J. (2018). Quantum, 2, 79. 
  • “Quantum Computing: An Applied Approach.” Hidary, J., Springer, 2019. 
  • “Quantum Computing for Computer Scientists”, Yanofsky, N. and Mannucci, M., Cambridge University Press, 2008.
  • “Quantum Computing: Progress and Prospects.” Emily Grumbling and Mark Horowitz, editors. National Academies Press, 2019. 
  • “Quantum Computation and Quantum Information.” Michael A. Nielsen and Isaac L. Chuang. Cambridge University Press, 2010. 
  • “Programming Quantum Computers: Essential Algorithms and Code Samples.” Johnston, E.R., et al. (2019). O’Reilly Media, Inc. 
  • “Quantum Computing for Computer Scientists.” Yanofsky, N., Mannucci, M., Cambridge University Press, 2008.
  • “Quantum Computing: An Applied Approach”, Hidary, J., Springer, 2019. 
  • “Quantum Computing in the NISQ era and beyond.” Preskill, John. Quantum, 2018. 
  • “Programming Quantum Computers: Essential Algorithms and Code Samples.” Johnston, E., Harrigan, N., Gimeno-Segovia, M., O’Reilly Media, 2019.
  • “Quantum Computing for Computer Scientists.” Noson S. Yanofsky and Mirco A. Mannucci. Cambridge University Press, 2008. 
  • “Dancing with qubits: How quantum computing works and how it can change the world.” Sutor, R. S. (2019). Packt Publishing Ltd. 
  • “Quantum Computing: An Applied Approach.” Jack D. Hidary. Springer, 2019. 
  • “Quantum Computing for Computer Scientists”, Yanofsky, N., Mannucci, M., Cambridge University Press, 2008. 
  • “Q#: Enabling scalable quantum computing and development with a high-level DSL.” Svore, K. M., Geller, A. J., Troyer, M., Azaria, S., Granade, C., Heim, B., … & Krysta, M. (2018). In Proceedings of the Real World Domain Specific Languages Workshop 2018 (pp. 1-10). 
  • “Cirq: A Python Framework for Creating, Editing, and Invoking Noisy Intermediate Scale Quantum Circuits.” White, T.C., et al. (2020). Quantum Science and Technology. 
  • “Quantum Computing: A Gentle Introduction.” Eleanor G. Rieffel and Wolfgang H. Polak. MIT Press, 2011.
  • “Efficient calculation of quantum gate errors in the presence of crosstalk.” Guinea, D., Egger, D. J., Sun, Y., & Gambetta, J. M. (2019). npj Quantum Information, 5(1), 1-8. 
  • “Qiskit: An Open-source Framework for Quantum Computing.” Egger, D.J., et al. (2020). 2020 IEEE 26th International Conference on Electronics, Circuits and Systems (ICECS).