Repository navigation
Add stable model extension support - #874
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved backend compatibility and capability-handling defects can crash inference, while insufficient catalog overlay validation can cause uncaught startup failures.
10 open issues
Prevent null engine downcasts in backend-only extensions · New Handle missing STATE capability in built-in frontends · New Validate overlay platforms before publishing registrations · New Generate relocatable package paths for multiarch libdirs · New Preserve preemption flag without a host XCLBIN manager · New Use -1 sentinel when provider has no BOS token · New Open UTF-8 catalog paths with filesystem::u8path · New Keep owned device alive through provider destruction · New Keep owned device alive through provider cleanup · New Destroy extensions before shutting down core runtime · New
What changed in this PR
Adds a stable C ABI for independently built model frontends and backend providers, integrating extensions into FastFlowLM’s model selection and lifecycle while preserving built-in defaults.
Changes:
- Introduces provider-aware registries, C adapters, catalog overlays, and extension-local assets.
- Updates model ownership, loading, tokenization, and backend selection to support external implementations.
- Adds hardware-free contract tests, versioned schemas, SDK packaging, and CI consumer checks.
| File | Description |
|---|---|
src/test/phi4_core/CMakeLists.txt |
Keeps downloader compatibility tests independent of runtime assets. |
src/test/model_list_platform/test_model_list_platform.cpp |
Tests overlays, provider validation, and built-in tag preservation. |
src/test/model_list_platform/fixtures/valid-model-catalog-overlay-v1.json |
Adds a valid provider-selected catalog fixture. |
src/test/model_list_platform/fixtures/invalid-model-catalog-overlay-v1.json |
Adds an unsupported-schema fixture. |
src/test/model_list_platform/CMakeLists.txt |
Supplies overlay fixtures and schema paths. |
src/test/model_frontend/test_model_frontend.cpp |
Tests registration, loading, rollback, and provider lifetimes. |
src/test/model_frontend/stubs/device_runtime.hpp |
Supplies a hardware-free runtime stub. |
src/test/model_frontend/fixtures/valid-model-extension-v1.json |
Adds a valid bundle manifest fixture. |
src/test/model_frontend/fixtures/invalid-model-extension-v1.json |
Adds an invalid manifest fixture. |
src/test/model_frontend/fake_model_extension.c |
Implements C providers for contract tests. |
src/test/model_frontend/fake_model_extension_dependency.c |
Supplies a private shared-library dependency fixture. |
src/test/model_frontend/CMakeLists.txt |
Builds loader tests, fake providers, and adapter compilation checks. |
src/test/model_extension_contracts/CMakeLists.txt |
Groups hardware-free extension contract suites. |
src/test/model_extension_consumer/provider.c |
Adds an independent C SDK consumer. |
src/test/model_extension_consumer/CMakeLists.txt |
Verifies installed SDK discovery and compilation. |
src/test/model_backend/test_model_backend.cpp |
Tests exact backend/provider selection and override rejection. |
src/test/model_backend/CMakeLists.txt |
Replaces runtime dependencies with test stubs. |
src/test/gemma4_core/test_gemma4_registry.cpp |
Updates registry and package-selection regression checks. |
src/src/main.cpp |
Loads extensions and merges their validated catalog contributions. |
src/src/benchmarking.hpp |
Uses registry-compatible frontend ownership. |
src/server/rest_handler.hpp |
Adopts extension-compatible frontend ownership. |
src/schemas/model-extension-manifest-v1.schema.json |
Defines the versioned extension bundle format. |
src/schemas/model-catalog-overlay-v1.schema.json |
Defines provider-selected catalog entries. |
src/runner/runner.hpp |
Adopts extension-compatible frontend ownership. |
src/runner/runner.cpp |
Accepts registry-created frontend results. |
src/pull/model_downloader.hpp |
Removes the configuration-loader dependency. |
src/pull/model_downloader.cpp |
Checks compatibility directly from model metadata. |
src/include/utils/vm_args.hpp |
Adds repeatable --model-extension arguments. |
src/include/program_args.hpp |
Stores extension manifests in load order. |
src/include/models/gemma4e/gemma4e_payload.hpp |
Separates private Gemma multimodal payload types. |
src/include/models/gemma4e/flm/aie2p/gemma4e_npu.hpp |
Imports the extracted payload definitions. |
src/include/model_list.hpp |
Merges overlays and filters explicit provider selections. |
src/include/lm_config.hpp |
Accepts extension-local execution asset roots. |
src/include/buffer.hpp |
Allows runtime headers to be supplied through include paths. |
src/include/AutoModel/modeling_qwen3vl.hpp |
Makes the Qwen3VL engine dependency explicit. |
src/include/AutoModel/modeling_qwen3_6_moe.hpp |
Makes the Qwen3.6 MoE engine dependency explicit. |
src/include/AutoModel/modeling_qwen3_5vl.hpp |
Makes the Qwen3.5VL engine dependency explicit. |
src/include/AutoModel/modeling_qwen2vl.hpp |
Makes the Qwen2VL engine dependency explicit. |
src/include/AutoModel/modeling_minicpm_v.hpp |
Makes the MiniCPM engine dependency explicit. |
src/include/AutoModel/modeling_gemma4e.hpp |
Imports explicit engine and payload dependencies. |
src/include/AutoModel/modeling_gemma4_12b.hpp |
Makes the Gemma4 12B engine dependency explicit. |
src/include/AutoModel/model_frontend.hpp |
Declares frontend registration, ownership, and extension lifecycle APIs. |
src/include/AutoModel/model_extension.h |
Defines the public versioned C extension ABI. |
src/include/AutoModel/model_extension_frontend.hpp |
Declares staged frontend registrations and adapter factories. |
src/include/AutoModel/model_extension_backend.hpp |
Declares staged backend registrations and publication support. |
src/include/AutoModel/model_catalog_overlay.hpp |
Parses and validates catalog contributions. |
src/include/AutoModel/model_backend.hpp |
Adds provider-aware registry and selection APIs. |
src/include/AutoModel/backend_contract.hpp |
Centralizes backend and provider identifiers. |
src/include/AutoModel/automodel.hpp |
Adds extension-facing tokenizer hooks and provider state. |
src/include/AutoModel/all_models.hpp |
Replaces frontend switch dispatch with registry lookup. |
src/common/AutoModel/modeling_qwen3.cpp |
Adds an explicit Qwen3 engine include. |
src/common/AutoModel/modeling_qwen3_8mtp.cpp |
Adds an explicit Qwen3.8 MTP engine include. |
src/common/AutoModel/modeling_qwen3_6_moe.cpp |
Adds an explicit MoE engine include. |
src/common/AutoModel/modeling_qwen3_6_moe_image.cpp |
Adds the image-processing engine dependency. |
src/common/AutoModel/modeling_qwen3_5vl.cpp |
Adds an explicit Qwen3.5VL engine include. |
src/common/AutoModel/modeling_qwen3_5vl_image.cpp |
Adds the image-processing engine dependency. |
src/common/AutoModel/modeling_qwen2.cpp |
Adds an explicit Qwen2 engine include. |
src/common/AutoModel/modeling_phi4.cpp |
Adds an explicit Phi4 engine include. |
src/common/AutoModel/modeling_nanbeige.cpp |
Adds an explicit Nanbeige engine include. |
src/common/AutoModel/modeling_minicpm_v.cpp |
Adds an explicit MiniCPM engine include. |
src/common/AutoModel/modeling_minicpm_v_image.cpp |
Adds the image-processing engine dependency. |
src/common/AutoModel/modeling_llama3.cpp |
Adds an explicit Llama engine include. |
src/common/AutoModel/modeling_lfm3.cpp |
Adds an explicit LFM3 engine include. |
src/common/AutoModel/modeling_lfm2.cpp |
Adds an explicit LFM2 engine include. |
src/common/AutoModel/modeling_gpt_oss.cpp |
Adds an explicit GPT-OSS engine include. |
src/common/AutoModel/modeling_gemma4e.cpp |
Adds explicit standard and flash engine includes. |
src/common/AutoModel/modeling_gemma4_12b.cpp |
Adds an explicit Gemma4 12B engine include. |
src/common/AutoModel/modeling_gemma4_12b_image.cpp |
Adds the image-processing engine dependency. |
src/common/AutoModel/modeling_gemma3.cpp |
Adds an explicit Gemma engine include. |
src/common/AutoModel/modeling_gemma3_text.cpp |
Adds an explicit text-only Gemma engine include. |
src/common/AutoModel/model_extension_frontend.cpp |
Adapts C frontend callbacks to AutoModel. |
src/common/AutoModel/model_extension_detail.hpp |
Shares span, error, cleanup, and runtime-handle helpers. |
src/common/AutoModel/model_extension_backend.cpp |
Adapts C backend callbacks and optional capabilities. |
src/common/AutoModel/model_backend.cpp |
Implements provider registration and exact selection. |
src/common/AutoModel/builtin_frontends.cpp |
Registers built-in frontend factories. |
src/common/AutoModel/builtin_backends.cpp |
Makes built-in engine dependencies explicit. |
src/common/AutoModel/automodel.cpp |
Integrates provider loading and frontend-neutral token handling. |
src/CMakeLists.txt |
Exports and installs the extension SDK and schemas. |
src/cmake/FastFlowLMModelExtensionConfig.cmake.in |
Defines SDK package discovery and runtime metadata. |
src/cmake/FastFlowLMModelExtension.cmake |
Defines the public extension interface target. |
.github/workflows/windows-build.yml |
Adds contract tests, SDK consumer checks, and packaging. |
.github/workflows/debian-portable.yml |
Adds contract tests, installed SDK checks, and packaged SDK files. |
Review effort: Balanced
bc808ca to
c14dd61
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved issues allow overlays to redirect built-in aliases, leave reasoning syntax and cached grammars stale after configuration, and cause null flm_version values to throw instead of using the compatibility fallback.
3 open issues
10 resolved since last review
Validate overlay platforms before publishing registrations Handle missing STATE capability in built-in frontends Prevent null engine downcasts in backend-only extensions Destroy extensions before shutting down core runtime Keep owned device alive through provider cleanup Keep owned device alive through provider destruction Open UTF-8 catalog paths with filesystem::u8path Use -1 sentinel when provider has no BOS token Preserve preemption flag without a host XCLBIN manager Generate relocatable package paths for multiarch libdirs
Review effort: Balanced
c14dd61 to
27e6e21
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Critical issues allow overlays to redirect built-in aliases, requests to reuse unrecoverably failed backend engines, and accepted entries with missing download metadata to crash model listing.
6 open issues
Reject requests after the backend is poisoned · New Require downloader metadata in extension validation · New Preserve built-in bare-tag resolution after filtering · New Add XRT include path discovery for Linux builds · New Fix the model info key for the Gemma open tag · New Execute the real frontend adapter in hardware-free tests · New
Review effort: Balanced
27e6e21 to
08797b0
Compare
08797b0 to
0b23424
Compare
zaneni6
left a comment
There was a problem hiding this comment.
Thanks a lot for this, Jorn, it's a really well-built change! The loader is careful: an explicit --model-extension flag only, bundle-relative paths that are checked, LOAD_LIBRARY_SEARCH_* flags, ABI and runtime checks, no exceptions crossing the C boundary, and clean rollback. Built-in tags still resolve to the same frontends and engines on XRT and HRX, and it's great that the Copilot comments are addressed. I mostly looked at how it lands next to what's on main now and at the XRT/HRX side, and had a few thoughts. Please feel free to push back on any of them.
1. Rebase onto main (gpt-oss conflict with #965)
src/common/AutoModel/modeling_gpt_oss.cpp now conflicts with #965. I think the right resolution is main's file plus your #include "models/gpt_oss/flm/aie2p/gpt_oss_npu.hpp" line, since #965 already switched to lm_engine->restore()/checkpoint().
- Keeping only main's side fails to compile (
gpt_oss_npu_state_apiis not declared onceautomodel.hppstops including engine headers). - Keeping only this PR's side drops #965's
_continue_verbatim/forwards_past_eos()gating for the GPU backend.
builtin_backends.cpp auto-merges fine with #965's oga-hipep registrations. One small thing after the rebase: the new logits.size() < in_features check in _sample makes the fakes in src/test/oga_hipep/frontend (test_qwen_frontend, test_gpt_oss_frontend) fail, since they return buffer<bf16>(1) with a 64-wide sampler. CI doesn't build those, so it wouldn't show up there. Would you mind re-running CI after the rebase?
2. --backend / FLM_BACKEND no longer override the catalog
resolve_backend_selection (model_backend.cpp ~line 242) now rejects any backend that differs from the catalog entry's. Before, it only checked that the family registers it. For example, FLM_BACKEND=core with qwen3:0.6b on a core-enabled build used to load and now errors. If that's intended, could the CLI/server docs (docs/docs/instructions/cli.md around the backend section) and the --backend help text be updated in the same PR? They publish straight to the site.
3. Extension steps inside the package build jobs
The model-extension contract tests and the Gemma4-open fixture build run as steps inside lin-build / win-build, before packaging. So a failure there means no package for that variant, none of its NPU tests run, and the XRT or HRX release is held, even when flm itself built fine. They also add roughly 6–10 minutes per Windows build: they use the VS generator without sccache, and the same contracts compile in 6 builds. The fixture also downloads the codec tarballs again each time, including from downloads.xiph.org, which #967 just had to work around. Would it be possible to move these into their own jobs that depend on the build, or into cpu-tests.yml? They could still count toward the verdict, without blocking packaging and the NPU sweep.
4. Path checks for overlay name / files
load_model_catalog_overlay only checks that name and files are non-empty strings, and get_model_path / get_model_file_path join them directly. So .., absolute or drive-relative entries let flm pull write, and flm remove delete, outside the model folder. With #965's new folder cleanup in remove_model, that could become a remove_all on an unexpected folder.
Related: the Gemma4-open fixture's catalog uses the same Gemma4-E2B-IT-NPU2 folder as the built-in gemma4-it:e2b, so flm remove gemma4-open-it:e2b would delete the built-in model's weights. Maybe require name to be a single relative component that doesn't match a built-in entry's folder, and reject .. / rooted entries in files?
Smaller ideas, fine for follow-ups (they only apply when an extension is loaded):
- Built-in multimodal frontends still
reinterpret_castthe engine, for examplemodeling_qwen3_6_moe.cpp:202/257,modeling_minicpm_v_image.cpp,modeling_gemma4_12b_image.cpp. An extension backend provider for one of those built-in families, with an overlay entry that leaves outvlm, would reach them on an image request. Maybe reject extension backend providers for families whose frontend downcasts, or usedynamic_castwith a request error? - An extension frontend can register the reserved
whisper-v3/embed-gemma/d3family names. accepts_private_payloadspairs frontend and backend by provider-id string, so two different extensions could use the same id.- The
FLM_TEST_PREFILL_FAULThook callstokenizer->decodewhileExtensionAutoModelresets the tokenizer. changes.pydoesn't know the new test/schema paths yet, so edits to only those run the full NPU sweep.- Release zips and tarballs now ship the SDK (header, CMake package, schemas), but the MSI doesn't, and the schema folder differs between Linux and Windows. Maybe worth a line in the release notes.
Thanks again, this is a big step for the project!
4dc2f33 to
721adcb
Compare
|
Hi @zaneni6, thanks for the thorough review! Everything is addressed in this PR, including the smaller ideas, since most of them were small. The PR is rebased onto current main (now past #972, #986 and #988) and is still two commits. CI is green. 1. Rebase and the gpt-oss conflict. I resolved 2. 3. Extension steps in the package builds. Both are out of
4. Overlay paths. Smaller ideas, also done here:
One note: the new |
Replace the compiled model-family switch with factories keyed by catalog family while preserving the existing construction and fallback behavior. Use provider-compatible ownership so later extensions can destroy frontends in the module that created them.
721adcb to
f3eb450
Compare
|
Thanks a lot, Jorn, for addressing everything so thoroughly, including the smaller ideas! I checked the fixes against the code, CI was all green, and it's merged now. 🎉 A few small leftovers I noticed while checking. None of them blocked the merge, so they're just ideas for a follow-up whenever convenient:
Thanks again for the great work on this! |
automodel.hpp no longer pulls in every engine header (#874), so the harness has to include hunyuan_npu.hpp itself. Co-Authored-By: Claude <noreply@anthropic.com>
The Windows model-extension build (from #874, merged into main after this branch started) passed -DVCPKG_INCLUDE_DIR=C:\dev\vcpkg\installed\x64-windows\include. That directory only ever supplied curl's headers, and this branch no longer creates C:\dev\vcpkg: curl's headers are committed under third_party/curl. The merged result failed to configure on both Windows runtimes: "VCPKG_INCLUDE_DIR must name an existing directory". The extension now takes curl's headers from third_party/curl/include next to FLM_SOURCE_DIR, so the workflow no longer passes the directory. Built locally against the fastflowlm-windows package artifact from CI run 42713502798: it configures and builds, and the bundle has the extension DLL, catalog and xclbins. Co-Authored-By: Claude <noreply@anthropic.com>
Thanks for merging and the follow-up comments, @zaneni6! I created a follow-up PR here: #997. I kept the SDK feature on by default as making it opt-in for MSI isn't that convenient. The files are small and just a header, CMake config and schemas, so installing them by default is cheap, but let me know if you explicitly want it to be opt-in and I can make the change. |
…ywhere in the string (#1047) * feat(core): ryzenai-corelib 0.70.0, get_npu replaces npu_usable and testing_npu_arch Moves the core backend to ryzenai-corelib 0.70.0 (corelib main at 39c30eab). What changed in corelib 0.61 to 0.70 that reaches FastFlowLM: - 0.70, NPU query: ryzenai_corelib_npu_usable and the testing hook ryzenai_corelib_testing_npu_arch are gone. ryzenai_corelib_get_npu (none / aiem / aie2p) and ryzenai_corelib_npu_name replace them, so corelib_api.hpp no longer includes corelib/testing.h. - The runtime's readiness check now asks for aiem. The old npu_usable was false on AIE2P, whose kernels corelib runs only behind an xclbin FastFlowLM never gives it; get_npu now answers aie2p there, so checking for "any NPU" would have offered the core backend on Strix. - NpuArch names the enum with npu_name, "" for none, as before, so dev04 / aie2p platform detection is unchanged. - 0.61 / 0.68, model structs: model_metadata gains max_draft_tokens and audio_token_id; session_options gains draft_tokens. FastFlowLM zero-initialises both at their full sizeof, so no draft is asked for. - 0.62 / 0.67, matmul: the 4-bit layout is mladf_v4 (was mladf) beside AIE2P's mladf_v2, and matmul_bf16_kernel_info gains format. FastFlowLM names neither; the fake corelib fills format. - 0.68: ssmlp_bf16_weights_desc gains ungated; unused here. - Model libraries and their names are unchanged. The weights loader's switch from bad_argument to unsupported for a wrong tensor type does not matter here: FastFlowLM does not branch on corelib's status codes. The fake corelib answers get_npu from one enum and npu_name as corelib spells it; the tests refuse none and aie2p, and read "" for none. On an AIE4 (Medusa) test machine, qwen3-core 0.6b/1.7b/4b/8b, phi4-mini-it-core:4b, qwen3.5-core 4b/9b and llama3.2-core:1b each load, pass the readiness check through get_npu, report no fallback and answer correctly, at decode rates within a few percent of corelib 0.59's. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(chat): a JSON Schema pattern matches anywhere in the string, and keeps a one-character class's length bounds JSON Schema finds a string pattern anywhere in the string; xgrammar matches the regex against the whole string. A field written as {"type": "string", "minLength": 1, "maxLength": 128, "pattern": "\\S"} ("not blank") therefore allowed exactly one character, and xgrammar also drops minLength/maxLength whenever a pattern is present (it logs "pattern combined with minLength/maxLength is not supported"). Found running an agent benchmark with qwen3.6-moe-core:35b-a3b: every free-text argument of a forced chart-generation tool call came back as one character ("caption":"7","alt_text":"A","labels":["P","C"]). The caller rejected it, the grammar left the model no other call to make, and it repeated until the tool-iteration limit. normalize_schema() now: - pads the side(s) a string pattern leaves unanchored with ".*" ("\S" becomes ".*(\S).*"). A pattern anchored at both ends is left as it is, so "^\d{4}-\d{2}-\d{2}$" keeps its meaning. - lets a lone character class that only has to occur somewhere ("\S", "\d", "[a-z]", ...) lead, and turns the schema's length bounds into the repetition after it: "\S" with maxLength 128 becomes "\S.{0,127}", so the bounds xgrammar would drop are enforced. - keeps minLength/maxLength and drops the pattern instead when that repetition would be longer than 128. xgrammar compiles a longer regex repetition into a rule of its own and cannot build that rule inside a nested object ("cannot build the decoding grammar: Check failed: per_rule_fsm_hashes[...].has_value()"), so the request would fail with HTTP 400; a string past its maxLength is the likelier mistake. response_format schemas now go through normalize_schema() as tool parameters already did, so they get the same reading. New live cases in src/test/openai_api_test: test_tool_calls function_unanchored_pattern and function_nested_long_bounded_pattern, and test_response_format schema_unanchored_pattern. The two unanchored cases fail on main ('P' for "Paris"); the nested one fails with the HTTP 400 above if the bounds are folded at any length. On an AIE4 (Medusa) test machine with qwen3.6-moe-core:35b-a3b: test_tool_calls.py 18/18, test_response_format.py 12/12. Co-authored-by: Cursor <cursoragent@cursor.com> * feat(core): ryzenai-corelib 0.87.0, has_feature replaces get_npu and npu_name Moves the core backend to ryzenai-corelib 0.87.0 (corelib main at 5bf19507). What changed in corelib 0.71 to 0.87 that reaches FastFlowLM: - 0.73, NPU query: ryzenai_corelib_get_npu, ryzenai_corelib_npu_name and the ryzenai_corelib_npu enum are gone. ryzenai_corelib_has_feature and ryzenai_corelib_feature_name replace them, over ryzenai_corelib_feature (npu, npu_aiem, npu_aie2p, gpu, npu_direct). - The runtime's readiness check asks has_feature(npu_aiem). AIE2P is still refused, since FastFlowLM never gives corelib an xclbin, and the error names npu_aie2p or none. - NpuArch passes corelib's spelling through (npu_aiem, npu_aie2p, ""), and platform_from_corelib_arch maps npu_aiem to dev04. FastFlowLM still keeps no table of devices. - Everything else FastFlowLM resolves is unchanged: every other entry point in FLM_CORELIB_FUNCTIONS keeps its signature, and model_metadata and session_options keep their layout. 0.87's single PDI list per stream, NPU direct, the .amd.gguf exports (0.80, 0.83) and the new ops do not touch FastFlowLM's calls. - 0.83: corelib's 4-bit GGUF types are renamed (AMD_Q4_G128, AMD_Q4_G32, new AMD_Q4_G64). Files published under the old type codes (ggml 128, 129) are still read as before, so the catalog's AMD files need no change. - Model libraries: ryzenai_corelib_model_d3 is new. The core build copies ryzenai_corelib_model_*.dll by glob, so it lands beside flm.exe without a change; no -core tag uses it yet. - Not taken here: corelib now lets Llama 3.2-1B/3B and 3.1-8B read a Q4_G128 GGUF in place of their Q8_0. Q8_0 still loads, so the catalog's Llama entries stay on Q8_0; switching them is a separate change. The fake corelib answers has_feature from one NPU feature, or none, and feature_name as corelib spells it. The tests refuse none and npu_aie2p, each named in the error, and read "" for none. The Linux setup guide's version check now prints 0, 87, 0. On an AIE4 (Medusa) test machine, with the core flm.exe statically linked against corelib's default build (no --npu-direct): every -core tag except Llama 3B/8B loads, passes the readiness check through has_feature(npu_aiem), reports no fallback and answers correctly, at decode rates matching 0.70's. Gemma 4 E2B/E4B, Qwen3.8 and Qwen3.6 recall a code from the middle of 4k and 12k prompts (Qwen3.6 also at 24k). An flm.exe linked against a corelib built with --npu-direct engages NPU direct for Qwen3.6 and gives the same greedy output, with prefill about 10-15% faster from 12k tokens. The core build stays on corelib's default build: --npu-direct needs CHESS in WSL, so turning it on is a build-only follow-up. Co-authored-by: Cursor <cursoragent@cursor.com> * test(core): the frontend stubs return a full vocabulary of logits; the DFlash entries hold no licence Two checks added on main left two Windows-only core suites failing on main itself. Only tests change here. - test_phi4_frontend, test_llama_frontend: #874 added a check to AutoModel::_sample that refuses logits shorter than the sampler's in_features, which is vocab_size from config.json. Each test's FakeEngine returned buffer<bf16>(1) from forward and prefill, so every test that samples failed with "Backend returned fewer logits than the frontend vocabulary". They now return kVocabSize logits, as the core backend does: 200064 for Phi-4 and 128256 for Llama. config.json takes vocab_size from the same constant. - test_model_downloader: #950 dropped LICENSE.OpenMDW-1.1 and LICENSE from the files of nemotron3.5-bolt-dflash:e4b and qwen3.8-dflash2:27b, but the test still expected them. It now expects config.json and dflash_weight.q4nx, as the catalog lists. The check itself is unchanged. The real core backend returns logits as wide as corelib's vocab_size, which equals config.json's for the shipped -core tags, so it does not trip there. Co-authored-by: Cursor <cursoragent@cursor.com> * feat(core): ryzenai-corelib 0.103.0 Moves the core backend to ryzenai-corelib 0.103.0 (corelib main at 49a8ed3c). What changed in corelib 0.88 to 0.103 that reaches FastFlowLM: - Every entry point in FLM_CORELIB_FUNCTIONS keeps its signature, and model_metadata keeps its layout, so the only code change is the required version in corelib_api.hpp. - model_session_options: lora is gone (0.97: a session runs LoRA kernels when its model has an adapter set), and low_memory (0.96) and kv_cache_bits (0.98) are appended. FastFlowLM value-initialises the struct and sets only max_sequence_length, so the defaults hold: no LoRA, the embedding table mapped, a BF16 KV cache. - Additive only, as far as FastFlowLM's calls go: uint8 tensors, stream_set_low_memory, PQ2_0 weights, head_gate_bf16, hadamard_bf16, and NPU direct on AIE2P. FastFlowLM still refuses AIE2P. - Model libraries: qwen2, lfm2, lfm3, hyv3, glide, minicpm_ocr and minicpmv47 are new. The core build copies ryzenai_corelib_model_*.dll by glob, so they land beside flm.exe without a change; no -core tag uses them yet. - Not taken here: the 8-bit KV cache (kv_cache_bits 8, AIE4 NPU direct only) and low_memory sessions. Both are opt-in and would be separate changes. The docs' version checks and the required-version notes move to 0.103. On an AIE4 (Medusa) test machine, qwen3-core 0.6b/1.7b/4b/8b, phi4-mini-it-core:4b, qwen3.5-core 4b/9b and llama3.2-core:1b each load, report no fallback and answer correctly, at decode rates matching 0.87's. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(chat): Gemma4 and LFM2 tool grammars keep a string's minLength/maxLength The argument grammars FastFlowLM writes itself (Gemma4, LFM2) gave every string property the unbounded string rule, so a tool parameter with maxLength 20 took a whole sentence: test_tool_calls function_pattern_keeps_length_bounds failed on gemma4-it:e2b, Linux and Windows. normalize_schema had also folded the bounds into a pattern that only xgrammar's JSON schema reads. These grammars now read the schema as sent and spell bounds up to XGRAMMAR_REGEX_REPEAT_LIMIT: Gemma4 through counted gstr_<low>_<high> rules (a "<" step takes the next character too, so lengths stay exact and "<|" still cannot occur), LFM2 through a {low,high} repetition where an escape is one character. Array items keep their bounds too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(chat): pad an unanchored pattern without ending the string; leave flags and inner anchors as sent Review follow-ups to the pattern rewrite: - The padding is now a class of what a JSON string holds unescaped, not ".*". xgrammar keeps '"', '\' and control characters out of a pattern's matches only when the pattern is printable ASCII; any other pattern compiles without that guard, where ".*" could close the string and add keys ("(é|x)" took x", "k": "y). The folded repetition after a lone class uses the same class. - A pattern opening with an inline flag such as "(?i)" is left as sent: padded, it no longer builds. - A pattern with an anchor inside a group, such as "(?:^abc)", is left as sent: xgrammar ignores an anchor in the middle, so padding would have let "xabc" through. - Each top-level alternative is padded on its own, so "^a|b" reads as "starts with a, or holds b" rather than "^(a|b).*". - normalize_schema no longer enters const, enum, default or examples, which are values, nor "not", whose meaning a rewrite would change. A property named like one of them is still a schema. - The comment on unsatisfiable bounds now says what happens: xgrammar ignores the bounds beside a pattern. The folded form's narrowing is noted. The live tests check for the expected word instead of a length above one, which a valid one-character answer would have failed. New checks in test_chat_tools cover each case through the grammar engine; on the previous code "^a|b" and the non-ASCII injection fail, and the inline-flag and inner-anchor patterns crash the harness. Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: tawei-amd <tawei@amd.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>


Summary
Add a stable C ABI for externally supplied FastFlowLM model frontends and backend providers.
Extensions can contribute:
New frontend families: Add support for architectures FLM does not understand yet, including configuration, prompt formatting, preprocessing, and output decoding.
Alternative backend providers: Supply a different engine for an existing family/backend without replacing the built-in implementation globally.
Model catalog entries: Add selectable model tags with their frontend family, backend/provider, model files, limits, and platform compatibility.
Extension-local runtime assets: Package engine-specific artifacts such as XCLBINs with the extension instead of rebuilding FLM or using global path overrides.
The existing built-in model path remains the default.
Rationale
Adding or replacing a model engine previously required changing and rebuilding FastFlowLM. External engines were coupled to internal C++ classes, registries, global state, and compiler/CRT compatibility.
This change allows independently built model implementations to plug into FastFlowLM without:
Gemma4-open validates the design as an external text, image, and audio provider on XRT and HRX.
Core concepts
Frontend
A frontend owns model-facing behavior:
A frontend is selected by
details.family.Built-in frontends remain registered by FastFlowLM. An extension may register a new frontend family or provide both ends of a private model-specific payload contract.
Backend
A backend identifies the execution contract or kernel flow used by a model package, such as
flmorcore.It describes package compatibility and how the frontend should prepare the engine context. It is not the identity of the library implementing that backend.
Backend provider
A provider is one implementation of a backend contract.
Backend registrations are keyed by:
For example:
This allows an external provider to implement the same logical backend without replacing the built-in implementation. The model catalog selects the exact compatible provider.
For multimodal entries,
frontend_provideridentifies the producer of opaque prefill payloads. This prevents a backend from receiving payloads generated by an incompatible frontend.Extension bundle
extension.jsonis the bundle manifest. It describes how to load an extension:All paths are bundle-relative.
The manifest describes the extension bundle, not the selectable models.
Catalog overlay
The catalog overlay contributes model tags and package metadata. It specifies:
Overlays cannot replace built-in tags. They are parsed and validated against staged frontend and backend registrations before anything is committed.
Both manifest and overlay formats have versioned JSON Schemas.
Stable ABI design
The public boundary is C-only and uses:
struct_sizefor append-only evolution.The required causal backend surface is intentionally small. Optional state, speculation, and health operations use independently versioned capability tables. Providers that do not expose those capabilities remain valid.
Model-specific payloads remain provider-owned and opaque to the generic loader.
Important implementation types
FrontendRegistryA process-wide singleton for built-in and extension frontends.
It owns loaded extension libraries and validated catalog overlays, and performs transactional extension registration and rollback.
BackendRegistryA process-wide singleton keyed by family/backend/provider.
It stores factories, traits, asset roots, and provider lifetime ownership. Built-in registrations use provider
builtin.ExtensionAutoModelAdapts a stable-C frontend implementation to FLM's internal
AutoModel.PreparedRequestOwns temporary stable-C request and payload views used by the frontend adapter.
ProviderBackendAdapts a stable-C backend instance to FLM's internal
ModelBackend.ProviderCausalLmAdapts the minimal causal callback table and optional capability tables to the internal
causal_lminterface.ExtensionFrontendRegistrationandExtensionBackendRegistrationStage extension contributions before atomic validation and publication.
ModelCatalogOverlayHolds a parsed, versioned extension catalog contribution.
BackendSelectionResolves and validates the exact backend/provider pair declared by a model package.
FrontendRegistryandBackendRegistryare the only process-wide registry singletons. Individualmodel_listinstances merge validated overlay snapshots; the model catalog itself is not another mutable singleton.Atomic registration and lifetime
Extension loading follows a transaction:
Provider libraries remain loaded while their factories, frontends, backends, or provider state may still be used. Extensions are explicitly unloaded before runtime shutdown.
Built-in compatibility
Built-in model registration now uses the same frontend/backend registries but remains selected through provider
builtin.Regression coverage verifies that provider filtering does not remove shipped model tags and that legacy model paths remain selectable.
A downloader compatibility check was also corrected to inspect model metadata without resolving host XCLBIN assets.
Validation
Hardware-free CI coverage includes:
Local hardware qualification includes:
No hardware E2E tests are added to CI.