Text Generation
Transformers
Safetensors
English
arloop_baseline
arloop
recurrent
custom_code
pretrained
Instructions to use osunlp/PreNormLoop-0.6B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use osunlp/PreNormLoop-0.6B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="osunlp/PreNormLoop-0.6B", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("osunlp/PreNormLoop-0.6B", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use osunlp/PreNormLoop-0.6B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "osunlp/PreNormLoop-0.6B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "osunlp/PreNormLoop-0.6B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/osunlp/PreNormLoop-0.6B
- SGLang
How to use osunlp/PreNormLoop-0.6B 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 "osunlp/PreNormLoop-0.6B" \ --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": "osunlp/PreNormLoop-0.6B", "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 "osunlp/PreNormLoop-0.6B" \ --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": "osunlp/PreNormLoop-0.6B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use osunlp/PreNormLoop-0.6B with Docker Model Runner:
docker model run hf.co/osunlp/PreNormLoop-0.6B
Default to BF16 weights for inference
Browse files- README.md +3 -1
- config.json +3 -2
- modeling_baseline.py +1 -1
README.md
CHANGED
|
@@ -34,7 +34,7 @@ model_id = "osunlp/ARLoop-baseline-0.6B"
|
|
| 34 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 35 |
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
|
| 36 |
model = AutoModelForCausalLM.from_pretrained(
|
| 37 |
-
model_id, trust_remote_code=True, dtype=torch.
|
| 38 |
).to(device).eval()
|
| 39 |
inputs = tokenizer("The capital of France is", return_tensors="pt").to(device)
|
| 40 |
with torch.inference_mode():
|
|
@@ -42,6 +42,8 @@ with torch.inference_mode():
|
|
| 42 |
print(tokenizer.decode(output[0], skip_special_tokens=True))
|
| 43 |
```
|
| 44 |
|
|
|
|
|
|
|
| 45 |
## Architecture
|
| 46 |
|
| 47 |
| Property | Value |
|
|
|
|
| 34 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 35 |
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
|
| 36 |
model = AutoModelForCausalLM.from_pretrained(
|
| 37 |
+
model_id, trust_remote_code=True, dtype=torch.bfloat16,
|
| 38 |
).to(device).eval()
|
| 39 |
inputs = tokenizer("The capital of France is", return_tensors="pt").to(device)
|
| 40 |
with torch.inference_mode():
|
|
|
|
| 42 |
print(tokenizer.decode(output[0], skip_special_tokens=True))
|
| 43 |
```
|
| 44 |
|
| 45 |
+
Weights load in BF16 for inference. The stored checkpoint retains the original FP32 weights; normalization statistics use FP32 internally.
|
| 46 |
+
|
| 47 |
## Architecture
|
| 48 |
|
| 49 |
| Property | Value |
|
config.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
| 7 |
"AutoModelForCausalLM": "modeling_baseline.ARLoopBaselineForCausalLM"
|
| 8 |
},
|
| 9 |
"bos_token_id": 0,
|
| 10 |
-
"dtype": "
|
| 11 |
"embedding_scale": 1.0,
|
| 12 |
"eos_token_id": 0,
|
| 13 |
"head_dim": 96,
|
|
@@ -29,5 +29,6 @@
|
|
| 29 |
"tie_word_embeddings": true,
|
| 30 |
"transformers_version": "5.12.1",
|
| 31 |
"use_cache": true,
|
| 32 |
-
"vocab_size": 49152
|
|
|
|
| 33 |
}
|
|
|
|
| 7 |
"AutoModelForCausalLM": "modeling_baseline.ARLoopBaselineForCausalLM"
|
| 8 |
},
|
| 9 |
"bos_token_id": 0,
|
| 10 |
+
"dtype": "bfloat16",
|
| 11 |
"embedding_scale": 1.0,
|
| 12 |
"eos_token_id": 0,
|
| 13 |
"head_dim": 96,
|
|
|
|
| 29 |
"tie_word_embeddings": true,
|
| 30 |
"transformers_version": "5.12.1",
|
| 31 |
"use_cache": true,
|
| 32 |
+
"vocab_size": 49152,
|
| 33 |
+
"torch_dtype": "bfloat16"
|
| 34 |
}
|
modeling_baseline.py
CHANGED
|
@@ -158,7 +158,7 @@ class ARLoopBaselineForCausalLM(PreTrainedModel, GenerationMixin):
|
|
| 158 |
if not bool(attention_mask.all()):
|
| 159 |
mask = (key_indices[None, :] <= query_indices[:, None])[None, None, :, :]
|
| 160 |
mask = mask & attention_mask[:, None, None, :].bool()
|
| 161 |
-
#
|
| 162 |
with torch.autocast(device_type=input_ids.device.type, dtype=torch.bfloat16):
|
| 163 |
h = self.transformer.wte(input_ids) * self.config.embedding_scale
|
| 164 |
ve = self.shared_value_embedding(input_ids)
|
|
|
|
| 158 |
if not bool(attention_mask.all()):
|
| 159 |
mask = (key_indices[None, :] <= query_indices[:, None])[None, None, :, :]
|
| 160 |
mask = mask & attention_mask[:, None, None, :].bool()
|
| 161 |
+
# Residual/value embeddings follow the loading dtype; Linear ops use BF16 autocast.
|
| 162 |
with torch.autocast(device_type=input_ids.device.type, dtype=torch.bfloat16):
|
| 163 |
h = self.transformer.wte(input_ids) * self.config.embedding_scale
|
| 164 |
ve = self.shared_value_embedding(input_ids)
|