Skip to content

Commit

Permalink
fix --gradient_checkpointing (#13964)
Browse files Browse the repository at this point in the history
  • Loading branch information
stas00 committed Nov 11, 2021
1 parent 3d607df commit 77262ef
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 21 deletions.
8 changes: 1 addition & 7 deletions examples/research_projects/wav2vec2/run_asr.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,6 @@ class ModelArguments:
freeze_feature_extractor: Optional[bool] = field(
default=True, metadata={"help": "Whether to freeze the feature extractor layers of the model."}
)
gradient_checkpointing: Optional[bool] = field(
default=False,
metadata={
"help": "If True, use gradient checkpointing to save memory at the expense of slower backward pass."
},
)
verbose_logging: Optional[bool] = field(
default=False,
metadata={"help": "Whether to log verbose messages or not."},
Expand Down Expand Up @@ -352,7 +346,7 @@ def main():
model = Wav2Vec2ForCTC.from_pretrained(
model_args.model_name_or_path,
cache_dir=model_args.cache_dir,
gradient_checkpointing=model_args.gradient_checkpointing,
gradient_checkpointing=training_args.gradient_checkpointing,
vocab_size=len(processor.tokenizer),
)

Expand Down
8 changes: 1 addition & 7 deletions examples/research_projects/wav2vec2/run_common_voice.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,6 @@ class ModelArguments:
"vectors will be masked along the time axis. This is only relevant if ``apply_spec_augment is True``."
},
)
gradient_checkpointing: Optional[bool] = field(
default=True,
metadata={
"help": "If True, use gradient checkpointing to save memory at the expense of slower backward pass."
},
)
layerdrop: Optional[float] = field(default=0.0, metadata={"help": "The LayerDrop probability."})


Expand Down Expand Up @@ -373,7 +367,7 @@ def extract_all_chars(batch):
hidden_dropout=model_args.hidden_dropout,
feat_proj_dropout=model_args.feat_proj_dropout,
mask_time_prob=model_args.mask_time_prob,
gradient_checkpointing=model_args.gradient_checkpointing,
gradient_checkpointing=training_args.gradient_checkpointing,
layerdrop=model_args.layerdrop,
ctc_loss_reduction="mean",
pad_token_id=processor.tokenizer.pad_token_id,
Expand Down
8 changes: 1 addition & 7 deletions examples/research_projects/wav2vec2/run_pretrain.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,6 @@ class ModelArguments:
freeze_feature_extractor: Optional[bool] = field(
default=True, metadata={"help": "Whether to freeze the feature extractor layers of the model."}
)
gradient_checkpointing: Optional[bool] = field(
default=False,
metadata={
"help": "If True, use gradient checkpointing to save memory at the expense of slower backward pass."
},
)
verbose_logging: Optional[bool] = field(
default=False,
metadata={"help": "Whether to log verbose messages or not."},
Expand Down Expand Up @@ -370,7 +364,7 @@ def normalize(batch):
config = Wav2Vec2Config.from_pretrained(
model_args.model_name_or_path,
cache_dir=model_args.cache_dir,
gradient_checkpointing=model_args.gradient_checkpointing,
gradient_checkpointing=training_args.gradient_checkpointing,
)

if not config.do_stable_layer_norm or config.feat_extract_norm != "layer":
Expand Down

0 comments on commit 77262ef

Please sign in to comment.