Skip to content

Add lazy option to QuantumOpticsRepr#83

Open
DennisWayo wants to merge 3 commits into
qojulia:mainfrom
DennisWayo:lazy-quantumoptics-repr
Open

Add lazy option to QuantumOpticsRepr#83
DennisWayo wants to merge 3 commits into
qojulia:mainfrom
DennisWayo:lazy-quantumoptics-repr

Conversation

@DennisWayo

@DennisWayo DennisWayo commented Jun 11, 2026

Copy link
Copy Markdown

This PR adds a small option to QuantumOpticsRepr so downstream packages can ask for a lazy QuantumOptics representation without changing the current default behavior.

The main change is that QuantumOpticsRepr now carries a lazy::Bool field:

julia> QuantumOpticsRepr()
QuantumOpticsRepr(2, false)

julia> QuantumOpticsRepr(lazy=true)
QuantumOpticsRepr(2, true)

julia> QuantumOpticsRepr(cutoff=4, lazy=true)
QuantumOpticsRepr(4, true)

The default remains eager conversion (lazy=false), and the existing positional cutoff form is preserved:

julia> QuantumOpticsRepr(4)
QuantumOpticsRepr(4, false)

This PR is intentionally only the interface piece. The actual lazy conversion behavior is implemented in the companion QuantumSymbolics PR:

QuantumSavory/QuantumSymbolics.jl#201

Why this is useful:

  • keeps the public representation choice in QuantumInterface.jl, where QuantumOpticsRepr is defined;
  • lets existing callers keep getting the same eager conversion behavior;
  • gives packages like QuantumSymbolics.jl a clean way to opt into LazySum, LazyProduct, and LazyTensor construction.

Tests added:

  • default QuantumOpticsRepr() keeps cutoff == 2 and lazy == false;
  • QuantumOpticsRepr(4) still works as before;
  • QuantumOpticsRepr(lazy=true) and QuantumOpticsRepr(cutoff=4, lazy=true) store the requested values.

Local test command:

julia --project=. -e 'using Pkg; Pkg.test()'

OSS Contributions
PennyLaneAI/pennylane#9566
PennyLaneAI/pennylane#9604
https://www.linkedin.com/posts/activity-7443523751436091392-depM?utm_source=share&utm_medium=member_desktop&rcm=ACoAABfS9T0BJJPP6KT13py3QtCdMEGtOb3Q3PE

AI Use Disclosure: Code syntax was assisted by Codex model. All handwritten code and accompanying text were thoroughly reviewed and verified by me prior to submission. I retain full responsibility for the final contribution.

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.

1 participant