Skip to content

perf: keep embedding table in FP16 to save ~1GB on 1.7b model - #107

Merged
jafreck merged 2 commits into
mainfrom
fix/embed-fp16-memory
Apr 5, 2026
Merged

perf: keep embedding table in FP16 to save ~1GB on 1.7b model#107
jafreck merged 2 commits into
mainfrom
fix/embed-fp16-memory

Conversation

@jafreck

@jafreck jafreck commented Apr 5, 2026

Copy link
Copy Markdown
Owner

The embed_tokens.bin (594MB FP16) was eagerly expanded to a 1.2GB FP32 Vec<f32> at load time, but only a single token's embedding (~8KB) is looked up per decoder step.

This keeps the raw FP16 bytes in memory and converts only the requested token on-the-fly in lookup_embedding_fp16. The per-call cost is negligible (2048 FP16→FP32 conversions ≈ microseconds).

Result: RSS drops from ~6GB to ~4.9GB for the 1.7b Qwen3-ASR model.

jafreck added 2 commits April 5, 2026 13:14
The embed_tokens.bin (594MB FP16) was eagerly converted to FP32
(1.2GB) at load time, but only one token's embedding (8KB) is looked
up per decoder step. Store the raw FP16 bytes and convert on-the-fly
during lookup. Reduces RSS from ~6GB to ~4.9GB for the 1.7b model.
@jafreck
jafreck merged commit d2eaf27 into main Apr 5, 2026
5 checks passed
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