Hi, thanks for open-sourcing this project.
We encountered a performance issue when using PyTorch native Selective Activation Checkpointing (SAC) for a Transformer layer.
Our intended policy was:
- recompute the Transformer layer as a whole;
- save the All-to-All operation and exclude it from recomputation;
- recompute the remaining operations.
Conceptually, the SAC policy looked like this:
def policy_fn(ctx, op, *args, **kwargs):
if is_all_to_all(op):
return CheckpointPolicy.MUST_SAVE
return CheckpointPolicy.PREFER_RECOMPUTE
Unexpectedly, this selective configuration was slower than fully recomputing the entire Transformer layer, even though it avoided repeating the All-to-All operation.
Profiler analysis suggested that the workload became Host-bound. In particular, the per-operation TorchDispatchMode / policy callback path appeared to delay accelerator operator launches. The additional Host dispatch overhead outweighed the compute/communication saved by excluding All-to-All from recomputation.
Is this type of workload one of the main motivations for torch_remat?
Our understanding is that the equivalent configuration would be approximately:
def transformer_layer(x):
# Other operations recompute by default.
x = remat.region(
all_to_all_region,
"all_to_all",
recompute=False,
)(x)
return remaining_layer(x)
output = remat.checkpoint(
region_name="transformer_layer",
)(transformer_layer)(input)
Unlike native SAC, this makes the save/recompute decision at explicit callable-region boundaries rather than invoking a Python policy for every dispatched ATen operation.
We would like to confirm:
- Is avoiding per-ATen-op dispatch overhead a design goal of
torch_remat?
- Is wrapping the whole Transformer layer with
remat.checkpoint and marking only the All-to-All region with recompute=False the recommended configuration?
- Are there any benchmarks comparing the Host overhead of region-based rematerialization against native SAC?
- Are there recommended region granularities for Host-bound workloads?
Hi, thanks for open-sourcing this project.
We encountered a performance issue when using PyTorch native Selective Activation Checkpointing (SAC) for a Transformer layer.
Our intended policy was:
Conceptually, the SAC policy looked like this:
Unexpectedly, this selective configuration was slower than fully recomputing the entire Transformer layer, even though it avoided repeating the All-to-All operation.
Profiler analysis suggested that the workload became Host-bound. In particular, the per-operation
TorchDispatchMode/ policy callback path appeared to delay accelerator operator launches. The additional Host dispatch overhead outweighed the compute/communication saved by excluding All-to-All from recomputation.Is this type of workload one of the main motivations for
torch_remat?Our understanding is that the equivalent configuration would be approximately:
Unlike native SAC, this makes the save/recompute decision at explicit callable-region boundaries rather than invoking a Python policy for every dispatched ATen operation.
We would like to confirm:
torch_remat?remat.checkpointand marking only the All-to-All region withrecompute=Falsethe recommended configuration?