Qualcomm AI Engine Direct - [GenAI Pipeline] PR4: Adapter interfaces, default implementations & dataset providers - #21751
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/21751
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 3aac96f with merge base c56e6bf ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
@pytorchbot label "release notes: qualcomm" |
|
@qti-horodnic Firstly, this is a great refactor, modular, composable, and creating abstractions for all external |
|
|
@psiddh Phase 1: The current work, includes PRs 1-7 as outlined in the PR description. Includes only the addition of the skeleton of the new GenAI infrastructure. No existing code paths change behavior, and the skeleton isn't wired into any current entry point. This phase is purely additive and inert by construction, which is why several interfaces here are single-graph / stub-bodied: they're the N=1 degenerate case, with the general form landing in Phase 2. Phase 2: The next phase will include 4 PRs, divided between me and @DannyYuyang-quic into 2 (roughly) parallel work streams. This phase will include moving legacy code (e.g. Phase 3: Cleanup of old code. This will be done after only phase 2 has been completed and all critical code paths have been validated successfully. Nothing is deleted before this phase. |
On the HF -> static flat-KV swap: I'd keep that out of the transform list since it's "which class to construct" and is already registry data. Separating the two keeps the
|
…and default implementations
|
Merging it now (inert for now) , as it unblocks the next few PRs |
Summary
This PR adds the adapter layer that wraps external APIs (ExecuTorch, QNN SDK, HuggingFace) behind injectable Protocol interfaces for testability. Each strategy implementation (in subsequent PRs) delegates to these adapters rather than calling external APIs directly, enabling unit tests with mocked dependencies.
What's included
Adapter Protocols (6 files):
QuantizerAdapter: Protocol wrappingmake_quantizer,prepare_pt2e,calibrate,convert_pt2eCompilerAdapter: Protocol wrappingExportSessioncompilation flow +CompilationResultdataclassDeviceRunnerAdapter: Protocol wrappingSimpleADBpush/execute/pull +InferenceResultdataclassModelLoaderAdapter: Protocol wrapping HuggingFace model/tokenizer loadingCalibrationDataAdapter: Protocol for calibration dataset constructionTrainingDataAdapter: Protocol for QAT training data (yields (features, labels) pairs)Default Implementations (6 files):
DefaultQuantizerAdapter: Delegates toexport_utils.make_quantizer+torchao.quantization.pt2eDefaultCompilerAdapter: Placeholder for recipe-based compilation (depends onExportRecipe/ExportSessionAPIs not yet available). RaisesNotImplementedErrorwith guidance to inject a customCompilerAdapterusingto_edge_transform_and_lower_to_qnn.DefaultDeviceRunnerAdapter: Delegates toSimpleADBfor on-device executionDefaultModelLoaderAdapter: Delegates to HuggingFaceAutoModelForCausalLM+AutoTokenizerDefaultCalibrationDataAdapter: Random token sequences; accepts a caller-supplied dataset or DataLoader via extra_options["dataset"]DefaultTrainingDataAdapter: Pass-through for caller-supplied QAT data; raises ValueError if absent (labelled data can't be synthesized)Configuration:
.coveragercupdated to omitdefault_*_adapter.pyfiles (integration-test-only, require real SDK/hardware)__init__.pyfiles updated to export new adapter typesNew
datasets/packageDataset providers are a cross-stage concern, not a model-preparation detail — the same corpus feeds PTQ calibration during quantization and
on-device result evaluation during inference (including pre-built
.pteflows where model preparation never runs).They therefore live in a top-level
datasets/package rather than understrategies/model_preparation/.PR Review Checklist
Related PRs
Test plan
All existing tests continue to pass (no regressions).
Test Coverage
Command to run:
Result: