Skip to content

fix(groot_n17): implement latency stats, populate __init__.py, clean up stale docstrings - #132

Merged
LiangSu8899 merged 1 commit into
flashrt-project:mainfrom
heiheiha798:fix/groot-n17-latency-stats-and-init
Jul 6, 2026
Merged

LiangSu8899 merged 1 commit into
flashrt-project:mainfrom
heiheiha798:fix/groot-n17-latency-stats-and-init

Conversation

@heiheiha798

Copy link
Copy Markdown
Contributor

Summary

  • Implement get_latency_stats() across all N1.7 frontends (Thor, RTX, FP8, FP16, SM89). Previously a NotImplementedError stub — now records wall-clock inference latency per infer() call and reports count / mean / std / min / max / p50 / p95 / Hz, matching the Pi0.5 and Groot N1.6 API contract.

  • Clear latency_records after warmup in every set_prompt() path so get_latency_stats() reflects only user-visible steady-state inference, not graph-capture or cuBLAS-priming cost.

  • Populate groot_n17/__init__.py with public re-exports. Embodiment mappings (EMBODIMENT_TAG_TO_INDEX, EMBODIMENT_NUM_VIEWS) are imported eagerly (pure dicts, no heavy deps). Calibration, M-RoPE table, and pipeline symbols are lazy-loaded via __getattr__ so that import flash_rt.models.groot_n17 does not pull in torch.

  • Remove stale Phase 3c comments and docstrings that referenced set_prompt / infer as "still stubbed".

Files changed

File Change
groot_n17_thor.py latency_records init, timing in infer() (both graph + eager paths), get_latency_stats() impl, warmup clear, docstring cleanup
groot_n17_rtx_fp16.py Timing in overridden infer(), warmup clear
groot_n17_rtx_sm89_fp16.py Timing in overridden infer(), warmup clear
groot_n17_rtx_fp8.py Warmup clear
groot_n17_rtx_sm89.py Warmup clear
groot_n17_thor_fp8.py Warmup clear
groot_n17/__init__.py Lazy public re-exports

Validation

# __init__.py does not pull torch eagerly
>>> import sys; mods_before = set(sys.modules)
>>> import flash_rt.models.groot_n17
>>> any('torch' in m for m in set(sys.modules) - mods_before)
False

# Lazy symbols resolve correctly
>>> from flash_rt.models.groot_n17 import calibrate_pipeline_amax, dit_forward
>>> calibrate_pipeline_amax is not None and dit_forward is not None
True

# get_latency_stats is no longer a stub
>>> import inspect
>>> 'NotImplementedError' not in inspect.getsource(
...     flash_rt.frontends.torch.groot_n17_thor.GrootN17TorchFrontendThor.get_latency_stats)
True

No GPU / checkpoint required for this change — all edits are Python-level API plumbing with no change to runtime kernels, calibration, or graph capture behavior.

Test plan

  • Verify import flash_rt.models.groot_n17 does not import torch
  • Verify lazy attribute access resolves calibrate_pipeline_amax, RopeConfig, dit_forward
  • Verify get_latency_stats() source contains no NotImplementedError
  • Verify infer() in Thor base and both FP16 subclasses contains time.perf_counter + latency_records.append
  • (requires GPU) Run test_groot_n17_e2e.py — confirm get_latency_stats() returns non-empty dict after inference
  • (requires GPU) Confirm latency_records is empty immediately after set_prompt() (warmup cleared)

…up stale docstrings

- Implement get_latency_stats() across all N1.7 frontends (Thor, RTX,
  FP8, FP16, SM89). The method was previously a NotImplementedError
  stub. Now records wall-clock inference latency per call and reports
  count, mean, std, min, max, p50, p95, and Hz.

- Clear latency_records after warmup in every set_prompt() path so
  get_latency_stats() reflects only user-visible steady-state infer
  calls, not graph-capture or cuBLAS-priming cost.

- Populate groot_n17/__init__.py with public re-exports. Embodiment
  mappings are imported eagerly (no heavy deps); calibration, M-RoPE
  table, and pipeline symbols are lazy-loaded via __getattr__ so that
  `import flash_rt.models.groot_n17` does not pull in torch.

- Remove stale Phase 3c comments and docstrings that referenced
  set_prompt/infer as "still stubbed".
@heiheiha798
heiheiha798 requested a review from LiangSu8899 as a code owner July 5, 2026 02:29
Copilot AI review requested due to automatic review settings July 5, 2026 02:29

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Implements steady-state inference latency tracking for the GR00T N1.7 torch frontends and exposes the flash_rt.models.groot_n17 public API via a lightweight __init__.py that keeps heavyweight imports (e.g., torch) lazy.

Changes:

  • Added per-infer() latency recording and a get_latency_stats() implementation on the N1.7 Thor base frontend (inherited by RTX variants).
  • Cleared latency_records after set_prompt() warmup across N1.7 frontends so stats reflect steady-state inference only.
  • Populated flash_rt.models.groot_n17.__init__ with eager re-exports for embodiment mappings and lazy re-exports for calibration / M-RoPE / pipeline symbols.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
flash_rt/models/groot_n17/init.py Adds eager/lazy public re-exports to avoid importing torch on package import.
flash_rt/frontends/torch/groot_n17_thor.py Adds latency tracking + stats reporting; clears warmup timing; docstring cleanup.
flash_rt/frontends/torch/groot_n17_thor_fp8.py Clears latency_records after warmup in set_prompt().
flash_rt/frontends/torch/groot_n17_rtx_fp8.py Clears latency_records after warmup in set_prompt().
flash_rt/frontends/torch/groot_n17_rtx_sm89.py Clears latency_records after warmup in set_prompt().
flash_rt/frontends/torch/groot_n17_rtx_fp16.py Adds timing/recording for overridden infer(); clears warmup timing.
flash_rt/frontends/torch/groot_n17_rtx_sm89_fp16.py Adds timing/recording for overridden infer(); clears warmup timing.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

self._k_actions.copy_(torch.randn(
action_horizon, action_dim, dtype=torch.bfloat16, device=device))
self._k_dit_graph.replay()
torch.cuda.synchronize()
# ── Euler step ──────────────────────────────────────────────
actions = actions + (dt * velocity).to(actions.dtype)

torch.cuda.synchronize()
velocity = self._run_action_decode(h_out[:, -action_horizon:])
actions = actions + (dt * velocity).to(actions.dtype)

torch.cuda.synchronize()
velocity = self._run_action_decode(h_out[:, -action_horizon:])
actions = actions + (dt * velocity).to(actions.dtype)

torch.cuda.synchronize()
@LiangSu8899
LiangSu8899 merged commit f8d0239 into flashrt-project:main Jul 6, 2026
hypertseng added a commit to hypertseng/FlashRT that referenced this pull request Jul 10, 2026
Include:
- Qwen3 prefill fast path optimization (flashrt-project#134)
- SM89 Qwen3-VL FP8 decode-path optimization (flashrt-project#139)
- VLASH async runner (flashrt-project#138)
- RTC temporal fusion runtime (flashrt-project#137)
- GRoot N17 latency stats and fixes (flashrt-project#132)
- Thor fp16 routing through Thor producer (flashrt-project#133)
- Qwen3-VL improvements and fixes

Co-Authored-By: Claude Fable 5 <[email protected]>
@heiheiha798
heiheiha798 deleted the fix/groot-n17-latency-stats-and-init branch July 28, 2026 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants