Commit fcbd88f
fix: add transformer. prefix in GPT-2 and Falcon/Bloom preprocess_weights (#113)
## Problem
HF safetensors for GPT-2 and Bloom store layer weights **without** the
outer `transformer.` prefix (e.g. `h.N.*`, `wte.*`, `ln_f.*`,
`word_embeddings.*`). Our ONNX initialisers include it because the outer
module attribute is `self.transformer`. As a result,
`preprocess_weights()` produced keys that never matched any ONNX
initialiser — every weight was left unloaded, and ORT rejected the model
with `Node input 'transformer.wte.weight' is not a graph input,
initializer, or output of a previous node.`
## Root Cause
- **GPT-2 / OpenAI-GPT / GPT-SW3**: safetensors keys are `h.N.attn.*`,
`wte.*`, `wpe.*`, `ln_f.*` (no prefix). GPT-Neo and GPT-BigCode already
include `transformer.`.
- **Bloom**: safetensors keys are `h.N.*`, `word_embeddings.*`, `ln_f.*`
(no prefix).
## Fix
- **`gpt2.py`**: in step 1 of the weight-normalisation loop, add
`transformer.` for plain GPT-2/GPT-SW3 keys (biogpt.\*, model.\*,
output_projection.\* and lm_head.\* are handled separately).
- **`falcon.py`**: after the Falcon/Bloom QKV-split and rename loop,
re-key entries that lack the `transformer.` or `lm_head.` prefix.
## Testing
Golden tests confirmed passing after the fix:
```
tests/e2e_golden_test.py::TestL4CheckpointVerified::test_prefill_argmax_matches_golden[text-generation/gpt2] PASSED
tests/e2e_golden_test.py::TestL4CheckpointVerified::test_prefill_argmax_matches_golden[text-generation/bloom-560m] PASSED
```
Also removes now-stale xfail/skip marks from `integration_test.py`:
- gpt2 xfail `tie_word_embeddings graph reference issue in ORT`
- bloom-560m skip `word_embeddings_layernorm not implemented`
All 2277 unit tests pass. Lintrunner clean.
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 04c8e62 commit fcbd88f
3 files changed
Lines changed: 18 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
577 | 577 | | |
578 | 578 | | |
579 | 579 | | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
580 | 589 | | |
581 | 590 | | |
582 | 591 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
126 | 135 | | |
127 | 136 | | |
128 | 137 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | 100 | | |
104 | 101 | | |
105 | 102 | | |
| |||
113 | 110 | | |
114 | 111 | | |
115 | 112 | | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | 113 | | |
121 | 114 | | |
122 | 115 | | |
| |||
0 commit comments