File size: 5,831 Bytes
77d19a8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
---
license: apache-2.0
base_model: ibm-granite/granite-speech-4.1-2b-nar
library_name: onnx
pipeline_tag: automatic-speech-recognition
language:
  - en
  - fr
  - de
  - es
  - pt
tags:
  - automatic-speech-recognition
  - granite-speech
  - onnx
  - onnxruntime
  - directml
  - cpu
  - int4
  - matmulnbits
  - taurscribe
---

# Granite Speech 4.1 2B NAR Portable INT4 for Taurscribe

This repository contains a portable ONNX Runtime artifact derived from IBM's
[Granite Speech 4.1 2B NAR](https://huggingface.co/ibm-granite/granite-speech-4.1-2b-nar)
model for local transcription in Taurscribe.

It is designed for Windows systems without an NVIDIA CUDA GPU. It supports:

- full GPU inference through ONNX Runtime DirectML on compatible AMD, Intel,
  and NVIDIA DirectX 12 GPUs;
- multi-threaded ONNX Runtime CPU inference as a portable fallback.

This is not a newly trained or fine-tuned model. The learned Granite weights,
tokenizer, vocabulary, and supported languages are inherited from IBM's base
model. Taurscribe changed the ONNX representation and host runtime path.

> This is a multi-graph Taurscribe runtime bundle, not a single-file
> Transformers replacement. Correct inference requires Taurscribe's feature
> extraction, CTC, projection, edit-slot, and tokenizer pipeline.

## What Changed

The portable artifact builds on Taurscribe's INT4/token-ID Granite bundle:

1. Selected large `MatMul` weights use INT4 weight-only quantization through
   ONNX `MatMulNBits`.
2. `editor.onnx` performs `ArgMax` in the graph and returns `token_ids` instead
   of transferring the full sequence-by-vocabulary logits tensor to Rust.
3. Thirty-two rank-5 windowed-attention `MatMul` operations in `encoder.onnx`
   are reshaped to equivalent rank-3 batched operations supported by DirectML.
4. Runtime shape chains are evaluated for Taurscribe's fixed `[1, 800, 160]`
   encoder bucket, stored as constants, and approximately 950 dead shape nodes
   are removed.
5. Sixteen two-output GLU `Split` operations are replaced with equivalent
   `Slice` pairs to avoid incorrect output inside DirectML fused partitions.

Only `encoder.onnx` receives the DirectML compatibility rewrites. The
projector, token embedding graph, editor, tokenizer, and model weights are
copied from the INT4/token-ID parent artifact.

## Runtime Placement

Full DirectML:

```text
encoder.onnx      -> DirectML
projector.onnx    -> DirectML
embed_tokens.onnx -> DirectML
editor.onnx       -> DirectML
```

CPU fallback:

```text
encoder.onnx      -> CPU
projector.onnx    -> CPU
embed_tokens.onnx -> CPU
editor.onnx       -> CPU
```

The ONNX files do not select a GPU vendor. Taurscribe's Rust code asks ONNX
Runtime to create DirectML or CPU sessions. See
`taurscribe_granite_nar_manifest.json` for the graph contract.

## Validation

The conversion script compares every rewritten encoder output against the
source encoder on CPU and aborts if the worst relative difference exceeds
`1e-3`. The produced artifact measured a worst relative difference of about
`4.4e-5`. DirectML encoder BPE argmax agreement with CPU was `1.0000` on the
validated input.

The following end-to-end Taurscribe results use the same 30 utterances from
LibriSpeech `test-clean` (mean processed duration: 8.47 seconds):

| Route | Hardware | Mean latency | Mean RTF | Mean WER |
|---|---|---:|---:|---:|
| CUDA reference artifact | RTX 4070 Laptop | 0.250 s | 0.040 | 4.31% |
| **This artifact, full DirectML** | **Radeon 780M** | **4.045 s** | **0.643** | **4.31%** |
| **This artifact, CPU (8 threads)** | **Ryzen 7 8845HS** | **8.823 s** | **1.415** | **4.31%** |
| Historical hybrid baseline | 1-thread CPU encoder + DirectML | 13.135 s | 2.194 | 4.31% |

These are limited local validation results, not a replacement for the base
model's full published evaluation. See `BENCHMARKS.md` for methodology and tail
latency.

## Hardware Compatibility

- **AMD Radeon 780M DirectML:** validated end to end with CPU fallback disabled.
- **NVIDIA DirectML:** graph-level compatibility validated; use the separate
  CUDA artifact for substantially better NVIDIA performance.
- **Intel DirectML:** expected to work on DirectX 12 hardware but not yet
  validated with this exact artifact.
- **x86-64 CPU:** supported through ONNX Runtime CPU; actual speed depends
  heavily on memory bandwidth and thread count.

DirectML requires Windows and a DirectX 12-compatible GPU. A GPU driver or
execution-provider failure should be handled by the host application with CPU
fallback. For production hardware certification, run the DirectML probe in a
separate helper process so a native driver crash cannot terminate the app.

## Taurscribe Selection

Taurscribe model ID:

```text
granite-speech-4.1-2b-nar-portable
```

Development overrides:

```powershell
$env:TAURSCRIBE_GRANITE_BACKEND = "directml"
$env:TAURSCRIBE_GRANITE_DML_DEVICE_ID = "0"
$env:TAURSCRIBE_GRANITE_BACKEND = "cpu"
$env:TAURSCRIBE_GRANITE_CPU_THREADS = "8"
```

The DirectML device ID follows DXGI adapter order and is machine-specific.

## Files

```text
encoder.onnx
encoder.onnx.data
projector.onnx
projector.onnx.data
embed_tokens.onnx
editor.onnx
editor.onnx.data
tokenizer.json
tokenizer_config.json
preprocessor_config.json
processor_config.json
generation_config.json
taurscribe_granite_nar_manifest.json
manifest.json
BENCHMARKS.md
NOTICE
LICENSE
```

`manifest.json` records artifact metadata, exact file sizes, and SHA-256
checksums for the runtime payload.

## Source and Attribution

- Base model: [ibm-granite/granite-speech-4.1-2b-nar](https://huggingface.co/ibm-granite/granite-speech-4.1-2b-nar)
- Original provider: IBM Granite Team
- Original license: Apache License 2.0
- ONNX optimization and packaging: Taurscribe project

No additional training or fine-tuning was performed by Taurscribe.