handwoven8588 commited on
Commit
5265f03
·
verified ·
1 Parent(s): d1021c8

Card: parity table at 1954de4 and real-document results at the model defaults

Browse files
Files changed (1) hide show
  1. README.md +42 -26
README.md CHANGED
@@ -99,51 +99,67 @@ The weights are the original CodeRankEmbed weights (bf16-cast), so embeddings ma
99
  original to within bf16 precision. The table below measures every tier **on the same GPU**, so
100
  `eager` is the O(seq²) baseline the varlen tiers are compared against.
101
 
102
- **Protocol.** 64 real Python source snippets (the first 40 lines of each file; 428 tokens mean,
103
- 638 max), encoded with sentence-transformers at an explicit **batch size of 32 and of 64** (the
 
104
  `batch_size=` passed to `encode`; with 64 snippets, 64 is one forward). Each tier encodes once
105
  untimed, then again for the measurement. Cosine similarity is taken on fp32-renormalized output
106
  against the **pre-dispatch revision of this repo on the same GPU** (its `flash_attn` path).
107
  `flash_attn` runs the same computation as before the dispatch, so its cosine is a parity check.
108
  `torch_varlen` is a different, torch-native kernel, and `eager` a different algorithm, so theirs
109
  are the real signal. `auto` is the default with no override: the probe keeps `torch_varlen`.
110
- **Encode peak** is the encode's peak CUDA allocation above what the loaded model holds (266 MiB
111
- of bf16 weights; the first model loaded in a process also holds cuBLAS's workspace, 8 MiB on sm_86
112
- and 32 MiB on sm_120). Each tier loads and frees its own model, so no reading includes another
113
- tier's weights. Wall time is one encode of all 64 snippets. Cosines and VRAM repeated exactly
114
- across every run; wall time moved by up to ~15% between runs, so read it as indicative.
115
- Every row was measured loading this repo at commit `1954de4`.
116
 
117
  | GPU | batch size | tier | mean cos | min cos | encode peak | wall |
118
  | --- | --- | --- | --- | --- | --- | --- |
119
  | RTX 3090 Ti (sm_86) | 32 | `torch_varlen` | 0.999941 | 0.999856 | 600 MiB | 0.197 s |
120
  | RTX 3090 Ti (sm_86) | 32 | `flash_attn` | 1.000000 | 1.000000 | 600 MiB | 0.197 s |
121
  | RTX 3090 Ti (sm_86) | 32 | `eager` | 0.999912 | 0.999856 | 807 MiB | 0.262 s |
122
- | RTX 3090 Ti (sm_86) | 32 | `auto` (→ `torch_varlen`) | 0.999941 | 0.999856 | 600 MiB | 0.197 s |
123
  | RTX 3090 Ti (sm_86) | 64 | `torch_varlen` | 0.999941 | 0.999856 | 1201 MiB | 0.223 s |
124
  | RTX 3090 Ti (sm_86) | 64 | `flash_attn` | 1.000000 | 1.000000 | 1201 MiB | 0.218 s |
125
  | RTX 3090 Ti (sm_86) | 64 | `eager` | 0.999910 | 0.999856 | 1614 MiB | 0.302 s |
126
- | RTX 3090 Ti (sm_86) | 64 | `auto` (→ `torch_varlen`) | 0.999941 | 0.999856 | 1201 MiB | 0.218 s |
127
- | RTX 5090 Laptop GPU (sm_120) | 32 | `torch_varlen` | 0.999944 | 0.999919 | 600 MiB | 0.235 s |
128
- | RTX 5090 Laptop GPU (sm_120) | 32 | `flash_attn` | 1.000000 | 1.000000 | 600 MiB | 0.234 s |
129
- | RTX 5090 Laptop GPU (sm_120) | 32 | `eager` | 0.999912 | 0.999870 | 807 MiB | 0.318 s |
130
- | RTX 5090 Laptop GPU (sm_120) | 32 | `auto` (→ `torch_varlen`) | 0.999944 | 0.999919 | 600 MiB | 0.235 s |
131
- | RTX 5090 Laptop GPU (sm_120) | 64 | `torch_varlen` | 0.999944 | 0.999919 | 1201 MiB | 0.271 s |
132
- | RTX 5090 Laptop GPU (sm_120) | 64 | `flash_attn` | 1.000000 | 1.000000 | 1201 MiB | 0.273 s |
133
- | RTX 5090 Laptop GPU (sm_120) | 64 | `eager` | 0.999913 | 0.999834 | 1614 MiB | 0.377 s |
134
- | RTX 5090 Laptop GPU (sm_120) | 64 | `auto` (→ `torch_varlen`) | 0.999944 | 0.999919 | 1201 MiB | 0.274 s |
135
 
136
  Cosines rounded to 6 decimal places, VRAM to the nearest MiB. `torch 2.12.1+cu130`,
137
- `transformers 5.11.0`, `sentence-transformers 6.1.0`, `flash-attn 2.8.3` (`2.8.3.post1` on the 3090 Ti host).
138
- Each run held the hosts' shared GPU lock, with the card idle (0% util, no foreign process)
139
- before and after.
140
 
141
  Eager's cost grows with `batch × heads × seq²`: at these short snippets it needs about a third more
142
- encode memory than the varlen tiers. At longer inputs the gap stops being a percentage. At a
143
- batch size of **256** inputs of ~300–2048 tokens, `torch_varlen` stays under 20 GB peak VRAM,
144
- while eager's attention scores alone (`256 × 12 heads × 2048² × 2 bytes`) exceed a 24 GB card.
145
- Both varlen tiers are also gated downstream at min cosine > 0.997 against the fp32
146
- `nomic-ai/CodeRankEmbed` reference.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
147
 
148
  ## What changed vs the source repo
149
 
 
99
  original to within bf16 precision. The table below measures every tier **on the same GPU**, so
100
  `eager` is the O(seq²) baseline the varlen tiers are compared against.
101
 
102
+ **Protocol.** 64 real Python source snippets (the first 40 lines of the first 64 `.py` files,
103
+ by path, of the PenStock inference library's source tree; 428 tokens mean, 638 max), encoded
104
+ with sentence-transformers at an explicit **batch size of 32 and of 64** (the
105
  `batch_size=` passed to `encode`; with 64 snippets, 64 is one forward). Each tier encodes once
106
  untimed, then again for the measurement. Cosine similarity is taken on fp32-renormalized output
107
  against the **pre-dispatch revision of this repo on the same GPU** (its `flash_attn` path).
108
  `flash_attn` runs the same computation as before the dispatch, so its cosine is a parity check.
109
  `torch_varlen` is a different, torch-native kernel, and `eager` a different algorithm, so theirs
110
  are the real signal. `auto` is the default with no override: the probe keeps `torch_varlen`.
111
+ **Encode peak** is the encode's peak CUDA allocation above the loaded model's own ~266 MiB of
112
+ bf16 weights. Wall time is one encode of all 64 snippets.
 
 
 
 
113
 
114
  | GPU | batch size | tier | mean cos | min cos | encode peak | wall |
115
  | --- | --- | --- | --- | --- | --- | --- |
116
  | RTX 3090 Ti (sm_86) | 32 | `torch_varlen` | 0.999941 | 0.999856 | 600 MiB | 0.197 s |
117
  | RTX 3090 Ti (sm_86) | 32 | `flash_attn` | 1.000000 | 1.000000 | 600 MiB | 0.197 s |
118
  | RTX 3090 Ti (sm_86) | 32 | `eager` | 0.999912 | 0.999856 | 807 MiB | 0.262 s |
 
119
  | RTX 3090 Ti (sm_86) | 64 | `torch_varlen` | 0.999941 | 0.999856 | 1201 MiB | 0.223 s |
120
  | RTX 3090 Ti (sm_86) | 64 | `flash_attn` | 1.000000 | 1.000000 | 1201 MiB | 0.218 s |
121
  | RTX 3090 Ti (sm_86) | 64 | `eager` | 0.999910 | 0.999856 | 1614 MiB | 0.302 s |
122
+ | RTX 5090 Laptop GPU (sm_120) | 32 | `torch_varlen` | 0.999944 | 0.999919 | 600 MiB | 0.177 s |
123
+ | RTX 5090 Laptop GPU (sm_120) | 32 | `flash_attn` | 1.000000 | 1.000000 | 600 MiB | 0.175 s |
124
+ | RTX 5090 Laptop GPU (sm_120) | 32 | `eager` | 0.999912 | 0.999870 | 807 MiB | 0.249 s |
125
+ | RTX 5090 Laptop GPU (sm_120) | 64 | `torch_varlen` | 0.999944 | 0.999919 | 1201 MiB | 0.202 s |
126
+ | RTX 5090 Laptop GPU (sm_120) | 64 | `flash_attn` | 1.000000 | 1.000000 | 1201 MiB | 0.203 s |
127
+ | RTX 5090 Laptop GPU (sm_120) | 64 | `eager` | 0.999913 | 0.999834 | 1614 MiB | 0.298 s |
 
 
 
128
 
129
  Cosines rounded to 6 decimal places, VRAM to the nearest MiB. `torch 2.12.1+cu130`,
130
+ `transformers 5.11.0`, `sentence-transformers 6.1.0`, `flash-attn 2.8.3` (`2.8.3.post1` on the
131
+ 3090 Ti), all measured loading this repo at `1954de4`.
 
132
 
133
  Eager's cost grows with `batch × heads × seq²`: at these short snippets it needs about a third more
134
+ encode memory than the varlen tiers. At longer inputs the gap stops being a percentage.
135
+
136
+ **Real documents at the model defaults.** 768 Python files sampled with a fixed seed from one shard
137
+ of [`HuggingFaceTB/stack-edu`](https://huggingface.co/datasets/HuggingFaceTB/stack-edu) (730,431
138
+ tokens after truncation), encoded with sentence-transformers at this model's default
139
+ `max_seq_length` of 8192 and one `encode()` call per row, so the files are length-sorted before
140
+ batching. Wall time covers the whole corpus; peak VRAM is the peak CUDA allocation, weights
141
+ included. The largest batch row is the largest batch size that fit on each card (the 3090 Ti was
142
+ sharing about 1 GiB with other processes).
143
+
144
+ | GPU | batch size | tier | wall (768 files) | peak VRAM |
145
+ | --- | --- | --- | --- | --- |
146
+ | RTX 3090 Ti (sm_86) | 4 | `torch_varlen` | 6.57 s | 1,295 MiB |
147
+ | RTX 3090 Ti (sm_86) | 4 | `flash_attn` | 6.58 s | 1,296 MiB |
148
+ | RTX 3090 Ti (sm_86) | 4 | `eager` | 14.18 s | 12,961 MiB |
149
+ | RTX 3090 Ti (sm_86) | 32 | `torch_varlen` | 6.37 s | 7,973 MiB |
150
+ | RTX 3090 Ti (sm_86) | 64 | `torch_varlen` | 7.24 s | 15,659 MiB |
151
+ | RTX 3090 Ti (sm_86) | 71 | `torch_varlen` | 7.60 s | 17,340 MiB |
152
+ | RTX 5090 Laptop GPU (sm_120) | 4 | `torch_varlen` | 5.54 s | 1,319 MiB |
153
+ | RTX 5090 Laptop GPU (sm_120) | 4 | `flash_attn` | 5.57 s | 1,319 MiB |
154
+ | RTX 5090 Laptop GPU (sm_120) | 4 | `eager` | 16.27 s | 12,983 MiB |
155
+ | RTX 5090 Laptop GPU (sm_120) | 32 | `torch_varlen` | 6.36 s | 7,995 MiB |
156
+ | RTX 5090 Laptop GPU (sm_120) | 64 | `torch_varlen` | 7.48 s | 15,681 MiB |
157
+ | RTX 5090 Laptop GPU (sm_120) | 73 | `torch_varlen` | 7.83 s | 17,843 MiB |
158
+
159
+ At batch 4 `eager` takes 2.2× (3090 Ti) to 2.9× (5090 Laptop) as long as the varlen tiers and needs
160
+ about ten times the memory. At batch 32 with the same files in random order, `eager` ran out of
161
+ memory on 21 of the 24 batches (3090 Ti). Both varlen tiers are also gated downstream at min
162
+ cosine > 0.997 against the fp32 `nomic-ai/CodeRankEmbed` reference.
163
 
164
  ## What changed vs the source repo
165