Repository navigation
Add native Flint model, strict checkpoint loading and tool protocol - #322
Merged
Merged
Conversation
Within one paged prefill row/call, consecutive eligible query blocks with the same query and visible-key counts have byte-identical Boolean sliding masks: each block's first query sits (visible keys - queries) positions after its first visible key. Retain only the last such mask locally and pass it as the same .array SDPA mask, instead of rebuilding it per block. Span, bidirectional, softcap and Qwen4-indexer paths, cold blocks, one-query tails, arithmetic, 128-query blocking, gather-before-write and page ownership are unchanged. New tests compare exact BF16/FP32 outputs and retained KV against an independent per-block rebuild oracle across cold/wrapped histories (including a prefill gather across the physical ring seam), partial tails, decode and reordered packed rows. Paged A/B through the provider measured about +0.8% at 4K fixed-prompt prefill. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Bring in main through #323, including the mlx-swift main pin (67dc7528), GLM-5.3-Flash native support and Nemotron Super kernels. Resolve the tool-call format conflicts by keeping both the Flint and GLM5 parsers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jonathan308
marked this pull request as ready for review
October 22, 2026 00:09
jonathan308
added a commit
that referenced
this pull request
Oct 22, 2026
Brings #322 (Flint), #324, #326-#330 (CBv2 paged/MTP/SDPA, GPT-OSS), #325 and the Nemotron Super fused MTP verify window: SDK main up to the commit d-inference master pins (889fe3c). Main's later #331/#332 are left out until the provider adopts #332's streamed tool-call type. Package.swift pins the cluster mlx-swift 9fe34405 instead of main's 67dc7528; that was the only conflict. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
javiech1
pushed a commit
to javiech1/mlx-swift-lm
that referenced
this pull request
Oct 24, 2026
* Add support for Qwen3-VL-MoE models.
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.
Recursive's Flint checkpoint currently has no native Swift model or tool dialect in this SDK. This adds exact
flintregistration, strict BF16/official mixed-bit INT4 loading, hybrid full/sliding attention with learned sinks, and schema-aware streaming tool parsing. d-inference consumes this native implementation through its production CBv2 adapter.Update — paged sliding-mask reuse (
48bda794)Within one paged prefill row/call, consecutive eligible query blocks with equal query and visible-key counts have byte-identical Boolean sliding masks: each block's first query sits (visible keys − queries) positions after its first visible key.
PagedLayerCachenow keeps only the last such mask locally and passes it as the same.arraySDPA mask. Span, bidirectional, softcap and Qwen4-indexer paths, cold blocks, one-query tails, 128-query blocking, arithmetic order, gather-before-write and page ownership are unchanged.flowchart LR subgraph Before A1["Each 128-query block"] --> B1["Build causal+window Bool mask"] --> C1["SDPA .array(mask)"] end subgraph After A2["Each 128-query block"] --> D2{"Same counts as last eligible block?"} D2 -->|"yes"| E2["Reuse identical mask"] --> C2["SDPA .array(mask)"] D2 -->|"no / ineligible"| B2["Build mask"] --> C2 end classDef input fill:#dbeafe,stroke:#1d4ed8,color:#172554 classDef gate fill:#fef3c7,stroke:#b45309,color:#451a03 classDef native fill:#dcfce7,stroke:#15803d,color:#052e16 class A1,A2 input class D2 gate class B1,B2,C1,C2,E2 nativeCBv2PagedSlidingMaskReuseTests(new): exact BF16/FP32 output and retained-KV bytes vs an independent per-block rebuild oracle; cold/wrapped histories incl. a prefill gather across the physical ring seam; partial and one-query tails; decode; reordered packed rows; reservation cleanupCBv2PagedQueryBlocking,CBv2PagedQueryBlockBounds,CBv2PagedPackedSpan,CBv2AttentionSinkDtype,FlintPrefixTests,FlintTests(MLX_ENABLE_TF32=0, query block 128)Independent static review found the exactness argument sound; its ring-seam coverage and write-validation suggestions are included. The source-count estimate (4K mask builds 1,568 → 658) is not separately measured.
Earlier changes
Before — behavior and code flow
flowchart LR A["Flint checkpoint or tool stream"] --> B{"SDK registry / parser"} B --> C["Unsupported architecture / dialect"] classDef input fill:#dbeafe,stroke:#1d4ed8,color:#172554 classDef blocked fill:#fee2e2,stroke:#b91c1c,color:#450a0a class A,B input class C blockedAfter — behavior and code flow
flowchart LR A["Pinned Flint files"] --> B{"Strict configuration and tensors"} B --> C["Native decoder + CBv2 KV"] C --> D["Prefill final-row head / normal decode"] E["Flint tool stream"] --> F{"Schema-aware frame parser"} F --> G["Complete typed calls"] F --> H["Malformed frame rejected"] classDef input fill:#dbeafe,stroke:#1d4ed8,color:#172554 classDef native fill:#dcfce7,stroke:#15803d,color:#052e16 classDef blocked fill:#fee2e2,stroke:#b91c1c,color:#450a0a class A,B,E,F input class C,D,G native class H blockedThe CBv2 token-constraint mode now includes
auto, allowing the provider to apply native Flint reasoning/tool boundaries without requiring a tool call. The provider owns the bounded grammar and HTTP tests in d-inference draft #1535.The prompt-output optimization reuses the existing GPTOSS/Gemma CBv2 contract: every prompt token and KV write remains; unused vocabulary projections are omitted. FP32 routing probabilities, weighted reduction and head inputs are preserved. No TF32, activation quantization, MTP, or security/admission policy change is introduced. Packed prefill remains disabled.
Validation on physical M5 Max / 128 GiB, macOS 27.0, Swift 6.4, source-matched Metal library:
swift build --build-tests --scratch-path <owned-sdk-build>succeeded.MLX_ENABLE_TF32=0 swift test --skip-build --scratch-path <owned-sdk-build> --filter 'FlintTests|FlintToolTests|FlintPrefixTests|ToolCallParserIntegrationTests': 19 native/parser tests (including both paged and contiguous restore cases) plus 47 server parser integration tests passed.affine_qmm_t_naxand routedaffine_gather_qmm_rhs_nax_ntBF16-activation kernels; the FP32 output head used its portable fallback. This proves those dispatches, not a whole-model NAX speedup.scripts/check-unit-test-files.sh, fork-diff coverage check, Swift formatting andgit diff --checkpassed. Dedicated refactor subagent reviewed the implementation; regressions were fixed and tests rerun.The tested artifact is RecursiveSI/flint-int4@3b93f9053b530488405ae9fca51d4900d6ce21f0: group-64 affine INT4 projections/experts, INT8 embeddings, native BF16 KV; not NVFP4. All 11 serving files matched published SHA256 values. No weights are committed.
Credits: this is an attributed Swift adaptation of Prince Canuma's MIT mlx-vlm Flint implementation (#2565, reviewed
1a6ebd06459be3b18cb1c7922305c9e362612c62) and Recursive's Apache-2.0 rec conventions (e53663b262af4cb1ca498e596ca8b1a2d79e0800). The independent NumPy oracle also credits Prince's reference tests. Exact reuse/differences and complete licenses are inThirdPartyNotices/Flint.md.Draft limits: text-only model; raw string arguments cannot reliably contain the published protocol's literal
</arg_value>terminator. Full-release BF16/reference quality, maximum-context/RAM tiers, reduced-precision KV and MTP are unqualified. Preview access was unavailable, so preview acceptance is not inherited. d-inference performance and broader HTTP qualification are being reported separately; the 2× M3 Ultra prefill and 400 tok/s decode targets are not claimed as achieved. This PR does not publish a model, activate a catalog, or release a provider.