Forge-UGC: FX optimization and register-graph engine for universal graph compiler
Abstract
We present Forge-UGC (FX Optimization and Register-Graph Engine for Universal Graph Compilation), a four-phase compiler for transformer deployment on heterogeneous accelerator hardware, validated on Intel AI Boost NPU. Existing frameworks such as OpenVINO and ONNX Runtime often use opaque compilation pipelines, limited pass-level visibility, and weak buffer management, which can lead to higher compilation cost and runtime overhead. Forge-UGC addresses this with a hardware-agnostic design that separates graph capture, optimization, intermediate representation lowering, and backend scheduling. Phase 1 captures graphs with torch.export at the ATen operator level, supporting modern transformer components such as rotary position embeddings, grouped-query attention, and SwiGLU without manual decomposition. Phase 2 applies six optimization passes: dead code elimination, common subexpression elimination, constant folding, attention fusion, operator fusion, and layout optimization, reducing graph node count by 14.2 to 21.9%. Phase 3 lowers the optimized graph into a typed intermediate representation with explicit virtual register assignments. Phase 4 performs liveness analysis, linear-scan buffer allocation, reducing peak buffer count by 30 to 48%, and device-affinity scheduling, reducing NPU-CPU transitions by 42 to 65%. Across six model families ranging from 125M to 8B parameters, evaluated on WikiText-103 and GLUE, Forge-UGC delivers 6.9 to 9.2x faster compilation than OpenVINO and ONNX Runtime, 18.2 to 35.7% lower inference latency, and 30.2 to 40.9% lower energy per inference. Fidelity is preserved, with max absolute logit differences below 2.1e-5 and KL divergence below 8.4e-9. We also introduce Fusion Gain Ratio, Compilation Efficiency Index, and per-pass execution profiling for systematic evaluation of NPU compilation pipelines.
Figures & tables
| Symbol | Description |
| FX computation graph | |
| Set of graph nodes (operations) | |
| Set of data-dependency edges | |
| Node count before/after optimization | |
| Set of optimization passes | |
| Execution time of pass (ms) |
| Component | Specification |
| CPU | Intel Core Ultra 9 285HX |
| NPU | Intel AI Boost (11 TOPS INT8) |
| NPU Driver | 32.0.100.4514 |
| NPU Memory | Shared LPDDR5, 72.7 GB |
| NPU Location | PCI bus 0, device 11, function 0 |
| GPU | NVIDIA RTX PRO 5000 Blackwell |
| Model | Params | Hidden | Layers | Attn | Precision |
| GPT-2 | 125M | 768 | 12 | MHA | fp16 |
| Granite-350M | 350M | 1024 | 24 | MHA | fp16 |
| Qwen2-0.5B | 500M | 1024 | 24 | GQA | fp16 |
| Llama-3.2-1B | 1.0B | 2048 | 16 | GQA | fp16 |
| LFM2-2.6B | 2.6B | 2560 | 32 | MHA | fp16 |
| Llama-3.1-8B | 8.0B | 4096 | 32 | GQA | W-int8/ A-fp16 |
| Model | FORGE | OpenVINO | ONNX RT |
| GPT-2 (125M) | 1,000 | 6,930 | 7,271 |
| Granite-350M | 1,420 | 9,840 | 10,320 |
| Qwen2-0.5B | 1,680 | 11,240 | 11,890 |
| Llama-3.2-1B | 2,340 | 18,520 | 19,840 |
| LFM2-2.6B | 3,850 | 32,160 | 34,280 |
| Llama-3.1-8B | 6,720 | 58,430 | 62,150 |
| Model | Initial | Final | % | |
| GPT-2 (125M) | 403 | 333 | 70 | 17.4 |
| Granite-350M | 782 | 636 | 146 | 18.7 |
| Qwen2-0.5B | 804 | 652 | 152 | 18.9 |
| Llama-3.2-1B | 562 | 468 | 94 | 16.7 |
| LFM2-2.6B | 1,068 | 834 | 234 | 21.9 |
| Llama-3.1-8B | 1,124 | 896 | 228 | 20.3 |
| Model | PPL Pre | PPL Post | Max-Abs Logit | KL Div |
| GPT-2 (125M) | 29.41 | 29.41 | ||
| Granite-350M | 16.22 | 16.22 | ||
| Qwen2-0.5B | 14.87 | 14.87 | ||
| Llama-3.2-1B | 9.76 | 9.76 | ||
| LFM2-2.6B | 7.52 | 7.52 | ||
| Llama-3.1-8B | 6.24 | 6.24 |
| FORGE-UGC (ms) | OpenVINO (ms) | ONNX Runtime (ms) | ||||||||||
| Model | Mean | P50 | P90 | P99 | Mean | P50 | P90 | P99 | Mean | P50 | P90 | P99 |
| GPT-2 (125M) | 6.82 | 6.74 | 7.31 | 8.12 | 8.45 | 8.38 | 9.12 | 10.84 | 9.13 | 9.02 | 9.87 | 11.52 |
| Granite-350M | 9.41 | 9.32 | 10.08 | 11.24 | 12.67 | 12.54 | 13.81 | 15.93 | 13.28 | 13.12 | 14.55 | 16.87 |
| Qwen2-0.5B | 11.83 | 11.72 | 12.64 | 14.03 | 15.42 | 15.28 | 16.91 | 19.47 | 16.21 | 16.04 | 17.68 | 20.35 |
| Llama-3.2-1B | 18.24 | 18.08 | 19.52 | 21.67 | 24.81 | 24.62 | 27.16 | 31.28 | 26.37 | 26.14 | 28.89 | 33.23 |
| LFM2-2.6B | 31.56 | 31.28 | 33.74 | 37.48 | 45.23 | 44.87 | 49.52 | 57.01 | 48.14 | 47.72 | 52.69 | 60.64 |
| FORGE-UGC (ms) | OpenVINO (ms) | ONNX Runtime (ms) | ||||||||||
| Model | Mean | P50 | P90 | P99 | Mean | P50 | P90 | P99 | Mean | P50 | P90 | P99 |
| GPT-2 (125M) | 5.94 | 5.88 | 6.37 | 7.08 | 7.36 | 7.30 | 7.95 | 9.44 | 7.95 | 7.86 | 8.59 | 10.03 |
| Granite-350M | 8.21 | 8.13 | 8.79 | 9.80 | 11.04 | 10.93 | 12.04 | 13.88 | 11.57 | 11.44 | 12.68 | 14.71 |
| Qwen2-0.5B | 10.32 | 10.22 | 11.02 | 12.23 | 13.44 | 13.32 | 14.74 | 16.97 | 14.13 | 13.98 | 15.41 | 17.74 |
| Llama-3.2-1B | 15.91 | 15.76 | 17.02 | 18.89 | 21.62 | 21.46 | 23.68 | 27.26 | 22.98 | 22.78 | 25.18 | 28.96 |
| LFM2-2.6B | 27.52 | 27.28 | 29.42 | 32.68 | 39.43 | 39.10 | 43.15 | 49.67 | 41.97 | 41.60 | 45.93 | 52.86 |
| Model | FORGE (mJ) | OV (mJ) | ONNX (mJ) | OV | ONNX |
| GPT-2 (125M) | 69.6 | 99.7 | 110.5 | 30.2% | 37.0% |
| Granite-350M | 96.0 | 149.5 | 160.7 | 35.8% | 40.3% |
| Qwen2-0.5B | 120.7 | 181.9 | 196.1 | 33.6% | 38.4% |
| Llama-3.2-1B | 186.0 | 292.8 | 319.1 | 36.5% | 41.7% |
| LFM2-2.6B | 322.0 | 533.7 | 582.5 | 39.7% | 44.7% |
| Llama-3.1-8B | 637.3 | 1,078.2 | 1,183.6 | 40.9% | 46.2% |
| Pass | Time (ms) | Nodes |
| DCE | 7 | 0 |
| CSE | 9 | 0 |
| Constant Folding | 11 | 0 |
| Device Constant | 21 | +1 |
| Attention Fusion | 38 | 59 |
| Operator Fusion | 72 | 12 |
| Model | Layers | Opt. Time | Attn. Fusion |
| GPT-2 | 12 | 208 | 38 |
| Granite-350M | 24 | 382 | 71 |
| Qwen2-0.5B | 24 | 396 | 74 |
| Llama-3.2-1B | 16 | 284 | 52 |
| LFM2-2.6B | 32 | 548 | 102 |
| Llama-3.1-8B | 32 | 572 | 108 |
| Model | Score ( =0) | Score ( =1) | FGR |
| GPT-2 (125M) | 364.87 | 8.64 | 42.3 |
| Granite-350M | 718.42 | 14.82 | 48.5 |
| Qwen2-0.5B | 742.18 | 15.24 | 48.7 |
| Llama-3.2-1B | 1,246.34 | 24.68 | 50.5 |
| LFM2-2.6B | 2,482.61 | 38.92 | 63.8 |
| Llama-3.1-8B | 4,218.47 | 62.14 | 67.9 |
| Model | CEI | CEI | Compile (s) |
| GPT-2 (125M) | 1.239 | 1.339 | 1.00 |
| Granite-350M | 0.948 | 0.994 | 1.42 |
| Qwen2-0.5B | 0.776 | 0.815 | 1.68 |
| Llama-3.2-1B | 0.581 | 0.618 | 2.34 |
| LFM2-2.6B | 0.372 | 0.396 | 3.85 |
| Llama-3.1-8B | 0.218 | 0.233 | 6.72 |
| Configuration | Cost Score | vs. Full |
| All Passes | 8.64 | — |
| w/o DCE | 8.69 | +0.6% |
| w/o CSE | 8.64 | +0.0% |
| w/o Constant Folding | 8.64 | +0.0% |
| w/o Device Constant | 8.64 | +0.0% |
| w/o Attention Fusion | 238.34 | +2,658% |
| Model | Layers | w/ Fusion | w/o Fusion | % |
| GPT-2 | 12 | 6.82 | 8.18 | 16.6% |
| Granite-350M | 24 | 9.41 | 12.32 | 23.6% |
| Qwen2-0.5B | 24 | 11.83 | 15.48 | 23.6% |
| Llama-3.2-1B | 16 | 18.24 | 22.71 | 19.7% |
| LFM2-2.6B | 32 | 31.56 | 44.18 | 28.6% |
| Llama-3.1-8B | 32 | 62.48 | 88.72 | 29.6% |
| Model | V-Regs | Phys. | Trans. | |
| GPT-2 | 333 | 218 | 34.5% | 42.1% |
| Granite-350M | 636 | 412 | 35.2% | 48.3% |
| Qwen2-0.5B | 652 | 418 | 35.9% | 49.1% |
| Llama-3.2-1B | 468 | 324 | 30.8% | 44.7% |
| LFM2-2.6B | 834 | 478 | 42.7% | 58.2% |
| Llama-3.1-8B | 896 | 468 | 47.8% | 64.8% |
| Cost Score | Nodes | Fused Ops | |
| 0.0 | 364.87 | 403 | 0 |
| 0.2 | 142.31 | 392 | 4 |
| 0.4 | 58.42 | 378 | 8 |
| 0.6 | 22.18 | 358 | 12 |
| 0.8 | 10.84 | 342 | 18 |
| 1.0 | 8.64 | 333 | 24 |
| Model | Default | Autotuned | % |
| GPT-2 | 8.64 | 8.28 | 4.2% |
| Granite-350M | 14.82 | 13.92 | 6.1% |
| Qwen2-0.5B | 15.24 | 14.18 | 7.0% |
| Llama-3.2-1B | 24.68 | 22.84 | 7.5% |
| LFM2-2.6B | 38.92 | 35.74 | 8.2% |
| Llama-3.1-8B | 62.14 | 56.72 | 8.7% |
| Metric | Mean | Std Dev | CV (%) |
| Compilation Time (ms) | 1,000 | 18.4 | 1.84 |
| Inference Latency (ms) | 6.82 | 0.14 | 2.05 |
| P99 Latency (ms) | 8.12 | 0.19 | 2.34 |
| Node Reduction (%) | 17.4 | 0.0 | 0.00 |
| FGR | 42.3 | 0.82 | 1.94 |
| Mean Latency (ms) | vs. Best Baseline | FORGE-UGC Metrics | ||||||
| Model | FORGE | OV | ONNX | Latency | Compile | FGR | CEI | |
| GPT-2 (125M) | 6.82 | 8.45 | 9.13 | 19.3% | 85.6% | 42.3 | 1.24 | 34.5% |
| Granite-350M | 9.41 | 12.67 | 13.28 | 25.7% | 85.6% | 48.5 | 0.95 | 35.2% |
| Qwen2-0.5B | 11.83 | 15.42 | 16.21 | 23.3% | 85.1% | 48.7 | 0.78 | 35.9% |
| Llama-3.2-1B | 18.24 | 24.81 | 26.37 | 26.5% | 87.4% | 50.5 | 0.58 | 30.8% |
| LFM2-2.6B | 31.56 | 45.23 | 48.14 | 30.2% | 88.0% | 63.8 | 0.37 | 42.7% |
| Model | % | Lat. % | ||
| GPT-2 | 86 | 50 | 41.9% | 4.2% |
| Granite-350M | 168 | 87 | 48.2% | 5.8% |
| Qwen2-0.5B | 174 | 89 | 48.9% | 6.1% |
| Llama-3.2-1B | 126 | 70 | 44.4% | 5.1% |
| LFM2-2.6B | 248 | 104 | 58.1% | 8.4% |
| Llama-3.1-8B | 264 | 93 | 64.8% | 11.2% |
| Model | FORGE | OV | ONNX RT |
| GPT-2 | 1.20 | 1.29 | 1.28 |
| Granite-350M | 1.21 | 1.27 | 1.29 |
| Qwen2-0.5B | 1.20 | 1.27 | 1.27 |
| Llama-3.2-1B | 1.20 | 1.27 | 1.27 |
| LFM2-2.6B | 1.20 | 1.27 | 1.27 |
| Llama-3.1-8B | 1.20 | 1.27 | 1.27 |
| Feature | TVM | XLA | IREE | torch.compile | OpenVINO | ONNX RT | NNAL | FORGE-UGC |
| Direct PyTorch FX input | No | No | No | Yes | No | No | No | Yes |
| No lossy export required | No | Partial | No | Yes | No | No | N/A | Yes |
| Pass-level visibility | Partial | No | Yes | Partial | No | No | N/A | Yes |
| Attention fusion (NPU) | No | Yes | Partial | No | No | No | No | Yes |
| Operator fusion (NPU) | Partial | Yes | Partial | GPU/CPU only | Partial | Partial | No | Yes |
| NPU-aware autotuning | Yes | No | No | No | No | No | No | Yes |
| Metric | WikiText-103 | GLUE | Std Dev |
| vs. OpenVINO | 26.4% | 26.1% | 0.21% |
| vs. ONNX RT | 30.2% | 29.8% | 0.28% |
| Compile Time | 85.6% | 85.6% | 0.00% |
Appendix figures & tables1 asset
Supplementary material from the paper’s appendix.
Appendix
| Model | Run 1 | Run 2 | Run 3 | Mean |
| GPT-2 (125M) | 6.78 | 6.84 | 6.83 | 6.82 |
| Granite-350M | 9.38 | 9.44 | 9.40 | 9.41 |
| Qwen2-0.5B | 11.79 | 11.86 | 11.84 | 11.83 |
| Llama-3.2-1B | 18.19 | 18.28 | 18.24 | 18.24 |
| LFM2-2.6B | 31.48 | 31.62 | 31.57 | 31.56 |
| Llama-3.1-8B | 62.31 | 62.58 | 62.54 | 62.48 |