Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed May 2, 2024
1 parent 20dae4a commit 7d52560
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion examples/asr/transcribe_speech.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ def autocast(dtype=None):
# ctx.__enter__()
torch.cuda.cudart().cudaProfilerStart()
import time

start_time = time.time()
# assert all(param.requires_grad for param in asr_model.parameters())
transcriptions = asr_model.transcribe(audio=filepaths, override_config=override_cfg,)
Expand All @@ -431,7 +432,6 @@ def autocast(dtype=None):
# ctx.__exit__(None, None, None)
torch.cuda.cudart().cudaProfilerStop()


if cfg.dataset_manifest is not None:
logging.info(f"Finished transcribing from manifest file: {cfg.dataset_manifest}")
if cfg.presort_manifest:
Expand Down
2 changes: 1 addition & 1 deletion nemo/collections/asr/models/ctc_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ def _transcribe_output_processing(self, outputs, trcfg: TranscribeConfig) -> Gen
# See comment in
# ctc_greedy_decoding.py::GreedyCTCInfer::forward() to
# understand this idiom.

# This is way way wayyyyy too slow. A single
# cudaHostAlloc takes an average of 10ms if the
# caching allocator fails to return an
Expand Down
1 change: 0 additions & 1 deletion nemo/collections/asr/parts/mixins/transcription.py
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,6 @@ def _transcribe_on_begin(self, audio, trcfg: TranscribeConfig):
# assert all(param.requires_grad for param in self.parameters())
# import ipdb; ipdb.set_trace()


def _transcribe_on_end(self, trcfg: TranscribeConfig):
"""
Internal function to teardown the model after transcription. Perform all teardown and post-checks here.
Expand Down
5 changes: 3 additions & 2 deletions nemo/collections/asr/parts/submodules/multi_head_attention.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,14 @@ def forward(self, query, key, value, mask, pos_emb, cache=None):

# temporary until we solve this more gracefully
from contextlib import nullcontext
with nullcontext(): # avoid_float16_autocast_context():

with nullcontext(): # avoid_float16_autocast_context():
q, k, v = self.forward_qkv(query, key, value)
q = q.transpose(1, 2) # (batch, time1, head, d_k)

n_batch_pos = pos_emb.size(0)
# embedding is not affected by autocast. Ignore for now...

# Could make a custom torch.nn.Module that checks if we're
# in inference mode, and then caches its own weights'
# casted versions that way...
Expand Down

0 comments on commit 7d52560

Please sign in to comment.