Skip to content

Transforms complex documents like PDFs and Office docs into LLM-ready markdown/JSON for your Agentic workflows.

fix(hardware): display info report in English

myhlolie83f46ea706c
diff --git a/docs/next/cli/mineru-kit-hardware.md b/docs/next/cli/mineru-kit-hardware.md
index 5b1ea35c..8efed6d4 100644
--- a/docs/next/cli/mineru-kit-hardware.md
+++ b/docs/next/cli/mineru-kit-hardware.md
@@ -42,7 +42,7 @@ JSON 报告保持 `schema_version=1`,包含 `ceiling`、`pdf_image_tiers`、`d
`info` 不调用自动推荐或 OCR 校准,不下载、加载模型权重或写配置。运行时导入和原生 GPU 探测使用独立子进程,最多并发 4 项,并与系统信息采集重叠进行;每项子进程启动后最多等待 15 秒。某项失败时继续报告其他信息,并区分未安装、导入失败和超时。
-默认文本先输出系统、Python 和 MinerU 版本,再依次输出 CPU/内存、已安装软件、完成合并的显卡库存、运行时探测、有效配置及设备选择与校准信息。每节完成后立即刷新,重定向到管道时也无需等到整份报告完成。`--json` 仍一次输出完整对象,原有字段和结果顺序保持稳定,`schema_version=1`;ONNX 运行时结果补充 `selected_device`,记录只读选型及原因。
+默认文本使用英文,先输出系统、Python 和 MinerU 版本,再依次输出 CPU/内存、已安装软件、完成合并的显卡库存、运行时探测、有效配置及设备选择与校准信息。每节完成后立即刷新,重定向到管道时也无需等到整份报告完成。`--json` 仍一次输出完整对象,原有字段和结果顺序保持稳定,`schema_version=1`;ONNX 运行时结果补充 `selected_device`,记录只读选型及原因。
- 系统、Python 和 MinerU 版本;JSON 额外保留解释器与实际模块路径。
- CPU 型号、物理/逻辑/进程可用核数,基础/当前/最大频率(MHz);内存总量及可用量。文本容量统一按 `1024³` 换算为三位小数的 GiB,JSON 保留原始字节数。
@@ -54,13 +54,13 @@ JSON 报告保持 `schema_version=1`,包含 `ceiling`、`pdf_image_tiers`、`d
运行时文本不直接展开内部 `selection`、`backends` 或适配器字典。Torch 的 CUDA/ROCm 构建版本仅在选中相应设备且版本已知时展示;CPU、MPS 及 NPU/GCU/MUSA/MLU/SDAA 等扩展设备直接显示实际设备名,不列出其他不可用后端,也不套用无关构建字段。这些构建版本来自 Torch 自身,不代表系统驱动或另行安装的工具链版本。
-Windows DXGI 和 Linux Vulkan 的原生库存用于补充“系统显卡”,不在运行时文本中重复展开;macOS 使用系统工具采集,不执行 DXGI/Vulkan 这两项库存探测。采集错误仍进入提示,完整后端矩阵、所有适配器及 LUID/PCI/厂商标识等诊断字段继续保留在 `--json` 中。
+Windows DXGI 和 Linux Vulkan 的原生库存用于补充“System GPUs”,不在运行时文本中重复展开;macOS 使用系统工具采集,不执行 DXGI/Vulkan 这两项库存探测。采集错误仍进入提示,完整后端矩阵、所有适配器及 LUID/PCI/厂商标识等诊断字段继续保留在 `--json` 中。
-“设备选择与校准”展示当前小模型后端、设备及选择依据。Torch 直接使用运行时的设备检查结果,并说明不适用 ONNX OCR 校准;ONNX 复用实际选型的候选规则,解释显式 CPU/GPU、独显免校准、不可用或待校准的情况。只读检查不会初始化 GPU 推理会话;需要测速时,设备显示“待校准”(JSON `selected_device.device` 为 `null`),不预先声称 CPU 或 GPU 胜出。
+“Device selection and calibration”展示当前小模型后端、设备及选择依据。Torch 直接使用运行时的设备检查结果,并说明不适用 ONNX OCR 校准;ONNX 复用实际选型的候选规则,解释显式 CPU/GPU、独显免校准、不可用或待校准的情况。只读检查不会初始化 GPU 推理会话;需要测速时,设备显示“pending calibration”(JSON `selected_device.device` 为 `null`),不预先声称 CPU 或 GPU 胜出。
存在有效校准记录时展开详细信息;没有详细记录时仅展示设备选择与原因,不列出空的测速字段。损坏或不可读的记录保留路径及错误。当前为 Torch 时,已有 ONNX 记录明确标注为不参与当前选择。JSON 的原始 `calibration` 对象仍保留全部字段。
-未知值为 JSON `null`,文本显示“未知”。例如 Apple Silicon 通常不报告可可靠读取的 CPU 主频,统一内存也不作为独立显存。系统或容器限制导致库存不完整时保留错误说明;不从型号名称猜测设备类型或频率。
+未知值为 JSON `null`,文本显示“unknown”。例如 Apple Silicon 通常不报告可可靠读取的 CPU 主频,统一内存也不作为独立显存。系统或容器限制导致库存不完整时保留错误说明;不从型号名称猜测设备类型或频率。
独立显存采集能力和 Windows PCI 身份修复继续保留,其结果不参与自动 tier。Windows 原生查询不依赖 Torch:DXGI 库存通过 `D3DKMTOpenAdapterFromLuid` / `D3DKMTQueryAdapterInfo(KMTQAITYPE_ADAPTERADDRESS)` 补充物理 PCI 位置,内存仍由对应适配器的 DXGI 接口读取。身份匹配优先使用 LUID 和已知 PCI 坐标,不猜测缺失字段;查询失败或多个同等匹配保留未知。读取预算成功不代表模型推理已验证。
diff --git a/mineru/kit/commands/hardware.py b/mineru/kit/commands/hardware.py
index 53b76360..1ee3392a 100644
--- a/mineru/kit/commands/hardware.py
+++ b/mineru/kit/commands/hardware.py
@@ -29,7 +29,7 @@ def _value(value: Any) -> str:
return "{" + ", ".join(f"{key}: {_value(item)}" for key, item in value.items()) + "}"
if isinstance(value, (list, tuple)):
return "[" + ", ".join(_value(item) for item in value) + "]"
- return "未知" if value is None or value == "" else str(value)
+ return "unknown" if value is None or value == "" else str(value)
def render_detection(data: dict[str, Any]) -> str:
@@ -52,14 +52,14 @@ def render_detection(data: dict[str, Any]) -> str:
def _memory(value: int | None) -> str:
"""将已知字节容量转换为三位小数的 GiB,未知值不附加伪造单位。"""
- return "未知" if value is None else f"{value / 1024**3:.3f} GiB"
+ return "unknown" if value is None else f"{value / 1024**3:.3f} GiB"
def _torch_device_summary(data: dict[str, Any]) -> str:
"""仅展示选中的 Torch 设备及其型号、容量,严格匹配设备索引而不猜测其他卡。"""
device = (data.get("selected_device") or {}).get("device")
if not device:
- return "未知"
+ return "unknown"
kind, _, index_text = device.partition(":")
try:
index = int(index_text) if index_text else 0
@@ -73,7 +73,7 @@ def _torch_device_summary(data: dict[str, Any]) -> str:
if selected.get("total_memory_bytes") is not None:
details.append(_memory(selected["total_memory_bytes"]))
label = f"{kind}:{index}"
- return f"{label}({','.join(details)})" if details else label
+ return f"{label} ({', '.join(details)})" if details else label
def _render_runtime_probe(probe: dict[str, Any]) -> list[str]:
@@ -83,9 +83,9 @@ def _render_runtime_probe(probe: dict[str, Any]) -> list[str]:
# 原生库存已合并进系统显卡;采集失败由报告末尾的 warnings 保留。
return []
if name == "selection" and status == "ok":
- return [f" 小模型后端:{_value(data.get('small_backend'))};VLM 引擎:{_value(data.get('vlm_engine'))}"]
+ return [f" Small model backend: {_value(data.get('small_backend'))}; VLM engine: {_value(data.get('vlm_engine'))}"]
labels = {
- "selection": "后端选择",
+ "selection": "Backend selection",
"torch": "Torch",
"onnx": "ONNX Runtime",
"llama-cpp": "llama.cpp",
@@ -93,25 +93,25 @@ def _render_runtime_probe(probe: dict[str, Any]) -> list[str]:
"lmdeploy": "LMDeploy",
"mlx-vlm": "MLX-VLM",
}
- states = {"ok": "正常", "not_installed": "未安装", "error": "失败", "timeout": "超时"}
- version = f"{data['version']}," if data.get("version") else ""
- lines = [f" {labels.get(name, name)}:{version}{states.get(status, status)}"]
+ states = {"ok": "ok", "not_installed": "not installed", "error": "error", "timeout": "timeout"}
+ version = f"{data['version']}, " if data.get("version") else ""
+ lines = [f" {labels.get(name, name)}: {version}{states.get(status, status)}"]
if probe["error"]:
lines.append(f" {probe['error']}")
if status != "ok":
return lines
if name == "torch":
- lines.append(f" 当前设备:{_torch_device_summary(data)}")
+ lines.append(f" Current device: {_torch_device_summary(data)}")
selected = data.get("selected_device") or {}
if (selected.get("device") or "").split(":", 1)[0] == "cuda":
if data.get("rocm_build"):
- lines.append(f" ROCm 构建版本:{data['rocm_build']}")
+ lines.append(f" ROCm build: {data['rocm_build']}")
elif data.get("cuda_build"):
- lines.append(f" CUDA 构建版本:{data['cuda_build']}")
+ lines.append(f" CUDA build: {data['cuda_build']}")
if selected.get("warning"):
- lines.append(f" 提示:{selected['warning']}")
+ lines.append(f" Warning: {selected['warning']}")
lines.extend(
- f" 提示:{backend} 探测失败:{details['error']}"
+ f" Warning: {backend} probe failed: {details['error']}"
for backend, details in data.get("backends", {}).items()
if details.get("error")
)
@@ -123,27 +123,27 @@ def _render_runtime_probe(probe: dict[str, Any]) -> list[str]:
for provider in data.get("providers", [])
]
if providers:
- lines.append(f" 可用 Provider:{', '.join(providers)}")
+ lines.append(f" Available providers: {', '.join(providers)}")
selected = data.get("selected_device") or {}
device = selected.get("device")
adapter = selected.get("adapter") or data.get("selected_adapter") or {}
if selected.get("reason") in {"calibration_required", "calibration_pending"}:
- lines.append(" 设备选择:待校准")
+ lines.append(" Device selection: pending calibration")
if adapter.get("name"):
- lines.append(f" 候选设备:{adapter['name']}")
+ lines.append(f" Candidate device: {adapter['name']}")
elif device == "gpu":
label = f"{selected.get('backend') or data.get('backend')}:gpu"
- detail = f"({adapter['name']})" if adapter.get("name") else ""
- lines.append(f" 设备选择:{label}{detail}")
+ detail = f" ({adapter['name']})" if adapter.get("name") else ""
+ lines.append(f" Device selection: {label}{detail}")
else:
- lines.append(f" 设备选择:{_value(device)}")
+ lines.append(f" Device selection: {_value(device)}")
if data.get("adapter_error"):
- lines.append(f" 提示:{data['adapter_error']}")
+ lines.append(f" Warning: {data['adapter_error']}")
elif name == "llama-cpp" and "devices" in data:
- lines.append(" 可见设备:" if data["devices"] else " 未发现可见 GPU")
+ lines.append(" Visible devices:" if data["devices"] else " No visible GPU found")
for device in data["devices"]:
label = device.get("name") or device.get("backend") or "GPU"
- detail = f":{device['description']}" if device.get("description") else ""
+ detail = f": {device['description']}" if device.get("description") else ""
lines.append(f" {label}{detail}")
return lines
@@ -153,65 +153,69 @@ def _render_device_selection(data: dict[str, Any]) -> list[str]:
backend = (data["effective_config"].get("resolved") or {}).get("small_backend")
probe = next((probe for probe in data["runtimes"] if probe["name"] == backend), None)
selection = probe["data"].get("selected_device") if probe and probe["status"] == "ok" else None
- lines = ["设备选择与校准:", f" 小模型后端:{_value(backend)}"]
+ lines = ["Device selection and calibration:", f" Small model backend: {_value(backend)}"]
reason = selection.get("reason") if selection else None
reasons = {
- "torch_accelerator": "Torch 加速设备可用",
- "torch_cpu": "未发现可用的 Torch 加速设备,使用 CPU",
- "torch_device_unavailable": "指定的 Torch 设备不可用,回退 CPU",
- "torch_device_error": "Torch 设备检查失败,回退 CPU",
- "configured_cpu": "配置指定使用 CPU",
- "configured_gpu": "配置指定使用 GPU,跳过自动测速",
- "discrete_gpu": "已确认的候选独显满足免校准规则",
- "unsupported_platform": "当前平台不支持 ONNX GPU 路径,使用 CPU",
- "directml_unavailable": "DirectML provider 不可用,使用 CPU",
- "no_hardware_gpu": "未发现可用的 ONNX GPU,使用 CPU",
- "webgpu_architecture_policy": "没有通过 WebGPU 架构与可见性检查的 GPU,使用 CPU",
- "calibration_required": "候选 GPU 需要 OCR 校准后才能确定最终设备",
- "calibration_pending": "当前后端尚未配置可用的校准阈值",
- "selection_unavailable": "设备探测失败,无法确定选择结果",
+ "torch_accelerator": "A Torch accelerator is available",
+ "torch_cpu": "No usable Torch accelerator found; using CPU",
+ "torch_device_unavailable": "The configured Torch device is unavailable; falling back to CPU",
+ "torch_device_error": "Torch device checks failed; falling back to CPU",
+ "configured_cpu": "CPU selected by configuration",
+ "configured_gpu": "GPU selected by configuration; automatic benchmarking skipped",
+ "discrete_gpu": "The confirmed discrete GPU candidate meets the rules for skipping calibration",
+ "unsupported_platform": "ONNX GPU execution is unsupported on this platform; using CPU",
+ "directml_unavailable": "DirectML provider is unavailable; using CPU",
+ "no_hardware_gpu": "No usable ONNX GPU found; using CPU",
+ "webgpu_architecture_policy": "No GPU passed the WebGPU architecture and visibility checks; using CPU",
+ "calibration_required": "The candidate GPU requires OCR calibration before final device selection",
+ "calibration_pending": "No usable calibration threshold is configured for the current backend",
+ "selection_unavailable": "Device probing failed; selection could not be determined",
}
if selection:
device = selection.get("device")
if reason in {"calibration_required", "calibration_pending"}:
- device = "待校准"
+ device = "pending calibration"
elif backend == "onnx" and device == "gpu":
device = f"{selection['backend']}:gpu"
- lines.append(f" 选择设备:{_value(device)}")
- lines.append(f" 选择依据:{reasons.get(reason, _value(reason))} ({_value(reason)})")
+ lines.append(f" Selected device: {_value(device)}")
+ lines.append(f" Selection reason: {reasons.get(reason, _value(reason))} ({_value(reason)})")
if selection.get("warning"):
- lines.append(f" 设备提示:{selection['warning']}")
+ lines.append(f" Device warning: {selection['warning']}")
if backend == "onnx" and selection.get("device") == "gpu":
- lines.append(" 验证范围:只读选型,尚未验证 GPU 推理会话")
+ lines.append(" Validation scope: read-only selection; GPU inference session has not been validated")
else:
- lines.append(" 选择设备:未知")
- detail = f"{probe['status']},{_value(probe['error'])}" if probe else "未取得对应运行时的设备选择结果"
- lines.append(f" 选择依据:{detail}")
+ lines.append(" Selected device: unknown")
+ detail = f"{probe['status']}, {_value(probe['error'])}" if probe else "No device selection result from this runtime"
+ lines.append(f" Selection reason: {detail}")
if backend == "torch":
- lines.append(" 校准:不适用(Torch 后端无需 ONNX OCR 校准)")
+ lines.append(" Calibration: not applicable (Torch does not require ONNX OCR calibration)")
elif reason in {"discrete_gpu", "configured_gpu"}:
- lines.append(" 校准:免校准")
+ lines.append(" Calibration: skipped")
elif reason in {"calibration_required", "calibration_pending"}:
- lines.append(" 校准:待完成(info 只读检查不会执行测速)")
+ lines.append(" Calibration: pending (info performs read-only checks without benchmarking)")
elif selection and selection.get("device") == "cpu":
- lines.append(" 校准:未执行(当前选择 CPU)")
+ lines.append(" Calibration: not performed (CPU is currently selected)")
calibration = data["calibration"]
if calibration["status"] == "present":
- label = "ONNX 校准记录(不参与当前 Torch 设备选择)" if backend == "torch" else "ONNX 校准记录"
- lines.append(f" {label}:")
+ label = (
+ "ONNX calibration record (not used for current Torch device selection)"
+ if backend == "torch"
+ else "ONNX calibration record"
+ )
+ lines.append(f" {label}:")
lines.extend(f" {key}: {_value(value)}" for key, value in calibration.items() if value is not None)
elif calibration["status"] == "invalid":
lines.extend(
[
- " 校准记录:不可用",
+ " Calibration record: unavailable",
f" path: {calibration['path']}",
f" error: {_value(calibration['error'])}",
]
)
elif backend != "torch" and reason not in {"discrete_gpu", "configured_gpu"}:
- lines.append(" 校准记录:无详细记录")
+ lines.append(" Calibration record: no detailed record")
return lines
@@ -220,50 +224,52 @@ def _render_info_section(section: HardwareInfoSection, data: dict[str, Any]) ->
if section == "environment":
return "\n".join(
[
- f"系统:{data['system']['name']} {data['system']['release']} ({data['system']['architecture']})",
- f"系统版本:{_value(data['system'].get('os_version'))}",
- f"发行版:{_value(data['system']['distribution'])}",
- f"Python:{data['python']['version']}",
- f"MinerU:{data['mineru']['version']}",
+ f"System: {data['system']['name']} {data['system']['release']} ({data['system']['architecture']})",
+ f"OS version: {_value(data['system'].get('os_version'))}",
+ f"Distribution: {_value(data['system']['distribution'])}",
+ f"Python: {data['python']['version']}",
+ f"MinerU: {data['mineru']['version']}",
]
)
if section == "cpu_memory":
cpu, memory = data["cpu"], data["memory"]
return "\n".join(
[
- f"CPU:{_value(cpu['model'])}",
- f"CPU 核数:物理 {_value(cpu['physical_cores'])},逻辑 {_value(cpu['logical_cores'])},"
- f"进程可用 {_value(cpu['available_cores'])}",
- f"CPU 频率 (MHz):基础 {_value(cpu['base_mhz'])},当前 {_value(cpu['current_mhz'])},"
- f"最大 {_value(cpu['max_mhz'])}",
- f"内存:总量 {_memory(memory['total_bytes'])},可用 {_memory(memory['available_bytes'])}",
+ f"CPU: {_value(cpu['model'])}",
+ f"CPU cores: physical {_value(cpu['physical_cores'])}, logical {_value(cpu['logical_cores'])}, "
+ f"available to process {_value(cpu['available_cores'])}",
+ f"CPU frequency (MHz): base {_value(cpu['base_mhz'])}, current {_value(cpu['current_mhz'])}, "
+ f"max {_value(cpu['max_mhz'])}",
+ f"Memory: total {_memory(memory['total_bytes'])}, available {_memory(memory['available_bytes'])}",
]
)
if section == "packages":
- return "\n".join(["已安装软件:", *(f" {package['name']} {package['version']}" for package in data["packages"])])
+ return "\n".join(
+ ["Installed packages:", *(f" {package['name']} {package['version']}" for package in data["packages"])]
+ )
if section == "gpus":
- lines = ["系统显卡:"]
+ lines = ["System GPUs:"]
if not data["gpus"]:
- lines.append(" 未发现;如有探测错误,请参见提示")
+ lines.append(" None found; see warnings for any probe errors")
for gpu in data["gpus"]:
lines.extend(
[
- f" {_value(gpu['name'])} [{gpu['kind']}],厂商 {_value(gpu['vendor'])},标识 {_value(gpu['device_id'])}",
- f" 来源 {gpu['source']},驱动 {_value(gpu['driver'])},总线 {_value(gpu['bus_id'])}",
- f" 独立显存 {_memory(gpu['dedicated_memory_bytes'])},"
- f"共享内存 {_memory(gpu['shared_memory_bytes'])},统一内存 {_value(gpu['unified_memory'])}",
+ f" {_value(gpu['name'])} [{gpu['kind']}], vendor {_value(gpu['vendor'])}, ID {_value(gpu['device_id'])}",
+ f" Source {gpu['source']}, driver {_value(gpu['driver'])}, bus {_value(gpu['bus_id'])}",
+ f" Dedicated memory {_memory(gpu['dedicated_memory_bytes'])}, "
+ f"shared memory {_memory(gpu['shared_memory_bytes'])}, unified memory {_value(gpu['unified_memory'])}",
]
)
return "\n".join(lines)
if section == "runtimes":
- lines = ["运行时:"] if data.get("runtime_header", True) else []
+ lines = ["Runtimes:"] if data.get("runtime_header", True) else []
for probe in data["runtimes"]:
lines.extend(_render_runtime_probe(probe))
return "\n".join(lines)
- lines = ["有效配置:"]
+ lines = ["Effective configuration:"]
lines.extend(f" {key}: {_value(value)}" for key, value in data["effective_config"].items())
lines.extend(_render_device_selection(data))
- lines.extend(f"提示:{warning}" for warning in data["warnings"])
+ lines.extend(f"Warning: {warning}" for warning in data["warnings"])
return "\n".join(lines)
diff --git a/tests/unittest/test_hardware_info.py b/tests/unittest/test_hardware_info.py
index 4fa38ffc..b005bc3a 100644
--- a/tests/unittest/test_hardware_info.py
+++ b/tests/unittest/test_hardware_info.py
@@ -69,7 +69,7 @@ def test_info_command_output(monkeypatch: pytest.MonkeyPatch, json_mode: bool) -
if json_mode:
assert json.loads(result.stdout) == report
else:
- assert "test CPU" in result.stdout and "未知" in result.stdout
+ assert "test CPU" in result.stdout and "unknown" in result.stdout
assert "driver unavailable" in result.stdout
assert result.stdout.rstrip() == command.render_info(report)
assert "/env" not in result.stdout and "/source" not in result.stdout
@@ -362,7 +362,7 @@ def test_help_imports_no_heavy_runtime(arguments: list[str]) -> None:
assert result.returncode == 0, result.stderr
[email protected]("amount, expected", [(None, "未知"), (0, "0.000 GiB"), (16 * 1024**3, "16.000 GiB")])
[email protected]("amount, expected", [(None, "unknown"), (0, "0.000 GiB"), (16 * 1024**3, "16.000 GiB")])
def test_info_memory_and_runtime_paths(amount: int | None, expected: str) -> None:
"""系统与嵌套运行时容量使用相同单位,文本隐藏路径且原始 JSON 不受影响。"""
data = asdict(_report())
@@ -382,13 +382,13 @@ def test_info_memory_and_runtime_paths(amount: int | None, expected: str) -> Non
]
before = json.dumps(data)
rendered = command.render_info(data)
- assert f"总量 {expected}" in rendered
- assert f"共享内存 {expected}" in rendered
+ assert f"total {expected}" in rendered
+ assert f"shared memory {expected}" in rendered
if amount is None:
- assert "当前设备:cuda:0\n" in rendered
+ assert "Current device: cuda:0\n" in rendered
else:
- assert f"当前设备:cuda:0({expected})" in rendered
- assert "独立显存 未知," in rendered and "未知 bytes" not in rendered
+ assert f"Current device: cuda:0 ({expected})" in rendered
+ assert "Dedicated memory unknown, " in rendered and "unknown bytes" not in rendered
assert "module_path" not in rendered and "/runtime" not in rendered and "/nested" not in rendered
assert "/env" not in rendered and "/source" not in rendered
assert "/tmp/config.yaml.onnx-calibration.json" not in rendered
@@ -511,7 +511,7 @@ def test_text_sections_flush_before_probe_completion(monkeypatch: pytest.MonkeyP
"""在返回完整报告之前检查分节通知是否已经写入可读内容。"""
if on_section:
on_section("environment", asdict(_report()))
- assert "Python:3.12" in output.getvalue()
+ assert "Python: 3.12" in output.getvalue()
assert output.flushes == 1
else:
assert not output.getvalue()
@@ -528,11 +528,11 @@ def test_text_sections_flush_before_probe_completion(monkeypatch: pytest.MonkeyP
@pytest.mark.parametrize(
"backend, device, reason, expected",
[
- ("torch", "mps", "torch_accelerator", "Torch 加速设备可用"),
- ("torch", "cpu", "configured_cpu", "配置指定使用 CPU"),
- ("onnx", "gpu", "discrete_gpu", "候选独显满足免校准规则"),
- ("onnx", "gpu", "configured_gpu", "配置指定使用 GPU"),
- ("onnx", None, "calibration_required", "需要 OCR 校准后才能确定最终设备"),
+ ("torch", "mps", "torch_accelerator", "A Torch accelerator is available"),
+ ("torch", "cpu", "configured_cpu", "CPU selected by configuration"),
+ ("onnx", "gpu", "discrete_gpu", "discrete GPU candidate meets the rules for skipping calibration"),
+ ("onnx", "gpu", "configured_gpu", "GPU selected by configuration"),
+ ("onnx", None, "calibration_required", "requires OCR calibration before final device selection"),
],
)
def test_info_without_calibration_explains_device(backend: str, device: str | None, reason: str, expected: str) -> None:
@@ -552,14 +552,14 @@ def test_info_without_calibration_explains_device(backend: str, device: str | No
]
before = json.dumps(data)
rendered = "\n".join(command._render_device_selection(data))
- assert "设备选择与校准:" in rendered and expected in rendered
- assert all(key not in rendered for key in ("path:", "cpu_elapsed:", "matches_environment:", "未知"))
+ assert "Device selection and calibration:" in rendered and expected in rendered
+ assert all(key not in rendered for key in ("path:", "cpu_elapsed:", "matches_environment:", "unknown"))
if backend == "torch":
- assert f"选择设备:{device}" in rendered and "不适用" in rendered
+ assert f"Selected device: {device}" in rendered and "not applicable" in rendered
elif device == "gpu":
- assert "选择设备:dml:gpu" in rendered and "校准:免校准" in rendered
+ assert "Selected device: dml:gpu" in rendered and "Calibration: skipped" in rendered
else:
- assert "选择设备:待校准" in rendered and "不会执行测速" in rendered
+ assert "Selected device: pending calibration" in rendered and "without benchmarking" in rendered
assert json.dumps(data) == before
@@ -588,8 +588,8 @@ def test_info_calibration_details_are_preserved(backend: str, matches: bool) ->
assert "cpu_elapsed: 2.0" in rendered and "gpu_elapsed: 1.0" in rendered
assert "ratio: 0.5" in rendered and "threshold: 0.8" in rendered
assert "path: /record.json" in rendered and "model_sha256: test-hash" in rendered
- assert "error: 未知" not in rendered
- assert ("不参与当前 Torch 设备选择" in rendered) == (backend == "torch")
+ assert "error: unknown" not in rendered
+ assert ("not used for current Torch device selection" in rendered) == (backend == "torch")
def test_info_invalid_record_and_probe_failure_remain_visible() -> None:
@@ -597,8 +597,8 @@ def test_info_invalid_record_and_probe_failure_remain_visible() -> None:
data = asdict(_report())
data["calibration"] = asdict(onnx_calibration_cache.CalibrationInfo("/bad.json", "invalid", error="invalid record"))
rendered = "\n".join(command._render_device_selection(data))
- assert "选择设备:未知" in rendered and "driver unavailable" in rendered
- assert "校准记录:不可用" in rendered and "invalid record" in rendered
+ assert "Selected device: unknown" in rendered and "driver unavailable" in rendered
+ assert "Calibration record: unavailable" in rendered and "invalid record" in rendered
assert "path: /bad.json" in rendered and "cpu_elapsed" not in rendered
diff --git a/tests/unittest/test_hardware_runtime_output.py b/tests/unittest/test_hardware_runtime_output.py
index bdf13a11..99486334 100644
--- a/tests/unittest/test_hardware_runtime_output.py
+++ b/tests/unittest/test_hardware_runtime_output.py
@@ -76,19 +76,19 @@ def test_windows_runtime_summary_preserves_raw_diagnostics(windows_runtimes: dic
rendered = command._render_info_section("runtimes", windows_runtimes)
assert rendered == "\n".join(
[
- "运行时:",
- " 小模型后端:torch;VLM 引擎:lmdeploy",
- " Torch:2.12.1+cu126,正常",
- " 当前设备:cuda:0(NVIDIA GeForce RTX 3060 Ti,8.000 GiB)",
- " CUDA 构建版本:12.6",
- " ONNX Runtime:1.24.4,正常",
- " 可用 Provider:DirectML, CPU",
- " 设备选择:dml:gpu(NVIDIA GeForce RTX 3060 Ti)",
- " llama.cpp:正常",
- " 可见设备:",
- " Vulkan0:NVIDIA GeForce RTX 3060 Ti",
- " Vulkan1:Intel(R) UHD Graphics 770",
- " LMDeploy:0.17.0,正常",
+ "Runtimes:",
+ " Small model backend: torch; VLM engine: lmdeploy",
+ " Torch: 2.12.1+cu126, ok",
+ " Current device: cuda:0 (NVIDIA GeForce RTX 3060 Ti, 8.000 GiB)",
+ " CUDA build: 12.6",
+ " ONNX Runtime: 1.24.4, ok",
+ " Available providers: DirectML, CPU",
+ " Device selection: dml:gpu (NVIDIA GeForce RTX 3060 Ti)",
+ " llama.cpp: ok",
+ " Visible devices:",
+ " Vulkan0: NVIDIA GeForce RTX 3060 Ti",
+ " Vulkan1: Intel(R) UHD Graphics 770",
+ " LMDeploy: 0.17.0, ok",
]
)
assert json.dumps(windows_runtimes) == before
@@ -118,9 +118,9 @@ def test_torch_summary_selects_actual_device_index(backend: str) -> None:
)
)
rendered = "\n".join(command._render_runtime_probe(probe))
- assert f"当前设备:{backend}:1(selected GPU,16.000 GiB)" in rendered
+ assert f"Current device: {backend}:1 (selected GPU, 16.000 GiB)" in rendered
assert "other GPU" not in rendered
- assert ("CUDA 构建版本" in rendered) == (backend == "cuda")
+ assert ("CUDA build" in rendered) == (backend == "cuda")
assert "ROCm" not in rendered
@@ -138,7 +138,7 @@ def test_torch_summary_does_not_guess_missing_device(device: str) -> None:
)
)
rendered = "\n".join(command._render_runtime_probe(probe))
- assert f"当前设备:{device}" in rendered
+ assert f"Current device: {device}" in rendered
assert "wrong GPU" not in rendered and "8.000 GiB" not in rendered
@@ -156,7 +156,7 @@ def test_torch_summary_displays_rocm_build_when_applicable() -> None:
)
)
rendered = "\n".join(command._render_runtime_probe(probe))
- assert "ROCm 构建版本:6.3" in rendered and "CUDA 构建版本" not in rendered
+ assert "ROCm build: 6.3" in rendered and "CUDA build" not in rendered
@pytest.mark.parametrize("device, reason", [("cpu", "configured_cpu"), (None, "calibration_required")])
@@ -174,9 +174,9 @@ def test_onnx_summary_distinguishes_candidate_from_selected_gpu(device: str | No
)
rendered = "\n".join(command._render_runtime_probe(probe))
if device == "cpu":
- assert "设备选择:cpu" in rendered and "candidate GPU" not in rendered
+ assert "Device selection: cpu" in rendered and "candidate GPU" not in rendered
else:
- assert "设备选择:待校准" in rendered and "候选设备:candidate GPU" in rendered
+ assert "Device selection: pending calibration" in rendered and "Candidate device: candidate GPU" in rendered
@pytest.mark.parametrize("name", ["dxgi", "vulkan"])
@@ -200,5 +200,5 @@ def test_runtime_summary_keeps_actionable_errors() -> None:
)
)
rendered = command._render_info_section("runtimes", {"runtimes": [failed, torch]})
- assert "ONNX Runtime:失败" in rendered and "driver unavailable" in rendered
- assert "configured GPU unavailable" in rendered and "cuda 探测失败:driver failure" in rendered
+ assert "ONNX Runtime: error" in rendered and "driver unavailable" in rendered
+ assert "configured GPU unavailable" in rendered and "cuda probe failed: driver failure" in rendered