Skip to main content
NVIDIA
Explore
Models
Skills
Blueprints
GPUs
Docs
Help Center
Getting Started
  1. Create and verify your account to unlock full access to NVIDIA NIM APIs.
ResourcesDeveloper ForumsContact Support
FAQs
  • View All Playbooks
    View All Playbooks

    onboarding

    • Connect Two DGX Stations for Distributed Workloads
    • MIG on DGX Station

    data science

    • Topic Modeling
    • Build Knowledge Graphs with txt2kg

    tools

    • Quantize Models to NVFP4 with NVIDIA Model Optimizer

    fine tuning

    • Train a Chat Model with NanoChat
    • NVFP4 Pretraining with Megatron Bridge

    use case

    • Run NemoClaw with a Local LLM
    • DGX Station AI Skills and dgx-assist
    • Secure AI Agents with OpenShell
    • Local Coding Agent
    • Profiler-Driven Kernel Optimization for Fine-Tuning
    • Local Healthcare Agent on DGX Station

    inference

    • Serve LLMs with vLLM
    • Generate Images and Videos with ComfyUI
    • Isaac GR00T N1.6 Fine-Tuning
    • Serve LLMs with SGLang

    Profiler-Driven Kernel Optimization for Fine-Tuning

    2 HRS

    Use torch.profiler to find training bottlenecks, then write custom Triton kernels to optimize LLaMA 8B fine-tuning

    • DGX Station
    • Fine-Tuning
    • GB300
    • Kernel Development
    • LLaMA
    • Performance Optimization
    • Training
    • Triton
    View on GitHub
    OverviewOverviewInstructionsInstructionsTroubleshootingTroubleshooting
    SymptomCauseFix
    ModuleNotFoundError: No module named 'triton'Container missing TritonUse the kernel-dev-ft container built from the playbook's Dockerfile. Triton ships with PyTorch NGC containers. Verify: python -c "import triton; print(triton.__version__)".
    triton.compiler.errors.CompilationError referencing sm_100Triton version too old for BlackwellUse PyTorch NGC container 26.01+ which includes Triton with Blackwell support. Check: python -c "import triton; print(triton.__version__)".
    Cross-entropy BF16 test fails on loss or gradientBF16 + 128K vocab accumulate drift vs PyTorch's CE pathcross_entropy_test.py uses relaxed loss tolerances and compares gradients in float32 with wider atol/rtol. If it still fails, check PyTorch / CUDA versions; file an issue with torch.__version__.
    RuntimeError: Trace is already saved from profilerAn older profile_baseline.py saved the same trace twice in one run (TensorBoard on_trace_ready handler and a manual export_chrome_trace); on PyTorch 2.10 kineto enforces save-onceUse the current profile_baseline.py, which exports the Chrome trace exactly once. This is an in-process double-save, not a stale-directory issue — deleting traces/* does not fix the older script.
    torch.cuda.OutOfMemoryError during baseline profilingBatch size or sequence length too largeReduce --batch-size or --seq-len in profile_baseline.py. LLaMA 3.1 8B in BF16 needs ~16 GB for weights alone, plus ~32 GB for AdamW optimizer states.
    torch.cuda.OutOfMemoryError during PyTorch cross-entropy but NOT during custom kernelStandard cross-entropy materializes full [B*T, V] logit tensorThis demonstrates exactly why the custom kernel is needed. Reduce batch size or sequence length for the baseline comparison, or run only the custom kernel path.
    Profiler trace JSON is very large (>1 GB)Too many training steps profiledReduce wait, warmup, active in the profiler schedule. The default script profiles only 1 active step.
    401 Client Error when downloading LLaMA 3.1 8BMissing or invalid Hugging Face token, or no LLaMA accessSet HF_TOKEN environment variable. Accept the LLaMA 3.1 license at https://huggingface.co/meta-llama/Llama-3.1-8B. Verify token: huggingface-cli whoami.
    Custom RMSNorm backward produces NaN gradientsEpsilon value too small or input contains extreme valuesEnsure epsilon is 1e-6 (LLaMA default). Check input tensor for NaN/Inf with torch.isfinite(x).all().
    Benchmark shows no speedup for RMSNorm on small hidden dimensionsKernel launch overhead dominates for small tensorsRMSNorm speedup is most visible at hidden_size >= 2048. LLaMA 3.1 8B uses 4096, which is well above the threshold.
    docker: Error response from daemon: could not select device driverNVIDIA Container Toolkit not installed or Docker not restartedInstall: sudo apt install nvidia-container-toolkit && sudo systemctl restart docker. Verify: docker run --rm --gpus all nvidia/cuda:12.8.0-base-ubuntu24.04 nvidia-smi.
    Fused cross-entropy loss differs from PyTorch by more than 0.1Bug in the chunked online softmax implementationVerify the running-max update: m_new = max(m_old, chunk_max) must happen BEFORE updating the running sum-of-exp d. Check that the target index masking uses the correct chunk offset.
    Fine-tuning throughput is not improved despite faster kernelsGPU is compute-bound on matmuls, not bandwidth-bound on norms/lossThis is expected if batch size is large enough that matmuls dominate. The primary benefit is memory reduction (enabling larger batches or longer sequences) rather than pure latency.
    ImportError: cannot import name 'LlamaForCausalLM'transformers library version too oldUpdate: pip install --upgrade transformers>=4.45.0. The container's Dockerfile pins a compatible version.
    Chrome trace file won't open in browserTrace file too large for chrome://tracingUse Perfetto UI instead, which handles larger traces. Or reduce the number of profiled steps.

    Resources

    • Triton Language Documentation
    • PyTorch Profiler Documentation
    • Liger-Kernel (reference implementations)
    • Blackwell Architecture Tuning Guide
    • NVIDIA Nsight Systems
    Terms of Use
    Privacy Policy
    Your Privacy Choices
    Contact

    Copyright © 2026 NVIDIA Corporation