Text Generation
Transformers
PyTorch
English
shram
research
sparse-attention
mixture-of-experts
custom_code
Instructions to use smithblack-0/SHRAM-dev with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use smithblack-0/SHRAM-dev with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="smithblack-0/SHRAM-dev", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("smithblack-0/SHRAM-dev", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use smithblack-0/SHRAM-dev with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "smithblack-0/SHRAM-dev" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "smithblack-0/SHRAM-dev", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/smithblack-0/SHRAM-dev
- SGLang
How to use smithblack-0/SHRAM-dev 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 "smithblack-0/SHRAM-dev" \ --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": "smithblack-0/SHRAM-dev", "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 "smithblack-0/SHRAM-dev" \ --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": "smithblack-0/SHRAM-dev", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use smithblack-0/SHRAM-dev with Docker Model Runner:
docker model run hf.co/smithblack-0/SHRAM-dev
Update architecture and tokenizer
Browse files- huggingface.py +4 -4
huggingface.py
CHANGED
|
@@ -2471,7 +2471,7 @@ def pack_experts(
|
|
| 2471 |
tokens_per_expert = _count_tokens_per_expert(flattened_selected_heads, num_experts)
|
| 2472 |
max_count = tokens_per_expert.max().item()
|
| 2473 |
no_overflow = max_count <= packed_length
|
| 2474 |
-
_enforce_no_overflow(no_overflow,
|
| 2475 |
|
| 2476 |
# -----------------------------------------------------------------------
|
| 2477 |
# Construct the unpacking mask.
|
|
@@ -2614,9 +2614,9 @@ def _enforce_no_overflow(condition: bool, tokens_per_expert, max_length) -> None
|
|
| 2614 |
raise RuntimeError(
|
| 2615 |
"Expert packing overflow: at least one expert bucket contains more "
|
| 2616 |
"tokens than mosrah_packed_length allows. Increase "
|
| 2617 |
-
"mosrah_overallocation_factor in ShramConfig to resolve."
|
| 2618 |
-
f"
|
| 2619 |
-
f"
|
| 2620 |
)
|
| 2621 |
|
| 2622 |
|
|
|
|
| 2471 |
tokens_per_expert = _count_tokens_per_expert(flattened_selected_heads, num_experts)
|
| 2472 |
max_count = tokens_per_expert.max().item()
|
| 2473 |
no_overflow = max_count <= packed_length
|
| 2474 |
+
_enforce_no_overflow(no_overflow, tokens_per_expert, packed_length)
|
| 2475 |
|
| 2476 |
# -----------------------------------------------------------------------
|
| 2477 |
# Construct the unpacking mask.
|
|
|
|
| 2614 |
raise RuntimeError(
|
| 2615 |
"Expert packing overflow: at least one expert bucket contains more "
|
| 2616 |
"tokens than mosrah_packed_length allows. Increase "
|
| 2617 |
+
"mosrah_overallocation_factor in ShramConfig to resolve.\n"
|
| 2618 |
+
f"Supported lengths were:\n {max_length}\n"
|
| 2619 |
+
f"head lengths were:\n {tokens_per_expert}\n"
|
| 2620 |
)
|
| 2621 |
|
| 2622 |
|