Skip to content

Add SONIC v1.1 inference and verified model setup - #4305

Open
Nabla7 wants to merge 11 commits into
pim/fix/g1-control-foundationfrom
pim/feat/g1-sonic-inference
Open

Nabla7 wants to merge 11 commits into
pim/fix/g1-control-foundationfrom
pim/feat/g1-sonic-inference

Conversation

@Nabla7

@Nabla7 Nabla7 commented Sep 28, 2026 •

Copy link
Copy Markdown
Collaborator

What is this feature?

Add NVIDIA GEAR-SONIC v1.1 planner, encoder and decoder inference in dimos/control/sonic/, including joint mappings, observation history, trajectory timing, explicit gait selection and streamed motion references. The default gait is slow walk; velocity commands do not automatically switch gaits. Squat and kneeling request no translation, neutral crawl input stops translation, and face-down mode 7 is excluded from the selectable menu.

The model installer downloads pinned policy/configuration assets and 13 motion clips into the DimOS cache and verifies SHA-256 hashes. The ONNX Runtime wrapper configures CUDA sessions and checks JetPack compatibility. An explicit cpu_simulation=True option uses CPU sessions with four inference threads; the runnable G1 layer selects it for macOS simulation and rejects it for hardware. This layer also contains pipeline tests and dependency metadata.

Layer 2 of the SONIC stack, based on #4304 and followed by #3557: 7 files, +2,650/-1. The standalone policy module, runnable blueprint and Jetson installer are in #3557.

The planner timeout stays with SONIC inference; shared motor faults use the G1 control helper from #4304. No sim2 or unmerged coordinator dependency.

Why do we need this?

Keep model execution and reference handling separately reviewable from hardware command delivery and the robot module. The inference layer accepts numeric references without requiring a headset integration.

How to Test

uv run --no-sync pytest \
  dimos/control/tasks/test_registry.py \
  dimos/control/sonic/test_sonic_pipeline.py \
  dimos/robot/test_all_blueprints_generation.py
uv run --no-sync dimos-sonic-models --check

At 69195ae06, 73 inference/motor-fault tests and targeted mypy pass with only layers 1 and 2 present. Previous checkpoint evidence: all 43 cached model/configuration/clip assets verified offline. Asset verification requires the models to have been installed with dimos-sonic-models first. These checks do not establish crawl stability or hardware motion safety.

Latest layer-only verification: 52 inference tests passed, plus targeted mypy and commit hooks. Tests cover explicit CPU inference, default CPU-only rejection and rejection of unintended CUDA-to-CPU fallback.

Which issue(s) does this PR close?

Part of #3557; no separate issue is closed.

Checklist

  • I have read and approved the CLA.

Stack update (2026-10-22)

Review and merge in order:

  1. Preserve G1 motor-command freshness and MuJoCo timing #4304: G1 motor delivery and simulation foundation.
  2. Add SONIC v1.1 inference and verified model setup #4305: SONIC inference and verified assets.
  3. Integrate standalone G1 SONIC policy and blueprint #3557: standalone policy module and blueprint.
  4. feat(g1): add SONIC Desktop activation and stop controls #4783 (draft): Desktop activation/stop APIs and run-bound gateway calls.
  5. feat(g1): add enterprise Pico WebXR full-body SONIC teleop #4784 (draft): enterprise Pico browser WebXR full-body teleop.

Controller app companion: jeff-hykin/dim-controller#1, separate repository.

Main at 42ca50dfef is merged through the original three branches without rewriting history. No sim2 or unmerged ControlCoordinator dependency was introduced. The native Pico/XRoboToolkit workaround is excluded.

Previous checkpoint, before the Mac CPU fix: 224 focused Python checks passed (SONIC/WebXR/movement, gateway/G1 safety/clocks/sim adapter, composition and registry); one hardware-specific check was skipped. Targeted mypy and commit hooks passed. The companion UI passed 290 tests and production-bundle desktop/mobile browser checks using mocked gateway replies.

Mac CPU simulation is now supported and verified with the actual SONIC models in MuJoCo (walking, stopping and staying upright). Hardware still requires CUDA. Enterprise-Pico tracking and physical-robot acceptance remain pending; no robot deployment or actuation was performed.

@github-actions github-actions Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

go2 replay realtime

Details
Benchmark suite Current: 6d4cfc9 Previous: 576d547 Ratio
first frame wall 9.619 s 9.922 s 0.97
first frame cpu 19.62 s 20.847 s 0.94
run cpu 32.694 s 29.144 s 1.12
run cpu (user) 23.424 s 21.535 s 1.09
run cpu (system) 9.27 s 7.609 s 1.22
peak memory 2734.625 MB 2715.977 MB 1.01
peak threads 401 threads 409 threads 0.98
disk read 14.434 MB 29.492 MB 0.49
disk write 812.289 MB 753.289 MB 1.08

This comment was automatically generated by workflow using github-action-benchmark.

@github-actions github-actions Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'go2 replay realtime'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.08.

Benchmark suite Current: 6d4cfc9 Previous: 576d547 Ratio
run cpu 32.694 s 29.144 s 1.12
run cpu (user) 23.424 s 21.535 s 1.09
run cpu (system) 9.27 s 7.609 s 1.22

This comment was automatically generated by workflow using github-action-benchmark.

@codecov

codecov Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 79.94524% with 293 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
dimos/control/sonic/sonic_pipeline.py 79.94% 115 Missing and 34 partials ⚠️
dimos/control/sonic/streamed_motion.py 56.66% 50 Missing and 15 partials ⚠️
dimos/control/sonic/models.py 27.39% 52 Missing and 1 partial ⚠️
dimos/control/sonic/sonic_onnx_runtime.py 75.86% 11 Missing and 3 partials ⚠️
dimos/control/sonic/preflight.py 71.42% 11 Missing and 1 partial ⚠️
@@                        Coverage Diff                        @@
##           pim/fix/g1-control-foundation    #4305      +/-   ##
=================================================================
- Coverage                          82.43%   82.31%   -0.12%     
=================================================================
  Files                               1694     1700       +6     
  Lines                             158953   160414    +1461     
  Branches                           13316    13492     +176     
=================================================================
+ Hits                              131031   132052    +1021     
- Misses                             24248    24651     +403     
- Partials                            3674     3711      +37     
Components Coverage Δ
Tests 96.88% <100.00%> (+0.01%) ⬆️
Flag Coverage Δ
OS-macos-latest 76.41% <79.94%> (+0.03%) ⬆️
OS-ubuntu-24.04-arm 76.24% <79.94%> (+0.03%) ⬆️
OS-ubuntu-latest 76.59% <79.94%> (+0.03%) ⬆️
Py-3.10 76.59% <79.94%> (+0.03%) ⬆️
Py-3.11 76.58% <79.94%> (+0.23%) ⬆️
Py-3.12 76.59% <79.94%> (+0.03%) ⬆️
SelfHosted-Large 31.82% <20.12%> (-0.28%) ⬇️
SelfHosted-Linux 40.25% <20.12%> (-0.20%) ⬇️
SelfHosted-macOS 40.57% <20.12%> (-0.20%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
dimos/control/sonic/test_sonic_pipeline.py 100.00% <100.00%> (ø)
dimos/control/sonic/preflight.py 71.42% <71.42%> (ø)
dimos/control/sonic/sonic_onnx_runtime.py 75.86% <75.86%> (ø)
dimos/control/sonic/models.py 27.39% <27.39%> (ø)
dimos/control/sonic/streamed_motion.py 56.66% <56.66%> (ø)
dimos/control/sonic/sonic_pipeline.py 79.94% <79.94%> (ø)

... and 11 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@greptile-apps

greptile-apps Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 3/5

[High risk] Adds SONIC inference pipeline with new model dependencies.

Not safe to merge until the posture dwell and reset failures are fixed.

Findings

  1. P1 Repeated commands skip posture dwell ▶
  2. P1 Reset stalls the next plan ▶

Summary

Adds SONIC v1.1 model setup and inference. Two control failures need fixing before merge: repeating a floor-posture command skips its safety dwell, and resetting during inference can make the next plan time out before it starts.

Reviews (1) · Last reviewed commit: "feat(sonic): add v1.1 inference pipeline..."

Comment on lines +682 to +688
stages = _transition_stages(self._mode_override, target)
self._mode_queue = stages[1:]
self._mode_dwell = 0.0
first = stages[0]
if first != self._mode_override:
self._needs_replan = True
self._mode_override = first

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Repeated commands skip posture dwell

Requesting CRAWLING from standing selects KNEEL_TWO_LEGS and queues CRAWLING until the two-second dwell ends. Repeating CRAWLING during that dwell recalculates the transition from KNEEL_TWO_LEGS and selects CRAWLING immediately. This bypasses the pause intended to prevent a violent drop and must be fixed before merging.

Artifacts

Executable single-request and repeated-request pipeline reproduction

  • This authored script runs the real mode-transition and policy-step logic with mocked ONNX sessions; it provides the executed source for both comparisons.

Pipeline output with one CRAWLING request

  • The command completed with exit code 0 and showed KNEEL_TWO_LEGS still selected after 0.04s; the dwell held without a repeated request.

Pipeline output after repeating CRAWLING at 0.02s

  • The command completed with exit code 0 and showed CRAWLING selected after 0.04s; the repeated request bypassed the dwell.

View artifacts

T-Rex Ran code and verified through T-Rex

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Repeating a posture request now preserves the active kneeling pause, and changing the requested target also preserves that pause.

Comment thread dimos/control/sonic/sonic_pipeline.py Outdated
Comment on lines +863 to +865
if self._planner_future is not None and not self._planner_future.done():
self._planner_future.cancel()
self._planner_future = None

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Reset stalls the next plan

If reset occurs during planner inference, cancelling and discarding its future does not stop the running job. The next plan queues behind it on the sole worker, but its one-second timeout starts at submission. Reactivating control can therefore raise a planner timeout before the new inference starts; this must be fixed before merging.

Artifacts

Source for the planner reset reproduction

  • This authored Python harness runs the real pipeline and executor with a controllable fake planner, reproducing both reset timings.

Planner run with reset after inference finished

  • The command completed with exit code 0 and the second plan produced a trajectory without timing out.

Planner run with reset during inference

  • The command completed with exit code 0 after asserting that the queued second plan timed out before it started.

View artifacts

T-Rex Ran code and verified through T-Rex

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reset now retains running inference until it finishes and discards its result before starting another plan with a fresh deadline, while preserving the original timeout if the old inference gets stuck.

@greptile-apps

greptile-apps Bot commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

Comments Outside Diff

These findings sit on lines the diff does not cover, so they could not be posted inline. Each one leaves this list once its file changes.

  • P1 Repeated CRAWLING request bypasses the kneeling safety dwell ▶

    • Bug
      • After standing-to-CRAWLING selects KNEEL_TWO_LEGS, sending CRAWLING again before two seconds immediately selects CRAWLING.
    • Cause
      • dimos/control/tasks/g1_sonic_wbc_task/sonic_pipeline.py:682-688 recomputes stages from the current override (5), replaces the pending queue, and applies the first stage (8) without preserving the active dwell.
    • Fix
      • When the requested target is already pending, preserve the current stage, queue, and dwell; advance only through the timed transition in step().
  • P1 Reset leaves a running plan occupying the sole worker ▶

    • Bug
      • A plan submitted after reset can spend its entire one-second timeout queued behind the pre-reset inference and fault before its own inference starts.
    • Cause
      • dimos/control/tasks/g1_sonic_wbc_task/sonic_pipeline.py:863-865 cancels and discards the future without replacing the executor when it is still open. Cancellation does not stop a running job. The new job is submitted to the same single-worker executor at lines 1104-1115, while lines 1118-1124 measure its timeout from submission.
    • Fix
      • On reset, isolate subsequent plans from an in-flight worker, and ensure superseded work cannot publish results; alternatively account for queue time separately from inference time.

@Nabla7
Nabla7 force-pushed the pim/feat/g1-sonic-inference branch from ac5a769 to bcafe13 Compare September 28, 2026 15:26

@github-actions github-actions Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

go2 replay realtime (arm64)

Details
Benchmark suite Current: 8ec3195 Previous: c3f0add Ratio
peak memory 1827.449 MB 1762.234 MB 1.04
peak threads 368 threads 359 threads 1.03
network (transport) 2736.335 MB 2735.794 MB 1.00
disk write 1.758 MB 1.699 MB 1.03
instructions 137.821 G 137.654 G 1.00

This comment was automatically generated by workflow using github-action-benchmark.

@github-actions github-actions Bot added the ready-to-merge Required CI checks have passed on this PR label Oct 24, 2026

This branch was previously deployed

1 inactive (outdated) deployment
cachix — 1dbc498b Deployed Oct 23, 2026 by Nabla7 via cachix-build-macos #14066
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge Required CI checks have passed on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant