Instructions to use facebook/KernelLLM with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use facebook/KernelLLM with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="facebook/KernelLLM") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("facebook/KernelLLM") model = AutoModelForCausalLM.from_pretrained("facebook/KernelLLM") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use facebook/KernelLLM with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "facebook/KernelLLM" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "facebook/KernelLLM", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/facebook/KernelLLM
- SGLang
How to use facebook/KernelLLM 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 "facebook/KernelLLM" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "facebook/KernelLLM", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "facebook/KernelLLM" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "facebook/KernelLLM", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use facebook/KernelLLM with Docker Model Runner:
docker model run hf.co/facebook/KernelLLM
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,85 @@
|
|
| 1 |
-
---
|
| 2 |
-
license:
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: other
|
| 3 |
+
base_model:
|
| 4 |
+
- meta-llama/Llama-3.1-8B
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+
# KernelLLM
|
| 8 |
+
|
| 9 |
+
We introduce KernelLLM, a large language model, based on Llama 3.1, which has been trained specfically for the task of writing kernels.
|
| 10 |
+
This is in collaboration with [Project Popcorn](https://gpu-mode.github.io/popcorn/).
|
| 11 |
+
|
| 12 |
+
## Model Use
|
| 13 |
+
|
| 14 |
+
To use this model, please make sure to install transformers:
|
| 15 |
+
|
| 16 |
+
```bash
|
| 17 |
+
pip install transformers accelerate
|
| 18 |
+
```
|
| 19 |
+
|
| 20 |
+
The code below demonstrates default capabilities. You may need to set the HuggingFace access token - see (https://huggingface.co/docs/hub/security-tokens).
|
| 21 |
+
|
| 22 |
+
```python
|
| 23 |
+
from transformers import AutoTokenizer
|
| 24 |
+
import transformers
|
| 25 |
+
import torch
|
| 26 |
+
|
| 27 |
+
model = "facebook/KernelLLM"
|
| 28 |
+
|
| 29 |
+
tokenizer = AutoTokenizer.from_pretrained(model)
|
| 30 |
+
pipeline = transformers.pipeline(
|
| 31 |
+
"text-generation",
|
| 32 |
+
model=model,
|
| 33 |
+
torch_dtype=torch.float16,
|
| 34 |
+
device_map="auto",
|
| 35 |
+
)
|
| 36 |
+
|
| 37 |
+
prompt = "import torch"
|
| 38 |
+
|
| 39 |
+
response = pipeline(
|
| 40 |
+
prompt,
|
| 41 |
+
do_sample=True,
|
| 42 |
+
top_k=2,
|
| 43 |
+
temperature=0.1,
|
| 44 |
+
top_p=0.95,
|
| 45 |
+
num_return_sequences=1,
|
| 46 |
+
eos_token_id=tokenizer.eos_token_id,
|
| 47 |
+
max_length=100,
|
| 48 |
+
truncation=True,
|
| 49 |
+
)[0]
|
| 50 |
+
print(prompt, response, join="")
|
| 51 |
+
```
|
| 52 |
+
|
| 53 |
+
## Model Details
|
| 54 |
+
|
| 55 |
+
**Model Developers** Meta.
|
| 56 |
+
|
| 57 |
+
**Input** Models input text only.
|
| 58 |
+
|
| 59 |
+
**Output** Models generate text only.
|
| 60 |
+
|
| 61 |
+
**Model Architecture** KernelLLM is an auto-regressive language model that uses an optimized transformer architecture.
|
| 62 |
+
|
| 63 |
+
**Model Dates** KernelLLM was been trained in March 2025.
|
| 64 |
+
|
| 65 |
+
**Status** This is a static model trained on an offline dataset.
|
| 66 |
+
|
| 67 |
+
**License** See LICENSE.pdf for details.
|
| 68 |
+
|
| 69 |
+
## Intended Use
|
| 70 |
+
|
| 71 |
+
**Intended Use Cases** KernelLLM is intended for commercial and research use in English, relevant programming languages, Python, and Triton.
|
| 72 |
+
|
| 73 |
+
**Out-of-Scope Uses** Use in any manner that violates applicable laws or regulations (including trade compliance laws). Use in languages other than English. Use in any other way that is prohibited by the [Acceptable Use Policy](https://llama.meta.com/llama3/use-policy) and Licensing Agreement for KernelLLM and its variants.
|
| 74 |
+
|
| 75 |
+
## Hardware and Software
|
| 76 |
+
|
| 77 |
+
**Training Factors** We used custom training libraries.
|
| 78 |
+
|
| 79 |
+
**Carbon Footprint** In aggregate, training KernelLLM required 250 hours of computation on hardware of type A100-80GB (TDP of 350-400W), not including the training of the base model. 100% of the estimated tCO2eq emissions were offset by Meta’s sustainability program.
|
| 80 |
+
|
| 81 |
+
## Ethical Considerations and Limitations
|
| 82 |
+
|
| 83 |
+
KernelLLM and its variants are a new technology that carries risks with use. Testing conducted to date has been in English, and has not covered, nor could it cover all scenarios. For these reasons, as with all LLMs, KernelLLMs’s potential outputs cannot be predicted in advance, and the model may in some instances produce inaccurate or objectionable responses to user prompts. Therefore, before deploying any applications of KernelLLM, developers should perform safety testing and tuning tailored to their specific applications of the model.
|
| 84 |
+
|
| 85 |
+
Please see the Responsible Use Guide available available at [https://ai.meta.com/llama/responsible-use-guide](https://ai.meta.com/llama/responsible-use-guide).
|