Repository navigation
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/24568
Note: Links to docs will display an error until the docs builds have been completed. ❌ You can merge normally! (1 Unrelated Failure), 1 Unclassified FailureAs of commit b294f72 with merge base 765e973 ( UNCLASSIFIED FAILURE - DrCI could not classify the following job because the workflow did not run on the merge base. The failure may be pre-existing on trunk or introduced by this PR:
BROKEN TRUNK - The following job failed but were present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
winskuo-quic
left a comment
There was a problem hiding this comment.
Hi @psiddh,
Since this is a draft PR, I am focusing on the high-level design.
My understanding of this PR is to introduce a KvCacheIOManager which accepts KVcache as inputs/outputs.
I would like to know what PTE (lowering flow) you are currently using for this runner?
I tried lower a XNNPACK model and it seems like the IO contract doesn't really match KvCacheIOManager.
The official documentation of HuggingFace states that there are actually a lot more inputs and outputs. Reference: https://github.com/huggingface/transformers/blob/e20e0787c9863f4b78781e603adfe6648415a854/docs/source/en/exporters.md?plain=1#L784
Difference 1: The Cache input/output actually consists of 3 things instead of 2: k_cache, v_cache, cumulative_length.
Difference 2: The HF flow will output 2 sets of Cache: regular output Cache and mutated Cache.
I would like to know whether these differences are taken into consideration or not. Personally, I think some of these HF I/Os are unnecessary and could cause memory spikes (or bloat the memory footprint) at runtime, which is problematic on resource-constrained edge devices.
It would be appreciated if you could share some of your thoughts on this. Thanks
| method.c_str(), | ||
| num_inputs, | ||
| cross_inputs); | ||
| const int32_t layers = |
There was a problem hiding this comment.
I think the num_inputs consists of cumulative_length too when I tried the HF lowering flow with XNNPACK. If cumulative length is also one of the inputs maybe we should /3 instead?
Run each partitioner’s edge transforms after caller-supplied passes so backends can use the standard lowering entry point. QNN contributes its existing transforms through the new hook.
Reserve names for constant tensors already present in the exported program before lifting new constants, so methods with folded tables retain distinct constants.
Choose the registered IOManager and its logits, method names and step sizes, rejecting unknown contracts and invalid metadata. Load and reset the selected methods; route prompt tails to decode with a side-effect-free capacity check. Preserve module and I/O-buffer lifetimes and expose a backend-neutral allocator hook.
3823faf to
b294f72
Compare
|
Thanks for trying it with XNNPACK. The version you reviewed was out of date, and I've updated it. |
LLM runner: select I/O contracts and accept custom buffer allocators
Add a backend-neutral IOManager registry and buffer-allocator hook. The generic runner selects a registered manager from the program metadata and rejects unknown contracts or invalid metadata. This PR adds no concrete cache adapter; the hf_static implementation follows in PR 7.
The runner loads and resets selected methods, preserves module/buffer lifetimes, and uses a side-effect-free capacity preflight to route a prompt tail through decode. Execution errors are not retried. Builtin registration is an inert definition until PR 7 registers the concrete manager.
Review the interface/registry, runner load/reset and lifetime handling, prompt capacity preflight, then tests. QNN allocation follows in PR 4. Eviction, state adoption and fork policy remain IOManager follow-ups.
Files
Test Plan
Commit
395a6e50450f4f0d065b89fe09074ba98db5056aon892e50425f5a3e90ff8d3c8802fdfb31f8599518. Validated locally with Python 3.12, pinned Torch/TorchAO, the local transformers exporter branch and QAIRT SDK 2.48.146 runner tests passed; 2 existing skips; 0 failures.
cmake --build /data/users/sidart/qnnflow/gh_prs/build-split-native-pr03 -j4 --target test_runner ctest --test-dir /data/users/sidart/qnnflow/gh_prs/build-split-native-pr03 -R "^test_runner$" --output-on-failure -VThe two existing runner skips are
TextDecoderRunnerTest.LoadUsesMethodNameandStepWithAllModels.No device/physical rpcmem, two-target FCB, real-model export or full QNN device-suite result is claimed. Buck could not start because the local launcher requires a missing
.buck2. The base already contains #23563 and #23183; neither is a separate prerequisite commit here.Related PRs (review in order)
Each PR includes the commits of the ones above it; review only its own top commit.