Thanks for posting the input values.
Did you make sure to properly copy the values, as you are changing the original array?
This script gives the same results for different values of K (of course you’ll get inf for too large values):
adj_prob = np.array([[0.0000, 0.1429, 0.1429, 0.1429, 0.1429, 0.1429, 0.1429, 0.1429],
    [0.2500, 0.0000, 0.2500, 0.2500, 0.0000, 0.0000, 0.0000, 0.2500],
    [0.2500, 0.2500, 0.0000, 0.2500, 0.0000, 0.0000, 0.0000, 0.2500],
    [0.2500, 0.2500, 0.2500, 0.0000, 0.0000, 0.0000, 0.0000, 0.2500],
    [0.5000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.5000, 0.0000],
    [0.5000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.5000, 0.0000],
    [0.3333, 0.0000, 0.0000, 0.0000, 0.3333, 0.3333, 0.0000, 0.0000],
    [0.2500, 0.2500, 0.2500, 0.2500, 0.0000, 0.0000, 0.0000, 0.0000]])

adj_prob_tensor = torch.from_numpy(adj_prob).clone()

K = 5

adj_k_prob = adj_prob
adj_k_pow =  adj_prob
for i in range(K):
    adj_k_pow = np.matmul(adj_prob, adj_k_pow)
    adj_k_prob += adj_k_pow


adj_k_prob_pt = adj_prob_tensor
adj_k_pow_pt = adj_prob_tensor
for i in range(K):
    adj_k_pow_pt = torch.matmul(adj_prob_tensor, adj_k_pow_pt)
    adj_k_prob_pt += adj_k_pow_pt

print(torch.abs(torch.from_numpy(adj_k_prob) - adj_k_prob_pt).max())
> tensor(0., dtype=torch.float64)