Commit 9db9a3a
Fix BGE-small export compatibility (#263)
* Fix BGE-small export compatibility
The documented BGE flow (scripts/download_bge_small_en_v1_5.py + the bge
examples) is broken on a fresh download: current optimum exports produce a
graph the tracer rejects at load with 'Unimplemented ONNX operator: Sqrt'.
Root causes (export drift):
- Fused LayerNormalization (opset >= 17) decomposes under tract into
Div(x, Sqrt(var+eps)); tract only re-fuses Recip(Sqrt(.)) into Rsqrt (see
declutter_recip), and the tracer has an Rsqrt handler but no Sqrt handler.
- The export now has two graph outputs (token_embeddings, sentence_embedding);
the prover seeds an opening only for outputs()[0] (prover.rs output_claim),
so the second output is never opened (EvalReduction EmptyInput).
- The export takes two inputs now (token_type_ids dropped), so the examples'
three-input call panics with an out-of-bounds index at execution.
Fix, in the download script's normalize_graph():
- Pin --opset 14 (keeps LayerNorm decomposed) and rewrite
Div(x, Sqrt(v)) -> Mul(x, Reciprocal(Sqrt(v))) so tract fuses to Rsqrt.
- Keep token_embeddings (the encoder's last hidden state) as the sole output
and dead-node eliminate the pooling / L2-norm subgraph that only fed
sentence_embedding. Pooling + normalization are a cheap public post-step.
- Update bge.rs / bge_generate.rs to the two-input signature.
Verified: scripts/download + 'cargo run -p jolt-atlas-core --example bge'
loads, traces, proves, and verifies end to end.
Note: keeping the full model's sentence_embedding output instead hits a
separate degenerate-instance panic in the Shout lookup prover (scalar Rsqrt
over the single pooled element -> RaPolynomial stuck in Round1 ->
final_claim); filed separately.
* Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Khalil Gibran Hassam <59589957+Forpee@users.noreply.github.com>1 parent f521423 commit 9db9a3a
3 files changed
Lines changed: 85 additions & 8 deletions
File tree
- atlas-onnx-tracer/examples
- jolt-atlas-core/examples
- scripts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | | - | |
| 16 | + | |
18 | 17 | | |
19 | 18 | | |
20 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
| 49 | + | |
54 | 50 | | |
55 | 51 | | |
56 | 52 | | |
| |||
61 | 57 | | |
62 | 58 | | |
63 | 59 | | |
64 | | - | |
| 60 | + | |
65 | 61 | | |
66 | 62 | | |
67 | 63 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
| 47 | + | |
46 | 48 | | |
47 | 49 | | |
48 | 50 | | |
| |||
53 | 55 | | |
54 | 56 | | |
55 | 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 | + | |
56 | 137 | | |
57 | 138 | | |
58 | 139 | | |
| |||
70 | 151 | | |
71 | 152 | | |
72 | 153 | | |
| 154 | + | |
73 | 155 | | |
74 | 156 | | |
75 | 157 | | |
| |||
0 commit comments