Skip to content

Compile-cache bundles: mstar cache and serve --compile-bundle - #1096

Draft
merceod wants to merge 7 commits into
users/atindra/pr-29-s5-pinned-arenafrom
users/atindra/pr-30-h5-cache
Draft

merceod wants to merge 7 commits into
users/atindra/pr-29-s5-pinned-arenafrom
users/atindra/pr-30-h5-cache

Conversation

@merceod

@merceod merceod commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator

Stacked on #1095 (pr-29-s5-pinned-arena).

Why

A cold server on MI325X compiles for minutes: r9b takes 340 s on Qwen3.5 9B, 644 s on Whisper and 1032 s on Qwen3-Omni colocated with empty caches (one start each, one GPU, shared node). A restart on the same host is warm, but a new host or container pays all of it again, and there was no way to carry the Inductor, Triton and MIOpen caches over.

What changed

  • mstar/cli/cache.py, mstar/utils/compile_bundle.py: mstar cache key|dirs|pack|unpack|show. A bundle is keyed on product, torch, HIP or CUDA, and Triton, and holds one uncompressed tar per cache. pack appends under a lock and merges MIOpen's databases. unpack refuses another stack unless given --force, and exits 3 when the root has no match, so callers can serve cold.
  • mstar/cli/main.py: mstar serve --compile-bundle ROOT unpacks before serving.
  • mstar/worker/worker.py: each worker logs its stack key and whether the unpacked bundle matches.
  • mstar/engine/accelerator_graph_config.py, accelerator_graph_runner.py: a compile_dynamic capture option, one dynamic-batch graph for every bucket. Default off, and nothing here opts in.
  • docs/compile_cache.rst, docs/serving.rst.
  • All of it is opt-in and works by stack key, so it isn't platform specific. Without the flag the only change on any platform is the startup line. It hasn't run on NVIDIA.

Verification

  • CPU: ruff clean. test_compile_bundle.py, test_accelerator_graph_capture.py, test_platform_dispatch.py, test_torch_config.py 90 passed, 4 skipped. On the speech stack's tip, the targeted set plus every branch's tests 2436 passed, 61 skipped, 0 failed, none failing only here. The widened 96-file set 1549 passed, 206 skipped, 5 failed, r9b 1519, 204, 5, the same 5 (ZMQ tests over the socket path limit under a long --basetemp, 15 passed with a short one).
  • GPU, one MI325X: test_accelerator_graph_capture 29 passed.
  • No window times startup. Seconds from launch to /health, MI325X, one start each, one GPU on a shared node, empty Inductor, Triton and MIOpen dirs, the speech stack's tip against r9b:
config r9b cold tip cold tip bundle, 1st tip bundle, 2nd
qwen3omni_colocated 1032 746 391 250
qwen3tts_1p7b 202 226 51 39
whisper_large 644 551 433 97
qwen3_5_9b 340 325 262 148
  • Pack 1.4-3.7 s, 2.9 GB with all four rows, unpack 2.8-3.8 s.
  • On the branch's own base, medians of three starts, same kind of job: 9B 337 to 136 s, Omni 848 to 247, Whisper 63 to 33, FLUX.2 klein 1140 to 54. A 3.07 GiB bundle packs in 11 s and unpacks in 4 s.
  • Output from a bundle start: bit-identical on Whisper and FLUX, within the near-tie protocol on 9B and Omni.

Not in this PR

  • The first start from a bundle is slower than the next on every row (1.3-4.5x here) and grows the Triton dir. The cause is unverified, so treat the 2nd-start column as the good case, not a startup claim.
  • Omni still spends 211 s warming before capture with every cache warm. Re-tracing per batch-size graph is a hypothesis.
  • Whisper's r9b cold start is 644 s because Whisper/Qwen3-ASR PR 5: serving performance #568 compiles one encoder graph per batch bucket. A dynamic-batch encoder on compile_dynamic compiles 4x faster, but its replay cost is unsettled and it stays on a local branch.
  • The bundle format needs to go upstream with the kernel registry.

A bundle is a directory per (GPU product, torch, HIP or CUDA, Triton) key holding one uncompressed tar per cache (Inductor, Triton, MIOpen) and a manifest. Packing appends only new or changed files under a lock; unpacking extracts the bundle for this stack into the cache dirs a server here resolves and leaves a marker that each worker reads at startup to log the key and whether the bundle matches. mstar serve --compile-bundle unpacks before starting.
The runner hints dynamo that each static input's bucket-varying dim is dynamic (maybe_mark_dynamic, so a forward that needs a fixed size still compiles per bucket) and compiles under the platform's overrides for any count. Size 1 keeps a graph of its own. Each bucket is still captured separately. Meant for encoders over fixed-size windows, whose per-bucket Inductor compiles are most of a cold start.
MIOpen keeps each database in one file (find and perf DBs as key=value text, kernels in SQLite), so packing caches warmed separately replaced the bundle's records with the last host's. A changed database is now merged with the bundle's last copy, this host's record winning on the same key, and appended only when the merge adds something. MIOpen files are compared by content: two warm-ups can leave databases of the same size and mtime.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant