Skip to content

Fix cudaq.control(...) type specialization bug#3860

Merged
taalexander merged 2 commits intoNVIDIA:mainfrom
taalexander:fix-control-veq-specialization
Feb 4, 2026
Merged

Fix cudaq.control(...) type specialization bug#3860
taalexander merged 2 commits intoNVIDIA:mainfrom
taalexander:fix-control-veq-specialization

Conversation

@taalexander
Copy link
Collaborator

Description

Fix a bug where controlled kernel calls failed with type mismatch errors when the kernel had both float and list[complex] parameters and accessed .real on complex values. Required to run the Krylov notebook in #3839.

The bug occurred during constant propagation in ApplySpecialization when veq argument types were specialized (un-relaxed from !quake.veq<?> to !quake.veq) but inner func.call operations still expected the dynamic type, causing "'func.call' op operand type mismatch" errors.

The fix adds hasCallWithDynamicVeq() to check if a function has any inner calls expecting !quake.veq<?>, and skips veq type specialization in those cases to avoid the type mismatch.

Copy link
Collaborator

@lmondada lmondada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect, thanks a lot for the fix. See the minor comment.

github-actions bot pushed a commit that referenced this pull request Feb 4, 2026
@github-actions
Copy link

github-actions bot commented Feb 4, 2026

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

Fix a bug where controlled kernel calls failed with type mismatch
errors when the kernel had both float and list[complex] parameters
and accessed .real on complex values.

The bug occurred during constant propagation in ApplySpecialization
when veq argument types were specialized (un-relaxed from !quake.veq<?>
to !quake.veq<N>) but inner func.call operations still expected the
dynamic type, causing "'func.call' op operand type mismatch" errors.

The fix adds hasCallWithDynamicVeq() to check if a function has any
inner calls expecting !quake.veq<?>, and skips veq type specialization
in those cases to avoid the type mismatch.

Changes:
- lib/Optimizer/Transforms/ApplyOpSpecialization.cpp: Add check to
  skip veq specialization when inner calls expect dynamic veq types
- test/Transforms/apply_ctrl_veq_type.qke: New MLIR regression test
- python/tests/kernel/test_control_negations.py: Remove xfail marker
  from test_control_float_list_complex_real_access
Replace boolean flag pattern with idiomatic MLIR WalkResult for
cleaner early termination when a dynamic veq type is found.
@taalexander taalexander force-pushed the fix-control-veq-specialization branch from 7c8b4d7 to 58e63cc Compare February 4, 2026 18:52
@taalexander taalexander enabled auto-merge (squash) February 4, 2026 18:53
@taalexander taalexander merged commit 71f14ec into NVIDIA:main Feb 4, 2026
192 checks passed
github-actions bot pushed a commit that referenced this pull request Feb 4, 2026
@bettinaheim bettinaheim added the bug fix To be listed under Bug Fixes in the release notes label Mar 12, 2026
@bettinaheim bettinaheim added this to the release 0.14.0 milestone Mar 12, 2026
@bettinaheim bettinaheim changed the title Fix cudaq.control() veq type specialization bug Fix cudaq.control(...) type specialization bug Mar 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug fix To be listed under Bug Fixes in the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants