Repository navigation
Fix mixed control values in qjit capture - #10356
Open
JerryChen97 wants to merge 9 commits into
Open
JerryChen97 wants to merge 9 commits into
JerryChen97 wants to merge 9 commits into
Conversation
[sc-133997] Assisted-by: Codex
[sc-133997] Assisted-by: Codex
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #10356 +/- ##
=======================================
Coverage 99.44% 99.44%
=======================================
Files 617 617
Lines 68037 68044 +7
=======================================
+ Hits 67656 67664 +8
+ Misses 381 380 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
[sc-133997] Assisted-by: Codex
albi3ro
reviewed
Oct 20, 2026
albi3ro
reviewed
Oct 20, 2026
| control_values = [bool(control_values)] | ||
| elif isinstance(control_values, tuple): | ||
| control_values = [bool(v) for v in control_values] | ||
| control_values = [v if math.is_abstract(v) else bool(v) for v in control_values] |
Contributor
There was a problem hiding this comment.
Could we convert to a bool dtype here to handle things like control_values=(0,1) which would default to int?
paul0403
approved these changes
Oct 20, 2026
paul0403
left a comment
Member
There was a problem hiding this comment.
LGTM from primitive invar/param perspective, approving pending on Christina's comments
[sc-133997] Assisted-by: Codex
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.
Context
Under
qp.qjit(capture=True, skip_preprocess=True),qp.ctrlmishandlescontrol_valuesthat mix Python Booleans with traced values. Depending on the input form, PennyLane can select the wrong array interface, attempt to callbool()on a tracer, or store a tracer in static primitive metadata.Changes
Infer the array interface from all control values.
Preserve traced values when normalizing tuples.
Pass all callable control values as Boolean operands:
Remove the static
control_valuesprimitive parameter.Update the primitive implementation, interpreter, tape conversion, and regression tests.
The public
qp.ctrlAPI is unchanged.Compatibility and landing plan
This changes the internal capture contract for callable controls. PennyLane and Catalyst therefore need coordinated updates; either new implementation is incompatible with the other repository's previous representation.
Proposed order:
PennyLaneAI/catalyst#3350 and PennyLaneAI/catalyst#3365 address separate decomposition issues and are outside this PR's scope.
Validation
default.qubit, plus static and nested controls.TestDeviceLevelSpecs.test_complexhas a temporary strictxfaillimited to the old Catalyst handler's missing-control_valueserror. It was verified as XFAIL with the upstream handler, strict XPASS with the companion change, and passing with the companion change under--runxfail. The marker can be removed once a compatible Catalyst nightly is available.tach check, andgit diff --checkpassed.tachreported three pre-existing unused-ignore warnings.Related issue
[sc-133997]
AI assistance: Prepared with AI assistance at the contributor's request. Human review remains in progress.