mirror of
https://github.com/ollama/ollama.git
synced 2026-11-23 00:30:24 +00:00
* mlx: batch requests through a shared scheduler Use one request queue and scheduler for generation, decisions, embeddings and speech, including parallelism one. Share compatible model operations while keeping request caches, sampling state and response streams independent. Interleave prompt chunks with decoding and retain speculative decoding when generation runs alone. Cover isolation, cancellation, slow readers, cache reuse and mixed requests with unit and integration tests. Remove the stale llama-server architecture restriction on parallel requests. * mlx: prevent cache snapshots from retaining batch peers Copy each request’s initial batched K/V row so a sliding-cache snapshot cannot retain the whole batch allocation while accounting for only one row. Exclude grammar compilation waits from prompt timing and reuse row-selected attention masks across layers. Return errors for requests rejected before admission and strengthen numerical and compiled-speech regression checks. * address comments
27 lines
795 B
Go
27 lines
795 B
Go
package model
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/ollama/ollama/llm"
|
|
)
|
|
|
|
// SpeechModel batches generation over independently owned speech requests.
|
|
// All methods run on the MLX worker. DecodeSpeech shares model computation
|
|
// across the supplied states; output rows correspond to input rows.
|
|
type SpeechModel interface {
|
|
NewSpeech(context.Context, llm.SpeechRequest) (SpeechState, error)
|
|
DecodeSpeech([]SpeechState) ([]SpeechOutput, error)
|
|
}
|
|
|
|
// SpeechState owns one request's caches, sampling history and codec stream.
|
|
// Close runs on the MLX worker after completion, cancellation or failure.
|
|
type SpeechState interface {
|
|
Close()
|
|
}
|
|
|
|
type SpeechOutput struct {
|
|
Samples []float32 // CPU-owned 24 kHz mono audio.
|
|
Done bool
|
|
Err error // A request-local failure; peers may continue.
|
|
}
|