Skip to content

MediaTek and QNN exports on Modal, sized per window - #16

Merged
alpharomercoma merged 6 commits into
mainfrom
mtk-modal
Oct 7, 2026
Merged

alpharomercoma merged 6 commits into
mainfrom
mtk-modal

Conversation

@alpharomercoma

@alpharomercoma alpharomercoma commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

Moves the last two exports off the 15.7 GiB Namespace runner and onto Modal, the way XNNPACK and Vulkan already run.

  • MediaTek: mtk-matrix sizes a Sandbox per window. Memory comes from calibration_bytes (16 GiB floor), and cores and minutes from export_mtk.MODAL_SHAPES. Hybrids at 16k and up get one attention layer per chunk (finding 39). scripts/mtk-setup.sh downloads, verifies and deletes the NeuroPilot SDK inside each run, so none of it is stored.
  • QNN: qnn-matrix requests 20 B per parameter (24 GiB floor, up to 1.5× by 8k), with 16 or 32 cores. This is a minimum that Modal lets the run exceed. QAIRT is downloaded inside each run, and the Actions cache that kept a copy is removed.
  • ExecuTorch 1.5.1: importing the Qualcomm package no longer downloads QAIRT. The probe now calls setup_qnn_sdk() and checks that the libraries exist.
  • The original LFM2 checkpoints: hub.normalize_config reads full_attn_idxs and block_ff_dim.
  • From the Codex reviews:
    • Sizing uses the prompt_tokens override.
    • A window past the shapes is skipped instead of aborting the matrix.
    • Non-hybrids are left out of per-attention chunking.
    • Sandboxes receive the GitHub run IDs, so reports link to their build again.
    • Reports record the container's own memory peak (peak_cgroup_bytes).

Tested on this branch, with publishing off:

  • MediaTek: LFM2.5-350M at 2k, A16W8, run 37638181940, 12.4 min.
  • QNN: SmolLM2-135M at 2k on SM8750, run 37641157643, 19.9 min, structural check passed. The first attempt, run 37639219157, failed on the 1.5.1 SDK change.

264 tests pass, plus the 20 QNN tests against executorch 1.5.1.

🤖 Generated with Claude Code


View with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is enabled.

alpharomercoma and others added 6 commits October 7, 2026 22:36
…FM2 checkpoints

The Namespace profile (15.7 GiB, 4 vCPUs) carried no LFM2 window by the estimate, and a 32k
streaming calibration needs cores more than memory. mtk-matrix now gives each window a
Sandbox: memory from calibration_bytes (16 GiB floor), cores and minutes from
export_mtk.MODAL_SHAPES, and one attention layer per chunk for a hybrid at 16k and up
(finding 39). The image carries MediaTek's public Python 3.10 tools; scripts/mtk-setup.sh
downloads, checks and deletes the NeuroPilot SDK inside each run, so none of it is stored.

LiquidAI/LFM2-350M, -700M and -1.2B describe their layers as full_attn_idxs and
block_ff_dim rather than LFM2.5's layer_types and intermediate_size; hub.normalize_config
reads both, so sizing, chunking and lfm2.py see the same config.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Namespace profile has 15.7 GiB and no swap, and the one QNN export measured, Qwen3-0.6B,
already peaked at 15.6 GB of RSS at 2k and 4k (findings 8 and 10), so nothing larger could
build there. qnn-matrix gives each window a Sandbox: 20 bytes a parameter (24 GiB floor),
half again by 8k, 16 or 32 cores and up to 23 hours by model size. The request is a minimum
Modal lets the run exceed, and each report records the peak to refit it against.

The wheel still downloads QAIRT on first import, now inside the Sandbox, so the Actions
cache that kept a copy is gone and the SDK is never stored.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…hybrid-only chunking to hybrids

From Codex's review of the Modal move: the Sandbox was sized at the default 128-token prompt
batch while the export took the prompt_tokens input (73 GiB against 24 GiB for the 1.2B at
32k with 4096); a window past MODAL_SHAPES raised and dropped the whole matrix instead of
that one window; and a plain transformer whose config lists its layers as all
full_attention was cut one chunk per layer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s own memory peak

From Codex's review of the QNN move, true of every export on Modal: the Sandbox did not get
GITHUB_SERVER_URL, GITHUB_REPOSITORY or GITHUB_RUN_ID, so run_info was empty and the model
cards lost their build links; and MemorySampler's peak_in_use_bytes comes from /proc/meminfo,
which in a Sandbox is the host's. It now also records the cgroup's peak where the container
has one, as peak_cgroup_bytes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…no longer fetches

1.5.1 emptied backends/qualcomm/__init__.py and moved the download to
utils/qnn_sdk_setup.setup_qnn_sdk, called by the paths that start a backend. The probe still
imported the package and read the paths it would use, so the first export since the bump
(SmolLM2-135M at 2k on Modal) found no libQnnHtp.so there and failed inside the Qualcomm
script. The probe now calls setup_qnn_sdk and checks the libraries exist before the script.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…Linux CI runner has

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@alpharomercoma
alpharomercoma merged commit ae62bfc into main Oct 7, 2026
1 check 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