w
gcw_uQ09W7jl/autogluon-mitra-classifier-1.1-NPU
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

Mitra Classifier 1.1 (NPU)

#NPU — AutoGluon Mitra Classifier 1.1 tabular foundation model (classification) running real inference on Ascend 910 NPU (npu:0).

  • Model: autogluon/mitra-classifier-1.1 (revision 10eead743ab2d810e0738fe2234c566bc8cea0d6)
  • Architecture: Tab2D (12-layer dual-attention Transformer, 75.67M params, dim=512, 4 heads, 10 output classes)
  • Task: tabular classification via in-context learning (ICL) — no fine-tuning required
  • Loading backend: custom portable PyTorch implementation loaded from local model.safetensors (no trust_remote_code, no flash-attention dependency)

Model overview

Mitra Classifier 1.1 is a tabular foundation model pretrained on purely synthetic data and designed for in-context learning. Given a labeled support set (train rows + labels) and an unlabeled query set (test rows), it predicts query labels by attending over the support examples. The pretrained weights perform strong classification out of the box (fine_tune=False in AutoGluon's README example).

This repository contains a self-contained, dependency-light PyTorch re-implementation of AutoGluon's Tab2D model. The model file layout is identical to the upstream checkpoint (config.json + model.safetensors), and weights load directly with load_state_dict. The non-flash attention path uses torch.nn.functional.scaled_dot_product_attention, which maps cleanly onto torch_npu kernels — no CUDA-only operators are used.

Data contract

Validation dataset: Iris (scikit-learn, load_iris, 150 rows, 4 numeric features, 3 classes).

ItemValue
Rows (total)150
Features4 (sepal length, sepal width, petal length, petal width)
Classes3 (setosa, versicolor, virginica)
Splitstratified 80/20 (random_state=42)
Support set120 rows (train)
Query set30 rows (test)
Column orderpreserved (no re-ordering)
Dtypefloat32 input, int64 labels
Missing valuesimputed with column mean (none present in Iris)
Singular columnsdropped (none in Iris)
Random mirrorfixed seed=0 for reproducibility

The preprocessing matches the AutoGluon Mitra Preprocessor with production defaults: use_quantile_transformer=False (quantile bucketing is performed inside the model on-device), use_random_transforms=False, shuffle_features=False, shuffle_classes=False, random_mirror_x=True (feature sign flip fixed at seed 0).

Environment

  • Huawei Ascend 910 (Ascend910_9362), 2 NPUs visible, target device npu:0
  • CANN 8.5.1
  • Python 3.11.14
  • PyTorch 2.9.0 + torch_npu 2.9.0 (torch_npu required only for NPU execution)
  • No flash-attn, no einops/einx, no AutoGluon required

Installation

pip install -r requirements.txt
# If torch_npu is not preinstalled, install the build matching your torch version, e.g.:
# pip install torch-npu==2.9.0

NPU inference

Download the pretrained weights once and load them from the local directory (the repository does not bundle the 303 MB checkpoint):

export HF_ENDPOINT=https://hf-mirror.com   # optional, recommended in CN regions
huggingface-cli download autogluon/mitra-classifier-1.1 --local-dir ./model

Run real inference on npu:0 (default command):

python inference.py --model-dir ./model

Example output (truncated):

model_repo: autogluon/mitra-classifier-1.1
device:     npu:0  (npu_available=True, count=2)
model:      Tab2D  layers=12 dim=512 heads=4 output_classes=10 params=75,670,026
weights:    first param device=npu:0 dtype=torch.float32
dataset:    iris (scikit-learn) rows=150 features=4 classes=3 ['setosa', 'versicolor', 'virginica']
tensors:    x_support torch.Size([1, 120, 4]) torch.float32 npu:0 | x_query torch.Size([1, 30, 4]) torch.float32 npu:0
output:     logits (30, 3) float32 | probs (30, 3) float32
metrics:    accuracy=1.0000  (n=30, support_rows=120)
status:     OK  device=npu:0 dtype=torch.float32 compile_or_first_run=201.026ms

Real results (this run)

  • Accuracy: 1.0000 (30/30 correct) on Iris test set via in-context learning (no fine-tuning)
  • CPU baseline: 100% accuracy (same predictions)

CPU–NPU consistency

Both runs use identical weights, inputs, preprocessing, dtype (float32) and random seed.

MetricValue
Logits max abs error3.10e-4 (probabilities)
Probabilities max abs error3.10e-4
Probabilities mean abs error3.02e-5
Argmax (class) agreement1.0 (100%)

Thresholds: atol=1e-3, rtol=1e-2 on probabilities (float32 across different hardware accumulation order). The predicted class labels are identical on CPU and NPU.

Performance (NPU, fp32, batch=1, support=120 rows, query=30 rows)

Measured with torch.npu.synchronize() around every timed iteration.

MetricValue
First run (graph compile + inference)181.7 ms
Avg inference20.5 ms
Min / Max20.4 / 21.1 ms
p50 / p90 / p9520.5 / 20.6 / 20.9 ms
Throughput~1461 rows/s (query rows per batched inference)
Peak NPU memory (allocated / reserved)340.9 / 372.0 MB

Timing includes on-device quantile bucketing (999 quantiles) and the full 12-layer dual-attention forward pass. CSV/DataFrame loading and preprocessing are excluded from the timed region.

Evidence

The following images were rendered by xterm.js from this run's real stdout/stderr logs (not fabricated screenshots):

  • assets/agent_workflow.png — environment check, model inspection, weights download, CPU baseline, NPU inference, consistency check and benchmark.
  • assets/npu_device_call.png — npu-smi info + check_npu.py + model parameter device/dtype proof.
  • assets/model_result.png — default python inference.py full output with schema summary, real predictions, metrics and final status.

Limitations

  • The pretrained checkpoint targets up to 10 classes (dim_output=10); datasets with more classes require fine-tuning, which is out of scope for this adaptation (in-context inference is demonstrated).
  • Tabular preprocessing (imputation, singular-feature removal, random mirror) runs on CPU; the model core forward (quantile embedding, attention, MLPs, classification head) runs entirely on NPU.
  • The demo dataset is Iris; for a different dataset, replace load_dataset() with your own CSV loader and keep the column order and label encoding consistent.
  • NPU first-call latency includes graph compilation; steady-state latency is reported separately.