HiramKHackenbacker commited on
Commit
d25ffc2
·
verified ·
1 Parent(s): c00efb9

v5: the verify entrypoint — full logits + activations for the assistant drafter

Browse files
Files changed (11) hide show
  1. .gitattributes +2 -0
  2. v5/README.md +38 -0
  3. v5/gpu-pipelined/gemma4_e4b_qat_decode_int4lin_tbl_pf64_ple4_pe4_hsc_vfy8_msdpa_g8_wkv_stable_c131072/export_report.json +128 -0
  4. v5/gpu-pipelined/gemma4_e4b_qat_decode_int4lin_tbl_pf64_ple4_pe4_hsc_vfy8_msdpa_g8_wkv_stable_c131072/gemma4_e4b_qat_decode_int4lin_tbl_pf64_ple4_pe4_hsc_vfy8_msdpa_g8_wkv_stable_c131072.aimodel/main.hash +1 -0
  5. v5/gpu-pipelined/gemma4_e4b_qat_decode_int4lin_tbl_pf64_ple4_pe4_hsc_vfy8_msdpa_g8_wkv_stable_c131072/gemma4_e4b_qat_decode_int4lin_tbl_pf64_ple4_pe4_hsc_vfy8_msdpa_g8_wkv_stable_c131072.aimodel/main.mlirb +3 -0
  6. v5/gpu-pipelined/gemma4_e4b_qat_decode_int4lin_tbl_pf64_ple4_pe4_hsc_vfy8_msdpa_g8_wkv_stable_c131072/gemma4_e4b_qat_decode_int4lin_tbl_pf64_ple4_pe4_hsc_vfy8_msdpa_g8_wkv_stable_c131072.aimodel/metadata.json +5 -0
  7. v5/gpu-pipelined/gemma4_e4b_qat_decode_int4lin_tbl_pf64_ple4_pe4_hsc_vfy8_msdpa_g8_wkv_stable_c131072/metadata.json +70 -0
  8. v5/gpu-pipelined/gemma4_e4b_qat_decode_int4lin_tbl_pf64_ple4_pe4_hsc_vfy8_msdpa_g8_wkv_stable_c131072/tokenizer/chat_template.jinja +386 -0
  9. v5/gpu-pipelined/gemma4_e4b_qat_decode_int4lin_tbl_pf64_ple4_pe4_hsc_vfy8_msdpa_g8_wkv_stable_c131072/tokenizer/generation_config.json +14 -0
  10. v5/gpu-pipelined/gemma4_e4b_qat_decode_int4lin_tbl_pf64_ple4_pe4_hsc_vfy8_msdpa_g8_wkv_stable_c131072/tokenizer/tokenizer.json +3 -0
  11. v5/gpu-pipelined/gemma4_e4b_qat_decode_int4lin_tbl_pf64_ple4_pe4_hsc_vfy8_msdpa_g8_wkv_stable_c131072/tokenizer/tokenizer_config.json +142 -0
.gitattributes CHANGED
@@ -65,3 +65,5 @@ v4/gpu-pipelined/gemma4_e4b_qat_decode_int4lin_tbl_pf64_ple4_pe4_hsc_msdpa_g8_wk
65
  v4/ios-frontend/gemma4_e4b_qat_gather_raw/embed_per_layer.i4 filter=lfs diff=lfs merge=lfs -text
66
  v4/ios-frontend/gemma4_e4b_qat_gather_raw/embed_per_layer.scale.f16 filter=lfs diff=lfs merge=lfs -text
67
  v4/ios-frontend/gemma4_e4b_qat_gather_raw/head.f16 filter=lfs diff=lfs merge=lfs -text
 
 
 
65
  v4/ios-frontend/gemma4_e4b_qat_gather_raw/embed_per_layer.i4 filter=lfs diff=lfs merge=lfs -text
66
  v4/ios-frontend/gemma4_e4b_qat_gather_raw/embed_per_layer.scale.f16 filter=lfs diff=lfs merge=lfs -text
67
  v4/ios-frontend/gemma4_e4b_qat_gather_raw/head.f16 filter=lfs diff=lfs merge=lfs -text
68
+ v5/gpu-pipelined/gemma4_e4b_qat_decode_int4lin_tbl_pf64_ple4_pe4_hsc_vfy8_msdpa_g8_wkv_stable_c131072/gemma4_e4b_qat_decode_int4lin_tbl_pf64_ple4_pe4_hsc_vfy8_msdpa_g8_wkv_stable_c131072.aimodel/main.mlirb filter=lfs diff=lfs merge=lfs -text
69
+ v5/gpu-pipelined/gemma4_e4b_qat_decode_int4lin_tbl_pf64_ple4_pe4_hsc_vfy8_msdpa_g8_wkv_stable_c131072/tokenizer/tokenizer.json filter=lfs diff=lfs merge=lfs -text
v5/README.md ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Gemma 4 E4B — v5: v4 plus the VERIFY entrypoint (full logits + activations)
2
+
3
+ The same head-sidecar construction `v4/` shipped (graph constant ~0, bit-exact
4
+ numerics — see the v4 card), plus the one thing the assistant drafter needs: a
5
+ `verify` entrypoint, S=8, FULL logits [1,8,262144] and the post-final-norm hidden
6
+ states as `activations` [1,8,2560].
7
+
8
+ **No `accepted_count` input, deliberately.** The E-series ring is R=1024 over
9
+ W=512, write-then-read: a verify call commits its rows (its own drafts must be
10
+ attendable), and a REJECTED draft's row is geometry-dead — its implied position
11
+ fails the window test until it is overwritten. Single-pass speculation, which is
12
+ why the E4B's speculative economics beat the 12B's two-pass protocol.
13
+
14
+ Measured the night it was built (python Metal runtime, CPU fp32 drafter — a
15
+ handicapped harness): assistant drafting accepted a mean 3.20/8 per round on
16
+ report prompts and was net-positive over vanilla decode (2.11 vs 1.81 tok/s)
17
+ even with the drafter on CPU. `verify takes input_ids/position_ids [1,8] plus the bundle's static inputs and returns FULL logits [1,K,V] and the post-final-norm hidden states as `activations` [1,K,H]. It COMMITS...` — the full contract is in
18
+ `metadata.json`.
19
+
20
+ ## Tables
21
+
22
+ Pair with **`v4/ios-frontend/gemma4_e4b_qat_gather_raw/`** — the v5 dump is
23
+ byte-identical (verified sha256 file-for-file before this upload) and is not
24
+ duplicated here.
25
+
26
+ ## Bundle — v5/gpu-pipelined/gemma4_e4b_qat_decode_int4lin_tbl_pf64_ple4_pe4_hsc_vfy8_msdpa_g8_wkv_stable_c131072 (2,648,430,757 B)
27
+
28
+ ```
29
+ export_report.json 2,328 B 9df137263fc9583bffa5a25855180e8e8afee028024de1939f7d7dc991074db5
30
+ gemma4_e4b_qat_decode_int4lin_tbl_pf64_ple4_pe4_hsc_vfy8_msdpa_g8_wkv_stable_c131072.aimodel/main.hash 32 B 50e6393296c7f901d291b996a19c1ea96ee2954064c5b5f769e3dd8ac27e6df9
31
+ gemma4_e4b_qat_decode_int4lin_tbl_pf64_ple4_pe4_hsc_vfy8_msdpa_g8_wkv_stable_c131072.aimodel/main.mlirb 2,616,233,483 B 83b920e1e526ec292451b2a39a7b4c93e45f2948a76fb0150eedcdd4a036b8be
32
+ gemma4_e4b_qat_decode_int4lin_tbl_pf64_ple4_pe4_hsc_vfy8_msdpa_g8_wkv_stable_c131072.aimodel/metadata.json 105 B 91051e4aeb11738398465fe47ae5f9e0b0491cf48e99ed6ab22837321d80384d
33
+ metadata.json 2,682 B 67e5a7e56be59d34e46fa3c38cf88beff5843e7887cf05ef5ebdffe9b59f10b6
34
+ tokenizer/chat_template.jinja 18,569 B 0a2c8073c878ab1da004bee933a998606537bbb62016310352c7285c3f01c5b5
35
+ tokenizer/generation_config.json 203 B b69207f9be617e982d13cc273cce6fd88c98dda99a4bdc5e2d52ffe0a0d9f0a9
36
+ tokenizer/tokenizer.json 32,169,626 B cc8d3a0ce36466ccc1278bf987df5f71db1719b9ca6b4118264f45cb627bfe0f
37
+ tokenizer/tokenizer_config.json 3,729 B 3ab5c7b94dc97d65ca7064496fa69b88ff875378e1cb7ee3e43070c3a8170999
38
+ ```
v5/gpu-pipelined/gemma4_e4b_qat_decode_int4lin_tbl_pf64_ple4_pe4_hsc_vfy8_msdpa_g8_wkv_stable_c131072/export_report.json ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "gemma4_e4b_qat_decode_int4lin_tbl_pf64_ple4_pe4_hsc_vfy8_msdpa_g8_wkv_stable_c131072",
3
+ "hf_id": "google/gemma-4-E4B-it-qat-q4_0-unquantized",
4
+ "capacity": 131072,
5
+ "pf": 64,
6
+ "ring_slots": 1024,
7
+ "split_g": 8,
8
+ "kv_quant": "none",
9
+ "kv": {
10
+ "n_sliding_slots": 20,
11
+ "n_full_slots": 4,
12
+ "ring_slots": 1024,
13
+ "global_per_token": 16384,
14
+ "global_per_token_fp16": 16384,
15
+ "ring_fixed": 41943040,
16
+ "shipped_unified_per_token": 98304,
17
+ "ring_lever": 6.0
18
+ },
19
+ "states": {
20
+ "main": [
21
+ {
22
+ "name": "keyCache",
23
+ "shape": [
24
+ 4,
25
+ 1,
26
+ 2,
27
+ 131072,
28
+ 512
29
+ ],
30
+ "dtype": "f16",
31
+ "dynamic": false
32
+ },
33
+ {
34
+ "name": "valueCache",
35
+ "shape": [
36
+ 4,
37
+ 1,
38
+ 2,
39
+ 131072,
40
+ 512
41
+ ],
42
+ "dtype": "f16",
43
+ "dynamic": false
44
+ },
45
+ {
46
+ "name": "localKeyCache",
47
+ "shape": [
48
+ 20,
49
+ 1,
50
+ 2,
51
+ 1024,
52
+ 256
53
+ ],
54
+ "dtype": "f16",
55
+ "dynamic": false
56
+ },
57
+ {
58
+ "name": "localValueCache",
59
+ "shape": [
60
+ 20,
61
+ 1,
62
+ 2,
63
+ 1024,
64
+ 256
65
+ ],
66
+ "dtype": "f16",
67
+ "dynamic": false
68
+ }
69
+ ],
70
+ "prefill": [
71
+ {
72
+ "name": "keyCache",
73
+ "shape": [
74
+ 4,
75
+ 1,
76
+ 2,
77
+ 131072,
78
+ 512
79
+ ],
80
+ "dtype": "f16",
81
+ "dynamic": false
82
+ },
83
+ {
84
+ "name": "valueCache",
85
+ "shape": [
86
+ 4,
87
+ 1,
88
+ 2,
89
+ 131072,
90
+ 512
91
+ ],
92
+ "dtype": "f16",
93
+ "dynamic": false
94
+ },
95
+ {
96
+ "name": "localKeyCache",
97
+ "shape": [
98
+ 20,
99
+ 1,
100
+ 2,
101
+ 1024,
102
+ 256
103
+ ],
104
+ "dtype": "f16",
105
+ "dynamic": false
106
+ },
107
+ {
108
+ "name": "localValueCache",
109
+ "shape": [
110
+ 20,
111
+ 1,
112
+ 2,
113
+ 1024,
114
+ 256
115
+ ],
116
+ "dtype": "f16",
117
+ "dynamic": false
118
+ }
119
+ ]
120
+ },
121
+ "mlirb_bytes": 2616233483,
122
+ "bundle_bytes": 2648428429,
123
+ "signature_clean": true,
124
+ "kernels": [
125
+ "gemma4_dense_full_sdpa_bounded_occ8",
126
+ "gemma4_dense_full_sdpa_prefill"
127
+ ]
128
+ }
v5/gpu-pipelined/gemma4_e4b_qat_decode_int4lin_tbl_pf64_ple4_pe4_hsc_vfy8_msdpa_g8_wkv_stable_c131072/gemma4_e4b_qat_decode_int4lin_tbl_pf64_ple4_pe4_hsc_vfy8_msdpa_g8_wkv_stable_c131072.aimodel/main.hash ADDED
@@ -0,0 +1 @@
 
 
1
+ �� ��&�)$Q���{L��_)H�o���Ԡ6��
v5/gpu-pipelined/gemma4_e4b_qat_decode_int4lin_tbl_pf64_ple4_pe4_hsc_vfy8_msdpa_g8_wkv_stable_c131072/gemma4_e4b_qat_decode_int4lin_tbl_pf64_ple4_pe4_hsc_vfy8_msdpa_g8_wkv_stable_c131072.aimodel/main.mlirb ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:83b920e1e526ec292451b2a39a7b4c93e45f2948a76fb0150eedcdd4a036b8be
3
+ size 2616233483
v5/gpu-pipelined/gemma4_e4b_qat_decode_int4lin_tbl_pf64_ple4_pe4_hsc_vfy8_msdpa_g8_wkv_stable_c131072/gemma4_e4b_qat_decode_int4lin_tbl_pf64_ple4_pe4_hsc_vfy8_msdpa_g8_wkv_stable_c131072.aimodel/metadata.json ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ {
2
+ "producer" : "coreai-core 1.0.0b2",
3
+ "creationDate" : "20260828T234506Z",
4
+ "assetVersion" : "2.0"
5
+ }
v5/gpu-pipelined/gemma4_e4b_qat_decode_int4lin_tbl_pf64_ple4_pe4_hsc_vfy8_msdpa_g8_wkv_stable_c131072/metadata.json ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "metadata_version": "0.2",
3
+ "kind": "llm",
4
+ "name": "gemma4_e4b_qat_decode_int4lin_tbl_pf64_ple4_pe4_hsc_vfy8_msdpa_g8_wkv_stable_c131072",
5
+ "assets": {
6
+ "main": "gemma4_e4b_qat_decode_int4lin_tbl_pf64_ple4_pe4_hsc_vfy8_msdpa_g8_wkv_stable_c131072.aimodel"
7
+ },
8
+ "language": {
9
+ "tokenizer": "google/gemma-4-E4B-it-qat-q4_0-unquantized",
10
+ "vocab_size": 262144,
11
+ "max_context_length": 131072,
12
+ "embedded_tokenizer": true,
13
+ "function_map": {
14
+ "main": [
15
+ "main",
16
+ "prefill"
17
+ ],
18
+ "verify": [
19
+ "verify"
20
+ ]
21
+ },
22
+ "verify_query_tokens": 8,
23
+ "verify_contract": "verify takes input_ids/position_ids [1,8] plus the bundle's static inputs and returns FULL logits [1,K,V] and the post-final-norm hidden states as `activations` [1,K,H]. It COMMITS its rows (write-then-read design); rejected drafts are safe by ring geometry, not by a blend: R = 1024 over W = 512 means a stale row's implied position fails the window test until it is overwritten. The host adjudicates and simply continues from the accepted position \u2014 global rows self-heal by absolute-position masking.",
24
+ "capacity_tiers": [
25
+ {
26
+ "function": "main",
27
+ "prefill_function": "prefill",
28
+ "context_window_tokens": 131072,
29
+ "global_kv_bytes": 2147483648,
30
+ "ring_kv_bytes": 41943040,
31
+ "total_kv_bytes": 2189426688
32
+ }
33
+ ],
34
+ "capacity_tier_notes": {
35
+ "global_kv_bytes_per_token": 16384,
36
+ "global_kv_bytes_per_token_fp16_equivalent": 16384,
37
+ "global_kv_dtype": "fp16",
38
+ "ring_is_capacity_invariant": true,
39
+ "ring_slots": 1024,
40
+ "sliding_window": 512,
41
+ "shipped_unified_kv_bytes_per_token": 98304,
42
+ "embed_packed": true,
43
+ "ple_bits": 4,
44
+ "ple_granularity": "per_block",
45
+ "ple_block": 32,
46
+ "ple_table_file": "embed_per_layer.i4",
47
+ "ple_scale_file": "embed_per_layer.scale.f16",
48
+ "ple_bytes": 1585446912,
49
+ "head_sidecar": true,
50
+ "head_table_file": "head.f16",
51
+ "head_table_shape": [
52
+ 262144,
53
+ 2560
54
+ ],
55
+ "head_table_dtype": "float16",
56
+ "shape_stable_decode": true,
57
+ "shape_stable_decode_gate": "gate_e_windowed.py",
58
+ "selection": "pick the highest rung whose total_kv_bytes the machine admits at load; every rung is individually shape-stable, and the length-bounded Metal kernel makes a rung an allocation cost rather than a per-step one"
59
+ }
60
+ },
61
+ "source": {
62
+ "model_definition": "torch",
63
+ "hf_model_id": "google/gemma-4-E4B-it-qat-q4_0-unquantized"
64
+ },
65
+ "compression": null,
66
+ "compilation": {
67
+ "date": "2026-08-28T23:45:08.917378+00:00",
68
+ "targets": []
69
+ }
70
+ }
v5/gpu-pipelined/gemma4_e4b_qat_decode_int4lin_tbl_pf64_ple4_pe4_hsc_vfy8_msdpa_g8_wkv_stable_c131072/tokenizer/chat_template.jinja ADDED
@@ -0,0 +1,386 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {#
2
+ Template: Google Gemma 4 Canonical Chat Template
3
+ Author: Google Gemma Engineering Team
4
+ Published: 2026-07-09
5
+ Context: Fixed tool-calling loops, turn closures, and thinking content-ordering.
6
+ #}
7
+ {%- macro format_parameters(properties, required, filter_keys=false) -%}
8
+ {%- set standard_keys = ['description', 'type', 'properties', 'required', 'nullable'] -%}
9
+ {%- set ns = namespace(found_first=false) -%}
10
+ {%- for key, value in properties | dictsort -%}
11
+ {%- set add_comma = false -%}
12
+ {%- if not filter_keys or key not in standard_keys -%}
13
+ {%- if ns.found_first %},{% endif -%}
14
+ {%- set ns.found_first = true -%}
15
+ {{ key }}:{
16
+ {%- if value['description'] -%}
17
+ description:<|"|>{{ value['description'] }}<|"|>
18
+ {%- set add_comma = true -%}
19
+ {%- endif -%}
20
+ {%- if value['type'] | upper == 'STRING' -%}
21
+ {%- if value['enum'] -%}
22
+ {%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}
23
+ enum:{{ format_argument(value['enum']) }}
24
+ {%- endif -%}
25
+ {%- elif value['type'] | upper == 'ARRAY' -%}
26
+ {%- if value['items'] is mapping and value['items'] -%}
27
+ {%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}
28
+ items:{
29
+ {%- set ns_items = namespace(found_first=false) -%}
30
+ {%- for item_key, item_value in value['items'] | dictsort -%}
31
+ {%- if item_value is not none -%}
32
+ {%- if ns_items.found_first %},{% endif -%}
33
+ {%- set ns_items.found_first = true -%}
34
+ {%- if item_key == 'properties' -%}
35
+ properties:{
36
+ {%- if item_value is mapping -%}
37
+ {{- format_parameters(item_value, value['items']['required'] | default([])) -}}
38
+ {%- endif -%}
39
+ }
40
+ {%- elif item_key == 'required' -%}
41
+ required:[
42
+ {%- for req_item in item_value -%}
43
+ <|"|>{{- req_item -}}<|"|>
44
+ {%- if not loop.last %},{% endif -%}
45
+ {%- endfor -%}
46
+ ]
47
+ {%- elif item_key == 'type' -%}
48
+ {%- if item_value is string -%}
49
+ type:{{ format_argument(item_value | upper) }}
50
+ {%- else -%}
51
+ type:{{ format_argument(item_value | map('upper') | list) }}
52
+ {%- endif -%}
53
+ {%- else -%}
54
+ {{ item_key }}:{{ format_argument(item_value) }}
55
+ {%- endif -%}
56
+ {%- endif -%}
57
+ {%- endfor -%}
58
+ }
59
+ {%- endif -%}
60
+ {%- endif -%}
61
+ {%- if value['nullable'] %}
62
+ {%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}
63
+ nullable:true
64
+ {%- endif -%}
65
+ {%- if value['type'] | upper == 'OBJECT' -%}
66
+ {%- if value['properties'] is defined and value['properties'] is mapping -%}
67
+ {%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}
68
+ properties:{
69
+ {{- format_parameters(value['properties'], value['required'] | default([])) -}}
70
+ }
71
+ {%- elif value is mapping -%}
72
+ {%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}
73
+ properties:{
74
+ {{- format_parameters(value, value['required'] | default([]), filter_keys=true) -}}
75
+ }
76
+ {%- endif -%}
77
+ {%- if value['required'] -%}
78
+ {%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}
79
+ required:[
80
+ {%- for item in value['required'] | default([]) -%}
81
+ <|"|>{{- item -}}<|"|>
82
+ {%- if not loop.last %},{% endif -%}
83
+ {%- endfor -%}
84
+ ]
85
+ {%- endif -%}
86
+ {%- endif -%}
87
+ {%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}
88
+ type:<|"|>{{ value['type'] | upper }}<|"|>}
89
+ {%- endif -%}
90
+ {%- endfor -%}
91
+ {%- endmacro -%}
92
+ {%- macro format_function_declaration(tool_data) -%}
93
+ declaration:{{- tool_data['function']['name'] -}}{description:<|"|>{{- tool_data['function']['description'] -}}<|"|>
94
+ {%- set params = tool_data['function']['parameters'] -%}
95
+ {%- if params -%}
96
+ ,parameters:{
97
+ {%- if params['properties'] -%}
98
+ properties:{ {{- format_parameters(params['properties'], params['required']) -}} },
99
+ {%- endif -%}
100
+ {%- if params['required'] -%}
101
+ required:[
102
+ {%- for item in params['required'] -%}
103
+ <|"|>{{- item -}}<|"|>
104
+ {{- ',' if not loop.last -}}
105
+ {%- endfor -%}
106
+ ],
107
+ {%- endif -%}
108
+ {%- if params['type'] -%}
109
+ type:<|"|>{{- params['type'] | upper -}}<|"|>}
110
+ {%- endif -%}
111
+ {%- endif -%}
112
+ {%- if 'response' in tool_data['function'] -%}
113
+ {%- set response_declaration = tool_data['function']['response'] -%}
114
+ ,response:{
115
+ {%- if response_declaration['description'] -%}
116
+ description:<|"|>{{- response_declaration['description'] -}}<|"|>,
117
+ {%- endif -%}
118
+ {%- if response_declaration['type'] | upper == 'OBJECT' -%}
119
+ type:<|"|>{{- response_declaration['type'] | upper -}}<|"|>}
120
+ {%- endif -%}
121
+ {%- endif -%}
122
+ }
123
+ {%- endmacro -%}
124
+ {%- macro format_argument(argument, escape_keys=True) -%}
125
+ {%- if argument is none -%}
126
+ {{- 'null' -}}
127
+ {%- elif argument is string -%}
128
+ {{- '<|"|>' + argument + '<|"|>' -}}
129
+ {%- elif argument is boolean -%}
130
+ {{- 'true' if argument else 'false' -}}
131
+ {%- elif argument is mapping -%}
132
+ {{- '{' -}}
133
+ {%- set ns = namespace(found_first=false) -%}
134
+ {%- for key, value in argument | dictsort -%}
135
+ {%- if ns.found_first %},{% endif -%}
136
+ {%- set ns.found_first = true -%}
137
+ {%- if escape_keys -%}
138
+ {{- '<|"|>' + key + '<|"|>' -}}
139
+ {%- else -%}
140
+ {{- key -}}
141
+ {%- endif -%}
142
+ :{{- format_argument(value, escape_keys=escape_keys) -}}
143
+ {%- endfor -%}
144
+ {{- '}' -}}
145
+ {%- elif argument is sequence -%}
146
+ {{- '[' -}}
147
+ {%- for item in argument -%}
148
+ {{- format_argument(item, escape_keys=escape_keys) -}}
149
+ {%- if not loop.last %},{% endif -%}
150
+ {%- endfor -%}
151
+ {{- ']' -}}
152
+ {%- else -%}
153
+ {{- argument -}}
154
+ {%- endif -%}
155
+ {%- endmacro -%}
156
+ {%- macro strip_thinking(text) -%}
157
+ {%- set ns = namespace(result='') -%}
158
+ {%- for part in text.split('<channel|>') -%}
159
+ {%- if '<|channel>' in part -%}
160
+ {%- set ns.result = ns.result + part.split('<|channel>')[0] -%}
161
+ {%- else -%}
162
+ {%- set ns.result = ns.result + part -%}
163
+ {%- endif -%}
164
+ {%- endfor -%}
165
+ {{- ns.result | trim -}}
166
+ {%- endmacro -%}
167
+
168
+ {%- macro format_tool_response_block(tool_name, response) -%}
169
+ {{- '<|tool_response>' -}}
170
+ {%- if response is mapping -%}
171
+ {{- 'response:' + tool_name + '{' -}}
172
+ {%- for key, value in response | dictsort -%}
173
+ {{- key -}}:{{- format_argument(value, escape_keys=False) -}}
174
+ {%- if not loop.last %},{% endif -%}
175
+ {%- endfor -%}
176
+ {{- '}' -}}
177
+ {%- else -%}
178
+ {{- 'response:' + tool_name + '{value:' + format_argument(response, escape_keys=False) + '}' -}}
179
+ {%- endif -%}
180
+ {{- '<tool_response|>' -}}
181
+ {%- endmacro -%}
182
+
183
+ {#- ===== SETUP ===== -#}
184
+ {%- set ns = namespace(prev_message_type=None, prev_non_tool_role=None) -%}
185
+ {%- set loop_messages = messages -%}
186
+ {%- set enable_thinking = enable_thinking | default(false) -%}
187
+ {%- set preserve_thinking = preserve_thinking | default(false) -%}
188
+ {{- bos_token -}}
189
+ {#- Handle System/Tool Definitions Block -#}
190
+ {%- if enable_thinking or tools or (messages and messages[0]['role'] in ['system', 'developer']) -%}
191
+ {{- '<|turn>system\n' -}}
192
+ {#- Inject Thinking token at the very top of the FIRST system turn -#}
193
+ {%- if enable_thinking -%}
194
+ {{- '<|think|>\n' -}}
195
+ {%- set ns.prev_message_type = 'think' -%}
196
+ {%- endif -%}
197
+ {%- if messages and messages[0]['role'] in ['system', 'developer'] -%}
198
+ {%- if messages[0]['content'] is string -%}
199
+ {{- messages[0]['content'] | trim -}}
200
+ {%- elif messages[0]['content'] is sequence -%}
201
+ {%- for item in messages[0]['content'] -%}
202
+ {{- item['text'] | trim + ' '-}}
203
+ {%- endfor -%}
204
+ {%- endif -%}
205
+ {%- set loop_messages = messages[1:] -%}
206
+ {%- endif -%}
207
+ {%- if tools -%}
208
+ {%- for tool in tools %}
209
+ {{- '<|tool>' -}}
210
+ {{- format_function_declaration(tool) | trim -}}
211
+ {{- '<tool|>' -}}
212
+ {%- endfor %}
213
+ {%- set ns.prev_message_type = 'tool' -%}
214
+ {%- endif -%}
215
+ {{- '<turn|>\n' -}}
216
+ {%- endif %}
217
+
218
+ {#- Pre-scan: find last user message index for reasoning guard -#}
219
+ {%- set ns_turn = namespace(last_user_idx=-1) -%}
220
+ {%- for i in range(loop_messages | length) -%}
221
+ {%- if loop_messages[i]['role'] == 'user' -%}
222
+ {%- set ns_turn.last_user_idx = i -%}
223
+ {%- endif -%}
224
+ {%- endfor -%}
225
+
226
+ {#- Loop through messages -#}
227
+ {%- for message in loop_messages -%}
228
+ {%- if message['role'] != 'tool' -%}
229
+ {%- set ns.prev_message_type = None -%}
230
+ {%- set role = 'model' if message['role'] == 'assistant' else message['role'] -%}
231
+ {#- Detect continuation using tracked state — O(1) instead of O(n) backward scan -#}
232
+ {%- set continue_same_model_turn = (role == 'model' and ns.prev_non_tool_role == 'assistant') -%}
233
+ {%- if not continue_same_model_turn -%}
234
+ {{- '<|turn>' + role + '\n' }}
235
+ {%- endif -%}
236
+
237
+ {#- Render reasoning/reasoning_content as thinking channel -#}
238
+ {%- set thinking_text = message.get('reasoning') or message.get('reasoning_content') -%}
239
+ {%- set thinking_gate = (loop.index0 > ns_turn.last_user_idx) or (preserve_thinking and message.get('tool_calls')) -%}
240
+ {%- if thinking_text and thinking_gate -%}
241
+ {{- '<|channel>thought\n' + thinking_text + '\n<channel|>' -}}
242
+ {%- endif -%}
243
+
244
+ {%- if message.get('tool_calls') -%}
245
+ {%- for tool_call in message.get('tool_calls') -%}
246
+ {%- set function = tool_call['function'] -%}
247
+ {{- '<|tool_call>call:' + function['name'] + '{' -}}
248
+ {%- if function['arguments'] is mapping -%}
249
+ {%- set ns_args = namespace(found_first=false) -%}
250
+ {%- for key, value in function['arguments'] | dictsort -%}
251
+ {%- if ns_args.found_first %},{% endif -%}
252
+ {%- set ns_args.found_first = true -%}
253
+ {{- key -}}:{{- format_argument(value, escape_keys=False) -}}
254
+ {%- endfor -%}
255
+ {%- elif function['arguments'] is none -%}
256
+ {%- else -%}
257
+ {{- raise_exception(
258
+ "chat_template: tool_calls[].function.arguments must be a "
259
+ "JSON object (mapping), not a string. Deserialize arguments "
260
+ "before passing to the template."
261
+ ) -}}
262
+ {%- endif -%}
263
+ {{- '}<tool_call|>' -}}
264
+ {%- endfor -%}
265
+ {%- set ns.prev_message_type = 'tool_call' -%}
266
+ {%- endif -%}
267
+
268
+ {%- set ns_tr_out = namespace(flag=false) -%}
269
+ {%- if message.get('tool_responses') -%}
270
+ {#- Legacy: tool_responses embedded on the assistant message (Google/Gemma native) -#}
271
+ {%- for tool_response in message.get('tool_responses') -%}
272
+ {{- format_tool_response_block(tool_response['name'] | default('unknown', true), tool_response['response']) -}}
273
+ {%- set ns_tr_out.flag = true -%}
274
+ {%- set ns.prev_message_type = 'tool_response' -%}
275
+ {%- endfor -%}
276
+ {%- elif message.get('tool_calls') -%}
277
+ {#- OpenAI Chat Completions: forward-scan consecutive role:tool messages -#}
278
+ {%- set ns_tool_scan = namespace(stopped=false) -%}
279
+ {%- for k in range(loop.index0 + 1, loop_messages | length) -%}
280
+ {%- if ns_tool_scan.stopped -%}
281
+ {%- elif loop_messages[k]['role'] != 'tool' -%}
282
+ {%- set ns_tool_scan.stopped = true -%}
283
+ {%- else -%}
284
+ {%- set follow = loop_messages[k] -%}
285
+ {#- Resolve tool_call_id to function name -#}
286
+ {%- set ns_tname = namespace(name=follow.get('name') or 'unknown') -%}
287
+ {%- for tc in message.get('tool_calls') -%}
288
+ {%- if tc.get('id') == follow.get('tool_call_id') -%}
289
+ {%- set ns_tname.name = tc['function']['name'] -%}
290
+ {%- endif -%}
291
+ {%- endfor -%}
292
+ {#- Handle content as string or content-parts array -#}
293
+ {%- set tool_body = follow.get('content') -%}
294
+ {%- if tool_body is string -%}
295
+ {{- format_tool_response_block(ns_tname.name, tool_body) -}}
296
+ {%- elif tool_body is sequence and tool_body is not string -%}
297
+ {%- set ns_txt = namespace(s='') -%}
298
+ {%- for part in tool_body -%}
299
+ {%- if part.get('type') == 'text' -%}
300
+ {%- set ns_txt.s = ns_txt.s + (part.get('text') | default('')) -%}
301
+ {%- endif -%}
302
+ {%- endfor -%}
303
+ {{- format_tool_response_block(ns_tname.name, ns_txt.s) -}}
304
+ {%- for part in tool_body -%}
305
+ {%- if part.get('type') in ['image', 'image_url'] -%}
306
+ {{- '<|image|>' -}}
307
+ {%- elif part.get('type') in ['audio', 'input_audio'] -%}
308
+ {{- '<|audio|>' -}}
309
+ {%- elif part.get('type') == 'video' -%}
310
+ {{- '<|video|>' -}}
311
+ {%- endif -%}
312
+ {%- endfor -%}
313
+ {%- else -%}
314
+ {{- format_tool_response_block(ns_tname.name, tool_body) -}}
315
+ {%- endif -%}
316
+ {%- set ns_tr_out.flag = true -%}
317
+ {%- set ns.prev_message_type = 'tool_response' -%}
318
+ {%- endif -%}
319
+ {%- endfor -%}
320
+ {%- endif -%}
321
+
322
+ {%- set captured_content -%}
323
+ {%- if message.get('content') is string -%}
324
+ {%- if role == 'model' -%}
325
+ {{- strip_thinking(message['content']) -}}
326
+ {%- else -%}
327
+ {{- message['content'] | trim -}}
328
+ {%- endif -%}
329
+ {%- elif message.get('content') is sequence -%}
330
+ {%- for item in message['content'] -%}
331
+ {%- if item.get('type') == 'text' -%}
332
+ {%- if role == 'model' -%}
333
+ {{- strip_thinking(item['text']) -}}
334
+ {%- else -%}
335
+ {{- item['text'] | trim -}}
336
+ {%- endif -%}
337
+ {%- elif item.get('type') in ['image', 'image_url'] -%}
338
+ {{- '<|image|>' -}}
339
+ {%- elif item.get('type') in ['audio', 'input_audio'] -%}
340
+ {{- '<|audio|>' -}}
341
+ {%- elif item.get('type') == 'video' -%}
342
+ {{- '<|video|>' -}}
343
+ {%- endif -%}
344
+ {%- endfor -%}
345
+ {%- endif -%}
346
+ {%- endset -%}
347
+
348
+ {{- captured_content -}}
349
+ {%- set has_content = captured_content | trim | length > 0 -%}
350
+
351
+ {#- Forward-scan: find next non-tool message role for continuation detection -#}
352
+ {%- set next_nt = namespace(role=None, found=false) -%}
353
+ {%- for j in range(loop.index0 + 1, loop_messages | length) -%}
354
+ {%- if not next_nt.found -%}
355
+ {%- if loop_messages[j]['role'] != 'tool' -%}
356
+ {%- set next_nt.role = loop_messages[j]['role'] -%}
357
+ {%- set next_nt.found = true -%}
358
+ {%- endif -%}
359
+ {%- endif -%}
360
+ {%- endfor -%}
361
+
362
+ {%- set continues_into_next = (
363
+ role == 'model'
364
+ and next_nt.role == 'assistant'
365
+ and (not message.get('tool_calls') or ns_tr_out.flag)
366
+ ) -%}
367
+
368
+ {%- if ns.prev_message_type == 'tool_call' and not ns_tr_out.flag -%}
369
+ {{- '<|tool_response>' -}}
370
+ {%- elif continues_into_next -%}
371
+ {%- elif not (ns_tr_out.flag and not has_content and not next_nt.found) -%}
372
+ {{- '<turn|>\n' -}}
373
+ {%- endif -%}
374
+
375
+ {#- Track previous non-tool role for next iteration (avoids O(n) backward scan) -#}
376
+ {%- set ns.prev_non_tool_role = message['role'] -%}
377
+ {%- endif -%}
378
+ {%- endfor -%}
379
+
380
+ {%- if add_generation_prompt -%}
381
+ {%- if ns.prev_message_type != 'tool_response' and ns.prev_message_type != 'tool_call' -%}
382
+ {{- '<|turn>model\n' -}}
383
+ {%- elif ns.prev_message_type == 'tool_response' and enable_thinking -%}
384
+ {{- '<|channel>thought\n' -}}
385
+ {%- endif -%}
386
+ {%- endif -%}
v5/gpu-pipelined/gemma4_e4b_qat_decode_int4lin_tbl_pf64_ple4_pe4_hsc_vfy8_msdpa_g8_wkv_stable_c131072/tokenizer/generation_config.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token_id": 2,
3
+ "do_sample": true,
4
+ "eos_token_id": [
5
+ 1,
6
+ 106,
7
+ 50
8
+ ],
9
+ "pad_token_id": 0,
10
+ "temperature": 1.0,
11
+ "top_k": 64,
12
+ "top_p": 0.95,
13
+ "transformers_version": "5.6.2"
14
+ }
v5/gpu-pipelined/gemma4_e4b_qat_decode_int4lin_tbl_pf64_ple4_pe4_hsc_vfy8_msdpa_g8_wkv_stable_c131072/tokenizer/tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cc8d3a0ce36466ccc1278bf987df5f71db1719b9ca6b4118264f45cb627bfe0f
3
+ size 32169626
v5/gpu-pipelined/gemma4_e4b_qat_decode_int4lin_tbl_pf64_ple4_pe4_hsc_vfy8_msdpa_g8_wkv_stable_c131072/tokenizer/tokenizer_config.json ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "audio_token": "<|audio|>",
3
+ "backend": "tokenizers",
4
+ "boa_token": "<|audio>",
5
+ "boi_token": "<|image>",
6
+ "bos_token": "<bos>",
7
+ "eoa_token": "<audio|>",
8
+ "eoc_token": "<channel|>",
9
+ "eoi_token": "<image|>",
10
+ "eos_token": "<eos>",
11
+ "eot_token": "<turn|>",
12
+ "escape_token": "<|\"|>",
13
+ "etc_token": "<tool_call|>",
14
+ "etd_token": "<tool|>",
15
+ "etr_token": "<tool_response|>",
16
+ "extra_special_tokens": [
17
+ "<|video|>"
18
+ ],
19
+ "image_token": "<|image|>",
20
+ "is_local": false,
21
+ "local_files_only": false,
22
+ "mask_token": "<mask>",
23
+ "model_max_length": 1000000000000000019884624838656,
24
+ "model_specific_special_tokens": {
25
+ "audio_token": "<|audio|>",
26
+ "boa_token": "<|audio>",
27
+ "boi_token": "<|image>",
28
+ "eoa_token": "<audio|>",
29
+ "eoc_token": "<channel|>",
30
+ "eoi_token": "<image|>",
31
+ "eot_token": "<turn|>",
32
+ "escape_token": "<|\"|>",
33
+ "etc_token": "<tool_call|>",
34
+ "etd_token": "<tool|>",
35
+ "etr_token": "<tool_response|>",
36
+ "image_token": "<|image|>",
37
+ "soc_token": "<|channel>",
38
+ "sot_token": "<|turn>",
39
+ "stc_token": "<|tool_call>",
40
+ "std_token": "<|tool>",
41
+ "str_token": "<|tool_response>",
42
+ "think_token": "<|think|>"
43
+ },
44
+ "pad_token": "<pad>",
45
+ "padding_side": "left",
46
+ "processor_class": "Gemma4Processor",
47
+ "response_schema": {
48
+ "properties": {
49
+ "content": {
50
+ "type": "string"
51
+ },
52
+ "role": {
53
+ "const": "assistant"
54
+ },
55
+ "thinking": {
56
+ "type": "string"
57
+ },
58
+ "tool_calls": {
59
+ "items": {
60
+ "properties": {
61
+ "function": {
62
+ "properties": {
63
+ "arguments": {
64
+ "additionalProperties": {},
65
+ "type": "object",
66
+ "x-parser": "gemma4-tool-call"
67
+ },
68
+ "name": {
69
+ "type": "string"
70
+ }
71
+ },
72
+ "type": "object",
73
+ "x-regex": "call\\:(?P<name>\\w+)(?P<arguments>\\{.*\\})"
74
+ },
75
+ "type": {
76
+ "const": "function"
77
+ }
78
+ },
79
+ "type": "object"
80
+ },
81
+ "type": "array",
82
+ "x-regex-iterator": "<\\|tool_call>(.*?)<tool_call\\|>"
83
+ }
84
+ },
85
+ "type": "object",
86
+ "x-regex": "(\\<\\|channel\\>thought\\n(?P<thinking>.*?)\\<channel\\|\\>)?(?P<tool_calls>\\<\\|tool_call\\>.*\\<tool_call\\|\\>)?(?P<content>(?:(?!\\<turn\\|\\>)(?!\\<\\|tool_response\\>).)+)?(?:\\<turn\\|\\>|\\<\\|tool_response\\>)?"
87
+ },
88
+ "response_template": {
89
+ "defaults": {
90
+ "role": "assistant"
91
+ },
92
+ "fields": {
93
+ "content": {
94
+ "close": [
95
+ "<turn|>",
96
+ "<|tool_response>",
97
+ "<eos>"
98
+ ],
99
+ "content": "text"
100
+ },
101
+ "thinking": {
102
+ "close": "<channel|>",
103
+ "content": "text",
104
+ "open": "<|channel>thought\n"
105
+ },
106
+ "tool_calls": {
107
+ "close": "<tool_call|>",
108
+ "content": "json",
109
+ "content_args": {
110
+ "string_delims": [
111
+ [
112
+ "<|\"|>",
113
+ "<|\"|>"
114
+ ]
115
+ ],
116
+ "unquoted_keys": true
117
+ },
118
+ "open_pattern": "<\\|tool_call>call:(?P<name>\\w+)",
119
+ "repeats": true,
120
+ "transform": {
121
+ "function": {
122
+ "arguments": "{content}",
123
+ "name": "{name}"
124
+ },
125
+ "type": "function"
126
+ }
127
+ }
128
+ },
129
+ "start_anchor": [
130
+ "<|turn>model\n",
131
+ "<tool_response|>"
132
+ ]
133
+ },
134
+ "soc_token": "<|channel>",
135
+ "sot_token": "<|turn>",
136
+ "stc_token": "<|tool_call>",
137
+ "std_token": "<|tool>",
138
+ "str_token": "<|tool_response>",
139
+ "think_token": "<|think|>",
140
+ "tokenizer_class": "GemmaTokenizer",
141
+ "unk_token": "<unk>"
142
+ }