AssertionError: 到达无法到达的条件 (执行了 RERAISE 操作码), batch_size > 1
System Information: - Operating System: Ubuntu 24.04.1 - Numba version: 0.61.0 - NumPy version: 2.1.3 - Python version: 3.12.3 Description: I encountered an internal Numba error when running matrix operations with batch sizes larger than 1. The error occurs in a JIT-compiled function that performs matrix inversion operations. The code works fine with batch_size=1 but fails with batch_size=10 or larger. The error message indicates this is an internal Numba issue: "This should not have happened, a problem has occurred in Numba's internals." Steps to Reproduce: 1. Run the attached code 2. The code runs successfully with batch_size=1 3. The code fails with batch_size=10 with an "Unreachable condition reached" error Code to reproduce: Python import numpy as np import numba as nb @nb.njit(fastmath=True) def matrix_update(feature_matrix, A_inv, temp_arrays): """ JIT-compiled function that focuses on matrix inversion operations which likely cause the Numba error """ batch_size, n_features = feature_matrix.shape # Unpack temporary arrays lambda_A_inv_feat_T, M, M_inv = temp_arrays # Compute A_inv @ feature_matrix.T for j in range(n_features): for i in range(batch_size): val = 0.0 for k in range(n_features): val += A_inv[j, k] * feature_matrix[i, k] lambda_A_inv_feat_T[j, i] = val # Compute M = I + feature_matrix @ A_inv @ feature_matrix.T for i in range(batch_size): for j in range(batch_size): if i == j: M[i, j] = 1.0 # Identity matrix diagonal else: M[i, j] = 0.0 # Zero off-diagonal elements for i in range(batch_size): for j in range(batch_size): for k in range(n_features): M[i, j] += feature_matrix[i, k] * lambda_A_inv_feat_T[k, j] # Matrix inversion - this is likely where the error happens # Reset M_inv to zeros for i in range(batch_size): for j in range(batch_size): M_inv[i, j] = 0.0 # Handle different batch sizes with explicit code paths if batch_size == 1: # Direct inversion for 1x1 matrices M_inv[0, 0] = 1.0 / M[0, 0] elif batch_size == 2: # 2x2 matrix inversion det = M[0, 0] * M[1, 1] - M[0, 1] * M[1, 0] if abs(det) > 1e-10: M_inv[0, 0] = M[1, 1] / det M_inv[0, 1] = -M[0, 1] / det M_inv[1, 0] = -M[1, 0] / det M_inv[1, 1] = M[0, 0] / det else: # Fallback to diagonal regularization for i in range(batch_size): M_inv[i, i] = 1.0 / (M[i, i] + 1e-8) else: # Simplified approach for larger matrices try: # Simple regularized diagonal approach for i in range(batch_size): M_inv[i, i] = 1.0 / (M[i, i] + 1e-8) except: # Fallback - just in case for i in range(batch_size): M_inv[i, i] = 1.0 / (M[i, i] + 1e-8)
内容来源: numba/numba