Skip to content

[run] Support returning nested data types (e.g. list of lists) #3889

@khalatepradnya

Description

@khalatepradnya

Required prerequisites

  • Search the issue tracker to check if your feature has already been mentioned or rejected in other issues.

Describe the feature

CUDA-Q run does not support kernels that return nested or aggregate vectors / lists / structs (e.g., list[list[int]]).
(main as of commit ID 5cf20bd)

This should be supported.

  • Example 1
import cudaq

@cudaq.kernel
def test() -> list[list[int]]:
    return [[1, 2], [3, 4]]

cudaq.run(test)

fails with RuntimeError: cudaq.run does not yet support returning nested list from entry-point kernels.

  • Example 2
import cudaq
from dataclasses import dataclass

@dataclass(slots=True)
class MyTuple:
    foo: int
    bar: list[bool]

@cudaq.kernel
def test_tuple() -> MyTuple:
    return MyTuple(42, [True, False, True])

cudaq.run(test_tuple)

fails with RuntimeError: Unsupported element type in struct type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions