Repository navigation
Add NeRD model extension and an SL training showcase - #855
Conversation
[Medium impact] The changes reach a shared training workflow, a bundled model package, and the NeRD showcase. Fix CPU history lengths in padded CUDA inference before merging.
|
Preserve both model-extension and vendor robot asset checks. Update the synthetic wheel fixture and cover missing asset entry points and retired robot modules. Validation: 145 focused checks, API/context gates, and actual wheel build, release guard, metadata and SL train/export/inference smoke.
| index = (valid_lengths - 1)[:, None, None].expand(-1, 1, value.shape[-1]) | ||
| return value.gather(1, index) |
There was a problem hiding this comment.
NeRDModel.evaluate() accepts and checks CPU valid_lengths, but leaves the gather index on CPU. With a CUDA model and CUDA inputs, passing CPU lengths—such as the length tensor returned by DynamicsWindowDataset.get_batch()—then fails at value.gather() instead of returning predictions.
Move the checked lengths or the resulting index to value.device before gathering.
| index = (valid_lengths - 1)[:, None, None].expand(-1, 1, value.shape[-1]) | |
| return value.gather(1, index) | |
| index = (valid_lengths.to(value.device) - 1)[:, None, None].expand( | |
| -1, 1, value.shape[-1] | |
| ) | |
| return value.gather(1, index) |
Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/embodichain_models/embodichain_models/dynamics/nerd/model.py
Line: 323-324
Comment:
**Padded GPU inference fails**
`NeRDModel.evaluate()` accepts and checks CPU `valid_lengths`, but leaves the gather index on CPU. With a CUDA model and CUDA inputs, passing CPU lengths—such as the `length` tensor returned by `DynamicsWindowDataset.get_batch()`—then fails at `value.gather()` instead of returning predictions.
Move the checked lengths or the resulting index to `value.device` before gathering.
```suggestion
index = (valid_lengths.to(value.device) - 1)[:, None, None].expand(
-1, 1, value.shape[-1]
)
return value.gather(1, index)
```
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
Description
Add NeRD as an installable model extension and runnable SL showcase, keeping model-specific collection, reference experiments and raw assets out of the core.
embodichain.learning.slowns shared supervised updates, training and recovery; the NeRD recipe uses that trainer by default.The branch includes current
mainat8cb2b5353(#846), with no conflicts or changes to upstream motion code. #857 was merged into this PR's feature branch, rather thanmain; its SL foundation remains included here. The #860 NeRD-to-SL integration is also consolidated here as requested.Refs #822, #848 and #860.
Ownership and entry points
embodichain.learning.sl;embodichain train-slembodichain.learning.modelsembodichain_models.dynamics.nerd, fromextensions/embodichain_models/embodichain_models/examples/learning/nerd/, with private_supporthelpersexamples/learning/nerd/configs/;embodichain run-example learning/nerdRemove the NeRD-only
compute/dynamics,data_pipeline/dynamics,learning/dynamics,learning/models/nerdand specialized coredynamicsCLI. Preserve released general MLP/RL imports. The model extension is bundled in the same wheel/version; it has no separate distribution or registry and does not import the example, Newton, Warp or the simulator for inference/SL training.The extension has two first-level domains defined by prediction contract:
policypredicts actions;dynamicspredicts future state, geometry, observations or latent transitions. Canonical packages underembodichain_modelsarepolicy.bc,dynamics.nerd,dynamics.rwmanddynamics.rigidformer. Only NeRD is implemented here; the other three are migration targets for their follow-ups. RWM belongs todynamicsbecause it predicts next robot state from state/action/context;world_modelsis not a parallel domain or alternate namespace. Modalities, network architecture and training methods do not determine the domain or imply gradient/solver capabilities. The model catalog contract owns this naming.Downloadable assets
The four former packaged reference files now live at reference_assets/v1 on Hugging Face. Their bytes, attribution and upstream Apache license are preserved; all 116 pre-existing remote files remain unchanged. Raw XML/URDF files are absent from the core and wheel.
Preparation pins the asset revision above, dataset revision
b9ec58f36da99cc99a93f97adfe74ebc9fd66586and portable-model revision78e581526570069410bf269b38c0c52c800b24a7. It verifies manifests and payload/member hashes, uses caller-owned caches, and supports--assets-onlyand--local-files-only. Imports do not download resources.The default recipe uses common SL checkpoints. Both common SL and historical NeRD checkpoints export through the showcase, preserving floating precision and ordered feature columns. Relative default outputs resolve from the caller's directory after wheel installation. See the showcase README for custom recipes, resume and historical workflows.
Review fixes
last.ptpreserves an owned CPU best snapshot and selection boundary for recovery into a fresh directory.Independent migration review also found and fixed the implicit evaluation preset's output-directory resolution. Installed-showcase execution checks verified that outputs stay in the caller's directory.
Validation
At the requesting user's direction, remove all NeRD-specific unit tests from this PR: 19 test modules and their helper/package/fixture files, 27 files in total. Shared SL, generic packaging, documentation and CI checks remain. Clear the deleted test paths from the context map and route NeRD validation to runnable showcase/reference workflows.
HF_ENDPOINT=https://hf-mirror.comand an empty NeRD resource cache, a real download of the pinned reference bundle succeeds from the canonical Hub. Checksum verification and offline cache reuse also pass.last.pt, and run held-out inference over 12 test windows. No NeRD unit-test files are added or retained.black ., whitespace checks, context validation and 3168/3168 API documentation coverage pass.Earlier long numerical qualification remains bound to its recorded source revisions and the frozen acceptance protocol. Historical test counts describe those older revisions rather than the current test inventory.
CI follow-up
The failing test job had four NeRD asset-download failures and 10,117 passing checks. Its global mirror returned missing Hub commit metadata for the newly published asset revision. Fetch this small pinned reference bundle explicitly from
https://huggingface.co; retain the configured mirrors for other data/model downloads and preserve all pinned revisions, hashes, cache and offline semantics.Commit
2c9ee8875includes the download fix and the requested removal of NeRD unit tests. The push triggers a new CI run; local validation is reported separately from its eventual result.Contracts, dependencies and review
last.ptis resumable state; historical newbest.ptfiles are model-only selected snapshots. The default common SL recipe exports its committed last weights. Older complete NeRD checkpoints and portable models remain readable; trusted legacy Python-object conversion still requires explicit--trust-pickle. Physical metadata/provenance is preserved rather than relabeled, and collector resume still requires the recorded source identity.DDP #864, RWM #859, RigidFormer #858 and draft BC #861 remain separate follow-ups and will need to follow the new extension/import layout. This PR does not claim full-budget retraining, paper-level reproduction, native learned-solver deployment or completed ODS integration.
Keep this PR open for the requesting user's review; auto-merge is disabled.
Type of change
Checklist
black .with Black 26.10.1.