Nemotron3-Nano

Nemotron3-Nano (NVIDIA)

Nemotron3-Nano는 NVIDIA의 30B 파라미터 하이브리드 LLM으로, 전통적인 "attention + MLP" 트랜스포머 블록 대신 MoE feed-forward 레이어, Mamba2 시퀀스 모델링 레이어, 표준 self-attention 레이어를 하나의 스택에 섞은 모델이에요. 이 페이지에서는 SGLang에서 Nemotron3-Nano를 설치·배포·호출하는 방법과 추론, 툴 호출, 벤치마크를 설명해요.

출처: 문서

본문

1. Model Introduction (모델 소개)

NVIDIA Nemotron3-Nano는 30B 파라미터 하이브리드 LLM으로, 전통적인 "attention + MLP" 트랜스포머 블록 대신 Mixture-of-Experts(MoE) feed-forward 레이어, Mamba2 시퀀스 모델링 레이어, 표준 self-attention 레이어를 하나의 스택에 섞어요.

BF16 변형(nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-BF16)은 고충실도 참조 모델로 설계되었어요. 최신 NVIDIA GPU에서 최적화된 추론 성능을 위해 FP8 변형(nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-FP8)과 NVFP4 변형(nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-NVFP4)을 지원해요.

개괄적으로:

  • 하이브리드 레이어 스택 (Mamba2 + MoE + attention): 네트워크는 Mamba2, MoE feed-forward, attention 전용 중 하나인 인터리브된 레이어로 구성돼요.
  • 비균일 레이어 순서: 이 특화 레이어들의 순서와 혼합은 단순하고 고정된 패턴이 아니며, 깊이에 따라 시퀀스 모델링, 라우팅 용량, 표현력을 교환할 수 있게 해줘요.
  • 배포 친화적 정밀도: 정확도에 민감한 평가 워크로드에는 BF16을, 최신 NVIDIA GPU에서 지연·처리량이 중요한 서빙에는 FP8을 사용해요.

2. SGLang Installation (SGLang 설치)

공식 SGLang 설치 가이드를 참고하거나, nightly wheel을 통해 설치해요.

uv pip install --prerelease=allow sglang==0.5.6.post3.dev1278+gad1b4e472 --extra-index-url https://sgl-project.github.io/whl/nightly/

3. Model Deployment (모델 배포)

이 섹션은 빠른 배포부터 성능 튜닝까지 단계별로 안내해요.

3.1 Basic Configuration

Nemotron3-Nano 시리즈는 NVIDIA GPU와 Intel Arc Pro B-Series GPU(코드명: BMG (Battlemage))를 포함한 다양한 하드웨어 플랫폼에 최적화된 여러 크기와 아키텍처의 모델을 제공해요.

인터랙티브 명령 생성기: 하드웨어, 모델 변형, 일반 노브를 선택해 실행 명령을 생성해요.

3.2 Configuration Tips

  • Attention backend:

    H200: 기본적으로 flash attention 3 backend 사용. B200: 기본적으로 flashinfer backend 사용.

  • TP 지원:

    tp 크기는 --tp <1|2|4|8>로 설정해요.

  • FP8 KV cache:

    fp8 kv cache를 활성화하려면 --kv-cache-dtype fp8_e4m3을 추가해요.

4. Model Invocation (모델 호출)

4.1 Basic Usage (OpenAI-Compatible API)

SGLang은 OpenAI 호환 엔드포인트를 제공해요. OpenAI Python 클라이언트 예제:

from openai import OpenAI

client = OpenAI(
    base_url="http://localhost:30000/v1",
    api_key="EMPTY",
)

resp = client.chat.completions.create(
    model="nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-FP8",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Summarize what MoE models are in 5 bullets."},
    ],
    temperature=0.7,
    max_tokens=256,
)

print(resp.choices[0].message.content)

스트리밍 채팅 완성

from openai import OpenAI

client = OpenAI(
    base_url="http://localhost:30000/v1",
    api_key="EMPTY",
)

stream = client.chat.completions.create(
    model="nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-FP8",
    messages=[
        {"role": "system", "content": "You are a helpful AI assistant."},
        {"role": "user", "content": "What are the first 5 prime numbers?"}
    ],
    temperature=0.7,
    max_tokens=1024,
    stream=True,
)
for chunk in stream:
    delta = chunk.choices[0].delta
    if delta and delta.content:
        print(delta.content, end="", flush=True)

4.2 Reasoning

추론을 활성화하려면 실행 명령에 --reasoning-parser nemotron_3을 추가해야 해요. 모델은 Reasoning ON(기본값) vs OFF의 두 가지 모드를 지원해요. 아래처럼 enable_thinking을 False로 설정해 전환할 수 있어요.

from openai import OpenAI

client = OpenAI(
    base_url="http://localhost:30000/v1",
    api_key="EMPTY",
)

# Reasoning on (default)
print("Reasoning on")
resp = client.chat.completions.create(
    model="nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-FP8",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Write a haiku about GPUs."}
    ],
    temperature=0.7,
    max_tokens=512,
)
print(resp.choices[0].message.reasoning_content)

# Reasoning off
print("Reasoning off")
resp = client.chat.completions.create(
    model="nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-FP8",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Write a haiku about GPUs."}
    ],
    temperature=0.6,
    max_tokens=256,
    extra_body={"chat_template_kwargs": {"enable_thinking": False}}
)
print(resp.choices[0].message.reasoning_content)

4.3 Tool calling

툴 호출을 활성화하려면 실행 명령에 --tool-call-parser qwen3_coder을 추가해야 해요. OpenAI Tools 스키마로 함수를 호출하고 반환된 tool_calls를 확인해요.

from openai import OpenAI

client = OpenAI(
    base_url="http://localhost:30000/v1",
    api_key="EMPTY",
)

# Tool calling via OpenAI tools schema
TOOLS = [
    {
        "type": "function",
        "function": {
            "name": "calculate_tip",
            "parameters": {
                "type": "object",
                "properties": {
                    "bill_total": {
                        "type": "integer",
                        "description": "The total amount of the bill"
                    },
                    "tip_percentage": {
                        "type": "integer",
                        "description": "The percentage of tip to be applied"
                    }
                },
                "required": ["bill_total", "tip_percentage"]
            }
        }
    }
]

completion = client.chat.completions.create(
    model="nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-FP8",
    messages=[
        {"role": "system", "content": ""},
        {"role": "user", "content": "My bill is $50. What will be the amount for 15% tip?"}
    ],
    tools=TOOLS,
    temperature=0.6,
    top_p=0.95,
    max_tokens=512,
    stream=False
)

print(completion.choices[0].message.reasoning_content)
print(completion.choices[0].message.tool_calls)

5. Benchmark (벤치마크)

5.1 Speed Benchmark (속도 벤치마크)

테스트 환경:

  • Hardware: NVIDIA B200 GPU

FP8 변형

  • 모델 배포 명령:
python3 -m sglang.launch_server \
  --model-path nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-FP8 \
  --trust-remote-code \
  --max-running-requests 1024 \
  --host 0.0.0.0 \
  --port 30000
  • 벤치마크 명령:
python3 -m sglang.bench_serving \
  --backend sglang \
  --host 127.0.0.1 \
  --port 30000 \
  --model nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-FP8 \
  --dataset-name random \
  --random-input-len 1024 \
  --random-output-len 1024 \
  --num-prompts 4096 \
  --max-concurrency 256
  • 테스트 결과:
============ Serving Benchmark Result ============
Backend:                                 sglang
Traffic request rate:                    inf
Max request concurrency:                 256
Successful requests:                     4096
Benchmark duration (s):                  183.18
Total input tokens:                      2081726
Total input text tokens:                 2081726
Total input vision tokens:               0
Total generated tokens:                  2116125
Total generated tokens (retokenized):    1076256
Request throughput (req/s):              22.36
Input token throughput (tok/s):          11364.25
Output token throughput (tok/s):         11552.04
Peak output token throughput (tok/s):    24692.00
Peak concurrent requests:                294
Total token throughput (tok/s):          22916.30
Concurrency:                             251.19
----------------End-to-End Latency----------------
Mean E2E Latency (ms):                   11233.74
Median E2E Latency (ms):                 11142.97
---------------Time to First Token----------------
Mean TTFT (ms):                          172.99
Median TTFT (ms):                        116.57
P99 TTFT (ms):                           1193.68
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms):                          21.74
Median TPOT (ms):                        21.14
P99 TPOT (ms):                           41.12
---------------Inter-Token Latency----------------
Mean ITL (ms):                           21.45
Median ITL (ms):                         9.06
P95 ITL (ms):                            62.59
P99 ITL (ms):                            110.83
Max ITL (ms):                            5368.19
==================================================

BF16 변형

  • 모델 배포 명령:
python3 -m sglang.launch_server \
  --model-path nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-BF16 \
  --trust-remote-code \
  --max-running-requests 1024 \
  --host 0.0.0.0 \
  --port 30000
  • 벤치마크 명령:
python3 -m sglang.bench_serving \
  --backend sglang \
  --host 127.0.0.1 \
  --port 30000 \
  --model nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-BF16 \
  --dataset-name random \
  --random-input-len 1024 \
  --random-output-len 1024 \
  --num-prompts 4096 \
  --max-concurrency 256
  • 테스트 결과:
============ Serving Benchmark Result ============
Backend:                                 sglang
Traffic request rate:                    inf
Max request concurrency:                 256
Successful requests:                     4096
Benchmark duration (s):                  360.22
Total input tokens:                      2081726
Total input text tokens:                 2081726
Total input vision tokens:               0
Total generated tokens:                  2087288
Total generated tokens (retokenized):    1940652
Request throughput (req/s):              11.37
Input token throughput (tok/s):          5779.10
Output token throughput (tok/s):         5794.55
Peak output token throughput (tok/s):    9169.00
Peak concurrent requests:                276
Total token throughput (tok/s):          11573.65
Concurrency:                             249.76
----------------End-to-End Latency----------------
Mean E2E Latency (ms):                   21965.10
Median E2E Latency (ms):                 21706.35
---------------Time to First Token----------------
Mean TTFT (ms):                          211.54
Median TTFT (ms):                        93.06
P99 TTFT (ms):                           2637.66
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms):                          43.27
Median TPOT (ms):                        43.04
P99 TPOT (ms):                           61.15
---------------Inter-Token Latency----------------
Mean ITL (ms):                           42.77
Median ITL (ms):                         28.46
P95 ITL (ms):                            71.85
P99 ITL (ms):                            113.20
Max ITL (ms):                            5237.28
==================================================

5.2 Accuracy Benchmark (정확도 벤치마크)

5.2.1 GSM8K Benchmark

환경

  • Hardware: NVIDIA B200 GPU
  • Model: BF16 checkpoint

모델 실행

python3 -m sglang.launch_server \
  --model-path nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-BF16 \
  --trust-remote-code \
  --reasoning-parser nemotron_3

lm-eval로 벤치마크 실행

pip install lm-eval[api]==0.4.9.2

lm_eval --model local-completions --tasks gsm8k --model_args "model=nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-BF16,base_url=http://127.0.0.1:30000/v1/completions,num_concurrent=4,max_retries=3,tokenized_requests=False,max_lengths=16384" --gen_kwargs '{"chat_template_kwargs":{"thinking":true}}' --batch_size 256

테스트 결과:

|Tasks|Version|     Filter     |n-shot|  Metric   |   |Value |   |Stderr|
|-----|------:|----------------|-----:|-----------|---|-----:|---|-----:|
|gsm8k|      3|flexible-extract|     5|exact_match|↑  |0.5603|±  |0.0137|
|     |       |strict-match    |     5|exact_match|↑  |0.8453|±  |0.0100|

더 알아보기 (Learn more)