Repository navigation
ggml : set output of view src - #25729
Conversation
|
A bit more info would be helpful - where do we use views for output? |
|
I'm adding the deepseek4 MTP, there we need to add a hidden state from a reshape (which is a view) llama.cpp/src/models/deepseek4.cpp Lines 1156 to 1160 in c3d47e6 |
|
I think you can simply output the hidden state before the reshape? The hidden state extraction logic only needs to know the total size of the tensor - the specific dimensions are not relevant. |
|
The unflattened tensor is 3d, |
|
Also in general this is a bug right? If any t is a view then this can possibly cause issues. We have no documentation that says that these things can't be views. |
Yes, we should assert in the
I don't follow. Is this a problem? Normally, all embeddings and hidden states that we extract are 2D. |
|
It's not a problem for the MTP, I'll just update this PR to add an assert for outputs not being views then |
|
Some server tests are failing after this change: https://github.com/ggml-org/llama.cpp/actions/runs/29490535879/job/87595298014?pr=25729#step:7:752 |
|
It looks like some cases with backend_sampling: true are failing |
|
This is the problem. The top-p default returns a view as output llama.cpp/src/llama-sampler.cpp Lines 1434 to 1458 in fd4fd67 |
|
I faced a similar issue in #25532 How about fixing it within GGML? We can propagate the output flag to the backing tensor in |
|
I was a bit hesitant to make it since I initially thought that we don't need to use output views. But it does seem that there are some use cases where it's complicated to avoid having a view for output. |
|
I see that @am17an's first commit in this PR did something similar. But it's not clear to me why an output can't be a "view". The current assert also enforces this only for tensors registered in |
|
Ok, I added the change to |
Co-authored-by: Gaurav Garg <gaugarg@nvidia.com>
…utput now walks view_src (ggml-org#25729 landed our fix)
…utput now walks view_src (ggml-org#25729 landed our fix)
* llama-graph: set_outputs to t->view_src * change set_output to GGML_ASSERT about views not being outputs * sampler : avoid views in outputs * cont : fix dist sampler * cont : consistent logits handling * ggml : set output of view src * graph : simplify set_outputs() * cont : cleanup Co-authored-by: Gaurav Garg <gaugarg@nvidia.com> --------- Co-authored-by: Georgi Gerganov <ggerganov@gmail.com> Co-authored-by: Gaurav Garg <gaugarg@nvidia.com>
* llama-graph: set_outputs to t->view_src * change set_output to GGML_ASSERT about views not being outputs * sampler : avoid views in outputs * cont : fix dist sampler * cont : consistent logits handling * ggml : set output of view src * graph : simplify set_outputs() * cont : cleanup Co-authored-by: Gaurav Garg <gaugarg@nvidia.com> --------- Co-authored-by: Georgi Gerganov <ggerganov@gmail.com> Co-authored-by: Gaurav Garg <gaugarg@nvidia.com>
* llama-graph: set_outputs to t->view_src * change set_output to GGML_ASSERT about views not being outputs * sampler : avoid views in outputs * cont : fix dist sampler * cont : consistent logits handling * ggml : set output of view src * graph : simplify set_outputs() * cont : cleanup Co-authored-by: Gaurav Garg <gaugarg@nvidia.com> --------- Co-authored-by: Georgi Gerganov <ggerganov@gmail.com> Co-authored-by: Gaurav Garg <gaugarg@nvidia.com>
* llama-graph: set_outputs to t->view_src * change set_output to GGML_ASSERT about views not being outputs * sampler : avoid views in outputs * cont : fix dist sampler * cont : consistent logits handling * ggml : set output of view src * graph : simplify set_outputs() * cont : cleanup Co-authored-by: Gaurav Garg <gaugarg@nvidia.com> --------- Co-authored-by: Georgi Gerganov <ggerganov@gmail.com> Co-authored-by: Gaurav Garg <gaugarg@nvidia.com>
Overview
The
ggml_set_outputnow also sets the src tensors of views as outputs as well. This is to prevent from the allocator from reusing their memory.Requirements