NVIDIA / cuda-quantum

C++ and Python support for the CUDA Quantum programming model for heterogeneous quantum-classical workflows
https://nvidia.github.io/cuda-quantum/
Other
524 stars 186 forks source link

Cannot cast type to IntegerType #2203

Open zohimchandani opened 2 months ago

zohimchandani commented 2 months ago

Required prerequisites

Describe the bug

This executes fine:

import cudaq
from cudaq import spin 
from typing import List

vector = [1.0]

@cudaq.kernel
def kernel(vector: List[float]):

    q = cudaq.qvector(1) 

    if vector[0] == 1: 
        x(q[0])

cudaq.observe(kernel, spin.z(0), vector).expectation()

If I change if vector[0] == 1 to if vector[0] == 1.0 which is what it should be given that my input type is a List[float], I get the following error:

ValueError: Cannot cast type to IntegerType (from Type(f64))

Steps to reproduce the bug

NA

Expected behavior

NA

Is this a regression? If it is, put the last known working version (or commit) here.

Not a regression

Environment

Suggestions

NA