When torch.use_deterministic_algorithms(True) is enabled, make topk resolve tied values with stable index tie-breaking.
CPU topk now compares by value and then index in deterministic mode. CUDA keeps the existing top-k selection path and uses stable sorting for the selected top-k outputs so threshold ties preserve input-index order without falling...