r/MachineLearning • u/Zipidyzip • 3h ago
Project Running CellGemma in llama.cpp: a tokenizer fix and a Q8_0 NaN bug [P]
Yesterday Google Deepmind released CellGemma, a Gemma 4 E4B fine-tune that predicts how human cells respond to drugs, CRISPR knockdowns and cytokines. it adds about 20k gene symbols to the vocab as single tokens and predicts the residual from a mean-shift baseline, then small per-dataset decoders turn the ranked gene list into fold changes.
i wanted to run it locally so I ported it to llama.cpp. a few things broke along the way:
- the converter typed the gene tokens as normal BPE pieces, so MYC got split up instead of staying one token. retyping them as USER_DEFINED fixed it and full prompts now match HF token for token
- Q8_0 gave NaN logits after 20-30 tokens, every single time. bisected it down to ffn_down, keeping just that in bf16 fixes it
- greedy parity vs transformers: BF16 matches 64/64 tokens, Q8_0 matches 47/64 then swaps two neighbouring genes
Anyways, ended up wrapping it in a free open source windows app (Rust/Tauri, no python at runtime). about 4 min per prediction on an RTX 4000 Ada. contributors very welcome, especially for linux/mac builds and AMD testing.
repo: https://github.com/Fazmin/cellgemma-workbench
parity notes: https://github.com/Fazmin/cellgemma-workbench/blob/main/scripts/PARITY.md
1
u/AutoModerator 3h ago
Your post was automatically removed for being a link post on the weekday, please read rule 5. The moderators will not respond to questions regarding this removal unless you suggest which rule you most likely broke. If you have a beginner related question, visit /r/MLQuestions or /r/LearnMachineLearning.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.