Mordant-3B-Think β€” LiteRT-LM (on-device)

On-device conversion of Kezmark/Mordant-3B-Think β€” a full fine-tune of ibm-granite/granite-4.1-3b for AI image-generation prompt composition with chain-of-thought reasoning β€” to a .litertlm bundle for the LiteRT-LM runtime. All credit for the model itself goes to its author; this repo only packages it for phones and desktops.

Requires litert-lm β‰₯ 0.16 to run.

file quant size
Mordant-3B-Think_int8.litertlm dynamic int8 (linears + embedding) 3.76 GB

2026-09-21: chat template updated to accept the 0.18 content-parts form (string form unchanged); weights, tokenizer and executor metadata byte-identical.

Conversion & verification

Converted with one command by hf-to-litertlm (python scripts/convert.py Kezmark/Mordant-3B-Think, 2026-08-25):

  • The finetune's own chat template β€” a thinking-form template that opens the assistant turn with <think> β€” is embedded verbatim (byte-equal to the checkpoint's chat_template.jinja, 1474/1474).
  • The spurious metadata start token is dropped: this family declares bos == eos == <|end_of_text|> and its template never renders a leading BOS, so an engine-prepended start token reads as "this document already ended" β€” measured on this checkpoint, it flips HF bf16 greedy output into a code-fence loop.
  • Reduced set of 7 signatures (6 prefill lengths and decode) + externalized embedder (the β‰₯3B ship shape; the full set of 11 signatures is killed by iOS at Metal init on this family).
  • Quality check: 8/8 on the 8-question sanity check (think-aware budget), non-degenerate.

Performance (Apple M4 Max, litert-lm 0.16.0, -p 256 -d 256 --runs 3 --cache no)

backend prefill tok/s decode tok/s TTFT
CPU 97.3 20.2 2.68 s
GPU 1129 71.9 0.24 s

Usage

pip install litert-lm
litert-lm run Mordant-3B-Think_int8.litertlm \
  --prompt "A cat sitting on a windowsill at sunset" --max-num-tokens 4096

The model answers with a <think>…</think> block followed by the composed image prompt β€” budget generation length accordingly. On Android, load the bundle in an app embedding the LiteRT-LM engine (e.g. Google AI Edge Gallery-style hosts).

Thinking cannot be switched off. On litert-lm 0.18.0 ThinkingConfig(enable_thinking=False) has no effect on this file: with a 400-token cap the thought channel uses the whole cap and no answer text appears (measured 2026-10-13). Set thinking_token_budget (300 answered 17 Γ— 23 under a 700-token cap) and a cap above it.

Replies that take over 10 minutes. On litert-lm 0.18.x and 0.19.0, a blocking send_message that is still generating after 10 minutes fails with DEADLINE_EXCEEDED (a fixed timeout with no setting), and the generation it leaves running can crash the process. For long replies on a slow backend (long thinking in particular), lower max_output_tokens or use the streaming send_message_async, which has no such limit.

Known runtime issues

The bundle's chat template opens a thought in every answer, so after each answer the runtime rebuilds the cache from the re-rendered history at the next turn: the second turn is free of the defect below when the conversation opens with a user message, and the same source shows a zero embedding at another token from the third turn on (not measured). The defect: after an answer without a thought (no <think> … </think> block), from the second turn of a conversation on, LiteRT-LM puts the previous answer's stop token into the KV cache with a zero embedding, because this file holds the embedding table in its own section and the decoder takes embeddings, so later answers in a conversation can differ from the answer the model gives to the same messages in one prompt (read in the source of LiteRT-LM 0.16.0 to 0.18.1; measured with 0.18.1 on WeVisOne-VL-2B and Qwen2.5-Coder-1.5B-Instruct, not on this file). One question per conversation avoids both, as does a new conversation that starts with the earlier messages and the new question.

On LiteRT-LM releases before 0.17.0 (read in the source of 0.10.1 to 0.16.1), an answer whose last punctuation mark is a token of its own, such as a . or ? after a word, arrives without that mark: this file carries stop sequences of <|end_of_text|> and a newline with each of 13 characters in front (12 punctuation marks and a space), so the runtime holds the mark back to see whether <|end_of_text|> and a newline follow, the answer ends on <|end_of_text|> alone, and the held mark is never written. LiteRT-LM 0.17.0 and later write the held mark (StopTokenStreamFilter in runtime/core/tasks.cc, read in the source of 0.17.0 to 0.18.1). Not measured on this file: this follows from the runtime's source read with this file's stop list and tokenizer; the drop itself was seen with LiteRT-LM 0.16.1 on a Galaxy S26, on another bundle whose stop sequences have the same form.

From a conversation preface (the system message, initial messages, tools and extra context a conversation is created with) that has tools and no messages, LiteRT-LM renders this file's chat template with an empty message list, and the template reads messages[0] without checking that the list is non-empty, so the render fails with Failed to apply template: undefined value. This happens in two places: when the preface is prefilled at creation (prefillPrefaceOnInit = true in Kotlin, prefillPrefaceOnInit: true on the web, SetPrefillPrefaceOnInit(true) in C++; the default is false), where creating the conversation fails with that error, and in the preface render (renderPrefaceIntoString() in Kotlin and Swift, RenderPrefaceIntoString() in C++, litert_lm_conversation_render_preface_to_string in the C API). The same happens with extra context (such as enable_thinking) and no messages, and in the preface render with an empty preface (run in the runtime on one Qwen3 template; the other templates rendered with minijinja 2.14 and jinja2). Read in the source of LiteRT-LM 0.17.0, 0.18.1 and main; measured with LiteRT-LM 0.18.1 (the litert-lm package from PyPI) through its C API on this file's template text. The default path, where the first message is rendered together with the preface, is not affected: the Python API and the CLI of 0.18.1 expose neither the flag nor the preface render, and Google AI Edge Gallery sets neither (its source as read on 2026-10-25). A system message or any initial message in the conversation config avoids it.

On LiteRT-LM 0.18.1 and 0.19.1, once a message fails because it does not fit in the context window, every later message in that conversation fails as well (the next one with Task failed with state: 7). Start a new conversation after such an error.

License

apache-2.0, inherited from the source model and its granite-4.1 base.

Downloads last month
-
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for mlboydaisuke/Mordant-3B-Think-LiteRT

Quantized
(3)
this model