NemoClaw icon indicating copy to clipboard operation
NemoClaw copied to clipboard

[DGX Spark][Agent&Skills] Trivial "hello" agent turn takes ~10s P50 / 17s max on local Ollama (nemotron-3-nano:30b)

Open hulynn opened this issue 7 months ago • 7 comments

Description

Description

On DGX Spark with local Ollama (nemotron-3-nano:30b, fully GPU-resident), a trivial agent turn ("say hello") takes 7-17 seconds end-to-end. P50 is 10.4 s, max is 17.5 s. Pure inference latency for a one-token greeting on this hardware is expected to be ~1-2 s; agent framework overhead (gateway round-trip, prompt/tool-schema assembly, agent loop) inflates this 5-10x.
Reproduces the VDR #4 finding SP-10 (originally reported with gemma4:31b at ~8 s) on the latest NemoClaw v0.0.28 + OpenClaw 2026.4.9 build.
Environment
Device:        DGX Spark (host: p4242-0081)
OS:            Ubuntu (host); sandbox = NemoClaw default
Architecture:  aarch64 (DGX Spark / Grace)
Node.js:       Not captured
npm:           Not captured
Docker:        Not captured
OpenShell CLI: openshell 0.0.36
NemoClaw:      v0.0.28
OpenClaw:      2026.4.9 (build 0512059)

Sandbox name:  vdr
Provider:      ollama-local (Ollama 127.0.0.1:11434, proxy on :11435)
Model:         nemotron-3-nano:30b
Model status:  27 GB resident, 100% GPU, context window 262,144
GPU:           1x GPU, 122,543 MB VRAM
Steps to Reproduce
1. Onboard NemoClaw v0.0.28 on DGX Spark; choose Local Ollama → nemotron-3-nano:30b.
2. After sandbox creation, open the sandbox:
     nemoclaw vdr connect
3. Run a one-shot agent turn 10 times and measure wall-clock per iteration:
     for i in $(seq 1 10); do
       T=$( { time openclaw agent --agent main --message "say hello" --json \
                >/tmp/a.$i.json 2>/tmp/a.$i.err ; } 2>&1 | awk '/real/{print $2}')
       printf "iter %2d  agent_total=%s\n" "$i" "$T"
     done
4. Inspect /tmp/a.*.json for the agentMeta block.
Expected Result
A 1-token greeting against a fully GPU-resident 30B local model on DGX Spark
should complete end-to-end in < 3 s (inference < 2 s + framework < 1 s).
At minimum 10/10 iterations should be < 5 s.
Actual Result
10/10 iterations exceeded 7 s; 5/10 exceeded 10 s; max 17.5 s.

Raw timings (10 iterations, wall-clock):
  iter  1  17.462 s
  iter  2   8.075 s
  iter  3   8.854 s
  iter  4   7.838 s
  iter  5  15.241 s
  iter  6  10.204 s
  iter  7  10.530 s
  iter  8  14.182 s
  iter  9  11.362 s
  iter 10   7.283 s

Statistics:
  min          7.28 s
  P50 (median) 10.37 s
  P90          15.24 s
  max          17.46 s
  range        2.4x (max/min)

Agent JSON instrumentation (iter 1 sample):
  {
    "status": "ok",
    "result": {
      "payloads": [{ "text": "Hello! How can I assist you today?" }],
      "meta": {
        "durationMs": 15050,
        "agentMeta": {
          "provider": "inference",
          "model":    "nemotron-3-nano:30b",
          "lastCallUsage": { "input": 0, "output": 0, "total": 0 }
        }
      }
    }
  }

Note: lastCallUsage all-zero — the Ollama provider does not report token usage back to the agent. Cannot independently confirm prompt-token explosion (Brev/NIM showed input=18355 for the same prompt). Likely worth filing as a separate minor instrumentation bug if not already known.

GPU state during run:
  Pre-perf:  GPU util 93% (still warming from prior probe)
  Post-perf: GPU util 0%, model still resident (Ollama keep-alive 2 min)
Logs
Suggested attachments (zip and upload after draft is created):
- agent_timings.txt: 10-iter wall-clock per iteration
- agent_iter1.json:  /tmp/a.1.json full dump (systemPromptReport, sandbox info, agentMeta)
- gpu_state.txt:     ollama list + nvidia-smi pre/post

Analysis:
- Pure inference time (raw `openclaw infer model run` for the same prompt)
  was not collected in this session; will be appended once measured.
  Expected ~1-2 s based on Ollama benchmarks for 30B/GPU.
- Agent framework overhead = agent_total - raw_infer ≈ 5-7 s per turn,
  consistent with observations on Brev where the agent always builds
  full system prompt + 18k+ tool-schema tokens (Brev/NIM input=18355).
- For a trivial conversational turn the agent always pays the full
  bootstrap cost; consider a lighter path that skips full tool schema
  for "no tools needed" prompts.

Related:
- VDR #4 finding SP-10: "Latency ~8s for hello world with gemma4:31b on
  local Ollama" — current finding partially reproduces and confirms the
  issue persists at v0.0.28 / OpenClaw 2026.4.9 (slightly slower).
- BR-7 (Brev): agent turns occasionally hang ~2 min on nvidia-prod NIM.
  Different root cause (remote NIM tail latency) but same observable
  category.
- Minor instrumentation gap: agent JSON shows lastCallUsage.input/output=0
  for Ollama provider; Brev/NIM correctly reports tokens.

Bug Details

Field Value
Priority Unprioritized
Action Dev - Open - To fix
Disposition Open issue
Module Machine Learning - NemoClaw
Keyword NemoClaw, NemoClaw_Agent&Skills, NEMOCLAW_GH_SYNC_APPROVAL, NemoClaw_Inference, NemoClaw-SWQA-RelBlckr-Recommended, NemoClaw-SWQA-VDR

[NVB#6122111]

hulynn avatar Apr 28 '26 10:04 hulynn

Cross-issue update + upstream filed

Ran a controlled prompt-length sweep on plain macOS + Ollama + llama3.2:1b (no Spark needed) to validate the mechanism. Same prompt, same model, same hardware, varying only the size of an injected fake tool-schema prefix:

Configuration Prompt tokens Total latency Slowdown
Bare "say hello" 27 212 ms 1×
+ ~2k fake schema 2,433 2,980 ms 14×
+ ~10k fake schema 12,033 22,189 ms 104×
+ ~18k fake schema (matches Brev measurement) 21,633 36,581 ms 172×

Latency is linear in prompt size. The 18k-token row reproduces the slowdown the reporter saw on Spark — confirming the root cause is openclaw prepending a full tool schema on every turn, regardless of hardware. Spark just made it obvious because raw inference is so fast there.

This bug is not in NemoClaw code. The prompt-assembly path lives in the openclaw npm/docker artifact (we pin min_openclaw_version: 2026.4.24 and ship it unmodified). The reporter's proposed fix direction ("lighter path that skips full tool schema for 'no tools needed' prompts") is the right shape but has to land upstream.

Filed upstream

openclaw/openclaw#81056 — with the prompt-length sweep above, mechanism analysis, and four proposed fix directions for upstream to pick from.

Cross-issue

Same root cause shows up in:

  • #2600 — Brev/NIM trivial turn P50 9s, P99 128s. Same 18k-token preamble, different backend tail behavior.
  • #3261 — explicit feature request for "system prompt bypass" citing "+10k input tokens per request" overhead.

All three close (or substantially advance) when openclaw ships the fix.

Next steps from NemoClaw side

  • Track upstream openclaw/openclaw#81056.
  • Bump min_openclaw_version in nemoclaw-blueprint/blueprint.yaml once the fix ships.
  • (Separately) add NemoClaw-side observability so the next round of prompt bloat surfaces in nemoclaw status instead of escalating from QA. Will file that as its own issue.

Leaving #2598 open to track the upstream resolution.

cjagwani avatar May 12 '26 14:05 cjagwani

Closing as fixed-on-latest. NemoClaw v0.0.52 enables OpenClaw Tool Search by default via #4096 (generate-openclaw-config.py:474 sets tools.toolSearch: true). Verified today on a fresh Brev CPU box with Ollama + llama3.2:1b on v0.0.52: agent run logs [agent/embedded] tool-search: cataloged 28 tools behind compact prompt surface, confirming the workaround fires at runtime — the 28-tool full-schema dump that caused the original 18,355-prompt-token explosion is no longer the per-turn cost.

The underlying upstream remains open as canonical tracker openclaw/openclaw#14785 ("Reduce tool schema token overhead"). My upstream filing openclaw/openclaw#81056 was closed as duplicate of that tracker.

Closing here because the user-visible regression no longer reproduces. If tools.toolSearch ever gets disabled or the underlying upstream regresses, this will surface again — easy enough to re-open at that point.

cjagwani avatar May 27 '26 20:05 cjagwani

Still reproduced on NemoClaw v0.0.54 DGX Spark. Reopening this issue.

Here are the logs and comparisons with previous results: Numbers from your current sandbox run

From the for i in $(seq 1 10) loop: Iteration timings (wall‑clock “agent_total”):

iter 1: 8.722 s iter 2: 5.554 s iter 3: 5.857 s iter 4: 6.508 s iter 5: 16.734 s iter 6: 5.344 s iter 7: 9.867 s iter 8: 5.474 s iter 9: 5.270 s iter 10: 6.887 s

Summarizing as:

Min: ~5.27 s Max: ~16.73 s Median (rough): ~6–7 s (since most are in the 5–7 s band, with a couple of high outliers)

And from the JSON: meta.durationMs: 6804 ms (≈ 6.8 s) for iter 1. agentMeta.promptTokens: 6152 agentMeta.usage: input 6152, output 175, total 6327

On DGX Spark sandbox with nemotron-3-nano:30b, 10 “say hello” calls still show high latency: Wall‑clock per turn (10 runs): 5.27–16.73 s, with most in the 5–7 s range and a worst case of 16.73 s. Example iter (1): durationMs ≈ 6804 ms while promptTokens=6152, usage.input=6152, usage.output=175 (total 6327 tokens) for a trivial “say hello” request. This reproduces the “hello world” agent‑side latency issue: every turn still pays a ~6k‑token bootstrap cost instead of a tiny chat prompt.

Numbers from the bug’s previous run (for comparison)

min: 7.28 s P50: 10.37 s P90: 15.24 s max: 17.46 s

Original report: min 7.28 s, P50 10.37 s, P90 15.24 s, max 17.46 s for “hello world”. Current sandbox: min ~5.27 s, median ≈ 6–7 s, max ~16.73 s.

Behavior is slightly better on this build/hardware but still far above the expected sub‑second range for a trivial local 30B turn, and the large prompt (6k+ tokens) is clearly visible in the JSON.

PrachiShevate-nv avatar May 29 '26 22:05 PrachiShevate-nv

@cjagwani

This issue reproduced on v0.0.56. Reopening this issue. 

Here is my explanation: ​​​​​​​ I re-tested on latest NemoClaw with the vdr sandbox and nemotron-3-nano:30b on DGX Spark.

Tool Search appears to be enabled and the worst-case behavior from the original report (28-tool full-schema dump ≈18k prompt tokens per turn) no longer reproduces. However, the user-visible latency regression is still present in my environment, just with a smaller but still high prompt footprint:

10 one-shot openclaw agent --agent main --message "say hello" --json runs inside the vdr sandbox take between 5.3 s and 11.4 s end-to-end, with a P50 around 7 s for a trivial greeting.

Agent JSON shows promptTokens / usage.input still in the 6–8k token range for each “say hello” turn, even though this is a tiny conversational request.

Model is nemotron-3-nano:30b fully resident on GPU; based on local Ollama/vLLM benchmarks, pure model inference for a 1-token reply at this size should be ≈1–2 s, so the remaining 4–9 s appears to be agent/framework overhead from prompt construction and context injection.

Because of this:

The specific 18k-token full tool-schema prompt issue is mitigated, but

The original user-facing problem (“hello world on a local 30B model is much slower than expected due to heavy prompt/context overhead”) is not fully resolved on DGX Spark.

I suggest keeping this bug open (or tracking in a follow-up) to cover the remaining gap:

Current behavior: 6–8k tokens and 5–11 s per trivial turn.

Expected target: on a fully GPU-resident 30B local model, a single-token greeting should land in roughly ≤3–4 s P50 end-to-end (≈1–2 s raw inference + ≤1–3 s agent overhead).

If you prefer to treat the original 18k-token issue as closed, we can close this as “mitigated” and open a new performance bug specifically for the residual 6–8k promptTokens / 5–11 s latency baseline on local 30B models.

PrachiShevate-nv avatar Jun 02 '26 22:06 PrachiShevate-nv

Adding a hardware-verified benchmark to help isolate the remaining overhead after the Tool Search fix.

Pure inference baseline (same hardware, same model)

Tested on GIGABYTE AI TOP ATOM (GB10, SM121, aarch64, 128 GB LPDDR5x):

Model: nemotron-3-nano:30b (24 GB, 100% GPU)
Prompt: "Say hello in one word."

iter 1: 1.56s (cold)
iter 2: 1.23s (warm)
iter 3: 1.27s
iter 4: 1.15s
iter 5: 1.23s
Average: 1.29s

Agent turn (from the issue)

Iteration Time
1 8.722s
2 5.554s
3 5.857s

Overhead breakdown

Pure inference:      1.2s  ( 8% of 15s)
Agent overhead:      4-14s (92% of 15s)
  ├─ Prompt assembly:    ~2-5s
  ├─ Tool catalog:       ~1-3s (even with Tool Search enabled)
  ├─ Gateway round-trip: ~0.5-1s
  └─ Agent loop:         ~0.5-5s

The Tool Search fix addressed the prompt size issue, but ~4-14s of latency remains unaccounted for. The largest contributor appears to be the tool catalog helper injection (nemoClawCreateToolCatalog()) which still runs catalog assembly even when the agent task is trivial.

Potential further optimizations:

  1. Lazy catalog: don't build the tool catalog until the agent actually requests tool access
  2. Catalog cache: reuse the assembled catalog across agent turns (invalidate on config change)
  3. Skip catalog: if the agent policy already has --agent_policy, skip tool injection entirely for simple turns

theherrovn avatar Jun 03 '26 09:06 theherrovn

Picked this up after @theherrovn's hardware breakdown. Spun up a fresh brev box with OpenClaw 2026.5.27 + llama3.2:1b through Ollama, put a capture proxy in front of Ollama, and ran the same "say hello" turn to see what's actually in the prompt.

What I found

The system prompt is 23,872 chars. From meta.systemPromptReport:

Total systemPrompt:       23,872 chars  (~6,000 tokens)
  Project context:        12,350 chars  (~3,100 tokens)
  Non-project context:    11,522 chars  (~2,900 tokens)
  • Project context = workspace files OpenClaw auto-injects from /sandbox/.openclaw/workspace every turn (capped at 12k per file, 60k total via bootstrapMaxChars).
  • Non-project context = framework boilerplate. Sandbox info, agent loop instructions, output-format hints, the 3 Tool Search catalog control tools.

The Tool Search fix from #4096 shrunk the tool catalog. The residual is bootstrap context, separate code path. That's why the 6-8k tokens you're still seeing don't go away.

  1. NEMOCLAW_MINIMAL_BOOTSTRAP flag (NemoClaw PR coming). Opt-in env var that empties the workspace at sandbox-create time, knocks the ~3,100 project-context tokens off. Verifiable on this brev box: with the flag set the prompt drops below llama3.2:1b's 4k context so the agent actually responds, without it the agent fails with Context overflow.
  2. Upstream issue at openclaw/openclaw#NEW (filing alongside step 1). Asks for a symmetric agents.bootstrap.minimalNonProjectContext flag for the ~2,900-token framework boilerplate. Mirrors the existing bootstrapMaxChars knob.

cjagwani avatar Jun 05 '26 21:06 cjagwani

Closing this out — NemoClaw-side scope is complete.

Three things landed in sequence:

  1. Diagnosis comment above with the byte-level breakdown of where the residual 6-8k tokens come from (~12k chars project context + ~11k chars non-project context)
  2. NEMOCLAW_MINIMAL_BOOTSTRAP=1 flag in #4870 (merged) that skips the default workspace template seed for new sandboxes, knocking ~3k tokens off every prompt
  3. Upstream ask at openclaw/openclaw#14785 for a symmetric flag covering the remaining ~3k tokens of OpenClaw framework boilerplate

The residual ~13% is bootstrap context that OpenClaw itself injects, not something we can touch without patching upstream's bundled JS. When openclaw#14785 lands the non-project knob and we bump the pinned OpenClaw version, that delta goes away automatically.

If this regresses, please point at which specific chunk of the breakdown above grew so we can route the fix correctly.

cjagwani avatar Jun 08 '26 21:06 cjagwani