Skip to content

fix(npu_utils): give npu_cmd a virtual destructor - #1233

Open
michyu-amd wants to merge 1 commit into
mainfrom
fix/npu-cmd-virtual-dtor
Open

michyu-amd wants to merge 1 commit into
mainfrom
fix/npu-cmd-virtual-dtor

Conversation

@michyu-amd

Copy link
Copy Markdown
Collaborator

npu_cmd is the base of all NPU instruction commands. Commands are owned as
std::unique_ptr<npu_cmd> and deleted through the base pointer
(npu_instr_utils.hpp clear_cmds), but npu_cmd had no virtual destructor.
That is undefined behaviour, and every subclass object was freed with the
base size.

Found with AddressSanitizer while debugging a Windows-only bug in the
minicpm-v-4.7-bf16 engine: about a million new-delete-type-mismatch reports
per request (unrelated to that bug, but it hides real findings).

Change: virtual ~npu_cmd() = default; in both definitions (XRT and HRX) of

  • flm-dev-kit/FLM_DLL/include/npu_utils/instr_utils/npu_cmd.hpp (engines)
  • src/include/npu_utils/instr_utils/npu_cmd.hpp (app)
    npu_cmd already has virtual methods, so the object layout does not change.
    Not touched: FLM_Xclbin/host_common (kernel host tests) and the LiquidAI
    model's own copy.

Tests:

  • small ASan program deleting a subclass through unique_ptr<npu_cmd>:
    old header -> new-delete-type-mismatch (32 bytes freed as 8); new header -> clean
  • engines qwen3_npu and minicpm_v_4_7_npu build with 0 errors (Linux)
  • CI self-tests 567/567, devkit_check ok

🤖 Generated with Claude Code

Commands are owned as std::unique_ptr<npu_cmd> and deleted through the base
pointer (npu_instr_utils clear_cmds), but npu_cmd had no virtual destructor:
undefined behaviour, and every subclass object was freed with the base size
(AddressSanitizer: new-delete-type-mismatch, about a million reports per
request in an engine run). Add `virtual ~npu_cmd() = default;` to both the
XRT and the HRX definition, in the dev-kit copy (FLM_DLL/include) and the
app copy (src/include). npu_cmd already has virtual methods, so the object
layout does not change.

Co-Authored-By: Claude <noreply@anthropic.com>
@michyu-amd
michyu-amd requested a review from zaneni6 December 2, 2026 23:19
@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown
Security scan found no critical or high findings on lines changed by this pull request

View the security scan run for complete reports.

“New” means the finding is located in a changed file on an added or modified line; it is not a base-versus-head findings delta.

@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown

Dev-kit bench

Results of the dev-kit benches in Build and Test run 46993496660 for 2e2f155695, as that run reported them (its artifacts hold the per-model reports).

Summary

Dev-kit bench (pr) on 2e2f155695

the pull request's staged packages: this run's numbers only, no comparison (to be designed later)

✅ No hard-gate failure and no soft-gate warning.

Linux XRT

Perf (tok/s; dev-kit against the base package on the same runner)

Model Machine Context Decode base → dev-kit Δ Prefill base → dev-kit Δ Decode Δ vs nightly (same kind)
gemma3:1b krackan 1k — → 43.8 — — → 851.4 — no baseline for this kind
gemma3:1b krackan 2k — → 43.7 — — → 1034.4 — no baseline for this kind
gemma3:1b krackan 4k — → 43.3 — — → 1245.6 — no baseline for this kind
gemma3:1b krackan 8k — → 41.1 — — → 1472.8 — no baseline for this kind
lfm2.5-it:1.2b strix 1k — → 63.0 — — → 1686.3 — no baseline for this kind
lfm2.5-it:1.2b strix 2k — → 60.1 — — → 1957.7 — no baseline for this kind
lfm2.5-it:1.2b strix 4k — → 54.9 — — → 2141.0 — no baseline for this kind
lfm2.5-it:1.2b strix 8k — → 53.3 — — → 2339.4 — no baseline for this kind
qwen3.5:0.8b strix 1k — → 48.7 — — → 1642.5 — no baseline for this kind
qwen3.5:0.8b strix 2k — → 47.5 — — → 1928.4 — no baseline for this kind
qwen3.5:0.8b strix 4k — → 46.2 — — → 2072.1 — no baseline for this kind
qwen3.5:0.8b strix 8k — → 41.3 — — → 2240.4 — no baseline for this kind
qwen3:0.6b strix 1k — → 83.3 — — → 1532.6 — no baseline for this kind
qwen3:0.6b strix 2k — → 65.5 — — → 1912.9 — no baseline for this kind
qwen3:0.6b strix 4k — → 46.4 — — → 1977.3 — no baseline for this kind
qwen3:0.6b strix 8k — → 31.9 — — → 1821.5 — no baseline for this kind

GSM8K accuracy (%)

Model Nightly baseline This run Δ (points) Notes
gemma3:1b — 38.0 — 5 hit max_tokens
lfm2.5-it:1.2b — 66.0 —
qwen3.5:0.8b — 6.0 — 3 hit max_tokens
qwen3:0.6b — 36.0 — 4 hit max_tokens

Linux HRX

Perf (tok/s; dev-kit against the base package on the same runner)

Model Machine Context Decode base → dev-kit Δ Prefill base → dev-kit Δ Decode Δ vs nightly (same kind)
gemma3:1b strix 1k — → 41.2 — — → 873.5 — no baseline for this kind
gemma3:1b strix 2k — → 41.0 — — → 1022.4 — no baseline for this kind
gemma3:1b strix 4k — → 39.9 — — → 1141.8 — no baseline for this kind
gemma3:1b strix 8k — → 38.3 — — → 1349.2 — no baseline for this kind
lfm2.5-it:1.2b strix 1k — → 63.6 — — → 1715.6 — no baseline for this kind
lfm2.5-it:1.2b strix 2k — → 62.3 — — → 2104.4 — no baseline for this kind
lfm2.5-it:1.2b strix 4k — → 58.9 — — → 2267.5 — no baseline for this kind
lfm2.5-it:1.2b strix 8k — → 54.6 — — → 2354.6 — no baseline for this kind
qwen3.5:0.8b strix-halo 1k — → 45.4 — — → 1702.2 — no baseline for this kind
qwen3.5:0.8b strix-halo 2k — → 44.4 — — → 2078.3 — no baseline for this kind
qwen3.5:0.8b strix-halo 4k — → 42.5 — — → 2291.0 — no baseline for this kind
qwen3.5:0.8b strix-halo 8k — → 38.7 — — → 2315.3 — no baseline for this kind
qwen3:0.6b krackan 1k — → 74.8 — — → 1635.0 — no baseline for this kind
qwen3:0.6b krackan 2k — → 59.3 — — → 2010.3 — no baseline for this kind
qwen3:0.6b krackan 4k — → 45.2 — — → 2064.5 — no baseline for this kind
qwen3:0.6b krackan 8k — → 30.6 — — → 1874.6 — no baseline for this kind

GSM8K accuracy (%)

Model Nightly baseline This run Δ (points) Notes
gemma3:1b — 38.0 — 5 hit max_tokens
lfm2.5-it:1.2b — 66.0 —
qwen3.5:0.8b — 6.0 — 3 hit max_tokens
qwen3:0.6b — 36.0 — 4 hit max_tokens

Perf: flm bench, decode and prefill average tok/s per context. A/B is the one perf signal that judges a change; the runners differ by machine kind, so the nightly comparison is informational and only made for the same kind. Accuracy: GSM8K (first 50 questions) and DocVQA (when enabled), greedy; unanswered questions count as wrong. Per-question reports, server logs and CSVs: the devkit-bench-result-* artifacts.

This branch has not been deployed

No deployments
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.

1 participant