Repository navigation
Conversation
…ma 4 at 16k Moves the `--rai` backend from ryzenai-corelib 0.11 to 0.26 and builds on what the new corelib offers. corelib 0.26 (pinned exactly): - Follow the ABI changes: `create_tensor_window` takes strides, `linear_attention_bf16` takes rows, and models are built with `model_weights_create_path` + `model_create`. - A 3-D matmul output that writes the KV cache is a strided window `[max_seq*head, head, 1]` (Phi-4, Qwen3, Qwen3.5 V writes; Gemma 4 E4B staging window). - Per-op engines open their stream through `corelib::OpenModelStream`, which enables the model's kernel bundle before any kernel query. - corelib's per-model libraries are copied beside `flm.exe` on Windows and beside corelib by `home_install.sh` on Linux. Nothing needs `RYZENAI_CORELIB_DD_ROOT` or `RYZENAI_CORELIB_KERNELS_ROOT` any more. Qwen3.6-35B-A3B (new `qwen3.6-moe-rai:35b-a3b`, text only): - Runs on corelib's model API; context up to 262144 in 4096-row pages, a prompt is a single `model_forward`, and checkpoint/restore use corelib state snapshots. - Fetch logits only for the row that gets sampled. Gemma 4: - Context of 1..4096 on flat attention, or a multiple of 4096 up to 16384 on corelib paged attention; the aie_next catalog entries default to 16384. A paged continuation starts from its own page. - `gemma4-it-rai:e4b` is offered again. Shared: - `Sampler::sampler_topk_apply` selects top-k with a k-entry heap in one pass (same ranking and tie rule). Tests: new `src/test/qwen36_rai`, and the Gemma 4, Phi-4 and Qwen3 rai tests and fake corelib follow the 0.26 ABI and the 16k paged context. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
Author
|
Moving this to the internal FLM-Medusa repo. |
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.
Stacked on #774 — review the 9 commits after
abcfa3b4(f4c49ab5..1a754611). Retarget or rebase once #774 lands.Qwen3, Qwen3.5 and Gemma 4 on the
raibackend stop driving corelib op by op and run as corelib's own models (ryzenai_corelib_model_*), the way Qwen3.6 already did. All four now share one engine and one backend; each model is a ~20-line spec. Phi-4 is unchanged (corelib'sphi4minitakes ONNX only, and FastFlowLM ships a GGUF).What changes
One engine:
flm::rai::CorelibModel(include/rai/corelib_model.hpp,common/rai/corelib_model.cpp)causal_lmover a corelib model, generalized from the Qwen3.6 engine.ModelSpecstates what differs between models:Continuation— where a multi-row pass may start past position 0: anywhere (Qwen3.5/3.6), only at 0 (Qwen3, so a later prompt re-runs the conversation), or at 0 / a 4096-row page boundary (Gemma 4).Rewind—kSeekfor attention-only models (every pass states its position; rewind and restore just move it),kSnapshotfor Qwen3.6 (model_state_save/restore),kReplayfor Qwen3.5 (reset and replay).clear_contexton akSeekmodel makes no corelib call: a pass never reads the cache past its position, andmodel_resetcost ~60 ms per request on Qwen3.One backend:
flm::rai::Factory(BackendSpec)(include/rai/corelib_model_backend.hpp)tokenizer_config.json'seos_tokenplusconfig.json'seos_token_id(Qwen3.6, Gemma 4 → {1, 106}); Gemma 4's BOS comes frombos_token.Removed
rai/gguf_file,rai/weight_cache, and the Q8/RMSNorm parts ofrai/host_ops; 14 corelib entry points nothing calls any more.<gguf stem>.rai-weights.bin/.jsonfiles can be deleted.Tests
src/test/rai_model/: 36 engine tests (everyRewind/Continuationcombination, poisoning, capacity) and 14 backend tests against the fake corelib. The Qwen3.6 tests moved here.test_gemma4_registry.cpp, plus one test of the Gemma 4 spec. The op-level Gemma 4 and Qwen3 suites are gone.Docs:
src/common/models/README.mdgains §2a ("a model corelib runs whole"); the Qwen page notes the dropped weight cache.Results (xcomedusad-44, AIE4; old and new builds run interleaved)
flm serveprocess: every answer matches a fresh run, no errors.Known regression: Gemma 4 is slower on corelib 0.26's built-in model. Prefill takes ~1.5× (E2B) / 1.6–2× (E4B), decode is 24–29% slower, and loads are slower. The cause is in corelib, not here: the host per-layer-embedding projection in
Gemma4::BuildPle(FP32 weights, scalar, single-threaded on decode) and serial weight packing with no pre-packed input. A corelib fix is being prepared; FastFlowLM picks it up with a version bump. Qwen3 loads ~1 s slower without the packed-weight cache.Not covered
flm_raiwas not compiled for this change.Diff: 69 files; product code +801 / −8,423, tests +1,487 / −12,763.