dupla-vla 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. dupla_vla-0.1.0/ARCHITECTURE.md +62 -0
  2. dupla_vla-0.1.0/CHANGELOG.md +5 -0
  3. dupla_vla-0.1.0/FORMAT.md +102 -0
  4. dupla_vla-0.1.0/LICENSE +201 -0
  5. dupla_vla-0.1.0/MANIFEST.in +5 -0
  6. dupla_vla-0.1.0/PKG-INFO +174 -0
  7. dupla_vla-0.1.0/README.md +144 -0
  8. dupla_vla-0.1.0/pyproject.toml +45 -0
  9. dupla_vla-0.1.0/setup.cfg +4 -0
  10. dupla_vla-0.1.0/src/dupla/__init__.py +21 -0
  11. dupla_vla-0.1.0/src/dupla/__main__.py +3 -0
  12. dupla_vla-0.1.0/src/dupla/_compat.py +28 -0
  13. dupla_vla-0.1.0/src/dupla/_io.py +193 -0
  14. dupla_vla-0.1.0/src/dupla/_media.py +189 -0
  15. dupla_vla-0.1.0/src/dupla/_prefix.py +71 -0
  16. dupla_vla-0.1.0/src/dupla/_public.py +96 -0
  17. dupla_vla-0.1.0/src/dupla/_schema.py +30 -0
  18. dupla_vla-0.1.0/src/dupla/benchmark.py +341 -0
  19. dupla_vla-0.1.0/src/dupla/cli.py +128 -0
  20. dupla_vla-0.1.0/src/dupla/conformance/__init__.py +75 -0
  21. dupla_vla-0.1.0/src/dupla/conformance/golden/README.md +11 -0
  22. dupla_vla-0.1.0/src/dupla/conformance/golden/SO100-LICENSE.txt +202 -0
  23. dupla_vla-0.1.0/src/dupla/conformance/golden/benchmark/audio/user.wav +0 -0
  24. dupla_vla-0.1.0/src/dupla/conformance/golden/benchmark/cases/move_then_stop.json +68 -0
  25. dupla_vla-0.1.0/src/dupla/conformance/golden/benchmark/manifest.json +25 -0
  26. dupla_vla-0.1.0/src/dupla/conformance/golden/benchmark/profile.yaml +2 -0
  27. dupla_vla-0.1.0/src/dupla/conformance/golden/demonstrations/episodes/intervention/episode.json +157 -0
  28. dupla_vla-0.1.0/src/dupla/conformance/golden/demonstrations/episodes/intervention/rgb.npz +0 -0
  29. dupla_vla-0.1.0/src/dupla/conformance/golden/demonstrations/episodes/intervention/robot.wav +0 -0
  30. dupla_vla-0.1.0/src/dupla/conformance/golden/demonstrations/episodes/intervention/trajectory.h5 +0 -0
  31. dupla_vla-0.1.0/src/dupla/conformance/golden/demonstrations/episodes/intervention/user.wav +0 -0
  32. dupla_vla-0.1.0/src/dupla/conformance/golden/demonstrations/episodes/reference/episode.json +122 -0
  33. dupla_vla-0.1.0/src/dupla/conformance/golden/demonstrations/episodes/reference/rgb.npz +0 -0
  34. dupla_vla-0.1.0/src/dupla/conformance/golden/demonstrations/episodes/reference/robot.wav +0 -0
  35. dupla_vla-0.1.0/src/dupla/conformance/golden/demonstrations/episodes/reference/trajectory.h5 +0 -0
  36. dupla_vla-0.1.0/src/dupla/conformance/golden/demonstrations/episodes/reference/user.wav +0 -0
  37. dupla_vla-0.1.0/src/dupla/conformance/golden/demonstrations/episodes/so100/episode.json +43 -0
  38. dupla_vla-0.1.0/src/dupla/conformance/golden/demonstrations/episodes/so100/rgb.npz +0 -0
  39. dupla_vla-0.1.0/src/dupla/conformance/golden/demonstrations/episodes/so100/robot.wav +0 -0
  40. dupla_vla-0.1.0/src/dupla/conformance/golden/demonstrations/episodes/so100/trajectory.h5 +0 -0
  41. dupla_vla-0.1.0/src/dupla/conformance/golden/demonstrations/episodes/so100/user.wav +0 -0
  42. dupla_vla-0.1.0/src/dupla/conformance/golden/demonstrations/manifest.json +132 -0
  43. dupla_vla-0.1.0/src/dupla/conformance/golden/demonstrations/windows.jsonl +20 -0
  44. dupla_vla-0.1.0/src/dupla/conformance/golden/expected.json +54 -0
  45. dupla_vla-0.1.0/src/dupla/dataset.py +267 -0
  46. dupla_vla-0.1.0/src/dupla/episode.py +370 -0
  47. dupla_vla-0.1.0/src/dupla/evidence.py +80 -0
  48. dupla_vla-0.1.0/src/dupla/py.typed +0 -0
  49. dupla_vla-0.1.0/src/dupla/schemas/benchmark_case.schema.json +421 -0
  50. dupla_vla-0.1.0/src/dupla/schemas/episode.schema.json +359 -0
  51. dupla_vla-0.1.0/src/dupla/schemas/manifest.schema.json +496 -0
  52. dupla_vla-0.1.0/src/dupla/schemas/windows_index.schema.json +42 -0
  53. dupla_vla-0.1.0/src/dupla/shards.py +208 -0
  54. dupla_vla-0.1.0/src/dupla/speech.py +117 -0
  55. dupla_vla-0.1.0/src/dupla/torch.py +134 -0
  56. dupla_vla-0.1.0/src/dupla/trajectory.py +105 -0
  57. dupla_vla-0.1.0/src/dupla/types.py +147 -0
  58. dupla_vla-0.1.0/src/dupla/verify.py +406 -0
  59. dupla_vla-0.1.0/src/dupla/windows.py +274 -0
  60. dupla_vla-0.1.0/src/dupla_vla.egg-info/PKG-INFO +174 -0
  61. dupla_vla-0.1.0/src/dupla_vla.egg-info/SOURCES.txt +78 -0
  62. dupla_vla-0.1.0/src/dupla_vla.egg-info/dependency_links.txt +1 -0
  63. dupla_vla-0.1.0/src/dupla_vla.egg-info/entry_points.txt +2 -0
  64. dupla_vla-0.1.0/src/dupla_vla.egg-info/requires.txt +8 -0
  65. dupla_vla-0.1.0/src/dupla_vla.egg-info/top_level.txt +1 -0
  66. dupla_vla-0.1.0/tests/__init__.py +0 -0
  67. dupla_vla-0.1.0/tests/conftest.py +284 -0
  68. dupla_vla-0.1.0/tests/helpers.py +42 -0
  69. dupla_vla-0.1.0/tests/test_benchmark.py +52 -0
  70. dupla_vla-0.1.0/tests/test_cli.py +24 -0
  71. dupla_vla-0.1.0/tests/test_conformance.py +19 -0
  72. dupla_vla-0.1.0/tests/test_dataset.py +74 -0
  73. dupla_vla-0.1.0/tests/test_episode.py +187 -0
  74. dupla_vla-0.1.0/tests/test_evidence.py +40 -0
  75. dupla_vla-0.1.0/tests/test_media.py +95 -0
  76. dupla_vla-0.1.0/tests/test_shards.py +101 -0
  77. dupla_vla-0.1.0/tests/test_speech.py +98 -0
  78. dupla_vla-0.1.0/tests/test_v01_data.py +40 -0
  79. dupla_vla-0.1.0/tests/test_verify.py +138 -0
  80. dupla_vla-0.1.0/tests/test_windows.py +285 -0
@@ -0,0 +1,62 @@
1
+ # DUPLA SDK Architecture
2
+
3
+ A concise guide for contributors reading or extending `dupla`.
4
+
5
+ ## Module Map
6
+
7
+ - `__init__.py` / `__main__.py`: public package exports, `__version__`, and `python -m dupla` entry point.
8
+ - `_io.py`: low-level file/JSON/WAV I/O, exact rational tick math (`ticks_for`), SHA-256 helpers, atomic directory staging (`staged_directory`), `relative_asset_path`/`asset` traversal guards, and shared `DATA_ERRORS`.
9
+ - `_schema.py`: cached Draft 2020-12 JSON Schema validators for manifests, episodes, benchmark cases, and `windows.jsonl`.
10
+ - `_compat.py`: action dimension resolution and named state / ground-truth specification helpers.
11
+ - `_media.py`: `RgbArchive`, a fork-safe lazy prefix-decoding reader for `.npz` RGB archives.
12
+ - `_public.py`: public benchmark leakage guardrails (`ORACLE`, `HOST_PATH`, `PRIVATE_FIELDS`) and `os.scandir()` release tree scanning.
13
+ - `_prefix.py`: counterfactual fork prefix array extraction and SHA-256 verification (`verify_pair`).
14
+ - `dataset.py`: `Dupla` release reader, family/pair graph validation, `windows.jsonl` index parsing, and per-instance LRU caches.
15
+ - `episode.py`: `Episode` stream validation, audio/RGB/trajectory slicing, and causal window assembly (`control_rate`, `window_at`, `window`).
16
+ - `trajectory.py`: HDF5 action, proprioception, and ground-truth stream validation and slicing.
17
+ - `speech.py`: Unicode word-boundary transcript checking, sample-clock word filtering, and `SpeechPlayback` cursors.
18
+ - `windows.py`: `WindowDataset` indexing/generation and NumPy batch collation (`collate_windows`).
19
+ - `types.py`: `TypedDict` definitions for word timings, index rows, windows, and NumPy batches.
20
+ - `torch.py`: optional PyTorch `TorchWindowDataset`, `TorchBatch` types, `build_category_sampler`, and `collate_torch_windows`.
21
+ - `benchmark.py`: public `Benchmark`, `BenchmarkCase`, and `export_subset`.
22
+ - `evidence.py`: milestone, concurrent dialogue, and reference-branch evaluability checks.
23
+ - `shards.py`: tar shard validation, shared `merge_shard_manifest`, and zero-double-copy `assemble_shards`.
24
+ - `verify.py`: `verify_release` orchestrator, `_TrainingAudit`, rolling per-shard verification (`--partial`, `--tmp-dir`), and cross-split exposure audit.
25
+ - `cli.py`: `dupla` CLI (`conformance`, `info`, `verify`, `assemble`, `export-eval`).
26
+ - `conformance/`: bundled golden fixtures and `run_conformance()`.
27
+
28
+ ## Data Flow
29
+
30
+ ```
31
+ Release directory (manifest.json / shards.json)
32
+ └─▶ Dupla (validates manifest, families, pairs; caches Episodes & RgbArchives)
33
+ └─▶ Episode (validates clock, RGB metadata and speech events, caches the checked trajectory signature)
34
+ └─▶ Episode.window_at(...) / Episode.window(...)
35
+ ├─ observations: causal RGB prefix, full-prefix audio & completed words, proprioception, executed_actions
36
+ ├─ targets: future expert_actions, action_mask, robot_audio, completed words, robot_speaking
37
+ └─ metadata: categories, event_tags, privileged ground_truth
38
+ └─▶ WindowDataset / collate_windows (NumPy batches)
39
+ └─▶ dupla.torch (TorchWindowDataset, WeightedRandomSampler, torch.Tensor batches)
40
+ ```
41
+
42
+ ## Verification Pipeline
43
+
44
+ `verify_release(root, *, partial=False, tmp_dir=None)` runs four stages:
45
+ 1. Locate component(s) (`demonstrations`, `benchmark`, or release root) and verify `SHA256SUMS` (skipping missing entries only when `partial=True`).
46
+ 2. Scan demonstration tree for host-path leaks (`scan_tree(..., public=False)`). For sharded releases without unpacked `episodes/`, unpack and audit one shard at a time in `tmp_dir` (~1 shard peak disk usage) and validate cross-shard ID uniqueness and spec consistency via `merge_shard_manifest`.
47
+ 3. Audit every episode (`_TrainingAudit`: transcript alignment, finite trajectory arrays, full CRC-verified RGB, WAVs, replay states, window bounds) and every counterfactual pair (`verify_pair`).
48
+ 4. Scan benchmark tree for private/oracle leakage (`scan_tree(..., public=True)`), verify case assets, and cross-check training exposure (initial states, audio digests, voices, scripts, wordings).
49
+
50
+ ## Caching & Fork-Safety
51
+
52
+ - `Dupla` maintains instance-scoped, `RLock`-guarded LRU caches (`_episode_cache` max 256, `_rgb_cache` max 16).
53
+ - Spawned workers rebuild both caches and the lock during unpickling. Forked workers reset them on their first cache access, before acquiring a lock inherited from the parent.
54
+ - The HDF5 structure check uses the identity, size, and timestamps of the open file descriptor when the driver exposes one. Full verification always checks trajectory values. Episode and RGB readers close their OS file handles after each read.
55
+
56
+ ## Lazy RGB Decoding
57
+
58
+ Training RGB arrays have shape `(T, V, H, W, 3)` and dtype `uint8`. The reader accepts both NumPy keys and exact ZIP member names.
59
+
60
+ - For C-order arrays with NPY v1 or v2 headers in stored or DEFLATE members, `RgbArchive` keeps the standard library ZIP decoder and its CRC state between requests. Window and frame reads decode the requested prefix with some ZIP read-ahead, reopening the file at the saved cursor under the archive lock.
61
+ - Reading the last capture or calling `Episode.rgb_frames()` consumes the image member through EOF and verifies its CRC. Capture ticks are read and checked in full on opening. Both `Episode.verify_streams()` and `dupla verify` request all frames.
62
+ - Fortran-order arrays, other NPY header versions, and other supported compression methods fall back to the full NumPy array reader.
@@ -0,0 +1,5 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0
4
+
5
+ First public release of `dupla-vla`. Includes typed state streams, causal speech and action windows, PyTorch dataset/collation helpers, counterfactual prefix verification, benchmark evidence contracts, sharded dataset tools, and an offline conformance fixture.
@@ -0,0 +1,102 @@
1
+ # DUPLA Interchange Format
2
+
3
+ This specification defines the portable DUPLA on-disk format (`dupla-*/0.1` schemas) and the SDK's causal reading contract.
4
+
5
+ ## 1. Components and clocks
6
+
7
+ A DUPLA release contains `demonstrations/`, `benchmark/`, or both; either component can be used independently.
8
+
9
+ - **Path safety & hashes**: all declared asset paths resolve relative to the declaring file and must stay inside their component root. File digests use SHA-256 of raw file bytes; numeric array digests use SHA-256 of C-order little-endian bytes in the recorded dtype.
10
+ - **Shared timeline**: each episode declares `control_hz`, `control_steps` (`N`), `audio_sample_rate`, and `audio_samples`. Both mono PCM16 channels (`user.wav`, `robot.wav`) start at state `0` and span the exact duration of the `N` control steps (`audio_samples * control_hz == N * audio_sample_rate`).
11
+ - **Control & capture convention**: action `k` transitions state `k` to state `k + 1`. An RGB capture at tick `k` is available before action `k`.
12
+ - **Decision boundary in audio samples**: `s(k) = floor(k * audio_sample_rate / control_hz)`.
13
+ - **Time-to-tick conversion**: durations passed to the SDK in seconds must align to integer control ticks. Floating-point values snap to the nearest tick only within one float ULP (when smaller than half a tick); exact `Fraction` and decimal strings are checked without rounding.
14
+
15
+ ## 2. Demonstrations, states, and optional ground truth
16
+
17
+ ### Component manifest (`dupla-dataset/0.1`)
18
+ Declares `info`, `event_audio`, `action_specs`, `state_specs`, episode rows, families, and counterfactual pairs. Every episode belongs to exactly one family and split. A singleton family has one episode and an empty pair list. Subsets and tar shards always preserve whole families.
19
+
20
+ ### Episode streams (`dupla-episode/0.1`)
21
+ Each episode references its `action_spec_id` and `state_spec_id` from the manifest:
22
+ - **Actions (`trajectory.h5`)**: `actions` and `executed_actions` are numeric `[N, D]` arrays; `action_mask` is a boolean `[N]` array.
23
+ - **Proprioception (`trajectory.h5`)**: each field in `state_spec.fields` declares trailing `shape` (`[]` for scalars), numeric/boolean `dtype`, `unit`, and coordinate `frame`, stored at `states/<name>` with shape `[N + 1, *shape]`.
24
+ - **Vision (`rgb.npz`)**: `uint8` captures in `[capture, camera, height, width, channel]` (`MVHWC`, RGB) order with strictly increasing integer capture ticks. Camera order and archive keys are declared in `episode.json`.
25
+
26
+ ### Optional privileged ground truth
27
+ Privileged streams under `ground_truth/` in `trajectory.h5` are optional (for example, hardware recordings may omit them). Each declared stream specifies its `axis` under `streams.trajectory.ground_truth.<name>.axis`:
28
+
29
+ | Axis | HDF5 layout | Slice returned for action interval `[k, j)` |
30
+ | --- | --- | --- |
31
+ | `state` | `ground_truth/<name>`, `N + 1` rows | States `k` through `j` inclusive |
32
+ | `interval` | `ground_truth/<name>`, `N` rows | Rows `k` through `j - 1` |
33
+ | `event` | `ground_truth/<name>/{ticks,values}`, equal lengths | Ticks in `[k, j)`, plus terminal tick `N` when `j == N` (repeated ticks allowed) |
34
+
35
+ Optional simulator replay metadata lives under `extensions.<backend>`. Ground truth is exposed via `Episode.ground_truth()` and `window["metadata"]["ground_truth"]`; omitting it returns `{}`.
36
+
37
+ ### Speech events and alignment
38
+ Each event in `episode.json` records `role` (`user` or `robot`), reference `text`, `category`, clip bounds (`clip_start_sample`, `clip_end_sample`), voice envelope (`voice_onset_sample`, `voice_offset_sample`), `voiced_intervals`, and `word_alignment`:
39
+ - User events also declare `control_op` and `determination_sample`; robot events declare a nullable `ref_event_id`.
40
+ - On-disk `word_alignment` entries store `{word, start_sample, end_sample}` **relative to the clip**.
41
+ - `voiced_intervals` are disjoint, positive-duration `[start, end)` intervals in **absolute episode samples** within the played clip. Their outer bounds match `[voice_onset_sample, voice_offset_sample]`; internal pauses may split one utterance into multiple intervals.
42
+ - For interrupted utterances, transcripts and alignments cover only completed words in the actual playback; a cut syllable contributes played audio without a completed word.
43
+
44
+ ## 3. Causal training windows and counterfactual pairs
45
+
46
+ For decision tick `k` and horizon `h`, write `b = s(k)` and `e = s(k + h)`. The reader converts word timings to absolute episode samples and orders them by `(end_sample, start_sample)` per speaker track, preserving genuine overlap.
47
+
48
+ | Window field | Returned value |
49
+ | --- | --- |
50
+ | `observations.user_audio`, `robot_audio` | Recorded mono PCM16 samples over `[0, b)` for each speaker |
51
+ | `observations.user_text`, `robot_text` | Completed aligned words of that speaker with `end_sample <= b` |
52
+ | `observations.rgb_frames`, `rgb_ticks`, `proprioception_history`, `executed_actions` | Captures through `k`, states through `k`, executed actions before `k` (bounded by `history_s` / `history_ticks` when set) |
53
+ | `observations.rgb`, `history_rgb`, `proprioception` | Convenience single-step views (`rgb` at latest causal frame, `proprioception` at `k`, `history_rgb` at lookback) |
54
+ | `targets.robot_audio`, `robot_text` | Actual robot PCM over `[b, e)`, and completed robot words with `b < end_sample <= e` |
55
+ | `targets.robot_speaking` | `True` iff `[b, e)` has positive overlap with any robot `voiced_intervals` entry (may be `True` with empty `robot_text` during a partial word) |
56
+ | `targets.expert_actions`, `action_mask` | Steps `[k, k + h)` |
57
+ | `metadata` | Index categories, `event_tags`, `phase` convenience view (when present), and `ground_truth` over `[k, k + h)` |
58
+
59
+ ### Causality guarantees
60
+ - Adjacent non-overlapping windows assign every completed word to **at most one** target window; at the next decision it moves into observation history.
61
+ - A half-spoken word immediately contributes its played PCM samples without leaking its uncompleted word token.
62
+ - Changing future actions or speech after `(k, b)` cannot alter any field in `observations`. Task IDs, full transcripts, future user words, event intent, goal predicates, and scoring rules stay outside `observations`.
63
+
64
+ ### Window index and batching
65
+ - By default, the reader returns the complete past; `history_s` / `history_ticks` bound only captured RGB frames, proprioception history, and executed actions (retaining the active RGB frame at the left boundary).
66
+ - A `windows.jsonl` row stores `episode_id`, `decision_tick`, `horizon_steps`, `coarse_category`, `fine_category`, and optional `event_tags`, unique by `(episode_id, decision_tick, horizon_steps)`. Without an index, `WindowDataset` generates fully supervised windows from `action_mask`. Category sampling weights resolve from `fine_category`, then `coarse_category`, then `1.0`.
67
+ - NumPy and PyTorch collators require matching camera, clock, action, state, and horizon specs. PCM tracks are right-padded with lengths; visual, state, and executed-action histories are left-padded with lengths; word records stay variable-length lists.
68
+
69
+ ### Counterfactual pairs
70
+ Each pair links a `reference` branch and an `intervention` branch at `(physics_fork_tick, audio_fork_sample)`. Published `prefix_sha256` digests cover:
71
+ - `actions` and `executed_actions` before `physics_fork_tick`;
72
+ - every `states/<name>` through `physics_fork_tick` (plus `sim_states` when MuJoCo replay states are declared);
73
+ - `rgb_frames` and `rgb_ticks` through `physics_fork_tick`;
74
+ - For `user_pcm` and `robot_pcm`, hash the PCM samples in `[0, audio_fork_sample)`.
75
+ - For `user_text` and `robot_text`, keep each speaker's absolute word records with `end_sample <= audio_fork_sample`.
76
+ Sort by `(end_sample, start_sample)`, preserving input order for ties.
77
+ Hash the bytes returned by `json.dumps(words, sort_keys=True, ensure_ascii=False, separators=(",", ":")).encode("utf-8")`.
78
+
79
+ ## 4. Public benchmark and evidence
80
+
81
+ A benchmark manifest (`dupla-benchmark/0.1`) indexes end-to-end evaluation cases (`dupla-case/0.1`), their three exposure axes (`voice`, `wording`, `script`, each `seen` or `unseen`), a timing/scoring profile, and speech provenance.
82
+
83
+ ### Case bindings and rules
84
+ - **`assets.env_binding`**: declares `backend`, backend-specific `spec`, `capabilities`, and optional `resources.<name>` (`path` + SHA-256). LIBERO initial states include array SHA-256 and seed.
85
+ - **`rules.goals.<id>`**: declares a human-readable `description` and `verifier` (`kind` and `spec`). Standard verifier kinds are `bddl_predicate`, `env_success_fn`, `human_or_vlm_rubric`, and `dynamic_state_qa`; custom kinds can advertise `verifier:<kind>`.
86
+ - **Milestones and scheduling**: milestone `check` values are `motion`, `stop`, `goal`, `clarification`, `cancel`, and `return`; `trigger` values are `ready`, `motion`, and `paused` (concurrent dialogue events may also use `robot_voiced`). Any verifier, milestone, concurrent event, or `reference_branch` may declare additional `requires_evidence`.
87
+
88
+ ### Evidence-gated scoring
89
+ - `case.evidence()` reports requirements against backend capabilities; pass rollout-supplied evidence to `case.evidence(available)` or `case.milestone_result(milestone_id, score, available=...)`.
90
+ - Missing required evidence always yields `status="not_evaluable"` and `score=None` (even if a caller supplies `0`). A verified failure with complete evidence can score `0`.
91
+ - For concurrent events or reference branches, pass the selected entry to `dupla.evidence.evidence_result()`. Evaluation summaries should report evaluable coverage separately from scores.
92
+
93
+ ### Speech playback tracks
94
+ - **Primary track (`native_pcm`)**: delivers **only played PCM** to the policy. Call `cursor.advance_to(played_samples)` as the renderer plays audio, using one cursor per clip (including robot self-speech).
95
+ - **Diagnostic track (`reference_subtitles`)**: additionally exposes completed reference words with absolute timestamps when `word_alignment` is present; otherwise `cursor.status("reference_subtitles")` returns `"not_evaluable"`.
96
+ - **Interruption**: calling `cursor.interrupt()` seals the clip at the played sample count and discards unplayed tail audio and unfinished words. Case rules, media indexes, expected answers, and unplayed clips remain evaluator-side.
97
+
98
+ ## 5. Validation, conformance, and utilities
99
+
100
+ - **Schemas and `dupla verify`**: the package includes four Draft 2020-12 JSON schemas (`manifest`, `episode`, `windows_index`, `benchmark_case`). `dupla verify` checks schemas, file/array checksums, clocks, shapes, finiteness, family/pair structure, counterfactual prefixes, public benchmark leakage guardrails, and transcript-to-word alignment (Unicode NFKC, casefolding, punctuation normalization, and word-boundary matching, including spaceless scripts such as Chinese).
101
+ - **Conformance (`dupla conformance`)**: runs the bundled golden fixture covering cross-boundary words, interrupted audible syllables, counterfactual prefix equality, a hardware trajectory without privileged ground truth, evidence gating, and playback tracks.
102
+ - **Export & shard assembly**: `dupla export-eval` writes a self-contained benchmark subset preserving WAVs, initial states, exposure groups, and verifiers. `dupla assemble` verifies shard tar digests, merges whole families, and checks spec compatibility.
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,5 @@
1
+ include src/dupla/py.typed
2
+ include LICENSE FORMAT.md README.md ARCHITECTURE.md CHANGELOG.md
3
+ recursive-include src/dupla/schemas *.json
4
+ recursive-include src/dupla/conformance/golden *
5
+ recursive-include tests *.py
@@ -0,0 +1,174 @@
1
+ Metadata-Version: 2.4
2
+ Name: dupla-vla
3
+ Version: 0.1.0
4
+ Summary: Local SDK for DUPLA demonstration data and benchmark assets
5
+ Author: DUPLA Contributors
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/habaniu/duplex-vla
8
+ Project-URL: Repository, https://github.com/habaniu/duplex-vla
9
+ Project-URL: Issues, https://github.com/habaniu/duplex-vla/issues
10
+ Project-URL: Documentation, https://github.com/habaniu/duplex-vla/blob/main/FORMAT.md
11
+ Keywords: robotics,vla,full-duplex,spoken-dialogue,benchmark,dataset
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
19
+ Requires-Python: >=3.10
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Requires-Dist: numpy>=1.26
23
+ Requires-Dist: h5py>=3.10
24
+ Requires-Dist: PyYAML>=6.0
25
+ Requires-Dist: jsonschema>=4.18
26
+ Requires-Dist: regex>=2022.10.31
27
+ Provides-Extra: torch
28
+ Requires-Dist: torch>=2.0; extra == "torch"
29
+ Dynamic: license-file
30
+
31
+ # DUPLA
32
+
33
+ DUPLA is a data protocol and Python SDK for full-duplex vision-language-action (VLA). It aligns camera images, robot states and actions, and separate user and robot audio tracks on a shared timeline.
34
+
35
+ The Python SDK is packaged as `dupla-vla` and imported as `dupla`.
36
+
37
+ ## What it does
38
+
39
+ - **Prepare training windows.** Load the observations available at each decision and the expert action and robot speech targets for the next window.
40
+ - **Read benchmark cases.** Load scene setup, audio instructions, goals, and scoring rules.
41
+ - **Validate data.** Check timing and file integrity, and verify that paired trajectories share the same history before an intervention.
42
+
43
+ LIBERO-OmniDuplex uses DUPLA for its training data and evaluation benchmark. [Dataset](https://huggingface.co/datasets/habaniu/Libero-OmniDuplex) · [Format specification](FORMAT.md)
44
+
45
+ ## Install
46
+
47
+ ```sh
48
+ pip install dupla-vla
49
+ dupla --version
50
+ dupla conformance
51
+ ```
52
+
53
+ For PyTorch integration, use `pip install 'dupla-vla[torch]'`. From a source checkout, run `pip install .`. The base package requires NumPy, h5py, PyYAML, jsonschema, and regex. Four JSON schemas and a compact golden recording set are bundled inside the package, so `dupla conformance` runs offline with no external downloads.
54
+
55
+ ## Read demonstrations
56
+
57
+ ```python
58
+ from dupla import Dupla, WindowDataset, collate_windows
59
+ from dupla.conformance import GOLDEN
60
+
61
+ release = Dupla(GOLDEN) # Or an unpacked (assembled) demonstrations directory.
62
+ windows = WindowDataset(release, episode_ids=["reference"])
63
+ episode = release["reference"]
64
+ print(episode.control_rate) # Exact control ticks per second (Fraction).
65
+ w = episode.window_at(2, horizon_ticks=1)
66
+ print(w["observations"]["robot_text"]) # Completed words, with absolute start/end samples.
67
+ print(w["targets"]["robot_speaking"], w["targets"]["robot_text"]) # True, []
68
+ batch = collate_windows([windows[0], windows[1]])
69
+ policy_inputs = batch["observations"]
70
+ supervision = batch["targets"]
71
+ valid_pcm = supervision["robot_audio"][0, :supervision["robot_audio_lengths"][0]]
72
+ ```
73
+
74
+ ### Reading one window
75
+
76
+ - `episode.window_at(tick, horizon_ticks=..., history_ticks=None)` takes integer control ticks.
77
+ - `episode.window(tick=...)` takes an integer control tick. `episode.window(t=...)` takes the decision time in seconds.
78
+ `horizon_s` and `history_s` are also in seconds. The SDK converts second-valued inputs using `episode.control_rate` and the time-to-tick rules in the format specification.
79
+
80
+ Both return the same dictionary structure:
81
+ - `observations`: everything recorded up to the decision tick.
82
+ - `targets`: future expert actions, action mask, robot PCM, completed robot words, and `robot_speaking` over the prediction horizon.
83
+ - `metadata`: window categories, `event_tags`, and optional privileged ground truth.
84
+
85
+ Audio and word histories of both speakers always start at sample zero. By default, visual, state, and executed-action histories also start at the beginning of the episode; set `history_s` or `history_ticks` to bound only image and trajectory history. To inspect raw recorded streams directly, use `episode.event_audio(id)`, `episode.open_trajectory()`, or `episode.ground_truth()`. Use `release.pair_episodes(id)` to open a counterfactual pair.
86
+
87
+ ### Training windows: indexed vs generated
88
+
89
+ `WindowDataset(release, episode_ids=None, ...)` defaults to the `train` split when `episode_ids` is omitted. How windows are constructed depends on whether the release provides a `windows.jsonl` index:
90
+
91
+ | Parameter | Release has `windows.jsonl` (published releases) | No index, or episode in `window_fallback_episode_ids` |
92
+ | --- | --- | --- |
93
+ | Window positions | Exactly the published rows | Generate candidates on a stride grid anchored at control tick 0. Convert `stride_s` to control ticks to determine the spacing. Keep candidates at or after the first RGB capture whose full horizon lies within the episode and has `action_mask=True` at every step. |
94
+ | `horizon_s` | **Filter**: keeps rows whose `horizon_steps` matches; a horizon absent from the index yields 0 windows | Length of each generated window (default `1` s) |
95
+ | `stride_s` | **Ignored** | Step spacing between generated windows (default `1` s) |
96
+ | `coarse_category` / `fine_category` | Filters on published categories | Generated windows have `None` categories, so any category filter yields 0 windows |
97
+ | `history_s` | Bounds image and trajectory history | Same |
98
+
99
+ To read a custom horizon or decision tick outside the published index, call `episode.window_at()` or `episode.window()` directly.
100
+
101
+ `sampling_weights(category_weights)` resolves each window's weight from its fine category, then its coarse category, then `1.0`. An optional `transform` callable is applied to each assembled window.
102
+
103
+ ### Batching and PyTorch
104
+
105
+ `collate_windows` batches windows sharing camera, clock, action, state, and horizon specs. Audio PCM is right-padded with explicit lengths; image, state, and executed-action histories are left-padded with explicit lengths; word lists remain variable-length Python lists. For PyTorch, import `TorchWindowDataset`, `build_category_sampler`, and `collate_torch_windows` from `dupla.torch`.
106
+
107
+ Static type definitions live in `dupla.types` (`Window`, `Batch`) and `dupla.torch` (`TorchBatch`), and the package ships `py.typed`.
108
+
109
+ ### Performance tips
110
+
111
+ - **Bound history (`history_s`)**: leaving `history_s=None` includes every frame since the start of the episode. Setting `history_s` (for example `history_s=1`) reduces worker IPC copy volume and memory usage.
112
+ - **Use worker processes (`num_workers > 0`)**: each `Dupla` instance maintains fork-safe caches of recently opened episodes and lazily decoded RGB prefixes, so `DataLoader(..., num_workers=4)` scales cleanly under both `fork` and `spawn`.
113
+ - **Verify before training**: causal window reads only decode the RGB prefix needed up to the decision tick, so corruption near the end of an archive may not surface until later frames are read. Run `dupla verify` once before training.
114
+
115
+ ## Read benchmark assets
116
+
117
+ ```python
118
+ from dupla import Benchmark
119
+ from dupla.conformance import GOLDEN
120
+
121
+ case = Benchmark(GOLDEN)[0]
122
+ cursor = case.playback("u0", start_sample=1000)
123
+ cursor.advance_to(90) # The renderer confirms 90 samples played from this clip.
124
+ policy_speech = cursor.read() # Only played PCM on the primary audio track.
125
+ if cursor.status("reference_subtitles") == "evaluable":
126
+ diagnostic = cursor.read("reference_subtitles")
127
+ cursor.interrupt()
128
+ score = case.milestone_result("start", 0, available=[])
129
+ assert score["status"] == "not_evaluable" and score["score"] is None
130
+ ```
131
+
132
+ Use `Benchmark.get_case_ids()` to filter by suite, task, paradigm, or seen/unseen exposure axes. `case.env_binding`, `case.goals`, `case.events`, `case.audio_index()`, and `case.rules` are intended for the evaluator. Policies consume rendered observations and played PCM; the optional `reference_subtitles` diagnostic track is available only when word timings are present.
133
+
134
+ ## Work with a release (CLI)
135
+
136
+ Run these commands from the root of a downloaded release directory:
137
+
138
+ ```sh
139
+ dupla info ./benchmark
140
+ dupla verify ./benchmark
141
+ dupla verify ./demonstrations --partial --tmp-dir ./verify-tmp
142
+ dupla verify ./sample
143
+ dupla assemble ./demonstrations --shards train-00000.tar --out ./assembled
144
+ dupla info ./assembled
145
+ dupla verify ./assembled
146
+ dupla export-eval ./benchmark --voice unseen --limit 16 --out ./eval-preview
147
+ ```
148
+
149
+ ### Sharded downloads
150
+
151
+ A published `demonstrations/` directory packages whole families into tar shards indexed by `shards.json`. `dupla info` and `dupla verify` operate directly on the sharded directory. Before reading training windows with `Dupla(...)`, assemble the shards you need via `dupla assemble ... --shards ... --out DIR`, then open `DIR`.
152
+
153
+ For partial downloads, pass `--partial` to skip missing shards while verifying everything present. Sharded verification unpacks one shard at a time in `--tmp-dir` to bound scratch disk usage. Once every file in `SHA256SUMS` is downloaded, run `dupla verify .` at the release root.
154
+
155
+ ### Verification
156
+
157
+ `dupla verify` checks file checksums, JSON schemas, control/audio clocks, tensor shapes, family membership, counterfactual prefix digests, transcript/word alignment, finite trajectory values, and full RGB archive CRC integrity. When both demonstrations and benchmark are present, it also checks cross-split exposure and exact resource reuse. A passing check validates the dataset assets; evaluating a policy requires a separate closed-loop runner.
158
+
159
+ ## Current scope and limitations
160
+
161
+ - **Structural `event_tags` validation**: `dupla verify` checks that each window's `event_tags` field is a list of strings; dataset-specific tag semantics are documented by each release.
162
+ - **Full index loading**: constructing a `WindowDataset` over a small subset of episodes parses the release's complete `windows.jsonl` once per `Dupla` instance.
163
+ - **Full-modality window assembly**: every window reads all streams (RGB prefix, both PCM tracks, trajectory, and ground truth) before any `transform` runs.
164
+ - **Assemble before training**: sharded `demonstrations/` directories must be unpacked with `dupla assemble` before reading windows.
165
+
166
+ ## Documentation
167
+
168
+ - [Format specification](https://github.com/habaniu/duplex-vla/blob/main/FORMAT.md): file layout, clocks, and causal window contract.
169
+ - [SDK architecture](https://github.com/habaniu/duplex-vla/blob/main/ARCHITECTURE.md): module map, data flow, verification pipeline, and caching.
170
+ - [Changelog](https://github.com/habaniu/duplex-vla/blob/main/CHANGELOG.md)
171
+
172
+ ## License
173
+
174
+ The SDK, specification, and schemas are licensed under Apache-2.0. Datasets and third-party examples carry their own terms. [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0) · [Example provenance](src/dupla/conformance/golden/README.md)