825 Commits

Author SHA1 Message Date
Akaash Parthasarathy 9fa644f54b [Fix] Adapt compiler passes to typed TIR buffer parameters (#3534) 2026-08-17 13:41:45 -07:00
Akaash Parthasarathy 2f78caa4db [Fix] Adapt tensor_ir_op kernels to current TVM APIs (#3530)
Adapt to TVM API and `call_tir` convention changes:
1. Update `DataflowVar.name_hint` to `DataflowVar.name`
2. Change sampler full kernel to accept int64 value before its output buffer and cast to int32
3. Reorder parameters for `tensor_ir_op` PrimFuncs so tensor/scalar arguments precede output buffers (Triton expert-ID generation, MoE indptr generation, vision crop and padding, Phi-3V dynamic repeat)
4. Move crop's `T.reads` and `T.writes` declarations to top of `T.sblock` as required by current TIR parser
2026-07-30 22:54:08 -04:00
Ruihang Lai a2bcc5c866 [Refactor] Adapt to tvm-ffi Optional and Relax Id refactor (#3509)
A newer TVM bumps tvm-ffi so that `Optional<T>` follows std::optional
semantics: `.defined()` is dropped in favor of `.has_value()`, and
`Optional<Tensor>` no longer implicitly converts to `ObjectRef`. Update
the C++ runtime to call `.has_value()` on the affected `Optional`
receivers (leaving `.defined()` on plain `ObjectRef`/`Function`/`Module`
handles intact) and return `recv.value_or(Tensor(nullptr))` from the
multi-GPU send/recv passthrough.

On the Python side, adapt the compiler passes and ops to the Relax/tirx
API changes. The Relax `Id` indirection is gone, so `PyExprMutator` var
remaps take the `Var` directly instead of `var.vid`. Symbolic size vars
drop `is_size_var`/`SizeVar` for plain `T.int32()`/`tirx.Var`;
`tirx.PrimExpr`/`multiply`/`subtract`/`generic.cast` become
`Expr`/`Mul`/`Sub`/`Cast`; the cross-thread all-reduce idiom uses
`T.int32(0)` with `dtype="void"`; `relax.expr.Call` becomes
`relax.Call`; and handle parameters are detected via
`isinstance(v.ty, PointerType)` now that a var's `.ty` carries a
`PrimType`/`PointerType` rather than a dtype string.

Verified end to end by compiling and chatting with both
Phi-4-mini-instruct and Qwen3-30B-A3B under tensor_parallel_shards=2.
2026-07-07 09:26:13 -07:00
Ruihang Lai 6474f7dbfa [Refactor] Adapt to TVM PrimType and tirx refactor (#3505)
Mainline TVM unified the PrimExpr type mechanism on PrimType (in place of
DataType) and moved the runtime datatype/object accessors onto tvm-ffi.
Update the C++ runtime to match: replace `tvm::Downcast<T>` with the
tvm-ffi accessors `.cast<T>()` / `.as_or_throw<T>()`, and use `DLDataType`
in place of `tvm::runtime::DataType`. In cpp/serve/model.cc the KV-cache
creation function now returns a heterogeneous `Array<Any>`, so its
elements are read as `Array<Any>[i].cast<Tensor>()` to avoid an Array
type error at runtime.

On the Python side, adapt the compiler passes, model definitions, and ops
to the refactored Relax/TIRScript API: parse TIRScript via
`tvm.script.tirx`, follow the StructInfo->Type rename (`.struct_info`->
`.ty`, `sinfo_args`->`ty_args`), use `relax.prim_value` and
`@T.prim_func(s_tir=True)`, and add explicit casts where the stricter
tirx well-formedness rules no longer let `T.let` widen implicitly.

Bump the 3rdparty/tvm submodule to the matching revision.

Also fix the (previously red) Windows CI job: the scikit-build-core wheel
build needs the MSVC toolchain on PATH, so activate the MSVC developer
environment before building; pin the build conda environment to Python
3.11 (core deps are dropping 3.10 wheels); and remove the GNU coreutils
link.exe that conda ships in Library\usr\bin, which otherwise shadows the
MSVC linker and breaks the Rust tokenizers build.
2026-06-30 10:59:29 -04:00
Ruihang Lai ef84353d88 [Refactor] Adapt to mainline TVM runtime/script refactor (#3495)
Mainline TVM removed several public headers and re-namespaced their
contents. Update C++ includes to the new tvm/ffi and tvm/ir paths,
rename IntTuple to ffi::Shape, replace tvm::runtime re-exports with
explicit `using tvm::ffi::Object/...; using tvm::Downcast;`, switch
linking from `tvm` to `tvm_runtime`, and vendor two small shims under
cpp/support/ for the removed `parallel_for_with_threading_backend`
helper and the now-private TVM_MODULE_VTABLE_* macros.

Python: ShapeTuple is gone — use tvm_ffi.Shape in the five affected
modules, and drop the now-removed `target` arg from the
tvm_callback_cuda_compile hook (TVM now fetches it via Target.current).
2026-05-11 14:53:13 -04:00
Ruihang Lai d1ea69a872 [CI] Migrate lint from Jenkins to GitHub Actions, switch to ruff (#3486)
Mirror the TVM setup (apache/tvm#18809): a minimal GHA workflow that
runs `uv sync --group lint` plus `pre-commit/action`. Pre-commit is
rewritten around ruff (check + format), replacing the previous
isort/black/mypy/pylint/cmake-format stack, and gains yamllint,
taplo, check-yaml, and check-toml. The corresponding Jenkins Lint
stage, the ci/task/{isort,black,mypy,pylint,clang-format}.sh scripts,
and .pylintrc are removed. pyproject.toml grows a [tool.ruff] section
(select E/F/I/UP/RUF, line-length 100, py39 target) and a
[dependency-groups] lint entry; the stale isort/black/mypy/pylint
tool tables are dropped.

To get the codebase green under the new ruler, existing UP006/UP035/
UP045/E501/RUF001/RUF002/E402/F821 violations are grandfathered via
inline `# noqa`, so new code in those forms is still flagged. Real
issues surfaced by the new rules are fixed directly: E741 renames
(ambiguous `l`/`O`), F841 unused locals, E722 bare `except`, RUF012
ClassVar annotations for mutable class defaults, RUF013 explicit
`Optional[...]`, and RUF005 iterable unpacking.

With pylint and mypy gone from CI, this also strips all `# pylint:
disable/enable` and `# type: ignore` directives from Python sources
(PEP 484 `# type: <expr>` comments and `# fmt: off/on` are
preserved), and runs the resulting files through ruff-format.
2026-04-21 20:53:57 -04:00
Ruihang Lai d75d64e753 [Fix] Strip reasoning in history for Qwen3 chat (#3484)
Qwen3's official HF chat template strips `<think>...</think>` blocks
from historical assistant messages (all turns before the last user
message) before rendering the prompt. mlc-llm's `qwen2` template —
which the published Qwen3-*-MLC repos use — does not, so prior
thinking traces get echoed back into context verbatim. On small
Qwen3 variants (e.g. 0.6B) this pushes the model to emit `<|im_end|>`
prematurely inside its next-turn `<think>` block, truncating the
response before `</think>` is ever produced.

This change adds a `strip_reasoning_in_history` flag on the
`Conversation` protocol (both the Python `as_prompt` in
`conversation_protocol.py` and the C++ `CreatePrompt` in
`json_ffi/conv_template.cc`), and registers a new `qwen3` template
that sets it. For Qwen3-*-MLC repos to pick it up, their
`mlc-chat-config.json` on HuggingFace needs the `conv_template`
entry swapped to the new `qwen3` template; no weight changes.

Fixes #3482.
2026-04-19 23:41:59 -04:00
Sai Gopal Reddy Kovvuri 63ab82faaf [WebGPU] Add --enable-subgroups flag for optional subgroup support (#3431)
* [WebGPU] Add --enable-subgroups flag for subgroup shuffle support

* Fix _apply_webgpu_subgroups function

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* Added unit tests for _apply_webgpu_subgroups

---------

Co-authored-by: Akaash Parthasarathy <43900735+akaashrp@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2026-04-14 13:39:42 -04:00
Sidharth N. Babu 27822ba87d Deduplicated helper function (#3479)
deduplicated helper function
2026-04-10 14:58:45 -04:00
Akaash Parthasarathy e656f00bc3 [Fix] Replace str(target.kind) with target.kind.name to align with new format (#3470) 2026-04-06 12:02:00 +05:30
Gabe Guralnick d46f65fca1 [Feature] Add Qwen3.5 conversation templates (#3473)
Add dedicated conversation templates for Qwen3.5 models instead of
using the generic ChatML format. Includes two variants:
- qwen3_5: thinking enabled (assistant opens a <think> block)
- qwen3_5_nothink: thinking disabled (empty <think> block prefix)

Sculptor: gabeguralnick

Co-authored-by: Gabriel Guralnick <gabriel@imbue.com>
2026-04-05 17:02:36 -04:00
Jonghyun Choe 2ca3380e61 [Model] Add OLMo 2 Support (#3467)
- Adds support for the OLMo 2 architecture
- Tested gen_config, convert_weight, compile, chat with
https://huggingface.co/allenai/OLMo-2-1124-7B-Instruct
2026-04-01 23:54:45 -04:00
Ruihang Lai fcce2cc3c8 [FIX] Fix black formatting in per_tensor_quantization (#3466)
Break long lines exceeding 100-char limit introduced during
the tir to tirx namespace migration.
2026-03-29 11:25:49 -04:00
Ruihang Lai f35b0fb5cf [FIX] Migrate tir to tirx in qwen35_model (#3465)
The prior tir->tirx migration (#3462) missed qwen35_model.py.
Update imports and all tir references to tirx.
2026-03-26 23:06:59 -04:00
gururaj 1c7963135b fix: apply post_layernorm in CLIPVisionTransformer forward (#3456)
The post_layernorm was defined in CLIPVisionTransformer.__init__ but
never applied in the forward method. This fix applies it to the final
encoder hidden state, replacing it in the returned tuple. This matches
the HuggingFace CLIPVisionTransformer behavior where last_hidden_state
is post-normalized.

The [-2] indexing in CLIPVisionModel (used by LLaVA and Phi3V to get
penultimate layer features) continues to work correctly since only the
last element of the tuple is replaced.

Fixes #3205

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-26 20:50:25 -04:00
Xijing Wang 76cd196a2c Fix model_task pydantic warning and skip flashinfer on non-linux (#3460)
## Summary
- avoid the Pydantic protected namespace warning for `model_task` in `MLCChatConfig`
- skip `flashinfer-python` for non-Linux editable installs (tested in macos)

## Details
- rename the internal Pydantic field to `field_model_task` and keep `alias="model_task"` so the serialized config format stays unchanged
- add a platform marker to `python/requirements.txt` so editable installs on macOS do not try to resolve `flashinfer-python`
2026-03-26 20:49:08 -04:00
Sidharth N. Babu 65a8d894c1 [Refactor] Migrate tir namespace to tirx (#3462)
Follow upstream TVM refactor (commit 141c22fd8) which renamed tvm.tir to tvm.tirx.

Update all Python imports, module references, TVMScript imports.
2026-03-26 20:15:01 -04:00
Miti 05f79e11b1 Add Qwen3.5 GatedDeltaNet hybrid model + kHybrid KVStateKind (#3449)
* Add Qwen3.5 model definition and kHybrid KVStateKind to serving runtime

Adds full Qwen3.5 GatedDeltaNet hybrid architecture support to MLC-LLM.
This is a hybrid model: 75% GatedDeltaNet recurrent linear attention layers,
25% standard GQA softmax attention layers (every 4th layer).

C++ changes:

1. KVStateKind enum in cpp/metadata/model.h: added kHybrid = 3, plus
   KVStateKindToString/KVStateKindFromString cases for "hybrid".

2. model.cc metadata parsing (cpp/metadata/model.cc): kHybrid is treated
   like kKVCache for KVCacheMetadata parsing (reads the "kv_cache" JSON
   block), since hybrid models still use PagedKVCache for attention layers.

3. FunctionTable (cpp/serve/function_table.h, function_table.cc): added
   create_rnn_state_func_ member. In _InitFunctions, when kv_state_kind
   is kHybrid, resolves create_kv_cache_func_ to
   "create_tir_paged_kv_cache" and create_rnn_state_func_ to
   "create_rnn_state" separately (hybrid needs both).

4. ModelImpl (cpp/serve/model.cc): added rnn_state_ and local_rnn_state_
   members. CreateKVCache creates both PagedKVCache and RNNState when
   kHybrid. All KV state lifecycle methods (AddNewSequence,
   ForkSequence, RemoveSequence, PopNFromKVCache, Reset) mirror
   operations to rnn_state_ when kHybrid. BatchPrefill, BatchDecode,
   BatchVerify, and their ToLastHidden variants call
   kv_cache_begin_forward_func_ and kv_cache_end_forward_func_ on
   rnn_state_ when kHybrid. BatchPrefill/BatchDecode/BatchVerify pass
   rnn_state_ as an extra argument to the model functions when kHybrid.
   GetNumAvailablePages and GetCurrentTotalSequenceLength use
   PagedKVCache (not RNNState) for capacity, since PagedKVCache is the
   constraining factor.

5. batch_prefill_base.cc: CanPrefill treats kHybrid like kKVCache (uses
   PagedKVCache page count for capacity decisions, not unlimited like
   kRNNState).

Python changes:

6. compile.py (_infer_kv_state_kind): returns "hybrid" when model_type
   contains "qwen3_5".

7. model/model.py: registered "qwen3_5" and "qwen3_5_text" entries in the
   MODELS dict, importing from the new qwen35 package. Both map to
   Qwen35LMHeadModel and Qwen35Config.

8. model/qwen35/qwen35_model.py: full model definition.
   Qwen35Config handles VLM text_config unwrapping and nested
   rope_parameters. Qwen35Attention implements GQA with output gate.
   Qwen35GatedDeltaNet implements linear attention with causal Conv1D,
   L2 normalization, gate computation (exp(-exp(A_log) * softplus(alpha
   + dt_bias))), delta rule recurrence via hand-written TIR kernel
   (thread-per-column, fp32 accumulation, GVA support), and per-head
   RMSNorm output gating. Two forward paths: forward() with explicit
   stacked state tensors, forward_rnn() with RNNState get/set.
   create_paged_kv_cache uses num_attention_layers with partial RoPE.
   create_rnn_state initializes recurrent (fp32) and conv state per
   linear layer.

9. model/qwen35/qwen35_loader.py: HF parameter mapping with VLM prefix
   translation (model.language_model.* -> model.*). Fuses QKV for
   attention, gate_up for MLP. Maps A_log and dt_bias without .weight
   suffix. Adds +1.0 offset to RMSNorm weights where needed.

* Pass rnn_state to ToLastHidden functions for hybrid models, remove unused linear_idx

ToLastHidden variants (prefill, decode, verify, and their single_batch
counterparts) were missing the rnn_state_ argument when kv_state_kind
is kHybrid. These are used for speculative decoding paths. Also removed
dead linear_idx variable from qwen35_loader.py.

* Fixed memory reuse fault that was causing crashes.

TVMs memory planner was reusing the initialization tensor's backing
memory, as it detected they were not being used after the RNN state
create call. In our case, we need to keep them around for every
request. Changing them to constants, and adding the compat fixes
into RNNState.py seem to have solved that problem. Still have a problem
with prefix caching failing.

Also - this likely affects the RWKV series of models as well.

* updated prefix caching logic in engine to work with rnn state semantics

* cleanup

* updated the rnn state builder to always take rx constants

* formatting / ci fixes

* revert chat updates

* cleanup

---------

Co-authored-by: Sidharth N. Babu <sidhartb@andrew.cmu.edu>
Co-authored-by: Sidharth N. Babu <sidharth.n.babu@gmail.com>
2026-03-26 16:24:51 -04:00
Ruihang Lai 20d7fb3096 [FIX] Rename T.alloc_buffer to T.sblock_alloc_buffer (#3457)
This PR fixes compilation silent failures due to a recent refactor
in mainline TVM https://github.com/apache/tvm/pull/18865.
2026-03-17 20:37:25 -04:00
Akaash Parthasarathy 2eb1f126a4 [Bug] Replace alloc_buffer with sblock_alloc_buffer and temporarily bypass CSE (#3454) 2026-03-17 20:33:00 -04:00
Xijing Wang 39c5716a67 Feature/embedding/metadata abstraction (#3452)
This PR is the first staged step toward a first-class embedding
serving/runtime path in MLC LLM.

It introduces an explicit embedding metadata abstraction so
embedding models are described by metadata/config traits instead
of being identified implicitly from exported function names alone.

This PR is scoped to metadata propagation only. It does not change
the `/v1/embeddings` API contract, does not change the normal
chat serving path, and does not yet introduce a dedicated embedding
runtime boundary.

Part of #3451
2026-03-17 13:48:46 -04:00
Masahiro Hiramori d063f3807d Handle graceful exit in chat CLI (#3453)
Fix two issues with `mlc_llm chat` exit behavior:

- Catch `KeyboardInterrupt` and `EOFError` in the input loop so Ctrl+C/Ctrl+D exit cleanly without a traceback.
- Explicitly call `engine.terminate()` after the chat loop ends to stop background threads. Previously the engine relied on `__del__` for cleanup, which never fired due to circular references, causing the process to hang on exit.
2026-03-16 10:36:18 -04:00
TR-3B 2c68d792d3 add MRoPE op + Qwen2.5-VL skeleton, with position-id layout compatibility fix (#3416)
NOTE: This PR is only the decoder-side MRoPE/text-model part,
not full end-to-end Qwen2.5-VL support yet.


## What this PR does
- Adds initial Qwen2.5-VL Python skeleton:
  - `python/mlc_llm/model/qwen2_5_vl/__init__.py`
  - `python/mlc_llm/model/qwen2_5_vl/qwen2_5_vl_model.py`
- Adds MRoPE op implementation and public exports:
  - `python/mlc_llm/op/mrope.py`
  - `python/mlc_llm/op/__init__.py`
- Makes MRoPE position-id handling layout-compatible by accepting both:
  - `(batch, seq, 3)`
  - `(3, batch, seq)`

## Why
- Fixes the position-id layout mismatch between `get_mrope_position_ids` output and MRoPE application.
- Unblocks direct use of generated multimodal position IDs in the Qwen2.5-VL path.
2026-03-09 00:21:05 -04:00
Sidharth N. Babu 345d2e2c96 Refactored model loaders to centralize shared loader where it can be done (#3443)
A lot of our models have really similar huggingface loaders, so we
should be able to replace with a standardized central loader, and
cut down some redundancy. There are a few models with some
specific quirks that are not yet covered by this.
2026-03-06 09:29:19 -05:00
Sidharth N. Babu feefbc66d2 Refactored quantization to use a centralized factory approach (#3441)
Explored the codebase, and found that quantization infrastructure
is duplicated on a per-model basis, when it could be centralized.

Tested with qwen3-8b - qualitatively compared the chat outputs of
quantization q4f16_1 across the main branch and this one, and both worked.
2026-03-03 14:12:25 -05:00
Sidharth N. Babu 95d50546b5 Refactoring some typos and removing some unnecessary comments (#3440)
Simple PR - noticed we had a "CasualLM" instead of "CausalLM" typo
across the codebase, and just wanted to clean it up. Also removed some
commented out model presets, and removed gen_config support for for
ones that don't have corresponding conv_templates.
Not sure if this last one is necessary / correct, can go back and restore that.
2026-03-02 15:18:40 -05:00
Siyuan Feng 8f49ea6b7b [Bench] Add bench for MMLU eval (#2584)
Usage:
```
python python/bench/eval/mmlu.py --model dist/Meta-Llama-3-8B-Instruct-q4f16_1-MLC --dataset /path/to/dataset --device cuda --log-dir debug/mmlu
```

Note that chat mode is problematic, which needs to be fixed.

Co-authored-by: Siyuan Feng <hzfengsy@sjtu.edu.cn>
2026-03-01 16:38:50 -05:00
Siyuan Feng f8c26f6e16 [Bench] Add bench for GSM8K eval (#2585)
Co-authored-by: Siyuan Feng <hzfengsy@sjtu.edu.cn>
2026-03-01 16:38:35 -05:00
rankaiyx cf36ef6882 Add API Key Authentication For openai_entrypoints (#3297)
This PR adds API key authentication to the server. Now users can secure
their endpoints with a simple API key.

Key features:
- API key is optional (disabled by default)
- API key is passed via `--api-key` command line argument (not
hardcoded or using environment variables)
- Authentication follows OpenAI API standard (Bearer token in Authorization header)
- No breaking changes - existing functionality remains unchanged
2026-03-01 16:36:49 -05:00
Ruihang Lai e611bfb795 fix: Update tvm submodule and fix Target.libs API for iOS compilation (#3438)
Access `target.libs` via `target.attrs.get("libs")` to match the new
TVM API where target attributes are no longer exposed as direct fields.
2026-03-01 12:03:55 -05:00
Ruihang Lai c6676585d5 fix: Use s_tir.renew_defs to resolve pylint no-member error (#3437)
Replace `tir.stmt_functor.renew_defs` with `s_tir.renew_defs` to fix the
pylint E1101 error reporting that `tvm.tir.stmt_functor` has no `renew_defs`
member, aligning with the updated TVM mainline API.
2026-03-01 10:38:58 -05:00
Ruihang Lai 46f47337d5 refactor: Update codebase for tvm mainline API changes (#3423)
1. JSON class update: migrate picojson usages to tvm::ffi::json API.

2. Error macro update: replace CHECK/ICHECK macros with TVM_FFI_ICHECK
   equivalents; replace old-form TVM_FFI_CHECK (2-arg) with TVM_FFI_ICHECK.

3. IO class update: replace dmlc::Stream / dmlc::MemoryStringStream with
   tvm::support::Stream / BytesOutStream / BytesInStream from tvm/support/io.h;
   update target attribute access (target.arch, target.max_num_threads) to
   use target.attrs.get(...).
2026-03-01 10:25:45 -05:00
Xijing Wang ac4252a2a4 fix(serve): add greedy sub-batching for decoder embedding when batch exceeds prefill_chunk_size (#3436)
### Problem:
When total tokens in a batch exceed `prefill_chunk_size (2048 in my case)`,
`_embed_decoder()` falls back to sequential processing for **ALL** texts,
causing a throughput cliff (53 → 4 texts/s at batch_size=64)

### Fix:
Greedy sub-batching — pack texts into sub-batches that fit within prefill_chunk,
preserving input order. Oversize single texts fall back to sequential chunked prefill.
2026-03-01 10:25:12 -05:00
TR-3B 99cc6fcc60 [ConvertWeight] Fix LoRA merge source detection and temp merge scope (#3432)
* [LoRA] Add PEFT merge path to convert_weight

* [ConvertWeight] Fix LoRA merge source detection and temp merge scope
2026-02-28 20:58:38 -05:00
Xijing Wang 5e9f680541 [Serve] Add Embedding Inference support with '/v1/embeddings' endpoint (#3430)
## Summary
Add end to end embedding inference support with /v1/embeddings endpoint, also provide related test files.

### Key Changes:
 - Add `Qwen3EmbeddingModel` subclass with quantize functions
to fix embedding model compilation 
 - Add `AsyncEmbeddingEngine` with auto model-type detection,
batch prefill optimization, and chunked prefill fallback
 - Add `/v1/embeddings` endpoint similar to openai, has dimension
truncation and base64 encoding support
 - Add `bert-bge` model type 
 - Add comprehensive tests (logit match, engine-level, server test)
2026-02-27 15:47:01 -05:00
Masahiro Hiramori 691a9c7d08 [Python] Remove flashinfer version requirement from requirements.txt (#3434)
Follow-up for #3405
2026-02-27 09:51:59 -05:00
Masahiro Hiramori f1577aecce [Python][Model] Add llm-jp conversation template (#3433)
Added a new conversation template for llm-jp models.
Validated with the following models:
- https://huggingface.co/llm-jp/llm-jp-3-440m-instruct3
- https://huggingface.co/llm-jp/llm-jp-3.1-1.8b-instruct4
2026-02-27 09:51:29 -05:00
Xijing Wang 7a4f8033c4 [BUG FIXED] fix missing 1/sqrt(d) scaling in attention fallback path (#3426)
Fix missing 1/sqrt(d) scaling in attention fallback path

The _fallback() path in op_ext.attention called
_attention_sequence_prefill with sm_scale=1.0 (default),
but the correct scaling factor is 1/sqrt(head_dim).

This caused attention scores to be head_dim times too large,
making softmax overly peaked and degrading embedding quality
for any model using this fallback (BERT, CLIP Vision, or any
model running on Metal/CPU/non-fp16 configurations).

Decoder models (Llama, Qwen, etc.) were not affected because
they pass sm_scale=self.head_dim**-0.5 through the KV cache
path, bypassing op_ext.attention entirely.

Measured impact on BGE-base-en-v1.5 (BERT encoder, Metal):
  Before: TVM vs HuggingFace cosine = 0.862 (avg)
  After:  TVM vs HuggingFace cosine = 0.999989 (avg)
2026-02-22 17:18:28 -05:00
Jonghyun Choe da299e1475 [Testing] Add logit test for Qwen3 embedding model (#3427) 2026-02-18 15:20:25 -05:00
Xijing Wang 988383e38d [Model] Fix weight conversion for Qwen3-Embedding while preserving Qwen3 compatibility (#3411)
[Qwen3] Fix weight conversion for Qwen3-Embedding while preserving Qwen3 compatibility
2026-02-13 13:54:22 -05:00
Sidharth N. Babu c4342edab9 Remove unused mlc_llm.op.position_embedding module (#3424)
This was a stale duplicate of
tvm.relax.frontend.nn.llm.position_embedding.
Verified removal is safe by:
Searching for all imports from mlc_llm.op.position_embedding (none
found)
Testing that mlc_llm.op imports correctly after cleanup
2026-02-13 10:01:53 -05:00
Akaash Parthasarathy b8c5d3ebf7 [Python][Model] Add ministral3_reasoning template (#3419) 2026-02-13 10:00:07 -05:00
Ronnie W. 1a23ff5c32 Add Mac Catalyst (macabi) support for iOS build and packaging (#3406)
Introduces Mac Catalyst (macabi) as a supported device target across build
scripts and Python packaging. Updates ios/prepare_libs.sh to handle --catalyst
builds, adds macabi handling in Python interface and packaging logic, and
extends auto_target.py to recognize and configure macabi targets.
This enables building and packaging static libraries for Mac Catalyst (arm64)
alongside existing iOS and Android targets.

Introduce support for specifying Mac Catalyst architecture (arm64 or x86_64)
in build scripts and Python interface. Update build directories, CMake
arguments, and target triples to handle both architectures. Improves flexibility
for building Mac Catalyst bindings.
2026-02-09 15:30:59 -05:00
Ruihang Lai 54dafa2fcb chore: Update per latest TVM refactor (#3420)
This PR updates the dlight import with regard to the recent
refactor in TVM mainline.
2026-02-09 13:41:55 -05:00
Sidharth N. Babu e3d7badfbd CI FIxes (#3415)
This commit fixes most of the CI tests.
2026-02-08 22:12:43 -05:00
thecaptain789 889227d041 fix: correct typo 'seperated' to 'separated' (#3418)
Co-authored-by: thecaptain789 <thecaptain789@gmail.com>
2026-02-08 15:39:08 -05:00
Bryan 74be5275df Fix: Use correct tvm.s_tir.Schedule API in compiler passes (#3417)
Changed tir.Schedule to tvm.s_tir.Schedule in:
- attach_softmax_with_temperature.py
- fuse_dequantize_take.py

Fixes AttributeError during model compilation where tir.Schedule
does not exist. The correct API is tvm.s_tir.Schedule.
2026-02-06 15:40:02 -05:00
Sidharth N. Babu de560d29b4 Refactor to match TVM Upstream PR#18689 (#3413)
Refactoring to match the changes introduced in https://github.com/apache/tvm/pull/18689.

3rdparty/tvm is also updated.
2026-02-02 23:18:59 -05:00
Akaash Parthasarathy af1020e486 [Model] Support Ministral 3 (#3409) 2026-02-03 09:25:04 +05:30
snav b1318375ad [Python] Fix BOOL error in logit processor. (#3396)
Fix BOOL error in logit processor.
2026-02-02 15:37:59 -05:00