Skip to content

Commit

Permalink
some minor improvements to dynamic mcxs
Browse files Browse the repository at this point in the history
  • Loading branch information
positr0nium committed Jan 3, 2025
1 parent bc22156 commit a682c1e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/qrisp/alg_primitives/mcx_algs/balauca.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,10 @@ def jasp_balauca_mcx(ctrls, target, ctrl_state):

with control(N == 1):
cx(ctrls[0], target[0])

with control(N == 2):
mcx([ctrls[0], ctrls[1]], target[0])

with control(N > 2):
balauca_anc = QuantumVariable(N-2+N%2)
with conjugate(jasp_balauca_helper)(ctrls, balauca_anc):
Expand Down Expand Up @@ -497,5 +499,4 @@ def jasp_balauca_helper(ctrls, balauca_anc):
balauca_anc[l+k+j],
method = "gidney")

l = cond(jnp.bool(k%2), lambda x : x-1, lambda x : x, l)
l += k
l += k - k%2
4 changes: 3 additions & 1 deletion src/qrisp/core/gate_application_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import sympy

import qrisp.circuit.standard_operations as std_ops
from qrisp.jasp import check_for_tracing_mode
from qrisp.jasp import check_for_tracing_mode, DynamicQubitArray

def append_operation(operation, qubits=[], clbits=[], param_tracers = []):
from qrisp import find_qs
Expand Down Expand Up @@ -510,6 +510,8 @@ def benchmark_mcx(n, methods):
)
else:
qubits_0 = controls
if isinstance(qubits_0, (QuantumVariable, DynamicQubitArray)):
method = "balauca"
qubits_1 = [target]
from qrisp.alg_primitives.mcx_algs import (
balauca_dirty,
Expand Down

0 comments on commit a682c1e

Please sign in to comment.