-
Notifications
You must be signed in to change notification settings - Fork 411
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: remove PyTorch 2.5.0 checks #1877
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -33,7 +33,7 @@ class OffloadActivations(saved_tensors_hooks): | |||||
use_streams (Optional[bool]): Whether or not to use streams for performance optimization where | ||||||
the communications get overlapped with the computation. Requires a torch build | ||||||
after torch-2.5.0.dev20240907. Default: True if a later torch build is found, else False. | ||||||
after torch-2.5.0.]. Default: True. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
max_fwd_stash_size (int): The maximum size of the forward stash, or the maximum number of | ||||||
consecutive activations to keep alive during the forward pass. This number must be at | ||||||
|
@@ -60,7 +60,7 @@ class OffloadActivations(saved_tensors_hooks): | |||||
def __init__( | ||||||
self, | ||||||
use_pin_memory: bool = True, | ||||||
use_streams: Optional[bool] = None, | ||||||
use_streams: Optional[bool] = True, | ||||||
max_fwd_stash_size: int = 5, | ||||||
min_offload_size: int = 1024, | ||||||
) -> None: | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,23 +42,21 @@ def compile_model( | |
backend = os.environ.get("TORCH_COMPILE_BACKEND", "inductor") | ||
if isinstance(model, DeepFusionModel): | ||
model = model.decoder | ||
if torch_version_ge("2.5.0"): | ||
if verbose: | ||
log.info("Compiling model layers with torch.compile...") | ||
for m in reversed(list(model.modules())): | ||
if isinstance(m, TransformerSelfAttentionLayer) or isinstance( | ||
m, TransformerCrossAttentionLayer | ||
): | ||
m.compile(backend=backend) | ||
else: | ||
# Per-layer compilation by default | ||
if verbose: | ||
log.info("Compiling model layers with torch.compile...") | ||
for m in reversed(list(model.modules())): | ||
if isinstance(m, TransformerSelfAttentionLayer) or isinstance( | ||
m, TransformerCrossAttentionLayer | ||
): | ||
m.compile(backend=backend) | ||
# Fallback for models that can't be per-layer compiled | ||
if not torch_version_ge("2.5.0"): | ||
if verbose: | ||
log.info( | ||
""" | ||
Compiling full model with torch.compile... | ||
For faster compile times via per-layer compile, please run on PyTorch nightlies. | ||
""" | ||
log.warning( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if we want to retain the fallback logic for older pytorch versions. If so, then the if-else should remain the same and only the warning message should be updated. any thoughts? @ebsmothers @felipemello1 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry just seeing this now. I think if we claim to not support PyTorch < 2.5 then we shouldn't leave in the full-model compile option at all. For the same reason I'm ambivalent about leaving in the log warning.. really if we want to check someone is at least on the latest stable PyTorch we should just do it in a single consolidated place. So not the end of the world to keep the warning in, but personally I'd just take it out. |
||
"Per-layer compilation may not be fully optimized in PyTorch versions < 2.5.0. " | ||
"Consider upgrading for improved performance." | ||
) | ||
model.compile(backend=backend) | ||
|
||
|
||
def compile_loss(loss: nn.Module, verbose: bool = True) -> None: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.