miniverse-sdk 0.2.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 (31) hide show
  1. miniverse_sdk-0.2.0/LICENSE +201 -0
  2. miniverse_sdk-0.2.0/PKG-INFO +34 -0
  3. miniverse_sdk-0.2.0/README.md +16 -0
  4. miniverse_sdk-0.2.0/pyproject.toml +33 -0
  5. miniverse_sdk-0.2.0/setup.cfg +4 -0
  6. miniverse_sdk-0.2.0/src/miniverse_sdk/__init__.py +3 -0
  7. miniverse_sdk-0.2.0/src/miniverse_sdk/__main__.py +3 -0
  8. miniverse_sdk-0.2.0/src/miniverse_sdk/agent_help/__init__.py +1 -0
  9. miniverse_sdk-0.2.0/src/miniverse_sdk/agent_help/auth.md +30 -0
  10. miniverse_sdk-0.2.0/src/miniverse_sdk/agent_help/bundles.md +73 -0
  11. miniverse_sdk-0.2.0/src/miniverse_sdk/agent_help/index.md +30 -0
  12. miniverse_sdk-0.2.0/src/miniverse_sdk/agent_help/onnx.md +89 -0
  13. miniverse_sdk-0.2.0/src/miniverse_sdk/agent_help/sessions.md +9 -0
  14. miniverse_sdk-0.2.0/src/miniverse_sdk/agent_help/upload.md +18 -0
  15. miniverse_sdk-0.2.0/src/miniverse_sdk/api.py +164 -0
  16. miniverse_sdk-0.2.0/src/miniverse_sdk/bundles.py +267 -0
  17. miniverse_sdk-0.2.0/src/miniverse_sdk/cli.py +325 -0
  18. miniverse_sdk-0.2.0/src/miniverse_sdk/config.py +239 -0
  19. miniverse_sdk-0.2.0/src/miniverse_sdk/onnx_compat.py +442 -0
  20. miniverse_sdk-0.2.0/src/miniverse_sdk/onnx_metadata.py +183 -0
  21. miniverse_sdk-0.2.0/src/miniverse_sdk/schemas/__init__.py +1 -0
  22. miniverse_sdk-0.2.0/src/miniverse_sdk/schemas/onnx-simulation-contract-0.3.schema.json +208 -0
  23. miniverse_sdk-0.2.0/src/miniverse_sdk/schemas/simulation-bundle-v1.schema.json +184 -0
  24. miniverse_sdk-0.2.0/src/miniverse_sdk/validation.py +343 -0
  25. miniverse_sdk-0.2.0/src/miniverse_sdk.egg-info/PKG-INFO +34 -0
  26. miniverse_sdk-0.2.0/src/miniverse_sdk.egg-info/SOURCES.txt +29 -0
  27. miniverse_sdk-0.2.0/src/miniverse_sdk.egg-info/dependency_links.txt +1 -0
  28. miniverse_sdk-0.2.0/src/miniverse_sdk.egg-info/entry_points.txt +2 -0
  29. miniverse_sdk-0.2.0/src/miniverse_sdk.egg-info/requires.txt +3 -0
  30. miniverse_sdk-0.2.0/src/miniverse_sdk.egg-info/top_level.txt +1 -0
  31. miniverse_sdk-0.2.0/tests/test_cli.py +475 -0
@@ -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,34 @@
1
+ Metadata-Version: 2.4
2
+ Name: miniverse-sdk
3
+ Version: 0.2.0
4
+ Summary: Validate and upload Dollhouse Robotics Miniverse simulation bundles.
5
+ Author: Dollhouse Robotics
6
+ License-Expression: Apache-2.0
7
+ Classifier: Development Status :: 3 - Alpha
8
+ Classifier: Environment :: Console
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3 :: Only
11
+ Requires-Python: >=3.10
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: jsonschema<5,>=4.23
15
+ Requires-Dist: keyring<26,>=25
16
+ Requires-Dist: onnx<2,>=1.17
17
+ Dynamic: license-file
18
+
19
+ # Miniverse SDK
20
+
21
+ The `miniverse-sdk` distribution installs the `miniverse` command for validating
22
+ and uploading immutable `.dhsim` simulation bundles.
23
+
24
+ ```bash
25
+ uv tool install miniverse-sdk
26
+ miniverse agent-help
27
+ ```
28
+
29
+ Use `MINIVERSE_API_TOKEN` for CI authentication, or run `miniverse auth login`
30
+ once for interactive device authorization. Interactive access and refresh
31
+ tokens are stored in a user-only file and renewed automatically. On ephemeral
32
+ Linux agents, persist `$XDG_STATE_HOME/miniverse` (or `~/.local/state/miniverse`).
33
+ Upgrades from a pre-0.2 keyring login require one new `miniverse auth login`;
34
+ the CLI does not migrate the old access-token-only credential.
@@ -0,0 +1,16 @@
1
+ # Miniverse SDK
2
+
3
+ The `miniverse-sdk` distribution installs the `miniverse` command for validating
4
+ and uploading immutable `.dhsim` simulation bundles.
5
+
6
+ ```bash
7
+ uv tool install miniverse-sdk
8
+ miniverse agent-help
9
+ ```
10
+
11
+ Use `MINIVERSE_API_TOKEN` for CI authentication, or run `miniverse auth login`
12
+ once for interactive device authorization. Interactive access and refresh
13
+ tokens are stored in a user-only file and renewed automatically. On ephemeral
14
+ Linux agents, persist `$XDG_STATE_HOME/miniverse` (or `~/.local/state/miniverse`).
15
+ Upgrades from a pre-0.2 keyring login require one new `miniverse auth login`;
16
+ the CLI does not migrate the old access-token-only credential.
@@ -0,0 +1,33 @@
1
+ [build-system]
2
+ requires = ["setuptools>=69"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "miniverse-sdk"
7
+ version = "0.2.0"
8
+ description = "Validate and upload Dollhouse Robotics Miniverse simulation bundles."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ dependencies = [
12
+ "jsonschema>=4.23,<5",
13
+ "keyring>=25,<26",
14
+ "onnx>=1.17,<2",
15
+ ]
16
+ license = "Apache-2.0"
17
+ license-files = ["LICENSE"]
18
+ authors = [{ name = "Dollhouse Robotics" }]
19
+ classifiers = [
20
+ "Development Status :: 3 - Alpha",
21
+ "Environment :: Console",
22
+ "Programming Language :: Python :: 3",
23
+ "Programming Language :: Python :: 3 :: Only",
24
+ ]
25
+
26
+ [project.scripts]
27
+ miniverse = "miniverse_sdk.cli:main"
28
+
29
+ [tool.setuptools.packages.find]
30
+ where = ["src"]
31
+
32
+ [tool.setuptools.package-data]
33
+ miniverse_sdk = ["agent_help/*.md", "schemas/*.json"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,3 @@
1
+ """Public package metadata for the Miniverse CLI."""
2
+
3
+ __version__ = "0.2.0"
@@ -0,0 +1,3 @@
1
+ from .cli import main
2
+
3
+ raise SystemExit(main())
@@ -0,0 +1 @@
1
+ """Versioned agent instructions bundled with miniverse-sdk."""
@@ -0,0 +1,30 @@
1
+ # Authentication
2
+
3
+ For CI or another non-interactive environment, provide the token only through
4
+ the environment:
5
+
6
+ ```bash
7
+ MINIVERSE_API_TOKEN=... miniverse bundle upload PATH.dhsim --json
8
+ ```
9
+
10
+ Do not pass a token as an argument, write it into repository files, or include
11
+ it in logs. `MINIVERSE_API_TOKEN` takes precedence over an OAuth credential.
12
+
13
+ For a person at a terminal, run `miniverse auth login` once. Complete the
14
+ displayed device authorization in the browser. The CLI stores the renewable
15
+ OAuth grant in a user-only file and refreshes it automatically, including after
16
+ an API response reports that the access token expired.
17
+
18
+ On Linux the default is `$XDG_STATE_HOME/miniverse/auth.json`, or
19
+ `~/.local/state/miniverse/auth.json` when `XDG_STATE_HOME` is unset. Set
20
+ `MINIVERSE_HOME` to put `auth.json` in a different persistent directory. An
21
+ ephemeral agent or container must mount that directory across runs.
22
+
23
+ The renewable credential format is a hard cutover. A pre-0.2 keyring login is
24
+ not read, copied, or deleted; run `miniverse auth login` once after upgrading.
25
+
26
+ Inspect only non-secret metadata with `miniverse auth status`. Run
27
+ `miniverse auth logout` to remove the local OAuth credential and attempt
28
+ server-side revocation; local removal still succeeds if revocation is
29
+ unavailable. To opt back into an available desktop credential service, set
30
+ `MINIVERSE_AUTH_STORE=keyring`.
@@ -0,0 +1,73 @@
1
+ # Bundle validation
2
+
3
+ A `.dhsim` archive contains exactly `bundle.json`, `policy.py`, mandatory
4
+ `embodiment/mjcf.zip`, and one or more `models/<id>.onnx` files. Do not put a
5
+ `scene`, `seed`, `robot`, `visual`, `primaryModel`, model providers,
6
+ or model loading policy in `bundle.json`.
7
+
8
+ The Python controller declares
9
+ its physics/policy/publication timing, owns randomness, sees all models through
10
+ `context.models`, constructs all inputs from `PolicyStep.sim_data`, and returns
11
+ physical actuation in canonical MJCF actuator order. Optional `metadata` is a
12
+ freeform JSON object and has no execution semantics.
13
+
14
+ For a policy-specific spawn/reset, define `initial_state()` on the controller
15
+ and return `ControllerInitialState` with the canonical root body ID, a
16
+ world-frame position, and an XYZW unit quaternion. Do not put reset state in
17
+ `bundle.json`; without the hook Miniverse uses the MJCF's compiled default pose.
18
+ Miniverse also derives rendering-only visuals from the included MJCF and
19
+ `embodiment.appearance.geometry`; do not include visual bytes yourself.
20
+ MJCF geoms may be both visible and collision-active. Authors can add
21
+ physics-neutral custom visuals with `contype="0" conaffinity="0" mass="0"`
22
+ without changing the bundle schema or simulation dynamics. Author visual `pos`,
23
+ `quat`, and `fromto` values in the MJCF source frame.
24
+
25
+ Author actuator gains, control/force ranges, and Miniverse's namespaced
26
+ actuator velocity-limit numeric directly in `embodiment/mjcf.zip`. Use
27
+ `embodiment.bodyDynamicsOverrides` only for exact named-body linear/angular
28
+ damping and maximum linear/angular velocity. Unsupported backends produce a
29
+ descriptive runtime error.
30
+
31
+ Each ONNX checkpoint must be self-contained and embed all Miniverse policy
32
+ metadata in
33
+ `com.dollhouserobotics.miniverse.simulation_contract`. Do not create an
34
+ adjacent JSON manifest. The embedded contract must include:
35
+
36
+ - complete model tensor shapes and dtypes;
37
+ - model outputs consumed explicitly by controller code;
38
+ - `precision: fp32 | fp16 | bf16`.
39
+
40
+ Precision is the requested Miniverse inference/compiler precision; it does not
41
+ assert that every tensor in the ONNX graph has that dtype. Missing and unknown
42
+ precision values are rejected. Exporters using
43
+ `miniverse.contracts.embed_onnx_contract` should pass
44
+ `{"schemaVersion": "0.3", "precision": "fp16", ...}`.
45
+
46
+ Run `miniverse bundle validate PATH.dhsim --json` before upload. Local validation
47
+ checks the archive structure, normative manifest, ONNX graph and embedded
48
+ contract, hashes, tensor mappings, fixed batch-one shapes, simulator support,
49
+ and statically knowable compatibility. It returns `errors`, `warnings`, and a
50
+ per-model result. Errors always produce exit status 2. Optimization warnings
51
+ produce exit status 0 unless `--strict` promotes them to errors. Server import
52
+ repeats validation over the uploaded bytes and remains authoritative for
53
+ embodiment/scene preprocessing and genuine backend execution. Treat an uploaded
54
+ bundle as immutable and preserve simulator profile, model, embodiment,
55
+ coordinate-frame, and actuator-order identities.
56
+
57
+ Validation also statically scans each ONNX graph for TensorRT builder limits
58
+ and reports them in `warnings` (for example `tensorrt_topk_k_limit`: TopK `K`
59
+ must be at most 3840, and a full sort lowers to TopK over the entire axis).
60
+ Warning findings do not invalidate a bundle — the ONNX Runtime fallback still
61
+ executes it — but Miniverse cannot derive TensorRT or TensorRT-RTX artifacts
62
+ until they are fixed, so re-export the checkpoint before uploading. Error
63
+ findings always invalidate the bundle. Pass `--strict` to promote optimization
64
+ warnings to errors. To validate a checkpoint during export iteration,
65
+ before it is zipped into a bundle, run:
66
+
67
+ ```bash
68
+ miniverse model validate PATH.onnx --json
69
+ ```
70
+
71
+ ONNX is the developer-facing checkpoint submission artifact. Developers do not
72
+ build or upload TensorRT, TensorRT-RTX, plan, or runtime-cache files; Miniverse
73
+ derives and invalidates those artifacts internally.
@@ -0,0 +1,30 @@
1
+ # Miniverse agent guide
2
+
3
+ You are using `miniverse-sdk` 0.2.0. Miniverse is Dollhouse Robotics'
4
+ cloud-based robotics physics simulation platform.
5
+
6
+ Start with:
7
+
8
+ ```bash
9
+ miniverse version --json
10
+ miniverse auth status --json
11
+ miniverse bundle validate PATH.dhsim --json
12
+ ```
13
+ Use `miniverse auth login` once for a persistent agent workspace; the CLI
14
+ refreshes that grant automatically. Use `MINIVERSE_API_TOKEN` for CI. Never
15
+ print credentials or signed transfer URLs.
16
+
17
+ Read the relevant topic before acting:
18
+
19
+ ```bash
20
+ miniverse agent-help auth
21
+ miniverse agent-help bundles
22
+ miniverse agent-help onnx
23
+ miniverse agent-help upload
24
+ miniverse agent-help sessions
25
+ ```
26
+
27
+ Read `onnx` BEFORE exporting a checkpoint: it lists the TensorRT-RTX
28
+ compatibility rules (no full-axis sorts, static TopK K, no data-dependent
29
+ control flow) that determine whether Miniverse can serve the checkpoint
30
+ through optimized inference instead of the ONNX fallback.
@@ -0,0 +1,89 @@
1
+ # Exporting TensorRT-compatible ONNX checkpoints
2
+
3
+ Miniverse attempts to compile each uploaded checkpoint with TensorRT-RTX and
4
+ standard TensorRT to serve optimized inference. A checkpoint that only runs
5
+ under the ONNX Runtime fallback still works, but loses the optimized path — so
6
+ export with the compiler in mind, then lint before bundling:
7
+
8
+ ```bash
9
+ miniverse model validate model.onnx --strict --json
10
+ ```
11
+
12
+ Fix findings by re-exporting from the source checkpoint, never by editing
13
+ graph bytes by hand.
14
+
15
+ ## Contract requirements
16
+
17
+ - Server-side import requires opset 13–21 (18 recommended) with static input
18
+ and output shapes. Local CLI validation does not currently enforce the opset
19
+ range, so treat a successful local result as preflight feedback rather than
20
+ import acceptance.
21
+ - Embed the Miniverse simulation contract (schema 0.3) in the model metadata,
22
+ including `precision` (`fp32`, `fp16`, or `bf16`). Weights stay fp32 in the
23
+ ONNX; `precision` declares the execution precision the compilers target.
24
+ - Export a single policy step.
25
+ - Every graph op must be on the runtime allowlist (deterministic tensor math
26
+ only); `miniverse model validate` reports violations as errors.
27
+ - Recurrent policies declare `stateBindings` pairing a state input with a
28
+ same-shape state output; the runtime owns allocation, feedback, and reset.
29
+ - Temporal features come from declarative `historyBuffers` (capacity +
30
+ `sampleOffsets` over any provider source), not from hand-rolled buffers.
31
+ - Actuator-target outputs are physical values: v0.3 has no output
32
+ `scale`/`offset`. Bake PD scaling and decoding into the graph.
33
+ - `miniverse model validate` also lints exact per-input operations against each
34
+ simulator profile. Fix `unsupported` rows before uploading. This is a lint,
35
+ not a `requiredCapabilities` declaration or runtime negotiation mechanism;
36
+ runtime failures repeat the selected and supporting backends descriptively.
37
+
38
+ ## TensorRT compatibility rules
39
+
40
+ **No full-axis sorts.** `torch.sort` and full-vocabulary `torch.topk` lower to
41
+ ONNX `TopK` with K equal to the axis length, which TensorRT cannot compile.
42
+ Restructure the math instead: prefer fixed-iteration, data-independent
43
+ formulations (for example threshold-based selection built from elementwise
44
+ compares and reductions) that preserve the checkpoint's output distribution.
45
+ Do not simply cap K when doing so changes policy behavior.
46
+
47
+ **Keep every `TopK` K a graph constant.** Shape-derived or otherwise dynamic
48
+ K cannot be verified at build time and fails compilation.
49
+
50
+ **For generative policies with in-graph sampling, declare `precision: "fp16"`
51
+ only when the whole graph tolerates it.** The compilers convert every float
52
+ tensor, not just the network weights. An fp16 cumulative distribution resolves
53
+ ~5e-4 absolute, so a sampler over a large vocabulary cannot draw tokens below
54
+ that probability and their mass shifts onto neighbours — a silent behavior
55
+ change that ONNX Runtime (which executes the declared fp32 graph) never shows.
56
+ Declare `fp32` for sampler-bearing graphs unless the CDF is kept in full
57
+ precision by construction.
58
+
59
+ **No data-dependent control flow.** Unroll loops to a fixed iteration count at
60
+ export; avoid `If`/`Loop`/`Scan` nodes.
61
+
62
+ **Do not change floating-point precision to gain compatibility.** Export the
63
+ exact dtypes of the source checkpoint. Never recast weights, activations, or
64
+ accumulations to lower or mixed precision merely to satisfy a compiler finding;
65
+ if a checkpoint only compiles after altering precision, treat it as
66
+ incompatible and report the finding to the user instead of uploading the
67
+ modified graph.
68
+
69
+ **For transformer-based policies, avoid known PyTorch export traps:**
70
+
71
+ - Disable the fused transformer fast path before export
72
+ (`torch.backends.mha.set_fastpath_enabled(False)`); the fused aten op has no
73
+ ONNX lowering.
74
+ - Avoid mutation-based indexed assignment and indexed constant construction;
75
+ they can produce invalid-rank `ScatterElements` nodes. Use functional
76
+ equivalents (`torch.where`, `torch.cat`, arithmetic index transforms).
77
+
78
+ ## Verify, bundle, upload
79
+
80
+ ```bash
81
+ miniverse model validate model.onnx --strict --json
82
+ miniverse bundle validate bundle.dhsim --strict --json
83
+ miniverse bundle upload bundle.dhsim --json
84
+ ```
85
+
86
+ `bundle validate` runs the same model validation across every model in the
87
+ archive. Contract, graph, hash, tensor, or simulator errors always fail.
88
+ Warnings mean the checkpoint will import and run on the fallback but cannot be
89
+ compiled; `--strict` promotes those warnings to errors.
@@ -0,0 +1,9 @@
1
+ # Session evidence and lifecycle
2
+
3
+ A simulation is ready only after a valid descriptor and monotonically advancing
4
+ sequence and physics ticks. For policy bundles also require policy invocation,
5
+ actuator write/target evidence, and observable joint, body, or root changes.
6
+
7
+ Treat health, allocation, `running`, WebSocket connection, and scene rendering
8
+ as intermediate signals. Verify command acknowledgement and command-to-effect,
9
+ then explicitly stop the session and confirm assignment release.
@@ -0,0 +1,18 @@
1
+ # Bundle upload
2
+
3
+ Run:
4
+
5
+ ```bash
6
+ miniverse bundle upload PATH.dhsim --json
7
+ ```
8
+
9
+ The CLI creates a D1-backed bundle revision and uploads the archive directly to
10
+ the returned conditional R2 URL. An R2 object-create event starts server-side
11
+ inspection and preprocessing; the CLI does not send a completion request or
12
+ declare the archive's manifest and asset identities. Use `--no-wait` to detach
13
+ and `miniverse bundle status ID@REVISION_ID` to resume observation.
14
+
15
+ An uploaded revision remains private when it becomes ready. Publication is a
16
+ separate, explicit `miniverse bundle publish ID@REVISION_ID` action that moves
17
+ the bundle's current-revision pointer. Never infer publication
18
+ or simulator readiness from an HTTP 202, object presence, or provider status.