mlboydaisuke commited on
Commit
0ebd258
Β·
verified Β·
1 Parent(s): e4e916c

LFM2.5-1.2B Core AI: card + LFM Open License v1.0

Browse files
Files changed (2) hide show
  1. LICENSE +41 -0
  2. README.md +98 -0
LICENSE ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ LICENSE TEXT
2
+
3
+
4
+
5
+
6
+ LFM Open License v1.0
7
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
8
+ 1. Definitions.
9
+ "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by this document.
10
+ "Licensor" shall mean Liquid AI, Inc.
11
+ "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
12
+ "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
13
+ "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
14
+ "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
15
+ "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work.
16
+ "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
17
+ "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
18
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
19
+ "Commercial Use" shall mean any use of the Work for direct or indirect commercial advantage or monetary compensation.
20
+ "Qualified Non-Profit Organization" shall mean a Legal Entity that is organized and operated exclusively for religious, charitable, scientific, testing for public safety, literary, or educational purposes, and which is exempt from federal income tax under Section 501(c)(3) of the United States Internal Revenue Code of 1986, as amended, or any equivalent non-profit or charitable organization in a foreign jurisdiction.
21
+ "Non-Commercial or Research Purposes" shall mean purposes that do not involve any use of the Work or a Derivative Work for Commercial Use.
22
+ "Threshold" shall mean annual revenue of 10 million United States dollars ($10,000,000) or more.
23
+ 2. Grant of Copyright License. Subject to the terms and conditions of this License, including the Commercial Use limitation set forth in Section 5, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
24
+ 3. Grant of Patent License. Subject to the terms and conditions of this License, including the Commercial Use limitation set forth in Section 5, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
25
+ 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
26
+ (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
27
+ (b) You must cause any modified files to carry prominent notices stating that You changed the files; and
28
+ (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
29
+ (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
30
+ You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
31
+ 5. Commercial Use Limitation.
32
+ (a) The rights granted under this License for Commercial Use are conditioned upon You or Your Legal Entity not exceeding the Threshold.
33
+ (b) Any Commercial Use of the Work or a Derivative Work by a Legal Entity that exceeds the Threshold is not licensed under this Agreement.
34
+ (c) The Threshold shall not apply to a Qualified Non-Profit Organization's use of the Work or a Derivative Work for Non-Commercial or Research Purposes.
35
+ 6. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
36
+ 7. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except for the reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
37
+ 8. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
38
+ 9. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
39
+ 10. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
40
+ 11. Termination. This License will terminate automatically and immediately if You fail to comply with any of its terms and conditions. Upon termination, You must cease all use of the Work and any Derivative Works and delete all copies in Your possession.
41
+ END OF TERMS AND CONDITIONS
README.md ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: other
3
+ license_name: lfm1.0
4
+ license_link: LICENSE
5
+ base_model: LiquidAI/LFM2.5-1.2B-Instruct
6
+ tags:
7
+ - coreai
8
+ - aimodel
9
+ - apple-silicon
10
+ - on-device
11
+ - lfm2
12
+ - hybrid
13
+ pipeline_tag: text-generation
14
+ ---
15
+
16
+ # LFM2.5-1.2B-Instruct β€” Apple Core AI (`.aimodel`)
17
+
18
+ **LiquidAI's LFM2.5-1.2B-Instruct converted to Apple's Core AI** (the Core ML successor
19
+ announced at WWDC26), ready to run on iOS 27 / macOS 27. A conv + full-attention hybrid
20
+ (10 short-conv mixers + 6 GQA attention layers) riding Apple's **`coreai-pipelined` GPU
21
+ engine** β€” the first non-Qwen architecture on that fast path, with zero custom kernels.
22
+
23
+ > Requires the iOS 27 / macOS 27 beta (Core AI ships with the OS). Conversion code, knowledge
24
+ > base, and the Swift runner: **[coreai-model-zoo](https://github.com/john-rocky/coreai-model-zoo)**.
25
+
26
+ ## Measured (greedy; single-step top-1 gated 16/16 vs the fp32 Hugging Face oracle)
27
+
28
+ | Surface | Bundle | Prefill | Decode |
29
+ |---|---|---:|---:|
30
+ | **M4 Max**, release `llm-benchmark` | `gpu-pipelined/lfm2_5_1_2b_instruct_decode_int8lin/` (1.5 GB) | 253.3 tok/s | **253.3 tok/s** |
31
+ | **iPhone 17 Pro**, one-shot runner | same bundle | 39.2–39.4 | **38.0–39.6 tok/s** |
32
+ | iPhone 17 Pro, chat app (CoreAIChat LFM mode, 200-tok turn) | same bundle | 30.7 | **35.8 tok/s** |
33
+
34
+ - ~39 tok/s on iPhone β‰ˆ **~87% of the naive bandwidth ceiling** (~60 GB/s Γ· ~1.4 GB/token) β€”
35
+ effectively memory-bandwidth saturated. Cold GPU specialization 6.8 s, warm load 1.6 s; no
36
+ AOT compile needed.
37
+ - iPhone greedy sequences are **24/24 token-identical to the M4 Max GPU** on both fixed
38
+ verification prompts.
39
+ - For scale: our Qwen3.5-0.8B on the same engine does 204 tok/s on M4 Max β€” this 1.2B does
40
+ 253.
41
+
42
+ ## What the bundle is
43
+
44
+ One full **LanguageBundle** (`.aimodel` + `tokenizer/` + `metadata.json`): decode-only graph,
45
+ `input_ids` static `[1,1]`, position_ids + KV seq dynamic (β†’ the engine factory selects
46
+ `coreai-pipelined`: async non-blocking encode, on-GPU argmax sampling, on-device KV growth).
47
+ Weights are **int8 linear per-block-32** (scale-multiply dequant β€” no LUT; k-means LUT
48
+ gathers measure slower on this GPU delegate) with the embedding, depthwise convs, norms,
49
+ lm_head, and the four attention projections kept high-precision. The attention projections
50
+ are fp32 on purpose: under a dynamic-shape graph the delegate's fp16 attention-prologue
51
+ matmuls lose ~1.3% relative accuracy, which LFM2.5's large q/k-norm gains amplify into wrong
52
+ logits β€” fp32 there restores layer-level exactness (+126 MB). Full write-up:
53
+ [`knowledge/pipelined-engine.md`](https://github.com/john-rocky/coreai-model-zoo/blob/main/knowledge/pipelined-engine.md).
54
+
55
+ ## Run it
56
+
57
+ ```bash
58
+ git clone https://github.com/john-rocky/coreai-model-zoo
59
+ git clone https://github.com/apple/coreai-models
60
+ git -C coreai-models apply ../coreai-model-zoo/apps/coreai-shared-product.patch \
61
+ ../coreai-model-zoo/apps/coreai-pipelined-extra-states.patch
62
+ # (the extra-states patch lets the engine carry the conv state as a fixed-shape extra state)
63
+
64
+ # download this bundle into coreai-models/exports/, then:
65
+ cd coreai-models && swift build -c release
66
+ COREAI_CHUNK_THRESHOLD=1 ./.build/release/llm-benchmark \
67
+ --model exports/lfm2_5_1_2b_instruct_decode_int8lin -p 128 -g 256 -n 3
68
+ ```
69
+
70
+ Run contract (each of these matters):
71
+ - `COREAI_CHUNK_THRESHOLD=1` **before engine creation** β€” prefill must run as pipelined S=1
72
+ steps (prompt tok/s β‰ˆ decode tok/s).
73
+ - **Never call `engine.warmup()`** on this S=1 bundle (it warms query length 256, which the
74
+ static `[1,1]` graph rejects). A 1-token generate after load is the warmup;
75
+ `llm-runner` needs `--warmup exact --warmup-length 1`.
76
+ - Benchmark **Release** builds only (a Debug engine measures ~3Γ— slow).
77
+
78
+ On iPhone, the [CoreAIChat sample app](https://github.com/john-rocky/coreai-model-zoo/tree/main/apps/CoreAIChat)
79
+ has an **LFM** picker mode that downloads this repo in-app and chats through this bundle.
80
+
81
+ ## Conversion
82
+
83
+ Reproducible with
84
+ [`conversion/export_lfm2_decode_pipelined.py`](https://github.com/john-rocky/coreai-model-zoo/blob/main/conversion/export_lfm2_decode_pipelined.py)
85
+ (+ the `models/macos/lfm2.py` overlay) from the upstream HF checkpoint. Numerics are gated
86
+ the strict way: a teacher-forced S=1 sweep over a 16-position oracle prompt (top-1 vs the
87
+ fp32 HF reference at every position, 16/16 required) plus an oracle-cache-seeded decode
88
+ step β€” not long-rollout eyeballing. Model card with the full method and the GPU-delegate
89
+ findings: [`zoo/lfm2.5.md`](https://github.com/john-rocky/coreai-model-zoo/blob/main/zoo/lfm2.5.md).
90
+
91
+ ## License
92
+
93
+ The model weights derive from
94
+ [LiquidAI/LFM2.5-1.2B-Instruct](https://huggingface.co/LiquidAI/LFM2.5-1.2B-Instruct) and are
95
+ redistributed under the **LFM Open License v1.0** (see [LICENSE](LICENSE)): Apache-style
96
+ grants, but **Commercial Use is licensed only for entities below US$10M annual revenue**
97
+ (qualified non-profits exempt for non-commercial/research use). The conversion code is
98
+ BSD-3-Clause (zoo repo).