Turn on speculative decoding for Gemma 4
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- Half a day
- Newbie friendliness
- 55/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Active
- Domain
- machine-learning, mobile-dev
Research direction
First check the Gemma 4 E2B load log and compare the generation chunks/sec with speculative decoding on and off on a real Android phone; the issue says to do this before coding. Then read lib/data/datasources/llm/flutter_gemma_gateway.dart, lib/data/datasources/llm/local_model_params.dart, and the AIModelRunner and lib/features/shiv/gana/engine/gana_workmanager.dart entry points. Done means speculative decoding is enabled for Gemma 4 only, tests cover other models remaining off or unset, and the measured result supports enabling it; this depends on #216.
Written by the indexing model from the issue text.
Description
What
Turn on speculative decoding for the Gemma 4 E2B and E4B models.
What is speculative decoding (simple version)
A small, fast "draft" model guesses the next few words, and the big model checks them in one step. When the guesses are right, you get several words for the price of one, so answers come out faster.
Why
Google's model cards show a big speedup on an S26 Ultra GPU:
| Model | Without | With |
|---|---|---|
| Gemma 4 E2B | 51.5 tokens/sec | 66–92 tokens/sec |
| Gemma 4 E4B | 21.9 tokens/sec | 37–49 tokens/sec |
Things to know first
- It speeds up writing the answer, not reading the prompt. Short outputs (Nataraj cards, translations) will gain less than the numbers above.
- Only Gemma 4 supports it. Not Qwen3, not DeepSeek R1.
- Today we never pass the setting, so the plugin uses whatever the model file defaults to. It may already be on, or off — we don't know yet.
- Model files downloaded before May 5, 2026 don't have the draft model. They just ignore the setting — no crash, just no speedup. So no special handling is needed.
Step 1 — measure (do this first)
- Load Gemma 4 E2B on a real Android phone and check the log. The engine prints
enable_speculative_decoding: trueorfalsewhen it loads. If it's alreadytrue, we may be done. - Run the same prompt with it on and off and compare the
generation total ... chunks/seclog line.
Step 2 — code (if it helps)
- Add an
enableSpeculativeDecodingoption toFlutterGemmaGateway.getActiveModel(lib/data/datasources/llm/flutter_gemma_gateway.dart) - Turn it on for Gemma 4 only (a flag in
lib/data/datasources/llm/local_model_params.dart) - Pass it in
AIModelRunnerand in the background Gana path, which callsFlutterGemma.getActiveModeldirectly (lib/features/shiv/gana/engine/gana_workmanager.dart) - Tests for "on for Gemma 4, off/unset for other models"
Estimate: about half a day — 2–3 hours of code, ~1 hour measuring on a phone (plus the ~2.6 GB download if Gemma 4 isn't installed).
Depends on #216 (flutter_gemma 1.8.3 + GPU on Android).
- Dominant language
- Dart
- Stars
- 2
- Forks
- 2
- Avg merge
- 1d 35m
- Merged PRs (30d)
- 36
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing 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.
More from basictech01/uniun
-
bug good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
basictech01/uniun#300 ·
Maintainers usually reply within 1 day
-
bug good first issue
Difficulty 3/5 1-2 days Newbie friendliness 52/100
basictech01/uniun#301 ·
Maintainers usually reply within 1 day
-
enhancement good first issue P2-Medium
Difficulty 5/5 Over a week Newbie friendliness 25/100
basictech01/uniun#296 ·
Maintainers usually reply within 1 day
-
bug good first issue P2-Medium
Difficulty 4/5 1-2 days Newbie friendliness 22/100
basictech01/uniun#293 ·
Maintainers usually reply within 1 day
-
bug P1-High
Difficulty 4/5 3-5 days Newbie friendliness 18/100
basictech01/uniun#286 · 2 comments ·
Maintainers usually reply within 1 day
All issues in basictech01/uniun
Similar issues
-
good-first-issue P3
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
flutter/dart-intellij-third-party#758 ·
Maintainers usually reply within 1 day
-
Bug: Incorrect location coordinates on logged Sound Meter dataPossibly taken @Jashan32 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
area/archive bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
DarkFlippers/qUnleashed#374 ·
Maintainers usually reply within 1 day
-
agent:in-progress agent:ready feature P2 · 中 区域: 悬浮窗
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
ASDW51/DanmuFloat#178 ·
Maintainers usually reply within 1 day
-
Missing workoutsOpenenhancement
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
InlitX/GymMane#237 · 1 comment ·
Maintainers usually reply within 5 days