NVIDIA / NVIDIA/cuda-quantum

Cannot cast type to IntegerType

Open
#2,203 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

python bridge stale-notified
Dominant language
C++
Stars
1.1k
Forks
456
Avg merge
1d 22h
Merged PRs (30d)
165

Description

Required prerequisites
  • Consult the security policy. If reporting a security vulnerability, do not report the bug using this form. Use the process described in the policy to report the issue.
  • Make sure you've read the documentation. Your issue may be addressed there.
  • Search the issue tracker to verify that this hasn't already been reported. +1 or comment there if it has.
  • If possible, make a PR with a failing test to give us a starting point to work on!
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
  • CUDA Quantum version:
  • Python version:
  • C++ compiler:
  • Operating system:
Suggestions

NA

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the supplied Python kernel and the comparison in the issue, recording the CUDA Quantum, Python, compiler, and operating-system versions that are currently missing. Trace the handling of the float comparison and its reported IntegerType cast; the work is done when the 1.0 comparison executes successfully and the behavior is covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
quantum-computing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.