Provide global toggles for static control flow folding#2912
Merged
Conversation
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.
rniczh
approved these changes
Jun 4, 2026
paul0403
approved these changes
Jun 5, 2026
isaacdevlugt
reviewed
Jun 5, 2026
isaacdevlugt
left a comment
Contributor
There was a problem hiding this comment.
Nice! Just added some docs suggestions :)
Co-authored-by: Isaac De Vlugt <34751083+isaacdevlugt@users.noreply.github.com>
isaacdevlugt
reviewed
Jun 5, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
isaacdevlugt
reviewed
Jun 8, 2026
Co-authored-by: Isaac De Vlugt <34751083+isaacdevlugt@users.noreply.github.com>
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>
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.
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
CompileOptionsin the future (for example).[sc-121161]