Skip to content

feat: Add an INT8 token-embedding runtime sidecar - #235

Closed
mihai-chiorean wants to merge 1 commit into
NVIDIA:mainfrom
mihai-chiorean:feat/int8-embedding-sidecar
Closed

mihai-chiorean wants to merge 1 commit into
NVIDIA:mainfrom
mihai-chiorean:feat/int8-embedding-sidecar

Conversation

@mihai-chiorean

@mihai-chiorean mihai-chiorean commented Oct 9, 2026 •

Copy link
Copy Markdown

What does this PR do?

Type of change: new feature

Overview: Adds an opt-in INT8 format for the runtime token-embedding sidecar, embedding.safetensors.

  • Export: tensorrt-edgellm-export --int8-embedding writes the table as symmetric INT8 ([-127, 127]) with one FP32 scale per vocabulary row. The flag is mutually exclusive with --fp8-embedding. The ONNX graph, the engine and the checkpoint quantization are unchanged.
  • Runtime: embeddingLookup gains an Int8EmbeddingLoader that dequantizes only the gathered rows into the existing FP16 output; the table is never expanded to FP16 in device memory. Image and audio placeholder positions still receive their FP16 encoder features; out-of-vocabulary ids and placeholders without a mapped feature row are zero-filled, as with an FP16 table. The hidden size must be a multiple of 8 (one 8-byte load per lane), which the launcher checks.
  • What INT8 adds over the existing --fp8-embedding: per-row scales instead of 128-wide block scales; closer reconstruction on the table measured here (Qwen2.5-0.5B-Instruct, all 151,936 rows: cosine min 0.999738 vs 0.999582, max abs error 0.00079 vs 0.00476); a slightly smaller file (136,742,720 vs 140,389,048 bytes); and it is the format the follow-up PR extends to the Gemma 4 per-layer table, which has no FP8 option. Upstream's fp8-embedding.md lists FP8 embeddings as SM89+, although --fp8-embedding ran end to end on my AGX Orin.
  • Loader: loadEmbeddingTable now validates the table dtype at load. FP16, FP8 and INT8 are accepted; any other dtype is rejected with the dtype and file path, and an embedding_scale tensor beside an FP16 table is an error. Before this change a non-FP16 table was logged as "Loaded FP16 embedding" and only failed inside the first request, in the kernel's dtype check.
  • Qwen3-Omni: the Talker reads the Thinker's embedding.safetensors as dense FP16, so the exporter rejects --int8-embedding for Qwen3-Omni and the Talker runtime rejects a quantized sidecar at construction.
  • Docs: docs/source/user_guide/features/int8-embedding.md (file contract, memory example, limitations), a pointer from quantization.md, and the sidecar list in checkpoint-export.md.
  • CI: tests/defs learns an int8emb test parameter (export, build and inference; it appends -INT8-EMB to the model id and -int8emb to the ONNX id, so the INT8 export lives beside the FP16 one, and verifies the sidecar's tensors, dtypes and shapes after export), and the test lists gain test_checkpoint_export[Qwen2.5-0.5B-Instruct-fp16-int8emb] in l0_onnx_export_1.yml plus the matching test_engine_build and test_inference[...-int8emb-llm_basic] cases in l0_pipeline_a30.yml. I cannot run NVIDIA's CI, so these entries are untested there; the same export -> build -> inference sequence was run manually on a Jetson AGX Orin (below).

Memory for a [262144, 2560] table (Gemma 4 E4B): 1,342,177,280 bytes FP16, 672,137,216 bytes INT8 plus FP32 row scales.

Usage

tensorrt-edgellm-export /path/to/checkpoint /path/to/onnx --int8-embedding

The resulting embedding.safetensors holds two tensors, and the runtime selects the INT8 path from the table dtype:

Tensor dtype Shape
embedding INT8 [vocab, hidden]
embedding_scale FP32 [vocab]

Dequantization is fp16(int8_value * row_scale); an all-zero row has scale 1.0.

Validation

Jetson AGX Orin 32 GB (SM87), JetPack 7.2 (L4T R39.2.1), CUDA 13.2.86, TensorRT 10.16.2.10, power mode MAXN with unlocked GPU clocks; candidate cadb95902d0a216583ec484016a8adb002b58ab6 built natively with -DBUILD_UNIT_TESTS=ON, baseline 0f52705 where stated.

  • Unit tests. The 12 unitTest* binaries were last run in full at 8a04d06 (all exit 0: unitTestCommon 149 passed; unitTestContextCache 203; unitTestCuteDslKernels 59; unitTestExamples 3; unitTestKernelsAttention 108 passed, 24 skipped (FP8 decode kernels); unitTestKernelsMisc 337 passed, 23 skipped; unitTestKernelsMoe 41 passed, 24 skipped (FP8/FP4); unitTestKernelsSpeculative 114; unitTestPlugins 17 passed, 1 skipped; unitTestRuntime 594 passed, 1 skipped; unitTestRuntimeState 113; unitTestScheduler 59). The only binary whose sources changed since then is unitTestKernelsMisc; at the final head it was rebuilt and run in full: 340 passed, 23 skipped, 0 failed (363 ran). The embedding filter (--gtest_filter='*Embedding*:*Int8*:*Ple*:*Fp16Lookup*:*SidecarLoader*:*GatherRejects*'): 33 passed, including the eleven new INT8, loader-rejection and kernel-rejection cases (hidden sizes 16, 2560 and 2568; the three loader messages with the file path; malformed INT8 scales at the loader and at embeddingLookup; scales passed with an FP16 table).

  • FP8 path on this device: the 13 FP8 unit tests in unitTestKernelsMisc pass (7 of them embedding-lookup tests), and --fp8-embedding ran end to end (export, llm_build, llm_inference, log Loaded FP8 embedding: [151936, 896], scales: [151936, 7]); its numbers are in the tables below.

  • Export -> build -> inference: Qwen/Qwen2.5-0.5B-Instruct (BF16 checkpoint, no weight quantization), exported on the device three times, without a flag, with --int8-embedding and with --fp8-embedding; model.onnx SHA256 4140fdc2a62367a9d3bd7ebe7c18c168c640aea42a1d4132b30cdf12ff78d239 and model.onnx.data SHA256 4ab2ce855ef82b721cd703a0665e725ed6518324636c2fb478388d89e718e309 are identical across the three exports; only embedding.safetensors differs. All built with llm_build --maxBatchSize 1 --maxInputLen 1024 --maxKVCacheCapacity 2048 and run with llm_inference (temperature 0, 64 new tokens). The INT8 engine logs Loaded INT8 embedding: [151936, 896], scales: [151936].

  • Output equivalence, 24 prompts (22 short, one ~250 tokens, one ~500 tokens), 64 new tokens, 1225 (FP16) / 1236 (INT8) generated tokens, 1218 positions compared pairwise. Across the separately built engines: INT8 vs FP16 16 of 24 prompts token-identical, FP8 vs FP16 16 of 24, FP8 vs INT8 14 of 24. On the same engine with the sidecar swapped (the engine binary serves either sidecar): FP16-built engine 20 of 24 identical (first differences at token 38, 31, 62, 21), INT8-built engine 19 of 24 (38, 31, 16, 14, 6); for reference, the same FP16 sidecar on the two builds gives 18 of 24 (TensorRT tactic selection differs between builds of identical ONNX). FP16 control run twice on one engine: 24 of 24 identical. Divergent continuations carry the same content.

  • Baseline vs candidate on the same FP16 engine and sidecar (24 prompts): 0f52705 runtime vs this branch 24 of 24 identical; vs the follow-up PLE branch 24 of 24 identical.

  • MMLU (N=500, stratified by subject with proportional allocation from the full 14,042-question test set, seed 0; 5-shot prompts from examples/accuracy/scripts/prepare_dataset.py, chat template, greedy, 64 new tokens, engines built with --maxInputLen 8192 --maxKVCacheCapacity 10240 --maxBatchSize 1, the sentence "Answer with the option's letter from the given choices directly." appended to the end of each user message; scored with calculate_correctness.py as shipped): FP16 35.0 % (175/500), INT8 35.6 % (178/500); identical predictions on 471/500; flips 4 (FP16-only correct) / 7 (INT8-only correct), exact McNemar p = 0.55; 469/500 (FP16) and 471/500 (INT8) answers parsed to a letter. The same subset at 8 new tokens gives 174 / 177 with 482/500 identical (467/500 parsed); with the harness's default prompt (no instruction, 32 tokens) only 308/500 parse (138 / 137, 451/500 identical); without the chat template the model continues the few-shot list (2/500 parse).

  • MMLU re-run with the letter instruction as a system turn (same 500 questions, this branch at cadb959; the instruction "Answer with the option's letter from the given choices directly. Reply with the letter only." moved from the end of the user message to a system turn, 16 new tokens instead of 64, chat template, greedy):

    model FP16 token table INT8 token table FP16-only / INT8-only correct identical predictions parsed McNemar exact p
    Qwen2.5-0.5B-Instruct 193 (38.6 %) 191 (38.2 %) 5 / 3 486 / 500 499 / 500 each 0.73
    Gemma 4 E4B W4A16, FP16 PLE table in both arms 323 (64.6 %) 323 (64.6 %) 0 / 0 499 / 500 500 / 500 each 1.00

    The Gemma row changes only this PR's table: one engine, the same FP16 PLE sidecar, and the token sidecar swapped. On the one question where its arms differ, both are wrong.

  • Load-time rejection, llm_inference exit 1 before any request: INT32 table -> Embedding tensor must be FP16, FP8, or INT8, got dtype 3: <path>; INT8 table without scales -> INT8 embedding requires 'embedding_scale' tensor: <path>; FP16 table with scales -> FP16 embedding must not have an 'embedding_scale' tensor: <path>.

  • Soak, 300 requests x 16 tokens on the INT8 engine, sampled every 0.5 s: VmRSS 2271 MiB at 10 % of the run, 2272 MiB at 50 %; system RAM above baseline 430 MiB -> 403 MiB; 300 of 300 responses.

  • Python unit tests, host: tests/python-unittests/test_embedding_quantization.py and test_export_embedding_flags.py, 26 passed. Run against main's sources, 22 of the 26 fail; the 4 that pass are compatibility guards, including the positional-argument test for write_runtime_artifacts.

Sidecar (file sizes for [151936, 896]; reconstruction against the FP16 table over all 151,936 rows, dequantized product rounded to FP16):

FP16 INT8 (per-row scales) FP8 (E4M3, block 128)
embedding.safetensors 272,269,400 B 136,742,720 B 140,389,048 B
row cosine mean / min / 1st percentile 0.999959 / 0.999738 / 0.999891 0.999674 / 0.999582 / 0.999629
max / mean abs error (max abs weight 0.2012) 0.00079 / 0.000116 0.00476 / 0.000262
prompts token-identical to the FP16 engine (of 24) 24 (control, same engine) 16 16
load log line Loaded FP16 embedding: [151936, 896] Loaded INT8 embedding: [151936, 896], scales: [151936] Loaded FP8 embedding: [151936, 896], scales: [151936, 7]

Memory, FP16 vs INT8 (0.5 s sampler of MemTotal - MemAvailable and process VmRSS during the 24-prompt run; --dumpProfile peaks; FP8 not measured):

FP16 INT8
peak system RAM above baseline 590 MiB 491 MiB
profile peak_gpu_memory (cuda free-memory delta, tool unit "MB") 514 417
peak process VmRSS 2357 MiB 2272 MiB
system RAM above baseline at "Runtime initialized" 48 MiB 44 MiB

The saving measured during inference is 99 MiB of system RAM, 97 of the profiler's "MB" of free-memory delta and 85 MiB of process VmRSS, against a file-size difference of 135,526,680 bytes; the remainder is allocation granularity of the runtime's device buffers (the soak shows no growth).

Speed, FP16 vs INT8 (llm_bench: 20 iterations after 3 warmup, batch 1; llm_inference --dumpProfile: 20 identical requests after 2 warmup, GPU stage times; FP8 not measured):

FP16 INT8
llm_bench prefill 64 tokens, 5 repeats 10.03-10.06 ms 10.87-10.97 ms
llm_bench prefill 1000 tokens 40.08 ms, 24951 tok/s 40.19 ms, 24884 tok/s
llm_bench decode, past KV 64 7.04 ms, 142.1 tok/s 6.94 ms, 144.2 tok/s
llm_bench decode, past KV 1000 7.27 ms, 137.5 tok/s 7.17 ms, 139.6 tok/s
short prompt (40 tok): prefill per run (TTFT) / decode median / p95 19.73 ms / 7.588 ms / 7.915 ms 20.32 ms / 7.507 ms / 7.798 ms
long prompt (896 tok): prefill per run (TTFT) / decode median / p95 38.11 ms / 7.757 ms / 8.006 ms 37.68 ms / 7.673 ms / 7.900 ms

The 64-token prefill gap follows the engine binary, not the sidecar: the FP16-built engine with the INT8 sidecar measures 10.03-10.06 ms and the INT8-built engine with the FP16 sidecar 10.95-10.97 ms (3 repeats each); it is TensorRT tactic selection between two builds of identical ONNX.

Load time, process start to "Runtime initialized", 5 runs (run 1 after other work on the device, runs 2-5 warm): FP16 1.49 s then 1.31-1.38 s; INT8 1.29 s then 1.28-1.29 s.

Reproduce:

tensorrt-edgellm-export Qwen/Qwen2.5-0.5B-Instruct onnx/qwen-fp16
tensorrt-edgellm-export Qwen/Qwen2.5-0.5B-Instruct onnx/qwen-int8emb --int8-embedding
tensorrt-edgellm-export Qwen/Qwen2.5-0.5B-Instruct onnx/qwen-fp8emb --fp8-embedding
sha256sum onnx/qwen-*/llm/model.onnx onnx/qwen-*/llm/model.onnx.data
for v in fp16 int8emb fp8emb; do
  ./build/examples/llm/llm_build --onnxDir onnx/qwen-$v/llm --engineDir engines/qwen-$v/llm --maxBatchSize 1 --maxInputLen 1024 --maxKVCacheCapacity 2048
  ./build/examples/llm/llm_inference --engineDir engines/qwen-$v/llm --inputFile prompts24.json --outputFile out24-$v.json --dumpProfile --profileOutputFile prof24-$v.json
  ./build/examples/llm/llm_bench --engineDir engines/qwen-$v/llm --mode prefill --inputLen 1000 --iterations 20 --warmup 3
  ./build/examples/llm/llm_bench --engineDir engines/qwen-$v/llm --mode decode --pastKVLen 1000 --iterations 20 --warmup 3
done
./build/unittests/unitTestKernelsMisc --gtest_filter='*Embedding*:*Int8*:*Ple*:*Fp16Lookup*:*SidecarLoader*:*GatherRejects*'
# MMLU: prepare the full set, draw a seeded subject-stratified 500 (proportional allocation, seed 0), append the
# instruction "Answer with the option's letter from the given choices directly." to each user message, set
# max_generate_length 64 and temperature 0, run both arms on engines built with --maxInputLen 8192 --maxKVCacheCapacity 10240, score
python3 examples/accuracy/scripts/prepare_dataset.py --dataset MMLU --output_dir mmlu_full
./build/examples/llm/llm_inference --engineDir engines/qwen-<v>-acc/llm --inputFile mmlu500_letter64.json --outputFile mmlu500-<v>.json
python3 examples/accuracy/scripts/calculate_correctness.py --predictions_file mmlu500-<v>.json --answers_file mmlu500_letter64.json

Validation on a 16 GB Jetson Orin NX

The Orin NX run (Jetson Orin NX 16 GB, JetPack 7.2, CUDA 13.2.86, TensorRT 10.16.2.10, 40 W power mode) was done with the follow-up branch's build at 33b7272, which stacks the Gemma 4 PLE sidecar on this PR, and with Gemma 4 E4B, whose INT8 set is the token table from this PR plus the PLE table from the follow-up. The two tables were not swapped independently (no FP16-PLE-plus-INT8-token set was run), so the memory and fit numbers belong to the follow-up PR and are reported there (mihai-chiorean#1): both sets fit, with 3.9 GB available at the minimum for INT8 and 1.2 GB for FP16, with about 2 GB of other inference load present. What this PR can take from the run:

  • The INT8 token-table loader and embeddingLookup INT8 path from this PR ran on an Orin NX (Loaded INT8 embedding: [262144, 2560], scales: [262144]), on an engine built on a Jetson AGX Orin, through 24 greedy prompts, a 20-request short-prompt profile, 3 load-time runs and 40 requests of a soak that the device's 92 C thermal guard ended; no errors, and every generated text identical to the AGX Orin's for the same inputs.
  • Decode speed is the same with the INT8 token table as with FP16 (60.0 vs 59.9–60.0 ms/token, 16.7 tok/s, step median 61.0 / p95 65.3–65.8 ms on the same engine).
  • Output agreement FP16 vs INT8 (token + PLE both quantized) on the 12 prompts both sets completed there: 10 of 12 identical, same as on the AGX Orin.

The unit-test filter was not run on the Orin NX (the device was only available for a short window and the GPU unit-test binaries were not part of the kit). The unit-test line for this PR remains the AGX Orin one above.

Orin NX 16 GB, second run: engines built on the device

The follow-up PLE branch (33b7272, which stacks on this PR) was run again on a Jetson Orin NX 16 GB (JetPack 7.2, CUDA 13.2.86, TensorRT 10.16.2.10, 40 W), this time with llm_build and visual_build run on the Orin NX itself and no other inference load on the device. The INT8 set there is this PR's token table plus the follow-up's PLE table; the two were not swapped independently, so the memory table is in the follow-up PR. What applies to this PR:

  • The INT8 token-table path ran on the device (Loaded INT8 embedding: [262144, 2560], scales: [262144]) through 24 greedy prompts, short- and long-prompt profiles, a 100-request soak and the paired accuracy runs, with no errors.
  • Decode speed is the same for both sets on the same engine: 41.18 ms/token (INT8) vs 41.14 ms/token (FP16), 24.3 tok/s.
  • Paired accuracy with both tables quantized: MMLU-500 323 / 323 (64.60 %), 499/500 identical predictions; MMStar-300 116 / 116 (38.67 %), 300/300 identical predictions. On the AGX Orin with the same prompts: MMLU-500 323 / 323, 500/500 identical.

Method: MMLU and MMStar are the public benchmarks, prepared with examples/accuracy/scripts/prepare_dataset.py and scored with the letter parser from examples/accuracy/scripts/calculate_correctness.py. The subsets are the stratified, seed-0 samples described in the follow-up PR. On the Orin NX the requests were sent through the Python binding by a small driver that keeps the model loaded and pauses for cooling, not through llm_inference; the request files are the same.

This PR's unit tests were not run on the Orin NX; that line remains the AGX Orin one above.

Scope and remaining validation

  • FP8 speed and memory were not measured; FP8 appears only in the sidecar table above.
  • Top-1 next-token logit agreement is not measured; llm_inference does not expose logits.
  • The Qwen3-Omni Talker guard has no unit test: constructing Qwen3OmniTTSRuntime needs engines.
  • The INT8 lookup kernel was not timed in isolation; the long-prompt TTFT numbers above bound its cost.
  • The l0_pipeline_a30.yml and l0_onnx_export_1.yml entries were not run in NVIDIA's CI; the commands above are their manual equivalent.
  • The accuracy harness's parser extracts a letter from 94 % of the 64-token answers; the MMLU accuracies of that run are lower bounds (the system-turn re-run parses 499–500 of 500) and the paired agreement on all items is the primary result.
  • An earlier version of this description said --fp8-embedding is not usable on Jetson Orin. That was wrong: it ran end to end on the AGX Orin, as reported under Validation.

🚀 Pull Request Checklist

✅ Pre-commit Checks

  • I have installed pre-commit by running pip install pre-commit.
  • I have installed the hooks with pre-commit install.
  • I have run the hooks manually with pre-commit run --all-files and fixed any reported issues. (Every file changed by this PR passes all hooks. On current main, yapf and clang-format reformat 13 files that this PR does not touch, and the same 13 are the only files reformatted on this branch.)

🧪 Tests

  • Tests have been added or updated as needed.
  • All tests are passing. (Host Python tests and the device unit tests above; the three new CI test-list entries have not run in NVIDIA's CI.)

📄 Documentation

  • Updated any necessary documentation

⚙️ Compatibility

  • The change is backward compatible. Existing FP16 and FP8 sidecars and all existing calls are unchanged (positional parameter lists of write_runtime_artifacts, export_onnx, _export_llm and _export_diffusion_gemma are identical to main; int8_embedding is keyword-only). Behaviour that does change, all verified against main: an FP16 table with a stray embedding_scale tensor now fails at load where it was ignored before; kernel::embeddingLookup rejects scales passed with an FP16 table where it ignored them; a table dtype other than FP16, FP8 or INT8 fails at load instead of in the kernel at the first request; the Qwen3-Omni Talker rejects a quantized Thinker sidecar at construction where it previously failed at the first lookup (embeddingLookup was called without scales); the DFlash/DSpark fold error for a quantized sidecar now names the flag that produced it.

Additional Information

Related issue: #188. This is the first of two PRs; the second adds the INT8 Gemma 4 per-layer-embedding sidecar (ple_embedding.safetensors, one scale per row and layer) on top of this one. With this PR alone, --int8-embedding on a Gemma 4 model quantizes the token embedding and leaves the PLE table FP16.

The loader dtype validation is included here rather than filed separately because the INT8 branch has to enumerate the accepted dtypes anyway, and the new C++ tests for the INT8 sidecar exercise the same load path. The FP8 branch's checks are unchanged.

Alternatives considered: extending --fp8-embedding to the per-layer table would be the other way to quantize it; per-row, per-layer INT8 scales match that table's structure and reconstructed more closely on the token table measured here, and FP8 on the per-layer table was not measured. Packed INT4 sidecars would save more but need an unpacking kernel and an accuracy study.

@copy-pr-bot

copy-pr-bot Bot commented Oct 9, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

Add `--int8-embedding` to tensorrt-edgellm-export. It writes
embedding.safetensors as symmetric INT8 with one FP32 scale per row,
mutually exclusive with `--fp8-embedding`. The runtime dequantizes only
the gathered rows in the embedding lookup kernel, so the table never
expands to FP16 in device memory.

loadEmbeddingTable now validates the table dtype at load: FP16, FP8 and
INT8 are accepted, anything else is rejected with the dtype and path,
and an embedding_scale tensor beside an FP16 table is an error. The
Qwen3-Omni talker rejects a quantized thinker embedding sidecar because
it reads that table as dense FP16.

Signed-off-by: Mihai Chiorean <[email protected]>
@mihai-chiorean
mihai-chiorean force-pushed the feat/int8-embedding-sidecar branch from 8a04d06 to cadb959 Compare October 9, 2026 23:41
@mihai-chiorean
mihai-chiorean marked this pull request as ready for review October 10, 2026 04:14
@mihai-chiorean
mihai-chiorean requested a review from a team October 10, 2026 04:14
@nvluxiaoz

Copy link
Copy Markdown
Collaborator

Thanks! Q: Will this enable this model on Jetson Orin Nano, or this is a general improvement strategy? We will look into it in a next version.

@mihai-chiorean

Copy link
Copy Markdown
Author

Thanks! Q: Will this enable this model on Jetson Orin Nano, or this is a general improvement strategy? We will look into it in a next version.

The goal is to fit Gemma 4 on the smaller Jetsons - E4B on a 16 GB Orin NX with room left for other workloads and E2B on an 8 GB Orin Nano.

This PR on its own is the general part. It works for any model's token embedding table (I also tested Qwen2.5-0.5B). Most of the Gemma 4 saving comes from the follow-up PR for the PLE table (mihai-chiorean#1, based on this branch, I need to open a PR for that). With both, the tables go from 6.50 GiB to 3.29 GiB for E4B and from 5.13 GiB to 2.60 GiB for E2B. I need to re-measure these on a nano, but my nano is on jp6 right now and I didn't get a chance to upgrade, I have some workloads on it.

@mihai-chiorean

Copy link
Copy Markdown
Author

Thanks! Q: Will this enable this model on Jetson Orin Nano, or this is a general improvement strategy? We will look into it in a next version.

Okay, I've now tested on my nano which is now on JetPack 7.2.1 / TensorRT 10.16.

So yes, this is what lets Gemma 4 run on the Orin Nano, and the INT8 tables are still needed even with 4-bit weights. INT4 only applies to the transformer weights; the token and PLE tables are separate and stay large. For E2B the tables are 2.60 GiB in INT8 (5.13 GiB in FP16) next to a 1.31 GB INT4 engine.

Here's what I measured on the Nano (E2B, 4096 input / 4608 KV engines, greedy):

E2B configuration full MMLU (14,042) min MemAvailable during the run
Original, FP16 weights and FP16 tables (on an AGX Orin, for reference) 55.48 % n/a
AWQ INT4 weights + INT8 tables on the GPU (this PR + the PLE follow-up) 53.48 % 171 MiB
Group-32 QAT INT4 weights + INT8 tables mapped in host memory 55.36 % 3,949 MiB

Now this is not with JUST this PR, but this change is part of the work. Here are some notes. I can get into the changes and open PRs if that's desirable but I hear at least for the PLE side you guys are doing it for 0.12.0 anyway

  • With the tables on the GPU, E2B runs but leaves 171 MiB free, and an 8192 / 10240 engine fails at init. I did not try FP16 tables on the Nano; they are 2.5 GiB larger than the INT8 ones.
  • Keeping the same INT8 tables mapped in host memory and gathering rows on the CPU (fork PR TensorRT Edge-LLM 0.4.0 release #3) gives back about 2.5 GB, keeps outputs bit-identical (MMLU-500: 500/500 identical predictions), and costs no measurable decode time on warm rows.
  • E4B also runs on the Nano with the same stack: full MMLU 65.41 % against 64.59% for the original (the same parse-rate effect applies, so read it as "close to the original"). At 8192 input / 10240 KV, thinking off: prefill 240 ms, decode 41.0 ms/token, min MemAvailable 1,183 MiB (30 MMLU-Pro prompts). E2B at the same size: 109 ms, 23.3 ms/token, 3,241 MiB.
    - INT4 tables (fork PR which config.json is required for qwen2.5-vl #5) cut the tables further (E2B 2.79 -> 1.55 GB) but are lossy; with host-mapped tables they only save disk, so I would keep INT8 as the default.

The MMLU scores on the Nano use your examples/accuracy harness unchanged (0-shot, 16 tokens). The original's score is from an AGX Orin with the same harness.

Fork PRs, all on top of this PR's branch:

Happy to split any of these into upstream PRs in whatever order suits your next release.

@nvluxiaoz

Copy link
Copy Markdown
Collaborator

Thanks! Since we are not GitHub first now, I will cherry-pick the core ideas into the current Edge-LLM main to be released in a next major release and quote on this. Sorry for this workflow inconvenience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants