-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Fix Windows Null Pointer Bug and Enhance Memory Operations in ggml-sycl #14290
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
Conversation
- Replace generic error message with more specific information - Use %zu format specifier for size_t type - Add device ID to the error message - Simplify memory allocation code
…perations - Add null pointer check for tensor data on Windows platform - Implement proper memset operation in buffer clear function - Add get_tensor function and include null pointer check - Improve error handling and logging in SYCL operations
| GGML_SYCL_DEBUG("[SYCL] call %s", __func__); | ||
| } | ||
|
|
||
| static void ggml_backend_sycl_buffer_get_tensor(ggml_backend_buffer_t buffer, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function already exists
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Author has "AI dev" in their name. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I'm just curious to see if I would get an answer :D
| << ", line:" << __LINE__ << std::endl; | ||
| std::exit(1); | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't make sense and won't compile
| SYCL_CHECK( | ||
| CHECK_TRY_ERROR(ptr = (void *)sycl::malloc_device( | ||
| look_ahead_size, *qptr))); | ||
| void * ptr = sycl::malloc_device(look_ahead_size, *qptr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reason to remove these checks?
| if (tensor->data == nullptr) { | ||
| GGML_ABORT("Error: Tensor data pointer is null.\n"); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The backends assume tensor->data is valid at this point so this does not seem needed.
This pull request addresses a critical null pointer bug on the Windows platform within the
ggml-syclmodule. It also introduces improvements to memory operations for better stability and performance.Key Changes:
Null Pointer Check for Tensor Data:
memcpyoperation logic to include this safety mechanism.Improved Buffer Clear Function:
memsetoperation in the buffer clear function to ensure memory is correctly cleared before reuse, avoiding undefined behavior.New Helper Function: get_tensor:
ggml_backend_sycl_buffer_get_tensorwith an additional null pointer check to handle edge cases where tensor data might be null during retrieval.Enhanced Error Handling and Logging:
Code Refactoring:
These changes collectively enhance the robustness of the
ggml-syclimplementation, particularly on the Windows platform, while also improving overall code maintainability and debugging capabilities.