Weight offloading API surface (CUDA backend)#19711
Draft
mergennachin wants to merge 1 commit into
Draft
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/19711
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 New Failure, 53 Pending, 3 Unrelated Failures, 3 Unclassified FailuresAs of commit 1a0ca10 with merge base 54f1f28 ( UNCLASSIFIED FAILURES - DrCI could not classify the following jobs because the workflow did not run on the merge base. The failures may be pre-existing on trunk or introduced by this PR:
FLAKY - The following jobs failed but were likely due to flakiness present on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
bb0b1ca to
f7a8396
Compare
Design-only PR for CUDA-backend weight offloading: weights live in
CPU memory, the runtime streams only the currently-needed ones to GPU
through a capped cudaMemPool. Headers and docstrings only -- no
implementation bodies, no caller, no wiring on the partitioner or
runtime side. All four design files are marked
``EXPERIMENTAL -- NOT YET WIRED``.
Public knobs (``CudaPartitioner(weight_offload=True, ...)`` and the
``weight_offload_budget_mb`` runtime spec) are intentionally NOT
exposed in this PR; they ship with the implementation. Four open
items block wiring and are documented inline:
* Probe op preservation -- an identity custom op with
``mutates_args=()`` is a DCE target through inductor; the
implementation PR must give probe non-elidable semantics that
don't trip torch.export's parameter-output validation, plus a
test that asserts the lowered AOTI wrapper actually emits the
probe calls.
* AOTI blob layout -- ``WeightCatalog::build`` needs per-constant
offsets and dtype/shape. AOTI doesn't expose either today;
implementation PR must either land upstream shims or serialize
the metadata into the offload payload at export time.
* Payload transport channel -- the pass has to run from
``AotiBackend.preprocess`` (the partitioner contract forbids
mutating the ExportedProgram from ``partition()``); the
implementation PR picks between ``processed_bytes`` and a
per-method ``NamedDataStore`` entry.
* Schedule / cursor order -- the runtime cursor hard-fails on a
mismatch against the recorded schedule, but the pass observes
parameter order before inductor lowering reorders / duplicates
reads. Implementation PR either regenerates the schedule from
the post-lowering wrapper or extends probe with a self-identifying
``probe_id`` / FQN arg so no cursor is needed.
Read order:
backends/cuda/passes/weight_offload_pass.py -- export half
backends/cuda/runtime/weight_offload/weight_offload.h -- runtime
backends/cuda/runtime/weight_offload/probe_op.h -- c-shim
backends/cuda/runtime/weight_offload/prefetcher.h -- copy stream
See: #19709
f7a8396 to
1a0ca10
Compare
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.
Weight offloading design surface (CUDA backend)
Design-only PR for CUDA-backend weight offloading: weights live in
CPU memory, the runtime streams only the currently-needed ones to GPU
through a capped cudaMemPool. Headers and docstrings only -- no
implementation bodies, no caller, no wiring on the partitioner or
runtime side. All four design files are marked
EXPERIMENTAL -- NOT YET WIRED.Public knobs (
CudaPartitioner(weight_offload=True, ...)and theweight_offload_budget_mbruntime spec) are intentionally NOTexposed in this PR; they ship with the implementation. Two open items
block wiring and are documented inline:
Probe op preservation -- an identity custom op with
mutates_args=()is a DCE target through inductor; theimplementation PR must give probe non-elidable semantics that
don't trip torch.export's parameter-output validation, plus a
test that asserts the lowered AOTI wrapper actually emits the
probe calls.
AOTI blob layout --
WeightCatalog::buildneeds per-constantoffsets and dtype/shape. AOTI doesn't expose either today;
implementation PR must either land upstream shims or serialize
the metadata into the partition payload at export time.
Read order:
backends/cuda/passes/weight_offload_pass.py -- export half
backends/cuda/runtime/weight_offload/weight_offload.h -- runtime
backends/cuda/runtime/weight_offload/probe_op.h -- c-shim
backends/cuda/runtime/weight_offload/prefetcher.h -- copy stream
See: #19709