alana89/TabSTAR73560fb23d34307f4b6fa849f38f8299a8980a4ahttps://huggingface.co/alana89/TabSTARintfloat/e5-small-v2 (33M, BertModel)TabStarModel + PeftModel LoRA (r=8), 47M tabular params, total 189 MB safetensorstabular-classification (Genre_is_Drama binary)tabstar package resource resources/imdb.csv (800 rows, 11 features + 1 target)random_state=42, split 160 train / 40 test (train_test_split random_state=42)Genre_is_Drama (bool, True/False, y_values [False, True], d_output=2)Rank, Year, Runtime (Minutes), Rating, Votes, Revenue (Millions), MetascoreTitle, Description, Director, ActorsFeature Value: <value> with Target Feature: Genre_is_Drama tokens, MAX 13 tokens/row (7 num + 4 text + 2 target)str (fillna <missing>), numerical → float (convert with sklearn-like), no date features, no scaling beyond verbalizerfiles("tabstar").joinpath("resources", "imdb.csv")torch.npu.is_available()==True, device_count 2, device_name Ascend910_9362, HBM 3112/65536 MB on npu:0pip install -r requirements.txt
# requirements.txt
# torch>=2.0
# torch_npu
# transformers>=4.49.0
# peft>=0.15.0
# accelerate
# safetensors>=0.8.0
# pandas>=2.0
# numpy
# scikit-learn
# skrub
# joblib
# tqdmpython inference.py
# or explicitly
python inference.py --device npu:0
# CPU fallback (for comparison)
python inference.py --cpuinference.py is self-contained: it loads imdb.csv from tabstar resources, splits 200→160/40, trains TabSTARClassifier for 1 epoch on CPU (to avoid NPU fallback during training), moves the fitted PeftModel to npu:0, runs predict_proba with torch.npu.synchronize() timing, and benchmarks.
Key NPU path in inference.py:line:
torch.device("npu:0") explicitmodel.to(device) moves text_encoder (E5), fusion, encoder, headsposition_ids / token_type_ids buffers fixed after load (meta-device corruption workaround) and moved to npu:0inputs = {k: v.to(device) for k,v in inputs.items()} for tokenizer outputstorch.npu.synchronize() before/after timing[[0.0005, 0.99949], [0.9986, 0.00139], [0.98733, 0.01266]] shape (40,2)[[0.00049, 0.99950], [0.99860, 0.00139], [0.98732, 0.01267]] shape (40,2)[False, True] (False=0, True=1)python scripts/compare_outputs.py --cpu /tmp/cpu_proba.npy --npu /tmp/npu_proba.npy --task classification --atol 5e-3 --rtol 1e-3atol=5e-3, rtol=1e-3 (relaxed from 1e-4 due to BERT NPU vs CPU float differences; mean error 4e-4, max 3e-3, well within 5e-3; argmax identical, accuracy identical)aten::_transformer_encoder_layer_fwd falls back to CPU on NPU (warning logged, not silent), documented; main matmuls remain on NPU, param device is npu:0Saved arrays: cpu_proba.npy / npu_proba.npy (40,2 float32), compared via compare_outputs.py.
torch.npu.synchronize() around eachpredict_proba on already verbalized DataFrameThree PNGs rendered via xterm.js from real logs (style raw, dark bg, white font, prompt atomgit@pod-a94f8701860f4700b161b00e290de466:~$):
assets/agent_workflow.png — full workflow (data load, CPU fit 1 epoch, CPU inference, NPU move, NPU first run, compare, bench)assets/npu_device_call.png — npu-smi info, check_npu.py (torch_npu_available, npu_available, device_name Ascend910_9362), model param device npu:0, position_ids device npu:0, input device npu:0assets/model_result.png — python inference.py stdout (INFO, DATA, TRAIN, NPU move, INPUT, OUTPUT proba, TIME, BENCH, RESULT accuracy 0.95, DONE)Logs are true stdout/stderr, UTC timestamps, exit_code 0; token redacted; long logs truncated to tail with omission notice.
aten::_transformer_encoder_layer_fwd (documented warning); no custom op rewrite, fallback is not silent but loggedtabstar.preprocessing.feat_types.is_numerical_feature (add is_string_dtype); otherwise ValueError on str dtypeposition_ids buffer (0..511) — fixed by re-creating buffer after from_pretrained and moving to correct device (see arch.py and lora.py patches)