Skip to content

Bug: Dimension mismatch when slicing some bonds #58

@brenjohn

Description

@brenjohn

I came across an example of a dsl file where slicing 4 bonds works fine but slicing 5 bonds gives the following error:

ERROR: LoadError: BoundsError: attempt to access 2-element Vector{ComplexF32} at index [3:3]
Stacktrace:
 [1] throw_boundserror(A::Vector{ComplexF32}, I::Tuple{UnitRange{Int64}})
   @ Base ./abstractarray.jl:691
 [2] checkbounds
   @ ./abstractarray.jl:656 [inlined]
 [3] view(A::Vector{ComplexF32}, I::UnitRange{Int64})
   @ Base ./subarray.jl:177
 [4] macro expansion
   @ ~/Code/QXContexts/QXContexts.jl/src/contexts/base.jl:115 [inlined]

I've checked with both QXContexts versions on master and simulation-refactor branches and the issue exists in both. It's not clear to me what's causing the issue yet. I've added the example dsl files here. Running the following should reproduce the error:

using QXContexts

dsl_file   = "./examples/sycamore/sycamore_53_4_0.qx"
data_file  = "./examples/sycamore/sycamore_53_4_0.jld2"

cg, _ = parse_dsl_files(dsl_file, data_file)
ctx = QXContext{Array{ComplexF32}}(cg)

bitstring = [true for _ in 1:53]

slice_params = params(cg, ViewCommand)
num_slices = 5
dims = map(x -> slice_params[Symbol("v$(x)")]::Int, 1:num_slices)
slices = CartesianIndices(Tuple(dims))
slice = slices[65] # using slice[64] works

ctx(bitstring, slice)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions