Upload folder using huggingface_hub
Browse files- .gitattributes +1 -0
- README.md +98 -3
- added_tokens.json +3 -0
- calib.json +117 -0
- config.json +58 -0
- generation_config.json +7 -0
- model.safetensors +3 -0
- special_tokens_map.json +33 -0
- tokenizer.json +3 -0
- tokenizer_config.json +0 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
|
@@ -1,3 +1,98 @@
|
|
| 1 |
-
---
|
| 2 |
-
license:
|
| 3 |
-
--
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: gemma
|
| 3 |
+
base_model: google/gemma-3-270m
|
| 4 |
+
library_name: transformers
|
| 5 |
+
tags:
|
| 6 |
+
- fp8
|
| 7 |
+
- quantized
|
| 8 |
+
- embedding
|
| 9 |
+
- nvidia-modelopt
|
| 10 |
+
- nanojet
|
| 11 |
+
pipeline_tag: feature-extraction
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
# gemma-3-270m-modelopt-fp8
|
| 15 |
+
|
| 16 |
+
FP8 (E4M3) quantized version of [google/gemma-3-270m](https://huggingface.co/google/gemma-3-270m), quantized using [NVIDIA ModelOpt](https://github.com/NVIDIA/TensorRT-Model-Optimizer) static FP8 quantization.
|
| 17 |
+
|
| 18 |
+
## Model Details
|
| 19 |
+
|
| 20 |
+
| Property | Value |
|
| 21 |
+
|----------|-------|
|
| 22 |
+
| Base Model | [google/gemma-3-270m](https://huggingface.co/google/gemma-3-270m) |
|
| 23 |
+
| Architecture | Gemma3 (18 layers, 4 heads, 1 KV head) |
|
| 24 |
+
| Hidden Size | 640 |
|
| 25 |
+
| Intermediate Size | 2048 |
|
| 26 |
+
| Head Dim | 256 |
|
| 27 |
+
| Vocab Size | 262,144 |
|
| 28 |
+
| Max Position Embeddings | 32,768 |
|
| 29 |
+
| Attention | Sliding window (512) + full attention (every 6th layer) |
|
| 30 |
+
| Quantization | FP8 E4M3 (weights + input activations) |
|
| 31 |
+
| Quantization Method | NVIDIA ModelOpt (mtq.FP8_DEFAULT_CFG) |
|
| 32 |
+
| Model Size | 416 MB (safetensors) |
|
| 33 |
+
|
| 34 |
+
## Quantization Details
|
| 35 |
+
|
| 36 |
+
### Method
|
| 37 |
+
|
| 38 |
+
- **Tool**: NVIDIA ModelOpt static FP8 quantization
|
| 39 |
+
- **Format**: FP8 E4M3 (torch.float8_e4m3fn)
|
| 40 |
+
- **Scope**: All linear layers (QKV projections, output projections, MLP layers) are quantized to FP8. Embeddings and RMSNorms remain in BF16.
|
| 41 |
+
- **Scales**: Per-tensor weight scales and input activation scales are stored alongside the quantized weights.
|
| 42 |
+
|
| 43 |
+
### Calibration
|
| 44 |
+
|
| 45 |
+
- **Dataset**: [CNN/DailyMail](https://huggingface.co/datasets/cnn_dailymail) (real text data)
|
| 46 |
+
- **Samples**: 64
|
| 47 |
+
- **Sequence Length**: 256
|
| 48 |
+
- **Batch Size**: 4
|
| 49 |
+
- **Activation Scales**: Collected at 4 points per layer (post-layernorm, attention output, MLP input, GELU output), saved in calib.json
|
| 50 |
+
|
| 51 |
+
## Precision Evaluation
|
| 52 |
+
|
| 53 |
+
Cosine similarity between this FP8 model and the original BF16 model, measured on CNN/DailyMail text inputs (threshold: 0.99):
|
| 54 |
+
|
| 55 |
+
| Batch | Seq Len | Cosine Similarity | Result |
|
| 56 |
+
|-------|---------|-------------------|--------|
|
| 57 |
+
| 1 | 128 | 0.9919 | PASS |
|
| 58 |
+
| 2 | 512 | 0.9937 | PASS |
|
| 59 |
+
| 4 | 1024 | 0.9935 | PASS |
|
| 60 |
+
| 8 | 2048 | 0.9937 | PASS |
|
| 61 |
+
| 8 | 100 | 0.9920 | PASS |
|
| 62 |
+
| 8 | 500 | 0.9933 | PASS |
|
| 63 |
+
| 8 | 4000 | 0.9937 | PASS |
|
| 64 |
+
|
| 65 |
+
All configurations achieve >0.99 cosine similarity with the BF16 baseline.
|
| 66 |
+
|
| 67 |
+
## File Structure
|
| 68 |
+
|
| 69 |
+
```
|
| 70 |
+
.
|
| 71 |
+
├── config.json # Model config with quantization_config
|
| 72 |
+
├── model.safetensors # FP8 quantized weights + scales
|
| 73 |
+
├── calib.json # Activation scales per layer
|
| 74 |
+
├── tokenizer.json # Tokenizer
|
| 75 |
+
├── tokenizer_config.json # Tokenizer config
|
| 76 |
+
├── special_tokens_map.json # Special tokens
|
| 77 |
+
├── added_tokens.json # Added tokens
|
| 78 |
+
└── generation_config.json # Generation config
|
| 79 |
+
```
|
| 80 |
+
|
| 81 |
+
## Usage
|
| 82 |
+
|
| 83 |
+
This model is designed to be used with the [NanoJet](https://github.com/ai-microsoft/NanoJet_Kernels) inference engine:
|
| 84 |
+
|
| 85 |
+
```python
|
| 86 |
+
from test.infrastructure.model_utils import load_nanojet_model
|
| 87 |
+
|
| 88 |
+
model = load_nanojet_model(
|
| 89 |
+
"1kxia/gemma-3-270m-modelopt-fp8",
|
| 90 |
+
batch=8,
|
| 91 |
+
seq_len=4096,
|
| 92 |
+
quantization="fp8"
|
| 93 |
+
)
|
| 94 |
+
```
|
| 95 |
+
|
| 96 |
+
## Intended Use
|
| 97 |
+
|
| 98 |
+
This model is intended for efficient FP8 inference on NVIDIA GPUs with FP8 support (Hopper architecture and above).
|
added_tokens.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"<image_soft_token>": 262144
|
| 3 |
+
}
|
calib.json
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model_type": "gemma3",
|
| 3 |
+
"hidden_size": 640,
|
| 4 |
+
"num_hidden_layers": 18,
|
| 5 |
+
"calibration_samples": 64,
|
| 6 |
+
"calibration_seq_len": 256,
|
| 7 |
+
"activation_scales": [
|
| 8 |
+
[
|
| 9 |
+
0.7857142857142857,
|
| 10 |
+
0.8169642857142857,
|
| 11 |
+
0.36830357142857145,
|
| 12 |
+
0.029854910714285716
|
| 13 |
+
],
|
| 14 |
+
[
|
| 15 |
+
0.5758928571428571,
|
| 16 |
+
0.6741071428571429,
|
| 17 |
+
2.2857142857142856,
|
| 18 |
+
0.018415178571428572
|
| 19 |
+
],
|
| 20 |
+
[
|
| 21 |
+
0.125,
|
| 22 |
+
0.140625,
|
| 23 |
+
1.2232142857142858,
|
| 24 |
+
0.015206473214285714
|
| 25 |
+
],
|
| 26 |
+
[
|
| 27 |
+
0.10435267857142858,
|
| 28 |
+
0.05161830357142857,
|
| 29 |
+
2.982142857142857,
|
| 30 |
+
0.024832589285714284
|
| 31 |
+
],
|
| 32 |
+
[
|
| 33 |
+
0.11439732142857142,
|
| 34 |
+
0.013741629464285714,
|
| 35 |
+
2.5714285714285716,
|
| 36 |
+
0.025669642857142856
|
| 37 |
+
],
|
| 38 |
+
[
|
| 39 |
+
0.12555803571428573,
|
| 40 |
+
0.020926339285714284,
|
| 41 |
+
7.285714285714286,
|
| 42 |
+
0.01416015625
|
| 43 |
+
],
|
| 44 |
+
[
|
| 45 |
+
0.10379464285714286,
|
| 46 |
+
0.013532366071428572,
|
| 47 |
+
3.6607142857142856,
|
| 48 |
+
0.018136160714285716
|
| 49 |
+
],
|
| 50 |
+
[
|
| 51 |
+
0.1328125,
|
| 52 |
+
0.07421875,
|
| 53 |
+
6.214285714285714,
|
| 54 |
+
0.020647321428571428
|
| 55 |
+
],
|
| 56 |
+
[
|
| 57 |
+
0.1875,
|
| 58 |
+
0.03766741071428571,
|
| 59 |
+
4.785714285714286,
|
| 60 |
+
0.016671316964285716
|
| 61 |
+
],
|
| 62 |
+
[
|
| 63 |
+
0.18638392857142858,
|
| 64 |
+
0.05022321428571429,
|
| 65 |
+
6.928571428571429,
|
| 66 |
+
0.020228794642857144
|
| 67 |
+
],
|
| 68 |
+
[
|
| 69 |
+
0.22209821428571427,
|
| 70 |
+
0.037388392857142856,
|
| 71 |
+
8.392857142857142,
|
| 72 |
+
0.015276227678571428
|
| 73 |
+
],
|
| 74 |
+
[
|
| 75 |
+
0.03208705357142857,
|
| 76 |
+
0.013602120535714286,
|
| 77 |
+
7.821428571428571,
|
| 78 |
+
0.016950334821428572
|
| 79 |
+
],
|
| 80 |
+
[
|
| 81 |
+
0.13169642857142858,
|
| 82 |
+
0.07254464285714286,
|
| 83 |
+
8.428571428571429,
|
| 84 |
+
0.022321428571428572
|
| 85 |
+
],
|
| 86 |
+
[
|
| 87 |
+
0.25558035714285715,
|
| 88 |
+
0.054966517857142856,
|
| 89 |
+
13.857142857142858,
|
| 90 |
+
0.024553571428571428
|
| 91 |
+
],
|
| 92 |
+
[
|
| 93 |
+
0.15736607142857142,
|
| 94 |
+
0.13113839285714285,
|
| 95 |
+
10.214285714285714,
|
| 96 |
+
0.019810267857142856
|
| 97 |
+
],
|
| 98 |
+
[
|
| 99 |
+
0.16964285714285715,
|
| 100 |
+
0.12276785714285714,
|
| 101 |
+
8.178571428571429,
|
| 102 |
+
0.022042410714285716
|
| 103 |
+
],
|
| 104 |
+
[
|
| 105 |
+
0.19977678571428573,
|
| 106 |
+
0.13727678571428573,
|
| 107 |
+
11.785714285714286,
|
| 108 |
+
0.01318359375
|
| 109 |
+
],
|
| 110 |
+
[
|
| 111 |
+
0.09542410714285714,
|
| 112 |
+
0.030412946428571428,
|
| 113 |
+
4.678571428571429,
|
| 114 |
+
0.009207589285714286
|
| 115 |
+
]
|
| 116 |
+
]
|
| 117 |
+
}
|
config.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_sliding_window_pattern": 6,
|
| 3 |
+
"architectures": [
|
| 4 |
+
"Gemma3ForCausalLM"
|
| 5 |
+
],
|
| 6 |
+
"attention_bias": false,
|
| 7 |
+
"attention_dropout": 0.0,
|
| 8 |
+
"attn_logit_softcapping": null,
|
| 9 |
+
"bos_token_id": 2,
|
| 10 |
+
"eos_token_id": 1,
|
| 11 |
+
"final_logit_softcapping": null,
|
| 12 |
+
"head_dim": 256,
|
| 13 |
+
"hidden_activation": "gelu_pytorch_tanh",
|
| 14 |
+
"hidden_size": 640,
|
| 15 |
+
"initializer_range": 0.02,
|
| 16 |
+
"intermediate_size": 2048,
|
| 17 |
+
"layer_types": [
|
| 18 |
+
"sliding_attention",
|
| 19 |
+
"sliding_attention",
|
| 20 |
+
"sliding_attention",
|
| 21 |
+
"sliding_attention",
|
| 22 |
+
"sliding_attention",
|
| 23 |
+
"full_attention",
|
| 24 |
+
"sliding_attention",
|
| 25 |
+
"sliding_attention",
|
| 26 |
+
"sliding_attention",
|
| 27 |
+
"sliding_attention",
|
| 28 |
+
"sliding_attention",
|
| 29 |
+
"full_attention",
|
| 30 |
+
"sliding_attention",
|
| 31 |
+
"sliding_attention",
|
| 32 |
+
"sliding_attention",
|
| 33 |
+
"sliding_attention",
|
| 34 |
+
"sliding_attention",
|
| 35 |
+
"full_attention"
|
| 36 |
+
],
|
| 37 |
+
"max_position_embeddings": 32768,
|
| 38 |
+
"model_type": "gemma3_text",
|
| 39 |
+
"num_attention_heads": 4,
|
| 40 |
+
"num_hidden_layers": 18,
|
| 41 |
+
"num_key_value_heads": 1,
|
| 42 |
+
"pad_token_id": 0,
|
| 43 |
+
"query_pre_attn_scalar": 256,
|
| 44 |
+
"rms_norm_eps": 1e-06,
|
| 45 |
+
"rope_local_base_freq": 10000.0,
|
| 46 |
+
"rope_scaling": null,
|
| 47 |
+
"rope_theta": 1000000.0,
|
| 48 |
+
"sliding_window": 512,
|
| 49 |
+
"torch_dtype": "bfloat16",
|
| 50 |
+
"transformers_version": "4.55.0.dev0",
|
| 51 |
+
"use_bidirectional_attention": false,
|
| 52 |
+
"use_cache": true,
|
| 53 |
+
"vocab_size": 262144,
|
| 54 |
+
"quantization_config": {
|
| 55 |
+
"quant_algo": "FP8",
|
| 56 |
+
"kv_cache_quant_algo": null
|
| 57 |
+
}
|
| 58 |
+
}
|
generation_config.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cache_implementation": "hybrid",
|
| 3 |
+
"do_sample": true,
|
| 4 |
+
"top_k": 64,
|
| 5 |
+
"top_p": 0.95,
|
| 6 |
+
"transformers_version": "4.55.0.dev0"
|
| 7 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3b45d41e87257bf24b1f40fd37797a2764742152750e96e93f306dbefd024b95
|
| 3 |
+
size 435975888
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"boi_token": "<start_of_image>",
|
| 3 |
+
"bos_token": {
|
| 4 |
+
"content": "<bos>",
|
| 5 |
+
"lstrip": false,
|
| 6 |
+
"normalized": false,
|
| 7 |
+
"rstrip": false,
|
| 8 |
+
"single_word": false
|
| 9 |
+
},
|
| 10 |
+
"eoi_token": "<end_of_image>",
|
| 11 |
+
"eos_token": {
|
| 12 |
+
"content": "<eos>",
|
| 13 |
+
"lstrip": false,
|
| 14 |
+
"normalized": false,
|
| 15 |
+
"rstrip": false,
|
| 16 |
+
"single_word": false
|
| 17 |
+
},
|
| 18 |
+
"image_token": "<image_soft_token>",
|
| 19 |
+
"pad_token": {
|
| 20 |
+
"content": "<pad>",
|
| 21 |
+
"lstrip": false,
|
| 22 |
+
"normalized": false,
|
| 23 |
+
"rstrip": false,
|
| 24 |
+
"single_word": false
|
| 25 |
+
},
|
| 26 |
+
"unk_token": {
|
| 27 |
+
"content": "<unk>",
|
| 28 |
+
"lstrip": false,
|
| 29 |
+
"normalized": false,
|
| 30 |
+
"rstrip": false,
|
| 31 |
+
"single_word": false
|
| 32 |
+
}
|
| 33 |
+
}
|
tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7d4046bf0505a327dd5a0abbb427ecd4fc82f99c2ceaa170bc61ecde12809b0c
|
| 3 |
+
size 33384570
|
tokenizer_config.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|