Simplifies Mixed Boolean-Arithmetic (MBA) expressions on Huawei Ascend 910 NPU. This is an NPU adaptation of qox/mba-simplifier with explicit npu:0 execution.
Three-layer pipeline (first hit wins):
d_model=256, n_heads=8, n_layers=4 — runs on npu:0 via torch_npuBase weights: mba_classifier.safetensors (8.5MB) + config.json/char_vocab.json/rule_vocab.json from original model.
| Metric | Value |
|---|---|
| CPU vs NPU cosine | 1.000000 (all samples) |
| max_diff | <5e-06 (fp32) |
| Top-1 rule agreement | 100% (10/10) |
| Pipeline correctness | 100% (10/10 cases) |
Validated on Ascend910_9362 with torch.npu.is_available()=True, next(model.parameters()).device=npu:0, input_ids.device=npu:0, logits.device=npu:0.
torch.npu.synchronize())pip install -r requirements.txt # torch, torch_npu, safetensors, numpy
python inference.py "(x & y) + (x | y)" --device npu:0
# also:
python inference.py "~(~x & ~y)" --bits 8from inference import simplify, DEVICE
print(DEVICE) # npu:0 on Ascend, cpu otherwise
result = simplify("(x & y) + (x | y)")
print(result["simplified"]) # "x + y"
print(result["strategy"]) # "bfs"
print(result["device"]) # "npu:0"| Input | Output | Strategy |
|---|---|---|
| `(x & y) + (x | y)` | x + y |
| `(x | y) - (x & y)` | x ^ y |
~(~x) | x | bfs |
x ^ x | 0 | bfs |
| `x & (x | y)` | x |
npu:0 (model.to(torch.device("npu:0")), input_ids.to("npu:0")).torch.npu.synchronize() is called before/after timing.aten::_transformer_encoder_layer_fwd (documented), but surrounding ops remain on NPU and logits.device==npu:0 is proven.

bfs_table_6.json, mba_classifier.safetensors, config.json, char_vocab.json, rule_vocab.json