Skip to content

Conversation

@ggerganov
Copy link
Member

@ggerganov ggerganov commented Mar 12, 2024

Running on master with thread-sanitizer enabled produces UB warnings:

./bin/test-quantize-fns
Testing iq3_s
/Users/ggerganov/development/github/llama.cpp/ggml-quants.c:9389:79: runtime error: left shift of 36408 by 16 places cannot be represented in type 'int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/ggerganov/development/github/llama.cpp/ggml-quants.c:9389:79 in 
/Users/ggerganov/development/github/llama.cpp/ggml-quants.c:9398:79: runtime error: left shift of 34588 by 16 places cannot be represented in type 'int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/ggerganov/development/github/llama.cpp/ggml-quants.c:9398:79 in 
Testing iq2_s
/Users/ggerganov/development/github/llama.cpp/ggml-quants.c:9028:79: runtime error: left shift of 36408 by 16 places cannot be represented in type 'int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/ggerganov/development/github/llama.cpp/ggml-quants.c:9028:79 in 
/Users/ggerganov/development/github/llama.cpp/ggml-quants.c:9037:79: runtime error: left shift of 34588 by 16 places cannot be represented in type 'int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/ggerganov/development/github/llama.cpp/ggml-quants.c:9037:79 in 

I doubt this causes any real issues, but fixing it to make the thread sanitizer happy

@ggerganov ggerganov force-pushed the gg/fix-thread-sanitizer branch from 993e2cd to 831075c Compare March 12, 2024 10:47
@ggerganov ggerganov requested a review from ikawrakow March 12, 2024 10:50
Copy link
Contributor

@ikawrakow ikawrakow left a comment

Choose a reason for hiding this comment

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

Did the UB sanitizer check out the assembly just in case?

It is funny because some compilers cannot be forced to do the shift on 16-bit ints, no matter what you do. Notably, the Metal compiler is one of those.

@ggerganov ggerganov merged commit 184215e into master Mar 12, 2024
@ggerganov ggerganov deleted the gg/fix-thread-sanitizer branch March 12, 2024 11:49
NeoZhangJianyu pushed a commit to NeoZhangJianyu/llama.cpp that referenced this pull request Mar 12, 2024
jordankanter pushed a commit to jordankanter/llama.cpp that referenced this pull request Mar 13, 2024
hodlen pushed a commit to hodlen/llama.cpp that referenced this pull request Apr 1, 2024
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.

3 participants