Skip to content

fix: release MLX resources between long diarized chunks - #399

Merged
seonghobae merged 6 commits into
mainfrom
feat/gpu-transcription-rust-backend
Aug 12, 2026
Merged

fix: release MLX resources between long diarized chunks#399
seonghobae merged 6 commits into
mainfrom
feat/gpu-transcription-rust-backend

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Summary

  • release completed MOSS audio/KV-cache objects after each bounded chunk
  • force Python GC and clear the MLX allocator cache before the next chunk
  • add a regression test for three-chunk speaker diarization cleanup

This keeps the existing TMK/VAD/fixed-duration provenance and checkpoint behavior unchanged while preventing long recordings from retaining completed GPU allocations.

Validation

  • python3 -m pytest -q (628 passed, 751 subtests)
  • cargo test --manifest-path rust-core/Cargo.toml --release (21 passed)
  • python3 -m ruff check audio_library.py tests/test_audio_library.py

Summary by CodeRabbit

  • 새 기능
    • 오디오 라이브러리 인벤토리, 파일 준비·검사·정리·적용을 지원하는 CLI를 추가했습니다.
    • 장시간 녹음의 분할, GPU 전사, 화자 분리, 설명·제목 생성 및 검토 흐름을 지원합니다.
    • macOS Apple Silicon에서 GPU 오디오 처리 환경을 안전하게 설정하는 도구를 제공합니다.
    • 세그먼트 측정 및 재개 비용을 확인하는 벤치마크 기능을 추가했습니다.
  • 문서
    • 오디오 큐레이션, 증거 관리, provenance 및 지연 데이터 조정 가이드를 추가했습니다.
  • 품질 개선
    • 오디오 처리, 파일 관리, CI 및 보안 관련 검증을 강화했습니다.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@seonghobae, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 18 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 866a07d4-af24-440d-a3f7-6b884a944a0d

📥 Commits

Reviewing files that changed from the base of the PR and between 3f06be3 and a02c3bf.

📒 Files selected for processing (2)
  • audio_library.py
  • tests/test_audio_library.py
📝 Walkthrough

Walkthrough

GPU 오디오 큐레이션 아키텍처와 Rust CLI를 추가했습니다. macOS MLX 런타임 부트스트랩, segmentation benchmark, Python 패키지 연결, CI 검증 및 기존 기능 회귀 테스트를 보강했습니다.

Changes

오디오 큐레이션 스택

Layer / File(s) Summary
큐레이션 아키텍처 및 처리 계약
README.md, docs/architecture/*
TMK/VAD segmentation, GPU 전사, provenance, iCloud materialization, Rust/Python 책임 경계 및 복구 계약을 문서화했습니다.
Rust CLI 및 Python 패키지 연결
pyproject.toml, rust-core/*, rust-toolchain.toml, .github/workflows/ci.yml, .coveragerc, .gitignore
Rust 명령을 추가하고 Python 콘솔 진입점, 선택 의존성, 고정 툴체인 및 CI 검증을 연결했습니다.
Segmentation benchmark 및 경계 검증
scripts/benchmark_segmentation.py, tests/test_chapters.py
고정/VAD 분할의 시간·메모리·경계 지표를 출력하고 chapter 경계 회귀 테스트를 추가했습니다.
macOS GPU 런타임 부트스트랩
scripts/bootstrap_macos_gpu_runtime.sh, tests/test_macos_gpu_bootstrap.py
경로, 권한, symlink, runtime identity, uv 및 잠금 의존성을 검증하는 MLX 런타임 설치 흐름을 추가했습니다.
기존 기능 회귀 테스트 보강
tests/test_mcp_driver.py, tests/test_media_shrinker.py, tests/test_saas_web.py
파일시스템 경계, iCloud 성공 처리, 선택 결과, ASGI disconnect 및 오류 응답 테스트를 보강했습니다.

Estimated code review effort: 5 (Critical) | ~90+ minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.55% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목은 장시간 화자 분리 청크 처리 후 MLX 리소스를 해제하는 PR의 주요 변경 사항을 정확히 설명합니다.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
⚔️ Resolve merge conflicts 💡
  • Resolve merge conflict in branch feat/gpu-transcription-rust-backend
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/gpu-transcription-rust-backend

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@seonghobae
seonghobae enabled auto-merge (squash) August 12, 2026 05:23

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (3)
tests/test_chapters.py (2)

13-13: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

모듈 이름과 지역 변수 이름이 충돌합니다.

이 파일의 여러 테스트는 chapters라는 지역 변수를 정의합니다(예: Line 31, Line 47). 새 테스트는 같은 이름의 모듈을 참조합니다. 현재는 동작합니다. 그러나 이후에 이 테스트 안에 chapters = ... 할당을 추가하면 UnboundLocalError가 발생합니다. 별칭을 사용하면 이 위험이 사라집니다.

♻️ 별칭 도입 제안
-import chapters
+from chapters import _boundaries_from_silences
         self.assertEqual(
-            chapters._boundaries_from_silences(
+            _boundaries_from_silences(
                 normalized_spans,
                 total_duration=600.0,
                 min_gap_seconds=3.0,
             ),
             [],
         )

Also applies to: 62-74

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/test_chapters.py` at line 13, Rename the imported chapters module to a
distinct alias and update the new tests’ module references accordingly,
including the affected range also covered by this comment. Preserve existing
local variables named chapters.

62-74: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

이 테스트는 도달 불가능한 입력을 검증합니다.

_boundaries_from_silences의 유일한 호출자인 detect_chapters_clamped_silences[0, total_duration]으로 클램프한 spans만 전달합니다. 따라서 (-10.0, 0.0)(600.0, 610.0) 같은 범위는 실제 경로에서 발생하지 않습니다. 방어 로직 테스트로서 가치는 있습니다. 클램프 이후 경계값인 (0.0, 4.0)(596.0, 600.0)을 추가하면 실제 경계 조건도 함께 고정됩니다.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/test_chapters.py` around lines 62 - 74, Update
test_boundary_helper_drops_timeline_extremes to retain the existing out-of-range
cases and also include post-clamping boundary spans (0.0, 4.0) and (596.0,
600.0), ensuring _boundaries_from_silences is verified for both defensive inputs
and reachable timeline edges.
.coveragerc (1)

3-3: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

CI에서 coverage gate를 실행하세요. .coveragercaudio_libraryfail_under = 100을 설정하지만, CI는 unittest만 실행합니다. coverage runcoverage report가 없으므로 현재 설정은 CI 실패를 유발하지 않습니다.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.coveragerc at line 3, Update the CI test workflow to run the unittest suite
through coverage and execute a coverage report gate afterward, ensuring the
existing .coveragerc settings for audio_library and fail_under = 100 are
enforced.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/architecture/segmentation-reconciliation.md`:
- Around line 39-44: Update the flowchart around “TMK marker ranges” to add the
reliable chapter/marker metadata fallback before nominal checkpoint ranges,
including when TMK is pending, unavailable, or verified without usable markers.
Preserve the existing VAD/silence and fixed-range fallbacks after this metadata
path, and make the precedence explicit as TMK markers → reliable metadata →
VAD/silence → fixed ranges.

In `@scripts/benchmark_segmentation.py`:
- Around line 143-144: Validate the value loaded by the args.silence_json
parsing path before assigning or passing it onward: require a top-level list
whose every item is a two-element pair, and raise a clear input error when the
shape is invalid. Preserve valid silence data unchanged and keep the validation
localized to the --silence-json handling.

---

Nitpick comments:
In @.coveragerc:
- Line 3: Update the CI test workflow to run the unittest suite through coverage
and execute a coverage report gate afterward, ensuring the existing .coveragerc
settings for audio_library and fail_under = 100 are enforced.

In `@tests/test_chapters.py`:
- Line 13: Rename the imported chapters module to a distinct alias and update
the new tests’ module references accordingly, including the affected range also
covered by this comment. Preserve existing local variables named chapters.
- Around line 62-74: Update test_boundary_helper_drops_timeline_extremes to
retain the existing out-of-range cases and also include post-clamping boundary
spans (0.0, 4.0) and (596.0, 600.0), ensuring _boundaries_from_silences is
verified for both defensive inputs and reachable timeline edges.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 77d1eeb8-c686-40c2-8c5d-013f7b2a7d59

📥 Commits

Reviewing files that changed from the base of the PR and between 65866fa and 3f06be3.

⛔ Files ignored due to path filters (3)
  • docs/papers/2212.04356-whisper.pdf is excluded by !**/*.pdf
  • docs/standards/NIST.FIPS.180-4.pdf is excluded by !**/*.pdf
  • rust-core/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (22)
  • .coveragerc
  • .github/workflows/ci.yml
  • .gitignore
  • README.md
  • audio_library.py
  • docs/architecture/gpu-transcription-rust-backend.md
  • docs/architecture/segmentation-reconciliation.md
  • pyproject.toml
  • requirements-macos-mlx-lock.txt
  • rust-core/Cargo.toml
  • rust-core/src/lib.rs
  • rust-core/src/main.rs
  • rust-toolchain.toml
  • scripts/benchmark_segmentation.py
  • scripts/bootstrap_macos_gpu_runtime.sh
  • tests/test_audio_library.py
  • tests/test_chapters.py
  • tests/test_ci_workflow.py
  • tests/test_macos_gpu_bootstrap.py
  • tests/test_mcp_driver.py
  • tests/test_media_shrinker.py
  • tests/test_saas_web.py

Comment thread docs/architecture/segmentation-reconciliation.md
Comment thread scripts/benchmark_segmentation.py
@seonghobae
seonghobae force-pushed the feat/gpu-transcription-rust-backend branch from 3f06be3 to 95821d3 Compare August 12, 2026 05:30
@seonghobae
seonghobae merged commit 40f36cb into main Aug 12, 2026
38 checks passed
@seonghobae
seonghobae deleted the feat/gpu-transcription-rust-backend branch August 12, 2026 06:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant