Repository navigation
Conversation
Signed-off-by: LauraGPT <18321252+LauraGPT@users.noreply.github.com>
This branch has not been deployed
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
finallyblock on both successful and failed ASR requests.Root Cause And Scope
The Gradio process keeps VoxCPM2 and the optional enhancer on the GPU. Previously, after Ultimate Cloning was used once,
self.asr_modelalso retained SenseVoice for the rest of the process lifetime. This change keeps ASR lazy and removes that long-lived reference after transcription.Clearing a reference is not a guarantee of immediate physical GPU-memory release on every error path. A propagating exception's traceback can still hold the model through its
generate()frame while thefinallyblock callsgc.collect()andtorch.cuda.empty_cache(). An object-lifetime probe confirmed this distinction: the controlled model was already unreachable at cache cleanup on success, but was still alive there on failure, becoming unreachable after the caller finished handling the exception. The probe used Python weak references and a fake model; it did not measure GPU memory or establish Gradio's exception-retention lifetime. External references or retained exceptions can also extend that lifetime.This PR therefore removes the demo's persistent ASR ownership and attempts cleanup; it does not promise that every failure immediately returns all SenseVoice memory to the GPU driver. The existing tests likewise verify reference clearing and a cache-cleanup call, not allocator behavior with a real model.
Fixes #300
Fresh Verification (2026-09-29)
Unchanged published head:
ed2fb51fa3b56a9627cf0df010779f7a125acf7c.Fetched actual upstream
main@f772e498a45fbb5fb8e13fbf9b9c48be9fe33e69. Its intervening changes do not alterapp.py,pyproject.toml, or these tests; no history refresh or source changes were needed for this check.PYTHONPATH="src:$DEPS" python3 -m pytest -q tests -ra: 58 passed, no skips/deselections. A separate collection run found all 58 tests; no shard orPYTEST_ADDOPTSoverride was supplied.python3 -m black --check tests/test_app_asr_lifecycle.py: passed.git diff --check origin/main: passed.demo.asr_model; the exception traceback retained the fake model until exception handling completed.This reused the existing Python 3.12.3 unit-test environment and test dependency directory. It is not a clean installation of the project's full dependency set: Gradio is absent there, and the repository tests substitute Gradio, FunASR, VoxCPM, and selected model dependencies with test doubles. The fake CUDA availability/cache functions exercise control flow without CUDA execution. The test run emitted a
pkg_resourcesdeprecation warning. No model was downloaded or loaded, no inference or GPU experiment ran, and no end-to-end UI result is claimed by this fresh pass.Historical GPU Evidence
The earlier validation recorded a successful real
iic/SenseVoiceSmalltranscription on an NVIDIA H100 80GB with PyTorch 2.11.0+cu128:demo.asr_model is None, with a completed transcript.Those measurements are historical, were not rerun on September 29, and do not validate the exception path or establish a universal memory reduction. The earlier compile checks are also historical. Maintainer review is still pending; no merge, release, workflow approval, or manual CI dispatch was performed in this follow-up.