[QDP] Pr1 phase kernel opt#1386
Open
aloha1357 wants to merge 3 commits into
Open
Conversation
ryankert01
requested changes
Jun 8, 2026
ca90282 to
29ecb19
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related Issues
related #1385
Changes
Why
The original phase encoding and IQP encoding kernels suffered from GPU thread divergence due to conditional branching (
if (val != 0.0)orif ((x >> i) & 1U)). Furthermore, the normalization factor (norm_factor) was being redundantly calculated inside the GPU kernel, consuming extra cycles. Eliminating these inefficiencies significantly improves the kernel's execution speed on the GPU.How
phase.cuandiqp.cu, theifconditions checking bit states were replaced with boolean arithmetic casting and multiplication (e.g.,phases[bit] * (double)((idx >> bit) & 1U)). This ensures that all threads in a warp follow the exact same instruction path, eliminating warp divergence.norm_factorcalculation to the host (CPU) before launching the kernel inphase.cu, passing the result as an immutable parameter.Benchmark Results
Environment: Dev Machine (NVIDIA RTX 4060)
Configuration: Qubits (N): 14, Batch Size: 128, Iterations: 5
phase.cuChecklist