msluszniak commited on
Commit
0cbd6b4
·
verified ·
1 Parent(s): ddddd43

Drop MLX: 5.13x/2.25x slower than Core ML fp16 with no size win

Browse files
mlx/NOTES.md ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # MLX is not shipped for this model
2
+
3
+ The MLX artifacts for this model were removed deliberately. The exporter in
4
+ `export-scripts` is kept so the decision can be re-tested against a future
5
+ ExecuTorch/MLX release, but no `.pte` or `config.json` is published here.
6
+
7
+ ## Why
8
+
9
+ Measured on device (iPhone 16, ExecuTorch 1.4.1, 3 warmup runs + 15 timed runs,
10
+ median, identical input shapes allocated from each model's own schema):
11
+
12
+ | model | Core ML fp16 | MLX fp16 | MLX penalty |
13
+ |---|---|---|---|
14
+ | rfdetr-nano detector | **8.4 ms** | 43.1 ms | **5.13x slower** |
15
+ | rfdetr-nano segmentation | **31.4 ms** | 70.5 ms | **2.25x slower** |
16
+
17
+ Both backends delegate fully and return finite output; MLX is simply slower.
18
+
19
+ **There is no size argument either.** The MLX and Core ML builds are within 1 MB
20
+ of each other (detector 55.7 vs 54.7 MB, segmentation 62.0 vs 62.4 MB), so
21
+ unlike CLIP and distiluse, where MLX int8 ships precisely because it is half the
22
+ size of the Core ML build, there is nothing here to trade the latency against.
23
+
24
+ ## Why RF-DETR is not a special case
25
+
26
+ MLX runs on the Metal GPU; Core ML lowers to the ANE, which is purpose-built for
27
+ this kind of network. MLX was measured behind Core ML on every convolutional
28
+ vision model tested, by 2.25x to 19.6x. Its real advantage is transformer
29
+ workloads, where weight-only quantization shrinks the artifact substantially:
30
+ CLIP vision is 97% `nn.Linear` and goes 351 MB to 98 MB, and distiluse goes
31
+ 541 MB to 140 MB. RF-DETR is a hybrid conv/transformer model and lands on the
32
+ wrong side of that line.
33
+
34
+ ## A correction to the earlier figure
35
+
36
+ An earlier note put the RF-DETR MLX penalty at about 33% (Core ML 51 ms vs MLX
37
+ 68 ms). That comparison is superseded and should not be quoted: it was measured
38
+ on an iPhone SE 3rd gen, and against the Core ML **int8** build that has since
39
+ been replaced by fp16, which is roughly 4x faster. The table above remeasures
40
+ both backends at the same precision on the same device.
mlx/config.json DELETED
@@ -1,62 +0,0 @@
1
- {
2
- "$schema": "https://huggingface.co/software-mansion/react-native-executorch-spec/resolve/main/config.schema.json",
3
- "model": "rfdetr_nano_segmentation",
4
- "family": "rfdetr",
5
- "capabilities": [
6
- "instance-segmentation"
7
- ],
8
- "backend": "mlx",
9
- "license": "apache-2.0",
10
- "variants": [
11
- {
12
- "file": "rfdetr_nano_seg_mlx_fp16.pte",
13
- "precision": "fp16",
14
- "quantized": false,
15
- "default": true,
16
- "methods": {
17
- "forward": {
18
- "inputs": [
19
- {
20
- "shape": [
21
- 1,
22
- 3,
23
- 312,
24
- 312
25
- ],
26
- "dtype": "float32"
27
- }
28
- ],
29
- "outputs": [
30
- {
31
- "shape": [
32
- 100,
33
- 4
34
- ],
35
- "dtype": "float32"
36
- },
37
- {
38
- "shape": [
39
- 100
40
- ],
41
- "dtype": "float32"
42
- },
43
- {
44
- "shape": [
45
- 100
46
- ],
47
- "dtype": "float32"
48
- },
49
- {
50
- "shape": [
51
- 100,
52
- 78,
53
- 78
54
- ],
55
- "dtype": "float32"
56
- }
57
- ]
58
- }
59
- }
60
- }
61
- ]
62
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
mlx/rfdetr_nano_seg_mlx_fp16.pte DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:fa12474eca909e436cc64799f7d5c67508138467d15481fd3499b89920e4b753
3
- size 62006528