Repository navigation
Conversation
Proposal only; no header changes. A context can own encoder and decoder memory (llama_memory_t-style: codec_get_memory, codec_memory_clear, codec_memory_state_get_size/get_data/set_data), so codec_encode / codec_decode continue a stream. Covers per-family semantics (Mimi, Qwen3-TTS tokenizer, MOSS, DAC, SNAC, WavTokenizer), how #6's windowed streamer becomes the internal fallback, the state blob format and versioning, thread safety and open questions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Per review: memory caches the context a model needs (sliding-window K/V, conv tails, convtr overlap partial sums, position) and nothing else. Removed flush, the ended state, input buffering, held-back output, the WINDOW kind and the in-library crossfade; each call returns exactly what a stateless call returns for its input. Encode chunks must be hop-aligned (the batch tail padding and the measured effect of caller zero-padding are documented). v1 supports causal models only; #6's host windowing stays the fallback. codec_model_memory_kind becomes codec_model_has_memory; codec_memory_n_frames and the speaker question are dropped (reference-voice state is a future codec_speaker proposal). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Per review, minimal change: models with no context to remember have memory size 0 and enabling it is a valid no-op (no "unsupported"); codec_model_has_memory means "non-zero memory". codec_encode/decode input handling, padding and output are unchanged; no hop-alignment rule, no new status codes, no fixed-per-stream parameters. The only restriction kept: codec_decode_batch neither reads nor updates memory (several sequences vs one). Removed all open questions (padding, sample rate, graph cache, non-causal support). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Per review: codec_model_has_memory becomes codec_model_is_causal (no look-ahead; memory then makes streamed output equal batch; non-causal parts have memory size 0). enum codec_memory_type becomes the bit set enum codec_part (NONE / ENCODER / DECODER / ALL), shared by the memory field, clear's `parts` and the state calls. Save/restore moves to the context as in llama.cpp: codec_state_get_size / get_data / set_data. The #6 streamer takes the incremental path when the decoder is causal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…keys
Per Hans's approved direction: drop enum codec_part. One memory handle
per side (encoder_memory / decoder_memory params,
codec_get_encoder_memory / codec_get_decoder_memory), clear and state
save/restore on the handle (deliberately unlike llama_state_*(ctx)),
codec_model_encoder_is_causal / codec_model_decoder_is_causal.
New GGUF keys codec.{encoder,decoder}.{look_back,look_ahead} in frames,
written by converters; is_causal = look_ahead == 0; -1 = unbounded;
look_back on a causal side is the cached context length. Missing keys
fall back to per-arch defaults (old GGUFs load); #6's window table
becomes those defaults. Adds a Rollout section (published GGUFs updated
in place later, each upload approved separately).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Mimi's transformers (also the Qwen3-TTS tokenizer's encoder) run at 25 Hz, twice the 12.5 Hz codec frame rate, so their 250-step sliding window is 125 codec frames, not 250. look_back is stated in codec frames throughout; a layer's cache spans its window at its own rate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposal only. This adds one document,
docs/proposals/codec_memory.md, and changes no code or header.include/andcommon/*.hstay untouched until the design is approved.What it proposes (the smallest possible change)
codec_encodeandcodec_decodehandle their input, padding and output exactly as today, and no status code is added. On a causal side, consecutive calls give the batch output.codec.{encoder,decoder}.{look_back,look_ahead}, in frames:is_causalmeanslook_ahead == 0, and −1 means unbounded;look_backis how many frames the memory caches;codec_decode_batchneither reads nor updates memory, because a batch holds several sequences and memory holds one.codec_context_paramsgrows) and a test plan.Naming
enum codec_memory_type/enum codec_partcodec_context_params.memorybool encoder_memory; bool decoder_memory;llama_context_paramsKV settingscodec_get_memory(ctx)codec_get_encoder_memory(ctx)/codec_get_decoder_memory(ctx)llama_get_memory(ctx)codec_memory_clear(mem, which/parts)codec_memory_clear(mem)llama_memory_clear(mem, data)codec_memory_state_*(mem, which, …)/codec_state_*(ctx, parts, …)codec_memory_state_get_size / get_data / set_data(mem, …)llama_state_get_size / get_data / set_data(ctx, …). We depart on purpose: state lives on the handle, so it is always clear which side is savedcodec_model_has_memory/codec_model_is_causal(model, part)codec_model_encoder_is_causal(model)/codec_model_decoder_is_causal(model)Out of scope:
codec_speakerproposal.🤖 Generated with Claude Code