[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M71MRWK4XX2D1643NSN7TTY8":3,"skill-same:01M71MRWK4XX2D1643NSN7TTY8":103},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":39,"linkOnly":40,"markdownContent":41,"markdownBody":42,"frontMatter":43,"refName":52,"commitSha":53,"skillDirectory":54,"forksCount":14,"repositoryHtmlUrl":55,"repositoryHomepageUrl":56,"ownerHtmlUrl":57,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":58,"install":59,"resources":72},"01M71MRWK4XX2D1643NSN7TTY8","dali-dynamic-mode",null,"DALI imperative dynamic mode (`nvidia.dali.experimental.dynamic`, ndd): use when working on ndd code or migrating pipelines; skip pipeline-only tasks.","pattanation\u002FNorvik","pattanation","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F235419268?v=4","01M71M5THHYYB15ME8R2E4FCZG","Patta","01M71M5TJM1NDM992M8PDKYR2K",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fpattanation\u002FNorvik\u002Fblob\u002Fclaude\u002Finstall-gsd-build-foQdV\u002F.agents\u002Fskills\u002Fdali-dynamic-mode\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38],"mode","dali dynamic mode","dali","data","gpu","deep-learning","team","tasks","code","when","use","only","python","learning","pipeline","loading","data-processing","NVIDIA","processing","deep","2026-11-10 10:56:23",false,"---\nname: dali-dynamic-mode\ndescription: \"DALI imperative dynamic mode (`nvidia.dali.experimental.dynamic`, ndd): use when working on ndd code or migrating pipelines; skip pipeline-only tasks.\"\nlicense: Apache-2.0\nmetadata:\n  author: \"DALI Team \u003Cdali-team@nvidia.com>\"\n  tags:\n    - dali\n    - dynamic-mode\n    - ndd\n    - data-loading\n    - data-processing\n    - gpu-processing\n  languages:\n    - python\n  team: dali\n  domain: deep-learning\n---\n\n# DALI Dynamic Mode\n\n## Purpose\n\nGuide AI agents in writing, reviewing, and migrating code that uses DALI's imperative dynamic-mode API, `nvidia.dali.experimental.dynamic` (`ndd`).\n\n## Instructions\n\n- Import dynamic mode as `nvidia.dali.experimental.dynamic as ndd` and write code as direct `ndd` calls in ordinary Python; do not use pipeline-mode APIs such as `Pipeline`, `@pipeline_def`, `pipe.build()`, or `pipe.run()`.\n- Treat readers as stateful: create them once, reuse them across epochs, and pass `batch_size` to `next_epoch(...)`.\n- Pass explicit `batch_size` to random ops; there is no pipeline-level batch size to inherit.\n- Use dynamic-mode API conventions: `device=\"gpu\"` instead of pipeline-mode `\"mixed\"`, `Batch.tensors[...]` for sample selection, and `Batch.slice[...]` for per-sample slicing.\n- Use `.torch()` to convert a tensor or batch to a PyTorch tensor. Use `pad=True` for batches with variable shapes.\n\n## Prerequisites\n\n- To run or validate code, NVIDIA DALI must be installed with dynamic mode importable as `nvidia.dali.experimental.dynamic`.\n- GPU decode or GPU operators require a CUDA-capable DALI build and an available NVIDIA GPU\u002Fdriver.\n- Framework conversion examples require the target framework installed, such as PyTorch for `.torch()`.\n\n## Introduction\n\nDynamic mode is DALI's imperative Python API. It lets code call DALI operators directly from normal Python control flow instead of building and running a pipeline graph.\n\n## Core Data Types\n\n### Tensor -- single sample\n\n```python\nt = ndd.tensor(data)           # copy\nt = ndd.as_tensor(data)        # wrap, no copy if possible\nt.cpu()                        # move to CPU\nt.gpu()                        # move to GPU\nt.torch(copy=False)            # conversion to PyTorch tensor with no copy (default)\nt[1:3]                         # slicing supported\nnp.asarray(t)                  # NumPy via __array__ (CPU only)\n```\n\nSupports `__dlpack__`, `__cuda_array_interface__`, `__array__`, arithmetic operators.\n\n### Batch -- collection of samples (variable shapes OK)\n\n```python\nb = ndd.batch([arr1, arr2])    # copy\nb = ndd.as_batch(data)         # wrap, no copy if possible\n```\n\n**Batch has no `__getitem__`** -- `batch[i]` raises `TypeError` because indexing is ambiguous (sample selection vs. per-sample slicing). Use the explicit APIs instead:\n\n| Intent | Method | Returns |\n|--------|--------|---------|\n| Get sample i | `batch.tensors[i]` | `Tensor` |\n| Get subset of samples | `batch.tensors[slice_or_list]` | `Batch` |\n| Slice within each sample | `batch.slice[...]` | `Batch` (same batch_size) |\n| Sample-wise slicing | `batch.slice[batch_of_indices]` | `Batch` (same batch_size) |\n\n`.tensors[]` picks **which samples**. `.slice` indexes **inside each sample**.\n\n```python\nxy = ndd.random.uniform(batch_size=16, range=[0, 1], shape=2)\ncrop_x = xy.slice[0]       # Batch of 16 scalars, first element from each sample\ncrop_y = xy.slice[1]       # Batch of 16 scalars, second element from each sample\nsample_0 = xy.tensors[0]   # Tensor, the entire first sample [x, y]\n```\n\n### Advanced slicing\n\nThe `.slice[]` API accepts batches of indices, allowing the user to mix and match batches and\nscalar values, e.g.:\n```python\nimgs = ndd.imread(filenames)  # a batch of images, if `filenames` is a list\nsliced = imgs.slice[\n    42 :  # the range start is broadcast to all samples\n    ndd.batch(imgs.shape).slice[0] \u002F\u002F 2  # per-sample range stop (half of each image)\n]\n```\n\n**PyTorch conversion:**\n- `batch.torch()` -- works for uniform shapes; raises for ragged batches\n- `batch.torch(pad=True)` -- zero-pads ragged batches to max shape (use for variable-length audio, detection boxes, etc.)\n- `batch.torch(copy=None)` is the default (avoids copy if possible)\n- Batch has **no `__dlpack__`** -- use `ndd.as_tensor(batch)` first for DLPack consumers. `ndd.as_tensor` supports `pad` as well.\n- `Tensor.torch(copy=False)` is default (no copy)\n\n**Iteration:** `for sample in batch:` yields Tensors.\n\n## Readers\n\nReaders are **stateful objects** -- create once, reuse across epochs. This matters because readers track internal state like shuffle order and shard position.\n\n```python\nreader = ndd.readers.File(file_root=image_dir, random_shuffle=True)\n\nfor epoch in range(num_epochs):\n    for jpegs, labels in reader.next_epoch(batch_size=64):\n        # jpegs, labels are Batch objects\n        ...\n```\n\nKey points:\n- Reader outputs (jpegs, labels, etc.) are **CPU** tensors\u002Fbatches. Labels typically stay on CPU until you convert them for your framework (e.g. `labels.torch().to(device)`).\n- Reader classes are **PascalCase**: `ndd.readers.File(...)`, `ndd.readers.COCO(...)`, `ndd.readers.TFRecord(...)`\n- `batch_size` goes to `next_epoch()`, not to the reader constructor\n- `next_epoch(batch_size=N)` yields tuples of `Batch`; `next_epoch()` without batch_size yields tuples of `Tensor`\n- The iterator from `next_epoch()` must be fully consumed before calling `next_epoch()` again\n- Once a reader is used with a given batch_size, it cannot be changed. Similarly, a reader used in batch mode cannot switch to sample mode or vice versa.\n\nSharded reading for distributed training:\n```python\nreader = ndd.readers.File(\n    file_root=image_dir,\n    shard_id=rank, num_shards=world_size,\n    stick_to_shard=True,\n    pad_last_batch=True,\n)\n```\n\n## Device Handling\n\n- Device is **inferred from inputs** -- GPU if any input is on GPU\n- For hybrid decode: use `device=\"gpu\"` (NOT `\"mixed\"`). The `\"mixed\"` keyword is a pipeline-mode concept for implicit CPU-to-GPU transfer; in dynamic mode, passing `device=\"gpu\"` triggers the same hardware-accelerated decode path.\n- Don't call `.cpu()` before passing to a GPU model -- `.torch()` gives you a GPU tensor directly. `.cpu()` is only needed for consumers requiring host memory (numpy, `__array__`).\n- CUDA stream sync between DALI and PyTorch is **automatic via DLPack** -- no manual stream management needed.\n\n## Execution Model\n\nDefault mode is `eager` -- async execution in a background thread, returns immediately.\n\n**No `.evaluate()` needed in most cases.** Any data consumption (`.torch()`, `__dlpack__`, `__array__`, `.shape`, property access, iteration) triggers evaluation automatically.\n\nFor debugging, switch to synchronous mode so errors surface at the exact call site rather than later in the async queue:\n\n```python\nwith ndd.EvalMode.sync_cpu:\n    images = ndd.decoders.image(jpegs, device=\"gpu\")\n    images = ndd.resize(images, size=[224, 224])\n    # Any error surfaces here, at the exact op that failed\n```\n\nModes (increasing synchronicity): `deferred` \u003C `eager` \u003C `sync_cpu` \u003C `sync_full`\n\nUse `EvalMode.sync_full` for debugging instead of scattering `.evaluate()` calls -- it's cleaner and catches all issues at once. `sync_cpu` is often sufficient and lighter than `sync_full`.\n\n## Thread Configuration\n\n```python\nndd.set_num_threads(4)  # Call once at startup, only if necessary to override the defaults\n```\n\nControls DALI's internal worker threads for CPU operators. Defaults to CPU affinity count or `DALI_NUM_THREADS` env var. Unrelated to Python-level threading.\n\n## RNG\n\nTwo approaches (use one, not both):\n\n```python\n# Approach 1: set the thread-local default seed (simple, good enough for most cases)\nndd.random.set_seed(42)\nangles = ndd.random.uniform(batch_size=64, range=(-30, 30))\n\n# Approach 2: explicit RNG object (finer control, pass rng= to each op)\nrng = ndd.random.RNG(seed=42)\nvalues = ndd.random.uniform(batch_size=64, range=[0, 1], shape=2, rng=rng)\n```\n\nWhen `rng=` is passed to a random op, the explicit RNG overrides the default seed. Thread-local: each thread has independent random state.\n\nRandom ops need an explicit `batch_size` when working with batches -- there is no pipeline-level batch size to inherit.\n\n## Checkpointing\n\nDynamic mode has **no pipeline-level checkpoint**. Checkpoints aggregate the state of individual stateful objects: readers and `RNG` instances. Stateless ops (decoders, resize, rotate, normalize, ...) are not part of a checkpoint.\n\n```python\nckpt = ndd.checkpoint.Checkpoint()\nckpt.register(reader, \"my_reader\")\nckpt.register(rng, \"rng\")\n\n# ... iterate for a while ...\n\nckpt.collect()                       # snapshot the registered objects\nckpt.save(\"ckpt_{seq:04d}.json\")     # writes ckpt_0000.json, ckpt_0001.json, ...\n```\n\nRestoring is the symmetric operation -- build a *fresh* reader and `RNG`, then `load` + `register`. The loaded state is applied to each object at `register` time:\n\n```python\nreader = ndd.readers.File(file_root=..., enable_checkpointing=True, name=\"my_reader\")\nrng = ndd.random.RNG()\n\nckpt = ndd.checkpoint.Checkpoint()\nckpt.load(\"ckpt_{seq:04d}.json\")     # picks the highest sequence number\nckpt.register(reader, \"my_reader\")   # state applied here\nckpt.register(rng, \"rng\")            # ditto\n\nfor batch in reader.next_epoch(batch_size=N):\n    ...  # produces the next batch after the checkpointed iteration\n```\n\nKey rules:\n\n- **Readers must opt in.** Construct with `enable_checkpointing=True`. Registering an already-iterated reader without it raises `RuntimeError`; if the reader has not been iterated yet, `register` enables it retroactively.\n- **Reader state must be applied before the first `next_epoch` call.** The prefetch thread starts on first iteration and the snapshot queue is locked after that. `set_state` (or a `register` from a loaded checkpoint) on an already-iterated reader raises `RuntimeError`.\n- **`enable_checkpointing=True` is incompatible with `compile=True`.** Calling `reader.next_epoch(..., compile=True)` on a checkpointing-enabled reader raises `NotImplementedError`.\n- **Named registration is safer.** Anonymous `register(op)` uses sequential keys (`__op_0`, `__op_1`, ...) so the registration order must match between save and restore. Type tags catch cross-type swaps but not reorders of compatible types. Prefer `register(op, name)`.\n- **`ndd.checkpoint.current()`** returns the `Checkpoint` bound to the current thread-local `EvalContext`. It's shared across calls -- call `ckpt.clear()` if reusing the default context for unrelated runs.\n- **Filename pattern:** `save`\u002F`load` take a Python format string with a single `{seq}` placeholder (e.g. `\"ckpt_{seq:04d}.json\"`). `save` picks the next free sequence; `load` picks the highest matching one on disk.\n- **Format version is strict.** `deserialize` rejects payloads from a different checkpoint format version -- no automatic upgrade.\n- **Not thread-safe.** One `Checkpoint` per thread.\n\nManual `get_state` \u002F `set_state` is also available directly on each `Reader` and `RNG` -- the `Checkpoint` aggregator is built on top of it. Use the manual API only when integrating with an external checkpoint system.\n\n## Examples\n\n### Image Classification Pipeline\n\n```python\nimport nvidia.dali.experimental.dynamic as ndd\n\nreader = ndd.readers.File(file_root=\"\u002Fdata\u002Fimagenet\u002Ftrain\", random_shuffle=True)\n\nfor epoch in range(num_epochs):\n    for jpegs, labels in reader.next_epoch(batch_size=64):\n        images = ndd.decoders.image(jpegs, device=\"gpu\")\n        images = ndd.resize(images, size=[224, 224])\n        images = ndd.crop_mirror_normalize(\n            images,\n            mean=[0.485 * 255, 0.456 * 255, 0.406 * 255],\n            std=[0.229 * 255, 0.224 * 255, 0.225 * 255],\n        )\n        train_step(images.torch(), labels.torch())\n```\n\n## Common Mistakes\n\n| Wrong | Right | Why |\n|-------|-------|-----|\n| `device=\"mixed\"` | `device=\"gpu\"` | `\"mixed\"` is pipeline mode only |\n| `batch[i]` | `batch.tensors[i]` | `Batch` has no `__getitem__` |\n| `batch.tensors[0]` for per-sample slicing | `batch.slice[0]` | `.tensors` pick samples; `.slice` slices within each sample |\n| `.evaluate()` after every op | Let consumption trigger eval | `.torch()`, `.shape`, etc. trigger it automatically |\n| `.cpu()` before GPU model | `.torch()` directly | Avoids wasteful D2H + H2D round-trip |\n| Recreate reader each epoch | `reader.next_epoch()` | Readers are stateful -- create once, reuse |\n| `ndd.readers.file(...)` | `ndd.readers.File(...)` | Reader classes are PascalCase |\n| `break` from `next_epoch()` loop | Exhaust iterator or create new reader | Iterator must be fully consumed before next `next_epoch()` |\n| No `batch_size` to random ops | `ndd.random.uniform(batch_size=N, ...)` | No pipeline-level batch size to inherit |\n| `register(reader)` after first `next_epoch` to restore | Register the freshly built reader before the first iteration | Reader state can only be applied before the prefetch thread starts |\n| Restoring into a reader built without `enable_checkpointing=True` after iteration | Pass `enable_checkpointing=True` at construction (or register before first iteration) | Backend doesn't keep snapshots otherwise |\n| Spelling out default argument values | Skip default argument values | Very high Python-side overhead, especially when the argument accepts Tensors\u002FBatches. Skipping arguments uses a fast path, actually passing a sentinel value. |\n\n## Pipeline Mode Migration\n\n| Pipeline Mode | Dynamic Mode |\n|--------------|--------------|\n| `@pipeline_def` \u002F `pipe.build()` \u002F `pipe.run()` | Direct function calls in a loop |\n| `fn.readers.file(...)` | `ndd.readers.File(...)` (PascalCase, stateful) |\n| `fn.decoders.image(jpegs, device=\"mixed\")` | `ndd.decoders.image(jpegs, device=\"gpu\")` |\n| `fn.op_name(...)` | `ndd.op_name(...)` |\n| Pipeline-level `batch_size=64` | `reader.next_epoch(batch_size=64)` + random ops `batch_size=64` |\n| Pipeline-level `seed=42` | `ndd.random.set_seed(42)` or `ndd.random.RNG(seed=42)` |\n| Pipeline-level `num_threads=4` | `ndd.set_num_threads(4)` at startup |\n| `output.at(i)` | `batch.tensors[i]` |\n| `output.as_cpu()` | `batch.cpu()` |\n| `pipe.run()` returns tuple of `TensorList` | `reader.next_epoch(batch_size=N)` yields tuples of `Batch` |\n| `Pipeline(..., enable_checkpointing=True)` + `pipe.checkpoint()` \u002F `pipeline(checkpoint=...)` | `ndd.checkpoint.Checkpoint` + per-object `register` \u002F `collect` \u002F `save` \u002F `load`; readers opt in with `enable_checkpointing=True` |\n\n## Limitations\n\nDynamic mode is more flexible than pipeline mode, but can have slightly worse performance. For maximum throughput, prefer pipeline mode.\n\n## Troubleshooting\n\n- If errors surface later than the failing call, rerun the block under `EvalMode.sync_cpu` or `EvalMode.sync_full`.\n- If a reader behaves unexpectedly across epochs, check that it is created once and each `next_epoch()` iterator is fully consumed.\n","# DALI Dynamic Mode\n\n## Purpose\n\nGuide AI agents in writing, reviewing, and migrating code that uses DALI's imperative dynamic-mode API, `nvidia.dali.experimental.dynamic` (`ndd`).\n\n## Instructions\n\n- Import dynamic mode as `nvidia.dali.experimental.dynamic as ndd` and write code as direct `ndd` calls in ordinary Python; do not use pipeline-mode APIs such as `Pipeline`, `@pipeline_def`, `pipe.build()`, or `pipe.run()`.\n- Treat readers as stateful: create them once, reuse them across epochs, and pass `batch_size` to `next_epoch(...)`.\n- Pass explicit `batch_size` to random ops; there is no pipeline-level batch size to inherit.\n- Use dynamic-mode API conventions: `device=\"gpu\"` instead of pipeline-mode `\"mixed\"`, `Batch.tensors[...]` for sample selection, and `Batch.slice[...]` for per-sample slicing.\n- Use `.torch()` to convert a tensor or batch to a PyTorch tensor. Use `pad=True` for batches with variable shapes.\n\n## Prerequisites\n\n- To run or validate code, NVIDIA DALI must be installed with dynamic mode importable as `nvidia.dali.experimental.dynamic`.\n- GPU decode or GPU operators require a CUDA-capable DALI build and an available NVIDIA GPU\u002Fdriver.\n- Framework conversion examples require the target framework installed, such as PyTorch for `.torch()`.\n\n## Introduction\n\nDynamic mode is DALI's imperative Python API. It lets code call DALI operators directly from normal Python control flow instead of building and running a pipeline graph.\n\n## Core Data Types\n\n### Tensor -- single sample\n\n```python\nt = ndd.tensor(data)           # copy\nt = ndd.as_tensor(data)        # wrap, no copy if possible\nt.cpu()                        # move to CPU\nt.gpu()                        # move to GPU\nt.torch(copy=False)            # conversion to PyTorch tensor with no copy (default)\nt[1:3]                         # slicing supported\nnp.asarray(t)                  # NumPy via __array__ (CPU only)\n```\n\nSupports `__dlpack__`, `__cuda_array_interface__`, `__array__`, arithmetic operators.\n\n### Batch -- collection of samples (variable shapes OK)\n\n```python\nb = ndd.batch([arr1, arr2])    # copy\nb = ndd.as_batch(data)         # wrap, no copy if possible\n```\n\n**Batch has no `__getitem__`** -- `batch[i]` raises `TypeError` because indexing is ambiguous (sample selection vs. per-sample slicing). Use the explicit APIs instead:\n\n| Intent | Method | Returns |\n|--------|--------|---------|\n| Get sample i | `batch.tensors[i]` | `Tensor` |\n| Get subset of samples | `batch.tensors[slice_or_list]` | `Batch` |\n| Slice within each sample | `batch.slice[...]` | `Batch` (same batch_size) |\n| Sample-wise slicing | `batch.slice[batch_of_indices]` | `Batch` (same batch_size) |\n\n`.tensors[]` picks **which samples**. `.slice` indexes **inside each sample**.\n\n```python\nxy = ndd.random.uniform(batch_size=16, range=[0, 1], shape=2)\ncrop_x = xy.slice[0]       # Batch of 16 scalars, first element from each sample\ncrop_y = xy.slice[1]       # Batch of 16 scalars, second element from each sample\nsample_0 = xy.tensors[0]   # Tensor, the entire first sample [x, y]\n```\n\n### Advanced slicing\n\nThe `.slice[]` API accepts batches of indices, allowing the user to mix and match batches and\nscalar values, e.g.:\n```python\nimgs = ndd.imread(filenames)  # a batch of images, if `filenames` is a list\nsliced = imgs.slice[\n    42 :  # the range start is broadcast to all samples\n    ndd.batch(imgs.shape).slice[0] \u002F\u002F 2  # per-sample range stop (half of each image)\n]\n```\n\n**PyTorch conversion:**\n- `batch.torch()` -- works for uniform shapes; raises for ragged batches\n- `batch.torch(pad=True)` -- zero-pads ragged batches to max shape (use for variable-length audio, detection boxes, etc.)\n- `batch.torch(copy=None)` is the default (avoids copy if possible)\n- Batch has **no `__dlpack__`** -- use `ndd.as_tensor(batch)` first for DLPack consumers. `ndd.as_tensor` supports `pad` as well.\n- `Tensor.torch(copy=False)` is default (no copy)\n\n**Iteration:** `for sample in batch:` yields Tensors.\n\n## Readers\n\nReaders are **stateful objects** -- create once, reuse across epochs. This matters because readers track internal state like shuffle order and shard position.\n\n```python\nreader = ndd.readers.File(file_root=image_dir, random_shuffle=True)\n\nfor epoch in range(num_epochs):\n    for jpegs, labels in reader.next_epoch(batch_size=64):\n        # jpegs, labels are Batch objects\n        ...\n```\n\nKey points:\n- Reader outputs (jpegs, labels, etc.) are **CPU** tensors\u002Fbatches. Labels typically stay on CPU until you convert them for your framework (e.g. `labels.torch().to(device)`).\n- Reader classes are **PascalCase**: `ndd.readers.File(...)`, `ndd.readers.COCO(...)`, `ndd.readers.TFRecord(...)`\n- `batch_size` goes to `next_epoch()`, not to the reader constructor\n- `next_epoch(batch_size=N)` yields tuples of `Batch`; `next_epoch()` without batch_size yields tuples of `Tensor`\n- The iterator from `next_epoch()` must be fully consumed before calling `next_epoch()` again\n- Once a reader is used with a given batch_size, it cannot be changed. Similarly, a reader used in batch mode cannot switch to sample mode or vice versa.\n\nSharded reading for distributed training:\n```python\nreader = ndd.readers.File(\n    file_root=image_dir,\n    shard_id=rank, num_shards=world_size,\n    stick_to_shard=True,\n    pad_last_batch=True,\n)\n```\n\n## Device Handling\n\n- Device is **inferred from inputs** -- GPU if any input is on GPU\n- For hybrid decode: use `device=\"gpu\"` (NOT `\"mixed\"`). The `\"mixed\"` keyword is a pipeline-mode concept for implicit CPU-to-GPU transfer; in dynamic mode, passing `device=\"gpu\"` triggers the same hardware-accelerated decode path.\n- Don't call `.cpu()` before passing to a GPU model -- `.torch()` gives you a GPU tensor directly. `.cpu()` is only needed for consumers requiring host memory (numpy, `__array__`).\n- CUDA stream sync between DALI and PyTorch is **automatic via DLPack** -- no manual stream management needed.\n\n## Execution Model\n\nDefault mode is `eager` -- async execution in a background thread, returns immediately.\n\n**No `.evaluate()` needed in most cases.** Any data consumption (`.torch()`, `__dlpack__`, `__array__`, `.shape`, property access, iteration) triggers evaluation automatically.\n\nFor debugging, switch to synchronous mode so errors surface at the exact call site rather than later in the async queue:\n\n```python\nwith ndd.EvalMode.sync_cpu:\n    images = ndd.decoders.image(jpegs, device=\"gpu\")\n    images = ndd.resize(images, size=[224, 224])\n    # Any error surfaces here, at the exact op that failed\n```\n\nModes (increasing synchronicity): `deferred` \u003C `eager` \u003C `sync_cpu` \u003C `sync_full`\n\nUse `EvalMode.sync_full` for debugging instead of scattering `.evaluate()` calls -- it's cleaner and catches all issues at once. `sync_cpu` is often sufficient and lighter than `sync_full`.\n\n## Thread Configuration\n\n```python\nndd.set_num_threads(4)  # Call once at startup, only if necessary to override the defaults\n```\n\nControls DALI's internal worker threads for CPU operators. Defaults to CPU affinity count or `DALI_NUM_THREADS` env var. Unrelated to Python-level threading.\n\n## RNG\n\nTwo approaches (use one, not both):\n\n```python\n# Approach 1: set the thread-local default seed (simple, good enough for most cases)\nndd.random.set_seed(42)\nangles = ndd.random.uniform(batch_size=64, range=(-30, 30))\n\n# Approach 2: explicit RNG object (finer control, pass rng= to each op)\nrng = ndd.random.RNG(seed=42)\nvalues = ndd.random.uniform(batch_size=64, range=[0, 1], shape=2, rng=rng)\n```\n\nWhen `rng=` is passed to a random op, the explicit RNG overrides the default seed. Thread-local: each thread has independent random state.\n\nRandom ops need an explicit `batch_size` when working with batches -- there is no pipeline-level batch size to inherit.\n\n## Checkpointing\n\nDynamic mode has **no pipeline-level checkpoint**. Checkpoints aggregate the state of individual stateful objects: readers and `RNG` instances. Stateless ops (decoders, resize, rotate, normalize, ...) are not part of a checkpoint.\n\n```python\nckpt = ndd.checkpoint.Checkpoint()\nckpt.register(reader, \"my_reader\")\nckpt.register(rng, \"rng\")\n\n# ... iterate for a while ...\n\nckpt.collect()                       # snapshot the registered objects\nckpt.save(\"ckpt_{seq:04d}.json\")     # writes ckpt_0000.json, ckpt_0001.json, ...\n```\n\nRestoring is the symmetric operation -- build a *fresh* reader and `RNG`, then `load` + `register`. The loaded state is applied to each object at `register` time:\n\n```python\nreader = ndd.readers.File(file_root=..., enable_checkpointing=True, name=\"my_reader\")\nrng = ndd.random.RNG()\n\nckpt = ndd.checkpoint.Checkpoint()\nckpt.load(\"ckpt_{seq:04d}.json\")     # picks the highest sequence number\nckpt.register(reader, \"my_reader\")   # state applied here\nckpt.register(rng, \"rng\")            # ditto\n\nfor batch in reader.next_epoch(batch_size=N):\n    ...  # produces the next batch after the checkpointed iteration\n```\n\nKey rules:\n\n- **Readers must opt in.** Construct with `enable_checkpointing=True`. Registering an already-iterated reader without it raises `RuntimeError`; if the reader has not been iterated yet, `register` enables it retroactively.\n- **Reader state must be applied before the first `next_epoch` call.** The prefetch thread starts on first iteration and the snapshot queue is locked after that. `set_state` (or a `register` from a loaded checkpoint) on an already-iterated reader raises `RuntimeError`.\n- **`enable_checkpointing=True` is incompatible with `compile=True`.** Calling `reader.next_epoch(..., compile=True)` on a checkpointing-enabled reader raises `NotImplementedError`.\n- **Named registration is safer.** Anonymous `register(op)` uses sequential keys (`__op_0`, `__op_1`, ...) so the registration order must match between save and restore. Type tags catch cross-type swaps but not reorders of compatible types. Prefer `register(op, name)`.\n- **`ndd.checkpoint.current()`** returns the `Checkpoint` bound to the current thread-local `EvalContext`. It's shared across calls -- call `ckpt.clear()` if reusing the default context for unrelated runs.\n- **Filename pattern:** `save`\u002F`load` take a Python format string with a single `{seq}` placeholder (e.g. `\"ckpt_{seq:04d}.json\"`). `save` picks the next free sequence; `load` picks the highest matching one on disk.\n- **Format version is strict.** `deserialize` rejects payloads from a different checkpoint format version -- no automatic upgrade.\n- **Not thread-safe.** One `Checkpoint` per thread.\n\nManual `get_state` \u002F `set_state` is also available directly on each `Reader` and `RNG` -- the `Checkpoint` aggregator is built on top of it. Use the manual API only when integrating with an external checkpoint system.\n\n## Examples\n\n### Image Classification Pipeline\n\n```python\nimport nvidia.dali.experimental.dynamic as ndd\n\nreader = ndd.readers.File(file_root=\"\u002Fdata\u002Fimagenet\u002Ftrain\", random_shuffle=True)\n\nfor epoch in range(num_epochs):\n    for jpegs, labels in reader.next_epoch(batch_size=64):\n        images = ndd.decoders.image(jpegs, device=\"gpu\")\n        images = ndd.resize(images, size=[224, 224])\n        images = ndd.crop_mirror_normalize(\n            images,\n            mean=[0.485 * 255, 0.456 * 255, 0.406 * 255],\n            std=[0.229 * 255, 0.224 * 255, 0.225 * 255],\n        )\n        train_step(images.torch(), labels.torch())\n```\n\n## Common Mistakes\n\n| Wrong | Right | Why |\n|-------|-------|-----|\n| `device=\"mixed\"` | `device=\"gpu\"` | `\"mixed\"` is pipeline mode only |\n| `batch[i]` | `batch.tensors[i]` | `Batch` has no `__getitem__` |\n| `batch.tensors[0]` for per-sample slicing | `batch.slice[0]` | `.tensors` pick samples; `.slice` slices within each sample |\n| `.evaluate()` after every op | Let consumption trigger eval | `.torch()`, `.shape`, etc. trigger it automatically |\n| `.cpu()` before GPU model | `.torch()` directly | Avoids wasteful D2H + H2D round-trip |\n| Recreate reader each epoch | `reader.next_epoch()` | Readers are stateful -- create once, reuse |\n| `ndd.readers.file(...)` | `ndd.readers.File(...)` | Reader classes are PascalCase |\n| `break` from `next_epoch()` loop | Exhaust iterator or create new reader | Iterator must be fully consumed before next `next_epoch()` |\n| No `batch_size` to random ops | `ndd.random.uniform(batch_size=N, ...)` | No pipeline-level batch size to inherit |\n| `register(reader)` after first `next_epoch` to restore | Register the freshly built reader before the first iteration | Reader state can only be applied before the prefetch thread starts |\n| Restoring into a reader built without `enable_checkpointing=True` after iteration | Pass `enable_checkpointing=True` at construction (or register before first iteration) | Backend doesn't keep snapshots otherwise |\n| Spelling out default argument values | Skip default argument values | Very high Python-side overhead, especially when the argument accepts Tensors\u002FBatches. Skipping arguments uses a fast path, actually passing a sentinel value. |\n\n## Pipeline Mode Migration\n\n| Pipeline Mode | Dynamic Mode |\n|--------------|--------------|\n| `@pipeline_def` \u002F `pipe.build()` \u002F `pipe.run()` | Direct function calls in a loop |\n| `fn.readers.file(...)` | `ndd.readers.File(...)` (PascalCase, stateful) |\n| `fn.decoders.image(jpegs, device=\"mixed\")` | `ndd.decoders.image(jpegs, device=\"gpu\")` |\n| `fn.op_name(...)` | `ndd.op_name(...)` |\n| Pipeline-level `batch_size=64` | `reader.next_epoch(batch_size=64)` + random ops `batch_size=64` |\n| Pipeline-level `seed=42` | `ndd.random.set_seed(42)` or `ndd.random.RNG(seed=42)` |\n| Pipeline-level `num_threads=4` | `ndd.set_num_threads(4)` at startup |\n| `output.at(i)` | `batch.tensors[i]` |\n| `output.as_cpu()` | `batch.cpu()` |\n| `pipe.run()` returns tuple of `TensorList` | `reader.next_epoch(batch_size=N)` yields tuples of `Batch` |\n| `Pipeline(..., enable_checkpointing=True)` + `pipe.checkpoint()` \u002F `pipeline(checkpoint=...)` | `ndd.checkpoint.Checkpoint` + per-object `register` \u002F `collect` \u002F `save` \u002F `load`; readers opt in with `enable_checkpointing=True` |\n\n## Limitations\n\nDynamic mode is more flexible than pipeline mode, but can have slightly worse performance. For maximum throughput, prefer pipeline mode.\n\n## Troubleshooting\n\n- If errors surface later than the failing call, rerun the block under `EvalMode.sync_cpu` or `EvalMode.sync_full`.\n- If a reader behaves unexpectedly across epochs, check that it is created once and each `next_epoch()` iterator is fully consumed.\n",{"name":5,"license":15,"metadata":44,"description":7},{"tags":45,"team":21,"author":50,"domain":24,"languages":51},[21,46,47,48,35,49],"dynamic-mode","ndd","data-loading","gpu-processing","DALI Team \u003Cdali-team@nvidia.com>",[31],"claude\u002Finstall-gsd-build-foQdV","d86cd127f527124b5fd0fd0bc679a4d79b7d01d7",".agents\u002Fskills\u002Fdali-dynamic-mode","https:\u002F\u002Fgithub.com\u002Fpattanation\u002FNorvik","https:\u002F\u002Fnorvik-orpin.vercel.app","https:\u002F\u002Fgithub.com\u002Fpattanation","2026-07-17 11:17:04",{"source":8,"skillName":5,"commands":60,"prompt":70,"zipAvailable":71},[61,64,67],{"tool":62,"command":63},"npx","npx skills add pattanation\u002FNorvik --skill dali-dynamic-mode",{"tool":65,"command":66},"bunx","bunx skills add pattanation\u002FNorvik --skill dali-dynamic-mode",{"tool":68,"command":69},"pnpm","pnpm dlx skills add pattanation\u002FNorvik --skill dali-dynamic-mode","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fpattanation\u002FNorvik\u002Fblob\u002Fclaude\u002Finstall-gsd-build-foQdV\u002F.agents\u002Fskills\u002Fdali-dynamic-mode\u002FSKILL.md",true,[73,79,83,89,93,97],{"path":74,"resourceType":75,"resourceTypeDesc":76,"sizeBytes":77,"sourceHtmlUrl":78},"BENCHMARK.md","REFERENCE","参考文档",3112,"https:\u002F\u002Fgithub.com\u002Fpattanation\u002FNorvik\u002Fblob\u002Fclaude\u002Finstall-gsd-build-foQdV\u002F.agents\u002Fskills\u002Fdali-dynamic-mode\u002FBENCHMARK.md",{"path":80,"resourceType":75,"resourceTypeDesc":76,"sizeBytes":81,"sourceHtmlUrl":82},"evals\u002Fevals.json",8291,"https:\u002F\u002Fgithub.com\u002Fpattanation\u002FNorvik\u002Fblob\u002Fclaude\u002Finstall-gsd-build-foQdV\u002F.agents\u002Fskills\u002Fdali-dynamic-mode\u002Fevals\u002Fevals.json",{"path":84,"resourceType":85,"resourceTypeDesc":86,"sizeBytes":87,"sourceHtmlUrl":88},"evals\u002Ffiles\u002Fpipeline_to_convert.py","SCRIPT","脚本",1446,"https:\u002F\u002Fgithub.com\u002Fpattanation\u002FNorvik\u002Fblob\u002Fclaude\u002Finstall-gsd-build-foQdV\u002F.agents\u002Fskills\u002Fdali-dynamic-mode\u002Fevals\u002Ffiles\u002Fpipeline_to_convert.py",{"path":90,"resourceType":85,"resourceTypeDesc":86,"sizeBytes":91,"sourceHtmlUrl":92},"scripts\u002Frequirements.txt",41,"https:\u002F\u002Fgithub.com\u002Fpattanation\u002FNorvik\u002Fblob\u002Fclaude\u002Finstall-gsd-build-foQdV\u002F.agents\u002Fskills\u002Fdali-dynamic-mode\u002Fscripts\u002Frequirements.txt",{"path":94,"resourceType":75,"resourceTypeDesc":76,"sizeBytes":95,"sourceHtmlUrl":96},"skill-card.md",3859,"https:\u002F\u002Fgithub.com\u002Fpattanation\u002FNorvik\u002Fblob\u002Fclaude\u002Finstall-gsd-build-foQdV\u002F.agents\u002Fskills\u002Fdali-dynamic-mode\u002Fskill-card.md",{"path":98,"resourceType":99,"resourceTypeDesc":100,"sizeBytes":101,"sourceHtmlUrl":102},"skill.oms.sig","OTHER","其他",5077,"https:\u002F\u002Fgithub.com\u002Fpattanation\u002FNorvik\u002Fblob\u002Fclaude\u002Finstall-gsd-build-foQdV\u002F.agents\u002Fskills\u002Fdali-dynamic-mode\u002Fskill.oms.sig",[104,112,119,126,152,176],{"skillNo":105,"name":106,"nameZh":6,"description":107,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":108,"categories":109,"keywords":110,"publishedAt":111},"01M73Z1NPMJ667E0DSPBS9FH0B","jetson-set-target","Switch the active Jetson target-platform pointer to an existing profile YAML. Use before customize\u002Fbuild\u002Fflash to change target; not for authoring profiles — use jetson-init-target instead.","https:\u002F\u002Fgithub.com\u002Fpattanation\u002FNorvik\u002Fblob\u002Fclaude\u002Finstall-gsd-build-foQdV\u002F.agents\u002Fskills\u002Fjetson-set-target\u002FSKILL.md",[],[],"2026-11-11 15:11:14",{"skillNo":113,"name":114,"nameZh":6,"description":115,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":116,"categories":117,"keywords":118,"publishedAt":111},"01M73YC29YWGCW521P7B0NM3HQ","earth2studio-data-fetch","Fetch weather\u002Fclimate data via Earth2Studio data sources for specific variables and times. Do NOT use for inference pipelines, model discovery, or installation.","https:\u002F\u002Fgithub.com\u002Fpattanation\u002FNorvik\u002Fblob\u002Fclaude\u002Finstall-gsd-build-foQdV\u002F.agents\u002Fskills\u002Fearth2studio-data-fetch\u002FSKILL.md",[],[],{"skillNo":120,"name":121,"nameZh":6,"description":122,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":123,"categories":124,"keywords":125,"publishedAt":111},"01M73YBNHMHFDFP83MAVGQQ92N","earth2studio-create-datasource","Create and validate Earth2Studio data source wrappers (DataSource, ForecastSource, DataFrameSource, ForecastFrameSource) from remote stores. Do NOT use for fetching data with existing sources, model inference, or installation tasks.","https:\u002F\u002Fgithub.com\u002Fpattanation\u002FNorvik\u002Fblob\u002Fclaude\u002Finstall-gsd-build-foQdV\u002F.agents\u002Fskills\u002Fearth2studio-create-datasource\u002FSKILL.md",[],[],{"skillNo":127,"name":128,"nameZh":6,"description":129,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":130,"sourceHtmlUrl":131,"categories":132,"keywords":133,"publishedAt":151},"01M71QDV4DM8T19HEHWATEF1K4","webapp-testing","Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.","https:\u002F\u002Fgithub.com\u002Fpattanation\u002FNorvik\u002Fblob\u002Fclaude\u002Finstall-gsd-build-foQdV\u002F.agents\u002Fskills\u002Fwebapp-testing\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fpattanation\u002FNorvik\u002Fblob\u002Fclaude\u002Finstall-gsd-build-foQdV\u002F.agents\u002Fskills\u002Fwebapp-testing\u002FSKILL.md",[],[134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150],"webapp","testing","webapp testing","local","screenshots","for","applications","browser","ui","behavior","web","playwright","with","frontend","debugging","toolkit","logs","2026-11-10 13:02:02",{"skillNo":153,"name":154,"nameZh":6,"description":155,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":156,"sourceHtmlUrl":157,"categories":158,"keywords":159,"publishedAt":151},"01M71QDH2GGMXGA9105C9W1N7B","web-artifacts-builder","Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn\u002Fui). Use for complex artifacts requiring state management, routing, or shadcn\u002Fui components - not for simple single-file HTML\u002FJSX artifacts.","https:\u002F\u002Fgithub.com\u002Fpattanation\u002FNorvik\u002Fblob\u002Fclaude\u002Finstall-gsd-build-foQdV\u002F.agents\u002Fskills\u002Fweb-artifacts-builder\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fpattanation\u002FNorvik\u002Fblob\u002Fclaude\u002Finstall-gsd-build-foQdV\u002F.agents\u002Fskills\u002Fweb-artifacts-builder\u002FSKILL.md",[],[160,144,161,162,163,164,165,166,167,168,169,170,139,171,172,147,173,29,174,175],"web artifacts builder","artifacts","artifacts builder","builder","multi","state","routing","state management","react","single-file","css","Tailwind","ui components","single","file","components",{"skillNo":177,"name":178,"nameZh":6,"description":179,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":180,"licenseFileUrl":181,"sourceHtmlUrl":182,"categories":183,"keywords":184,"publishedAt":151},"01M71QD9T2XC3EWMQNN9ACNWQ1","vueuse-functions","Apply VueUse composables where appropriate to build concise, maintainable Vue.js \u002F Nuxt features.","MIT","https:\u002F\u002Fgithub.com\u002Fpattanation\u002FNorvik\u002Fblob\u002Fclaude\u002Finstall-gsd-build-foQdV\u002F.agents\u002Fskills\u002Fvueuse-functions\u002FLICENSE.md","https:\u002F\u002Fgithub.com\u002Fpattanation\u002FNorvik\u002Fblob\u002Fclaude\u002Finstall-gsd-build-foQdV\u002F.agents\u002Fskills\u002Fvueuse-functions\u002FSKILL.md",[],[185,186,187,188,189,190,191,192,193,194,195,196,197,198],"vueuse","vueuse functions","functions","composables","project","nuxt","apply","github","concise","build","https","features","vue","js"]