Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -33,13 +33,16 @@ Getting it wrong does not throw; it returns vectors that look fine and rank wron
|
|
| 33 |
|
| 34 |
| build | file | size (MB) | Mac ms* | backend takes | worst cosine vs eager | retrieval budget |
|
| 35 |
|---|---|---|---|---|---|---|
|
| 36 |
-
| fp32 | `embed_all_minilm_l12_xnnpack_fp32.pte` | 133.0 |
|
| 37 |
-
| fp16 | `embed_all_minilm_l12_xnnpack_fp16.pte` | 66.7 |
|
| 38 |
-
| Core ML (fp16, iOS) | `embed_all_minilm_l12_coreml_all.pte` | 67.2 | 3.
|
| 39 |
|
| 40 |
-
\*Mac arm64,
|
| 41 |
-
cost, not a device number.
|
| 42 |
-
19.6 ms
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
Cosine is measured against the model run in eager through its own pooling, over eight
|
| 45 |
sentences. The last column is the one that decides: rank those eight against each
|
|
@@ -49,17 +52,23 @@ top-1 results.
|
|
| 49 |
|
| 50 |
## The attention is eager, and that is the faster export
|
| 51 |
|
| 52 |
-
`F.scaled_dot_product_attention`
|
| 53 |
-
whose guard against a
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
and
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
|
| 64 |
## Not shipped: int8
|
| 65 |
|
|
|
|
| 33 |
|
| 34 |
| build | file | size (MB) | Mac ms* | backend takes | worst cosine vs eager | retrieval budget |
|
| 35 |
|---|---|---|---|---|---|---|
|
| 36 |
+
| fp32 | `embed_all_minilm_l12_xnnpack_fp32.pte` | 133.0 | 20.6 | 78.5% | 1.000000 | 0% |
|
| 37 |
+
| fp16 | `embed_all_minilm_l12_xnnpack_fp16.pte` | 66.7 | 32.0 | 67.6% | 0.999999 | 4% |
|
| 38 |
+
| Core ML (fp16, iOS) | `embed_all_minilm_l12_coreml_all.pte` | 67.2 | 3.7 | 100.0% | 0.999969 | 23% |
|
| 39 |
|
| 40 |
+
\*Mac arm64, one 256-token sequence, **fastest of five medians of ten** — a reference
|
| 41 |
+
point for relative cost, not a device number. The host shares its cores with other work,
|
| 42 |
+
and a single median does not survive that: the same eager model here measured 19.6 ms and
|
| 43 |
+
182.8 ms twenty minutes apart. Contention only ever adds time, so the fastest repetition is
|
| 44 |
+
the one that means something. Torch eager fp32, measured the same way, is
|
| 45 |
+
19.1 ms.
|
| 46 |
|
| 47 |
Cosine is measured against the model run in eager through its own pooling, over eight
|
| 48 |
sentences. The last column is the one that decides: rank those eight against each
|
|
|
|
| 52 |
|
| 53 |
## The attention is eager, and that is the faster export
|
| 54 |
|
| 55 |
+
`F.scaled_dot_product_attention` does not survive export as one operation. The edge
|
| 56 |
+
dialect lowers it through `_safe_softmax`, whose guard against a row with no unmasked key
|
| 57 |
+
at all leaves **11 operations XNNPACK cannot take, in every attention
|
| 58 |
+
block** — `scalar_tensor`, `where`, `mul.Scalar`, `logical_not`, `eq`, `full_like`, `any.dim`. Each one cuts the subgraph in two.
|
| 59 |
+
|
| 60 |
+
The switch is `attn_implementation="eager"`: transformers then builds the mask
|
| 61 |
+
itself, as `torch.finfo(dtype).min`, instead of handing `F.sdpa` a **boolean** mask
|
| 62 |
+
for PyTorch to fill with `-inf`.
|
| 63 |
+
|
| 64 |
+
The guard is emitted whether or not it can ever fire, and here it cannot: it triggers only
|
| 65 |
+
on `-inf`, and this arm never produces one. So the two differ only about rows that have no
|
| 66 |
+
unmasked key at all — sdpa zeroes them, this one gives them a uniform row — and those are
|
| 67 |
+
padding rows, which the pooling discards and which every real query row masks out anyway.
|
| 68 |
+
Measured with all but eight positions masked, as adversarial as this shape gets, the two
|
| 69 |
+
graphs agree to 1.4e-07.
|
| 70 |
+
|
| 71 |
+
XNNPACK fp32 goes from **62.6% to 78.5%** delegated.
|
| 72 |
|
| 73 |
## Not shipped: int8
|
| 74 |
|