Fix cudaq.control(...) type specialization bug#3860
Merged
taalexander merged 2 commits intoNVIDIA:mainfrom Feb 4, 2026
Merged
Conversation
6e0339a to
7c8b4d7
Compare
lmondada
approved these changes
Feb 4, 2026
Collaborator
lmondada
left a comment
There was a problem hiding this comment.
Perfect, thanks a lot for the fix. See the minor comment.
|
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.
7c8b4d7 to
58e63cc
Compare
cudaq.control(...) type specialization bug
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.
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.