Skip to content

Generalize inc, dec, and test kernels to support arbitrary number of qubits.#28

Open
ToroData wants to merge 2 commits intoNVIDIA:mainfrom
ToroData:main
Open

Generalize inc, dec, and test kernels to support arbitrary number of qubits.#28
ToroData wants to merge 2 commits intoNVIDIA:mainfrom
ToroData:main

Conversation

@ToroData
Copy link
Copy Markdown

This PR fixes kernel argument issues and generalizes the inc_with_n_qubits, dec, and test kernels to work with any number of qubits, eliminating fixed-size constraints and runtime errors.

Original Issue

Attempting to run the original implementation triggered the following compiler error from CUDA Q:

cudaq.kernel.ast_bridge.CompilerError: <ipython-input>:16: error: Invalid variable name requested - 'num_qubits' is not defined within the quantum kernel it is used in. (offending source -> num_qubits)

Changes

  • inc_with_n_qubits(qubits) now derives its size internally via len(qubits).
  • dec(qubits) correctly uses cudaq.adjoint(...) with a single argument.
  • test(binary_list) was updated to remove num_qubits and infer size from the list.
  • Test loop updated to match kernel signature.

License

I affirm that this contribution is submitted under the Apache License 2.0 for source code and is compliant with the developer certificate of origin.


Signed-off-by: Ricard Santiago Raigada García ricardraigada@outlook.es

Refactored inc_with_n_qubits to infer qubit length dynamically.
Corrected dec and test kernels to remove argument mismatches.

Signed-off-by: Ricard Santiago Raigada García <ricardraigada@outlook.es>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant