MojoLlama
Archived Mojo/MAX quantizer and serving research repository (read-only history)
Brought by drakestapleton
MojoLlama / inspect_model.py
| 1 | #!/usr/bin/env python3 |
| 2 | import gguf |
| 3 | import numpy as np |
| 4 | import sys |
| 5 | |
| 6 | reader = gguf.GGUFReader('/tmp/models/qwen3.6-35b-a3b-q4_k_m.gguf') |
| 7 | |
| 8 | # List all tensor names for layer 0 only (fast iteration with break) |
| 9 | count = 0 |
| 10 | for t in reader.tensors: |
| 11 | name = t.name |
| 12 | if name.startswith('blk.0.'): |
| 13 | print(f'{name}: shape={list(t.shape)} type={t.tensor_type}') |
| 14 | count += 1 |
| 15 | if count >= 20: |
| 16 | break |
| 17 | |
| 18 | print() |
| 19 | |
| 20 | # Check ssm_a values |
| 21 | for t in reader.tensors: |
| 22 | if t.name == 'blk.0.ssm_a': |
| 23 | data = gguf.dequantize(t.data, t.tensor_type).astype(np.float32).reshape(-1) |
| 24 | print(f'SSM_A: {data}') |
| 25 | print(f' shape: {data.shape}') |
| 26 | print(f' exp(-exp(A)): {np.exp(-np.exp(data))}') |
| 27 | break |
| 28 | |
| 29 | # Check ssm_dt.bias |
| 30 | for t in reader.tensors: |
| 31 | if t.name == 'blk.0.ssm_dt.bias': |
| 32 | data = gguf.dequantize(t.data, t.tensor_type).astype(np.float32).reshape(-1) |
| 33 | print(f'ssm_dt.bias: {data}') |
| 34 | print(f' shape: {data.shape}') |
| 35 | break |
| 36 | |
| 37 | # Check ssm_norm.weight |
| 38 | for t in reader.tensors: |
| 39 | if t.name == 'blk.0.ssm_norm.weight': |
| 40 | data = gguf.dequantize(t.data, t.tensor_type).astype(np.float32).reshape(-1) |
| 41 | print(f'ssm_norm.weight: {data}') |
| 42 | print(f' shape: {data.shape}') |
| 43 | break |
| 44 | |
| 45 | # Check layer 3 (attention layer) tensors |
| 46 | print() |
| 47 | count = 0 |
| 48 | for t in reader.tensors: |
| 49 | name = t.name |
| 50 | if name.startswith('blk.3.'): |
| 51 | print(f'L3 {name}: shape={list(t.shape)} type={t.tensor_type}') |
| 52 | count += 1 |
| 53 | if count >= 20: |
| 54 | break |