Repository navigation
Qualcomm AI Engine Direct - [GenAI Pipeline] PRA2 - Runner and Evaluator - #25353
Open
DannyYuyang-quic wants to merge 1 commit into
Open
DannyYuyang-quic wants to merge 1 commit into
DannyYuyang-quic wants to merge 1 commit into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/25353
Note: Links to docs will display an error until the docs builds have been completed.
|
Contributor
Author
|
@pytorchbot label "release notes: qualcomm" |
Contributor
Author
|
Hi @psiddh |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR is the second of Phase 2 Stream A and closes Phase 2. A1 prepared and quantized LLM/MLLM models, and B1/B2 lowered them to
.pte. A2 adds the inference stage:.pteartifacts on an Android/OE-Linux device or on the x86 host;prompt_eval,tasks_eval,sqnr_eval) and returning one result per method;llama_stories_260kparity test against legacyllama.py, which gates the Phase 3 deletion of the legacy flow.Nothing under
examples/changes. The legacyllama.pydevice-evaluator flow remains CI's reference until Phase 3. Every external call (Device, the x86 runner, lm_eval, PTE metadata) stays behind an injectable adapter or platform.What's included
Inference strategy (
strategies/inference/executorch_inference_strategy.py)--pre-gen-ptewhen compilation was skipped, and the runtime tokenizer override. Everything inside inference readsinput_config.runtime_tokenizer_pathonly.DeployedModelfor each evaluator, and builds each method'sInferenceResultwith throughput plusresults.json/performance.json.Runner adapters (
strategies/inference/)llm_runner_adapter.py/mllm_runner_adapter.py(new):qnn_llama_runner/qnn_multimodal_runneradapters. They own the runner flags and decode the runner outputs (generated text, dumped logits). They do not know where the runner runs.device_runner_adapter.py: theDeviceRunnerAdapterprotocol (push_artifacts→get_metadata→push_inputs→execute→pull_results) is now request-typed instead of taking a free-form options dict.default_device_runner_adapter.py: the genericqnn_executor_runnerpath throughexport_utils.Device, migrated to the request types. The CLI does not build this path.Runner platforms (
inference/platforms/, new)RunnerPlatformdecides how files reach the runner, how it is launched, and how outputs come back.DevicePlatformruns on an Android/OE-Linux device over adb throughDevice.X86Platformruns the x86 build against the QNN SDK's x86 libraries and rewrites input-list entries to host paths, as the legacy flow does.get_runner_platform(qnn_config, enable_x86_64)selects one from the CLI flags.Runner I/O and helpers (
inference/, new)runner_io.py: typed requests/outputs:GenerateRequest/GenerateOutput,ForwardRequest/ForwardOutput,ExecuteRequest/ExecuteOutput, andRunnerMetadata, read once from the decoder PTE.runner_constants.py: runner flag values (EVAL_MODE,DECODER_MODEL_VERSION,MODALITY_INPUT_FLAG_MAP). A parity test checks them against the legacydecoder_constantsuntil Phase 3.utils.py: PTE selection (get_pte_paths), runtime tokenizer check,ControlArgswith inference overrides, PTE metadata (retrieve_info_from_pte), shared runner flags, logits loading and dequantization (post_process_logits), and MLLM media preprocessing (preprocess_encoder_inputs).preprocess_encoder_inputsstill lazily imports its processor, media loaders, modality configs and special tokens fromexamples/(see Deliberately deferred).Evaluation (
evaluation/, new)Evaluator.evaluate(model, control_args, input_config, metadata) -> EvaluationScoreis stateless. An evaluator decides what to feed the deployed model and how to score its predictions; it knows nothing about adapters, files or platforms.prompt_evalPromptEvaluator--promptand reports the generations.tasks_evalLmEvalEvaluator--eval-tasks), answering each model call with a KV-mode runner forward.sqnr_evalSqnrEvaluatordefaultDefaultEvaluatorDefaultDeviceRunnerAdapter. Not reachable from the CLI.evaluator_lookup.get_evaluators(eval_methods, multimodal)maps method names to evaluators. Multimodal models supportprompt_evalonly.Responsibility split
Dependencies point one way:
strategies/inference→evaluation/inference→configs.genai_pipeline.pydoes not depend onevaluationand reads no inference-specific keys.CLI (
cli.py)export_llama, including thetasks_eval/sqnr_evalmodel-mode checks.skip_quantizefor the modality encoder when more than one--image-pathis given (deferred from B2).get_inference_stageand result logging.Legacy parity
tasks_evalrejectslookaheadand warns forhybrid;sqnr_evalwarns for any non-kv mode. Only their forwards run in kv mode;--model-modeis unchanged for the other methods. This matches what legacy actually does: its(TASKS_EVAL or SQNR_EVAL) in eval_methodscheck only ever teststasks_eval.--image-path, the vision encoder skips quantization and compiles in FP16, as legacyllama.pydoes.--profile-level,--dump-intermediate-outputs,--htp-performance-modeand--direct-build-folderare not exposed. The legacy llama flow inherits them from the shared parser but never wires them into its compile specs or runner commands, and llama has no direct-mode runner.--skip-pushis not exposed.Deviceskips every push under it, including the token filestasks_eval/sqnr_evalpush per request and the MLLM media inputs, so those runs would silently read stale inputs on device.--pre-gen-ptereads only directories produced by this pipeline. Legacyllama.pyfile names depend on model mode and decoder name; an unrecognized directory fails with the list of expected file names.Config surface
InferenceInputConfig:pte_pathsreplacesartifact_paths; addsartifact_dir, the hostmodel_module/example_inputsSQNR needs, andinference_options. The orchestrator forwards them.InferenceOutputConfig.results: Dict[str, InferenceResult], one per method. This is a public API change:resultsreplaces theinference_results,performance_metrics,eval_resultsandetdumpfields.artifact_keys.pte_file_name(model_name, artifact_key=None): the single PTE naming rule shared by compilation (writes) and inference (--pre-gen-ptelookup):{model}_{key}.pteper component,{model}.ptefor a single-graph model. The compilation strategy now calls it; file names do not change.control_args.py:PROMPT_EVAL/TASKS_EVAL/SQNR_EVALconstants, shared by the CLI choices and the evaluator lookup.model_lookup.py:get_modality/validate_modality_inputsfor MLLM media inputs.Deliberately deferred
--ip/--port). The legacy CI entry point is unchanged.DefaultEvaluator/DefaultDeviceRunnerAdapterinto the CLI.TokenizerWrapper,DecoderInference,EagerEvalWrapper, and the processor, media loaders, modality configs and special tokenspreprocess_encoder_inputsuses out ofexamples/. They are shared with A1 and are left for a follow-up decouple PR.Unit tests (15 new files, 6 updated)
test_cli.py,test_llama_stories_260k_e2e.py,evaluation/test_{evaluator,evaluator_lookup,prompt,tasks,sqnr,default}.py,inference/test_{runner_io,runner_constants,platforms,inference_utils}.py,strategies/inference/test_{llm_runner_adapter,mllm_runner_adapter,default_device_runner_adapter}.py.test_executorch_inference_strategy.py,test_inference_stage.py,test_inference_input_config.py,test_genai_pipeline.py,test_artifact_keys.py(pte_file_name),test_tag_ios_parity.py(legacyTextDecoderimported lazily).test_llama_stories_260k_e2e.pyis the x86 parity test: it checks generations against legacyllama.pyand thesqnr_evalSQNR against a threshold. It is skipped without its environment variables.PR Review Checklist
Device, the x86 runner, lm_eval and PTE metadata sit behind a platform or adapter).examples/files are touched. Changes to merged Phase 2 code:InferenceOutputConfigfields are replaced byresults, andInferenceInputConfig.artifact_pathsbecomespte_paths.DeviceRunnerAdapterprotocol is request-typed, andDefaultDeviceRunnerAdapteris migrated to it.pte_file_name; the names are unchanged.Related PRs
Phase 2 flow.
PR-A1,PR-B1andPR-B2are merged.PR-A2depends onPR-B2and closes Phase 2 by wiring the runner and adding the parity test that gates the Phase 3 deletion of the legacy flow.Phase 1 (merged):
Phase 2:
Test plan
Run all
genai_pipelinetests:Result:
The skipped test is
test_llama_stories_260k_e2e.py, which needs its environment variables.Run all tests with coverage:
Result for the files this PR adds or changes:
The remaining uncovered lines:
cli.py:--list-models, theTokenizerWrappercall inside_load_runtime_tokenizer_path(patched in tests), and the model preparation / quantization stage construction from A1.model_lookup.py: mostly A1's model-config, source-transform and checkpoint-loading paths. This PR addsget_modality/validate_modality_inputs, which are not fully covered either.mllm_runner_adapter.py:130: a defensive branchgenerate_inputscannot reach with non-empty inputs.default_device_runner_adapter.pyis tested bytest_default_device_runner_adapter.pybut excluded from the report by.coveragerc. The package-wide total (79%) includes A1 modules outside this PR. Coverage will be raised to >=95% by the end of Phase 2.Confirm the legacy flow is unaffected:
Result: