Repository navigation
Remove "first token must be BOS" restriction - #2153
Merged
Merged
Conversation
ggerganov
approved these changes
Jul 9, 2023
ggerganov
left a comment
Member
There was a problem hiding this comment.
I added this check since the initial batch of OpenLLaMA models suffered significantly if the first token was not BOS.
I haven't checked what happened later - have some vague memory that this issue was resolved with later releases, so it is probably not needed any more.
Seunghhon
pushed a commit
to Seunghhon/llama.cpp
that referenced
this pull request
Apr 26, 2026
phuongncn
pushed a commit
to phuongncn/llama.cpp-gx10-dgx-sparks-deepseekv4
that referenced
this pull request
Apr 28, 2026
ljubomirj
pushed a commit
to ljubomirj/llama.cpp
that referenced
this pull request
May 6, 2026
AlexiAlp
pushed a commit
to minghaop/llama.cpp
that referenced
this pull request
Jun 2, 2026
AlexiAlp
pushed a commit
to minghaop/llama.cpp
that referenced
this pull request
Jun 2, 2026
bong-water-water-bong
pushed a commit
to bong-water-water-bong/llama.cpp
that referenced
this pull request
Sep 8, 2026
…ebind proposal Smaller route than Option A of BATCHED-FLASH-IMPL-PLAN.md: per-stream binding-offset rebinding of the existing decode-split kernel. DispatchBinding is value+byte-range and transients already bind as inputs, so contiguous batched tensors need NO copy kernel and NO kernel rewrite — matcher emits N×rows dispatches with stream offsets (s*nb[3]) and the same partial/q8 transients. Lane-level open items: completion-counter scaling, transient sharing under rows×streams, q8 alternate per stream, mask column semantics. The np4 cache_v_l0 view abort stays a separate item.
bong-water-water-bong
pushed a commit
to bong-water-water-bong/llama.cpp
that referenced
this pull request
Sep 8, 2026
… (offset-rebind) Batched (ne3>1) decode-split flash matcher: per-(stream,row) dispatches with per-stream s*nb[3] offset rebinding of the EXISTING kernel — no kernel change (BATCHED-FLASH-OFFSET-PROPOSAL.md). Contiguity-gated stream dim; per-dispatch partial/counter transients (sharing one set at offset 0 raced the online-softmax reduce). Verified on strixhalo (zaya q4nx-c43, np2): - the batched node is CLAIMED (was 'unsupported HRX node FLASH_ATTN_EXT f32[128,8,4,2]' graph -1) - per-position logits: stream 0 ≈ CPU-exact (9079/236761/107/4906 argmax order, small fp deltas) — the flash attention math itself is correct - residual bug (downstream, not this matcher): the q8 alternate consumer reads stream 1 one row stale (B's logits = A's previous-step logits) — batched q8 row indexing in the consuming dispatch Separate finding recorded on the issues: this branch's device decode is not oracle-correct with a REAL continuation (dense qwen3 + 30B collapsed; zaya diverges at tok 4) — the ggml-org#2147 decode-norm reorder fix is on fix/qwen3-decode-norm, not this lineage. Earlier 'token-identical' claims from the rt_tok harness were measured on a degenerate continuation (harness bug, corrected on ggml-org#2117/ggml-org#2116/ggml-org#2145).
bong-water-water-bong
pushed a commit
to bong-water-water-bong/llama.cpp
that referenced
this pull request
Sep 8, 2026
…U boundary on lm_head input Program-dump-verified: the batched flash matcher bindings are correct (per-stream strides, per-dispatch transients) and stream-0 logits are CPU-exact. The np2 B-stream staleness is the CPU-side lm_head (zaya vocab 262272 > 262144 device cap) reading the final hidden [2048,2] across the HRX->CPU boundary with a mis-mapped row 1 — the round-16e boundary class on the device->CPU direction. Corroborated by MUL_MAT->CPU making both streams garbage. Fix = scheduler boundary copy for batched tensors (or device lm_head coverage); also requires the ggml-org#2147 decode-norm lineage for any decode-quality validation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently, the
llama_eval_internalfunction requires the first token in thetokensarray to be a BOS token (=1).I believe that this is not necessary, as
In other words, the BOS token adds a "beginning of document" bias that can be optionally removed.
I originally encountered the "first token must be BOS" error while trying to evaluate llama.cpp using a transformers wrapper that I am working on here. The evaluation fails because the first token in the sequence provided by my code, which is based on this tutorial, is not BOS.