Skip to content

CUDA: fix race condition in FA vector kernels #13742

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

JohannesGaessler
Copy link
Collaborator

Fixes #13733 .

Looking at the code I added in #13584 again, I think I accidentally introduced a race condition. The mask is being written to shared memory anyways, so the synchronization between warps is achieved by each warp just checking all of the mask values, and then reducing skip within the warp. Each warp will come to the same conclusion regarding whether or not to execute the continue. However, warps are not guaranteed to execute the continue at the same time, and after they do they will write new values to maskf_shared which can in turn influence whether other warps will execute the continue, potentially causing the warps to become desynchronized.

@github-actions github-actions bot added Nvidia GPU Issues specific to Nvidia GPUs ggml changes relating to the ggml tensor library for machine learning labels May 24, 2025
@JohannesGaessler JohannesGaessler merged commit ffd0eae into ggml-org:master May 24, 2025
42 checks passed
@ggerganov
Copy link
Member

We should consider adding test-backend-ops tests that exercise this masking logic.

Nexesenex added a commit to Nexesenex/croco.cpp that referenced this pull request May 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ggml changes relating to the ggml tensor library for machine learning Nvidia GPU Issues specific to Nvidia GPUs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Misc. bug: Eval bug: Repetitive Output After Certain Token Count When Using -np > 1 in llama.cpp (Ver. b5468)
2 participants