Skip to content

Commit

Permalink
wrote some comparison to a recent classiq paper
Browse files Browse the repository at this point in the history
  • Loading branch information
positr0nium committed Dec 12, 2024
1 parent 4867eb4 commit 140c517
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions src/qrisp/examples/classiq_qsvt_paper_comparison.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
"""
\********************************************************************************
* Copyright (c) 2023 the Qrisp authors
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the Eclipse
* Public License, v. 2.0 are satisfied: GNU General Public License, version 2
* with the GNU Classpath Exception which is
* available at https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
"""


# This file implements the circuits described in https://arxiv.org/abs/2412.07372
# and computes some performance metrics
from qrisp import *
coin_0 = QuantumBool()
qv = QuantumFloat(20)

def walk_operator(data, coin, inpl_adder = fourier_adder):

inpl_adder(-1, data)

with control(coin):
inpl_adder(2, data)

walk_operator(qv, coin_0)
# This is the circuit described on page 6
qc = qv.qs.compile()
print("Walk Operator: ")
print("CNOT count: ", qc.cnot_count())
print("Qubits: ", qc.num_qubits())
# Walk Operator:
# CNOT count: 420
# Qubits: 21

# This is the circuit described on page 8
def controlled_reflection(data, ctrl_qb):

h(ctrl_qb)
h(data[0])
mcx([ctrl_qb] + data[:-1], data[-1], method = "balauca")
h(data[0])
h(ctrl_qb)

coin_1 = QuantumBool()
controlled_reflection(qv, coin_1)

qc = qv.qs.compile()
print("QSVT circuit:")
print("CNOT count: ", qc.cnot_count())
print("Qubits: ", qc.num_qubits())
# QSVT circuit:
# CNOT count: 536
# Qubits: 39

0 comments on commit 140c517

Please sign in to comment.