Skip to content

Perf/llama packed load memory#221

Closed
michalharakal wants to merge 2 commits into
developfrom
perf/llama-packed-load-memory
Closed

Perf/llama packed load memory#221
michalharakal wants to merge 2 commits into
developfrom
perf/llama-packed-load-memory

Conversation

@michalharakal

Copy link
Copy Markdown
Contributor

No description provided.

michalharakal and others added 2 commits June 27, 2026 14:56
…ak RSS

The NATIVE_OPTIMIZED Llama load peaks ~3.2 GB for a 668 MB model and
OOM-kills the 2 GB board. Two causes addressed:

- Fused load+pack: pack each raw-quant tensor inline in the streaming
  GGUF loader (DecoderGgufWeightLoader) instead of loading all tensors
  then converting in a second pass. convertLlamaWeightsPacked is now
  idempotent (empty quantTypes) and drains its source map destructively.
  Shared packLlamaTensor() helper factors the pack/dequant decision.

- Per-tensor gcCollectHint() (expect/actual across all targets; GC.collect
  on K/Native, no-op elsewhere) bounds the transient-copy high-water to
  ~one tensor in flight, mirroring the GemmaDecoder board pattern.

Compiles across all targets (jvm/native/js/wasm/android); publishToMavenLocal
green. Host/board RSS measurement pending a working native consume path.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sibling of core's KernelProfile (matmul dispatch): accumulates wall time per
named phase across the eager decode path — attn qkv/o projections, reshape,
RoPE, KV-cache update, fused-attention copy vs compute, RMSNorm, SwiGLU proj
vs eltwise, lm_head, residual, sampling. Diagnostic-only, always-on counters;
report/reset driven by the consumer (tinyllama SKAINET_PROFILE gate). Needed
to rank the ~54% non-matmul tail measured on the SL2619 board before fixing it.

Host-validated (macosArm64 eager, 8 tok): output unchanged and correct, buckets
sum to the measured inference time.

Perf-Tag: board-tail-profile

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@michalharakal

Copy link
Copy Markdown
Contributor Author

Superseded by #220: this branch is the pre-rebase (0.32.1-based) version of the same two commits (fused load+pack b5dbb47 / 1107fc9, PhaseProfile 7c8e4c8 / 58982d7). They were rebased onto 0.34.0 as perf/llama-packed-load-memory-0.34 — resolving the VoidDense.kt addBias conflict with the Moonshine work — and merged into develop via #220. Both changes are verified present on develop; nothing from this branch is lost.

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