mlboydaisuke commited on
Commit
35da6e9
·
verified ·
1 Parent(s): 068e9da

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +28 -7
README.md CHANGED
@@ -24,15 +24,15 @@ each candidate together with the query and scores it properly.
24
 
25
  ## Variants
26
 
27
- | build | file | size (MB) | worst score error vs eager | Mac median (ms)* |
28
- |---|---|---|---|---|
29
- | fp32 | `rerank_ms_marco_minilm_l12_xnnpack_fp32.pte` | 133.6 | 0.0000 logits | 52.7 |
30
- | fp16 | `rerank_ms_marco_minilm_l12_xnnpack_fp16.pte` | 67.0 | 0.0070 logits | 102.1 |
31
- | Core ML (fp16, iOS) | `rerank_ms_marco_minilm_l12_coreml_all.pte` | 67.2 | 0.0428 logits | 13.3 |
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: 26.7 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
@@ -63,9 +63,30 @@ that answers it, feeding zeros instead of the real segment ids moves the score f
63
  The graph therefore takes three inputs. XLM-R rerankers (`type_vocab_size: 1`) have no
64
  second segment and take two; the signature follows the model rather than being made uniform.
65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  ## Not shipped
67
 
68
- - **int8 (dynamic) is not shipped**: at 69.7 MB it is larger than the fp16 build's 67.0 MB, and its score error is 0.1148 logits. Dynamic int8 quantizes the linear weights and leaves the token embedding table in fp32, while fp16 halves that table too. The table here is 47 MB of a 134 MB model, and the arithmetic says int8 only comes out smaller when the table is under a third of the weights (45 MB) — measured on ten models on this shelf, the rule called all ten correctly.
69
 
70
  ## Verification
71
 
 
24
 
25
  ## Variants
26
 
27
+ | build | file | size (MB) | worst score error vs eager | Mac median (ms)* | backend takes |
28
+ |---|---|---|---|---|---|
29
+ | fp32 | `rerank_ms_marco_minilm_l12_xnnpack_fp32.pte` | 133.6 | 0.0000 logits | 33.0 | 80.0% |
30
+ | fp16 | `rerank_ms_marco_minilm_l12_xnnpack_fp16.pte` | 66.9 | 0.0070 logits | 52.2 | 69.0% |
31
+ | Core ML (fp16, iOS) | `rerank_ms_marco_minilm_l12_coreml_all.pte` | 68.3 | 0.0369 logits | 13.2 | 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: 34.6 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
 
63
  The graph therefore takes three inputs. XLM-R rerankers (`type_vocab_size: 1`) have no
64
  second segment and take two; the signature follows the model rather than being made uniform.
65
 
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 **63.6% to 80.0%** delegated.
86
+
87
  ## Not shipped
88
 
89
+ - **int8 (dynamic) is not shipped**: at 69.7 MB it is larger than the fp16 build's 66.9 MB, and its score error is 0.1073 logits. Dynamic int8 quantizes the linear weights and leaves the token embedding table in fp32, while fp16 halves that table too. The table here is 47 MB of a 134 MB model, and the arithmetic says int8 only comes out smaller when the table is under a third of the weights (45 MB) — measured on ten models on this shelf, the rule called all ten correctly.
90
 
91
  ## Verification
92