Spaces:
Running
Running
Jesse Gross
commited on
Commit
·
af16d74
1
Parent(s):
415b9fc
ggml: Don't assert fail when tensor data changes (llama/13222)
Browse filesThe following scenario will cause an assertion failure in the graph
allocator:
- Build and allocate a graph containing a tensor with a non-NULL data
pointer
- Build and allocate a new graph where that data is NULL
Result:
ggml-alloc.c:819: GGML_ASSERT(talloc->buffer_id >= 0) failed
This happens during revalidation because we think that memory should
have been previously allocated based on the current graph but in
reality the previous graph was different. In this situation, we
should do a full reallocation pass.
- ggml/src/ggml-alloc.c +4 -1
ggml/src/ggml-alloc.c
CHANGED
|
@@ -816,7 +816,10 @@ static void ggml_gallocr_init_tensor(ggml_gallocr_t galloc, struct ggml_tensor *
|
|
| 816 |
static bool ggml_gallocr_node_needs_realloc(ggml_gallocr_t galloc, struct ggml_tensor * node, struct tensor_alloc * talloc) {
|
| 817 |
size_t node_size = 0;
|
| 818 |
if (!node->data && !node->view_src) {
|
| 819 |
-
|
|
|
|
|
|
|
|
|
|
| 820 |
node_size = ggml_backend_buft_get_alloc_size(galloc->bufts[talloc->buffer_id], node);
|
| 821 |
}
|
| 822 |
return talloc->size_max >= node_size;
|
|
|
|
| 816 |
static bool ggml_gallocr_node_needs_realloc(ggml_gallocr_t galloc, struct ggml_tensor * node, struct tensor_alloc * talloc) {
|
| 817 |
size_t node_size = 0;
|
| 818 |
if (!node->data && !node->view_src) {
|
| 819 |
+
// If we previously had data but don't now then reallocate
|
| 820 |
+
if (talloc->buffer_id < 0) {
|
| 821 |
+
return false;
|
| 822 |
+
}
|
| 823 |
node_size = ggml_backend_buft_get_alloc_size(galloc->bufts[talloc->buffer_id], node);
|
| 824 |
}
|
| 825 |
return talloc->size_max >= node_size;
|