Skip to content

Bug: controlled/inverted state preparation with method='qswitch' #412

@renezander90

Description

@renezander90
from qrisp import *

@terminal_sampling
def main():

    coeffs = jnp.array([1.,2.,1.,3.])
    qb = QuantumBool()
    h(qb)
    qv = QuantumFloat(2)

    with control(qb):
        prepare(qv, coeffs, method="qswitch")

    return qv

main()

Yields: ValueError: Tried to evaluate jaxpr with insufficient arguments: expected 7 (including 3 consts), got 10.

and

from qrisp import *

@terminal_sampling
def main():

    coeffs = jnp.array([1.,2.,1.,3.])
    qb = QuantumBool()
    h(qb)
    qv = QuantumFloat(2)

    with invert():
        prepare(qv, coeffs, method="qswitch")

    return qv

main()

Yields: ValueError: Tried to evaluate jaxpr with insufficient arguments: expected 6 (including 3 consts), got 9.

Most likely, the prepare_qswitchmethod should be wrapped in @custom_control and @custom_inversion @PietropaoloFrisoni @positr0nium

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions