Skip to content

Merge upstream mlx-lm 4cfc647 into local - #26

Merged
eejd merged 15 commits into
localfrom
merge/upstream-4cfc647
Nov 15, 2026
Merged

eejd merged 15 commits into
localfrom
merge/upstream-4cfc647

Conversation

@eejd

@eejd eejd commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Merge

Merge upstream 4cfc6478473b0668ede3eb0cc93f2a9181a15052 into local with a merge commit. No tag is cut here; v0.32.2-local06 remains planned.

The 12 upstream commits:

Conflict resolutions

  • generate.py: take upstream TextStateMachine reader/Delta implementation, not the former tuple API; retain the fork's token stop-sequence helper and stream_generate(ignore_eos=...) behavior.
  • server.py: retain imports and BareToolCallFilter; adapt the formatter to upstream Delta tool calls while retaining the NotAToolCall content fallback and streaming indices. Preserve GenerationArguments.ignore_eos and request parsing/validation alongside upstream stop validation. Replace the old cached state-machine factory with upstream text-state and stop readers; for batched insertion select EOS stop tokens per request and omit ignored EOS from detokenization, while single generation forwards ignore_eos. In the chat handler feed the new reader and flush bare-call recovery at each normal-state exit, then handle parser fallback content and tool-call finish reasons for streaming and non-streaming. Upstream text stop handling remains in place.
  • tests/test_server.py: retain both upstream and fork tests, adapting fork state-machine helpers to readers and upstream formatter assertions to the fork's tuple return. No topic test was intentionally deleted or weakened.
  • Auto-merged Mistral vocabulary detection, Llama parser registration and batch KV-cache fast-mask code remain wired. pyproject.toml excludes non-PEP-440 fork -local* tags from setuptools-scm's git describe; without this, editable installation fails parsing v0.32.2-local05.

Verification and limitations

Python 3.14, MLX 0.32.4+local03, HF_HUB_OFFLINE=1, models cached (including mlx-community/Qwen1.5-0.5B-Chat-4bit, which the first run lacked); full pytest tests --continue-on-collection-errors in each tree:

  • Upstream 4cfc647: 23 failed, 357 passed, 1 skipped, 1 error, 181 subtests passed.
  • Merge (final head): 23 failed, 451 passed, 1 skipped, 1 error, 356 subtests passed.

The failing and erroring sets are identical in both trees (numerical assertions in test_generate/test_models, among them test_flint, uncached tokenizer models, one collection error in tests/models/test_muse_spark.py): they are inherited from pristine upstream on this host. The 94 extra passes are the carried topics' tests, all of which now run, including every TestIgnoreEos test (23 passed, 142 subtests).

An earlier version of this body said the model-dependent topic tests did not run and that no topic test was weakened. An independent review found four TestIgnoreEos tests failing in the merged tree because the test helper read ResponseGenerator._state_machine_cache, which upstream removed (the machine is built per request). The helper no longer touches a cache (commit 8e78509); the assertions are unchanged.

Deliberately kept fork behaviour (also in UPSTREAM.md): the made_call finish-reason rule of topic llama3-tool-parser, which differs from upstream's tool_formatter.count for a response whose only tool call fails to parse (tool_calls here, stop upstream). Open owner decision. Packaging: the port needs pillow in depends_lib (upstream dc2012b).

PYTHONPATH=<merged tree> python -c 'import mlx_lm.models.flint' succeeded. Offline real-model smoke with mlx-community/Llama-3.2-1B-Instruct-4bit: plain chat returned Hello! (stop, 3 completion tokens); ignore_eos=true, max_tokens=8 returned length with 8 completion tokens; tool request returned a weather tool call with {"city":"Paris"}. Server stopped afterward. These smokes do not replace the unavailable topic tests.

michalk8 and others added 15 commits October 19, 2026 08:19
QuantizedSwitchLinear passes global_scale to mx.gather_qmm since ml-explore#1844.
That keyword first shipped in mlx 0.32.3, so with mlx 0.32.2 every
quantized MoE fails with a TypeError on the first forward.
* Improve the state machine a bit

* Fix tool calling within reasoning

* Use deltas

* Prune tests

* Remove test

* Drop `drop_held`

* Make _state private

* Add discard to the reader

* Non-optional transitions

* Drop empty tool calls

* Prune comments

* Let first match win

* Don't add empty tool calls v2

* Add stopped flag

* Add deltas

* Simpler made_tool_call check

* Better typing

* Better API

* Fix stop reason when delta was stopped

* Catch any tool formatting exceptions

* Build from tokenizer/stop words

* Drop make_stop_sequences

* Drop header

* Drop SM cache

* Check for valid states

* Update server.md, prune docs

* Drop the add methods

* Revert trie change
* Fix ERNIE-4.5 MoE correction bias routing

- Add `Ernie4_5_MoeStatics` to preserve `e_score_correction_bias` from the checkpoint.
- Apply correction bias during top-k expert selection while keeping routing weights based on unbiased gates.
- Update sanitization to squeeze the bias from `[1, E]` to `[E]` and default to zeros when missing.
- Handle partial weight dictionaries safely and preserve float32 bias precision during conversion.
- Add tests for correction-bias sanitization and routing behavior.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Knightkolla <kartikeyadhavala2468@gmail.com>

* Drop the `Ernie4_5_MoeStatics` class

---------

Signed-off-by: Knightkolla <kartikeyadhavala2468@gmail.com>
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-authored-by: Michal Klein <46717574+michalk8@users.noreply.github.com>
Pass the starting cache offset to KV-reuse attention layers instead of
deriving it from shared sequence dimensions.

Add AFM7 left-padding regression coverage and build test caches using
make_prompt_cache(model).

Signed-off-by: Knightkolla <kartikeyadhavala2468@gmail.com>
Co-authored-by: michalk8 <46717574+michalk8@users.noreply.github.com>
…ore#1955)

* Fix ModelOpt NVFP4 config loading and global scales in convert

The ModelOpt config failed with a KeyError from both config.json and hf_quant_config.json. convert --dtype cast global_scale away from float32, and convert --dequantize ignored it.

* Drop the ModelOpt config changes

main now loads the ModelOpt config from config.json and hf_quant_config.json. The fallback for hf_quant_config.json files without quant_method only helps models with nvfp4 dense layers, which mlx-lm can't run yet.

---------

Co-authored-by: jundot <jundot@users.noreply.github.com>
* mistral 3.5

* pipelining fr mistral
Co-authored-by: Vincent Clifford <v_clifford@apple.com>
…#1997)

Co-authored-by: Vincent Clifford <v_clifford@apple.com>
Co-authored-by: Cheng <git@zcbenz.com>
* Support loading original checkpoint

* Keep router in float32 so expert selection matches the original.

Tested converting the original checkpoint to mlx and comparing long generations match.

---------

Co-authored-by: Pedro Cuenca <pedro@huggingface.co>
* Flint

* Align implementation with transformers

* Flint: use the fused expert routing kernel

Route with mlx_lm.kernels.expert_routing, the kernel added with Muse Spark Open. Flint has no expert bias, so the kernel gets a zero bias. Training and non-Metal backends keep the ops path because the kernel has no vjp.

* Apply suggestions from code review

Co-authored-by: Pedro Cuenca <pedro@huggingface.co>

* Add tests

* Fix int4 loading

* Fix layers of only 1 type

* Test left padding

* Use strict=True

---------

Co-authored-by: jundot <jundot@users.noreply.github.com>
Co-authored-by: michalk8 <46717574+michalk8@users.noreply.github.com>
…hine cache (upstream builds the machine per request)
…behaviour, pillow and test status (review of #26)
@eejd
eejd marked this pull request as ready for review November 15, 2026 10:55
@eejd
eejd merged commit 2ac756a into local Nov 15, 2026
1 of 2 checks passed
@eejd
eejd deleted the merge/upstream-4cfc647 branch November 15, 2026 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants