Create SmallView to avoid SmallList copies#754
Conversation
|
Hi Tyson, I think it would be shame to leave performance on the table for want of a few characters. The hard part of these optimisations (that we might have wanted to avoid given the relatively small improvement) is in finding what needs to change -- you've done the hard part, so we may as well reap the benefit! To be honest, I would just use
I did find myself asking just now why |
|
Agreed that it's a huge shame to cause more indirection, but the visual clutter of What about...
The relationship is now very explicit; (Btw I am also open to alternative names to |
|
Hi Tyson, that sounds like a reasonable compromise to me. I definitely like |
Here, we alias
to avoid all superfluous qubit list copying (even though it's only a stack copy). This gives a (mostly seamless) performance benefit in few-qubit settings (about 30% below 8 qubits). Note the name
SmallViewis tentative and chosen to not change line lengths; clearer choices includeSmallListView,ConstSmallList,ListView,ConstList, etc.@otbrown How do you feel about this? It's an important optimisation if we really cared about restoring v3 few-qubit performance, but I am not sure if it outweighs the reader confusion. It's main utility might be merely to assuage future readers who say "why all these superfluous
SmallListcopies?" - but what a big penalty to readability! :P AI assures me this is a sufficiently conventional approach in HPC applications but I'm moderatelty unconvinced. What do you think? I could take or leave.