Add angle-producing math functions to kernels with docs and tests#4697
Open
LakshikkaNathan wants to merge 7 commits into
Open
Add angle-producing math functions to kernels with docs and tests#4697LakshikkaNathan wants to merge 7 commits into
LakshikkaNathan wants to merge 7 commits into
Conversation
Adds C++ lowering for std::asin/acos/atan and Python lowering for np.tan/asin/acos/atan/log, documents the supported functions for both languages in the kernel spec, and adds per-function simulator tests plus a gate-parameter test. Addresses NVIDIA#2942. Signed-off-by: Lakshikka Sithamparanathan <2922185@vikes.csuohio.edu>
# Conflicts: # cudaq/test/AST-Quake/math_functions.cpp
Collaborator
Command Bot: Processing... |
CI Summary (
|
| Job | Result | Link |
|---|---|---|
build_and_test |
❌ failure | view |
Top-level jobs (13)
| Job | Result |
|---|---|
binaries |
⏩ skipped |
build_and_test |
❌ failure |
config_devdeps |
✅ success |
config_source_build |
⏩ skipped |
config_wheeldeps |
✅ success |
devdeps |
✅ success |
docker_image |
⏩ skipped |
gen_code_coverage |
⏩ skipped |
metadata |
✅ success |
python_metapackages |
⏩ skipped |
python_wheels |
⏩ skipped |
source_build |
⏩ skipped |
wheeldeps |
✅ success |
⏩ Skipped jobs (7) — intentionally skipped on PR builds; run on merge_group / workflow_dispatch
| Job |
|---|
binaries |
config_source_build |
docker_image |
gen_code_coverage |
python_metapackages |
python_wheels |
source_build |
All sub-jobs (42) — every matrix leg, with links
| Job | Status | Link |
|---|---|---|
| Build and test (amd64, gcc12, openmpi) / Dev environment (Debug) | ✅ success | view |
| Build and test (amd64, gcc12, openmpi) / Dev environment (Python) | ❌ failure | view |
| Build and test (amd64, llvm, openmpi) / Dev environment (Debug) | ✅ success | view |
| Build and test (amd64, llvm, openmpi) / Dev environment (Python) | ✅ success | view |
| Build and test (arm64, llvm, openmpi) / Dev environment (Debug) | ✅ success | view |
| Build and test (arm64, llvm, openmpi) / Dev environment (Python) | ✅ success | view |
| CI Summary | ❔ in_progress | view |
| Configure build (devdeps) | ✅ success | view |
| Configure build (source_build) | ⏩ skipped | view |
| Configure build (wheeldeps) | ✅ success | view |
| Create CUDA Quantum installer | ⏩ skipped | view |
| Create Docker images | ⏩ skipped | view |
| Create Python metapackages | ⏩ skipped | view |
| Create Python wheels | ⏩ skipped | view |
| Gen code coverage | ⏩ skipped | view |
| Load dependencies (amd64, gcc12) / Caching | ✅ success | view |
| Load dependencies (amd64, gcc12) / Finalize | ✅ success | view |
| Load dependencies (amd64, gcc12) / Metadata | ✅ success | view |
| Load dependencies (amd64, llvm) / Caching | ✅ success | view |
| Load dependencies (amd64, llvm) / Finalize | ✅ success | view |
| Load dependencies (amd64, llvm) / Metadata | ✅ success | view |
| Load dependencies (arm64, gcc12) / Caching | ✅ success | view |
| Load dependencies (arm64, gcc12) / Finalize | ✅ success | view |
| Load dependencies (arm64, gcc12) / Metadata | ✅ success | view |
| Load dependencies (arm64, llvm) / Caching | ✅ success | view |
| Load dependencies (arm64, llvm) / Finalize | ✅ success | view |
| Load dependencies (arm64, llvm) / Metadata | ✅ success | view |
| Load source build cache | ⏩ skipped | view |
| Load wheel dependencies (amd64, 12.6) / Caching | ✅ success | view |
| Load wheel dependencies (amd64, 12.6) / Finalize | ✅ success | view |
| Load wheel dependencies (amd64, 12.6) / Metadata | ✅ success | view |
| Load wheel dependencies (amd64, 13.0) / Caching | ✅ success | view |
| Load wheel dependencies (amd64, 13.0) / Finalize | ✅ success | view |
| Load wheel dependencies (amd64, 13.0) / Metadata | ✅ success | view |
| Load wheel dependencies (arm64, 12.6) / Caching | ✅ success | view |
| Load wheel dependencies (arm64, 12.6) / Finalize | ✅ success | view |
| Load wheel dependencies (arm64, 12.6) / Metadata | ✅ success | view |
| Load wheel dependencies (arm64, 13.0) / Caching | ✅ success | view |
| Load wheel dependencies (arm64, 13.0) / Finalize | ✅ success | view |
| Load wheel dependencies (arm64, 13.0) / Metadata | ✅ success | view |
| Prepare cache clean-up | ✅ success | view |
| Retrieve PR info | ✅ success | view |
⚠️ Required checks (5/6) — 1 missing — declared in .github/required-checks.yml for push
| Required check | Status | Link |
|---|---|---|
| Build and test (amd64, llvm, openmpi) / Dev environment (Debug) | ✅ success | view |
| Build and test (amd64, llvm, openmpi) / Dev environment (Python) | ✅ success | view |
| Build and test (arm64, llvm, openmpi) / Dev environment (Debug) | ✅ success | view |
| Build and test (arm64, llvm, openmpi) / Dev environment (Python) | ✅ success | view |
| Build and test (amd64, gcc12, openmpi) / Dev environment (Debug) | ✅ success | view |
| Build and test (amd64, gcc12, openmpi) / Dev environment (Python) | ❌ failure | view |
Signed-off-by: Lakshikka Sithamparanathan <2922185@vikes.csuohio.edu>
Author
Collaborator
Command Bot: Processing... |
sacpis
reviewed
Jun 8, 2026
sacpis
left a comment
Collaborator
There was a problem hiding this comment.
Overall LGTM. Thanks @LakshikkaNathan. Left a few comments. Once we have those changes, will take a look at it again before approving.
Signed-off-by: Lakshikka Sithamparanathan <2922185@vikes.csuohio.edu>
Author
|
Thanks for the review, @sacpis! Addressed all the comments in |
Collaborator
Command Bot: Processing... |
sacpis
reviewed
Jun 10, 2026
Signed-off-by: Lakshikka Sithamparanathan <2922185@vikes.csuohio.edu>
Author
|
Added the |
Collaborator
Command Bot: Processing... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2942
Summary
Completes the continuous, angle-producing math functions from the acceptance plan in #2942 (
sin, cos, tan, asin, acos, atan, sqrt, exp, log) for C++ and Python: it adds the functions that were not yet supported, and documents and tests the full set.lib/Frontend/nvqpp/ConvertExpr.cpp): lowering forstd::asin,std::acos,std::atan. The other angle functions were already supported.python/cudaq/kernel/ast_bridge.py): addsnp.tan,np.asin,np.acos,np.atan,np.logto the supported NumPy functions and lowers them to the matchingmathdialect ops (real-valued; complex inputs raise).Against the acceptance plan
docs/sphinx/specification/cudaq/kernels.rst).test_kernel_float.py), plus a FileCheck lowering test (test/AST-Quake/math_functions.cpp) covering double and float.ry(2*asin(sqrt(p)))prepares a state with P(|1>) = p, verified by sampling.Testing
Built from source in the
cuda-quantum-devcontainer. The new tests pass, the existingtest_kernel_float.pysuite still passes, and the FileCheck test passes viacudaq-quake | cudaq-opt | FileCheck.Note
I'm aware of #4680, which addresses the same issue. This PR takes a similar core approach and additionally includes the documentation and the executed gate-parameter test from the acceptance plan.
AI usage
I used Claude as a coding assistant to help draft this change. I built CUDA-Q from source, ran and verified the tests, and reviewed the full patch before submitting.