Imageomics / Imageomics/saev

Incorrect shape assertion in test_decode_prefixes_device_handling

Open
#23 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
66
Forks
12
PR merge metrics
No merged PRs in 30d

Description

## Bug Description

The test `test_decode_prefixes_device_handling` in `tests/test_nn_objectives.py` has an incorrect shape assertion on line 491.

## Current Code
```python
f_x = torch.randn(2, 32).cuda()
prefixes = torch.tensor([8, 16, 32])
x_hats = sae.decode(f_x, prefixes=prefixes)
assert x_hats.shape == (3, 2, 16) # BUG: Wrong shape!
```

## Expected Behavior

The `decode` method returns tensors with shape `(batch, n_prefixes, d_model)`. Given:
- batch_size = 2
- n_prefixes = 3
- d_model = 16

The correct shape should be `(2, 3, 16)` not `(3, 2, 16)`.

## Impact

This test is currently skipped on systems without CUDA, so the bug hasn't been caught by CI. However, on CUDA-enabled systems, this test would fail.

## Fix

Change line 491 from:
```python
assert x_hats.shape == (3, 2, 16)
```

to:
```python
assert x_hats.shape == (2, 3, 16)
```

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Open tests/test_nn_objectives.py and inspect test_decode_prefixes_device_handling around line 491, including the expected decode shape. Run the test on a CUDA-enabled system and update the assertion so it matches the documented (batch, n_prefixes, d_model) order.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning, testing-qa
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.