Repository navigation
Commit 29f02c7
sampling-config: gemma4:26b-ailang variant + opencode option pass-through
Root cause analysis from the 2026-05-23 sampling-collapse incident: opencode
sessions on gemma4:26b were burning 5-15 minutes per call on degenerate
token-repetition loops (single 32k-token argument observed in a write tool
call: "/var/folders/hd68_v_h_y_f_d_v_h_y_f_d_..." repeated 31,814 chars).
Per upstream bug github.com/google-deepmind/gemma#622, this is a known issue
in the gemma4 26b MoE variant with Google's default sampling params
(temperature=1.0, no repetition penalty).
Fix uses a two-layer approach because ollama's /v1/chat/completions endpoint
only honors a subset of sampling options:
Layer 1: tools/ollama/gemma4-26b-ailang.modelfile (NEW)
Bakes in ollama-native params that do NOT pass through /v1:
top_k=64 (Google official for Gemma 4)
repeat_penalty=1.1, repeat_last_n=256
min_p=0.05 (Unsloth safety floor)
num_predict=4096 (hard cap on single-generation output)
Build: ollama create gemma4:26b-ailang -f .../gemma4-26b-ailang.modelfile
Layer 2: ~/.config/opencode/opencode.jsonc (separately committed)
Sets OpenAI-compat names that DO pass through /v1:
temperature=0.5 (Gemma 4 agentic-loop middle ground; lower than
Google's 1.0 default for reliability)
top_p=0.95 (Google official)
frequency_penalty=0.3 (OpenAI-compat counterpart to repeat_penalty)
max_tokens=4096
CRITICAL: provider.ollama.options.name="Ollama" must be set or per-model
options are silently dropped (anomalyco/opencode#971). Easy trap.
models.yml: adds opencode-gemma4-26b-ailang entry pointing at the variant.
Existing opencode-gemma4-26b entry kept as A/B baseline (Google defaults).
Verified live (single-fizzbuzz, 2026-05-23 14:46):
- Determinism check ("What is 2+2?" twice) returned exactly "4" both
times at 15-16s, confirming options pass through (not just dropped)
- No 32k-token repetition loops observed in any opencode.step
- Per-call durations: 1.7s - 1m43s (mostly under 30s), vs 552s monsters
under old config
- Model produced syntactically plausible AILANG (one real scoping bug,
no collapse-into-gibberish behavior)
Remaining separate issue (NOT sampling-related): opencode session hangs
after writing solution.ail in agent mode for both old and new configs.
Tracked separately — not blocked by this commit.
Refs anomalyco/opencode#971, google-deepmind/gemma#622
Co-Authored-By: Claude Opus 4.7 <[email protected]>1 parent f6bbb48 commit 29f02c7
2 files changed
Lines changed: 89 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1038 | 1038 | | |
1039 | 1039 | | |
1040 | 1040 | | |
1041 | | - | |
| 1041 | + | |
1042 | 1042 | | |
1043 | 1043 | | |
1044 | 1044 | | |
| |||
1054 | 1054 | | |
1055 | 1055 | | |
1056 | 1056 | | |
1057 | | - | |
1058 | | - | |
1059 | | - | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
1060 | 1065 | | |
1061 | 1066 | | |
1062 | | - | |
1063 | | - | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
1064 | 1107 | | |
1065 | 1108 | | |
1066 | 1109 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
0 commit comments