Repository navigation
Commit c1daeaa
authored
Fix BF16 vision encoder: keep OneHot values as float32 (#252)
## Summary
ONNX OneHot op does not support bfloat16 for the values tensor. When
building Gemma4 with `--dtype bf16`, the vision encoder fails to load
because `CastLike` casts the OneHot values to bf16 before the op.
## Fix
Keep OneHot values as float32 and cast the output to model dtype
afterward for the subsequent MatMul.
## Testing
- 13 gemma4 tests pass
- BF16 build succeeds: `mobius build --model google/gemma-4-e2b-it
--dtype bf16 --no-weights`
Signed-off-by: Justin Chu <[email protected]>1 parent 798d363 commit c1daeaa
1 file changed
Lines changed: 5 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
445 | 445 | | |
446 | 446 | | |
447 | 447 | | |
| 448 | + | |
448 | 449 | | |
449 | | - | |
450 | | - | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
451 | 454 | | |
452 | 455 | | |
453 | 456 | | |
| |||
0 commit comments