Skip to content

Fix mutable default arguments and remove duplicate line in VLM models#130

Open
jashshah999 wants to merge 1 commit into
nvidia-cosmos:mainfrom
jashshah999:fix/mutable-defaults-and-duplicate-line
Open

Fix mutable default arguments and remove duplicate line in VLM models#130
jashshah999 wants to merge 1 commit into
nvidia-cosmos:mainfrom
jashshah999:fix/mutable-defaults-and-duplicate-line

Conversation

@jashshah999

Copy link
Copy Markdown

Summary

  • Replaced mutable dict default data_batch={} with data_batch=None (+ guard) in forward() across 4 VLM model files. Mutable defaults in Python are shared across all calls to the function, which can lead to unexpected shared state if the dict is ever modified in-place.
  • Removed duplicate attention_mask = data_batch.get("padding_mask", None) assignment in vlm_qwen_omni.py.

Files changed:

  • cosmos_predict2/_src/reason1/models/vlm_base.py
  • cosmos_predict2/_src/reason1/models/vlm_qwen.py
  • cosmos_predict2/_src/reason1/models/vlm_qwen_omni.py
  • cosmos_predict2/_src/predict2/text_encoders/reason1.py

- Replace mutable dict default `data_batch={}` with `data_batch=None` in `forward()` across VLM models. Mutable defaults are shared across all calls, which can lead to unexpected shared state if the dict is ever modified in-place.
- Remove duplicate `attention_mask = data_batch.get("padding_mask", None)` line in `vlm_qwen_omni.py`.

Signed-off-by: Jash Shah <jashshah.999@gmail.com>
@codeJRV codeJRV requested a review from asotoodeh-nv March 2, 2026 16:07
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