Text Generation
Transformers
Safetensors
PyTorch
English
yatnmn_gpt
gpt
yatnmn
nmn
chinchilla
nanochat
1b
custom_code
Instructions to use mlnomad/yatnmn-softplus-d22-chinchilla-1B-pytorch with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use mlnomad/yatnmn-softplus-d22-chinchilla-1B-pytorch with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="mlnomad/yatnmn-softplus-d22-chinchilla-1B-pytorch", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("mlnomad/yatnmn-softplus-d22-chinchilla-1B-pytorch", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use mlnomad/yatnmn-softplus-d22-chinchilla-1B-pytorch with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "mlnomad/yatnmn-softplus-d22-chinchilla-1B-pytorch" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mlnomad/yatnmn-softplus-d22-chinchilla-1B-pytorch", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/mlnomad/yatnmn-softplus-d22-chinchilla-1B-pytorch
- SGLang
How to use mlnomad/yatnmn-softplus-d22-chinchilla-1B-pytorch with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "mlnomad/yatnmn-softplus-d22-chinchilla-1B-pytorch" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mlnomad/yatnmn-softplus-d22-chinchilla-1B-pytorch", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "mlnomad/yatnmn-softplus-d22-chinchilla-1B-pytorch" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mlnomad/yatnmn-softplus-d22-chinchilla-1B-pytorch", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use mlnomad/yatnmn-softplus-d22-chinchilla-1B-pytorch with Docker Model Runner:
docker model run hf.co/mlnomad/yatnmn-softplus-d22-chinchilla-1B-pytorch
Fix: lazy non-persistent RoPE buffers — HF from_pretrained's meta-init was leaving persistent rope_cos/rope_sin uninitialised, producing NaN logits. Buffers are now computed on first forward.
Browse files- torch_gpt.py +22 -13
torch_gpt.py
CHANGED
|
@@ -315,17 +315,27 @@ class GELU_GPT(nn.Module):
|
|
| 315 |
}
|
| 316 |
)
|
| 317 |
|
| 318 |
-
#
|
| 319 |
-
#
|
| 320 |
-
#
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
)
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 329 |
|
| 330 |
# ------------------------------------------------------------------
|
| 331 |
# Forward
|
|
@@ -334,8 +344,7 @@ class GELU_GPT(nn.Module):
|
|
| 334 |
B, T = idx.shape
|
| 335 |
config = self.config
|
| 336 |
|
| 337 |
-
cos = self.
|
| 338 |
-
sin = self.rope_sin[:, :T].to(dtype=self.wte.weight.dtype)
|
| 339 |
|
| 340 |
x = self.wte(idx)
|
| 341 |
x = rms_norm(x)
|
|
|
|
| 315 |
}
|
| 316 |
)
|
| 317 |
|
| 318 |
+
# Lazy RoPE: HF from_pretrained can leave persistent buffers
|
| 319 |
+
# uninitialised (meta-init → NaN). We instead register an empty
|
| 320 |
+
# placeholder and compute the table on the first forward.
|
| 321 |
+
self._rope_max_len = config.sequence_len * 10
|
| 322 |
+
self._rope_head_dim = config.head_dim
|
| 323 |
+
self._rope_base = config.rope_base
|
| 324 |
+
self.register_buffer("rope_cos", torch.empty(0), persistent=False)
|
| 325 |
+
self.register_buffer("rope_sin", torch.empty(0), persistent=False)
|
| 326 |
+
self._rope_initialized = False
|
| 327 |
+
|
| 328 |
+
def _get_rope(self, T, dtype, device):
|
| 329 |
+
if (not self._rope_initialized
|
| 330 |
+
or self.rope_cos.numel() == 0
|
| 331 |
+
or self.rope_cos.shape[1] < T):
|
| 332 |
+
cos, sin = precompute_rotary_embeddings(
|
| 333 |
+
max(T, self._rope_max_len), self._rope_head_dim, base=self._rope_base
|
| 334 |
+
)
|
| 335 |
+
self.rope_cos = cos.to(device)
|
| 336 |
+
self.rope_sin = sin.to(device)
|
| 337 |
+
self._rope_initialized = True
|
| 338 |
+
return self.rope_cos[:, :T].to(dtype), self.rope_sin[:, :T].to(dtype)
|
| 339 |
|
| 340 |
# ------------------------------------------------------------------
|
| 341 |
# Forward
|
|
|
|
| 344 |
B, T = idx.shape
|
| 345 |
config = self.config
|
| 346 |
|
| 347 |
+
cos, sin = self._get_rope(T, self.wte.weight.dtype, self.wte.weight.device)
|
|
|
|
| 348 |
|
| 349 |
x = self.wte(idx)
|
| 350 |
x = rms_norm(x)
|