Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -26,13 +26,15 @@ each candidate together with the query and scores it properly.
|
|
| 26 |
|
| 27 |
| build | file | size (MB) | worst score error vs eager | Mac median (ms)* | backend takes |
|
| 28 |
|---|---|---|---|---|---|
|
| 29 |
-
| fp32 | `rerank_ms_marco_minilm_l4_xnnpack_fp32.pte` | 76.7 | 0.0000 logits | 11.
|
| 30 |
-
| fp16 | `rerank_ms_marco_minilm_l4_xnnpack_fp16.pte` | 38.4 | 0.0049 logits |
|
| 31 |
| Core ML (fp16, iOS) | `rerank_ms_marco_minilm_l4_coreml_all.pte` | 39.6 | 0.0501 logits | 4.6 | 100.0% |
|
| 32 |
|
| 33 |
-
\*Mac arm64,
|
| 34 |
-
reference point for relative cost, not a device number.
|
| 35 |
-
|
|
|
|
|
|
|
| 36 |
|
| 37 |
Correlation is not reported because it cannot be: the output is a single number, and the
|
| 38 |
correlation of a one-element vector is undefined. The column above is the error in the
|
|
@@ -66,21 +68,20 @@ second segment and take two; the signature follows the model rather than being m
|
|
| 66 |
## The attention is eager, and that is the faster export
|
| 67 |
|
| 68 |
`F.scaled_dot_product_attention` does not survive export as one operation. The edge
|
| 69 |
-
dialect lowers it through `_safe_softmax`, whose guard against a row with no unmasked
|
| 70 |
-
|
| 71 |
-
`scalar_tensor`, `where`, `mul.Scalar`, `logical_not`, `eq`, `full_like`, `any.dim`.
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
this shape gets, the two graphs agree to 1.1e-05.
|
| 84 |
|
| 85 |
XNNPACK fp32 goes from **59.4% to 72.5%** delegated.
|
| 86 |
|
|
|
|
| 26 |
|
| 27 |
| build | file | size (MB) | worst score error vs eager | Mac median (ms)* | backend takes |
|
| 28 |
|---|---|---|---|---|---|
|
| 29 |
+
| fp32 | `rerank_ms_marco_minilm_l4_xnnpack_fp32.pte` | 76.7 | 0.0000 logits | 11.1 | 72.5% |
|
| 30 |
+
| fp16 | `rerank_ms_marco_minilm_l4_xnnpack_fp16.pte` | 38.4 | 0.0049 logits | 17.9 | 63.0% |
|
| 31 |
| Core ML (fp16, iOS) | `rerank_ms_marco_minilm_l4_coreml_all.pte` | 39.6 | 0.0501 logits | 4.6 | 100.0% |
|
| 32 |
|
| 33 |
+
\*Mac arm64, one query-document pair at 512 tokens, **fastest of five medians of ten** — a
|
| 34 |
+
reference point for relative cost, not a device number. The host shares its cores with
|
| 35 |
+
other work, and a single median does not survive that; contention only ever adds time, so
|
| 36 |
+
the fastest repetition is the one that means something. PyTorch eager fp32, measured the
|
| 37 |
+
same way: 11.6 ms.
|
| 38 |
|
| 39 |
Correlation is not reported because it cannot be: the output is a single number, and the
|
| 40 |
correlation of a one-element vector is undefined. The column above is the error in the
|
|
|
|
| 68 |
## The attention is eager, and that is the faster export
|
| 69 |
|
| 70 |
`F.scaled_dot_product_attention` does not survive export as one operation. The edge
|
| 71 |
+
dialect lowers it through `_safe_softmax`, whose guard against a row with no unmasked key
|
| 72 |
+
at all leaves **11 operations XNNPACK cannot take, in every attention
|
| 73 |
+
block** — `scalar_tensor`, `where`, `mul.Scalar`, `logical_not`, `eq`, `full_like`, `any.dim`. Each one cuts the subgraph in two.
|
| 74 |
+
|
| 75 |
+
The switch is `attn_implementation="eager"`: transformers then builds the mask
|
| 76 |
+
itself, as `torch.finfo(dtype).min`, instead of handing `F.sdpa` a **boolean** mask
|
| 77 |
+
for PyTorch to fill with `-inf`.
|
| 78 |
+
|
| 79 |
+
The guard is emitted whether or not it can ever fire, and here it cannot: it triggers only
|
| 80 |
+
on `-inf`, and this arm never produces one. So the two differ only about rows that have no
|
| 81 |
+
unmasked key at all — sdpa zeroes them, this one gives them a uniform row — and those are
|
| 82 |
+
padding rows, which the pooling discards and which every real query row masks out anyway.
|
| 83 |
+
Measured with all but eight positions masked, as adversarial as this shape gets, the two
|
| 84 |
+
graphs agree to 1.1e-05.
|
|
|
|
| 85 |
|
| 86 |
XNNPACK fp32 goes from **59.4% to 72.5%** delegated.
|
| 87 |
|