Guides and tutorials
====================

Step-by-step guides that use Neuron Explorer to identify one kind of performance bottleneck and fix it, and tutorials that profile a complete workload from capture to analysis, by hand or with the :doc:`Neuron Agentic Development </tools/neuron-agentic-development/index>` skills.

Optimization guides
-------------------

Each guide takes one bottleneck from a profile to a fix: how to recognize it, which viewers to use, what the measurements mean, and what improved after the change.

.. grid:: 2
   :gutter: 2

   .. grid-item-card:: Reduce host-to-device transfer overhead
      :link: how-to-reduce-host-to-device-transfer-overhead
      :link-type: doc
      :class-header: sd-bg-primary sd-text-white

      Find host-to-device copies that leave the device idle in a system profile, and remove them by keeping buffers on the device.

   .. grid-item-card:: Reduce device-to-host transfer overhead
      :link: how-to-reduce-device-to-host-transfer-overhead
      :link-type: doc
      :class-header: sd-bg-primary sd-text-white

      Find device-to-host copies that leave the device idle in a system profile, and reduce results on the device before copying them back.

   .. grid-item-card:: Reduce inefficient DMA transfers
      :link: how-to-reduce-inefficient-dma-transfers
      :link-type: doc
      :class-header: sd-bg-primary sd-text-white

      Find small, inefficient DMA transfers in a device profile, and move more data per transfer.

Tutorials and related guides
----------------------------

.. grid:: 2
   :gutter: 2

   .. grid-item-card:: Profile a NKI kernel
      :link: /nki/guides/use-neuron-profile
      :link-type: doc
      :class-header: sd-bg-primary sd-text-white

      Capture a device profile of a NKI kernel, link instructions back to the kernel source, and mark kernel phases as NKI regions.

   .. grid-item-card:: NKI performance guide
      :link: /nki/deep-dives/nki_perf_guide
      :link-type: doc
      :class-header: sd-bg-primary sd-text-white

      How to reason about the performance of a NKI kernel: engine utilization, data movement, and the optimizations that address each bottleneck.

   .. grid-item-card:: Profile a vLLM inference workload
      :link: /tools/tutorials/performance-profiling-vllm
      :link-type: doc
      :class-header: sd-bg-primary sd-text-white

      Serve a model with the vLLM Neuron plugin, capture system and device profiles with the built-in profiler interface, and open them in Neuron Explorer.

   .. grid-item-card:: Profile vLLM Neuron workloads
      :link: /vllm-neuron/docs/guides/how-to-profile-workloads
      :link-type: doc
      :class-header: sd-bg-primary sd-text-white

      Capture profiles on a live vLLM server with the ``/start_profile`` and ``/stop_profile`` endpoints, including iteration control and disaggregated inference.

   .. grid-item-card:: Capture prefill and decode profiles with an agent
      :link: /tools/neuron-agentic-development/tutorials/profiling-vllm-neuron-tutorial
      :link-type: doc
      :class-header: sd-bg-primary sd-text-white

      Use the Neuron Agentic Development Profiling skill to capture a vLLM Neuron server's prefill and steady-state decode as separate device and system profiles.

   .. grid-item-card:: Analyze a profile with an agent
      :link: /tools/neuron-agentic-development/tutorials/profile-analysis-vllm-neuron-tutorial
      :link-type: doc
      :class-header: sd-bg-primary sd-text-white

      Use the Profile Analysis skill on a capture: which graphs ran, a step's roofline floors and binding engine, its collective share, and which model component is responsible.

.. toctree::
   :hidden:
   :maxdepth: 1

   Reduce host-to-device transfer overhead <how-to-reduce-host-to-device-transfer-overhead>
   Reduce device-to-host transfer overhead <how-to-reduce-device-to-host-transfer-overhead>
   Reduce inefficient DMA transfers <how-to-reduce-inefficient-dma-transfers>
