Skip to content

Replace vector<int> with stack-list#743

Merged
TysonRayJones merged 12 commits into
develfrom
stack-qubit-lists
May 17, 2026
Merged

Replace vector<int> with stack-list#743
TysonRayJones merged 12 commits into
develfrom
stack-qubit-lists

Conversation

@TysonRayJones
Copy link
Copy Markdown
Member

@TysonRayJones TysonRayJones commented May 10, 2026

This is to circumvent the std::vector performance overheads visible in few-qubit simulation (responsible for a performance regression from v3; see #720), and also so that qubit lists can be passed directly to CUDA kernels without conversion (as explored in #739).

which needs the attention of James, r.e. his migration away from 'devints'
to get GPU backend functional, though we should ideally switch to James' design
@TysonRayJones
Copy link
Copy Markdown
Member Author

@otbrown Do you have any thoughts about small_list.hpp? It almost seamlessly replaces std::vector<int> in the QuEST middle-end, and speeds up few-qubit simulation (eliminating all vector/heap allocs) without giving up copy-by-value safety.

Just like the (c|g)pu_qcomp overhaul, it gives us two birds with one stone, benefitting both CPU and GPU simulation; James' optimisations in #739 can (hopefully!!) leverage the list, so kernels can receive SmallList directly with no conversion layer.

@otbrown
Copy link
Copy Markdown
Collaborator

otbrown commented May 11, 2026

Philosophically I hate it, but it's correct and it's faster, so have at it! I work in HPC centre, not a philosophy... place

to match STL containers (like remaining std::vector of other types), and existing code which expected size_t from qubitlist.size()
all to avoid a single, stoopid, "var _ unused" compiler warning, bah!
which was a cute design, but a pitfall and readability nightmare!
@TysonRayJones
Copy link
Copy Markdown
Member Author

Hehe I share the feeling that it's regrettable, but at least meshes nicely with James' GPU optimisations. I note the move to std::vector<int> to SmallList above does improve few-qubit performance, but is not sufficient to reach v3 performance. I will add the final optimisations (mostly avoiding re-initialisation of internal objects) in another PR for cleanliness.


using devints = thrust::device_vector<int>;

devints getDevInts(SmallList h_list) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be made redundant by James' work

@TysonRayJones
Copy link
Copy Markdown
Member Author

Tests pass in all configurations, except that the cuQuantum backend has not been run, which (for convenience) I aim to do via the paid CI runner before the v4.3 release is finalised.

@TysonRayJones TysonRayJones merged commit f1606da into devel May 17, 2026
130 checks passed
@TysonRayJones TysonRayJones deleted the stack-qubit-lists branch May 17, 2026 21:49
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