mlboydaisuke commited on
Commit
addb1e2
·
verified ·
1 Parent(s): cf12fd1

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +21 -20
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.4 | 72.5% |
30
- | fp16 | `rerank_ms_marco_minilm_l4_xnnpack_fp16.pte` | 38.4 | 0.0049 logits | 19.2 | 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, single process, median of 10, one query-document pair at 512 tokens — a
34
- reference point for relative cost, not a device number. PyTorch eager fp32 on the same
35
- machine: 11.9 ms.
 
 
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
- key at all leaves **eleven operations XNNPACK cannot take, in every attention block** —
71
- `scalar_tensor`, `where`, `mul.Scalar`, `logical_not`, `eq`, `full_like`, `any.dim`.
72
- Each one cuts the subgraph in two. The count is exact and does not vary by family:
73
- measured across this shelf, from a 4-layer cross-encoder to a 28-layer causal reranker,
74
- it is 11 per block every time.
75
-
76
- The guard is emitted whether or not it can ever fire, and here it cannot. It triggers
77
- only on `-inf`, which reaches the graph only because the sdpa path hands `F.sdpa` a
78
- **boolean** mask for PyTorch to fill; `attn_implementation="eager"` masks with
79
- `torch.finfo(dtype).min`, a large finite number, and never produces one. So the two
80
- arms differ only on rows that have no unmasked key sdpa zeroes them, eager gives them
81
- a uniform row and those are padding rows, which the pooling discards and every real
82
- query row masks out. Measured with all but eight positions masked, as adversarial as
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