Skip to content

Add MLX support for draft model#20210

Draft
metascroy wants to merge 2 commits into
gh/digantdesai/62/headfrom
mlx-eagle3-on-cuda
Draft

Add MLX support for draft model#20210
metascroy wants to merge 2 commits into
gh/digantdesai/62/headfrom
mlx-eagle3-on-cuda

Conversation

@metascroy

@metascroy metascroy commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Adds Eagle3 MLX support. MLX supports more features than CUDA, including sharing embedding weights between draft/base model, quantization of draft model, runtime selection of chains, and runtime temperature sampling (not just greedy).

Export command:

python -m executorch.examples.models.eagle3.export \
  --backend mlx --target-model gemma4_31b \
  --target ./gemma-4-31B-it-HQQ-INT4 --draft "$SPEC" \
  --output-dir ./eagle3_mlx --chain 3 --max-prefill 256 \
  --quantize-draft --share-draft-embedding

Build command:

 make eagle3-mlx 

Run command:

./cmake-out/examples/models/eagle3/eagle3_speculator_runner \
  --model_path ./eagle3_mlx/model.pte \
  --tokenizer_path ./gemma-4-31B-it-HQQ-INT4/tokenizer.json \
  --prompt "Write a short joke about saving RAM." \
  --max_new_tokens 128 --chain 3 --temperature 0.8
I tokenizers:regex.cpp:27] Registering override fallback regex
WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
E0000 00:00:1781159777.559320 23022209 re2.cc:237] Error parsing '((\<pad\>|ool\|\>1\x00\x00\
             �\<t|respo|\<tool_call\|\>|\<bos\>|\<\|tool_response\>|\<\|think\|\>|\x0...': invalid UTF-8
I tokenizers:re2_regex.cpp:27] Re2 failed to compile regex: ((\<pad\>|ool\|\>1\x00\x00\
       �\<t|respo|\<tool_call\|\>|\<bos\>|\<\|tool_response\>|\<\|think\|\>|\x00\x00\\\<|\<tool_response\|\>|\<mask\>|\<\|\"\|\>|all\|\>j\x00\x00\\|\<channel\|\>|\<\|turn\>|\<turn\|\>|\<\|image\>|\<\|$
I tokenizers:regex_lookahead.cpp:27] Creating PCRE2 regex
I tokenizers:pcre2_regex.cpp:48] PCRE2 UTF-8 validation failed at offset 27: UTF-8 error: byte 2 top bits not 0x80. Retrying without UTF flags.
Prompt tokens: 24, chain K=3, max_new=128
Why did the computer programmer refuse to buy a new car?

Because he didn't have enough **space**, but he had plenty of **room** for improvement.

***

(Or, if you prefer a one-liner:)

**I tried to write a joke about saving RAM, but I decided to just keep it in my head to save space.**<turn|>
[timing] verify=2946ms draft=154ms over 33 rounds (89.3 / 4.7 ms per round)

--- EAGLE-3 speculative decode ---
generated 75 tokens in 33 rounds (tau=2.242)
decode: 23.60 tok/s (3.178 s)
PyTorchObserver {"prefill_token_per_sec":84.507,"decode_token_per_sec":23.5997,"prompt_tokens":24,"generated_tokens":75,"model_load_start_ms":1781159777286,"model_load_end_ms":1781159778444,"inference_start_ms":1781159778444,"inference_end_ms":1781159781906,"prompt_eval_end_ms":1781159778728,"first_token_ms":1781159778728,"aggregate_sampling_time_ms":0,"SCALING_FACTOR_UNITS_PER_SECOND":1000}

@pytorch-bot

pytorch-bot Bot commented Jun 10, 2026

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/20210

Note: Links to docs will display an error until the docs builds have been completed.

❌ 4 New Failures, 2 Unclassified Failures

As of commit 263bc33 with merge base dc55469 (image):

NEW FAILURES - The following jobs have failed:

UNCLASSIFIED FAILURES - DrCI could not classify the following jobs because the workflow did not run on the merge base. The failures may be pre-existing on trunk or introduced by this PR:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 10, 2026
@metascroy metascroy requested a review from digantdesai June 11, 2026 06:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant