Skip to content

Local SWAP Fusion via `applyMultiSwap()#795

Open
VinaYrdx wants to merge 6 commits into
QuEST-Kit:develfrom
VinaYrdx:main
Open

Local SWAP Fusion via `applyMultiSwap()#795
VinaYrdx wants to merge 6 commits into
QuEST-Kit:develfrom
VinaYrdx:main

Conversation

@VinaYrdx

Copy link
Copy Markdown

Submission: Local SWAP Fusion via applyMultiSwap()

I have implemented the local (non-distributed) SWAP fusion described in this issue.

Fork: https://github.com/VinaYrdx/QuEST
Branch: main
Key commit: e7a3d71

What was implemented

  • New public API function applyMultiSwap(Qureg, vector<int>, vector<int>) in operations.h + operations.cpp
  • O(k) qubit permutation via disjoint transposition composition in cpu_statevec_multiSwap_fused_sub()
  • Single O(2^n) pass with involution guard (j > i) — no visited array needed
  • Full 3-layer dispatch: API → localiser → accelerator → CPU subroutine
  • Graceful fallback to sequential applySwap() for distributed/GPU quregs

Benchmark (n=24, single-threaded, OpenMP disabled)

k (pairs) Sequential Fused Speedup
3 0.229s 0.097s 2.36x
5 0.458s 0.163s 2.82x
8 0.433s 0.214s 2.02x

This complements PR #786's distributed case — together they cover both local and distributed SWAP fusion.

@VinaYrdx

Copy link
Copy Markdown
Author

Submitted PR #795 implementing local (non-distributed) SWAP fusion via applyMultiSwap().

Benchmark at n=24 (single-threaded): 2.36x–2.82x speedup over sequential SWAPs. Full details in the PR.

@TysonRayJones

Copy link
Copy Markdown
Member

Check your diff! You've accidentally committed your build files

@VinaYrdx

Copy link
Copy Markdown
Author

Check your diff! You've accidentally committed your build files

Apologies for that. I've added a .gitignore and verified no build artifacts are tracked in repo. The diff should be clean now :)

@TysonRayJones

Copy link
Copy Markdown
Member

It looks like you worked out of the main branch, and are now committing to the devel branch, causing a conflict. Can you please migrate your diff to devel? (An AI should be able to help with this). Presently, I cannot trigger the CI tests due to the conflict.

Note that the unitaryHACK issue #595 has been awarded, so alas this PR isn't eligible for a prize. It is however a very useful external contribution - it's a great idea to add a fully local function, which had somehow not occurred to me! 🎉

We'd happily work with you to get this integrated, and your name added to the QuEST external contributor list. If you can switch over your changes to devel, we can do any remaining testing and cleanup

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