Skip to content
Merged
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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

## Unreleased - typical MTP acceptance

- Add per-model typical MTP draft acceptance for sampled requests (`[backend] mtp_acceptance`, `mtp_acceptance_by_model`; default `exact`), ported from mlx-serve PR #427. Greedy requests are unchanged; slot posture telemetry reports `mtp_acceptance`.
- Default eligible sampled target-prefix MTP requests to typical acceptance (delta `0.2`) when `[backend] mtp_acceptance` and the model override are absent. Sampled output is approximate, not distribution-exact; explicit `exact` restores exact acceptance and invalid values remain safely exact. Greedy behavior, native MiMo exact acceptance, disabled MTP and model eligibility are unchanged. Benchmark acceptance still defaults to `exact`; the recorded single-host B=1 runs do not qualify sampled quality or fleet-wide speed.
- Add per-model typical MTP draft acceptance for sampled requests (`[backend] mtp_acceptance`, `mtp_acceptance_by_model`), ported from mlx-serve PR #427. Greedy requests are unchanged; slot posture telemetry reports `mtp_acceptance`.
- Pin the merged SDK implementation from `mlx-swift-lm` main; its file tree matches the engine revision used in the recorded acceptance benchmarks.

## 0.9.18 - prepared candidate (not published)
Expand Down
21 changes: 15 additions & 6 deletions docs/architecture/inference.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Provider inference engine

> Last updated: 2026-10-06
> Last updated: 2026-10-07

How a chat-completion request is served inside the `darkbloom` provider
process: one in-process engine (`mlx-swift-lm`
Expand Down Expand Up @@ -430,17 +430,26 @@ constraints retain their ordinary-decode exclusions. Explicit offline serial
verification remains available as a diagnostic oracle; drafter-required modes
retain priority (`provider-swift/Sources/ProviderCore/Inference/MTP/EngineV2MTPAssistant.swift`,
`providerMTPVerificationPolicy`).
`[backend] mtp_acceptance = "typical"`, or the `mtp_acceptance_by_model`
table, installs typical acceptance for eligible sampled target-prefix rows of
that model: a draft is kept when the sampler-filtered target row gives it probability above
When neither a global nor a per-model acceptance value is configured, serving
defaults to typical acceptance for eligible 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
is then not distribution-exact for the target. Greedy rows keep the exact
walk, and the default is `exact` (`MTPAcceptancePolicy.resolve`;
is approximate, not distribution-exact for the target. Greedy rows keep the exact
walk. Explicit `"exact"` opts out; invalid values warn and safely resolve to
exact, including an invalid per-model override rather than falling back to the
global value (`MTPAcceptancePolicy.resolve`;
`CBv2MTPAcceptance` in
`libs/mlx-swift-lm/Libraries/MLXLMCommon/ContinuousBatchingV2/MTP/MTPContractsV2.swift`;
`mtp_acceptance` in slot posture telemetry). Design record:
[`../design/typical-mtp-acceptance.md`](../design/typical-mtp-acceptance.md).
Comment thread
Gajesh2007 marked this conversation as resolved.
Resolved
Configuration precedence and exact rollback are in the
[CLI reference](../provider/cli-reference.md#providertoml-keys-read-by-the-cli).
The benchmark session and default `--mtp-acceptance exact` are unchanged
(`provider-swift/Sources/ProviderBenchmark/MTPProductionSession.swift`). The
[recorded benchmarks](../reports/2026-10-07-typical-mtp-acceptance-benchmarks.md)
cover only single-host B=1 runs; they do not qualify sampled-output quality or
fleet-wide speed.
Native MiMo remains exact: its separately owned slot construction does not
apply this preference, so `typical` is unsupported on that path
(`provider-swift/Sources/ProviderCore/Inference/Engine/Factory/EngineV2SlotFactory+Native.swift`,
Expand Down
12 changes: 10 additions & 2 deletions docs/provider/cli-reference.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Provider CLI reference

> Last updated: 2026-10-06
> Last updated: 2026-10-07

Reference for the `darkbloom` command-line tool: every subcommand and flag, the
files and identifiers it creates, the `provider.toml` keys it reads with their
Expand Down Expand Up @@ -1350,7 +1350,7 @@ override `provider.toml` for one process, are in
| `[backend] engine_v2_max_concurrent_by_model` | `{}` | Exact model ID → operator cap; overrides the default for that model under the same qualification, architecture and memory bounds. `status` and `doctor` show the default policy and all configured model overrides, with unknown-profile bounds when different from the requested cap (`provider-swift/Sources/ProviderCore/Inference/Performance/ServingPerformanceProfile.swift`, `ServingPerformanceProfiles.summary`) |
| `[backend] engine_v2_kv_backend` | `"auto"` | `auto` / `paged` / `contiguous`; per-model table `engine_v2_kv_backend_by_model` takes precedence. Candidate `auto` tries paged only for the [exact qualified-artifact allowlist](../architecture/prefix-cache.md#kv-layouts), with contiguous fallback; all other IDs remain contiguous (`EngineV2KVBackendPolicy.parseSelection`, `preferredBackend`) |
| `[backend] mtp_mode` | `auto` | Written by `darkbloom beta enable|disable mtp` |
| `[backend] mtp_acceptance` | unset (resolves to `exact`) | `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); output is then not distribution-exact. Greedy requests never change. Native MiMo remains exact and does not apply this preference. 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 (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_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 @@ -1363,6 +1363,14 @@ override `provider.toml` for one process, are in
| `config_version` | retired | Ignored top-level key left by releases up to v0.9.9; no longer written |
| `[backend] continuous_batching`, `adaptive_prefill`, `engine_v2`, `legacy_compiled_decode`, `kv_quant`, `mtp` | retired | Parsed for presence only; one startup WARN each (`RetiredCodingKeys`). The boolean `mtp` is superseded by `mtp_mode` |

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`
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`
sets a process-wide token cap and `DARKBLOOM_CBV2_MIXED_PREFILL_CAP_BY_MODEL`
accepts comma-separated exact overrides such as `gemma-4-26b-qat-4bit=128,gpt-oss-20b=256`.
Expand Down
9 changes: 8 additions & 1 deletion docs/reference/configuration.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Configuration reference

> Last updated: 2026-10-06
> Last updated: 2026-10-07

Every environment variable read by the coordinator, the provider CLI
(`darkbloom`), console-ui and admin-ui: accepted values, the compiled default,
Expand Down Expand Up @@ -675,6 +675,13 @@ provider or model command is running. Code:

### Engine and scheduler

Serving acceptance is config-backed, not an environment override. Its default
and rollback are defined in the [provider configuration reference](../provider/cli-reference.md#providertoml-keys-read-by-the-cli).

| 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. |

| Variable | Values / type | Default | Read in | Effect |
|---|---|---|---|---|
| `DARKBLOOM_CBV2_PAGED_KV` | `0` forces contiguous | unset (policy decides) | `provider-swift/Sources/ProviderCore/Inference/Engine/EngineV2KVBackendPolicy.swift` (`preferredBackend`, `killSwitchDisabled`) | Kill switch for paged KV; beats the `provider.toml` setting. The [owned Flash-Next candidate](qwen4-next-support.md#identity-and-serving-policy) joins the exact automatic policy; a default is not runtime qualification. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ 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 `exact`.
/// absent) means "not set" and resolves to the built-in `typical`.
/// 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 @@ -5,7 +5,7 @@ import MLXLMCommon
/// provider configuration.
///
/// Precedence: `[backend] mtp_acceptance_by_model` for the exact model id,
/// then `[backend] mtp_acceptance`, then the built-in `exact`. A value that
/// then `[backend] mtp_acceptance`, then the built-in `typical`. 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.
Expand All @@ -32,7 +32,11 @@ public enum MTPAcceptancePolicy {
global: String?, byModel: [String: String], modelID: String
) -> Resolution {
let raw = byModel[modelID] ?? global
guard let raw else { return Resolution(acceptance: .exact, unrecognized: nil) }
guard let raw else {
return Resolution(
acceptance: .typical(delta: CBv2MTPAcceptance.defaultTypicalDelta),
unrecognized: nil)
}
guard let parsed = parse(raw) else {
return Resolution(acceptance: .exact, unrecognized: raw)
}
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 exact")
@Test("absent keys decode to nil and an empty table, and resolve to typical")
func absentKeys() {
let config = ConfigManager.parse(
"""
Expand All @@ -27,7 +27,7 @@ struct MTPAcceptanceConfigTests {
global: config.backend.mtpAcceptance,
byModel: config.backend.mtpAcceptanceByModel,
modelID: "gemma-4-26b-qat-4bit")
#expect(resolved.acceptance == .exact)
#expect(resolved.acceptance == .typical(delta: CBv2MTPAcceptance.defaultTypicalDelta))
#expect(resolved.unrecognized == nil)
}

Expand Down Expand Up @@ -61,6 +61,22 @@ struct MTPAcceptanceConfigTests {
#expect(other.unrecognized == nil)
}

@Test("explicit exact settings opt out of the typical default")
func exactOptOut() {
let global = MTPAcceptancePolicy.resolve(global: "exact", byModel: [:], modelID: "m")
#expect(global.acceptance == .exact)
#expect(global.unrecognized == nil)

let perModel = MTPAcceptancePolicy.resolve(
global: nil, byModel: ["m": "exact"], modelID: "m")
#expect(perModel.acceptance == .exact)
#expect(perModel.unrecognized == nil)

let other = MTPAcceptancePolicy.resolve(
global: nil, byModel: ["m": "exact"], modelID: "other")
#expect(other.acceptance == .typical(delta: CBv2MTPAcceptance.defaultTypicalDelta))
}

@Test("an unknown value resolves to exact and is reported")
func unknownValue() {
let resolved = MTPAcceptancePolicy.resolve(
Expand Down
Loading