Skip to content

Fix double bracket indexing bug on Hermes noise model - #786

Merged
PabloCarmona merged 1 commit into
IBM:masterfrom
atvasilopoulos:hermes_model_indexing_bug
Sep 7, 2026
Merged

PabloCarmona merged 1 commit into
IBM:masterfrom
atvasilopoulos:hermes_model_indexing_bug

Conversation

@atvasilopoulos

Copy link
Copy Markdown
Collaborator

Description

Double brackets were used to index a torch tensor in the hermes noise model, leading to a UserWarning when using it. Fixed this by changing it to proper indexing.

Details

The following warning was raised when using the hermes noise model (model.program_analog_weights()).

UserWarning: Using a non-tuple sequence for multidimensional indexing is deprecated and will be changed in pytorch 2.9; use x[tuple(seq)] instead of x[seq]. In pytorch 2.9 this will be interpreted as tensor index, x[torch.tensor(seq)], which will result either in an error or a different result (Triggered internally at /__w/pytorch/pytorch/torch/csrc/autograd/python_variable_indexing.cpp:349.)
  g_relative[[g_relative >= 0.0945]],

Found 5 instances where this indexing pattern was used in the class. Single bracket solves the issue.

@PabloCarmona

Copy link
Copy Markdown
Collaborator

Hey @atvasilopoulos ! Could you add the authoring sign in to your commits so the DCO check passes? Thanks!

@PabloCarmona
PabloCarmona self-requested a review August 25, 2026 10:49
@PabloCarmona PabloCarmona added the bug Something isn't working label Aug 25, 2026
@atvasilopoulos
atvasilopoulos force-pushed the hermes_model_indexing_bug branch from b7cd145 to 3d0658b Compare September 7, 2026 11:44
Signed-off-by: atvasilopoulos <atv@zurich.ibm.com>
@atvasilopoulos
atvasilopoulos force-pushed the hermes_model_indexing_bug branch from 3d0658b to e6af049 Compare September 7, 2026 14:53

@PabloCarmona PabloCarmona left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@PabloCarmona
PabloCarmona merged commit b7113b3 into IBM:master Sep 7, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants