Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
aa368d2
ci: add PR-Agent for automated PR reviews and descriptions (#48)
bong-water-water-bong Jun 28, 2026
2f2da82
ci: set model priority to Codex > GLM-5.2 > DeepSeek v4 Flash
bong-water-water-bong Jun 28, 2026
52086ea
fix: correct pr-agent version tag and model priority (DeepSeek Chat v3)
bong-water-water-bong Jun 28, 2026
f6a16c8
fix: use gpt-4o as primary model with custom_model_max_tokens fallback
bong-water-water-bong Jun 28, 2026
1554e86
fix: switch to OpenCode API with glm-5.2 as primary model
bong-water-water-bong Jun 28, 2026
8a82285
fix: use openai/ provider prefix for litellm compatibility
bong-water-water-bong Jun 28, 2026
9a51049
fix: switch to DeepSeek Chat v3 via litellm native deepseek/ provider
bong-water-water-bong Jun 28, 2026
eba7b72
fix: clean TOML syntax, use deepseek/deepseek-chat with DEEPSEEK_API_KEY
bong-water-water-bong Jun 28, 2026
f0992b1
docs: highlight 1-bit/ternary, NPU backend, GGUF, ROCm optimizations,…
Jul 6, 2026
12318f7
MTP: wire delta kernel, probabilistic acceptance, cache prefill
bong-water-water-bong Jul 10, 2026
2fe88e4
ignore start-mlx-server.sh
bong-water-water-bong Jul 10, 2026
50bb528
ci: add scheduled upstream sync workflow
bong-water-water-bong Jul 12, 2026
68fa281
chore(pr-agent): use local ollama models + add local runner
bong-water-water-bong Jul 17, 2026
798d3c1
fix(rocm): add missing return in mtp_delta_fused_rocm for T>1 prefill…
bong-water-water-bong Jul 17, 2026
9f076b3
fix: downgrade actions/checkout from v6 to v4 across all workflows
bong-water-water-bong Jul 17, 2026
1fe211a
Merge branch 'lemonade-sdk:main' into main
github-actions[bot] Jul 20, 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
8 changes: 4 additions & 4 deletions .github/workflows/build-mlx-engine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v6
uses: actions/checkout@v4
with:
submodules: recursive

Expand Down Expand Up @@ -244,7 +244,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v6
uses: actions/checkout@v4
with:
submodules: recursive

Expand Down Expand Up @@ -311,7 +311,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v6
uses: actions/checkout@v4
with:
submodules: recursive

Expand Down Expand Up @@ -877,7 +877,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v6
uses: actions/checkout@v4

- name: Download all build artifacts
uses: actions/download-artifact@v6
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/pr-agent.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: PR-Agent
on:
pull_request_target:
types: [opened, ready_for_review, reopened]
issue_comment:
types: [created, edited]

permissions:
pull-requests: write
issues: write
contents: read

jobs:
pr-agent:
runs-on: ubuntu-latest
if: |
(github.event_name == 'pull_request_target' && github.event.action != 'closed') ||
(github.event_name == 'issue_comment' && github.event.issue.pull_request &&
contains(github.event.comment.body, '/describe') ||
contains(github.event.comment.body, '/review') ||
contains(github.event.comment.body, '/improve') ||
contains(github.event.comment.body, '/ask'))
steps:
- name: PR-Agent
uses: codium-ai/pr-agent@v0.38.0
env:
OPENAI_API_KEY: ${{ secrets.DEEPSEEK_API_KEY }}
DEEPSEEK_API_KEY: ${{ secrets.DEEPSEEK_API_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
github_action_config.auto_describe: "true"
github_action_config.auto_review: "true"
github_action_config.auto_improve: "false"
github_action_config.enable_output: "true"
pr_agent.extra_config: ".pr_agent.toml"
18 changes: 18 additions & 0 deletions .github/workflows/sync-upstream.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Sync fork with upstream

on:
schedule:
- cron: '0 6 * * *'
workflow_dispatch: {}

permissions:
contents: write

jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Sync fork with upstream
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh repo sync "${{ github.repository }}" --source "lemonade-sdk/lemon-mlx-engine"
4 changes: 2 additions & 2 deletions .github/workflows/test-mlx-engine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
latest_release_tag: ${{ steps.get-release.outputs.latest_release_tag }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
uses: actions/checkout@v4

- name: Get release tag
id: get-release
Expand Down Expand Up @@ -98,7 +98,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v6
uses: actions/checkout@v4

- name: Install jq
run: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@ Thumbs.db
.Spotlight-V100
.Trashes
build-ci/
start-mlx-server.sh
33 changes: 33 additions & 0 deletions .pr_agent.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[config]
model = "ollama_chat/gpt-oss:20b"
fallback_models = ["ollama_chat/qwen3.5:9b"]
model_turbo = "ollama_chat/gpt-oss:20b"
verbosity_level = 2
publish_output = false
publish_output_progress = false
git_provider = "github"
skip_keys = []
use_repo_settings_file = false
use_wiki_settings_file = false
use_global_settings_file = false

[pr_reviewer]
require_score_review = true
require_tests_review = true
num_ais = 1
inline_code_comments = true
automatic_review = false
persistent_comment = false
extra_instructions = "Focus on INT8 quantization correctness, NPU context lifecycle bugs, BFP16 precision issues, and C++ memory safety. Reviewer: think like an NPU hardware engineer reviewing inference engine code."

[pr_description]
publish_labels = true
extra_instructions = "Use conventional commits. Include performance impact (ms/tok delta). Tag NPU-specific changes with [npu]."
enable_help_text = false

[pr_code_suggestions]
num_code_suggestions = 4
extra_instructions = "Prefer suggestions that reduce context-swapping overhead, eliminate heap allocations in decode loop, or improve INT8 quantization accuracy."

[pr_code_suggestions_reflect]
extra_instructions = "Reflect on whether suggested code would actually improve tok/s or token quality on real NPU hardware. Discard suggestions that are purely stylistic."
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@ add_library(mlx-lm-common
src/common/chat_template.cpp
src/common/gated_delta.cpp
src/common/graph_decode.cpp
src/common/mtp_delta_kernel.cpp
src/llm/models/mtp_head.cpp
src/llm/models/mtp_moe.cpp
)
# NOTE: src/common/mtp_delta_kernel.cpp intentionally excluded from build.
# Contains dead code (mtp_delta_fused / mtp_draft_forward) not wired into
# generate.cpp. Left on disk for future ROCm optimization work.
# MTP delta kernel -- fused GatedDeltaNet compute for MTP draft generation.
# Wired into generate.cpp via the mtp_head and context pipelines.
target_link_libraries(mlx-lm-common PUBLIC
mlx-lm-core
nlohmann_json::nlohmann_json
Expand Down
29 changes: 26 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@

C++ inference engine for large language models, built on [MLX](https://github.com/ml-explore/mlx).

Run LLMs locally on **Apple M-series**, **AMD GPUs** (Linux/Windows), and CPU -- no Python required.
Run LLMs locally on **Apple M-series**, **AMD GPUs** (Linux/Windows), **AMD XDNA2 NPU** (Strix Halo), and CPU -- no Python required.

## Features

- **50+ LLM architectures** -- Llama, Qwen, Gemma, Phi, DeepSeek, Mistral, Granite, GLM, Falcon, and more
- **12 VLM architectures** -- Qwen-VL, PaliGemma, Pixtral, Gemma3, SmolVLM, and more
- **Embedders** -- BERT, Nomic-BERT, Qwen3-Embed
- **Quantized inference** -- 4-bit/8-bit via `quantized_matmul`
- **HuggingFace integration** -- auto-downloads models, tokenizers, and chat templates
- **1-bit / ternary model support** -- BitNet b1.58, Falcon-E (BitLinear), Bonsai, full 1.58-bit and 1-bit variants
- **GGUF quant format support** -- Q4_0 through Q6_K, K-quants, auto-quantize on load
- **NPU backend** -- AMD XDNA2 NPU (Strix Halo) via XRT, custom BFP16 xclbins, zero-copy dispatch
- **ROCm GPU optimization** -- HIP graph decode, fused MoE/GDN kernels, O(1) memory reuse
- **Multi-token prediction (MTP)** -- Speculative decoding with MTP head support (Qwen3.5-Next)
- **Quantized inference** -- 4-bit/8-bit via `quantized_matmul`, KV cache quantization (4/8-bit)
- **Universal HuggingFace loading** -- auto-quantize, GGUF, PyTorch → safetensors converter
- **fastokens** -- high-performance BPE tokenizer ([crusoecloud/fastokens](https://github.com/crusoecloud/fastokens))
- **OpenAI-compatible API server** -- drop-in replacement for local inference
- **Streaming generation** -- async token pipeline with KV caching
Expand Down Expand Up @@ -98,6 +103,24 @@ eGPU link. When mixing a discrete RDNA 4 GPU with an integrated APU, make sure
`HSA_OVERRIDE_GFX_VERSION` is **unset** so kernels compile for each GPU's real
architecture (`chat` clears it automatically).

### NPU Backend (AMD XDNA2)

The engine also supports the **AMD XDNA2 NPU** on Strix Halo (Ryzen AI MAX 300)
via the XRT runtime. The NPU backend dispatches quantized GEMM to format-specific
BFP16 xclbins on the NPU, with zero-copy memory access via shared UMA.

Build with NPU support:

```bash
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DMLX_LM_BUILD_NPU=ON
make -j
```

Requires the XRT development headers and the amdxdna kernel driver. The NPU
backend auto-selects between Q4NX, FP16, and BitNet xclbins based on weight
format, falling back to CPU/GPU if the NPU is unavailable.

## API Server

```
Expand Down
Loading
Loading