Instructions to use Qwen/Qwen-72B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Qwen/Qwen-72B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Qwen/Qwen-72B", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen-72B", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Qwen/Qwen-72B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Qwen/Qwen-72B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Qwen/Qwen-72B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Qwen/Qwen-72B
- SGLang
How to use Qwen/Qwen-72B 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 "Qwen/Qwen-72B" \ --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": "Qwen/Qwen-72B", "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 "Qwen/Qwen-72B" \ --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": "Qwen/Qwen-72B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Qwen/Qwen-72B with Docker Model Runner:
docker model run hf.co/Qwen/Qwen-72B
_set_gradient_checkpointing() got an unexpected keyword argument 'enable'
#3
by ehartford - opened
I have worked around this by modifying modeling_qwen.py as follows:
def _set_gradient_checkpointing(self, enable: bool = False, gradient_checkpointing_func: Callable = None):
is_gradient_checkpointing_set = False
if isinstance(self, QWenModel):
self.gradient_checkpointing = enable
self._gradient_checkpointing_func = gradient_checkpointing_func
is_gradient_checkpointing_set = True
for module in self.modules():
if isinstance(module, QWenModel):
module.gradient_checkpointing = enable
module._gradient_checkpointing_func = gradient_checkpointing_func
is_gradient_checkpointing_set = True
if not is_gradient_checkpointing_set:
raise ValueError(f"{self.__class__.__name__} is not compatible with gradient checkpointing. Make sure all the architecture support it by setting a boolean attribute 'gradient_checkpointing' to modules of the model that uses checkpointing.")
@ehartford
Hello!
I am not creator of this model,
But I solved this problem, so I want to share my solution.
My solution is check the your transformers module version, such that pip install transformers==4.34.0
Thank you!
That's not a solution when you are using software that requires latest transformers