Create `SmallView` to avoid `SmallList` copies by TysonRayJones · Pull Request #754 · QuEST-Kit/QuEST · GitHub
Skip to content

Create SmallView to avoid SmallList copies#754

Merged
TysonRayJones merged 4 commits into
few-qubit-optimisationfrom
small-list-view
May 27, 2026
Merged

Create SmallView to avoid SmallList copies#754
TysonRayJones merged 4 commits into
few-qubit-optimisationfrom
small-list-view

Conversation

@TysonRayJones

@TysonRayJones TysonRayJones commented May 23, 2026

Copy link
Copy Markdown
Member

Here, we alias

using SmallView = const SmallList&;

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 SmallView is tentative and chosen to not change line lengths; clearer choices include SmallListView, 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 SmallList copies?" - 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.

@TysonRayJones TysonRayJones requested a review from otbrown May 23, 2026 19:48
This was referenced May 24, 2026
@otbrown

otbrown commented May 25, 2026

Copy link
Copy Markdown
Collaborator

@TysonRayJones

Copy link
Copy Markdown
Member Author

Agreed that it's a huge shame to cause more indirection, but the visual clutter of const SmallList& also damages readability. I do see the alaising of bah = const T& in some open source works, like here, but there the name is more explicit.

What about...

  • renaming SmallList to List64
  • renaming SmallView to ConstList64

The relationship is now very explicit; ConstList64 looks just like a list you cannot modify. And indeed that is all the reader should care about - the fact that it is also a reference is only because of the copy optimisation and irrelevant to function semantics.

(Btw I am also open to alternative names to SmallList / List64, such as IntList, etc. The suffix View was terrible in hindsight, since it invites a misinterpretation of a distinct type/object, and it's astonishing that a copy ctor back to a SmallList exists)

@otbrown

otbrown commented May 26, 2026

Copy link
Copy Markdown
Collaborator

Hi Tyson, that sounds like a reasonable compromise to me. I definitely like List64 a lot more than SmallList!

@TysonRayJones

Copy link
Copy Markdown
Member Author

@TysonRayJones TysonRayJones merged commit a41fe98 into few-qubit-optimisation May 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants