File size: 3,155 Bytes
bad67b2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
---
library_name: transformers
pipeline_tag: text-generation
base_model:
- stabilityai/stablelm-2-1_6b
---

This is a randomly initialized tiny model based on [stabilityai/stablelm-2-1_6b](https://huggingface.co/stabilityai/stablelm-2-1_6b) for testing and debugging.

| Feature | Source | This repo |
|---|---|---|
| Checkpoint tensor elements | 1.64B BF16 | 13.65M BF16 |
| Safetensors weight files | 3.29 GB (model.safetensors) | 27.31 MB (model.safetensors) |
| Layers | 24 | 4 |
| Hidden width / MLP width | 2,048 / 5,632 (2.75x) | 128 / 352 (2.75x) |
| Q heads / KV heads / head_dim | 32 / 32 / 64 | 4 / 4 / 32 |
| Rotary coverage | partial, 25% of head_dim | Same (8 of 32) |
| QKV bias / embedding tying | true / untied (source) | true / tied |
| Vocabulary rows | 100,352 | Same |
| Stored precision | FP16 config | BF16 |

StableLM has no rectangular attention, so TP=4 forces four 32-dim heads and hidden width 128. The tiny checkpoint ties the language-model head to the token embedding (the source shipped them untied), keeping the artifact at 27.31MB within the 30MB best-effort target.

| File path | Size |
|------|------|
| model.safetensors | 27.3MB |

### Example usage

#### Transformers (✅ verified)

```python
def run_transformers(model_id: str):
    import torch
    from transformers import AutoModelForCausalLM, AutoTokenizer

    model_id = str(model_id)
    tokenizer = AutoTokenizer.from_pretrained(model_id)
    model = (
        AutoModelForCausalLM.from_pretrained(model_id, dtype=torch.bfloat16, attn_implementation="sdpa").eval().cuda()
    )
    inputs = tokenizer("The quick brown fox jumps over the lazy dog.", return_tensors="pt").to("cuda")
    with torch.no_grad():
        assert torch.isfinite(model(**inputs).logits).all()
        output = model.generate(**inputs, do_sample=False, max_new_tokens=8)
    print(tokenizer.decode(output[0], skip_special_tokens=True))


if __name__ == "__main__":
    run_transformers(model_id="tiny-random/stablelm-2")
```

#### SGLang (✅ verified)

SGLang 0.5.10 ships a native `StableLmForCausalLM` implementation; serve the tiny checkpoint with tensor parallelism:

```bash
sglang serve --model-path tiny-random/stablelm-2 --tp 4 \
  --dtype bfloat16 --context-length 1024 --disable-piecewise-cuda-graph --host 0.0.0.0 --port 30000
```

piecewise prefill CUDA graph capture hits `CUBLAS_STATUS_INTERNAL_ERROR` in `o_proj`, so the command below passes `--disable-piecewise-cuda-graph`.

Send an OpenAI completion request:

```python
from openai import OpenAI

client = OpenAI(base_url="http://localhost:30000/v1", api_key="EMPTY")
resp = client.completions.create(
    model="tiny-random/stablelm-2", prompt="The quick brown fox", max_tokens=8, temperature=0
)
print(resp.choices[0].text)
```

### Creating this repo

- Code: [.meta/create_model.py](.meta/create_model.py)
- Model structure: [.meta/model.log](.meta/model.log)
- Environment: [.meta/env.json](.meta/env.json)

### Change log

- 2026-11-07: Initial version rebuilt from the official stabilityai/stablelm-2-1_6b source with four layers and 25%-partial rotary embeddings.

*This repo is generated by GPT-6.1-Sol.*