Skip to content

fix: Pin expected tensor to same device in online retrieval test - #6777

Open
piyush182004 wants to merge 2 commits into
feast-dev:masterfrom
piyush182004:fix/tensor-device-mismatch-cuda-test
Open

fix: Pin expected tensor to same device in online retrieval test#6777
piyush182004 wants to merge 2 commits into
feast-dev:masterfrom
piyush182004:fix/tensor-device-mismatch-cuda-test

Conversation

@piyush182004

@piyush182004 piyush182004 commented Aug 24, 2026

Copy link
Copy Markdown

ISSUE FIXED:- #6778

What this PR does / why we need it:

test_get_online_features computes device from torch.cuda.is_available()
and passes it when building the expected tensors for driver_id and trips,
but the avg_orders_day assertion omits it.

OnlineResponse.to_tensor() places its output on cuda when a GPU is present
(sdk/python/feast/online_response.py), so on a GPU host the expected tensor
stays on cpu and torch.equal raises:

RuntimeError: Expected all tensors to be on the same device, but got other is
on cpu, different from other tensors on cuda:0
(when checking argument in method wrapper_CUDA__equal)

CI runs CPU-only, where device resolves to "cpu" and the omission has no
effect — so this only reproduces on machines with CUDA available.

Verified on a CUDA host (RTX 4050), same machine and same code, varying only
GPU visibility:

CUDA_VISIBLE_DEVICES="" GPU visible
before passes fails
after passes passes

Full unit suite after the change: 2635 passed, 44 skipped.

Which issue(s) this PR fixes:

Checks

  • I've made sure the tests are passing.
  • My commits are signed off (git commit -s)
  • My PR title follows conventional commits format

Testing Strategy

  • Unit tests

test_get_online_features computes `device` from torch.cuda.is_available()
and passes it when building the expected tensors for `driver_id` and
`trips`, but the `avg_orders_day` assertion omits it.

OnlineResponse.to_tensor() places its output on cuda when a GPU is
present (sdk/python/feast/online_response.py), so on a GPU host the
expected tensor stays on cpu and torch.equal raises:

    RuntimeError: Expected all tensors to be on the same device, but got
    other is on cpu, different from other tensors on cuda:0
    (when checking argument in method wrapper_CUDA__equal)

CI runs CPU-only, where `device` resolves to "cpu" and the omission has
no effect, so this only reproduces on machines with CUDA available.

Verified on a CUDA host: the unmodified test fails with the GPU visible
and passes under CUDA_VISIBLE_DEVICES="", while the patched test passes
in both cases.

Signed-off-by: Piyush Mondal <piyushmondal182004@gmail.com>
@piyush182004
piyush182004 requested a review from a team as a code owner August 24, 2026 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant