Just to clarify, match_matrix contains these invalid values (9223372034707292159) sometimes and lets topk crash.
If that’s the case, it seems that bboxoverlaps is creating wrong results sometimes and I would suggest to check the indexing in the method.