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

A quick question: how do I calculate overhead for a model? #356

Closed
znsoftm opened this issue Jul 8, 2023 · 3 comments
Closed

A quick question: how do I calculate overhead for a model? #356

znsoftm opened this issue Jul 8, 2023 · 3 comments

Comments

@znsoftm
Copy link

znsoftm commented Jul 8, 2023

for BERT mode, its overhead is calculated as :

model_mem_req += (5 + 16 * n_layer) * 256; // object overhead

Can anyone explain the meaning 5, 16 , 256 for me ?

@znsoftm
Copy link
Author

znsoftm commented Jul 8, 2023

for GPT-2, it is:

ctx_size += (6 + 12*n_layer)*512; // object overhead

@znsoftm
Copy link
Author

znsoftm commented Jul 8, 2023

For the model BERT, it has n_layer, each layer has 16 tensors and 5 extra parameters (tensor), but what the 512 is for? I guess it is the size of "struct ggml_tensor", but it is not...
so what is the 256 for? It does be the size of something...

the sizeof(struct ggml_tensor) is 208, so 256 is rounded to n times 16?

@ggerganov
Copy link
Owner

The object overhead is calculated as:

size_t overhead_bytes = n_tensors * ggml_tensor_overhead();

CCLDArjun pushed a commit to CCLDArjun/ggml that referenced this issue Dec 18, 2023
* Introduce structs for the q4 data blocks

* ggml : rename quant struct variables + fix ARM_NEON

---------

Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants