Skip to content
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

ggml : remove src0 and src1 from ggml_tensor and rename opt to src #341

Closed
ggerganov opened this issue Jul 4, 2023 · 6 comments
Closed
Labels
good first issue Good for newcomers refactoring Refactoring

Comments

@ggerganov
Copy link
Owner

ggerganov commented Jul 4, 2023

ggml/include/ggml/ggml.h

Lines 415 to 420 in b98cd86

struct ggml_tensor * grad;
struct ggml_tensor * src0;
struct ggml_tensor * src1;
struct ggml_tensor * opt[GGML_MAX_OPT];

@ggerganov ggerganov added good first issue Good for newcomers refactoring Refactoring labels Jul 4, 2023
@slaren
Copy link
Collaborator

slaren commented Jul 4, 2023

I would suggest considering using an array for all src nodes instead. This will simplify the code when we need to look at the list of parents of a node. This already happens when printing to dot, internally in ggml-cuda, and will also happen when we implement the improved memory management. Having each parent in a different variable forces us to look at each one separately instead of just looping over an array.

@ggerganov ggerganov changed the title ggml : remove opt array from ggml_tensor ggml : remove src0 and src1 from ggml_tensor and rename opt to src Jul 4, 2023
@ggerganov
Copy link
Owner Author

I updated the issue

@nullhook
Copy link
Contributor

nullhook commented Jul 6, 2023

How would the new src indexing work in cases where a 4D tensor is created, but opt[0-2] is being written? It would be out of bounds. for ex: https://github.com/ggerganov/ggml/blob/master/src/ggml.c#L7268

@slaren
Copy link
Collaborator

slaren commented Jul 6, 2023

@nullhook I am not sure if I understand what you mean, the total number of source tensors available to ops will be the same, and can be increased as needed.

For instance, see how it is being done in #346:

ggml/src/ggml.c

Lines 7260 to 7266 in b7fd1a4

result->op = GGML_OP_FLASH_FF;
result->grad = is_node ? ggml_dup_tensor(ctx, result) : NULL;
result->src[0] = a;
result->src[1] = b0;
result->src[2] = b1;
result->src[3] = c0;
result->src[4] = c1;

@nullhook
Copy link
Contributor

nullhook commented Jul 6, 2023

I was looking at the PR linked to this issue. So it seems like GGML_MAX_OPT needed to be increased

@ggerganov
Copy link
Owner Author

Fixed via ggerganov/llama.cpp#2178

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers refactoring Refactoring
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants