Commit 08573c0
authored
fix: Zero division in inverse estimator functions (#65)
#### Motivation
Fixes this warning:
```
packages/text_generation_server/utils/memory_characterizer.py:71: RuntimeWarning: invalid value encountered in scalar divide
Shard 0: return (np.sqrt(c0**2 + 4*c1*(mem/batch)) - c0)/(2*c1)
```
#### Modifications
When the memory characterizer doesn't find a linear or quadratic
behavior, the coefficients are set to zero resulting in division by zero
errors in the inverse functions.
In this commit this situation is detected and the max float is returned
to be consistent with the semantics of the memory estimator
Signed-off-by: Max de Bayser <mbayser@br.ibm.com>1 parent cc6e911 commit 08573c0
1 file changed
Lines changed: 6 additions & 2 deletions
Lines changed: 6 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
76 | | - | |
| 75 | + | |
| 76 | + | |
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| 83 | + | |
| 84 | + | |
83 | 85 | | |
84 | 86 | | |
85 | 87 | | |
| 88 | + | |
| 89 | + | |
86 | 90 | | |
87 | 91 | | |
88 | 92 | | |
| |||
0 commit comments