Skip to content

sycl: Add more debug prints #13640

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Rbiessy
Copy link
Collaborator

@Rbiessy Rbiessy commented May 19, 2025

This adds more debugging prints related to the operations being run. scope_op_debug_print is introduced to print the "call ..." and "call ... done" logs in a single line.
This adds more information for all the operations and its destination and input tensors: the tensor type, its number of elements, stride sizes and whether the tensor is strided (i.e. non-contiguous) or permuted.
For mul_mat this also add some debug prints when conversations kernels are called from and to fp16, fp32 and quantized types.
This also adds debugging prints for a few operations that were missing it.

The output for llama-2-7b.Q4_0 PP and TG is added here as an example:

@github-actions github-actions bot added ggml changes relating to the ggml tensor library for machine learning SYCL https://en.wikipedia.org/wiki/SYCL - GPU programming language labels May 19, 2025
Copy link
Collaborator

@qnixsynapse qnixsynapse left a comment

Choose a reason for hiding this comment

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

Nice.
Is it possible to extend this to backend interface functions as well such as init, set, memset, clear, reset, etc?

@Rbiessy
Copy link
Collaborator Author

Rbiessy commented May 22, 2025

Nice. Is it possible to extend this to backend interface functions as well such as init, set, memset, clear, reset, etc?

I added some more logs and updated the example in the PR description. Note I am not reusing scope_op_debug_print everywhere as I wanted to make the difference between logs coming from the llama backend (like the functions you mentioned) and logs coming from the model (like operations that are run). I added some [OP] tag in the log to distinct between the 2.

Copy link
Collaborator

@Alcpz Alcpz left a comment

Choose a reason for hiding this comment

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

LGTM. If logs get too noisy we can implement a couple of levels to the debug variable in the future to either print ops or API calls.

Copy link
Collaborator

@qnixsynapse qnixsynapse left a comment

Choose a reason for hiding this comment

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

LGTM

@Rbiessy
Copy link
Collaborator Author

Rbiessy commented May 23, 2025

I switched from using std::string to std::string_view to avoid any cost associated with std::string. As I measured the PR wasn't enough to impact performance but a small reproducer showed more instructions generated. With std::string_view that is not the case anymore, see f1 (using macro) and f2 (using scope_dbg_print) are identical: https://gcc.godbolt.org/z/5T84n5rzs
I'll wait until Monday to merge this if there are no other comments.

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 SYCL https://en.wikipedia.org/wiki/SYCL - GPU programming language
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants