Skip to content

Latest commit

 

History

History
67 lines (52 loc) · 18.9 KB

inkling2-mini-support.md

File metadata and controls

67 lines (52 loc) · 18.9 KB

Inkling 2 Mini provider contract reference

Last updated: 2026-11-25

Reference for the provider's side of Thinking Machines' Inkling 2 Mini (inkling2_loop): identity, prompt, output, cache and drafter contracts read from the pinned checkpoint thinkingmachines/Inkling-2-Mini at 6e7c8248f75265bdd4fbab5273304243b5d8c2cb. The native model lives in the SDK (Inkling2Model, and the Inkling2VLM wrapper with its vision tower); nothing here publishes a model, approves a catalog entry or qualifies hardware.

Identity and serving policy

Concern Contract Source
Architecture Exact root model_type inkling2_loop with a text_config of type inkling2_loop_text whose loop and attention geometry yields a cache layout. Other spellings and Inkling 2 Small (inkling2) are not this architecture provider-swift/Sources/ProviderCoreFoundation/Inkling2ModelIdentity.swift (isNativeType, declaresNativeTextTower)
Context window 524,288 tokens of prompt plus output, half the checkpoint's model_max_length of 1,048,576: the largest window measured to serve with the DSpark drafter on. An output that would pass the window is cut to what the prompt leaves, and a prompt of 524,288 tokens or more is refused as a context error (HTTP 400 context_length_exceeded) before it reaches the engine. The DSpark drafter's per-request pool is granted what the paged pool's segments charge (SDK PagedState); a pool that cannot be reserved is refused as retryable capacity (503), not an untyped 500 provider-swift/Sources/ProviderCore/Inference/Memory/KVEstimation.swift (parseModelArchitecture); provider-swift/Sources/ProviderCoreFoundation/Inkling2ModelIdentity.swift (servedContextTokens); provider-swift/Sources/ProviderCore/Inference/Engine/Scheduler/MultiModelBatchSchedulerEngineError.swift (fromSchedulerMessage)
Served identities The upstream download id receives the serving defaults; a catalog listing id joins servedModelIDs when the catalog registers one Inkling2ModelIdentity.swift (servedModelIDs, isServedModelID)
Media Still images through the checkpoint's own tower (vision_config.model_type inkling2_vision, language_model_only not true). The model takes no video or audio, so video is never advertised and the template self-check renders no video part provider-swift/Sources/ProviderCoreFoundation/ModelMediaPolicy.swift (advertisesMedia, advertisesVideo); provider-swift/Sources/ProviderCoreFoundation/TemplateRenderCheck.swift (renderOK)
Serving Advertised by the exact type; the CBv2 adapter serves the text model or the VLM wrapper directly (48 slots, recurrent convolution state, native paged KV) provider-swift/Sources/ProviderCore/Inference/Engine/EngineV2SupportedModels.swift (isSupported); provider-swift/Sources/ProviderCore/Inference/Engine/Factory/EngineV2Factory+ModelAdapter.swift (ProductionModelAdapter, directServingModel)
KV backend Paged only: auto selects paged, and any other resolution (explicit contiguous, kill switch, crash guard) refuses the load, as for Flint; the model has no contiguous cache. The load-time native KV-type probe runs its one forward through the SDK's gathered reference attention (Inkling2GatheredAttentionCore), because the serving kernel core needs paged rows, then restores the kernel core before any engine exists provider-swift/Sources/ProviderCore/Inference/Engine/EngineV2KVBackendPolicy.swift (preferredBackend); provider-swift/Sources/ProviderCore/Inference/Engine/Factory/EngineV2Factory+BackendPreparation.swift (prepareProductionBackend); provider-swift/Sources/ProviderCore/Inference/Engine/Factory/EngineV2Factory+NativeKVTypes.swift (probeNativeKVTypes)
Prefill geometry 2,048-token prompt chunks and no solo stripe: with MLX's own prefill products (the SDK default) the engine keeps a fixed chunk grid of the scheduler's chunk and captures a prefix checkpoint only where every prompt range was exactly one grid chunk, so a solo stripe (an operator DARKBLOOM_CBV2_SOLO_PREFILL_STRIPE included) is not used for this model; boundaries fall at 2,048, 4,096, 6,144, ... DARKBLOOM_CBV2_PREFILL_CHUNK still sets the chunk, and so the grid. The step budget stays the SDK's 2,048 tokens unless DARKBLOOM_CBV2_STEP_TOKENS sets it (the grid gives a step's first prompt row its whole chunk past the budget), so one step carries at most one 2,048-token chunk beside its decode rows, as the solo stripe did; paged window rings and step bounds take max(chunk, stripe) = 2,048 as before provider-swift/Sources/ProviderCore/Inference/Engine/Factory/EngineV2Factory+Configuration.swift (prefillGeometry, inkling2PrefillChunkTokens)
Image input Images in user and tool-result messages. Each image's tower rows replace its run of token 200054 as causal tokens at scalar positions, no position state; only this model's cache bank admits causal media; content parts keep their message order into the template; video and media for a checkpoint without the tower are refused before any decode; media stays out of durable prefix checkpoints (engine rule) provider-swift/Sources/ProviderCore/Inference/Vision/EngineV2VisionPrefill.swift (buildInkling2Submission, validateInkling2Media); provider-swift/Sources/ProviderCore/Inference/Engine/Factory/EngineV2Factory+Production.swift
Prefix cache On by policy for served identities (the global switch still wins). Complete checkpoints use the SDK's historical recurrent layout, which carries all 48 cache slots: the 8 full-attention slots' K/V for every prompt position, the 40 sliding slots' last 1,024 positions, and every slot's convolution and recurrent state; with the DSpark drafter's rounds on, the drafter's own history too (native-paged-historical-recurrent-mtp-v1, otherwise native-paged-historical-recurrent-v1). Rows are stored exactly as served: the layout takes no lossy checkpoint profile, so the fleet's default profile leaves them native (the identity records native). Checkpoints sit on whole 2,048-token prefill chunks; a follow-up restores the deepest one below its prompt and recomputes the rest. The store, its encryption, cache identity (weights, prompt contract, build, numerics, drafter configuration) and tenant scoping (cacheSalt) are the ones every complete-checkpoint model uses; media requests are not captured (engine rule) provider-swift/Sources/ProviderCore/Inference/PrefixCache/PrefixCachePolicy+Activation.swift (isEnabled); provider-swift/Sources/ProviderCore/Inference/Engine/Factory/EngineV2SlotFactory+CompletePrefixCache.swift (completeCheckpointStorage); provider-swift/Sources/ProviderCore/Inference/PrefixCache/CompleteCheckpointStorageIdentity.swift (historicalRecurrent)
Drafter mtp_config on the native target declares the DSpark drafter in mtp.safetensors beside the target, outside its index. Its header is read with the inline bound; every tensor range must lie in the file; the header digest pins its tensor selection and is revalidated before load. Served on by default: the drafter loads bound to the text model (also when the VLM wrapper serves), with its own engine profile (up to 7 drafts, up to 8 speculating rows, adaptive depth down to plain decode; DARKBLOOM_INKLING_MTP_MAX_DRAFT lowers the draft cap, see the configuration reference); rows with a presence, frequency or repetition penalty or with stop strings draft too (DARKBLOOM_MTP_PENALTY_ROWS, DARKBLOOM_MTP_REPETITION_PENALTY_ROWS, DARKBLOOM_MTP_STOP_STRING_ROWS), and rows that request logprobs / top_logprobs draft under exact acceptance, with each token's logprob and top logprobs read from the row-exact verify pass, so they equal the values without speculation (DARKBLOOM_MTP_LOGPROB_ROWS=0 keeps them target-only; mtp_acceptance = typical keeps them target-only too), while logit_bias or a constraint keeps a row target-only; drafts are accepted exactly (a draft is kept only when it equals the target's own sample, so sampled output keeps the model's distribution) unless mtp_acceptance says otherwise; image rows run target-only provider-swift/Sources/ProviderCore/SpecDec/SpecDecStore.swift (declaresInkling2DSparkMTP, inspectInlineArtifact, revalidateForLoad); provider-swift/Sources/ProviderCore/Inference/MTP/EngineV2MTPAssistant.swift; EngineV2SlotFactory.swift (Inkling2DSparkDrafter.defaultMTPConfig()); provider-swift/Sources/ProviderCore/Config/SDKFeatureDefaults.swift (penaltyRowBuilds, repetitionPenaltyRowBuilds, stopStringRowBuilds); provider-swift/Sources/ProviderCore/Inference/MTP/MTPAcceptancePolicy.swift (resolve); provider-swift/Sources/ProviderCore/Inference/MTP/Inkling2MTPProfilePolicy.swift

Cache layout

The looped tower runs its core layers once per pass, each pass with caches of its own, so a sequence holds one cache slot per layer application.

Quantity Value at the pinned config Source
Slots 48: stored layers 0–23, then layers 6–17 for passes 2 and 3 Inkling2ModelIdentity.CacheLayout (slotLayers)
Full-attention slots 8 (layers 5 and 23, and 11 and 17 in each pass) CacheLayout.fullSlotCount
Sliding slots 40, window 1024 CacheLayout.slidingSlotCount
Marginal K/V per token 32,768 bytes at FP16 (8 slots × 8 heads × 128 × K and V) CacheLayout.kvBytesPerToken; provider-swift/Sources/ProviderCore/Inference/Memory/KVEstimation.swift (parseModelArchitecture)
Sliding plateau per sequence 167,772,160 bytes at FP16 CacheLayout.slidingWindowBytes
Convolution state per sequence 3,833,856 bytes in the reference's FP32, 1,916,928 in BF16 (K, V, after attention, after the MLP; 3 rows each, every slot); the loaded model's state decides CacheLayout.convolutionStateBytes
Context text_config.model_max_length 1,048,576 KVEstimation.parseModelArchitecture

Prompt contract

Concern Contract Source
Template chat_template.jinja (the tokenizer config has no template). Its tojson calls pass sort_keys and separators, which swift-jinja's filter refuses, so every render uses the Transformers-compatible filter provider-swift/Sources/ProviderCoreFoundation/HFTemplateFilters.swift (transformersOnlyModelTypes, bindingContext, install)
Reasoning effort The template reads the seven names exactly (none 0, minimal 0.1, low 0.2, medium 0.7, high 0.9, xhigh and max 0.99; default 0.9). Each accepted spelling reaches it as its canonical name; thinking off renders none provider-swift/Sources/ProviderCore/Inference/Prompting/Inkling2PromptContract.swift (templateEffort); provider-swift/Sources/ProviderCore/Inference/Prompting/ReasoningEffort.swift (templateEffort); fixtures/prompt-contract/v1/reasoning_effort_vectors.json
Declined reasoning Thinking off (reasoning.enabled, then enable_thinking, then an effort of none, off or 0) still lets the model think a little; that thought is never returned, in the answer or as logprobs entries, and is not counted as reasoning: its tokens count only in completion_tokens, and reasoning_tokens is 0. With logprobs, only tokens read inside an answer or call message keep their entries, while the thought's tokens and the frame markers (`< message_model
Tool-call history Each earlier call's arguments reach the template as the caller's JSON: the call's own function.arguments string, member order kept, null members and items kept, 1.0 a float, on every request (text and media, planned by the coordinator or not), as the reference's Transformers render does; the template sorts only the top-level keys. Arguments that are not a JSON object render as the provider decodes them provider-swift/Sources/ProviderCore/Inference/Prompting/TemplateJSONOrder.swift (callerArgumentModelTypes, orderingToolCalls); provider-swift/Sources/ProviderCore/Inference/Vision/MediaIngest.swift (buildUserInput)
Tool declarations Rendered as the body sent them (the template sorts their keys): null members kept (a Pydantic "default": null), numbers as written, and no member the provider's schema repairs add (a type inferred for a typeless property), on every request with a body the provider read, text and media, planned by the coordinator or not. Which declarations render follows the provider's preparation (by name); the repaired schemas still drive validation. A path that does not read the body (the local batch route, /v1/responses) renders the provider's normalized declarations TemplateJSONOrder.swift (Evidence.declarations, declaredTools); provider-swift/Sources/ProviderCore/Inference/Engine/Scheduler/MultiModelBatchSchedulerEngine+Translation.swift (capturingTemplateJSON, servingCoordinatorRequest)
Content parts A message sent as a list reaches the template as its text parts in order, each rendered as its own `< content_text
Known deliberate difference A developer message renders as a system message (OpenAI compatibility); the reference template raises on the developer role provider-swift/Sources/ProviderCore/InboundChatNormalization.swift (role aliases)
Tool choice No template control: required and named choices are prompt-forced and each call is checked before it leaves provider-swift/Sources/ProviderCore/Inference/Tools/ToolChoiceEnforcementPolicy.swift (forcedStrategy, advertisesCapability)
Load warm-up Every load, before the provider registers or its local API opens, runs one full prefill chunk with greedy decode steps at one row and short greedy decodes at two and eight rows where the served width allows (drafter rounds included); the shader-cache probe does not skip it, because the first full chunk of a process costs about a quarter more with a warm cache. Cells are warm-up cells with the cache off: no checkpoint, no tenant state, no rate change. DARKBLOOM_TTFT_SHAPE_WARMUP=0 turns it off; the Shape warmup log line reports its time. Then, once per load, every draft depth 0 (drafter off) to 7 runs on a private engine over the loaded model with its own scratch paged pool (the serving pool's geometry, a 2 GiB grant, released after): one row with a 4,224-token prompt, 2 and 8 rows of 256-token prompts where the served width allows, and with the drafter one 2-row cell of unequal prompts (256 and 1,100); each depth's widest and long cells run again on a second scratch pool with 2 MiB segments, so the attention's large segment bindings (8 fused, 16 otherwise) compile beside the small one (2); 12 greedy output tokens each, the prefix cache off, no prefix, checkpoint or SSD store, no tenant state, nothing persisted. It runs only while the Mac has twice the grant available; the Inkling 2 depth warmup log line reports its cells and time. The certified head's kernels for 1-64 rows compile when each engine starts (SDK) provider-swift/Sources/ProviderCore/Inference/Performance/ModelCalibrationPolicy.swift (ShapeWarmupPlan, inkling2Warmup); provider-swift/Sources/ProviderCore/Inference/Engine/Bridge/EngineV2Bridge+ShapeWarmup.swift (adoptInkling2ShapeWarmup); provider-swift/Sources/ProviderCore/Inference/Performance/Inkling2DepthWarmup.swift; provider-swift/Sources/ProviderCore/Inference/Engine/Factory/EngineV2Factory+Inkling2Warmup.swift
Loop guard On by default, as for the other served families: a reply that repeats verbatim ends as length; a call message (`< content_invoke_tool_json
Stops `< message_user

Output contract

Output after the prompt is a run of [<|message_model|>NAME]<|content_KIND|>BODY<|end_message|> messages, as the checkpoint's response_template reads it.

KIND Channel Rule Source
thinking reasoning Ends only at `< end_message
text, tool_error, invoke_tool_text content Refused for a forced choice provider-swift/Sources/ProviderCore/Inference/Streaming/NativeToolStreamRouter.swift (routeInkling)
invoke_tool_json one call Exactly {"name": NAME, "args": {...}}; a header name must match; `< end_message
image, xml, text outside messages none Dropped and counted, as the response template ignores them Inkling2OutputChannels (droppedBytes)

Calls leave complete when their message closes to a client that streams, else at the end of generation (provider-swift/Sources/ProviderCore/Inference/ToolStreamPreparation.swift, streamsInklingCalls). No text tool parser reads the output (makeHandler).

Drafter wiring

The drafter's declaration and automatic intent (ProviderConfig automaticEmbeddedModelTypes, SpecDecArtifactFunnel.isInlineTarget) and its load into the serving engine (EngineV2MTPAssistant, bound to the text model) are wired; see the Drafter row above.