kaldi-asr / kaldi-asr/kaldi

Very slow xvector computation with all time spend on compilation

Open
#4,271 11 comments 0 reactions 0 assignees View on GitHub
bug stale
Dominant language
Shell
Stars
15.5k
Forks
5.4k
PR merge metrics
No merged PRs in 30d

Description

While running Voxceleb with different architectures I noticed that xvector extraction is very slow:

```
nnet3-xvector-compute --verbose=0 --use-gpu=no --min-chunk-size=25 --chunk-size=10000 \
--cache-capacity=64 "nnet3-copy \
--nnet-config=exp/xvector_nnet_1a/extract.config \
exp/xvector_nnet_1a/final.raw - |" "ark:apply-cmvn-sliding \
--norm-vars=false --center=true --cmn-window=300 \
scp:feats.scp ark:- | select-voiced-frames \
ark:- scp,s,cs:data/voxceleb1_test/split20/1/vad.scp ark:- |" \
ark,scp:exp/xvector_nnet_1a/xvectors_voxceleb1_test/xvector.1.ark,exp/xvector_nnet_1a/xvectors_voxceleb1_test/xvector.1.scp
...
LOG (nnet3-xvector-compute[5.5.802~1-8d0c8]:main():nnet3-xvector-compute.cc:182) Chunk size of 10000 is greater than the number of rows in utterance: id10270-5r0dWxy17C8-00008, using chunk size of 1136
LOG (nnet3-xvector-compute[5.5.802~1-8d0c8]:main():nnet3-xvector-compute.cc:182) Chunk size of 10000 is greater than the number of rows in utterance: id10270-5r0dWxy17C8-00009, using chunk size of 812
LOG (nnet3-xvector-compute[5.5.802~1-8d0c8]:main():nnet3-xvector-compute.cc:182) Chunk size of 10000 is greater than the number of rows in utterance: id10270-5r0dWxy17C8-00010, using chunk size of 456
LOG (nnet3-xvector-compute[5.5.802~1-8d0c8]:main():nnet3-xvector-compute.cc:182) Chunk size of 10000 is greater than the number of rows in utterance: id10270-5r0dWxy17C8-00011, using chunk size of 420
....

LOG (nnet3-xvector-compute[5.5.669~1-b1d80]:main():nnet3-xvector-compute.cc:182) Chunk size of 10000 is greater than the number of rows in utterance: id10270-5r0dWxy17C8-00019, using chunk size of 764
LOG (select-voiced-frames[5.5.669~1-b1d80]:main():select-voiced-frames.cc:106) Done selecting voiced frames; processed 19 utterances, 0 had errors.
LOG (nnet3-xvector-compute[5.5.669~1-b1d80]:main():nnet3-xvector-compute.cc:238) Time taken 15.0148s: real-time factor assuming 100 frames/sec is 0.108457
LOG (nnet3-xvector-compute[5.5.669~1-b1d80]:main():nnet3-xvector-compute.cc:241) Done 19 utterances, failed for 0
LOG (nnet3-xvector-compute[5.5.669~1-b1d80]:~CachingOptimizingCompiler():nnet-optimize.cc:710) 12.9 seconds taken in nnet3 compilation total (breakdown: 12.7 compilation, 0.0195 optimization, 0 shortcut expansion, 0.0045 checking, 2.86e-06 computing indexes, 0.108 misc.) + 0 I/O.
```

Note that from 15.0148s of execution 12.7 were spent on compilation. Profiler confirms the issue, only 10% is in actual neural network computation.

It seems to be related to variable length of the chunks because if I submit chunks of equal size with --min-chunk-size=400 --chunk-size=400, the computation is much faster and compilation is done only once.

I wonder what is the proper approach to speedup this:

1. Fix something internally inside compilation so it will not compute again and again
2. Cluster on chunks of fixed width (probably use 100 frames steps - 100, 200, ...10000). Then such compilations will be cached more effectively.
3. I see there is also nnet3-xvector-compute-batched, but it also suffers from this issue. Is it supposed to work faster?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.