Add angle-producing math functions to kernels with docs and tests#4697
Add angle-producing math functions to kernels with docs and tests#4697LakshikkaNathan wants to merge 9 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
Command Bot: Processing... |
CI Summary (
|
| Job | Result |
|---|---|
binaries |
⏩ skipped |
build_and_test |
✅ success |
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) | ✅ success | 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 | ❔ in_progress | view |
| Retrieve PR info | ✅ success | view |
✅ Required checks (6/6) — 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) | ✅ success | view |
Signed-off-by: Lakshikka Sithamparanathan <2922185@vikes.csuohio.edu>
Command Bot: Processing... |
sacpis
left a comment
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>
|
Thanks for the review, @sacpis! Addressed all the comments in |
Command Bot: Processing... |
Signed-off-by: Lakshikka Sithamparanathan <2922185@vikes.csuohio.edu>
|
Added the |
Command Bot: Processing... |
|
Thanks for running the tests. The failing |
Command Bot: Processing... |
Command Bot: Processing... |
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.