Skip to content

Provide global toggles for static control flow folding#2912

Merged
dime10 merged 12 commits into
mainfrom
trace-time-unrolling
Jun 8, 2026
Merged

Provide global toggles for static control flow folding#2912
dime10 merged 12 commits into
mainfrom
trace-time-unrolling

Conversation

@dime10

@dime10 dime10 commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

A static conditional can be evaluated trivially at trace time since it doesn't really have a reason to exist. Static loops still serve the purpose of compacting the program, but will introduce additional dynamic variables. In some conditions resolving these at trace time can also be desirable.

The toggle is global because in the context where the decision is made we don't have access to QJIT-instance specific compilation options. This is the simplest way forward, although alternatives could expand the EvaluationContext with a reference to the currently active CompileOptions in the future (for example).

[sc-121161]

dime10 added 3 commits June 3, 2026 13:36
A static conditional can be evaluated trivially at trace time since it
doesn't really have a reason to exist. Static loops still serve the
purpose of compacting the program, but will introduce additional dynamic
variables. In some conditions resolving these at trace time can be
desirable.

The toggle is global because in the context where the decision is made
we don't have access to QJIT-instance specific compilation options. This
is the simplest way forward, although alternatives could expand the
EvaluationContext with a QJIT's CompileOptions for example.
@dime10 dime10 requested review from a team and isaacdevlugt June 3, 2026 18:23

@isaacdevlugt isaacdevlugt 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.

Nice! Just added some docs suggestions :)

Comment thread doc/releases/changelog-dev.md
Comment thread doc/releases/changelog-dev.md
Comment thread frontend/catalyst/__init__.py Outdated
Comment thread frontend/catalyst/__init__.py Outdated
Comment thread frontend/catalyst/__init__.py Outdated
Co-authored-by: Isaac De Vlugt <34751083+isaacdevlugt@users.noreply.github.com>
Comment thread doc/releases/changelog-dev.md Outdated
@codecov

codecov Bot commented Jun 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.94%. Comparing base (55f12dd) to head (8159743).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2912   +/-   ##
=======================================
  Coverage   96.94%   96.94%           
=======================================
  Files         166      165    -1     
  Lines       19067    19073    +6     
  Branches     1760     1763    +3     
=======================================
+ Hits        18485    18491    +6     
  Misses        430      430           
  Partials      152      152           

☔ 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.

Comment thread doc/releases/changelog-dev.md
dime10 and others added 2 commits June 8, 2026 10:18
Co-authored-by: Isaac De Vlugt <34751083+isaacdevlugt@users.noreply.github.com>
@dime10 dime10 merged commit ecf8b76 into main Jun 8, 2026
37 of 38 checks passed
@dime10 dime10 deleted the trace-time-unrolling branch June 8, 2026 15:05
JerryChen97 pushed a commit to DennisWayo/pennylane that referenced this pull request Jun 9, 2026
…icates (PennyLaneAI#9630)

**Context:**
Recently Catalyst [started evaluating static conditionals at tracing
time in legacy path](PennyLaneAI/catalyst#2912).
This means in cases where the conditional predicate is static, only the
correct branch will be taken, and no catalyst `cond` operators will be
traced.

In RS decomp, there is one place where the catalyst `cond` operator was
unconditionally queried and queued into a new tape.

**Description of the Change:**
Only query the catalyst `cond` operator when the predicate is not
static.

**Benefits:**
Unblocks work by fixing a test.
sarababaeii pushed a commit that referenced this pull request Jun 10, 2026
A static conditional can be evaluated trivially at trace time since it
doesn't really have a reason to exist. Static loops still serve the
purpose of compacting the program, but will introduce additional dynamic
variables. In some conditions resolving these at trace time can also be
desirable.

The toggle is global because in the context where the decision is made
we don't have access to QJIT-instance specific compilation options. This
is the simplest way forward, although alternatives could expand the
EvaluationContext with a reference to the currently active
`CompileOptions` in the future (for example).

[sc-121161]

---------

Co-authored-by: Isaac De Vlugt <34751083+isaacdevlugt@users.noreply.github.com>
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.

4 participants