Create GLM-5.2 Vocabulary Efficiency Improvements.md
Browse files
GLM-5.2 Vocabulary Efficiency Improvements.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
GLM-5.2 Vocabulary Efficiency Improvements.md
|
| 2 |
+
|
| 3 |
+
# GLM-5.2 Vocabulary Pruning Candidates (`glm_5.2_prune_candidates.json`)
|
| 4 |
+
|
| 5 |
+
Martial Terran, the LLM Vocabulary Reduction Specialist, has made a curated list [glm_5.2_prune_candidates.json] of Token IDs that are candidates for pruning or deactivation from the GLM-5.2 model's active inference weights, tokenizer configuration, and output projection layers.
|
| 6 |
+
|
| 7 |
+
The pruning configuration in `glm_5.2_prune_candidates.json` maps directly to rows that can be safely modified or removed within:
|
| 8 |
+
* `config.json`
|
| 9 |
+
* `tokenizer_config.json`
|
| 10 |
+
* `tokenizer.json`
|
| 11 |
+
* `chat_template.jinja`
|
| 12 |
+
* **Input Embeddings:** `model.embed_tokens.weight` `{Shape: torch.Size([154880, 6144])}` in shard `model-00001-of-00282.safetensors`
|
| 13 |
+
* **LM Head Projection:** `lm_head.weight` `{Shape: torch.Size([154880, 6144])}` in shard `model-00001-of-00282.safetensors`
|
| 14 |
+
|
| 15 |
+
**Target Repository ID:** `zai-org/GLM-5.2`
|
| 16 |
+
|
| 17 |
+
By safely deactivating or pruning these identified Token IDs from the active `lm_head` and `embed_tokens` matrices, you can reduce the parameter footprint and improve inference throughput.
|
| 18 |
+
|
| 19 |
+
---
|
| 20 |
+
|
| 21 |
+
## Pruning Efficiency Gains
|
| 22 |
+
|
| 23 |
+
Pruning these 331 inactive tokens translates to a reduction of **~20.34 Billion MACs** per 10,000 tokens of processed context.
|
| 24 |
+
|
| 25 |
+
### Resource Reduction Report
|
| 26 |
+
* **Number of Dead Tokens Identified:** 331
|
| 27 |
+
* **Vocabulary Reduction:** 0.21% of the total vocabulary
|
| 28 |
+
* **Memory Saved (Raw Weights):** 7.76 MB (at FP16/BF16 precision)
|
| 29 |
+
* **Total Parameters Removed:** 4,067,328 parameters
|
| 30 |
+
|
| 31 |
+
### Inference Efficiency (per 10,000 tokens)
|
| 32 |
+
* **MACs Saved:** 20.34 Billion MACs
|
| 33 |
+
* **FLOPs Saved:** 40.67 GFLOPs
|
| 34 |
+
|
| 35 |
+
---
|
| 36 |
+
|
| 37 |
+
## Hardware-Aware Performance Profile
|
| 38 |
+
|
| 39 |
+
To evaluate the real-world performance impact of pruning these tokens, we look beyond raw FLOP counts. During LLM deployment, execution is split into two fundamentally different hardware regimes:
|
| 40 |
+
|
| 41 |
+
1. **Prefill Phase (Prompt Processing):** Compute-bound (GEMM). FLOP/MAC savings scale linearly with context length and batch size.
|
| 42 |
+
2. **Decode Phase (Autoregressive Generation):** Memory-bandwidth bound (GEMV). The bottleneck is streaming the weight matrices from GPU High Bandwidth Memory (HBM) to SRAM/Registers. FLOP savings are secondary to **HBM read throughput savings**.
|
| 43 |
+
|
| 44 |
+
### 1. Bandwidth Savings vs. FLOP Savings
|
| 45 |
+
During the **Decode Phase**, GPU execution is heavily bound by memory bandwidth. By removing the elements identified in `glm_5.2_prune_candidates.json` from the `lm_head`, we save **3.14 MB of HBM reads per token generation step** (independent of batch size, as the weight matrix is streamed to SRAM once per step).
|
| 46 |
+
|
| 47 |
+
### 2. Latency Profile Generation
|
| 48 |
+
The table below translates these memory bandwidth savings into theoretical clock-time savings across NVIDIA A100, H100, and H200 accelerators based on raw hardware throughput limits.
|
| 49 |
+
|
| 50 |
+
---
|
| 51 |
+
|
| 52 |
+
## GLM-5.2 Hardware-Aligned Pruning Report
|
| 53 |
+
|
| 54 |
+
```text
|
| 55 |
+
================================================================================
|
| 56 |
+
GLM-5.2 HARDWARE-ALIGNED PRUNING REPORT (d_model=6144)
|
| 57 |
+
================================================================================
|
| 58 |
+
--- 1. VOCABULARY ALIGNMENT ANALYSIS (CUDA Warp / Tensor Core Optimization) ---
|
| 59 |
+
Original Vocabulary Size: 154,880 (Multiple of 128)
|
| 60 |
+
Raw Dead Tokens Identified: 331 (0.214% of vocab)
|
| 61 |
+
...
|
| 62 |
+
--- 3. PREFILL PHASE PROFILE (Compute-Bound: GEMM) ---
|
| 63 |
+
Execution Target Context: 8,192 tokens (Batch Size: 8)
|
| 64 |
+
Computational MACs Saved: 103.0792 Billion MACs
|
| 65 |
+
Computational FLOPs Saved: 206.1584 GFLOPs
|
| 66 |
+
|
| 67 |
+
--- 4. DECODE PHASE PROFILE (Bandwidth-Bound: GEMV) ---
|
| 68 |
+
HBM Data Stream Saved per Step: 3072.00 KB / token step
|
| 69 |
+
Theoretical Hardware Latency Saved per Autoregressive Step:
|
| 70 |
+
* NVIDIA A100 (SXM4) | Bandwidth: 2.039 TB/s | Saved: 1542.78 ns
|
| 71 |
+
* NVIDIA H100 (SXM5) | Bandwidth: 3.350 TB/s | Saved: 939.02 ns
|
| 72 |
+
* NVIDIA H200 (SXM) | Bandwidth: 4.800 TB/s | Saved: 655.36 ns
|
| 73 |
+
================================================================================
|