Repository navigation
feat(nemotron_voicechat): cache-aware online session with frame events - #2039
Merged
Merged
Conversation
Port the reference streaming front end so a session can advance speech perception one 80 ms frame at a time with bounded state (issue #1378). StreamingLogMel (audio/nemotron_mel_stream.rs) ports StreamingLogMelSpectrogram: hop-aligned frames are emitted once their centers trail the input by lookahead_samples, only two hops of look-behind stay buffered, and each frame reuses NemotronMelFrontend::frame_into, so joined outputs equal the offline log-mel. ConformerStreamingState (audio/fastconformer/streaming.rs) ports the reference ConformerStreamingState and _stream_block: per-layer attention caches (last left_context inputs) and causal-conv caches (last kernel-1 GLU frames), incremental subsampling over a 16-frame mel cache, and materialize() to evaluate outputs and caches each step. RelPositionMultiHeadAttention::stream and ConformerBlock::stream are new methods; the offline forward is unchanged. RnntStreamState (audio/rnnt/stream.rs) ports _RNNTState with the reference delta rule. Validated with unit tests on random weights and tests/nemotron_voicechat_stream_real.rs against a reference streaming dump: encoder rms diff 4.6e-8, identical streamed transcript and per-frame deltas. Refs #1378
Add VoiceChatStreamingSession: PCM chunks of any size are buffered into 1280-sample frames and each frame advances the streaming log-mel, the cache-aware FastConformer, the RNNT state, the Nemotron-H caches, EAR-TTS and the codec decode_step exactly once, emitting frame-aligned text, function, transcript and 1764-sample audio events. The system prompt is prefilled at creation without events; flush pads the partial frame and emits Done, cancel emits Cancelled, and max_streaming_seconds bounds a session. Language and perception caches can be disabled for diagnostics, and an optional profiler records per-stage timings with p50/p95 and the real-time factor. mlxcel generate --stream drives the session in 80 ms frames, prints deltas as they arrive, and with --profile prints the summary; --max-streaming-seconds maps to the session limit. Refs #1378
…fails push_audio drained every complete frame before running any, so a context-limit or inference error on one frame dropped the frames behind it; the reference pops one frame per iteration. The frame buffer now releases one frame at a time with a read offset (linear in the chunk size), and the push/flush/cancel contract lives in a model-free InputLifecycle so chunk boundaries, closed-session rejection, idempotent close, and the failing-frame case are unit tested without a checkpoint. Refs #1378
inureyes
force-pushed
the
feature/issue-1378-voicechat-streaming
branch
from
September 29, 2026 12:17
3a9f747 to
812a357
Compare
inureyes
added a commit
that referenced
this pull request
Sep 29, 2026
#2044) ## Summary Fills the Performance table in `docs/nemotron-voicechat.md`, which PRs #2037, #2039 and #2041 left as TBD because their measurements ran while other units shared the GPU. Epic #1372's definition of done asks for the measured real-time factor for the 4-bit and 8-bit checkpoints. ## Measurement - Machine: Apple M1 Ultra (128 GB), Metal, otherwise idle (no builds, servers or other model runs). - Command: `mlxcel generate -m <ckpt> --audio question.wav --stream --profile --seed 0` on main `38eaaee6`, with the "What is the capital of France?" prompt and 3 s of extra decoding (56 frames, first 5 dropped as cold). - One warm-up run, then three measured runs per checkpoint. | Checkpoint | Real-time factor (3 runs) | Frame time p50 | Frame time p95 | |---|---|---|---| | 4-bit | 1.039, 1.039, 1.037 | 82.7 to 82.8 ms | 83.8 to 84.0 ms | | 8-bit | 1.119, 1.122, 1.119 | 89.3 to 89.4 ms | 90.4 to 91.0 ms | `realtime_factor` is mean per-frame processing time divided by the 80 ms frame, so values above 1.0 mean slower than real time. Neither checkpoint keeps up on this machine. The doc states that plainly and gives the per-stage breakdown (TTS 36 ms is the largest stage). ## Changes - `docs/nemotron-voicechat.md`: replace the TBD rows with the measured values, the method, and the per-stage breakdown. Documentation only.
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.
Summary
Adds the cache-aware online Nemotron VoiceChat session.
VoiceChatStreamingSessionaccepts PCM chunks of any size and buffers them into 1280-sample (80 ms) frames. Each frame advances every network exactly once from persistent state, and the session emits frame-aligned events.mlxcel generate --audio ... --stream [--profile]drives it from the CLI. This session is also the library surface the/v1/realtimeendpoint (#1376) builds on.What changed
StreamingLogMel(bounded sample tail, frames emitted once they trail the input by 1280 samples) andConformerStreamingState. The Conformer state keeps per-layer attention (70) and conv (8) caches plus a 16-frame mel cache for incremental causal subsampling, addsstreamentry points on the attention and block types, and providesRnntStreamStatefor transcript deltas. None of this changes the offline numerics.models::nemotron_voicechat::streaming.create_streaming_session(StreamingOptions)seeds the RNG, warms EAR-TTS, and prefills the system prompt without emitting events.push_audio/flush(pad_partial)/cancelfollow the issue's semantics, andmax_streaming_secondsraisesContextLimit.AssistantTextDelta,FunctionDelta,UserTranscriptDelta,Audio(exactly 1764 samples plus the 31 codes),Done,Cancelled. The text delta rule is the reference's.decode_stepwithCausalConv1dCache.perception,rnnt,language,tts,codec,totaltimings, each taken after forcing evaluation.summary(drop_first)gives mean/p50/p95/max, frames per second, and the real-time factor.--stream,--max-streaming-seconds, and--profile(prints the summary JSON after dropping 5 cold frames).docs/nemotron-voicechat.mdcovering cache families, events, switches, profiler and CLI. The performance table keeps its marked placeholder.Validation
All checks ran on the real 4-bit checkpoint.
tests/nemotron_voicechat_streaming_real.rs):tests/nemotron_voicechat_stream_real.rs):--streamwrites 61 x 1764 samples, and two seeded runs are byte-identical.--max-streaming-seconds 1stops with the context-limit error.cli_help_consistency,dead_doc_pointers,llama_compat_manifest. GitHub CI was not awaited (the self-hosted runner is down).The profiler runs and prints finite numbers, but no latency or real-time-factor figures were recorded, because the GPU was shared with other jobs during this run. The measured real-time factor for the 4-bit and 8-bit checkpoints is deferred to the orchestrator and goes into the marked placeholder table in
docs/nemotron-voicechat.md.Deviations from the issue body (the reference wins)
push: returns an MLX array.push_valuesgives the hostVec<f32>form.SequenceIdinModelOwnedSequenceState. This gives the same isolation without touching the scheduler state.Changes during review
push_audionow releases one frame at a time, so frames behind a failing frame (context limit, inference error) stay buffered as in the reference; the buffer is linear in the chunk size. The push/flush/cancel contract moved into a model-freeInputLifecyclewith always-on unit tests for chunk boundaries (0/1/1/1 then one padded frame), closed-session rejection, idempotent close, and the failing-frame case.RelPositionMultiHeadAttention::streamshares its body withforwardonly by duplication; a later refactor can fold both into one helper without changing numerics.Closes #1378