Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
336 commits
Select commit Hold shift + click to select a range
8c9dd63
Add speculative decoding (#173)
petrukha-ivan Apr 3, 2026
7d9a6ab
Fix doc comments and verify in CI (#176)
DePasqualeOrg Apr 6, 2026
780048f
Add more documentation for integrations to readme (#201)
DePasqualeOrg Apr 9, 2026
ec9619b
Fix tool calling for Llama 3 (#145)
aleroot Apr 9, 2026
ab04a9c
Add IntegrationTesting Xcode project and additional integration test …
atdrendel Apr 10, 2026
490aad2
Fix links in readme (#204)
DePasqualeOrg Apr 10, 2026
7f169f9
Preserve JSONValue in Llama3 Tool Calls (#203)
Lakr233 Apr 10, 2026
67b146e
Add gemma 4 model (text, vision, MoE) (#180)
adrgrondin Apr 13, 2026
f7c5c99
Add Gemma 4 text model support (E2B and E4B) (#185)
stefan-geens Apr 13, 2026
c1ff9f8
small v3 api fixes (#190)
davidkoski Apr 13, 2026
826fbc9
v3 api embedder fixes (#202)
davidkoski Apr 14, 2026
e61edac
Fix prompt-cache round-trip support for `ArraysCache`, `MambaCache`, …
ronaldmannak Apr 15, 2026
b94661e
Prepare Gemma4Text for batched RoPE offsets (#212)
ronaldmannak Apr 15, 2026
81fba5e
Fix Gemma 4 system message and modality order (#211)
adrgrondin Apr 15, 2026
b331db1
Add qwen3_next to tool call format inference (#166)
alankessler Apr 15, 2026
1c05248
add upgrade docs, how to use, how to develop. (#206)
davidkoski Apr 15, 2026
2dccb38
Guard embedder inputs against maxPositionEmbeddings (#163)
alankessler Apr 15, 2026
99a2b1c
Doc corrections for v3 (#216)
DePasqualeOrg Apr 16, 2026
7e2b710
add fallback links to the readme -- docs are not yet built (#218)
davidkoski Apr 17, 2026
3e2ddb4
Fix Qwen35 VLM crash on text-only inference (SmallVector out of range…
dirvine May 7, 2026
38fff58
Add coherence integration tests (#235)
DePasqualeOrg May 7, 2026
3033891
fix: flatten prompt in TokenRing.loadPrompt to handle 2D inputs (#168…
spokvulcan May 11, 2026
cb432f5
Pass tools schema to ToolCallProcessor for type-aware parsing (#167)
alankessler May 11, 2026
1f5e5f2
Forward tools and additionalContext in GlmOcr and SmolVLM2 processors…
alankessler May 11, 2026
c2b20d8
fix: avoid shared CIContext in media processing (#268)
Meapri May 11, 2026
88beb40
feat: add ParoQuant (pairwise rotation quantization) support (#164)
spokvulcan May 11, 2026
b1b358f
fix ropeOffset use in Gemma3NText (#280)
davidkoski May 11, 2026
f5c7ff8
Handle stringified JSON tool call arguments (#172)
kuosuko May 11, 2026
e5d152b
fix build (#281)
davidkoski May 12, 2026
81829f6
fix segsum dtype promotion -- 2x memory waste on hybrid SSM models (#…
TheTom May 12, 2026
9cd30c9
Remove TokenLoopHandler Sendable requirement (#284)
thisray May 13, 2026
802e8a7
feat: expose speculative decoding in ChatSession (#181) (#193)
VDurocher May 13, 2026
f2f8b2e
Fix EmbeddingGemma init-order crash + dense head hidden size (#223)
0xweb3r May 13, 2026
7e7663d
fix: disable CIContext intermediate caching to prevent IOSurface exha…
Satchitananda May 13, 2026
84ab278
fix Gemma 4 MoE router -- softmax order + fuse norm dispatches (#228)
TheTom May 14, 2026
b6aeaa6
add FusedGateUpSwitchGLU -- single fused gate_up_proj for MoE models …
TheTom May 14, 2026
d6f3529
Fix UserInput init not setting self.images / self.videos (#182) (#253)
john-rocky May 14, 2026
4676fb9
pipeline prefill chunks with asyncEval -- 10x on GDN models (#225)
TheTom May 14, 2026
c566c95
fix gated delta state precision -- fp32 state to match Python (#224)
TheTom May 14, 2026
5b7e543
Fix non-compiling README quick-start example (#265)
programVeins May 14, 2026
52e9994
combine docs check with build to reuse a macos runner (#286)
davidkoski May 18, 2026
34af558
Remove SDK build version command from workflow (#306)
madrob May 21, 2026
3f9c86f
models should not mutate state during eval (#283)
davidkoski May 22, 2026
84697ac
Fix: tolerate 1D token inputs in Gemma4 VLM forward pass (#241)
brdcastro May 22, 2026
a65869e
fix Idefics3 prepare() to honor windowSize -- prompt prefill is never…
Adi2K May 22, 2026
4f1bbaf
Fix Gemma 4 vision pooler kernel derivation (#290)
joshuaejackson May 22, 2026
b087445
Add LLM generation benchmark helper (#248)
john-rocky May 22, 2026
2409248
Fix Gemma4 attention crash when vProj is nil (attentionKeqV) (#247)
jfranknichols May 22, 2026
8c61800
Adopt GemmaFunctionParser to accomodate Gemma4 tool calls. (#183)
viktike May 22, 2026
82d9cd6
Optimize Gemma 4 text decode: compile-fused RMSNorm-add and gelu-mul …
john-rocky May 22, 2026
3c6dd34
fix Idefics3 vision encoder dtype -- SigLIP runs in float32 instead o…
Adi2K May 26, 2026
32d51e5
Share the fused gated-delta kernel between MLXLLM and MLXVLM
john-rocky May 26, 2026
e832341
Fix Qwen2-VL chat template: emit vision tokens before text (#242)
NivDvir May 27, 2026
93cf322
Fix float32 dtype consistency in gatedDeltaUpdate for Qwen3.5 models …
somegeekintn May 27, 2026
2d0acae
Fix vision-encoder attention mask being ignored in Qwen2.5-VL (#238)
NivDvir May 27, 2026
5626257
LoRA: runtime toggle and PEFT adapter loader (#316)
smdesai May 27, 2026
9650f9a
Fix Qwen35 VLM sanitize for bare 'model.*' weight keys (#143) (#254)
john-rocky May 27, 2026
2007b1e
Fix SmolVLM2 tiles() upscaling small images, ~9x slowdown (#208) (#255)
john-rocky May 27, 2026
ee5320d
Add structured ChatSession continuation (#313)
aleroot May 29, 2026
1335fb5
Fix sporadic bare-JSON tool call handling and harden JSON parser reco…
aleroot Jun 1, 2026
01b8624
Fix Gemma4Text quantized KV cache attention (#237)
aleroot Jun 1, 2026
cc712f4
Fix MROPE, rope_deltas, and invFreq loading in Qwen2.5-VL (#239)
NivDvir Jun 3, 2026
ef85ed0
Optimize shared MoE combine paths (#324)
aleroot Jun 3, 2026
de2fed7
Make Gemma 4 per_layer_model_projection quantizable (#309)
davidkoski Jun 3, 2026
a47894a
support for audio resources (#298)
davidkoski Jun 4, 2026
b95dc78
Qwen2/2.5-VL: default to the model card's image pixel budget (#243)
NivDvir Jun 9, 2026
d675185
Fix Gemma 4 cross-layer KV sharing in no-cache forward pass (#333)
pavan-kkn Jun 10, 2026
e145aca
Add Gemma 4 MTP speculative decoding (#308)
angelsbrood Jun 11, 2026
01ac5af
fix Gemma4 prepare() to honor windowSize -- prompt prefill is never c…
joshuaejackson Jun 11, 2026
771e4ee
Align Falcon H1 with upstream MLX inference (#331)
aleroot Jun 11, 2026
e3cb1e1
Fix LFM2-MoE sigmoid routing and expert-bias selection (#332)
ykhrustalev Jun 11, 2026
d166a68
remove references per author request (#341)
davidkoski Jun 15, 2026
e6a753a
fix speculative decode tests (#326)
davidkoski Jun 15, 2026
f37305a
Improve Qwen3.5 recurrent cache handling (#323)
aleroot Jun 16, 2026
48dfaec
Raise swift-syntax floor to 602.0.0 for prebuilt availability (#340)
roryford Jun 16, 2026
91323c6
Expose ModelTypeRegistry.contains(_:) for pre-load support checks (#349)
jfranknichols Jun 16, 2026
f436169
Add Nemotron Labs Diffusion (#310)
smdesai Jun 16, 2026
0ec0f33
fix MLXVLM prepare(): honor windowSize for chunked prefill (FastVLM /…
john-rocky Jun 17, 2026
4253824
Fix speculative decoding test oracle (#354)
aleroot Jun 17, 2026
9743c63
Fix nomic-embed-text-v1.5 'Key embeddings.position_embeddings.weight …
JamalK Jun 17, 2026
0767814
Add Gemma 4 12B unified (#327)
adrgrondin Jun 17, 2026
e00785f
Fix iOS build: replace homeDirectoryForCurrentUser with shared HF cac…
hehua2008 Jun 18, 2026
4f1371d
Add speculative decoding telemetry and memory gating (#314)
aleroot Jun 18, 2026
e48c6b0
Add Swift model conversion API (#318)
aleroot Jun 19, 2026
944828f
Fix build on Xcode 16.3 / SDK < 26 (#359)
pcuenca Jun 21, 2026
d1d9a09
add kvScheme parameter for extensible KV cache compression (#230)
TheTom Jun 22, 2026
4bba1a8
Fix Gemma4 QAT load: KV-shared layers carry no k_proj/v_proj/k_norm (…
Flo5k5 Jun 22, 2026
a35746c
Lfm2.5 bidirectional embedders (#365)
ronaldmannak Jun 23, 2026
40c2ff0
Fix Gemma4 VLM PTQ load: drop redundant K/V tensors of KV-shared laye…
Flo5k5 Jun 23, 2026
e75c578
Validate RoPE model configurations (#371)
RNT56 Jun 26, 2026
3135127
Add runtime stop string handling (#372)
RNT56 Jun 26, 2026
4716b63
Falcon-H1R: correctness, cache, and preset fixes (#368)
aleroot Jun 26, 2026
1248805
Fix Gemma4 VLM end token defaults (#373)
RNT56 Jun 26, 2026
84a0cb0
Add Mamba2 (pure SSM) model (#380)
GoodOlClint Jun 29, 2026
ccdc386
Add Mixtral (sparse MoE) model (#378)
GoodOlClint Jun 29, 2026
ce06d36
Skip vision_embedder weights in Gemma4Model.sanitize (#366)
surawatthana Jun 29, 2026
41cba40
Gemma4: drop gemma4_unified vision_embedder weights in sanitize (#363)
neuromechanist Jun 29, 2026
4cea9e5
Support correlated tool call transcripts (#360)
aleroot Jun 29, 2026
e31237a
Qwen2-VL: implement M-RoPE in the language model (port of #239) (#345)
mnmly Jun 29, 2026
bd4b743
Add optional seed to GenerateParameters for reproducible sampling (#377)
GoodOlClint Jun 29, 2026
702e5a0
Set indentConditionalCompilationBlocks to false in .swift-format (#385)
ctymoszek Jun 30, 2026
b4fb830
CI: fix mac_build_and_test for mlx-swift >= 0.31.5 (skip package plug…
GoodOlClint Jul 9, 2026
4d73efe
ci: pin swift-format version so lint doesn't drift across PRs (#386)
GoodOlClint Jul 9, 2026
feff32d
Gemma 3: chunked prompt prefill, skipping lm_head on prompt positions…
beshkenadze Jul 9, 2026
09deb8c
Fix Gemma 4 VLM load: KV-shared layers must not declare k_proj/v_proj…
fdagostino Jul 10, 2026
2913a7d
add note on swift-format version and fill out configuration (#416)
davidkoski Jul 10, 2026
2c1dd13
ChatSession: cancel the generation task when the consumer goes away (…
fdagostino Jul 10, 2026
ec6b56a
Qwen3 embedder: honor attentionMask instead of silently ignoring it (…
spokvulcan Jul 13, 2026
2118561
Qwen3VL: apply the sRGB tone curve in the image preprocess path (#411)
spokvulcan Jul 13, 2026
d14cf3d
Convert Gemma tool parameters by schema type (#388)
atdrendel Jul 13, 2026
42f08a8
Fix prefill LMOutput.State being dropped on TokenIterator's .logits p…
NivDvir Jul 13, 2026
2f95038
Fix Qwen3.5 VLM sanitize double-shifting pre-converted RMSNorm weight…
GoodOlClint Jul 13, 2026
f5f18ed
fix: Honor safetensors index when loading weights (#408)
Zrxrxrx Jul 13, 2026
65be34c
Qwen3.5/3.6: windowed prefill + state-threaded warm continuation (fix…
spokvulcan Jul 14, 2026
57299b4
Make DeepseekV3Model.init public (#422)
magicnight Jul 14, 2026
65e28c2
Make MLXLLM compilable on Linux (#321)
gmondada Jul 14, 2026
19de279
Fix tool round-trip: record assistant tool_calls message before tool …
jacobwillemsma Jul 14, 2026
2b03485
Add cooperative cancellation check to prefill loop (#423)
sunshinfight Jul 14, 2026
10e0cb7
Fix cancellation submission race (#389)
SpiraMira Jul 14, 2026
f1573a9
Add MLXFoundationModels: an MLX-backed FoundationModels LanguageModel…
ctymoszek Jul 15, 2026
2f42530
Update project name in CONTRIBUTING.md (#427)
CharlieTLe Jul 15, 2026
efd498b
Decode PoolingConfiguration with optional pooling_mode flags (#376)
GoodOlClint Jul 15, 2026
93d46d8
Qwen3VL: default per-image resolution to a 1,280 vision-token budget …
spokvulcan Jul 15, 2026
5f4f570
Fix silent state truncation for non-multiple-of-32 GDN key dim (#381)
GoodOlClint Jul 15, 2026
4270a9a
Document model compatibility requirements (#303)
RNT56 Jul 15, 2026
68947cc
Fix MLXVLM Gemma4 loader to honor num_kv_shared_layers (E-series targ…
GoodOlClint Jul 15, 2026
d242429
Document -skipPackagePluginValidation for local test runs (#430)
CharlieTLe Jul 15, 2026
631325f
Fix Python finfo.min port in quantized attention masking (#369)
ronaldmannak Jul 15, 2026
2a2bdf4
Implement Gemma 4 E-series MTP centroid embedder (use_ordered_embeddi…
GoodOlClint Jul 15, 2026
4ca25fd
Update link to CONTRIBUTING document in PR template (#428)
CharlieTLe Jul 15, 2026
60bd0d7
Gemma 4: aspect-preserving image resize with per-image dynamic token …
prbme Jul 16, 2026
2a76e56
Track the current SDK's SamplingMode.Kind case names (#431)
CharlieTLe Jul 17, 2026
51b0fce
update tag on swift-format -- I had it wrong (#421)
davidkoski Jul 17, 2026
9cd1a48
Fix FoundationModels API drift and the integration tests that no long…
thechriswebb Jul 17, 2026
e69d0a9
fix(MLXFoundationModels): prepare tool-calling input through the mode…
jyauxi Jul 17, 2026
616cae2
Make BaseKVCache.ropeOffset overridable (#437)
GoodOlClint Jul 17, 2026
1c86cc1
fix(MLXFoundationModels): stop respond() crashing when emitting usage…
thechriswebb Jul 17, 2026
343cae3
Silence Metal compiler warning noise in integration test runs (#440)
CharlieTLe Jul 17, 2026
fd0f13b
add TurboQuant KV cache compression (#232)
TheTom Jul 20, 2026
6608a35
Expose minimal Gemma3 surface for frozen-text-encoder use (#387)
xocialize Jul 21, 2026
bc95ffb
Load EOS token IDs from nested text configs (#449)
aleroot Jul 21, 2026
f1bfca4
Optimize Qwen3.5 interleaved M-RoPE (#442)
aleroot Jul 21, 2026
e6e3de7
MLXLLM Gemma4Text: add MoE block (router + experts) (#364)
neuromechanist Jul 21, 2026
8e3b3f0
Fix MTP integration test skip semantics; auto-download 31B checkpoint…
CharlieTLe Jul 21, 2026
78eaa5b
Enable MTP speculative decoding for Gemma 4 12B (gemma4_unified targe…
fdagostino Jul 21, 2026
1032402
Hoist tool-schema $defs to the tool-calling envelope root (fixes #432…
jyauxi Jul 22, 2026
f7cacbc
Qwen3VL vision: per-image fused SDPA instead of a dense joint mask (#…
kklimuk Jul 22, 2026
eaefe75
Add regression coverage for mixed-precision quantized checkpoint load…
fdagostino Jul 22, 2026
12d2da0
DeepSeek-V3: populate kvHeads and update the KV cache once per attent…
GoodOlClint Jul 22, 2026
9d3a497
Support multi-round tool calling in MLXFoundationModels (#456)
thechriswebb Jul 23, 2026
294c31f
Add DeepSeek-V2 model (#379)
GoodOlClint Jul 23, 2026
5cd767e
Add Hunyuan dense V1 (hunyuan_v1_dense): Hunyuan-MT-7B and Hy-MT2-7B …
beshkenadze Jul 23, 2026
5fbb130
Add GitHub workflow for IntegrationTesting tests (#458)
CharlieTLe Jul 23, 2026
18edd22
Add end-to-end video input to the base Gemma 4 (gemma4) VLM (#391)
fdagostino Jul 23, 2026
3cbf928
Integration tests: build on both macOS 26 and 27 SDKs (#464)
CharlieTLe Jul 24, 2026
6056cbc
Add routing-correctness tests for GLM4MOE / GLM4MOELite MoE gates (#463)
GoodOlClint Jul 27, 2026
45693f6
Fix guided generation dropping required properties via streaming deto…
thechriswebb Jul 27, 2026
4d71d12
Integration tests CI: run on Xcode 26 only (#477)
CharlieTLe Jul 27, 2026
a65e78f
Gate remaining FoundationModels integration tests behind the 27 SDK (…
CharlieTLe Jul 27, 2026
3b3516d
Integration tests: scope down heavy suites, fix flakes and memory pre…
CharlieTLe Jul 28, 2026
3697686
feat(models): add Nanbeige (looped transformer) support (#460)
spokvulcan Jul 29, 2026
0bd3da4
Qwen3.5/3.6: run the decode step through compiled traces (#467)
spokvulcan Jul 29, 2026
861649b
Qwen3.5/3.6 MoE: fused router top-k kernel for decode (bit-identical,…
spokvulcan Jul 29, 2026
b207f60
Fix Gemma 3n Boolean attention masks (#479)
codesworth Jul 29, 2026
fa652f9
Fix LFM2 tool-call arg parsing; make tool-call tests deterministic; g…
CharlieTLe Jul 30, 2026
0321f28
Qwen3.5/3.6: fold the GDN decode conv into the compiled step (#468)
spokvulcan Jul 30, 2026
405146b
Fix structured ChatSession continuations (#472)
aleroot Jul 30, 2026
4c86bed
Let models declare chat conventions via ChatConventionsProviding (#482)
CharlieTLe Jul 30, 2026
a2736d4
Qwen2.5-VL / Qwen2-VL: windowed prefill + state-threaded warm continu…
NivDvir Jul 30, 2026
510b891
Fix remaining Linux build breaks in MLXLMCommon and MLXGuidedGenerati…
GoodOlClint Jul 31, 2026
d5d8b29
Fix gated delta recurrence precision (#488)
aleroot Jul 31, 2026
83f3ef6
Fix TF32 test-oracle flakiness in the Gemma4 chunk-invariance tests (…
GoodOlClint Jul 31, 2026
cd1ab3d
Add support for Qwen3-VL-MoE models (#322)
lucasnewman Aug 1, 2026
3d292ec
Migrate all models to ChatConventionsProviding; delete the infer chai…
CharlieTLe Aug 3, 2026
26f3a48
Add custom LogitProcessor injection to GenerateParameters / ChatSessi…
xocialize Aug 4, 2026
3ad8d0c
Run Integration Tests nightly and report failures on a tracking issue…
CharlieTLe Aug 5, 2026
bf4a953
Stand down from MTP speculation before the sliding cache wraps (#506)
angelsbrood Aug 5, 2026
38927f5
Add typed KV cache configuration and runtime reporting (#453)
aleroot Aug 5, 2026
7a94632
Add parser for GPT-OSS Harmony tool call format (#146)
aleroot Aug 6, 2026
4c7874b
Prefill: balanced chunking behind a new PrefillParameters (~9% at 32K…
spokvulcan Aug 6, 2026
c97539d
Olmo3: fix newCache signature so the sliding-window cache is actually…
GoodOlClint Aug 6, 2026
4b0b416
Prompt cache: persist model state, wire Qwen3-VL and GLM-OCR restorat…
kklimuk Aug 10, 2026
5c1d95a
Add single-dispatch TurboFlash for short contexts (#520)
aleroot Aug 10, 2026
a3eb1f1
Update Package.swift (#519)
ActuallyTaylor Aug 11, 2026
44a136c
Fix tied quantized Qwen3 MoE head sanitization (#490)
JamesPriceZV Aug 11, 2026
2af378b
Speculate past the sliding window in MTP (#516)
angelsbrood Aug 11, 2026
0b47e69
Remove the untyped staged-cache fallback (#526)
angelsbrood Aug 11, 2026
4ffa64d
Add Muse-Glimmer, a 30B agentic multimodal model, with ATEM tool call…
CharlieTLe Aug 12, 2026
5d8def8
Enforce and expose effective KV cache limits (#514)
aleroot Aug 12, 2026
b42181e
Add protocol-aware thinking budget enforcement (#521)
aleroot Aug 13, 2026
01472a7
Add Qwen3.5 MTP speculative decoding (#351)
aleroot Aug 13, 2026
3260260
Add Qwen 3.5 JSON tool-call fallback (#529)
aleroot Aug 13, 2026
5a81319
bump mlx-swift to 0.31.6 -- .4 was missing new API that the current c…
davidkoski Aug 13, 2026
d667610
Expose Gemma 4 encoder surface at @_spi(GemmaEncoder) (#530)
xocialize Aug 13, 2026
6f609be
Enforce copy semantics on LogitProcessor for speculative decoding (#5…
aleroot Aug 14, 2026
3de04ab
Fix tied word embedding weight sanitization (#532)
aleroot Aug 14, 2026
e5d6cfb
Add TranslateGemma support (Gemma 3 translation template) (#348)
beshkenadze Aug 14, 2026
381469a
Support video processing options in UserInput and MediaProcessing (#4…
aleroot Aug 14, 2026
d7dc03d
Surface rejected tool calls as generation events (#512)
aleroot Aug 14, 2026
a72fcec
Handle Generation.rejectedToolCall and add an Xcode 27 compile check …
CharlieTLe Aug 17, 2026
ef0b0cc
Fix nested tool grammar schema test (#527)
angelsbrood Aug 17, 2026
03258e6
Qwen2.5-VL: accumulate vision cuSeqlens across temporal slices (#509)
NivDvir Aug 17, 2026
b2c1091
Add Qwen3.5 VLM processor config fallback (#546)
ngutech21 Aug 17, 2026
7871b09
Tool call parser hardening (#531)
aleroot Aug 17, 2026
95cc8b8
Muse Glimmer: honor the requested KV-cache capacity (#556)
aleroot Aug 20, 2026
99c0e5f
Report prompt-cache reuse in GenerateCompletionInfo (#559)
aleroot Aug 20, 2026
72d9fdb
Enable cache reuse for text-only inputs (#549)
ngutech21 Aug 20, 2026
2b39bab
Add opt-in q4_0 lattice calibration to model conversion (#507)
GoodOlClint Aug 20, 2026
4c21bf6
Add Helium (Kyutai) LLM port (#555)
noorbhatia Aug 20, 2026
3c5805a
Read Gemma's brace-form object and array values (#557)
aleroot Aug 20, 2026
b6ba48d
Add LoRA dropout and training mode support (#541)
aleroot Aug 20, 2026
130e3f0
Add reranker API support (#375)
aleroot Aug 20, 2026
d661402
Load weight files a safetensors index leaves out (#562)
aleroot Aug 21, 2026
1441444
Fix MLXFoundationModels compilation against the Xcode 27 beta 5 SDK (…
abra-code Aug 22, 2026
d3f28a8
Tune TurboFlash query grouping for short decode (#570)
aleroot Aug 24, 2026
1970177
Fix mixed-precision QLoRA output promotion (#564)
aleroot Aug 24, 2026
60985ee
Add extensible VLM processor loading rules (#565)
aleroot Aug 24, 2026
626516b
Share fused Qwen3.5 router top-k across LLM and VLM (#567)
ngutech21 Aug 24, 2026
9219508
Fix SSM gradient transforms across chunks (#571)
aleroot Aug 24, 2026
410a214
MLXVLM: resolve the LFM2VL image token id from the vocabulary instead…
Siddhesh2377 Aug 25, 2026
5c07f31
Strengthen chunked SSM gradient tests (#574)
aleroot Aug 25, 2026
e36d8ce
Parallelize weight loading with byte-balanced contiguous groups(up to…
aleroot Aug 25, 2026
6745899
Add variance-normalized KV cache (#329)
aleroot Aug 25, 2026
c684e65
Temporarily disable the Xcode 27 integration build on pull requests (…
thechriswebb Aug 26, 2026
476a472
Replace MLXRandom.seed with task-local withRandomState in tests (#583)
aleroot Aug 27, 2026
68e89f9
Add AI usage policy (#585)
ctymoszek Aug 27, 2026
846964d
Generalize compiled decode segments to Qwen 3 Next (#569)
aleroot Aug 27, 2026
db767ef
Share fused MoE router top-k across models (#568)
aleroot Aug 27, 2026
5b81858
Qwen direct reduction (#573)
aleroot Aug 28, 2026
37688d2
Fuse Qwen GDN input projections (#572)
aleroot Aug 28, 2026
fc0566a
Clear the compiler warnings from the library and both test targets (#…
thechriswebb Aug 31, 2026
599d07b
Leverage GitHub workflows to keep PR labels up-to-date (#587)
thechriswebb Aug 31, 2026
28a7f30
Qwen3.5: don't shift norm weights just because a checkpoint has MTP t…
mandrael Aug 31, 2026
d443de7
Fix DeepSeek MTP layer filtering (#592)
aleroot Aug 31, 2026
ad00de5
Allow downstream specialization of the Qwen3.5 GDN/MoE blocks and Swi…
agerjura Aug 31, 2026
7e9f84b
Expose Falcon-H1 encoder surface at @_spi(FalconH1Encoder) (#596)
xocialize Aug 31, 2026
0f25e86
Report prompt token counts to FoundationModels again (#591)
thechriswebb Aug 31, 2026
1c1b257
Suspend instead of blocking cooperative threads while weights load (#…
aleroot Sep 1, 2026
5694a2f
Harden the Foundation Models test fixtures (#599)
thechriswebb Sep 1, 2026
e23300b
ParoQuant: extend to MoE and make the whole path fast (#164 follow-up…
spokvulcan Sep 3, 2026
ac17cf6
Await the async loadWeights overload in IntegrationTesting (#605)
thechriswebb Sep 3, 2026
ebae332
Declare module weights as compile state in compiled decode paths (#589)
aleroot Sep 3, 2026
e3d4a20
Gemma4Text: expose decoder layers as loraLayers so MLP adapters load …
cives93 Sep 3, 2026
db05290
Let training differentiate the gated-delta recurrence (#616)
jhancock1975 Sep 9, 2026
4c3d793
Emit only the new scalars when a token extends the previous character…
spokvulcan Sep 10, 2026
1012230
Gemma 4 VLM: fuse float32 logit softcapping (#615)
aleroot Sep 10, 2026
9ce5b4f
Fix generation loop blocking Swift cooperative workers (#611)
aleroot Sep 10, 2026
238ad74
Add configuration-based LoRA metadata discovery (#597)
aleroot Sep 10, 2026
604fae7
RotatingKVCache: make trim wrap-aware instead of corrupting the ring …
aleroot Sep 11, 2026
b887197
Merge upstream model runtime fixes through 604fae7
Satchitananda Sep 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Libraries/MLXLLM/Documentation.docc/using-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,27 @@ public class LLMModelFactory: ModelFactory {
Callers with specialized requirements can use these individual components to manually
load models, if needed.

### Inspecting LoRA Metadata

Use ``LLMModelFactory/loraMetadata(configurationData:)`` to discover the model's LoRA
layer count and default runtime module paths without loading checkpoint weights:

```swift
let configurationURL = modelDirectory.appending(component: "config.json")
let configurationData = try Data(contentsOf: configurationURL)

if let metadata = try await LLMModelFactory.shared.loraMetadata(
configurationData: configurationData
) {
print(metadata.layerCount)
print(metadata.defaultKeys)
}
```

The returned `LoRAModelMetadata.defaultKeys` come from the registered model architecture,
not from safetensors names. This accounts for models that rename or reshape checkpoint weights
while loading.

## Evaluation Flow

- Load the Model
Expand Down
8 changes: 8 additions & 0 deletions Libraries/MLXLLM/LLMModelFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,14 @@ public final class LLMModelFactory: GenericModelFactory {
/// by the model itself, e.g. DeepSeek-R1
public let conventionsRegistry: ChatConventionsRegistry

/// Returns the model's LoRA metadata from its configuration without loading weights.
///
/// The registered model architecture is instantiated so custom `LoRAModel.loraDefaultKeys`
/// implementations remain authoritative. No checkpoint files are read.
public func loraMetadata(configurationData: Data) async throws -> LoRAModelMetadata? {
try await typeRegistry.loraMetadata(configurationData: configurationData)
}

public func _load(
configuration: ResolvedModelConfiguration,
tokenizerLoader: any TokenizerLoader
Expand Down
9 changes: 6 additions & 3 deletions Libraries/MLXLLM/Models/Qwen35.swift
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,8 @@ final class Qwen35GatedDeltaNet: Module {
aLog: aLog,
dtBias: dtBias,
state: recState,
mask: prefixMask)
mask: prefixMask,
useKernel: !training)
let (suffixOut, suffixState) = gatedDeltaUpdate(
q: qNormed[0..., split..., 0..., 0...],
k: kNormed[0..., split..., 0..., 0...],
Expand All @@ -434,7 +435,8 @@ final class Qwen35GatedDeltaNet: Module {
aLog: aLog,
dtBias: dtBias,
state: prefixState,
mask: suffixMask)
mask: suffixMask,
useKernel: !training)
out = concatenated([prefixOut, suffixOut], axis: 1)
newRecState = suffixState

Expand All @@ -458,7 +460,8 @@ final class Qwen35GatedDeltaNet: Module {
aLog: aLog,
dtBias: dtBias,
state: recState,
mask: mask)
mask: mask,
useKernel: !training)
checkpoint = nil
}

Expand Down
3 changes: 2 additions & 1 deletion Libraries/MLXLLM/Models/Qwen3Next.swift
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,8 @@ public final class Qwen3NextGatedDeltaNet: Module {
aLog: aLog,
dtBias: dtBias,
state: recState,
mask: mask
mask: mask,
useKernel: !training
)

let normalized = norm(out, gate: z)
Expand Down
38 changes: 38 additions & 0 deletions Libraries/MLXLMCommon/Adapters/LoRA/LoRAModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,36 @@ import Foundation
import MLX
import MLXNN

/// Metadata describing where a model applies LoRA adapters.
public struct LoRAModelMetadata: Sendable, Equatable {
/// Number of model layers that support LoRA adapters.
public let layerCount: Int

/// Default module paths, relative to each LoRA layer, that receive adapters.
public let defaultKeys: [String]

public init(layerCount: Int, defaultKeys: [String]) {
self.layerCount = layerCount
self.defaultKeys = defaultKeys
}
}

extension ModelTypeRegistry where T == any LanguageModel {
/// Inspects the registered model's LoRA layers without loading checkpoint weights.
///
/// Model construction and metadata access use an independent random state.
/// Returns `nil` if the model does not conform to ``LoRAModel``.
public func loraMetadata(configurationData: Data) throws -> LoRAModelMetadata? {
try withRandomState(MLXRandom.RandomState(seed: 0)) {
let configuration = try JSONDecoder.json5().decode(
BaseConfiguration.self, from: configurationData)
let model = try createModel(
configuration: configurationData, modelType: configuration.modelType)
return (model as? LoRAModel)?.loraMetadata
}
}
}

public protocol LoRAModel {

/// Return the layers to apply LoRA adapters to.
Expand All @@ -26,6 +56,14 @@ public protocol LoRAModel {

extension LoRAModel {

/// Metadata for configuring LoRA without inspecting checkpoint weight names.
public var loraMetadata: LoRAModelMetadata {
LoRAModelMetadata(
layerCount: loraLayers.count,
defaultKeys: loraDefaultKeys.sorted()
)
}

/// By default we apply LoRA to all Linear layers.
/// This is aligned with `mlx-lm` Python logic.
public var loraDefaultKeys: [String] {
Expand Down
12 changes: 7 additions & 5 deletions Libraries/MLXLMCommon/Evaluate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2418,9 +2418,11 @@ private func generateLoopTask<
let handler = SendableBox(handler)
let tokenCollector = consume tokenCollector

// Launch a Task to perform iteration asynchronously.
// Keep task cancellation and task-local values while moving blocking MLX work
// onto a separate queue for each generation.
let task = Task {
let performIteration = {
let worker = GenerationWorker()
let performIteration = { @Sendable in
var iterator = iterator.consume()
var handler = handler.consume()
var tokenCollector = tokenCollector
Expand Down Expand Up @@ -2546,10 +2548,10 @@ private func generateLoopTask<

if let ticket = wiredMemoryTicket {
return await WiredMemoryTicket.withWiredLimit(ticket) {
performIteration()
await worker.run(performIteration)
}
} else {
return performIteration()
return await worker.run(performIteration)
}
}

Expand Down Expand Up @@ -2840,7 +2842,7 @@ private enum TokenLoopDisposition {
}
}

private protocol TokenLoopHandler {
private protocol TokenLoopHandler: SendableMetatype {
associatedtype Output

/// Semantic boundaries contributed by the response protocol handled by
Expand Down
103 changes: 79 additions & 24 deletions Libraries/MLXLMCommon/GatedDelta.swift
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,59 @@ private func gatedDeltaStepOps(
return (y.asType(q.dtype), state)
}

/// Steps per recompute chunk in `gatedDeltaOps`.
///
/// The ops path is the one that can be trained through (the fused kernel
/// has no gradient), and a recurrence run as plain ops keeps every step's
/// state for the backward pass: at Qwen3.5-27B's shapes (48 heads of
/// 128x128 fp32) that is about 4 MB a step, gigabytes per layer at a
/// thousand tokens. Each chunk is run through a custom function whose
/// backward recomputes the chunk instead, so only the chunk boundaries are
/// kept - what `mx.checkpoint` does for the Python trainer. Inference is
/// unaffected: the forward is the same ops in the same order.
let gatedDeltaRecomputeChunk = 16

private enum GatedDeltaRecompute {
/// `inputs` = [q, k, v, g, beta, state] plus the mask when there is one,
/// each sliced to the chunk; returns [y, state].
static func steps(_ inputs: [MLXArray], masked: Bool) -> [MLXArray] {
let (q, k, v, g, beta) = (inputs[0], inputs[1], inputs[2], inputs[3], inputs[4])
var state = inputs[5]
let mask = masked ? inputs[6] : nil
var ys = [MLXArray]()
ys.reserveCapacity(q.dim(1))
for t in 0 ..< q.dim(1) {
let (y, newState) = gatedDeltaStepOps(
q: q[0..., t],
k: k[0..., t],
v: v[0..., t],
g: g[0..., t],
beta: beta[0..., t],
state: state,
mask: mask.map { $0[0..., t] }
)
ys.append(y)
state = newState
}
return [MLX.stacked(ys, axis: 1), state]
}

// The closure holds a locked state object; two callers serialise on it.
nonisolated(unsafe) static let unmasked: ([MLXArray]) -> [MLXArray] = CustomFunction {
Forward { steps($0, masked: false) }
VJP { primals, cotangents in
vjp({ steps($0, masked: false) }, primals: primals, cotangents: cotangents).1
}
}

nonisolated(unsafe) static let masked: ([MLXArray]) -> [MLXArray] = CustomFunction {
Forward { steps($0, masked: true) }
VJP { primals, cotangents in
vjp({ steps($0, masked: true) }, primals: primals, cotangents: cotangents).1
}
}
}

func gatedDeltaOps(
q: MLXArray,
k: MLXArray,
Expand Down Expand Up @@ -258,30 +311,27 @@ func gatedDeltaOps(
var state = state ?? MLXArray.zeros([B, Hv, Dv, Dk], dtype: .float32)

var ys = [MLXArray]()
ys.reserveCapacity(T)

for t in 0 ..< T {
let qT = q[0..., t]
let kT = k[0..., t]
let vT = v[0..., t]
let gT = g[0..., t]
let betaT = beta[0..., t]
let maskT = mask == nil ? nil : mask![0..., t]

let (y, newState) = gatedDeltaStepOps(
q: qT,
k: kT,
v: vT,
g: gT,
beta: betaT,
state: state,
mask: maskT
)
ys.append(y)
state = newState
ys.reserveCapacity((T + gatedDeltaRecomputeChunk - 1) / gatedDeltaRecomputeChunk)

for start in stride(from: 0, to: T, by: gatedDeltaRecomputeChunk) {
let steps = start ..< min(start + gatedDeltaRecomputeChunk, T)
var inputs = [
q[0..., steps], k[0..., steps], v[0..., steps], g[0..., steps], beta[0..., steps],
state,
]
let run: ([MLXArray]) -> [MLXArray]
if let mask {
inputs.append(mask[0..., steps])
run = GatedDeltaRecompute.masked
} else {
run = GatedDeltaRecompute.unmasked
}
let out = run(inputs)
ys.append(out[0])
state = out[1]
}

let y = MLX.stacked(ys, axis: 1)
let y = ys.count == 1 ? ys[0] : MLX.concatenated(ys, axis: 1)
return (y, state)
}

Expand All @@ -296,7 +346,8 @@ public func gatedDeltaUpdate(
aLog: MLXArray,
dtBias: MLXArray,
state: MLXArray? = nil,
mask: MLXArray? = nil
mask: MLXArray? = nil,
useKernel: Bool = true
) -> (MLXArray, MLXArray) {
let beta = sigmoid(b).asType(.float32)
let g = computeGatedDeltaG(aLog, a, dtBias)
Expand All @@ -320,7 +371,11 @@ public func gatedDeltaUpdate(
// Dk = 192 (a multiple of 32), but the value is config-driven, so route any
// non-multiple-of-32 Dk to the ops fallback, which handles an arbitrary key
// dimension correctly (slower, but never truncating).
if GatedDeltaKernelManager.shared.kernel != nil, Dk % 32 == 0 {
//
// `useKernel: false` is for training: the kernel is a custom Metal
// kernel and has no gradient, so a model in training mode passes
// `!training` here, as the Python model does with `use_kernel`.
if useKernel, GatedDeltaKernelManager.shared.kernel != nil, Dk % 32 == 0 {
return gatedDeltaKernel(q: q, k: k, v: v, g: g, beta: beta, state: state, mask: mask)
}

Expand Down
14 changes: 14 additions & 0 deletions Libraries/MLXLMCommon/Gemma4Fusions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import MLX

private let compiledGemma4Softcap = compile(shapeless: true) {
(logits: MLXArray, cap: MLXArray) in tanh(logits / cap) * cap
}

package func gemma4LogitSoftcap(_ logits: MLXArray, _ cap: MLXArray) -> MLXArray {
guard cap.dtype == .float32 else { return tanh(logits / cap) * cap }
// Promote before tracing: mixed float16/float32 division can round differently inside compile.
if logits.dtype == .float16 || logits.dtype == .bfloat16 {
return compiledGemma4Softcap(logits.asType(.float32), cap)
}
return compiledGemma4Softcap(logits, cap)
}
Loading