mlboydaisuke commited on
Commit
5f5e017
·
verified ·
1 Parent(s): 4d985d6

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +23 -21
README.md CHANGED
@@ -40,13 +40,16 @@ retrieves worse.
40
 
41
  | build | file | size (MB) | Mac ms* | backend takes | worst cosine vs eager | retrieval budget |
42
  |---|---|---|---|---|---|---|
43
- | fp32 | `embed_multilingual_e5_large_xnnpack_fp32.pte` | 2235.7 | 103.6 | 80.7% | 1.000000 | 0% |
44
- | fp16 | `embed_multilingual_e5_large_xnnpack_fp16.pte` | 1118.2 | 145.5 | 69.6% | 0.999999 | 6% |
45
- | Core ML (fp16, iOS) | `embed_multilingual_e5_large_coreml_all.pte` | 1119.5 | 28.1 | 100.0% | 0.999992 | 40% |
46
 
47
- \*Mac arm64, median of 10, one 256-token sequence a reference point for relative
48
- cost, not a device number. Torch eager fp32 on the same machine is
49
- 135.6 ms.
 
 
 
50
 
51
  Cosine is measured against the model run in eager through its own pooling, over eight
52
  sentences. The last column is the one that decides: rank those eight against each
@@ -57,21 +60,20 @@ top-1 results.
57
  ## The attention is eager, and that is the faster export
58
 
59
  `F.scaled_dot_product_attention` does not survive export as one operation. The edge
60
- dialect lowers it through `_safe_softmax`, whose guard against a row with no unmasked
61
- key at all leaves **eleven operations XNNPACK cannot take, in every attention block** —
62
- `scalar_tensor`, `where`, `mul.Scalar`, `logical_not`, `eq`, `full_like`, `any.dim`.
63
- Each one cuts the subgraph in two. The count is exact and does not vary by family:
64
- measured across this shelf, from a 4-layer cross-encoder to a 28-layer causal reranker,
65
- it is 11 per block every time.
66
-
67
- The guard is emitted whether or not it can ever fire, and here it cannot. It triggers
68
- only on `-inf`, which reaches the graph only because the sdpa path hands `F.sdpa` a
69
- **boolean** mask for PyTorch to fill; `attn_implementation="eager"` masks with
70
- `torch.finfo(dtype).min`, a large finite number, and never produces one. So the two
71
- arms differ only on rows that have no unmasked key sdpa zeroes them, eager gives them
72
- a uniform row and those are padding rows, which the pooling discards and every real
73
- query row masks out. Measured with all but eight positions masked, as adversarial as
74
- this shape gets, the two graphs agree to 1.4e-07.
75
 
76
  XNNPACK fp32 goes from **63.8% to 80.7%** delegated.
77
 
 
40
 
41
  | build | file | size (MB) | Mac ms* | backend takes | worst cosine vs eager | retrieval budget |
42
  |---|---|---|---|---|---|---|
43
+ | fp32 | `embed_multilingual_e5_large_xnnpack_fp32.pte` | 2235.7 | 85.9 | 80.7% | 1.000000 | 0% |
44
+ | fp16 | `embed_multilingual_e5_large_xnnpack_fp16.pte` | 1118.2 | 142.2 | 69.6% | 0.999999 | 6% |
45
+ | Core ML (fp16, iOS) | `embed_multilingual_e5_large_coreml_all.pte` | 1119.5 | 27.2 | 100.0% | 0.999992 | 40% |
46
 
47
+ \*Mac arm64, one 256-token sequence, **fastest of five medians of ten** — a reference
48
+ point for relative cost, not a device number. The host shares its cores with other work,
49
+ and a single median does not survive that: the same eager model here measured 19.6 ms and
50
+ 182.8 ms twenty minutes apart. Contention only ever adds time, so the fastest repetition is
51
+ the one that means something. Torch eager fp32, measured the same way, is
52
+ 108.5 ms.
53
 
54
  Cosine is measured against the model run in eager through its own pooling, over eight
55
  sentences. The last column is the one that decides: rank those eight against each
 
60
  ## The attention is eager, and that is the faster export
61
 
62
  `F.scaled_dot_product_attention` does not survive export as one operation. The edge
63
+ dialect lowers it through `_safe_softmax`, whose guard against a row with no unmasked key
64
+ at all leaves **11 operations XNNPACK cannot take, in every attention
65
+ block** — `scalar_tensor`, `where`, `mul.Scalar`, `logical_not`, `eq`, `full_like`, `any.dim`. Each one cuts the subgraph in two.
66
+
67
+ The switch is `attn_implementation="eager"`: transformers then builds the mask
68
+ itself, as `torch.finfo(dtype).min`, instead of handing `F.sdpa` a **boolean** mask
69
+ for PyTorch to fill with `-inf`.
70
+
71
+ The guard is emitted whether or not it can ever fire, and here it cannot: it triggers only
72
+ on `-inf`, and this arm never produces one. So the two differ only about rows that have no
73
+ unmasked key at all sdpa zeroes them, this one gives them a uniform row — and those are
74
+ padding rows, which the pooling discards and which every real query row masks out anyway.
75
+ Measured with all but eight positions masked, as adversarial as this shape gets, the two
76
+ graphs agree to 1.4e-07.
 
77
 
78
  XNNPACK fp32 goes from **63.8% to 80.7%** delegated.
79