fix: give each translation worker its share of the CPUs
Translate runs NumCPU/2 sentence workers and each of them started GOMAXPROCS goroutines for the logit projection of every step: on 16 cores, 128 goroutines fighting for 16 cores. The model now caps the goroutines of a step (SetThreads, called once after Load) so that workers x threads stays within the machine.
This commit is contained in:
1 parent
d6ee57130f
commit
82bfef8cba
4 files changed
+26
-7
No files matched your search
@@ -212,6 +212,9 @@ func (m *Model) decodeStep(b *beam, crossK, crossV [][]float32, srcLen int, s *d
|
||||
func (m *Model) logProbs(hidden, out [][]float32) [][]float32 {
|
||||
d, vocab := m.cfg.DModel, m.cfg.VocabSize
|
||||
workers := runtime.GOMAXPROCS(0)
|
||||
if m.threads > 0 {
|
||||
workers = min(workers, m.threads)
|
||||
}
|
||||
chunk := (vocab + workers - 1) / workers
|
||||
var wg sync.WaitGroup
|
||||
for lo := 0; lo < vocab; lo += chunk {
|
||||
|
||||
Reference in new issue
Block a user