ml-explore / ml-explore/mlx-examples
Gemma issues identified by the Unsloth team / impact on mlx code? (shared on our discord as well)
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 9k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Description
posted this in the discord (https://discord.gg/pEPVK6gGfW)
but thanks to the awesome work of the unsloth team, they've identified some bugs in gemma implementations across the ecosystem: https://unsloth.ai/blog/gemma-bugs
i think these are the potential fixes to the mlx-lm examples repo, but would love a second pair of eyes -
token issues:
handle the addition of the token during finetuning
prefix to the input?
RMSNorm:
fp32 at the beginning and result back down at the end to the weight's dtype
set dtype of weight in RMSNorm class to fp32
rope issues:
unsloth guys say it needs to be int32 and not bfloat, but i dont see gemma.py in mlx examples handling it explicitly - maybe not an issue? cant tell. same with "RoPE is sensitive to a*(1/x) vs a/x"
gelu needs to be approx tanh
looking at mlx.nn, looks like it defaults to exact when you dont pass in a param. gemma.py does this:
return self.down_proj(nn.gelu(self.gate_proj(x)) * self.up_proj(x))
which I assume means it's using exact, and needs to pass in 'precise'
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Unsloth Gemma bug report and the Gemma implementation in gemma.py, then inspect mlx.nn behavior for token handling, RMSNorm, RoPE, and GELU. Compare each reported issue with the current implementation and document or implement only the applicable fixes; done means the affected Gemma behaviors match the intended specification.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100