Skip to content

Fix undefined mask variable in TransformerTemporalModel.forward()#179

Open
Mr-Neutr0n wants to merge 1 commit intoTMElyralab:mainfrom
Mr-Neutr0n:fix/undefined-mask-variable
Open

Fix undefined mask variable in TransformerTemporalModel.forward()#179
Mr-Neutr0n wants to merge 1 commit intoTMElyralab:mainfrom
Mr-Neutr0n:fix/undefined-mask-variable

Conversation

@Mr-Neutr0n
Copy link

Summary

  • Fix a NameError caused by referencing an undefined mask variable in musev/models/temporal_transformer.py at line 301.
  • When vision_conditon_frames_sample_index is None (or keep_content_condition is False) and need_temporal_weight is False, the code falls into the else branch where mask was never defined — it is only created inside the if vision_conditon_frames_sample_index is not None and self.keep_content_condition block.
  • Since there is no vision conditioning in this branch, all frames are treated equally and no masking is needed. The fix changes residual + mask * hidden_states to residual + hidden_states.

Details

The four branches of the output computation should be:

vision_conditon_frames_sample_index need_temporal_weight Output
not None True residual + abs(temporal_weight) * mask * hidden_states
not None False residual + mask * hidden_states
None True residual + abs(temporal_weight) * hidden_states
None False residual + hidden_states (was: residual + mask * hidden_states — bug)

The first three branches are correct. The fourth incorrectly referenced mask which does not exist in that scope, causing a NameError at runtime.

Test plan

  • Verify the fix by reading the surrounding control flow to confirm mask is only assigned in the if branch
  • Run inference with need_temporal_weight=False and no vision conditioning frames to confirm no NameError

When vision_conditon_frames_sample_index is None and
need_temporal_weight is False, the code referenced an undefined
variable `mask`. The mask variable is only defined in the branch
where vision_conditon_frames_sample_index is not None.

Since in this else branch there is no vision conditioning, all frames
should be treated equally with no masking, so the output should simply
be residual + hidden_states.
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