#NPU — AutoGluon Mitra Classifier 1.1 tabular foundation model (classification) running real inference on Ascend 910 NPU (npu:0).
autogluon/mitra-classifier-1.1 (revision 10eead743ab2d810e0738fe2234c566bc8cea0d6)model.safetensors (no trust_remote_code, no flash-attention dependency)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.
Validation dataset: Iris (scikit-learn, load_iris, 150 rows, 4 numeric features, 3 classes).
| Item | Value |
|---|---|
| Rows (total) | 150 |
| Features | 4 (sepal length, sepal width, petal length, petal width) |
| Classes | 3 (setosa, versicolor, virginica) |
| Split | stratified 80/20 (random_state=42) |
| Support set | 120 rows (train) |
| Query set | 30 rows (test) |
| Column order | preserved (no re-ordering) |
| Dtype | float32 input, int64 labels |
| Missing values | imputed with column mean (none present in Iris) |
| Singular columns | dropped (none in Iris) |
| Random mirror | fixed 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).
npu:0pip 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.0Download 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 ./modelRun real inference on npu:0 (default command):
python inference.py --model-dir ./modelExample 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.026msBoth runs use identical weights, inputs, preprocessing, dtype (float32) and random seed.
| Metric | Value |
|---|---|
| Logits max abs error | 3.10e-4 (probabilities) |
| Probabilities max abs error | 3.10e-4 |
| Probabilities mean abs error | 3.02e-5 |
| Argmax (class) agreement | 1.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.
Measured with torch.npu.synchronize() around every timed iteration.
| Metric | Value |
|---|---|
| First run (graph compile + inference) | 181.7 ms |
| Avg inference | 20.5 ms |
| Min / Max | 20.4 / 21.1 ms |
| p50 / p90 / p95 | 20.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.
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.dim_output=10); datasets with more classes require fine-tuning, which is out of scope for this adaptation (in-context inference is demonstrated).load_dataset() with your own CSV loader and keep the column order and label encoding consistent.