Skip to content

Controlled regions keeps work_wire_type - #3366

Merged
astralcai merged 5 commits into
mainfrom
ctrl-region-work-wire-type
Oct 21, 2026
Merged

astralcai merged 5 commits into
mainfrom
ctrl-region-work-wire-type

Conversation

@astralcai

@astralcai astralcai commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Context:

Follow-up to PennyLaneAI/pennylane#10355, adds work_wire_type to the controlled region primitive. Note that this change is purely in the frontend.

Description of the Change:

Benefits:

Possible Drawbacks:

Related GitHub Issues:
[sc-134199]

Comment thread doc/releases/changelog-dev.md Outdated
Comment thread frontend/catalyst/from_plxpr/qref_jax_primitives.py
Comment thread frontend/test/pytest/from_plxpr/test_from_plxpr.py Outdated

@mudit2812 mudit2812 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks great. Just one testing suggestion, otherwise ready to approve

Co-authored-by: Mudit Pandey <18223836+mudit2812@users.noreply.github.com>
astralcai and others added 2 commits October 21, 2026 09:45
)

Remove the two xfails blocked by PennyLane
#[10156](PennyLaneAI/pennylane#10156). Install
its branch after each `make frontend` in CI to test the fix.

Developed with assistance from OpenAI Codex.

[[sc-130866](https://app.shortcut.com/xanaduai/story/130866)]

---------

Co-authored-by: Astral Cai <astral.cai@xanadu.ai>
@codecov

codecov Bot commented Oct 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.14%. Comparing base (4aedc4b) to head (96925f9).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3366   +/-   ##
=======================================
  Coverage   96.14%   96.14%           
=======================================
  Files         177      177           
  Lines       21582    21582           
  Branches     2153     2153           
=======================================
  Hits        20751    20751           
  Misses        643      643           
  Partials      188      188           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@astralcai
astralcai merged commit 8deabe8 into main Oct 21, 2026
38 checks passed
@astralcai
astralcai deleted the ctrl-region-work-wire-type branch October 21, 2026 14:02
JerryChen97 added a commit that referenced this pull request Oct 21, 2026
Fixes captured `qp.ctrl` callables with mixed static and runtime Boolean
control values. The interpreter reads control values after the control
wires, and lowering passes them to the existing SSA `ctrlvals`.

Requires PennyLaneAI/pennylane#10356. The new operand layout also
applies to static controls, so the two changes need coordinated merging
and compatible dependency versions. This overlaps #3366's
`work_wire_type` changes.

Validation:

- 21 targeted Catalyst tests passed with the matching PennyLane patch,
including all four reported cases for both Boolean inputs against
`default.qubit`.
- SSA FileCheck passed, including existing static-control checks.
- Formatting passed; Pylint has no new findings.

Local execution used native artifacts from `aa5eb08a7`. The branch is
now based on `631b95e4a`; the Python patch is unchanged, but the newer
native passes were not rebuilt locally.

[sc-133997]

Assisted by Codex. WIP; human review is in progress.

---------

Co-authored-by: paul0403 <paulhaochen.wang@gmail.com>
HelioXv022 pushed a commit to HelioXv022/pennylane that referenced this pull request Oct 22, 2026
## Context

Under `qp.qjit(capture=True, skip_preprocess=True)`, `qp.ctrl`
mishandles `control_values` that mix Python Booleans with traced values.
Depending on the input form, PennyLane can select the wrong array
interface, attempt to call `bool()` 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:

  ```text
  ctrl_transform(*consts, *args, *control_wires, *control_values, ...)
  ```

- Remove the static `control_values` primitive parameter.
- Update the primitive implementation, interpreter, tape conversion, and
regression tests.

The public `qp.ctrl` API 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:

1. Land PennyLaneAI#10355 with
[PennyLaneAI/catalyst#3366](PennyLaneAI/catalyst#3366).
2. Rebase and land this change with its matching Catalyst update and
compatible dependency pins.


[PennyLaneAI/catalyst#3350](PennyLaneAI/catalyst#3350)
and
[PennyLaneAI/catalyst#3365](PennyLaneAI/catalyst#3365)
address separate decomposition issues and are outside this PR's scope.

## Validation

- 20 targeted PennyLane tests passed, covering static and dynamic
operand layouts, primitive execution, interpreter forwarding, tape
conversion, dynamic shapes, constants, and mixed operator-instance
lists.
- 21 targeted Catalyst tests passed with the matching local change,
including the four reported cases for both runtime Boolean values
against `default.qubit`, plus static and nested controls.
- Catalyst SSA FileCheck passed, including its existing static-control
checks.
- `TestDeviceLevelSpecs.test_complex` has a temporary strict `xfail`
limited to the old Catalyst handler's missing-`control_values` error. 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.
- PennyLane source and test Pylint, formatting, `tach check`, and `git
diff --check` passed. `tach` reported three pre-existing unused-ignore
warnings.
- Full local test suites were not run.

## Related issue

[sc-133997]

**AI assistance:** Prepared with AI assistance at the contributor's
request. Human review remains in progress.

---------

Co-authored-by: Christina Lee <christina@xanadu.ai>
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.

5 participants