Repository navigation
feat(runtime): continuous model-load progress in the trace log (llama.cpp-style) - #840
Conversation
Hosts that stream the framework log (audiocpp_server --log-file, audiocpp_cli --log) had no way to show model-load progress: the log only said which model was loading and when it was done, so load bars stalled between milestones. llama.cpp reports a continuous done/total curve over the per-tensor weight upload; audio.cpp now does the same. - New core/load_progress tracker: begin_model_load seeds the denominator from the inspected weight files; register_weight_bytes raises it when a store's uploads expand past the seed; add_uploaded_weight_bytes / emit_weight_upload_progress trace <store>.weights.upload_progress once per ~0.2% step (mutex-guarded, lazy loads included). - BackendWeightStore::upload feeds the tracker per tensor and emits the curve before and after every tensor copy. - ModelRegistry::load brackets the load with runtime.load.phase inspect|load and starts the curve; finish_model_load_trace() closes it (runtime.load.phase loaded + final curve point) once the host has built the task session - that is when the weight stores actually upload. - ServerState::load_models traces server.load.progress (models-completed fraction, 1.0 when every eager model is resident, before the listening banner).
|
Assisted with Glm5.3 and 5.3 flash over zcode |
c94cb0c to
aaae931
Compare
|
@drzsdrtfg Thanks for the PR. This helps address the lack of model-loading progress reported by UI users. However, I suggest making it opt-in with One minor issue is progress reaches 100% too early. In my LFM2 ASR test, it reached 100% after loading the 63 MiB encoder, before uploading the 917 MiB backbone. When the next component increases the total, the monotonic clamp keeps the displayed progress at 100%, so it no longer reflects the remaining work. |
|
ok, will come bakc when its done |
…otals rise Review feedback on 0xShug0#840: - All load-progress keys (runtime.load.phase, <store>.weights.upload_progress, server.load.progress) are now gated behind --load-progress 1 on both the server and the CLI, default 0. With the flag off the log is byte-identical to the pre-load-progress behavior: no phase brackets, no curve, no models-completed boundaries, and the runtime.model.* inspection trace keeps its original trace-log gating. The explicit per-load inspection runs exactly as before the feature. - The curve no longer strands at 100% when a later component raises the denominator (LFM2 ASR: 100% after the 63 MiB encoder, before the 917 MiB backbone). emit_weight_upload_progress now reports done/total over all work known so far: a total raise emits the corrected lower fraction immediately (no high-water clamp), and the per-tensor path caps at 0.99 - the final 1.0 belongs to end_model_load after the last store uploaded, so an undercounted seed can never display 100% early. - ParallelServerState closes the load-progress bracket after its first resident session and reports models-completed boundaries, matching the classic server state. Verified windows-cpu-release + windows-vulkan-release: flag-off boots emit zero new lines with /health 200; flag-on boots show the full ladder with the curve capped at 0.99 before runtime.load.phase loaded and 1.0 after; CLI synthesis emits the same on stdout; supertonic's multi-store upload stays monotonic to the cap.
|
Thanks for the review! Both points are addressed in 9159716: Opt-in reporting. All three key families ( Early 100%. Reproduced the shape of your LFM2 case from the code path: the seed (discovered weight bytes) undercounts when some weights aren't visible to the inspection, the first small store completes against that small denominator, and the old high-water clamp pinned the curve at 1.0 after the backbone raised the total. Two changes fix it:
Verified on windows-cpu-release and windows-vulkan-release: flag-off boots emit zero new lines with /health 200; flag-on boots show the ladder with the curve capped at 0.99 before |
|
Follow-up: I ran the LFM2 test you asked for, against 9159716. Package: LiquidAI/LFM2.5-Audio-1.5B-GGUF (Q8_0), four components — backbone 1.19 GB, mmproj 293 MB, vocoder 206 MB, tokenizer 77 MB (sizes differ from your 917 MiB/63 MiB figures, presumably a repo revision apart, but the mechanism is identical). Run via This family undercounts even harder than your case: With the fix, the emitted curve does the right thing:
So: no early 100% even with a zero seed, and after the denominator grows the curve tracks the actual remaining backbone work instead of sitting pinned. Flag off on the same model: zero new lines, pre-existing trace intact, same transcription. |
|
sorry for these slop comments(zcode somehow comments automatically without asking). Still not fixed. |
|
@drzsdrtfg Thanks! Merged. The current approach looks fine. We just need to document that progress is approximate and may move backward when loading multiple GGUF components. It works correctly for the tested single-GGUF cases. |
|
Yeah, but I am still searching for proper fix, since the prgress going back may not be to the liking of most users. |
|
Follow-up in 4caead7: after the LFM2 test I reworked the fix to remove the downward correction entirely rather than keep it. The correction drop treated the symptom. The real problem is that weight stores are built one component at a time, so nothing knew the whole model's byte count before the first tensor copied. This revision gives
Measured on LFM2.5-Audio ASR with |
|
Sounds good! |
|
Tested supertonic3 and granite 5 asr on my own ui, working properly. Note: my follow-up commit ( |
Yes! |
|
Sorry for being such a hassle and thanks for being so consistent on your work on audio.cpp. I decided to not open the other PR, since we need to add a couple of lines to every multi-component asr. Its just not worth it. My future work will probably be less on the backend side, since I suck. Have a happy day. |
|
@drzsdrtfg No worries at all. I really appreciate all the work you've put into audio.cpp. And don't be so hard on yourself...Looking forward to more contributions from you. Have a great day too! |
Problem
Hosts that stream the framework log (
audiocpp_server --log-file,audiocpp_cli --log) have no way to render an honest model-load progress bar. The log says which model started loading and when it finished, but nothing in between:llama.cpp solves this in the loader itself: a per-tensor
bytes_done / bytes_totalcallback that fires throughout the whole weight upload. This PR brings the same reporting to audio.cpp, over the existing trace log.Design: strictly opt-in (--load-progress 0|1, default 0)
Per review feedback, every new key is gated behind
--load-progress 1on both the server and the CLI. With the flag off, the log is byte-identical to the pre-load-progress behavior:runtime.load.phasebrackets, no<store>.weights.upload_progresscurve, noserver.load.progressboundaries;runtime.model.*inspection trace keeps its original gating (it still emits with plain--log/--log-fileexactly as before), and the explicit per-load inspection still runs — its cost and output are unchanged;What it emits (with
--load-progress 1plus--log/--log-file)runtime.load.phase inspect|load|loaded<store>.weights.upload_progress <0..1>server.load.progress <0..1>1.0once every configured model is resident, just before the listening bannerMechanics:
engine::core::load_progresstracker (include/engine/framework/core/load_progress.h).ModelRegistry::loadstarts a curve per load, seeding the denominator from the inspected weight files' on-disk bytes;BackendWeightStore::uploadraises the denominator if its backend tensors expand past the seed (dequantization, derived tensors, weights the inspection could not see) and feedsadd_uploaded_weight_bytesonce per uploaded tensor — the same place llama.cpp advances its callback.engine::runtime::finish_model_load_trace(), called by the server (classic and parallel) and the CLI aftercreate_task_session: that is when the weight stores have actually uploaded, not when the registry load returns.Exact denominator, no backward corrections (review fix, revised)
The first revision clamped the curve to its high-water mark; the second let the fraction correct downward when a later component raised the total. Both treated the symptom: the real problem was that no one knew the whole model's byte count before the first tensor copied, because weight stores are built one component at a time. This revision fixes the cause:
BackendWeightStore::upload()splits intoprepare()(allocate the buffer, register the store's full pending-tensor budget with the tracker — no data movement) and the copy loop;upload()prepares automatically, so families that keep uploading per store behave exactly as before.lfm2_audiodoes this for every session (ASR: encoder+backbone; TTS: backbone+depthformer+detokenizer; chat: all four); the runtime constructors only queue weights, and inference uploads lazily if a caller skips the explicit phases.Result on LFM2.5-Audio ASR: one monotonic climb across encoder and backbone — zero downward corrections — capped at 0.99, final
1.0only atruntime.load.phase loaded. For families that still upload per store (and for seeds that undercount, like lfm2_audio's emptydiscovered_weights), the earlier safety net remains: the fraction is always done/total over known work, a total raise emits the corrected fraction immediately, and the per-tensor path never reports 1.0 early.Example (windows-cpu-release, granite5asr + supertonic eager boot):
Verification
windows-cpu-releaseandwindows-vulkan-release(audiocpp_server,audiocpp_cli,audiocpp_gguf), on currentmain./health200 — byte-identical logging. Same for the CLI (--logonly).0.99beforeruntime.load.phase loaded, final1.0after it,server.load.progressboundaries,/health200 after bind.1.0, no spurious decreases, audio produced, exit 0.--load-progresswith any value other than0|1fails fast.Risk assessment
When the flag is off (default for every existing pipeline): the only hot-path change is one pass over pending tensors computing
ggml_nbytessums plus tracker calls that return after an atomic flag check — no locks, allocations, formatting, or syscalls; nanoseconds per tensor against weight copies measured in milliseconds. Log output is unchanged byte-for-byte, and the inspection phase runs exactly as before.When the flag is on: ~200–500 extra log lines per model load (~30 KB per two-model boot) through the existing trace logger. The progress mutex is uncontended in practice and never held during I/O.
Behavior: all keys are additive; hosts that don't parse them ignore them. No changes to inference, model formats, HTTP endpoints, session semantics, or memory layout.
Notes for reviewers: the store-name doubling in keys (
supertonic.weights.weights.upload_progress) comes from stores already named<family>.weights; hosts match the*.weights.upload_progresssuffix uniformly. A local install built from this branch self-reportsAUDIOCPP_VERSION=dev; tooling tracking installs by registry tag is unaffected.