nico-martin HF Staff commited on
Commit
4c69bc9
Β·
verified Β·
1 Parent(s): 75c1324

Quantize and tie q4f16 input embedding

Browse files

Quantizes the q4f16 input embedding with GatherBlockQuantized and lets its differently shaped initializer share the LM-head packed external byte range. This reduces external data from 2.058 GB to 1.534 GB (decimal) without introducing duplicate tied-weight storage.

Validation:
- shared-range graph is bit-exact to the equivalent duplicate-storage graph for prefill logits, cached logits, and all cache tensors
- ONNX Runtime CPU session creation and Transformers.js WebGPU loading/generation pass
- embedding quantization matched 11/12 varied 32-token greedy generations versus the FP16-embedding graph; the README documents the quantized embedding
- direct WebGPU benchmark improved from 102.16 to 106.05 tokens/s in the local test environment

README.md CHANGED
@@ -56,14 +56,14 @@ Find more details in the original model card: https://huggingface.co/LiquidAI/LF
56
  | Precision | Size | Platform | Use Case |
57
  |-----------|-------|-----------------|----------|
58
  | Q4 | ~1.9 GB | WebGPU, Server | Recommended for most uses (quantized embedding) |
59
- | Q4F16 | ~2.1 GB | WebGPU | Optimized q4 weights with FP16 runtime and caches |
60
  | FP16 | ~2.1 GB | WebGPU, Server | Higher quality |
61
  | Q8 | ~2.1 GB | Server only | Balance of quality and size |
62
 
63
  - **WebGPU**: Use `Q4`, `Q4F16`, or `FP16` (`Q8` is not supported on WebGPU).
64
  - **Server (CPU/GPU)**: All variants supported.
65
 
66
- Q4 uses a quantized input embedding. Q4F16 keeps the input embedding in FP16 while quantizing the LM head and decoder linear weights to q4.
67
 
68
  ## Model Files
69
 
@@ -72,7 +72,7 @@ onnx/
72
  β”œβ”€β”€ model.onnx # FP32
73
  β”œβ”€β”€ model_fp16.onnx # FP16
74
  β”œβ”€β”€ model_q4.onnx # Q4, quantized embedding (WebGPU)
75
- β”œβ”€β”€ model_q4f16.onnx # Q4 weights, FP16 runtime and caches (WebGPU)
76
  └── model_q8.onnx # Q8
77
  ```
78
 
 
56
  | Precision | Size | Platform | Use Case |
57
  |-----------|-------|-----------------|----------|
58
  | Q4 | ~1.9 GB | WebGPU, Server | Recommended for most uses (quantized embedding) |
59
+ | Q4F16 | ~1.5 GB | WebGPU | Quantized embedding and q4 weights with FP16 runtime and caches |
60
  | FP16 | ~2.1 GB | WebGPU, Server | Higher quality |
61
  | Q8 | ~2.1 GB | Server only | Balance of quality and size |
62
 
63
  - **WebGPU**: Use `Q4`, `Q4F16`, or `FP16` (`Q8` is not supported on WebGPU).
64
  - **Server (CPU/GPU)**: All variants supported.
65
 
66
+ Q4 and Q4F16 use a quantized input embedding. Q4F16 uses FP16 runtime tensors and caches while quantizing the LM head and decoder linear weights to q4.
67
 
68
  ## Model Files
69
 
 
72
  β”œβ”€β”€ model.onnx # FP32
73
  β”œβ”€β”€ model_fp16.onnx # FP16
74
  β”œβ”€β”€ model_q4.onnx # Q4, quantized embedding (WebGPU)
75
+ β”œβ”€β”€ model_q4f16.onnx # Q4 embedding/weights, FP16 runtime and caches (WebGPU)
76
  └── model_q8.onnx # Q8
77
  ```
78
 
onnx/model_q4f16.onnx CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:34d1e9d9a5c72659e338c8de3c11302b27d78d009fe891e6c060bec8246767a1
3
- size 222663
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ab9e9e77e202d7bd2b8a994ac8383f535a4277b4124d5621c79ccc5bb1508bde
3
+ size 222283
onnx/model_q4f16.onnx_data CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:13bd61df0b2449c3bce67c12f1eed81dd27341add0eb9d4caa60e7804b46861b
3
- size 1072164864
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:34537bf4a6d70ddf1627bd3709d31c8b7db8d5bcaee2098c45661be59476fbec
3
+ size 1063972864
onnx/model_q4f16.onnx_data_1 CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:5ad378ec208f81195cd482efc0d5f7b91c1342f6c73bfea05dbddd7c9302de31
3
- size 986054656
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1b645b44902caccd406098c4dbef5724927c5fb2a2be4a087ae328989b111a7f
3
+ size 469958656