Text Generation
Transformers
Safetensors
PyTorch
English
nemotron-nas
nvidia
llama-3
conversational
custom_code
Instructions to use nvidia/Llama-3_3-Nemotron-Super-49B-v1_5 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use nvidia/Llama-3_3-Nemotron-Super-49B-v1_5 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="nvidia/Llama-3_3-Nemotron-Super-49B-v1_5", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("nvidia/Llama-3_3-Nemotron-Super-49B-v1_5", trust_remote_code=True, dtype="auto") - Inference
- Local Apps Settings
- vLLM
How to use nvidia/Llama-3_3-Nemotron-Super-49B-v1_5 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "nvidia/Llama-3_3-Nemotron-Super-49B-v1_5" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "nvidia/Llama-3_3-Nemotron-Super-49B-v1_5", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/nvidia/Llama-3_3-Nemotron-Super-49B-v1_5
- SGLang
How to use nvidia/Llama-3_3-Nemotron-Super-49B-v1_5 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 "nvidia/Llama-3_3-Nemotron-Super-49B-v1_5" \ --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": "nvidia/Llama-3_3-Nemotron-Super-49B-v1_5", "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 "nvidia/Llama-3_3-Nemotron-Super-49B-v1_5" \ --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": "nvidia/Llama-3_3-Nemotron-Super-49B-v1_5", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use nvidia/Llama-3_3-Nemotron-Super-49B-v1_5 with Docker Model Runner:
docker model run hf.co/nvidia/Llama-3_3-Nemotron-Super-49B-v1_5
| # coding=utf-8 | |
| # Copyright 2024 Nvidia Corporation. All rights reserved. | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software | |
| # distributed under the License is distributed on an "AS IS" BASIS, | |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| # See the License for the specific language governing permissions and | |
| # limitations under the License. | |
| import dataclasses | |
| import warnings | |
| from typing import Dict, Any | |
| from transformers.utils import is_flash_attn_2_available | |
| from .block_config import BlockConfig | |
| from .transformers_4_44_2__configuration_llama import LlamaConfig | |
| from .transformers_4_44_2__modeling_rope_utils import \ | |
| rope_config_validation # fake import to make AutoConfig infer the dependency | |
| rope_config_validation # this line is here to make sure that auto-formatting doesn't remove the import | |
| class DeciLMConfig(LlamaConfig): | |
| model_type = "nemotron-nas" | |
| def __init__( | |
| self, | |
| block_configs: list[dict] | list[BlockConfig] = None, | |
| **kwargs, | |
| ): | |
| attn_implementation = kwargs.pop("attn_implementation", None) | |
| if attn_implementation is None and is_flash_attn_2_available(): | |
| attn_implementation = "flash_attention_2" | |
| if block_configs is not None: | |
| if isinstance(block_configs[0], dict): | |
| block_configs = [BlockConfig(**conf) for conf in block_configs] | |
| using_unshifted_sink = any([block_config.attention.unshifted_sink for block_config in block_configs]) | |
| if using_unshifted_sink and attn_implementation != "eager": | |
| warnings.warn("Forcing attn_implementation='eager' since some attention layers use unshifted sink") | |
| attn_implementation = "eager" | |
| super().__init__(attn_implementation=attn_implementation, **kwargs) | |
| self.intermediate_size = None | |
| self.num_key_value_heads = None | |
| if block_configs is not None: | |
| assert len(block_configs) == self.num_hidden_layers | |
| self.block_configs: list[BlockConfig] = block_configs | |
| def to_dict(self) -> Dict[str, Any]: | |
| self_dict = super().to_dict() | |
| if self.block_configs is not None: | |
| self_dict["block_configs"] = [dataclasses.asdict(conf) for conf in self.block_configs] | |
| return self_dict | |