Skip to content

Bug: mask.py uses logging.warning without importing logging module #523

@lencrouse

Description

@lencrouse

Bug

chatterbox/models/s3gen/utils/mask.py at line 162 calls logging.warning(...), but the module does not import logging. The safety fixup is dead code that would crash with NameError: name 'logging' is not defined if the all-False chunk_masks edge case ever fires.

Location

src/chatterbox/models/s3gen/utils/mask.py, around line 160-163:

if (chunk_masks.sum(dim=-1) == 0).sum().item() != 0:
    logging.warning('get chunk_masks all false at some timestep, force set to true, make sure they are masked in futuer computation!')
    chunk_masks[chunk_masks.sum(dim=-1)==0] = True

Suggested fix

Add import logging at the top of mask.py.

Also note: there's a typo in the warning message — futuer should be future. Optional, but might be worth fixing in the same PR.

How we found it

Discovered while doing a CoreML export of Chatterbox Multilingual for an iOS-native voice synthesis project. The if-branch on a data-dependent condition causes torch.export strict-mode to fail with GuardOnDataDependentSymNode. While building a torch.where semantic-equivalent replacement, ran a verification harness comparing upstream vs. refactor across cases where the condition does and does not fire — and the upstream function crashes with NameError instead of the intended warning + fixup behavior when the condition fires.

For typical valid inputs the condition shouldn't fire, so this hasn't caused observable failures in normal use — but a malformed token_len input would produce a confusing NameError instead of either the intended warning or a clean fallback.

Happy to send a PR if helpful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions