Skip to content

reduce memory usage across models - #162

Open
cjpais wants to merge 17 commits into
mainfrom
memory-usage-investigation
Open

cjpais wants to merge 17 commits into
mainfrom
memory-usage-investigation

Conversation

@cjpais

@cjpais cjpais commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

NOTE THIS MAY BREAK MODELS, NOT SUITABLE FOR MERGING YET

Some notes from my 4750U machine

Granite Speech 4.1 2B NAR — Unrestricted run caused system OOM; isolated run exhausted 8 GiB RAM + 2 GiB swap and was killed. Clear usability failure.
Moonshine Streaming Tiny — ~6.3 GiB RSS for a 48 MiB model before aborting; explicit streaming still aborted at ~677 MiB. Extreme amplification plus a likely indexing/streaming bug.
Qwen3-ASR 0.6B — ~7.6 GiB RSS, then hit its generation/context cap. Very high for an ~811 MiB model; likely duration-dependent growth.
GigaAM v3 RNNT — ~4.0 GiB RSS for a ~261 MiB model. Roughly 15× model size and strong growth with duration.
Multitalker Parakeet — One-shot: 4.45 GiB; explicit streaming: 1.26 GiB. Large mode-dependent difference; perhaps avoid or bound the one-shot path.
Canary-Qwen 2.5B — CPU remained at ≥8 GiB; Vulkan ~8.17 GiB after this PR. Still unsuitable for many 6–8 GiB GPUs.
Cohere Transcribe — ~7.5 GiB CPU, 4.34 GiB Vulkan. High absolute requirement, although its 2.25 GiB weights explain part of it.
Granite 4.0 1B Speech — ~5.6 GiB RSS, with an isolated cgroup peak around 8 GiB. High total working set relative to its 2.4 GiB weights.
SenseVoice Small — ~1.2 GiB for a ~139 MiB model.
MOSS Transcribe-Diarize — ~2.7 GiB and extremely slow on the five-minute recording.
Granite TurboCTC — ~1.2–1.4 GiB depending on quantization.
Moonshine Tiny — ~697 MiB before hitting its generation cap.

CJ Notes
Introduced slop limit on moonshine streaming

NairoDorian added a commit to NairoDorian/transcribe.cpp that referenced this pull request Sep 15, 2026
Port upstream PR handy-computer#162 which reduces memory usage across all model
families by bounding intermediate tensors and trimming padded rows
in-graph.

Conformer infrastructure:
- Add inplace_pre_encode and pre_encode_dw_time_chunk to ConvPolicy
- Inplace conv bias + relu, chunked depthwise convs for bounded
  activation memory
- Apply to canary_qwen and cohere encoders

GigaAM:
- Query-tiled attention for long sequences (T > 2048), tiling only
  the query axis to bound the O(T^2) score matrix

Granite-NAR:
- Replace host-side BPE-CTC pool+decode with graph-based bounded
  projection (512 windows per chunk), avoiding a full-utterance
  [vocab, T_enc] tensor

Moonshine Streaming:
- F16 sliding-window masks (no F32->F16 cast at graph build)
- Per-layer mask deduplication (tiny: 6 layers share 2 unique masks)
- Hard 81.92s input limit from 4096-row adapter position table
- Input limit check in run()/run_batch/stream_feed
- KV cache respects n_ctx cap

Qwen3 ASR:
- Removed encoder key-pad mask (build_cu_seqlens_mask, mask_in)
- Bounded chunked subsample (32-chunk batches) replaces inline conv
- KV cache init uses qwen3_context_ceiling instead of hardcoded 2048

Transcribe.cpp:
- Update max_kv_bytes comment for sessions that default to F32 KV

Tests:
- Rename moonshine batch_truncation -> input_limit (tests adapter
  position table gate, not output truncation)
- GigaAM smoke: 45s -> 90s (crosses query-tiling threshold)
- Update qwen3_asr truncation test comment

Docs:
- Document moonshine_streaming 81.92s adapter-position limit
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