gcw_6a3w2yXz/autogluon-mitra-classifier-NPU-2
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

autogluon/mitra-classifier-NPU

#NPU

模型简介

  • 模型名称: autogluon/mitra-classifier
  • Revision: 本地 working/models/mitra-classifier (config.json dim 512, dim_output 10, n_layers 12, n_heads 4, task CLASSIFICATION)
  • 模型类型: 表格数据 · tabular-classification (多分类)
  • 架构: Tab2D —— 12 层 Transformer,隐藏维度 512,4 头注意力,约 75.7M 参数 (~303 MB fp32, 289 MB safetensors),由 AutoGluon 团队在纯合成混合先验上预训练,支持 in-context 学习
  • 任务: 表格多分类,输出 logits [n_query, dim_output] 经切片到真实类别数后 softmax 得概率,argmax 得标签
  • 硬件: 华为昇腾 Ascend 910 (Ascend910_9362) 单卡 npu:0
  • 权重来源: https://huggingface.co/autogluon/mitra-classifier

数据契约

  • 输入: 表格 rows × features,本验证使用 sklearn.datasets.load_wine,形状 [178, 13] -> 划分 train [142,13] / test [36,13] (80/20, random_state=42, stratify)
  • 列名: ['alcohol','malic_acid','ash','alcalinity_of_ash','magnesium','total_phenols','flavanoids','nonflavanoid_phenols','proanthocyanins','color_intensity','hue','od280/od315_of_diluted_wines','proline'],列顺序固定
  • Target: target 三分类 0,1,2
  • 预处理: Preprocessor 执行 nanmean 均值填充,单值列剔除,无缩放;特征选择关闭
  • 数据来源: load_wine,SHA256 前缀 8edcf3903afd97c6

环境

  • NPU: npu-smi 25.5.5, 设备 Ascend910_9362, 2 设备
  • CANN: /usr/local/Ascend/cann-8.5.1
  • Python: 3.11.14, Torch 2.9.0+cpu, torch_npu 2.9.0.post1, einops 0.8.2, einx 0.4.3
  • 可用性: torch.npu.is_available()==True, device_count==2, 目标 npu:0
  • DTYPE: float32

安装

pip install -r requirements.txt

NPU 推理

python inference.py

真实结果(本次运行,NPU:0)

  • 输出形状: logits [36,3], probs [36,3]
  • 统计: mean 6.2054, std 3.3782, min 0.9608, max 11.4540
  • 指标: accuracy 1.0000, macro-F1 1.0000 (36 测试样本)

一致性

  • 相同权重、输入、预处理、dtype=float32、seed
  • python scripts/compare_outputs.py --cpu /tmp/cpu_logits.npy --npu npu_logits.npy --task classification --atol 0.01 --rtol 0.01
  • 结果: max_abs 0.00581, mean_abs 0.00162, argmax_agreement 1.0, passed True

性能

  • 同步: 每轮前后 torch.npu.synchronize()
  • 预热: 3 次,正式: 10 次
  • 耗时: avg 25.8 ms, min 25.4 ms, max 26.4 ms, p50 25.8 ms, p90 26.3 ms, p95 26.4 ms
  • 吞吐: 1392.9 rows/s

证据图

三张 PNG 均由 scripts/render_xterm_evidence.mjs --style raw 根据本次真实日志生成:

  • assets/agent_workflow.png
  • assets/npu_device_call.png
  • assets/model_result.png

agent_workflow npu_device_call model_result

限制

  • dim_output=10 为最大类别数,实际需 ≤10
  • 单次 support 上限 8192,query 上限 1024
  • 未执行 fine_tune,仅验证 in-context 推理