.. meta::
   :description: Quickstart for SGLang-Neuron. Start the SGLang-Neuron container image on a trn3.48xlarge instance, serve Qwen3-8B, and send an OpenAI-compatible chat request.
   :keywords: SGLang, SGLang-Neuron, quickstart, Qwen3-8B, AWS Neuron, Trainium3, Trn3, trn3.48xlarge, container image, chat completions
   :date-modified: 2026-11-16

.. _sglang-neuron-quickstart:

Quickstart: Serve Qwen3-8B with SGLang-Neuron
=============================================

.. note::

   SGLang-Neuron is in public preview. Features, APIs, and supported models can change in later releases.

**Applies to:** trn3.48xlarge

In this quickstart, you start the SGLang-Neuron container image on one trn3.48xlarge instance, serve Qwen3-8B on four NeuronCores, and send a chat request to the server. Then you stop the server.

This quickstart takes approximately 30 minutes. The first start of the model compiles its programs, which takes most of that time.

Prerequisites
-------------

Before you begin, make sure that you have:

- A trn3.48xlarge instance with Docker Engine.
- The Neuron driver of Neuron SDK 2.33.0 (``aws-neuronx-dkms`` 2.31.7.0 or later) on the host.
- A bash shell. The commands rely on bash to split ``$DEVICES`` into separate arguments. zsh does not do this.
- Internet access from the instance, to pull the image and download the checkpoint.
- Approximately 50 GB of free disk space for the container image and the Qwen3-8B checkpoint.

Step 1: Check the host
----------------------

In this step, you make sure that the Neuron driver is ready.

On the host, list the Neuron devices:

.. code-block:: bash

   ls /dev/neuron*

The command lists one device for each Neuron chip. If it lists no devices, install or load the Neuron driver. On a host that just started, the driver can need a few minutes before it is ready.

Step 2: Set the variables and pull the image
--------------------------------------------

In this step, you set the shell variables that the next steps use, and you pull the container image.

1. Set the variables. Replace ``/path/to/models`` and ``/path/to/cache`` with directories on the host:

   .. code-block:: bash

      IMAGE=public.ecr.aws/neuron/pytorch-inference-sglang-neuron:v0.1.0-neuron-py314-sdk-2.33.0-ubuntu26.04
      MODELS=/path/to/models                 # the checkpoints, mounted at /models
      CACHE=/path/to/cache                   # the compile cache: persistent and local, one directory per image version
      DEVICES=$(for d in /dev/neuron*; do printf -- '--device %s ' "$d"; done)

2. Pull the image:

   .. code-block:: bash

      docker pull $IMAGE

3. Make sure that the container finds the Neuron devices:

   .. code-block:: bash

      docker run --rm $DEVICES $IMAGE neuron-ls

   ``neuron-ls`` lists the same devices as ``ls /dev/neuron*`` on the host.

Step 3: Download the checkpoint
-------------------------------

In this step, you download the Qwen3-8B checkpoint from Hugging Face with the ``hf`` CLI in the image:

.. code-block:: bash

   docker run --rm -v $MODELS:/models $IMAGE hf download Qwen/Qwen3-8B --local-dir /models/Qwen3-8B

Step 4: Start the server
------------------------

In this step, you start the server in a container. The container runs the Qwen3-8B example script from the image, ``run_server.sh``. The script starts one server that does both prefill and decode, at tensor parallelism 4 (TP4) on four NeuronCores.

1. Start the container:

   .. code-block:: bash

      docker run -d --name qwen3-8b --init --ipc=host --cap-add SYS_NICE $DEVICES \
        -v $MODELS:/models:ro -v $CACHE:/cache -p 127.0.0.1:30000:30000 -e HOST=0.0.0.0 \
        $IMAGE /opt/sglang-neuron/examples/qwen3_8b/run_server.sh

   ``-p 127.0.0.1:30000:30000`` publishes the server port on the loopback address of the host only. ``HOST=0.0.0.0`` lets the published port reach the server in the container.

2. Wait until the server answers ``/health``:

   .. code-block:: bash

      until curl -sf http://127.0.0.1:30000/health; do
        [ "$(docker inspect -f '{{.State.Running}}' qwen3-8b)" = true ] || { echo "exited: docker logs qwen3-8b"; break; }
        sleep 10; done

   The first start on a new compile cache compiles the model programs. To see the progress, run ``docker logs -f qwen3-8b`` in a different shell. The server is ready when its log shows ``The server is fired up and ready to roll!``.

Step 5: Send a chat request
---------------------------

In this step, you send a request to the OpenAI-compatible ``/v1/chat/completions`` endpoint. The request turns off the thinking mode of Qwen3:

.. code-block:: bash

   curl -s http://127.0.0.1:30000/v1/chat/completions -H 'Content-Type: application/json' -d '{
     "model": "/models/Qwen3-8B", "temperature": 0, "max_tokens": 64,
     "chat_template_kwargs": {"enable_thinking": false},
     "messages": [{"role": "user", "content": "What is 17 * 23? Answer with the number."}]}'

The request sets ``temperature`` to 0, because the plug-in samples greedily by default. To serve sampled requests, see the ``SGLANG_NEURON_SAMPLER`` variable in :ref:`sglang-neuron-configuration-ref`.

Confirmation
------------

The answer contains this text:

.. code-block:: text

   17 * 23 = 391

To check the accuracy of the server, run the GSM8K check from the image. The check sends the first 100 GSM8K questions to the server and prints ``Accuracy``. For Qwen3-8B, expect an accuracy of approximately 0.92:

.. code-block:: bash

   docker run --rm --network host -e PORT=30000 $IMAGE /opt/sglang-neuron/examples/qwen3_8b/run_gsm8k.sh

Common issues
-------------

- **The server exits at start with** ``the compile cache ... was built from other NKI kernel sources``. The cache directory belongs to a different image version. Give this image its own cache directory.
- **The server fails with** ``Failed to load the backend extension: torch_neuronx``. A volume is mounted at ``/workspace``. Mount your data at a different path.
- **Neuron runtime errors on a host that just started.** The Neuron driver is not ready. Wait until ``ls /dev/neuron*`` lists the devices.

For more problems and fixes, see :ref:`sglang-neuron-tshoot`.

Clean up
--------

Stop and remove the container:

.. code-block:: bash

   docker stop -t 120 qwen3-8b && docker rm qwen3-8b

The server drains and stops every rank when it gets the stop signal. The default Docker timeout of 10 seconds can be too short, so the command sets 120 seconds.

The compile cache stays in ``$CACHE``. The next start of Qwen3-8B with the same cache directory loads the compiled programs.

Next steps
----------

- :ref:`Tutorial: Serve GPT-OSS-120B with prefill-decode disaggregation <sglang-neuron-gpt-oss-disaggregated-tutorial>`
- :ref:`Tutorial: Serve a multi-turn chat with Kimi-K3 <sglang-neuron-kimi-k3-multi-turn-tutorial>`
- :ref:`SGLang-Neuron configuration reference <sglang-neuron-configuration-ref>`

Further reading
---------------

- :ref:`What is SGLang-Neuron? <sglang-neuron-overview>`
- :ref:`SGLang-Neuron supported models <sglang-neuron-supported-models-ref>`
- `Container guide in the sglang-neuron repository <https://github.com/sgl-project/sglang-neuron/blob/main/docs/guides/container.md>`__
