[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M78HT334XQRM47830V6DCMEF":3,"skill-same:01M78HT334XQRM47830V6DCMEF":82},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":35,"commitSha":36,"skillDirectory":37,"forksCount":13,"repositoryHtmlUrl":38,"repositoryHomepageUrl":39,"ownerHtmlUrl":40,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":41,"install":42,"resources":55},"01M78HT334XQRM47830V6DCMEF","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.","matheussluzz\u002FZeuZ-Agent","matheussluzz","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F209255758?v=4","01M78HKHH1D1ASC9KC9BG583DH","01M78HKHHP6W7XRXQM2SBCAM3R",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fmatheussluzz\u002FZeuZ-Agent\u002Fblob\u002Fmain\u002Fcatalog\u002Fbundles\u002Fnvidia\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":14,"metadata":23,"description":7},{"tags":24,"team":25,"author":31,"domain":32,"languages":33},[25,26,27,28,29,30],"dali","dynamic-mode","ndd","data-loading","data-processing","gpu-processing","DALI Team \u003Cdali-team@nvidia.com>","deep-learning",[34],"python","main","fc4f2c7759ae400c66cd38656db70ead882a0d08","catalog\u002Fbundles\u002Fnvidia\u002Fdali-dynamic-mode","https:\u002F\u002Fgithub.com\u002Fmatheussluzz\u002FZeuZ-Agent","https:\u002F\u002Fgithub.com\u002Fmatheussluzz\u002FZeuZ-Agent#readme","https:\u002F\u002Fgithub.com\u002Fmatheussluzz","2026-08-27 05:21:51",{"source":8,"skillName":5,"commands":43,"prompt":53,"zipAvailable":54},[44,47,50],{"tool":45,"command":46},"npx","npx skills add matheussluzz\u002FZeuZ-Agent --skill dali-dynamic-mode",{"tool":48,"command":49},"bunx","bunx skills add matheussluzz\u002FZeuZ-Agent --skill dali-dynamic-mode",{"tool":51,"command":52},"pnpm","pnpm dlx skills add matheussluzz\u002FZeuZ-Agent --skill dali-dynamic-mode","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fmatheussluzz\u002FZeuZ-Agent\u002Fblob\u002Fmain\u002Fcatalog\u002Fbundles\u002Fnvidia\u002Fdali-dynamic-mode\u002FSKILL.md",true,[56,62,68,72,78],{"path":57,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":60,"sourceHtmlUrl":61},"BENCHMARK.md","REFERENCE","参考文档",3112,"https:\u002F\u002Fgithub.com\u002Fmatheussluzz\u002FZeuZ-Agent\u002Fblob\u002Fmain\u002Fcatalog\u002Fbundles\u002Fnvidia\u002Fdali-dynamic-mode\u002FBENCHMARK.md",{"path":63,"resourceType":64,"resourceTypeDesc":65,"sizeBytes":66,"sourceHtmlUrl":67},"scripts\u002Frequirements.txt","SCRIPT","脚本",41,"https:\u002F\u002Fgithub.com\u002Fmatheussluzz\u002FZeuZ-Agent\u002Fblob\u002Fmain\u002Fcatalog\u002Fbundles\u002Fnvidia\u002Fdali-dynamic-mode\u002Fscripts\u002Frequirements.txt",{"path":69,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":70,"sourceHtmlUrl":71},"skill-card.md",3859,"https:\u002F\u002Fgithub.com\u002Fmatheussluzz\u002FZeuZ-Agent\u002Fblob\u002Fmain\u002Fcatalog\u002Fbundles\u002Fnvidia\u002Fdali-dynamic-mode\u002Fskill-card.md",{"path":73,"resourceType":74,"resourceTypeDesc":75,"sizeBytes":76,"sourceHtmlUrl":77},"skill.oms.sig","OTHER","其他",5077,"https:\u002F\u002Fgithub.com\u002Fmatheussluzz\u002FZeuZ-Agent\u002Fblob\u002Fmain\u002Fcatalog\u002Fbundles\u002Fnvidia\u002Fdali-dynamic-mode\u002Fskill.oms.sig",{"path":79,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":80,"sourceHtmlUrl":81},"zeuz.manifest.yaml",172,"https:\u002F\u002Fgithub.com\u002Fmatheussluzz\u002FZeuZ-Agent\u002Fblob\u002Fmain\u002Fcatalog\u002Fbundles\u002Fnvidia\u002Fdali-dynamic-mode\u002Fzeuz.manifest.yaml",[83,91,98,105,112,119],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":87,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":18},"01M78JQ2R0QR8H2Z6662RFX804","gamma","Fixture skill gamma for discovery benchmarks.","MIT","https:\u002F\u002Fgithub.com\u002Fmatheussluzz\u002FZeuZ-Agent\u002Fblob\u002Fmain\u002Ftest\u002Ffixtures\u002Fskill-registry-mini\u002Fskills\u002Fgamma\u002FSKILL.md",[],[],{"skillNo":92,"name":93,"nameZh":6,"description":94,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":87,"licenseFileUrl":6,"sourceHtmlUrl":95,"categories":96,"keywords":97,"publishedAt":18},"01M78JQ1KCVZ15APZG3FFF29K0","beta","Fixture skill beta for discovery benchmarks.","https:\u002F\u002Fgithub.com\u002Fmatheussluzz\u002FZeuZ-Agent\u002Fblob\u002Fmain\u002Ftest\u002Ffixtures\u002Fskill-registry-mini\u002Fskills\u002Fbeta\u002FSKILL.md",[],[],{"skillNo":99,"name":100,"nameZh":6,"description":101,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":87,"licenseFileUrl":6,"sourceHtmlUrl":102,"categories":103,"keywords":104,"publishedAt":18},"01M78JQ0FJTK4Q9JKZMX9SVSEN","alpha","Fixture skill alpha for discovery benchmarks.","https:\u002F\u002Fgithub.com\u002Fmatheussluzz\u002FZeuZ-Agent\u002Fblob\u002Fmain\u002Ftest\u002Ffixtures\u002Fskill-registry-mini\u002Fskills\u002Falpha\u002FSKILL.md",[],[],{"skillNo":106,"name":107,"nameZh":6,"description":108,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":87,"licenseFileUrl":6,"sourceHtmlUrl":109,"categories":110,"keywords":111,"publishedAt":18},"01M78JPYVYPY7R8QS10KADQPWE","writing-for-agents","Writing documents for agents. Use when creating or editing skills, or modifying AGENTS.md or CLAUDE.md.","https:\u002F\u002Fgithub.com\u002Fmatheussluzz\u002FZeuZ-Agent\u002Fblob\u002Fmain\u002Fskills\u002Fwriting-for-agents\u002FSKILL.md",[],[],{"skillNo":113,"name":114,"nameZh":6,"description":115,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":87,"licenseFileUrl":6,"sourceHtmlUrl":116,"categories":117,"keywords":118,"publishedAt":18},"01M78JPVYHB88RF5ATZVGX84RR","wizard","Generate an interactive bash wizard that walks a human through steps only they can perform. Use when provisioning infrastructure, setting up credentials or CI secrets, walking an unfamiliar third-party dashboard, or running a one-off migration or cutover. Don't invoke this for steps the agent can perform itself.","https:\u002F\u002Fgithub.com\u002Fmatheussluzz\u002FZeuZ-Agent\u002Fblob\u002Fmain\u002Fskills\u002Fwizard\u002FSKILL.md",[],[],{"skillNo":120,"name":121,"nameZh":6,"description":122,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":87,"licenseFileUrl":6,"sourceHtmlUrl":123,"categories":124,"keywords":125,"publishedAt":18},"01M78JPSSWNTZW89DWGJTX7716","wayfinder","Plan a huge chunk of work (more than one agent session can hold) as a shared map of decision tickets on your issue tracker, and resolve them one at a time until the way to the destination is clear.","https:\u002F\u002Fgithub.com\u002Fmatheussluzz\u002FZeuZ-Agent\u002Fblob\u002Fmain\u002Fskills\u002Fwayfinder\u002FSKILL.md",[],[]]