Instructions to use tiiuae/falcon-40b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use tiiuae/falcon-40b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="tiiuae/falcon-40b", trust_remote_code=True)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("tiiuae/falcon-40b", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("tiiuae/falcon-40b", trust_remote_code=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use tiiuae/falcon-40b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "tiiuae/falcon-40b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "tiiuae/falcon-40b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/tiiuae/falcon-40b
- SGLang
How to use tiiuae/falcon-40b 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 "tiiuae/falcon-40b" \ --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": "tiiuae/falcon-40b", "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 "tiiuae/falcon-40b" \ --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": "tiiuae/falcon-40b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use tiiuae/falcon-40b with Docker Model Runner:
docker model run hf.co/tiiuae/falcon-40b
how much Vram does it take to run Falcon 40b
how much Vram/Hotswap Ram does it take to run Falcon 40b any1 got idears??
157G
? what cards? how is that Vram or RAM?
Depends on if you want to do inference in 32, 16, 8 or 4 bit, but at full 32 bit I think it's about 80GB of VRAM.
Correction: 16 bit is 80ish GB and 32 bit would be around 160ish GB I believe. Thanks Mikael110 was thinking about 16 bit and not 32 when I wrote this.
With 8bit loading it consumes ~46GB of VRAM, and with 4bit loading it takes ~24GB VRAM. Those numbers exclude OS headroom, so don't expect 4bit to fit on actual 24GB cards, and 8bit will be a tight squeeze on 48GB cards, you will probably OOM once the context gets even remotely long. I can't give numbers for 16bit and 32bit since they OOM on the A100 80GB which I was testing on. But given that even 16bit is too big for the card I'm quite confident that 32bit is quite a bit larger than 80GB. Maybe that's the number leoapolonio was referencing? I could definitively see it actually being that high for full 32bit inference.
THANK YOU!
Hi, the model is trained in bfloat16, not float32 - you need 40B x 2 byte per param = ~80Go to run it
We recommend 80-100GB to run inference on Falcon-40B comfortably.