mlboydaisuke commited on
Commit
49f49ab
·
verified ·
1 Parent(s): c86f173

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +22 -21
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_bge_reranker_base_xnnpack_fp32.pte` | 1112.3 | 0.0000 logits | 55.3 | 78.3% |
30
- | fp16 | `rerank_bge_reranker_base_xnnpack_fp16.pte` | 556.4 | 0.0067 logits | 96.6 | 67.8% |
31
- | Core ML (fp16, iOS) | `rerank_bge_reranker_base_coreml_all.pte` | 557.7 | 0.0419 logits | 20.1 | 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: 62.4 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
@@ -65,21 +67,20 @@ this shelf, scores the same passage -10.96 and puts it fifth of
65
  ## The attention is eager, and that is the faster export
66
 
67
  `F.scaled_dot_product_attention` does not survive export as one operation. The edge
68
- dialect lowers it through `_safe_softmax`, whose guard against a row with no unmasked
69
- key at all leaves **eleven operations XNNPACK cannot take, in every attention block** —
70
- `scalar_tensor`, `where`, `mul.Scalar`, `logical_not`, `eq`, `full_like`, `any.dim`.
71
- Each one cuts the subgraph in two. The count is exact and does not vary by family:
72
- measured across this shelf, from a 4-layer cross-encoder to a 28-layer causal reranker,
73
- it is 11 per block every time.
74
-
75
- The guard is emitted whether or not it can ever fire, and here it cannot. It triggers
76
- only on `-inf`, which reaches the graph only because the sdpa path hands `F.sdpa` a
77
- **boolean** mask for PyTorch to fill; `attn_implementation="eager"` masks with
78
- `torch.finfo(dtype).min`, a large finite number, and never produces one. So the two
79
- arms differ only on rows that have no unmasked key sdpa zeroes them, eager gives them
80
- a uniform row and those are padding rows, which the pooling discards and every real
81
- query row masks out. Measured with all but eight positions masked, as adversarial as
82
- this shape gets, the two graphs agree to 1.1e-05.
83
 
84
  XNNPACK fp32 goes from **62.5% to 78.3%** delegated.
85
 
 
26
 
27
  | build | file | size (MB) | worst score error vs eager | Mac median (ms)* | backend takes |
28
  |---|---|---|---|---|---|
29
+ | fp32 | `rerank_bge_reranker_base_xnnpack_fp32.pte` | 1112.3 | 0.0000 logits | 54.9 | 78.3% |
30
+ | fp16 | `rerank_bge_reranker_base_xnnpack_fp16.pte` | 556.4 | 0.0067 logits | 95.6 | 67.8% |
31
+ | Core ML (fp16, iOS) | `rerank_bge_reranker_base_coreml_all.pte` | 557.7 | 0.0419 logits | 19.9 | 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: 62.3 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
 
67
  ## The attention is eager, and that is the faster export
68
 
69
  `F.scaled_dot_product_attention` does not survive export as one operation. The edge
70
+ dialect lowers it through `_safe_softmax`, whose guard against a row with no unmasked key
71
+ at all leaves **11 operations XNNPACK cannot take, in every attention
72
+ block** — `scalar_tensor`, `where`, `mul.Scalar`, `logical_not`, `eq`, `full_like`, `any.dim`. Each one cuts the subgraph in two.
73
+
74
+ The switch is `attn_implementation="eager"`: transformers then builds the mask
75
+ itself, as `torch.finfo(dtype).min`, instead of handing `F.sdpa` a **boolean** mask
76
+ for PyTorch to fill with `-inf`.
77
+
78
+ The guard is emitted whether or not it can ever fire, and here it cannot: it triggers only
79
+ on `-inf`, and this arm never produces one. So the two differ only about rows that have no
80
+ unmasked key at all sdpa zeroes them, this one gives them a uniform row — and those are
81
+ padding rows, which the pooling discards and which every real query row masks out anyway.
82
+ Measured with all but eight positions masked, as adversarial as this shape gets, the two
83
+ graphs agree to 1.1e-05.
 
84
 
85
  XNNPACK fp32 goes from **62.5% to 78.3%** delegated.
86