Commit fb210c3
feat: add MLX builds for LFM2.5 and privacy-filter models (#1266)
## Description
Adds MLX (Apple GPU) builds for the LFM2.5 family and the privacy-filter
models, wiring the HF-hosted MLX variants into the model registry so
they
default to MLX on iOS (with the existing XNNPACK builds as the
simulator / Android fallback):
- LFM2.5 text — 350M, 1.2B
- LFM2.5-VL — 450M, 1.6B
- Privacy filter — openai, nemotron
Runner changes needed to drive the new builds:
- `vision_encoder` now reads its declared input dtype from method
metadata
and converts the preprocessed fp32 pixels to match (fp32 passthrough,
bf16, or fp16) instead of hardcoding `Float`. Required for bf16 MLX
vision encoders; the fp32 path stays zero-copy.
- The multimodal prefiller image-embed splice now handles `fp32 <->
bf16`
vision/text-embed dtype pairs (a hybrid where the vision encoder is fp32
and the decoder embeds are bf16), in addition to the existing
fp32<->fp16 cases.
- New `convert_from_float` helper in `runner/util.h`.
Review order: `modelUrls.ts` + `modelRegistry.ts` (the wiring) first,
then
the three `common/runner` files (the dtype handling).
### Introduces a breaking change?
- [ ] Yes
- [x] No
### Type of change
- [x] New feature (change which adds functionality)
### Tested on
- [x] iOS
### Testing instructions
1. On a physical iOS device, load each model via its accessor with the
default backend (resolves to MLX on iOS), e.g.
`models.llm.lfm2_5_vl_450m()`, `models.privacy_filter.openai()`.
2. Verify the privacy filters classify PII and the LFM2.5 / LFM2.5-VL
models generate correctly (the VL models with an image).
3. MLX requires a physical device; on the simulator the accessors fall
back to XNNPACK (or pass `{ backend: 'xnnpack' }` explicitly).
### Checklist
- [x] I have performed a self-review of my code
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent b180046 commit fb210c3
6 files changed
Lines changed: 158 additions & 25 deletions
File tree
- packages/react-native-executorch
- common/runner
- encoders
- src/constants
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
70 | 71 | | |
71 | 72 | | |
72 | 73 | | |
| 74 | + | |
73 | 75 | | |
74 | 76 | | |
75 | 77 | | |
| |||
124 | 126 | | |
125 | 127 | | |
126 | 128 | | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
127 | 132 | | |
128 | 133 | | |
| 134 | + | |
129 | 135 | | |
130 | 136 | | |
131 | 137 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| |||
Lines changed: 29 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
27 | 41 | | |
28 | 42 | | |
29 | 43 | | |
| |||
186 | 200 | | |
187 | 201 | | |
188 | 202 | | |
| 203 | + | |
| 204 | + | |
189 | 205 | | |
190 | | - | |
191 | | - | |
192 | 206 | | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
207 | 220 | | |
208 | 221 | | |
209 | 222 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
173 | 221 | | |
174 | 222 | | |
175 | 223 | | |
| |||
Lines changed: 66 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
260 | 260 | | |
261 | 261 | | |
262 | 262 | | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
263 | 321 | | |
264 | 322 | | |
265 | 323 | | |
| |||
594 | 652 | | |
595 | 653 | | |
596 | 654 | | |
597 | | - | |
598 | | - | |
599 | | - | |
600 | | - | |
601 | | - | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
602 | 659 | | |
603 | 660 | | |
604 | 661 | | |
605 | 662 | | |
606 | 663 | | |
607 | 664 | | |
608 | 665 | | |
609 | | - | |
610 | | - | |
| 666 | + | |
| 667 | + | |
611 | 668 | | |
612 | 669 | | |
613 | 670 | | |
| |||
617 | 674 | | |
618 | 675 | | |
619 | 676 | | |
620 | | - | |
621 | | - | |
| 677 | + | |
| 678 | + | |
622 | 679 | | |
623 | 680 | | |
624 | 681 | | |
| |||
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
450 | 450 | | |
451 | 451 | | |
452 | 452 | | |
| 453 | + | |
453 | 454 | | |
454 | 455 | | |
455 | 456 | | |
| |||
476 | 477 | | |
477 | 478 | | |
478 | 479 | | |
| 480 | + | |
479 | 481 | | |
480 | 482 | | |
481 | 483 | | |
| |||
527 | 529 | | |
528 | 530 | | |
529 | 531 | | |
| 532 | + | |
530 | 533 | | |
531 | 534 | | |
532 | 535 | | |
533 | 536 | | |
534 | 537 | | |
| 538 | + | |
535 | 539 | | |
536 | 540 | | |
537 | 541 | | |
| |||
1281 | 1285 | | |
1282 | 1286 | | |
1283 | 1287 | | |
| 1288 | + | |
| 1289 | + | |
1284 | 1290 | | |
1285 | 1291 | | |
1286 | 1292 | | |
| |||
1293 | 1299 | | |
1294 | 1300 | | |
1295 | 1301 | | |
| 1302 | + | |
| 1303 | + | |
1296 | 1304 | | |
1297 | 1305 | | |
1298 | 1306 | | |
| |||
0 commit comments