warp-debug-gradients

Diagnose and fix incorrect gradients in differentiable NVIDIA Warp programs.

3.2k|370|Updated Feb 25, 2026
One-click install
npx skills add https://github.com/NVIDIA/skills --skill warp-debug-gradients
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: warp-debug-gradients
Source: https://github.com/NVIDIA/skills/tree/main/skills/warp-debug-gradients
Command: npx skills add https://github.com/NVIDIA/skills --skill warp-debug-gradients

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires warp-lang, and includes references (resource) components.

What problem does it solve?

Differentiable simulations and training loops built on NVIDIA Warp often fail silently: the forward pass looks healthy while wp.Tape gradients are zero, NaN, doubled, or subtly wrong due to taping-pattern bugs like buffer reuse, missing requires_grad, or faulty custom adjoints. This Skill provides an evidence-driven workflow to verify gradients against finite differences, localize the root cause, and apply a minimal verified fix.

Core Features & Use Cases

  • Finite-difference verification: Establishes ground truth with wp.autograd.gradcheck and the overwrite tracker (wp.config.verify_autograd_array_access) before hypothesizing causes.
  • Failure-signature diagnosis: Matches observed gradient symptoms (zero, NaN/inf, exact-factor errors, scale-dependent corruption) to a ranked hypothesis table and a known-bug-pattern checklist.
  • Custom gradient guidance: Covers @wp.func_grad, @wp.func_replay, and @wp.func_native usage, misuse patterns, and straight-through estimators for piecewise-constant ops.
  • Use Case: A user's cloth simulation training loss creeps back up despite learning-rate tuning; the Skill shrinks the repro, detects a write-after-read overwrite from ping-pong state buffers, fixes the dataflow with distinct per-step buffers, and re-verifies with the same FD harness.

Quick Start

Ask your agent to debug why training through your Warp kernels diverges or produces wrong gradients, pointing it at your reproduction script.

Frequently Asked Questions about warp-debug-gradients

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I debug wrong gradients in NVIDIA Warp?

Enable wp.config.verify_autograd_array_access under an active tape to catch write-after-read overwrites, then run an end-to-end wp.autograd.gradcheck comparing autodiff against finite differences at the true optimization inputs. Match the error signature (zero, NaN, exact factor, subtle drift) to known bug patterns before fixing.

Why are my Warp gradients exactly zero during training?

Common causes include missing requires_grad=True on an array in the chain (wp.zeros defaults to False), enable_backward=False, a loss not connected to the tape, or reading grads after tape.zero(). Piecewise-constant ops like wp.round also correctly produce zero gradients, requiring a straight-through estimator instead.

Does Warp gradient debugging work on CPU-only machines?

Yes. Diagnosis runs the user's reproduction on any functioning device, CPU or CUDA, and the bug classes involved (overwrites, missing requires_grad, double accumulation) are taping properties independent of device. Only float atomic accumulation ordering differs between CPU and CUDA.

What Warp version is required for gradient verification tools?

Warp >= 1.13 is the minimum, with >= 1.17 recommended for reliable verification. Copy-adjoint accumulation, overwrite-warning call sites, read-flag lifetime, and gradcheck's restore_inputs behavior changed in 1.17, so older versions need manual harness workarounds.

When should I not use Warp gradient debugging?

Do not use it for forward-only Warp work such as kernel authoring, rendering, or performance tuning, Warp build or installation problems, or autograd issues in other frameworks like pure PyTorch with no Warp involvement.

Why does gradcheck pass per-kernel but end-to-end gradients are wrong?

wp.autograd.gradcheck_tape validates each recorded launch in isolation, so it is structurally blind to inter-kernel overwrite bugs and silently skips kernels compiled with enable_backward=False. A clean per-kernel pass with wrong end-to-end gradients points at the taping pattern between kernels.