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

refact : fix convert script + zero out KV cache to avoid nans #3523

Merged
merged 4 commits into from
Oct 9, 2023

Conversation

ggerganov
Copy link
Owner

@ggerganov ggerganov commented Oct 7, 2023

ref: #3329 (comment)

Question: should we first mask the KV tensor and then apply ALiBi?

llama.cpp/llama.cpp

Lines 3763 to 3771 in bdbe117

// KQ_masked = mask_past(KQ_scaled)
struct ggml_tensor * KQ_scaled_alibi = ggml_alibi(ctx0, KQ_scaled, /*n_past*/ 0, n_head, 8);
ggml_set_name(KQ_scaled_alibi, "KQ_scaled_alibi");
struct ggml_tensor * KQ_masked = ggml_add(ctx0, KQ_scaled_alibi, KQ_mask);
offload_func_kq(KQ_masked);
ggml_set_name(KQ_masked, "KQ_masked");

If that were the case, then the above KV cache initialization wouldn't be needed since any uninitialized values will be masked with -INF

@ggerganov ggerganov mentioned this pull request Oct 7, 2023
@slaren
Copy link
Collaborator

slaren commented Oct 7, 2023

If that were the case, then the above KV cache initialization wouldn't be needed since any uninitialized values will be masked with -INF

But nan - INF is still nan, so I don't think that this would work for removing nans before alibi.

@ggerganov ggerganov added the need feedback Testing and feedback with results are needed label Oct 8, 2023
@ggerganov ggerganov merged commit fcca0a7 into master Oct 9, 2023
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need feedback Testing and feedback with results are needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants