sm_120 m/l/xl engines: fused fp16 attention (+11/+13/+21 %); s unchanged. Card: per-bucket attention precision, trt11.3 file list
Browse files- README.md +61 -8
- code-daemon-embed-v1-l_linux_x64_trt11.3_sm_120.engine +2 -2
- code-daemon-embed-v1-l_win_x64_trt11.3_sm_120.engine +2 -2
- code-daemon-embed-v1-m_linux_x64_trt11.3_sm_120.engine +2 -2
- code-daemon-embed-v1-m_win_x64_trt11.3_sm_120.engine +2 -2
- code-daemon-embed-v1-xl_linux_x64_trt11.3_sm_120.engine +2 -2
- code-daemon-embed-v1-xl_win_x64_trt11.3_sm_120.engine +2 -2
README.md
CHANGED
|
@@ -206,7 +206,10 @@ inference time; it is higher because host work overlaps with the GPU.
|
|
| 206 |
|
| 207 |
Four engines, one per length bucket, each with a **dynamic sequence dimension** so a batch
|
| 208 |
can be dispatched at its own longest text instead of the bucket ceiling. One engine alone,
|
| 209 |
-
dispatch only, 200 iterations
|
|
|
|
|
|
|
|
|
|
| 210 |
|
| 211 |
**s** β 96 Γ 8β¦48, opt 48
|
| 212 |
|
|
@@ -253,6 +256,46 @@ Three things to take from that table when you build your own serving path:
|
|
| 253 |
they measured *slower* than serially (1,487 ms vs 1,423 ms for the same work). The lanes
|
| 254 |
exist to keep the GPU fed while the host works, not to multiply throughput.
|
| 255 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 256 |
### Without a discrete GPU β OpenVINO on CPU, integrated GPU and NPU
|
| 257 |
|
| 258 |
Same model, no NVIDIA card involved. Measured on an **Intel Core Ultra 9 275HX** β its CPU
|
|
@@ -480,8 +523,9 @@ codesearchnet python 68.30 β 68.32.
|
|
| 480 |
**Prebuilt engines**, uploaded progressively per architecture:
|
| 481 |
|
| 482 |
```text
|
| 483 |
-
TensorRT β¦-{s,m,l,xl}_{win_x64,linux_x64}_trt11.
|
| 484 |
-
β¦-{s,m,l,xl}_linux_x64_trt11.
|
|
|
|
| 485 |
OpenVINO β¦-{s,m,l,xl}_ov2026.4_{cpu_int8,igpu_lnl_int8,npu_int4}_b*_s*.{xml,bin}
|
| 486 |
TVM Vulkan β¦_{win_x64,linux_x64}_tvm0.25_vulkan.{dll,so}
|
| 487 |
MLX (Apple) model_gpu_mlx0.32/
|
|
@@ -499,11 +543,11 @@ The filenames are a loading contract, not decoration. A serialized TensorRT plan
|
|
| 499 |
fallback, so pick all four coordinates exactly:
|
| 500 |
|
| 501 |
```
|
| 502 |
-
code-daemon-embed-v1-m_win_x64_trt11.
|
| 503 |
β β β βββ GPU arch: sm_75 Turing Β· sm_80 Ampere (A100, A30)
|
| 504 |
β β β sm_86 Ampere (RTX 30xx, A-series) Β· sm_89 Ada (RTX 40xx, L4)
|
| 505 |
β β β sm_90 Hopper (H100, H200) Β· sm_120 Blackwell (RTX 50xx)
|
| 506 |
-
β β βββ TensorRT 11.
|
| 507 |
β βββ OS/ABI
|
| 508 |
βββ length bucket: s | m | l | xl
|
| 509 |
```
|
|
@@ -550,8 +594,9 @@ Two notes that cost real debugging time:
|
|
| 550 |
### 4.4 Building your own TensorRT engines
|
| 551 |
|
| 552 |
TensorRT 11 reads precision **entirely from the ONNX Q/DQ nodes** β the per-precision flags
|
| 553 |
-
(`--int8`, `--fp16`, `--calib`) were removed. Feed it the Q/DQ graph
|
| 554 |
-
`--stronglyTyped`
|
|
|
|
| 555 |
cleanly, loads cleanly, is twice the size and a fraction of the speed β the size is the only
|
| 556 |
visible symptom, so check it.
|
| 557 |
|
|
@@ -560,7 +605,6 @@ Rectangular engine for one bucket (here **m**, 128Γ64):
|
|
| 560 |
```bash
|
| 561 |
trtexec --onnx=model_int8qdt.onnx \
|
| 562 |
--saveEngine=code-daemon-embed-v1-m.engine \
|
| 563 |
-
--stronglyTyped \
|
| 564 |
--builderOptimizationLevel=5 \
|
| 565 |
--timingCacheFile=timing.cache \
|
| 566 |
--minShapes=input_ids:1x1,attention_mask:1x1 \
|
|
@@ -588,6 +632,15 @@ Three rules behind those numbers:
|
|
| 588 |
Without the sort the dynamic engines buy ~0%: any 128-text batch drawn from the 49β64 range
|
| 589 |
almost surely contains a 64 and dispatches at 64 anyway.
|
| 590 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 591 |
A dynamic build reports ~69 layers against a rectangular build's ~54 β a wider shape range
|
| 592 |
costs fusions, and that is exactly where the small tax at the ceiling lives.
|
| 593 |
|
|
|
|
| 206 |
|
| 207 |
Four engines, one per length bucket, each with a **dynamic sequence dimension** so a batch
|
| 208 |
can be dispatched at its own longest text instead of the bucket ceiling. One engine alone,
|
| 209 |
+
dispatch only, 200 iterations. These are the engines built straight from `model_int8qdt.onnx`,
|
| 210 |
+
with attention in fp32 β what every architecture ships except the sm_120 **m / l / xl**
|
| 211 |
+
engines, which are faster (see [Attention precision differs by bucket on
|
| 212 |
+
sm_120](#attention-precision-differs-by-bucket-on-sm_120)):
|
| 213 |
|
| 214 |
**s** β 96 Γ 8β¦48, opt 48
|
| 215 |
|
|
|
|
| 256 |
they measured *slower* than serially (1,487 ms vs 1,423 ms for the same work). The lanes
|
| 257 |
exist to keep the GPU fed while the host works, not to multiply throughput.
|
| 258 |
|
| 259 |
+
### Attention precision differs by bucket on sm_120
|
| 260 |
+
|
| 261 |
+
On RTX 50xx (sm_120) the **m, l and xl** engines run each attention core as **one fused fp16
|
| 262 |
+
kernel**; the **s** engine does not, on purpose.
|
| 263 |
+
|
| 264 |
+
An engine built straight from `model_int8qdt.onnx` runs attention in fp32: QKα΅, softmax and Β·V
|
| 265 |
+
as separate kernels, with the score matrix written to memory in between. TensorRT has no fused
|
| 266 |
+
kernel for fp32 attention at this configuration (12 heads Γ 64) on sm_120. The m / l / xl
|
| 267 |
+
engines are built from the same graph with each of the four attention cores expressed as a
|
| 268 |
+
native ONNX `Attention` op on fp16 Q, K, V and mask, its output cast back to fp32. Nothing else
|
| 269 |
+
changes: every INT8 GEMM, LayerNorm and the fused pooling are identical, and so is the I/O
|
| 270 |
+
contract.
|
| 271 |
+
|
| 272 |
+
**s keeps fp32 attention because the fused kernel is slower at its shape.** One engine alone,
|
| 273 |
+
real text, the two variants interleaved, minimum of 9 rounds:
|
| 274 |
+
|
| 275 |
+
| bucket | batch Γ seq | fp32 attention | fused fp16 attention | | cos vs FP32 ONNX (mean / min) |
|
| 276 |
+
|---|---|--:|--:|--:|---|
|
| 277 |
+
| s | 96 Γ 48 | **20,272** | 18,577 | β8.4 % | 0.9772 / 0.9634 β 0.9769 / 0.9660 |
|
| 278 |
+
| m | 128 Γ 64 | 12,771 | **14,188** | +11.1 % | 0.9776 / 0.9613 β 0.9777 / 0.9660 |
|
| 279 |
+
| l | 128 Γ 80 | 9,525 | **10,772** | +13.1 % | 0.9776 / 0.9613 β 0.9774 / 0.9623 |
|
| 280 |
+
| xl | 256 Γ 128 | 5,259 | **6,344** | +20.6 % | 0.9776 / 0.9613 β 0.9779 / 0.9663 |
|
| 281 |
+
|
| 282 |
+
(texts/s at the full batch; the gain holds across each dynamic range β per seq cell m +7 to
|
| 283 |
+
+16 %, l +11 to +13 %, xl +14 to +21 %.)
|
| 284 |
+
|
| 285 |
+
**End to end**, a full index through the production indexer, the two engine sets alternated
|
| 286 |
+
twice each: embedding wall time **β13.8 %** on a 24k-vector repository and **β10.8 %** on a
|
| 287 |
+
90k-vector Java repository (the smaller gain is the more tokenizer-bound pipeline; the GPU part
|
| 288 |
+
of both fell by ~9 %). Long texts carry the gain β xl is a quarter to three quarters of the texts
|
| 289 |
+
in a code corpus but half or more of the GPU time.
|
| 290 |
+
|
| 291 |
+
**The vectors are interchangeable.** The two variants differ from each other by less than each
|
| 292 |
+
differs from the FP32 graph: top-10 neighbours agree with the FP32 answer 0.855 of the time with
|
| 293 |
+
fp32 attention and 0.859 with fused fp16 attention, and 0.859 when fused-attention queries are
|
| 294 |
+
run against a store embedded with fp32 attention. An existing index does not need re-embedding.
|
| 295 |
+
|
| 296 |
+
Engines for **sm_75 β sm_90** are built from the unmodified graph (fp32 attention); whether the
|
| 297 |
+
fused variant helps on those architectures has not been measured.
|
| 298 |
+
|
| 299 |
### Without a discrete GPU β OpenVINO on CPU, integrated GPU and NPU
|
| 300 |
|
| 301 |
Same model, no NVIDIA card involved. Measured on an **Intel Core Ultra 9 275HX** β its CPU
|
|
|
|
| 523 |
**Prebuilt engines**, uploaded progressively per architecture:
|
| 524 |
|
| 525 |
```text
|
| 526 |
+
TensorRT β¦-{s,m,l,xl}_{win_x64,linux_x64}_trt11.3_sm_{75,80,86,89,120}.engine
|
| 527 |
+
β¦-{s,m,l,xl}_linux_x64_trt11.3_sm_90.engine
|
| 528 |
+
(sm_120 m / l / xl: fused fp16 attention β Β§3; all others: fp32 attention)
|
| 529 |
OpenVINO β¦-{s,m,l,xl}_ov2026.4_{cpu_int8,igpu_lnl_int8,npu_int4}_b*_s*.{xml,bin}
|
| 530 |
TVM Vulkan β¦_{win_x64,linux_x64}_tvm0.25_vulkan.{dll,so}
|
| 531 |
MLX (Apple) model_gpu_mlx0.32/
|
|
|
|
| 543 |
fallback, so pick all four coordinates exactly:
|
| 544 |
|
| 545 |
```
|
| 546 |
+
code-daemon-embed-v1-m_win_x64_trt11.3_sm_120.engine
|
| 547 |
β β β βββ GPU arch: sm_75 Turing Β· sm_80 Ampere (A100, A30)
|
| 548 |
β β β sm_86 Ampere (RTX 30xx, A-series) Β· sm_89 Ada (RTX 40xx, L4)
|
| 549 |
β β β sm_90 Hopper (H100, H200) Β· sm_120 Blackwell (RTX 50xx)
|
| 550 |
+
β β βββ TensorRT 11.3 β a plan loads only on the TensorRT that built it
|
| 551 |
β βββ OS/ABI
|
| 552 |
βββ length bucket: s | m | l | xl
|
| 553 |
```
|
|
|
|
| 594 |
### 4.4 Building your own TensorRT engines
|
| 595 |
|
| 596 |
TensorRT 11 reads precision **entirely from the ONNX Q/DQ nodes** β the per-precision flags
|
| 597 |
+
(`--int8`, `--fp16`, `--calib`) were removed. Feed it the Q/DQ graph; strongly typed is the
|
| 598 |
+
only mode (`--stronglyTyped` is accepted and has no effect since 11.3). Feed it an unquantized
|
| 599 |
+
graph instead and you get an FP16 engine that builds
|
| 600 |
cleanly, loads cleanly, is twice the size and a fraction of the speed β the size is the only
|
| 601 |
visible symptom, so check it.
|
| 602 |
|
|
|
|
| 605 |
```bash
|
| 606 |
trtexec --onnx=model_int8qdt.onnx \
|
| 607 |
--saveEngine=code-daemon-embed-v1-m.engine \
|
|
|
|
| 608 |
--builderOptimizationLevel=5 \
|
| 609 |
--timingCacheFile=timing.cache \
|
| 610 |
--minShapes=input_ids:1x1,attention_mask:1x1 \
|
|
|
|
| 632 |
Without the sort the dynamic engines buy ~0%: any 128-text batch drawn from the 49β64 range
|
| 633 |
almost surely contains a 64 and dispatches at 64 anyway.
|
| 634 |
|
| 635 |
+
An engine built this way has **fp32 attention** (Β§3). On sm_120 the shipped m / l / xl engines
|
| 636 |
+
fuse it instead: replace each attention core β `Mul(Q)`, `Mul(Kα΅)` β `MatMul` β `Add(mask)` β
|
| 637 |
+
`Softmax` β `MatMul(Β·V)` β with an opset-23 `Attention` op on fp16 Q, K, V and mask (default
|
| 638 |
+
scale; the export's two `64^-ΒΌ` multipliers are exactly `1/β64`), cast its output back to fp32,
|
| 639 |
+
and keep the **s** bucket on the plain graph. Clamp the mask's `-3.4e38` fill to `-10000` first:
|
| 640 |
+
fp16 cannot hold it. Two shapes that look equivalent do **not** fuse on sm_120: an fp32
|
| 641 |
+
`Attention` op (the build fails with "not supported by a dedicated kernel"), and fp16 Q/K/V
|
| 642 |
+
cast back up to fp32 around the op.
|
| 643 |
+
|
| 644 |
A dynamic build reports ~69 layers against a rectangular build's ~54 β a wider shape range
|
| 645 |
costs fusions, and that is exactly where the small tax at the ceiling lives.
|
| 646 |
|
code-daemon-embed-v1-l_linux_x64_trt11.3_sm_120.engine
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:696772ac0a006f25e52d42a646e791738586c92a427548dd70aef7f9ce67f0c3
|
| 3 |
+
size 101772172
|
code-daemon-embed-v1-l_win_x64_trt11.3_sm_120.engine
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f359a3951007a5d22e38fe44ccddc26883c554dace59eea1ff87488001aa3c48
|
| 3 |
+
size 101786564
|
code-daemon-embed-v1-m_linux_x64_trt11.3_sm_120.engine
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:486f3c1bffcfce2761ebce326d0257a5f23f92dc330504209deddfbb7c2815e3
|
| 3 |
+
size 101754628
|
code-daemon-embed-v1-m_win_x64_trt11.3_sm_120.engine
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:249ce10d3ea0b1ea7896eb4f15fa567ea9ed2518efd703315ee277dee5a3b145
|
| 3 |
+
size 101769012
|
code-daemon-embed-v1-xl_linux_x64_trt11.3_sm_120.engine
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:33eb7a45cd9f9c1d321613094d7ab836a10066a5304d8e59db700c228a73d7ea
|
| 3 |
+
size 101791316
|
code-daemon-embed-v1-xl_win_x64_trt11.3_sm_120.engine
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:14f97f2d9a4d18c8e5cc77b7bb51c724c2d58dfc3452b293352e7818b481dc8e
|
| 3 |
+
size 101814572
|