-
Notifications
You must be signed in to change notification settings - Fork 25
Description
Dictionaries.jl is an interesting library aiming to make dictionaries that behave more like arrays. Such dictionaries have several nice benefits, including:
- Fast iteration over keys/values/pairs
- Comfortable interface for common array operations like broadcasting (
abs.(dict)), sorting (sort(dict),sortperm(dict), in-place manipulationdict *= 0.9and 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 - Easy high-level parallelization using
Base.Threadsand the@threadsmacro.
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
PauliRotationgates. - 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.