Skip to content

Dictionaries.jl optimized for PauliRotations #87

@MSRudolph

Description

@MSRudolph

Dictionaries.jl is an interesting library aiming to make dictionaries that behave more like arrays. Such dictionaries have several nice benefits, including:

  1. Fast iteration over keys/values/pairs
  2. Comfortable interface for common array operations like broadcasting (abs.(dict)), sorting (sort(dict), sortperm(dict), in-place manipulation dict *= 0.9 and tokenization. The latter allows manipulating elements by performing only a single hash. See, for example, this Julia issue: julep/rfc: proposal for unified Dict get/insert/has interface JuliaLang/julia#12157
  3. Easy high-level parallelization using Base.Threads and the @threads macro.

Using Dictionaries.jl dicts has been brought up in #58, and would have several obvious benefits for gate such as Clifford gates or Pauli noise gates. At the same time, our most common gate type are PauliRotation gates, and there the advantages are not as clear-cut.

Challenges:
My attempts at writing apply functions for the currently most common gate - PauliRotation - have had limited success (see answer below). At the scale of dozens of Pauli strings, I see Dictionaries.jl dicts starting to be slower than Base.Dict, mostly because insertion of elements can be substantially slower. This likely mean that highly-branching gates are even worse with Dictionaries.jl dicts, but our focus should be on the most common gates. The potential benefits here are great.

Concrete goals:

  • Prototype a gate application function such as the one below for PauliRotation gates.
  • Showcase that it is not slower at scale than our current Base.Dict code at a variety of circuits. Given my experiences, the trend of not slowing down beyond the current code should hold up to runtimes of tens of minutes.
  • Finding trade-offs between Base.Dict and Dictionaries.jl dicts is good. If some cases are faster and others are slower, we can still consider supporting both.

Metadata

Metadata

Assignees

No one assigned

    Labels

    performanceFeature improving performanceunitaryHackunitaryHack 2025

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions