Avoid copying output from GPU to CPU for ASR runner #16235
+131
−14
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 adds the ability to skip copying GPU outputs back to CPU for specific methods in the CUDA backend, and enables conditional CUDA compilation for the ASR runner.
Changes
CUDA Backend (
backends/cuda/runtime/cuda_backend.cpp)skip_copy_output_to_cpu_for_methodbackend option from a boolean to a string that accepts a method nameset_option()afterinit()is called, allowing runtime configurationexecute(), the backend compares the configured method name against the handle's method name to decide whether to skip the GPU→CPU output copyUsage example:
AOTI Delegate Handle (
backends/aoti/aoti_delegate_handle.h)method_namefield toAOTIDelegateHandleto track which method each delegate handle corresponds toASR Runner CMake (
extension/asr/runner/CMakeLists.txt)EXECUTORCH_BUILD_CUDAis enabled andCUDAToolkitis found, theCUDA_AVAILABLEcompile definition is addedMotivation
When running multi-method models (e.g., prefill + decode for LLMs, or encoder + decoder for ASR), some methods benefit from keeping outputs on GPU to avoid unnecessary memory copies between methods. This change enables fine-grained control over which method(s) skip the GPU→CPU copy.
Test Plan
skip_copy_output_to_cpu_for_methodoption works for specified method