[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M787K4AC1TFP0NCTA2FBJTRT":3,"skill-same:01M787K4AC1TFP0NCTA2FBJTRT":82},{"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":14,"repositoryHtmlUrl":39,"repositoryHomepageUrl":6,"ownerHtmlUrl":40,"ownerBlogUrl":41,"ownerDescription":42,"updatedAt":43,"install":44,"resources":57},"01M787K4AC1TFP0NCTA2FBJTRT","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.","Solizardking\u002Ftrain2earn","Solizardking","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F108096810?v=4","01M786KDB10AYV042N0F9BD5B5","Clawd","01M786KDC5C3NPE4W44C5641EZ",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002FSolizardking\u002Ftrain2earn\u002Fblob\u002Fmain\u002Fskillhub\u002Fpublic\u002Fapi\u002Fskills\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":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","86cc27ffd16af6cb85948f1155578e6f3f61cc4c","skillhub\u002Fpublic\u002Fapi\u002Fskills\u002Fnvidia\u002Fdali-dynamic-mode","https:\u002F\u002Fgithub.com\u002FSolizardking\u002Ftrain2earn","https:\u002F\u002Fgithub.com\u002FSolizardking","https:\u002F\u002Fmusebook.trade","Got a mile high and never came down","2026-10-08 11:52:53",{"source":8,"skillName":5,"commands":45,"prompt":55,"zipAvailable":56},[46,49,52],{"tool":47,"command":48},"npx","npx skills add Solizardking\u002Ftrain2earn --skill dali-dynamic-mode",{"tool":50,"command":51},"bunx","bunx skills add Solizardking\u002Ftrain2earn --skill dali-dynamic-mode",{"tool":53,"command":54},"pnpm","pnpm dlx skills add Solizardking\u002Ftrain2earn --skill dali-dynamic-mode","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FSolizardking\u002Ftrain2earn\u002Fblob\u002Fmain\u002Fskillhub\u002Fpublic\u002Fapi\u002Fskills\u002Fnvidia\u002Fdali-dynamic-mode\u002FSKILL.md",true,[58,64,68,74,78],{"path":59,"resourceType":60,"resourceTypeDesc":61,"sizeBytes":62,"sourceHtmlUrl":63},"BENCHMARK.md","REFERENCE","参考文档",3112,"https:\u002F\u002Fgithub.com\u002FSolizardking\u002Ftrain2earn\u002Fblob\u002Fmain\u002Fskillhub\u002Fpublic\u002Fapi\u002Fskills\u002Fnvidia\u002Fdali-dynamic-mode\u002FBENCHMARK.md",{"path":65,"resourceType":60,"resourceTypeDesc":61,"sizeBytes":66,"sourceHtmlUrl":67},"metadata.json",351,"https:\u002F\u002Fgithub.com\u002FSolizardking\u002Ftrain2earn\u002Fblob\u002Fmain\u002Fskillhub\u002Fpublic\u002Fapi\u002Fskills\u002Fnvidia\u002Fdali-dynamic-mode\u002Fmetadata.json",{"path":69,"resourceType":70,"resourceTypeDesc":71,"sizeBytes":72,"sourceHtmlUrl":73},"scripts\u002Frequirements.txt","SCRIPT","脚本",26,"https:\u002F\u002Fgithub.com\u002FSolizardking\u002Ftrain2earn\u002Fblob\u002Fmain\u002Fskillhub\u002Fpublic\u002Fapi\u002Fskills\u002Fnvidia\u002Fdali-dynamic-mode\u002Fscripts\u002Frequirements.txt",{"path":75,"resourceType":60,"resourceTypeDesc":61,"sizeBytes":76,"sourceHtmlUrl":77},"skill-card.md",3873,"https:\u002F\u002Fgithub.com\u002FSolizardking\u002Ftrain2earn\u002Fblob\u002Fmain\u002Fskillhub\u002Fpublic\u002Fapi\u002Fskills\u002Fnvidia\u002Fdali-dynamic-mode\u002Fskill-card.md",{"path":79,"resourceType":60,"resourceTypeDesc":61,"sizeBytes":80,"sourceHtmlUrl":81},"verification.json",1501,"https:\u002F\u002Fgithub.com\u002FSolizardking\u002Ftrain2earn\u002Fblob\u002Fmain\u002Fskillhub\u002Fpublic\u002Fapi\u002Fskills\u002Fnvidia\u002Fdali-dynamic-mode\u002Fverification.json",[83,91,99,107,114,122],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":87,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":19},"01M78B94RSCAKMH1QS79VE6DG9","testing","For testing with Light Protocol programs and clients on localnet, devnet, and mainnet validation.","MIT","https:\u002F\u002Fgithub.com\u002FSolizardking\u002Ftrain2earn\u002Fblob\u002Fmain\u002Fskillhub\u002Fskills\u002Ftesting\u002FSKILL.md",[],[],{"skillNo":92,"name":93,"nameZh":6,"description":94,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":87,"licenseFileUrl":95,"sourceHtmlUrl":96,"categories":97,"keywords":98,"publishedAt":19},"01M78B81BKY8RX12HETPG8YKWK","qedgen","Formally verify programs by writing Lean 4 proofs. Trigger this skill whenever the user wants to formally verify code, generate Lean 4 proofs, prove properties about algorithms or smart contracts, verify invariants, convert program logic into formal specifications, or anything involving Lean 4 and formal verification. Also trigger when the user mentions \"qedgen\", \"lean proof\", \"formal proof\", \"verify my code\", \"prove correctness\", \"formal verification\", or wants mathematical guarantees about their implementation.","https:\u002F\u002Fgithub.com\u002FSolizardking\u002Ftrain2earn\u002Fblob\u002Fmain\u002Fskillhub\u002Fskills\u002Fsolana-formal-verification\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FSolizardking\u002Ftrain2earn\u002Fblob\u002Fmain\u002Fskillhub\u002Fskills\u002Fsolana-formal-verification\u002FSKILL.md",[],[],{"skillNo":100,"name":101,"nameZh":6,"description":102,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":87,"licenseFileUrl":103,"sourceHtmlUrl":104,"categories":105,"keywords":106,"publishedAt":19},"01M78B7Q7C5K54E01DN83A60KG","solana-dev","Use when user asks to \"build a Solana dapp\", \"write an Anchor program\", \"create a token\", \"debug Solana errors\", \"set up wallet connection\", \"test my Solana program\", \"deploy to devnet\", or \"explain Solana concepts\" (rent, accounts, PDAs, CPIs, etc.). Also use for quick on-chain lookups via public RPC + curl — \"what's the balance of \u003Cwallet>\", \"look up transaction \u003Csig>\", \"token balance for \u003Caccount>\", \"check this address on mainnet\u002Fdevnet\". End-to-end Solana development playbook covering wallet connection, Anchor\u002FPinocchio programs, Codama client generation, LiteSVM\u002FMollusk\u002FSurfpool testing, security checklists, and JSON-RPC curl lookups against public clusters. Integrates with the Solana MCP server for live documentation search. Prefers framework-kit (@solana\u002Fclient + @solana\u002Freact-hooks) for UI, wallet-standard-first connection (incl. ConnectorKit), @solana\u002Fkit for client\u002FRPC code, and @solana\u002Fweb3-compat for legacy boundaries.","https:\u002F\u002Fgithub.com\u002FSolizardking\u002Ftrain2earn\u002Fblob\u002Fmain\u002Fskillhub\u002Fskills\u002Fsolana-dev\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FSolizardking\u002Ftrain2earn\u002Fblob\u002Fmain\u002Fskillhub\u002Fskills\u002Fsolana-dev\u002FSKILL.md",[],[],{"skillNo":108,"name":109,"nameZh":6,"description":110,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":87,"licenseFileUrl":6,"sourceHtmlUrl":111,"categories":112,"keywords":113,"publishedAt":19},"01M78B7HXD6N6GWKSVRQ8F6Q31","solana-common-errors","Diagnose and fix common Solana development errors — GLIBC mismatches, Anchor version conflicts, cargo build-sbf \u002F platform-tools failures, LiteSVM issues, edition2024 crate pins, RPC airdrops, and Anchor 0.29→0.32 migrations. Use when builds fail, Anchor CLI won't install, or CI breaks on Debian\u002FUbuntu.","https:\u002F\u002Fgithub.com\u002FSolizardking\u002Ftrain2earn\u002Fblob\u002Fmain\u002Fskillhub\u002Fskills\u002Fsolana-common-errors\u002FSKILL.md",[],[],{"skillNo":115,"name":116,"nameZh":6,"description":117,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":118,"sourceHtmlUrl":119,"categories":120,"keywords":121,"publishedAt":19},"01M78B6T7YSYWQ0N4DP40QDXEZ","skill-creator","Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.","https:\u002F\u002Fgithub.com\u002FSolizardking\u002Ftrain2earn\u002Fblob\u002Fmain\u002Fskillhub\u002Fskills\u002Fskill-creator\u002Flicense.txt","https:\u002F\u002Fgithub.com\u002FSolizardking\u002Ftrain2earn\u002Fblob\u002Fmain\u002Fskillhub\u002Fskills\u002Fskill-creator\u002FSKILL.md",[],[],{"skillNo":123,"name":124,"nameZh":6,"description":125,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":87,"licenseFileUrl":6,"sourceHtmlUrl":126,"categories":127,"keywords":128,"publishedAt":19},"01M78B1VFT9X5AND7AE1HZPZGF","phantom-wallet-mcp","Execute wallet operations through the Phantom MCP server. Use when the user wants to interact with their Phantom wallet directly — get addresses, transfer SOL or SPL tokens, buy\u002Fswap tokens, sign transactions, and sign messages across Solana, Ethereum, Bitcoin, and Sui. Requires the @phantom\u002Fmcp-server to be configured as an MCP server.","https:\u002F\u002Fgithub.com\u002FSolizardking\u002Ftrain2earn\u002Fblob\u002Fmain\u002Fskillhub\u002Fskills\u002Fphantom-wallet-mcp\u002FSKILL.md",[],[]]