refactor: remove unused other_mimi MimiModel instance (~200MB memory savings)#72
Open
mvanhorn wants to merge 1 commit intoNVIDIA:mainfrom
Open
refactor: remove unused other_mimi MimiModel instance (~200MB memory savings)#72mvanhorn wants to merge 1 commit intoNVIDIA:mainfrom
mvanhorn wants to merge 1 commit intoNVIDIA:mainfrom
Conversation
The second MimiModel instance (other_mimi) in server.py and offline.py processes the same audio as the primary mimi, but every encode/decode result is discarded (assigned to _). Removing it saves ~200MB GPU memory. Addresses NVIDIA#46
1 task
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
Removes the second
MimiModelinstance (other_mimi) fromserver.pyandoffline.py. Every call toother_mimi.encode()andother_mimi.decode()discards the result by assigning to_. The primarymimiinstance produces all actual output. Removingother_mimifrees ~200MB GPU memory.Why this matters
#46 identified that
other_mimiloads a full copy of the Mimi codec weights but never uses any output. On memory-constrained deployments (consumer GPUs, Jetson), 200MB is significant.Changes
moshi/moshi/server.py:other_mimifield fromServerStatedataclassother_mimiparameter from__init__,warmup, andhandle_chatother_mimi = loaders.get_mimi(...)instantiation inmain()_ = self.other_mimi.encode(chunk)and_ = self.other_mimi.decode(tokens[:, 1:9])callsmoshi/moshi/offline.py:other_mimiparameter fromwarmup()anddecode_tokens_to_pcm()other_mimi = loaders.get_mimi(...)instantiation inrun_inference()_ = other_mimi.encode(chunk)and_ = other_mimi.decode(tokens[:, 1:9])callsNet: -22 lines, +6 lines (signature adjustments).
Testing
Verified via
grep -rn other_mimi --include="*.py"that zero references remain. The primarymimiencode/decode path is untouched.No test suite exists in this repo.
Note for maintainer
If
other_mimiwas intended for a future streaming state feature or a separate voice prompt encoding path, please let me know and I'll revert. Based on the current code, all its outputs are discarded.Fixes #46
This contribution was developed with AI assistance (Claude Code).