Repository navigation
Commit 3ce0444
authored
Fix L4/L5 e2e harness for Gemma4 per_layer_inputs + BOOL audio mask (#318)
## Problem
L4 / L5 e2e tests have been failing on `main` for every Gemma4 case
since
#296 (Move Gemma4 per-layer embeddings to embedding model). Two distinct
root causes:
### 1. `per_layer_inputs` missing from decoder feed
After #296 the embedding sub-model emits a second output
`per_layer_inputs` and the decoder accepts it as a required input. The
e2e harness only wired the first embedding output (`inputs_embeds`)
into the decoder, so every multi-model Gemma4 path failed with:
```
ValueError: Required inputs (['per_layer_inputs']) are missing from input feed
(['inputs_embeds', 'past_key_values.0.key', ..., 'attention_mask', 'position_ids'])
```
Affected: text-only on multi-model (`text-generation/gemma-4-e2b`),
VL prefill (`image-text-to-text/gemma-4-e2b-it`, `…-e4b-it`), VL
generation (L5), speech-language prefill+generation.
### 2. `input_features_mask` dtype mismatch
The Gemma4 audio encoder (`_gemma4.py:367`) declares
`input_features_mask` as `tensor(bool)`, but the harness unconditionally
cast every feature-extractor output to `np.float32`, producing:
```
InvalidArgument: Unexpected input data type. Actual: (tensor(float)), expected: (tensor(bool))
```
Even when the fallback all-True mask path was taken (line 1267), the
bool numpy array crashed `ort_easy`'s DLPack-first conversion path
because DLPack has no native bool type code.
## Fix
### `tests/e2e_golden_test.py`
In every decoder-feed setup (5 sites: text-only multi-model prefill,
VL prefill, VL generation, speech-language prefill, speech-language
generation), wire any extra embedding outputs through to the decoder by
name. For models without `per_layer_inputs` the extra loop iteration is
a no-op:
```python
elif name in emb_out:
dec_feeds[name] = emb_out[name]
```
For both audio-encoder setup sites (L4 + L5 paths), honor the session's
declared input dtype:
```python
target_dtype = audio_session.get_input_dtype(name) or np.float32
audio_feeds[name] = audio_processed[name].astype(target_dtype)
```
And use the session-declared dtype for the fallback all-True mask too.
### `src/mobius/_testing/ort_inference.py`
Route bool numpy arrays through `OrtValue.ortvalue_from_numpy` directly
in `_numpy_to_ort_value`, bypassing `ort_easy`'s DLPack-first path
(which has no bool type code).
## Verification (locally on H200)
| Test | Before | After |
|---|---|---|
| L4 `text-generation/gemma-4-e2b` | FAIL (missing per_layer_inputs) |
**PASS** |
| L4 `image-text-to-text/gemma-4-e2b-it` | FAIL (missing
per_layer_inputs) | **PASS** |
| L4 `speech-language/gemma-4-e2b-it-audio` | FAIL (bool dtype mismatch)
| **PASS** |
| L5 `image-text-to-text/gemma-4-e2b-it` | FAIL | **PASS** |
| L5 `speech-language/gemma-4-e2b-it-audio` | FAIL | **PASS** |
5 passed, 1 skipped (L5 text-gen is gated by integration markers under
fast runs), 0 failed. `ruff check` + `ruff format --check` both pass.
L1 + L3 + non-gemma e2e suites are unaffected (the embedding-output
loop is a generic no-op for models that don't emit extra outputs;
audio-mask changes only trigger when the session declares a bool input).
## Why this didn't get caught earlier
The CI matrix only runs L4 / L5 in the affected-models lane, and #296
was tested standalone before this lane started exercising the multi-
model Gemma4 path through the e2e harness. The bool-mask issue is even
older — it was masked by the harness's unconditional
`astype(np.float32)`
until the audio_encoder was upgraded to take a real BOOL mask.
Signed-off-by: justinchuby <[email protected]>
Co-authored-by: justinchuby <[email protected]>1 parent 32cbe86 commit 3ce0444
2 files changed
Lines changed: 61 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
| 69 | + | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
73 | | - | |
74 | | - | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
75 | 75 | | |
76 | 76 | | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
77 | 81 | | |
78 | 82 | | |
79 | 83 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
666 | 666 | | |
667 | 667 | | |
668 | 668 | | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
669 | 673 | | |
670 | 674 | | |
671 | 675 | | |
| |||
862 | 866 | | |
863 | 867 | | |
864 | 868 | | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
865 | 875 | | |
866 | 876 | | |
867 | 877 | | |
| |||
918 | 928 | | |
919 | 929 | | |
920 | 930 | | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
921 | 937 | | |
922 | 938 | | |
923 | 939 | | |
| |||
1069 | 1085 | | |
1070 | 1086 | | |
1071 | 1087 | | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
1072 | 1093 | | |
1073 | 1094 | | |
1074 | 1095 | | |
| |||
1200 | 1221 | | |
1201 | 1222 | | |
1202 | 1223 | | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
1203 | 1229 | | |
1204 | 1230 | | |
1205 | 1231 | | |
| |||
1252 | 1278 | | |
1253 | 1279 | | |
1254 | 1280 | | |
1255 | | - | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
1256 | 1286 | | |
1257 | 1287 | | |
1258 | 1288 | | |
| |||
1264 | 1294 | | |
1265 | 1295 | | |
1266 | 1296 | | |
1267 | | - | |
| 1297 | + | |
| 1298 | + | |
1268 | 1299 | | |
1269 | 1300 | | |
1270 | 1301 | | |
| |||
1352 | 1383 | | |
1353 | 1384 | | |
1354 | 1385 | | |
| 1386 | + | |
| 1387 | + | |
| 1388 | + | |
| 1389 | + | |
1355 | 1390 | | |
1356 | 1391 | | |
1357 | 1392 | | |
| |||
1701 | 1736 | | |
1702 | 1737 | | |
1703 | 1738 | | |
1704 | | - | |
| 1739 | + | |
| 1740 | + | |
1705 | 1741 | | |
1706 | 1742 | | |
1707 | 1743 | | |
| |||
1713 | 1749 | | |
1714 | 1750 | | |
1715 | 1751 | | |
1716 | | - | |
| 1752 | + | |
| 1753 | + | |
1717 | 1754 | | |
1718 | 1755 | | |
1719 | 1756 | | |
| |||
1798 | 1835 | | |
1799 | 1836 | | |
1800 | 1837 | | |
| 1838 | + | |
| 1839 | + | |
| 1840 | + | |
| 1841 | + | |
| 1842 | + | |
| 1843 | + | |
1801 | 1844 | | |
1802 | 1845 | | |
1803 | 1846 | | |
| |||
1841 | 1884 | | |
1842 | 1885 | | |
1843 | 1886 | | |
| 1887 | + | |
| 1888 | + | |
| 1889 | + | |
| 1890 | + | |
| 1891 | + | |
| 1892 | + | |
1844 | 1893 | | |
1845 | 1894 | | |
1846 | 1895 | | |
| |||
0 commit comments