A high-throughput and memory-efficient inference and serving engine for LLMs
Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git
Synced Nov 6, 10:45 UTC
fix(cpu): add null check for aligned_alloc in ScratchPadManager (#37369)
Signed-off-by: yassha <50112520+yassha@users.noreply.github.com>
yassha committed
Mar 19, 2026 at 10:45 UTC
199f914183e1f50f0a63a7fa0dd9b025952d8689
1 file changed
+4
-1
csrc/cpu/utils.cpp
+4
-1
@@ -173,10 +173,13 @@ ScratchPadManager::ScratchPadManager() : size_(0), ptr_(nullptr) {
173
void ScratchPadManager::realloc(size_t new_size) {
174
new_size = round(new_size);
175
if (new_size > size_) {
176
+ void* new_ptr = std::aligned_alloc(64, new_size);
177
+ TORCH_CHECK(new_ptr != nullptr,
178
+ "ScratchPadManager: aligned_alloc failed for size ", new_size);
179
if (ptr_ != nullptr) {
180
std::free(ptr_);
181
}
179
- ptr_ = std::aligned_alloc(64, new_size);
182
+ ptr_ = new_ptr;
183
size_ = new_size;
184
}
185
}