Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelog.d/gemma-qat-exact-mtp-default.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
### Gemma QAT sampled MTP acceptance

- Default `gemma-4-26b-qat-4bit` to exact target-prefix MTP acceptance so sampled reasoning retains the target distribution. Explicit acceptance overrides retain their precedence; paged attention, prefix caching and greedy acceptance are unchanged.
- Full-model quality and performance qualification remain required before release.
5 changes: 4 additions & 1 deletion docs/architecture/inference.md
Original file line number Diff line number Diff line change
Expand Up @@ -2495,7 +2495,10 @@ verification remains available as a diagnostic oracle; drafter-required modes
retain priority (`provider-swift/Sources/ProviderCore/Inference/MTP/EngineV2MTPAssistant.swift`,
`providerMTPVerificationPolicy`).
When neither a global nor a per-model acceptance value is configured, serving
defaults to typical acceptance for eligible sampled target-prefix rows:
uses exact acceptance for `gemma-4-26b-qat-4bit` and the private Bonsai 9B candidate.
Gemma's greedy draft proposals can sustain repetitive reasoning when accepted
by a probability floor; exact acceptance preserves the target distribution.
Other eligible profiles default to typical acceptance for sampled target-prefix rows:
a draft is kept when the sampler-filtered target row gives it probability above
`min(1, 0.2 * exp(-H))`, `H` the row's entropy in nats; the first rejected
position and the bonus position still commit the keyed target sample. Output
Expand Down
8 changes: 5 additions & 3 deletions docs/provider/cli-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -3288,7 +3288,7 @@ override `provider.toml` for one process, are in
| `[backend] engine_v2_kv_checkpoint_quantization` | `"balanced"` | Independent complete-checkpoint encoding request with the same four values. Eligible native paged and contiguous targets encode older attention rows and restore to native state. Unsupported layouts retain native encoding; live-packed targets keep their existing packed format. This does not enable caching, force paging or reduce native memory admission. See [numerical limits and fallback](../architecture/kv-cache-quantization.md#native-execution-with-quantized-checkpoints). On a two-Mac cluster it also sets the pair's SSD prompt-prefix record precision for the pair's public model; both Macs must resolve the same value ([cluster record precision](../reference/configuration.md#cluster-ssd-prefix-record-precision)). |
| `[backend] engine_v2_kv_checkpoint_quantization_by_model` | `{}` | Exact model-ID checkpoint request overrides the global setting; `DARKBLOOM_CBV2_CHECKPOINT_QUANTIZATION` overrides both. MiMo remains native before parsing. |
| `[backend] mtp_mode` | `auto` | Written by `darkbloom beta enable|disable mtp` |
| `[backend] mtp_acceptance` | unset (resolves to `typical`, delta `0.2`) | `exact` / `typical` draft acceptance for eligible sampled target-prefix requests. `typical` keeps a draft when the target's filtered probability for it is above `min(1, 0.2 * exp(-H))` (`H` = the target row's entropy in nats); sampled output is approximate, not distribution-exact. Greedy requests never change. Native MiMo remains exact and does not apply this preference. This setting does not enable disabled MTP or widen eligibility. Parsing ignores case and surrounding whitespace; unknown values warn and resolve to `exact` (`provider-swift/Sources/ProviderCore/Inference/MTP/MTPAcceptancePolicy.swift`, `resolve`) |
| `[backend] mtp_acceptance` | unset (model-specific rule; see [configuration reference](../reference/configuration.md)) | `exact` / `typical` draft acceptance for eligible sampled target-prefix requests. `typical` keeps a draft when the target's filtered probability for it is above `min(1, 0.2 * exp(-H))` (`H` = the target row's entropy in nats); sampled output is approximate, not distribution-exact. Greedy requests never change. Native MiMo remains exact and does not apply this preference. This setting does not enable disabled MTP or widen eligibility. Parsing ignores case and surrounding whitespace; unknown values warn and resolve to `exact` (`provider-swift/Sources/ProviderCore/Inference/MTP/MTPAcceptancePolicy.swift`, `resolve`) |
| `[backend] mtp_acceptance_by_model` | `{}` | Exact model ID to acceptance string; overrides `mtp_acceptance` for that model. An unknown override resolves to `exact`, not the global value. Same eligibility and native MiMo exclusion as above (`MTPAcceptancePolicy.resolve`) |
| `[backend.model_autopilot] enabled` | `false` | Experimental cached-inventory enrollment/consent, not activation; nonempty verified inventory is required, and only a live lease enables residency control (`provider-swift/Sources/ProviderCore/Autopilot/ModelAutopilotSettings.swift`) |
| `[backend.model_autopilot] min_dwell_seconds` | `1800` | Minimum residence before Autopilot replacement; runtime clamps to `60...86400` (`ModelAutopilotSettings.effectiveMinDwellSeconds`) |
Expand All @@ -3312,8 +3312,10 @@ To restore exact acceptance, set `mtp_acceptance = "exact"` under `[backend]`
in `provider.toml` and restart the provider. Per-model entries take precedence:
remove any `"typical"` overrides from `[backend.mtp_acceptance_by_model]`, or
set them to `"exact"` too. To opt out for only one model, set its exact model
ID to `"exact"` in that table. Removing both settings restores the typical
default, not exact acceptance. The benchmark default `--mtp-acceptance exact`
ID to `"exact"` in that table. Removing both settings restores the model-specific
default: the served Gemma QAT model uses exact acceptance. An explicit `"typical"`
override still takes precedence and requires separate quality qualification.
The benchmark default `--mtp-acceptance exact`
is unchanged; see the [benchmark-only environment rule](../reference/configuration.md#engine-and-scheduler).

For foreground/local mixed-prefill tuning, `DARKBLOOM_CBV2_MIXED_PREFILL_CAP`
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ and rollback are defined in the [provider configuration reference](../provider/c

| Config key | Default | Read in | Effect |
|---|---|---|---|
| `[backend] mtp_acceptance`, `mtp_acceptance_by_model` | unset resolves to `typical` (delta `0.2`); model map `{}` | `provider-swift/Sources/ProviderCore/Inference/MTP/MTPAcceptancePolicy.swift` (`resolve`) | Exact model override precedes global, then the built-in default. Eligible sampled target-prefix MTP output is approximate, not distribution-exact; explicit `exact` opts out and invalid values safely resolve to `exact`. Greedy behavior and native MiMo exact acceptance are unchanged. Does not enable disabled MTP or widen eligibility. |
| `[backend] mtp_acceptance`, `mtp_acceptance_by_model` | model map `{}`; unset uses the model-specific rule: `exact` for `gemma-4-26b-qat-4bit` and the private Bonsai 9B candidate, `typical` (delta `0.2`) otherwise | `provider-swift/Sources/ProviderCore/Inference/MTP/MTPAcceptancePolicy.swift` (`resolve`) | Exact model override precedes global, then the built-in default. `typical` sampled target-prefix output is approximate, not distribution-exact; explicit `exact` opts out and invalid values safely resolve to `exact`. Explicit `typical` can override Gemma's exact default and requires separate quality qualification. Greedy behavior and native MiMo exact acceptance are unchanged. Does not enable disabled MTP or widen eligibility. |

| Variable | Values / type | Default | Read in | Effect |
|---|---|---|---|---|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,9 @@ public struct BackendSettings: Sendable, Equatable, Codable {
public var mtpDrafterPath: String?
/// MTP draft acceptance rule for sampled requests (`mtp_acceptance`
/// under `[backend]`): `"exact"` or `"typical"`. nil (default, key
/// absent) means "not set" and resolves to the built-in `typical`.
/// absent) means "not set" and resolves to the model's built-in rule:
/// exact for the served Gemma 4 QAT profile and private Bonsai candidate,
/// typical for the other eligible profiles.
/// Optional on purpose: `TOMLEncoder` writes every non-optional key, and
/// a written default would shadow every lower-precedence source for the
/// life of the file. `typical` keeps a draft when the target's filtered
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import MLXLMCommon
///
/// Precedence: `[backend] mtp_acceptance_by_model` for the exact model id,
/// then `[backend] mtp_acceptance`, then the built-in rule (exact for the
/// private Bonsai 9B candidate, typical for existing profiles). A value that
/// names no known rule is reported and resolves to `exact`, so a typo can
/// never install a lossy rule. The typical threshold is the engine constant
/// served Gemma 4 QAT profile and private Bonsai 9B candidate, typical otherwise).
/// A value that names no known rule is reported and resolves to `exact`, so a
/// typo can never install a lossy rule. The typical threshold is the engine constant
/// `CBv2MTPAcceptance.defaultTypicalDelta`; it is not a production key.
/// Serving reads no environment variable for this rule; the benchmark
/// harness alone honours `DARKBLOOM_MTP_ACCEPTANCE`.
Expand All @@ -35,7 +35,10 @@ public enum MTPAcceptancePolicy {
let raw = byModel[modelID] ?? global
guard let raw else {
return Resolution(
acceptance: Bonsai9BModelPolicy.matchesModelID(modelID) ? .exact
// Typical acceptance can sustain repetitive Gemma reasoning.
// Exact acceptance preserves the target's sampling distribution.
acceptance: modelID == "gemma-4-26b-qat-4bit"
|| Bonsai9BModelPolicy.matchesModelID(modelID) ? .exact
: .typical(delta: CBv2MTPAcceptance.defaultTypicalDelta),
unrecognized: nil)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Testing

@Suite("MTP acceptance config")
struct MTPAcceptanceConfigTests {
@Test("absent keys decode to nil and an empty table, and resolve to typical")
@Test("absent keys decode to nil and an empty table, and Gemma QAT resolves to exact")
func absentKeys() {
let config = ConfigManager.parse(
"""
Expand All @@ -27,10 +27,27 @@ struct MTPAcceptanceConfigTests {
global: config.backend.mtpAcceptance,
byModel: config.backend.mtpAcceptanceByModel,
modelID: "gemma-4-26b-qat-4bit")
#expect(resolved.acceptance == .typical(delta: CBv2MTPAcceptance.defaultTypicalDelta))
#expect(resolved.acceptance == .exact)
#expect(resolved.unrecognized == nil)
}

@Test("Gemma's exact default preserves explicit overrides and other model defaults")
func gemmaDefaultAndOverrides() {
let explicitTypical = MTPAcceptancePolicy.resolve(
global: "typical", byModel: [:], modelID: "gemma-4-26b-qat-4bit")
#expect(explicitTypical.acceptance == .typical(delta: CBv2MTPAcceptance.defaultTypicalDelta))
#expect(explicitTypical.unrecognized == nil)

let modelTypical = MTPAcceptancePolicy.resolve(
global: "exact", byModel: ["gemma-4-26b-qat-4bit": "typical"],
modelID: "gemma-4-26b-qat-4bit")
#expect(modelTypical.acceptance == .typical(delta: CBv2MTPAcceptance.defaultTypicalDelta))

let other = MTPAcceptancePolicy.resolve(
global: nil, byModel: [:], modelID: "qwen3.8-flash-next")
#expect(other.acceptance == .typical(delta: CBv2MTPAcceptance.defaultTypicalDelta))
}

@Test("keys decode and the per-model table outranks the global value")
func precedence() {
let config = ConfigManager.parse(
Expand Down
Loading