BentoML
BentoML copied to clipboard
bug: incorrectly rounded float output
Describe the bug
When I retrieve a float number as output, it appears to be inaccurately rounded.
@svc.api(input=NumpyNdarray(), output=NumpyNdarray(dtype=np.float32))
async def predict(arr: np.ndarray) -> float:
return np.round(25.1234, 2)
The response is:
25.1200008392334
I haven't had the opportunity to review the code and identify the specific issue yet. I will provide an update to this ticket as soon as I can isolate the error.
To reproduce
Steps to reproduce the bug:
- build a bento with:
@svc.api(input=NumpyNdarray(), output=NumpyNdarray(dtype=np.float32))
async def predict(arr: np.ndarray) -> float:
return np.round(25.1234, 2)
- serve it
- curl -X POST http://0.0.0.0:3000/predict -d '[0]'
Expected behavior
Get 25.12
returned
Environment
python: 3.11 bentoml: 1.1.9