Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong site override when calling replace! on AbstractQuantum with already existing index #244

Open
mofeing opened this issue Nov 11, 2024 · 0 comments
Labels
bug Something isn't working
Milestone

Comments

@mofeing
Copy link
Member

mofeing commented Nov 11, 2024

using Tenet
using LinearAlgebra

mat = reshape(LinearAlgebra.I(4), 2, 2, 2, 2)
gate = Quantum(mat, [site"2", site"3", site"2'", site"3'"])

oinds = Dict(site"2" => :B, site"3" => :C)

tmpinds = Dict(site => gensym(:tmp) for site in sites(gate; set=:inputs))
replace!(gate, [inds(gate; at=site) => i for (site, i) in tmpinds])

# HERE IS THE BUG
replace!(gate, [inds(gate; at=site) => i for (site, i) in oinds])

The result of gate.sites is

julia> gate.sites
Dict{Site, Symbol} with 4 entries:
  3  => :C
  3' => Symbol("##tmp#272")
  2' => Symbol("##tmp#271")
  2  => :C

when it should be

julia> gate.sites
Dict{Site, Symbol} with 4 entries:
  3  => :C
  3' => Symbol("##tmp#272")
  2' => Symbol("##tmp#271")
  2  => :B

In simple_update!, I've fixed it by calling it twice with some temporary indices in between, but we have to fix it to make it work without this workaround.

replace!(gate, [inds(gate; at=site) => gensym() for (site, i) in oinds])
replace!(gate, [inds(gate; at=site) => i for (site, i) in oinds])
@mofeing mofeing added the bug Something isn't working label Nov 11, 2024
@mofeing mofeing added this to the 0.8 milestone Dec 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant