Repository navigation
fix(dynamo): a dry run moves no weights - #5069
Open
cehongwang wants to merge 1 commit into
Open
cehongwang wants to merge 1 commit into
cehongwang wants to merge 1 commit into
Conversation
A dry run builds and runs no engine, but with offload_module_to_cpu it still moved weights: compile offloaded the module to the CPU, and compile_module moved the parts that run in PyTorch back to the GPU. On weights still on meta, which a dry run accepts, the move back raised "Cannot copy out of meta tensor"; on a GPU model, the dry run left the weights of its TensorRT parts on the CPU. CompilationSettings now turns offload_module_to_cpu off for a dry run, as the reporting path already does for its own dry runs, and compile and cross_compile_for_windows read it from the settings and skip the low-GPU-memory warning in a dry run.
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.
Description
A dry run builds and runs no engine, but with
offload_module_to_cpu=Trueit still moved weights:compileoffloaded the module to the CPU, andcompile_modulemoved the parts that run in PyTorch back to the GPU. Both consequences are reproduced by the new tests onmain:meta, which a dry run accepts on purpose (pre_export_loweringskips the meta-weights check, since a dry run only needs shapes), made the move back raise:CompilationSettings.__post_init__now turnsoffload_module_to_cpuoff whendryrunis set, as_reporting.pyalready does for its own dry runs.compileandcross_compile_for_windowsread the setting fromsettingsinstead of their argument, and skip the low-GPU-memory warning ("Consider setting offload_module_to_cpu=True") in a dry run, which builds no engine.Found while testing
low_memory(model_weights_on_meta=True)(#5005), whosecompile_settingsturn offload on: a dry run to inspect the partitions of a model built onmetacrashed.Type of change
Testing
torch 2.16.0.dev20261029, TensorRT 11.4, A40, Python runtime:
test_dry_run_moves_no_weightsandtest_dry_run_of_weights_on_metaintests/py/dynamo/partitioning/test_000_fast_partitioning.py, each with the fast and the global partitioner: all 4 fail onmain(a weight left on the CPU;Cannot copy out of meta tensor) and pass with the fix.test_000_fast_partitioning.py: 15 passed.test_000_global_partitioning.py,test_000_require_full_compilation.py,test_dryrun_stats_observable.py: 30 passed.test_low_memory.py,test_buffer_lifting.py: 91 passed.test_reporting_stages.py: 6 passed.test_003_cross_compile_for_windows.pyskips here (no TensorRT Windows library), so CI covers thecross_compile_for_windowschange.pre-commit: every hook passes except mypy's 4 "Untyped decorator" errors in_compiler.py, whichmainhas at the same lines.Checklist: