Commit aae2567
ytian218
server: fix crash when batch > ubatch with embeddings (#12836)
This fixes issue #12836 where the server crashes with GGML_ASSERT
failure when running with embeddings enabled and n_batch > n_ubatch.
The root cause is that embeddings require non-causal attention,
which requires all tokens to be processed within a single ubatch.
When n_batch > n_ubatch, the server attempts to split processing
across multiple ubatches, causing an assertion failure:
GGML_ASSERT((cparams.causal_attn || cparams.n_ubatch >= n_tokens_all)
&& "non-causal attention requires n_ubatch >= n_tokens") failed
Solution:
- Add parameter validation after common_params_parse()
- When embeddings are enabled and n_batch > n_ubatch:
* Log warning messages explaining the issue
* Automatically set n_batch = n_ubatch
* Prevent server crash
This follows the approach suggested by @ggerganov in the issue.
Testing:
- Server builds successfully
- Parameter validation occurs before model loading
- Warning messages inform users of the auto-correction
- Server no longer crashes with the problematic configuration1 parent 583cb83 commit aae2567
2 files changed
+54
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3657 | 3657 | | |
3658 | 3658 | | |
3659 | 3659 | | |
| 3660 | + | |
| 3661 | + | |
| 3662 | + | |
| 3663 | + | |
| 3664 | + | |
| 3665 | + | |
| 3666 | + | |
| 3667 | + | |
| 3668 | + | |
3660 | 3669 | | |
3661 | 3670 | | |
3662 | 3671 | | |
| |||
0 commit comments