Closed alvations closed 1 year ago
This makes sense @alvations but what is the specific use case you are trying here? The current implementations should be working with current models implementation
The bug shouldn't impact normal COMET users using the model off-the-shelves. It was found after stress testing modules in the library.
But in any case, the cache should at least assert the 2-D nature just in case users made some changes to the model / inputs.
Ok got it. I'll work on it
Thank you for the commit!!
I also released version 2.0.1 which includes this already. Enjoy!
🐛 Bug
The
tensor_lru_cache
assumes tensor diagonals because ofx.diagonal().__repr__()
in_make_key
. To support robust tensor caching, it's best to check for size before callingrepr(diagonal())
.To Reproduce
This works as expected:
[out]:
This works too:
[out]:
This fails because the tensor is 1-D
[out]:
Expected behaviour
[out]:
Suggested solution
At https://github.com/Unbabel/COMET/blob/master/comet/models/lru_cache.py#L52 this change would fix the issue:
Otherwise checking that it's >= 2-D would work too, e.g.
Note: Calling
__repr__
in a singlenew_args.append(x.__repr() + "\n" ...)
would also increase cache hits but for bevity and readability in this issue, I've usedrepr
.