Repository navigation
Conversation
The modulo check used num_blocks instead of block_size, so slices aligned to individual blocks (e.g. bd[:12, :12] with block_size=12) were incorrectly handled. Also, cross-block slices (row blocks != col blocks) fell through to block-level indexing instead of the generic path, producing non-square sub-blocks. Fix uses block_size for alignment checks, detects cross-block slices and falls back to the generic super()._getitem(), and selects blocks from the batch dimension rather than passing block indices as matrix row/col indices.
|
Thanks for picking this up! One concern: import torch
from linear_operator.operators import BlockInterleavedLinearOperator, DenseLinearOperator
torch.manual_seed(0)
op = BlockInterleavedLinearOperator(DenseLinearOperator(torch.randn(2, 4, 4))) # 8 x 8
print((op[0:4, 0:4].to_dense() - op.to_dense()[0:4, 0:4]).abs().max())
# main: tensor(0.) this PR: tensor(2.0447)The existing test suite passes with this PR because none of the generic Also, with a I opened #142, which moves the fast path to |
See cornellius-gp/gpytorch#2747 for the full analysis and reproduction.
The modulo check used num_blocks instead of block_size, so slices aligned to individual blocks were incorrectly handled. Cross-block slices fell through to block-level indexing instead of the generic path, producing non-square sub-blocks.
The fix switches to block_size for alignment checks, detects cross-block slices to fall back to the generic path, and selects blocks from the batch dimension rather than passing block indices as matrix row/col indices.