[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7CP6CVW9DFW0J9DYY6BYK66":3,"skill-same:01M7CP6CVW9DFW0J9DYY6BYK66":64},{"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":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":36,"commitSha":37,"skillDirectory":38,"forksCount":39,"repositoryHtmlUrl":40,"repositoryHomepageUrl":6,"ownerHtmlUrl":41,"ownerBlogUrl":6,"ownerDescription":42,"updatedAt":43,"install":44,"resources":57},"01M7CP6CVW9DFW0J9DYY6BYK66","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.","om-scogo\u002Fskillsh-scraper","om-scogo","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F160466840?v=4","01M79AWB6DFVCQ7RK70CS34B96","Om Achrekar","01M79AWB6ZM9SKR8KDH1WSSM22",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fom-scogo\u002Fskillsh-scraper\u002Fblob\u002Fmain\u002Fdata\u002Fskills\u002Fnvidia-skills\u002Fdali-dynamic-mode\u002FSkill.md",[],[],"2026-11-15 14:19:17",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":24,"description":7},{"tags":25,"team":26,"author":32,"domain":33,"languages":34},[26,27,28,29,30,31],"dali","dynamic-mode","ndd","data-loading","data-processing","gpu-processing","DALI Team \u003Cdali-team@nvidia.com>","deep-learning",[35],"python","main","8859218955d9504cd18b59e7892100718039d3b4","data\u002Fskills\u002Fnvidia-skills\u002Fdali-dynamic-mode",1,"https:\u002F\u002Fgithub.com\u002Fom-scogo\u002Fskillsh-scraper","https:\u002F\u002Fgithub.com\u002Fom-scogo","SDE-1 @ Scogo ","2026-07-18 12:22:46",{"source":8,"skillName":5,"commands":45,"prompt":55,"zipAvailable":56},[46,49,52],{"tool":47,"command":48},"npx","npx skills add om-scogo\u002Fskillsh-scraper --skill dali-dynamic-mode",{"tool":50,"command":51},"bunx","bunx skills add om-scogo\u002Fskillsh-scraper --skill dali-dynamic-mode",{"tool":53,"command":54},"pnpm","pnpm dlx skills add om-scogo\u002Fskillsh-scraper --skill dali-dynamic-mode","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fom-scogo\u002Fskillsh-scraper\u002Fblob\u002Fmain\u002Fdata\u002Fskills\u002Fnvidia-skills\u002Fdali-dynamic-mode\u002FSkill.md",true,[58],{"path":59,"resourceType":60,"resourceTypeDesc":61,"sizeBytes":62,"sourceHtmlUrl":63},"metadata.json","REFERENCE","参考文档",418,"https:\u002F\u002Fgithub.com\u002Fom-scogo\u002Fskillsh-scraper\u002Fblob\u002Fmain\u002Fdata\u002Fskills\u002Fnvidia-skills\u002Fdali-dynamic-mode\u002Fmetadata.json",[65,73,78,85,90,97],{"skillNo":66,"name":67,"nameZh":6,"description":68,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":69,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":19},"01M7D6MC9FAAEV4CMNYX8W7JTG","arxiv-search","Search arXiv physics, math, and computer science preprints using natural language queries. Powered by Valyu semantic search.","MIT","https:\u002F\u002Fgithub.com\u002Fom-scogo\u002Fskillsh-scraper\u002Fblob\u002Fmain\u002Fdata\u002Fskills\u002Fyorkeccak-scientific-skills\u002Farxiv-search\u002Fskills\u002Farxiv-search\u002FSKILL.md",[],[],{"skillNo":74,"name":67,"nameZh":6,"description":68,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":69,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":19},"01M7D6M85CKKN87TA98VCQV4H7","https:\u002F\u002Fgithub.com\u002Fom-scogo\u002Fskillsh-scraper\u002Fblob\u002Fmain\u002Fdata\u002Fskills\u002Fyorkeccak-scientific-skills\u002Farxiv-search\u002FSkill.md",[],[],{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":69,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":19},"01M7D4ZTCS4DR3CE4JY06X84T2","working-with-legacy-code","Safely change and test untested codebases using Feathers' \"Working Effectively with Legacy Code\". Use when the user mentions \"legacy code\", \"no tests\", \"untested codebase\", \"how do I test this\", \"seams\", \"characterization tests\", \"golden master\", \"sprout method\", \"afraid to change this code\", \"monster method\", \"dependency breaking\", or \"inherited a messy codebase\". Also trigger when changing code without tests safely, getting a class under test when constructors, statics, or singletons block it, adding features to tangled modules, or planning incremental test coverage for an old codebase. Covers the legacy-code change algorithm, seams, characterization tests, sprout\u002Fwrap, and dependency-breaking techniques. For refactoring code that already has tests, see refactoring-patterns. For day-to-day code quality, see clean-code.","https:\u002F\u002Fgithub.com\u002Fom-scogo\u002Fskillsh-scraper\u002Fblob\u002Fmain\u002Fdata\u002Fskills\u002Fwondelai-skills\u002Fworking-with-legacy-code\u002Fworking-with-legacy-code\u002FSKILL.md",[],[],{"skillNo":86,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":69,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":19},"01M7D4ZHZKJD2RSNGAF63V14P4","https:\u002F\u002Fgithub.com\u002Fom-scogo\u002Fskillsh-scraper\u002Fblob\u002Fmain\u002Fdata\u002Fskills\u002Fwondelai-skills\u002Fworking-with-legacy-code\u002FSkill.md",[],[],{"skillNo":91,"name":92,"nameZh":6,"description":93,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":69,"licenseFileUrl":6,"sourceHtmlUrl":94,"categories":95,"keywords":96,"publishedAt":19},"01M7D4ZB4CJBFW5JE67CPH2QRV","web-typography","Select, pair, and implement typefaces for web projects. Use when the user mentions \"font pairing\", \"which typeface\", \"line height\", \"responsive typography\", \"web font loading\", \"type hierarchy\", \"variable fonts\", \"FOUT\u002FFOIT\", \"typographic scale\", or \"the text is hard to read\". Also trigger when choosing between system fonts and web fonts, optimizing font-loading performance, or designing readable long-form content. Covers readability evaluation, CSS implementation, and performance optimization. For overall UI design systems, see refactoring-ui. For dramatic typographic experiences, see top-design.","https:\u002F\u002Fgithub.com\u002Fom-scogo\u002Fskillsh-scraper\u002Fblob\u002Fmain\u002Fdata\u002Fskills\u002Fwondelai-skills\u002Fweb-typography\u002Fweb-typography\u002FSKILL.md",[],[],{"skillNo":98,"name":92,"nameZh":6,"description":93,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":69,"licenseFileUrl":6,"sourceHtmlUrl":99,"categories":100,"keywords":101,"publishedAt":19},"01M7D4Z4MVYVY3NMJ18BNV6WNA","https:\u002F\u002Fgithub.com\u002Fom-scogo\u002Fskillsh-scraper\u002Fblob\u002Fmain\u002Fdata\u002Fskills\u002Fwondelai-skills\u002Fweb-typography\u002FSkill.md",[],[]]