Repository navigation
[GraphTrainer] Unified framework for activation memory management - #3118
Conversation
888ce61 to
97aeb9f
Compare
| """Log timing, op-count diffs, and before/after graphs for each pass to tlparse.""" | ||
|
|
||
| memory_policy: Literal["default", "eager"] = "default" | ||
| memory_policy: Literal["default", "eager", "cpu_offload_all"] = "default" |
There was a problem hiding this comment.
how should a user express a combination of offload + SAC
There was a problem hiding this comment.
I expect user to implement a policy_fn, and register it. The framework doesn't exist yet, but I expect something like this to work
@register_policy
def my_tagging_pass(gm)
...
We should provide our own, e.g. based on Sanket's ILP solver.
| _NOT_IN_LAYERS, | ||
| ) | ||
| from torchtitan.experiments.graph_trainer.cpu_offload import cpu_offload_pass | ||
| from torchtitan.experiments.graph_trainer.cpu_offload import ( |
There was a problem hiding this comment.
IIUC, cpu_offload_pass = tag_all_offloadable_activations + apply_cpu_offload_pass
In the current code, we didn't call cpu_offload_pass anymore. Shall we remove it? And we can also clean up the APIs in cpu_offload.py
| """Log timing, op-count diffs, and before/after graphs for each pass to tlparse.""" | ||
|
|
||
| memory_policy: Literal["default", "eager"] = "default" | ||
| memory_policy: Literal["default", "eager", "cpu_offload_all"] = "default" |
There was a problem hiding this comment.
same question: if user use "default", tag_all_offloadable_activations won't be called, then apply_cpu_offload_pass is a no-op?
There was a problem hiding this comment.
yes, it's ok to run a no-op pass.
There was a problem hiding this comment.
annotate_flex_attention_for_regional_inductor_pass is also an no-op pass for model not using flex
There was a problem hiding this comment.
so right now we can't have SAC and CPU offloading at the same time?
There was a problem hiding this comment.
yea, we don't have a policy_fn that would use SAC and CPU offload at the same time yet...
There was a problem hiding this comment.
added comment.
…policy_pass Introduce a unified tag_with_memory_policy_pass that tags forward nodes with MUST_SAVE, PREFER_RECOMPUTE, or MUST_CPU_OFFLOAD based on the configured memory policy. The pass pipeline now always runs apply_cpu_offload_pass and selective_activation_remat_pass after tagging (both are no-ops when no nodes are tagged). Add cpu_offload_all memory policy that offloads all eligible activations to CPU. This is a work-in-progress policy for development and testing. Add integration test for aot_fx_trace with cpu_offload_all.
97aeb9f to
c5a5e9d
Compare
Summary
tag_with_memory_policy_passthat unifies SAC and CPU offload tagging into a single pass, dispatching based onconfig.compile.memory_policycpu_offload_allmemory policy that tags all eligible activations for CPU offload (WIP, for dev/testing)apply_cpu_offload_passandselective_activation_remat_passalways run after tagging (no-ops when no nodes are tagged)Test plan
test_cpu_offload.py)test_passes.py)--compile.memory_policy cpu_offload_allcompletes successfully, logs show 40 activations offloaded (222.81 MB)aot_fx_trace_llama3_fsdp_tp_cpu_offload_all