Cudaq importing

From NVIDIA/skills · View interactive version

Cudaq importing is an AI agent skill from the GitHub repository NVIDIA/skills. Use when porting circuits from another framework (e.g. Qiskit) into CUDA-Q kernels while preserving the source algorithm and validation fidelity.

How to use this skill

Skill file

CUDA-Q Importing

Purpose

Use this skill to port quantum circuits from another framework into CUDA-Q

Python kernels. This includes Qiskit code and Qiskit-style circuit construction,

as well as other framework-driven circuit builders. The goal is a framework-free

CUDA-Q port that preserves the source quantum algorithm, matches source behavior

at small test sizes, and documents any unavoidable CUDA-Q limitations.

For authoring new CUDA-Q kernels from scratch, and for CUDA-Q installation,

simulation targets, QPU access, and parallelization, use the cudaq-guide

skill (/cudaq-guide author for kernel authoring).

Prerequisites

python -c "import cudaq; print(getattr(cudaq, '__version__', 'unknown'))".

behavior.

installed in the validation environment only. The final CUDA-Q port itself

must not require the source framework.

connector is available before relying on it; otherwise use local docs or the

source tree.

documentation, review relevant documentation or source changes before

treating a behavior difference as a porting bug.

Workflow

  1. Read the source circuit construction and identify the exact algorithm,

qubit/register layout, measurement behavior, and any framework helpers.

  1. Preserve the high-level quantum algorithm. Do not replace mid-circuit

measurement, QPE structure, oracle definitions, or decomposition strategy

without explicit user permission.

  1. Select the CUDA-Q execution pattern:

used per shot.

CUDA-Q requires a fixed-length return shape.

  1. Translate gates and subcircuits. For detailed gate mappings, ordering rules,

precision guidance, and helper-extraction patterns, read

references/porting-reference.md.

  1. Remove runtime source-framework dependencies from the CUDA-Q port. Extract

pure helpers into framework-free modules.

  1. Validate with small deterministic inputs before scaling. Compare raw count

keys and distributions, not just aggregate fidelity.

  1. Re-run any previously failing configurations after every fix.

Core Rules

imports unless they are genuinely unavoidable and documented.

transpiling through the source framework.

measurement return list, or final count-key formatting.

fidelity differences matter (CUDA-Q defaults to fp32, Qiskit to fp64).

source-compatible behavior.

When to Read the Reference

Read references/porting-reference.md when

you need any of the following:

Limitations

behavior against the installed CUDA-Q version for version-sensitive features.

Python; use the companion cudaq-guide skill (/cudaq-guide author) for core

CUDA-Q authoring constraints and shared kernel patterns.

order. Apparent fidelity or bitstring mismatches may be convention

differences.

the local CUDA-Q installation.

correctness-preserving ports.

Troubleshooting

Use this format when diagnosing failures:

CUDA-Q path.

Cause: The port still imports the source framework.

Solution: Move pure helpers into a framework-free module and verify with

the import-blocker pattern in the reference.

Cause: The source framework and CUDA-Q count-key ordering differ.

Solution: Fix allocation, return-list order, or formatting at the port

boundary. Do not alter the algorithm.

Cause: CUDA-Q and the source framework may be using different

floating-point precision.

Solution: Match precision before comparing, then rerun the smallest

failing deterministic case.

silently changes behavior at higher arity.

Cause: The port used a fixed-arity dispatcher.

Solution: Use CUDA-Q control-list patterns for arbitrary arity.

Cause: Connector unavailable, stale, or transiently failing.

Solution: Verify the connector/resource list, retry transient failures

once, then fall back to local docs/source or official CUDA-Q docs. Do not

change the port based on unverified MCP results.

Cause: The installed CUDA-Q version may differ from the latest

documentation.

Solution: Check cudaq.__version__, then review relevant documentation or

source changes between the installed version and latest before changing the

port.

References

patterns, kernel-language constraints, execution APIs, and debugging workflow.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.