Repository navigation
docs: CPU compilation and resource partitioning in the resource management guide - #4858
Draft
cehongwang wants to merge 4 commits into
Draft
cehongwang wants to merge 4 commits into
cehongwang wants to merge 4 commits into
Conversation
…budget, offload_module_to_cpu and CPU-created tensors, autocast error text
…literals, paragraph split)
…he unreproduced run-time-tensor caveat
6 tasks
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
Documents two ways to lower compile-time memory that work today, in
docsrc/tutorials/resource_memory/resource_management.rst:ExportedProgramwith GPU inputs. TensorRT takes weights from host memory and the converters pass a CPU weight's own memory, so the model never has a GPU copy. Unlikeoffload_module_to_cpu, no host copy is added. Also covered:.cuda()the compiled module needs when some layers run in PyTorch, and the three reasons a layer can stay in PyTorch;offload_module_to_cpu=Trueas an alternative to that.cuda();torch_tensorrt.compile(nn.Module)doesn't accept a model on the CPU, so the guide usestorch.export+torch_tensorrt.dynamo.compile;torch.autocast("cpu", ...).enable_resource_partitioning/cpu_memory_budget, and how the per-engine budget is derived. That includes the RSS caveat: on a CPU-compiled model, RSS already holds the weights. Also covered: the default budget, a link to thelow_cpu_memory_compilationexample, and the memory cost when a split cuts through weights reused across an unrolled loop.docsrc/contributors/partitioning.rst: "negligible runtime cost" now notes that exception.Measured
pi0.5 (lerobot, bf16, about 3B parameters, 10-step unrolled denoising loop, Anthony Shoumikhin's ExecuTorch export), A40, TensorRT 11.0, load phase excluded:
The CPU-compilation snippet was run on
main, both with a PyTorch fallback (defaultmin_block_size, so the toy model stays in PyTorch) and fully converted (min_block_size=1). Outputs match eager. Without.cuda(), the fallback case fails with a device mismatch, which is why the guide includes it. Withoffload_module_to_cpu=Trueinstead of.cuda(), the fallback case runs and matches eager.Checked on
main:torch_tensorrt.compile(cpu_module, ir="dynamo")fails withFakeTensorDeviceMismatchError, with CPU or CUDA example inputs.torch.arange) on a layer left to PyTorch fails with a device mismatch. I couldn't reproduce that: six variants pass, with static and dynamic batch, and with.cuda()oroffload_module_to_cpu=True. So the caveat is gone.Both pages parse. The two heading-level errors docutils reports in
partitioning.rstare already onmain.Related settings in review, each documented in its own PR: #4853 (
release_weights_after_build), #4854 (map_weights), #4855 (resource_partition_engine_cap).Type of change
Checklist: