Skip to content

Add kernel math function support#4680

Open
LubuSeb wants to merge 2 commits into
NVIDIA:mainfrom
LubuSeb:codex/unitaryhack-cudaq-2942-math-functions
Open

Add kernel math function support#4680
LubuSeb wants to merge 2 commits into
NVIDIA:mainfrom
LubuSeb:codex/unitaryhack-cudaq-2942-math-functions

Conversation

@LubuSeb

@LubuSeb LubuSeb commented Jun 5, 2026

Copy link
Copy Markdown

Closes #2942.

Summary

  • add C++ AST lowering for asin, acos, and atan, including float overloads
  • add Python AST bridge lowering for real-valued NumPy tan, asin, acos, atan, and log
  • add focused C++ FileCheck and Python kernel tests for the newly covered math functions

Reproduction / scope

The bounty issue asks for continuous mathematical function support in CUDA-Q kernels. Existing C++ lowering already handled several functions through visitMathLibFunc; this change extends that same path for inverse trig functions. Python lowering already mapped selected NumPy calls through the AST bridge; this change adds the missing real-valued operations there while leaving untested complex inverse trig/log/tan support out of scope.

Minimality

This is limited to the existing lowering tables/switches and targeted tests. It does not refactor the frontend, broaden discrete-control support, or add backend-specific behavior.

Validation

  • python -m py_compile python/cudaq/kernel/ast_bridge.py python/tests/kernel/test_kernel_float.py
  • git diff --cached --check
  • Local standalone <cmath> syntax smoke check for the float overload names used by the new C++ test

Not run locally: CUDA-Q native lit/runtime tests, because the local environment does not have the CUDA-Q compiler/test toolchain installed.

AI assistance disclosure

I used AI assistance to inspect the codebase and draft parts of this change; I reviewed the final patch and validation results before submission.

@copy-pr-bot

copy-pr-bot Bot commented Jun 5, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

Signed-off-by: LubuSeb <187313664+LubuSeb@users.noreply.github.com>
@sacpis

sacpis commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

/ok to test 157f60f

Command Bot: Processing...

@github-actions

Copy link
Copy Markdown

CI Summary (push) — ❌ failed

Run #27292583323 · ✅ 5 · ⏩ 7 · ❌ 1 · ⛔ 0

❌ Failed or cancelled
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) ❌ failure view
Build and test (arm64, llvm, openmpi) / Dev environment (Debug) ✅ success view
Build and test (arm64, llvm, openmpi) / Dev environment (Python) ❌ failure 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 (3/6) — 3 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) ❌ failure view
Build and test (arm64, llvm, openmpi) / Dev environment (Debug) ✅ success view
Build and test (arm64, llvm, openmpi) / Dev environment (Python) ❌ failure view
Build and test (amd64, gcc12, openmpi) / Dev environment (Debug) ✅ success view
Build and test (amd64, gcc12, openmpi) / Dev environment (Python) ❌ failure view

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.

Mathematical functions support

2 participants