Skip to content

fix(platforms): handle Ascend A3 multi-chip rows and stop before npu-smi process table - #1099

Open
Liuchenbing-2026 wants to merge 2 commits into
InferMatrixLab:mainfrom
Liuchenbing-2026:fix/ascend-npu-smi-a3-and-process-rows
Open

Liuchenbing-2026 wants to merge 2 commits into
InferMatrixLab:mainfrom
Liuchenbing-2026:fix/ascend-npu-smi-a3-and-process-rows

Conversation

@Liuchenbing-2026

Copy link
Copy Markdown

Governing Issue and delivery slice

  • What this PR delivers: Fixes _npu_smi_records() in src/inferrsi/apps/host/platforms/__init__.py so Ascend npu-smi info output is accurately parsed on Atlas A3 multi-chip topologies (e.g. NPU ID + Chip ID + multi-token / numeric model names like Ascend 910B2 / 910B3) and stops parsing before the lower Process id table section so process rows are never misclassified as NPU devices. Adds focused unit regression tests in tests/apps/test_inspection.py.
  • What it does not deliver: Changes to CUDA/ROCm inspection paths or remote scheduling policies.

Knowledge authorship declaration

Not applicable — this PR modifies only src/inferrsi/apps/host/platforms/__init__.py and tests/apps/test_inspection.py (no knowledge-policy protected paths).

Changed artifacts and evidence

Requirement Actual change Check / evidence and result Remaining gap
Parse Atlas A3 dual-chip & multi-token Ascend models accurately src/inferrsi/apps/host/platforms/__init__.py Local Python 3.12 unittest on tests/apps/test_inspection.py: 13/13 PASS Full CI pytest matrix
Prevent npu-smi info process section rows from being treated as devices src/inferrsi/apps/host/platforms/__init__.py, tests/apps/test_inspection.py Regression case test_ascend_parses_a3_multi_token_and_numeric_models_without_process_rows: PASS Live Atlas A3 host verification if desired

Checks and dependencies

  • Checks actually run (result and tested scope): Executed all 13 unittest test cases in tests/apps/test_inspection.py on Python 3.12 against src/ (Ran 13 tests in 0.276s — OK).
  • Failed, skipped, timed-out or not-run checks (if applicable): Full pytest / linter / CI workflows were not run locally and will run in repository CI.
  • Dependencies / shared interfaces / integration assumptions (if applicable): No new dependencies; preserves _npu_smi_records() return format tuple[tuple[str, str], ...].

…nd skip process rows

Signed-off-by: liuchenbing <chenliumail@163.com>
Dong1017
Dong1017 previously approved these changes Dec 5, 2026

@Dong1017 Dong1017 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

Posted by Dong-bot (review), an automated agent acting on behalf of @Dong1017 (always-on-bot, model auto-smart?optimize_for=balanced).

PR review verdict — PASS
Reviewed base 6050c76 and head b8e5a2f (first review of this head; full diff). pr/prior-reviews.md shows no formal reviews, no Approve on this head and no outstanding CHANGES_REQUESTED, so this is the first independent review, not a re-check.

Verified by reading the code (src/inferrsi/apps/host/platforms/__init__.py L27-59 at head, and the new test in tests/apps/test_inspection.py):

  • _npu_smi_records now accepts only 3-cell framed rows whose second cell is a known health value (ok/warning/alarm/critical/general/unknown). Chip rows (PCI Bus-Id or NA in column 2), the title/version row (1 cell), and the column-header rows ("Health", "Bus-Id") are all skipped. The existing NPC_TABLE fixture (910B3, 310P3) still parses to ids 0 and 1, so the previous tests are unaffected.
  • The old re.search([A-Za-z]) filter is gone. 910_9391 (A3), the multi-token 910 ProB and numeric-only 910 now produce records, with the name rebuilt from head[1:].
  • The loop stops at the first 2+-cell row containing "process" or "pid", so the trailing process table cannot add records. Process rows have 4 cells and NA chip tokens, so they would also fail the 3-cell/health check. The break is therefore a second guard.
  • I traced the model matching in parsed_tool_facts / _normalized_model (L84-120). Ascend 910_9391 normalises to 9109391, 910 ProB to 910prob, and Ascend910 to 910. Each matches its record. The new assertions (devices list, selection_verified, absent process-table id 9 not verified) agree with what the code does.
  • The change is scoped to discovery and parsing. It makes no compatibility or performance claim, and .github/ is untouched.

Non-blocking notes:

  • The health allowlist is closed. A health string outside the list drops that device, so it fails closed ("No device records parsed" or "ID absent") and never admits a false device. Consider a short comment saying so, or a follow-up if real npu-smi output shows other values.
  • The new test does not isolate the break. Process rows are already rejected by the 3-cell/health filter, so the test passes without the early stop. A process-table row shaped like a 3-cell device row, such as | 9 foo | OK | ... |, would cover it. This is optional.
  • Model matching is substring-based after normalisation, so a requested 910 matches 910_9391 as well. That is existing behaviour and out of scope.

Not verified here: I did not run the test suite and have not seen CI results. I did not compare against real A3 npu-smi info captures; the fixture is synthetic. No governing issue is linked in pr/meta.json, so I could not check scope against one.

Eligibility: this Approve is one vote from the posting account. The ruleset still needs two qualifying approvals, and merge is left to the integrator.


@Dong1017 Dong1017 added the area:apps Apps line: CLI, Python entrypoints, host inspection, workflows, views, and adapters label Dec 5, 2026
amy-why-3459
amy-why-3459 previously approved these changes Dec 5, 2026

@amy-why-3459 amy-why-3459 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM
inferRSI, acting for @amy-why-3459.

PR review verdict — PASS
Reviewed base 6050c76 and head b8e5a2f.

Verified _npu_smi_records in src/inferrsi/apps/host/platforms/__init__.py and the new regression in tests/apps/test_inspection.py:

  • Device rows must have exactly 3 framed cells and a known health value in column 2 (ok/warning/alarm/critical/general/unknown). Chip rows with a Bus-Id or NA in that column, and 1-cell title/version rows, are skipped. Existing NPC_TABLE cases (910B3, 310P3) still parse to ids 0 and 1.
  • Names are taken from head[1:] after a numeric id, so 910_9391, 910 ProB, and numeric 910 become records. The old alphabetic-name filter is gone.
  • Parsing stops at the first 2+-cell row whose cells contain "process" or "pid", so the trailing process table cannot add a device. Process rows in the new fixture also fail the 3-cell/health check; id 9 is not verified.
  • _normalized_model still drives selection: Ascend 910_9391 matches 910_9391, 910 ProB matches itself, and Ascend910 matches 910. Return type stays a list of {id, name} records; CUDA/ROCm and scheduling are untouched.
  • Accuracy and performance comparison experiments are not applicable: this is host discovery parsing only, with no model-output or performance claims.

Before submitting I re-read the reviews and comments on this head. #1099 (review) is an Approve, not a blocking review.

No actionable findings. I did not rerun the unit tests or compare against a live Atlas A3 npu-smi info capture. The fixture is synthetic. No governing issue is linked; the PR itself bounds the slice to this parser and its tests.

@Bounty-hunter Bounty-hunter left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Claude Code agent, acting for @Bounty-hunter.

PR review verdict — interim comment (no formal approve / request-changes state).

Reviewed base 6050c76 (main) and head b8e5a2f.
I was not invited to review this revision, so this is non-voting feedback from a read of the diff; I did not submit a formal review state.

What I checked

I read the full diff and traced _npu_smi_records through inspect_ascend → parsed_tool_facts. I imported src/inferrsi/apps/host/platforms/__init__.py at this head with the sibling cuda/mlx imports stubbed, and exercised parsed_tool_facts(..., records=_npu_smi_records) directly — the same path inspect_ascend uses.

Results:

  • The new A3 fixture parses to [{"id": "0", "name": "910_9391"}, {"id": "1", "name": "910 ProB"}, {"id": "2", "name": "910"}]; ids 0/1/2 qualify as available with the matching models, and NPU 9 from the trailing process table does not qualify.
  • The pre-existing NPC_TABLE fixture still parses to [{"id": "0", "name": "910B3"}, {"id": "1", "name": "310P3"}]. The behaviours the existing ascend tests pin still hold: a temperature token is not an ID (ids=("3",) → tool_available, selection_verified false), ids=("1",), model="910B3" → device_model_mismatch, and empty output → No device records parsed from npu-smi output.
  • The old parser run against the same A3 fixture returns [{"id": "0", "name": "NA"}, {"id": "9", "name": "NA"}], which confirms both halves of the reported bug (process rows misread as devices, A3 model names missed) and that this diff removes them.

I did not review the CUDA/ROCm/MLX paths; the diff does not touch them.

Findings

No blocking findings in the reviewed diff. Three non-blocking observations:

Suggestion 1 — src/inferrsi/apps/host/platforms/__init__.py:52: len(cells) != 3 is stricter than the parser it replaces. The removed code accepted any row whose first cell split into an id plus an alphabetic name, so a device row carrying an extra column group (a fourth pipe cell) would have parsed before and is now silently skipped. Since the premise of this change is that layouts vary across npu-smi versions and SKUs, len(cells) >= 3 with cells[1] as the discriminator keeps the same discrimination without dropping wider rows. Optional — I have no capture showing such a layout, so I am not treating it as a defect.

Suggestion 2 — src/inferrsi/apps/host/platforms/__init__.py:52: the health allowlist is fail-closed, which is the right direction for a discovery fact (no false available), but the failure mode is total: an unlisted health word drops every device row and yields No device records parsed from npu-smi output. Worth one sentence in the docstring so the next reader knows a wording change looks like "no devices" rather than a partial parse.

Suggestion 3 — src/inferrsi/apps/host/platforms/__init__.py:50: _is_npu_process_header matches process/pid in any cell and breaks the loop. Correct for the documented layout where the process table is last, but it turns any future row that merely mentions a process into a hard stop for the rest of the output. A comment recording that assumption would make the next layout change visible.

Evidence gap (non-blocking) — the A3 fixture is hand-written; no real npu-smi info capture is committed with the PR, and the PR body itself lists "Live Atlas A3 host verification if desired" as open. The parse is only as good as that fixture's column layout. A redacted capture from one A3 host would make the layout claim checkable and would also settle Suggestion 1.

Checks

At the time of this comment the only check run on head b8e5a2f was declarations (completed, success); the full pytest matrix had not reported. The author's local claim (Ran 13 tests ... OK on tests/apps/test_inspection.py) is consistent with what I reproduced for the ascend cases, but I did not run the whole file.

@zengchuang-hw zengchuang-hw 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.

PR review verdict — DO NOT PASS
dot, acting for @zengchuang-hw.

Reviewed 6050c767d5ed46867a992ed051f521cd8469fbb2 → b8e5a2fd8a33cdcb1cd5fe321a0b34bf7b060b70 as independent reviewer on the first Ready revision under the review rules.

One [P1] blocking finding inline: the new numeric-name path can qualify a device which the driver reports as not started or absent. The inspection suite passed (20 tests, 11 subtests); a separate CPU fixture reproduced the regression against base and head. No live A3 execution. Only the declarations check was visible on this head; CI is not the basis of the finding.

continue
if _is_npu_process_header(cells):
break
if len(cells) != 3 or cells[1].casefold() not in _NPU_HEALTH_VALUES:

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] Keep UNKNOWN devices out of the verified selection. I passed | 0 910 | UNKNOWN | NA NA | through the actual Ascend probe with exit 0, ID 0 and model 910: base rejects the numeric row; this head returns status=available and selection_verified=True. The npu-smi reference defines UNKNOWN as a device that does not exist or is not started. The CLI uses both fields to admit the run, so this is more than a display problem. Do not let an UNKNOWN row satisfy selection; add this as a negative control alongside the existing positive numeric-model fixture.

…tion

Do not treat `npu-smi info` rows with `UNKNOWN` health (device absent or not started) as verified Ascend devices, and add a negative control regression test alongside the positive numeric-model fixture.

Signed-off-by: liuchenbing <chenliumail@163.com>

@Bounty-hunter Bounty-hunter left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Claude Code agent, acting for @Bounty-hunter.

The [P1] in review 6202004142 is resolved on head 10a714bccd7d: an UNKNOWN row no longer produces a device record, so it can never satisfy selection. No new blocking finding in the delta. Posted as COMMENT because there is no review invitation on this head.

What I checked

Reviewed base 6050c767d5ed46867a992ed051f521cd8469fbb2 → head 10a714bccd7ddf79172369cc7f7ddefee2a3a0ad (commit 10a714b, "fix(platforms): exclude UNKNOWN npu-smi health rows from Ascend selection").

  • Delta: unknown removed from _NPU_HEALTH_VALUES (src/inferrsi/apps/host/platforms/__init__.py:27-30), plus test_ascend_unknown_health_row_never_qualifies_a_device (tests/apps/test_inspection.py:221-235). Nothing else changed.
  • I imported the module at this head with the sibling cuda/mlx imports stubbed and ran parsed_tool_facts(..., records=_npu_smi_records) — the path inspect_ascend uses — on these fixtures:
    • | 0 910 | UNKNOWN | NA NA | with ids=("0",), model="910": devices=[], status=tool_available, selection_verified=False, reason No device records parsed from npu-smi output. Same result without ids, and with ids but no model.
    • Lower-case unknown: also excluded.
    • Mixed table (id 0 OK, id 1 UNKNOWN): requesting id 1 is rejected (Requested device IDs absent…: 1); id 0 still qualifies.
    • A four-cell UNKNOWN row: also excluded — it drops at the 3-cell check, so the fail-closed path holds for wider layouts.
    • Existing NPC_TABLE (910B3/310P3) and the A3 fixture parse unchanged; process id 9 is still not verified.
  • The allowlist is now closed: any unlisted future health word drops the row instead of admitting it. That is the right direction for a discovery fact, and worth one docstring sentence the next time this parser is touched.

Still open from the earlier reviews here (non-blocking, untouched by this commit): the len(cells) != 3 strictness against wider device rows, and the unconditional break on any process/pid cell. Neither has a real capture behind it.

Not verified: the full pytest matrix on this head, CI results, or a live Atlas A3 npu-smi info capture. The fixture is still synthetic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:apps Apps line: CLI, Python entrypoints, host inspection, workflows, views, and adapters

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants