Skip to content

fix(mlxlm): check if output_type is None instead of truthiness - #1987

Open
Aryan-Pardeshi wants to merge 2 commits into
dottxt-ai:mainfrom
Aryan-Pardeshi:fix/mlxlm-identity-none-check
Open

fix(mlxlm): check if output_type is None instead of truthiness#1987
Aryan-Pardeshi wants to merge 2 commits into
dottxt-ai:mainfrom
Aryan-Pardeshi:fix/mlxlm-identity-none-check

Conversation

@Aryan-Pardeshi

Copy link
Copy Markdown

Fixes #1980

Context

In \src/outlines/models/mlxlm.py, \ ormat_output_type\ previously checked \if not output_type:. This causes issue #1980 when an \output_type\ object evaluates to \False\ in boolean context (e.g., custom processors/callables with _bool_\ returning \False).

Changes

  • Replaced \if not output_type:\ with \if output_type is None:\ in \MLXLMTypeAdapter.format_output_type, matching the standard pattern across all other model adapters.
  • Added unit tests in \ ests/models/test_mlxlm_type_adapter.py\ for both \None\ and falsy processor objects.

@RobinPicard RobinPicard left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, the fix itself looks good as it makes mlxlm consistent with the other adapters, so happy to merge it.

Could you remove the two added tests though? A falsy processor cannot actually occur here: everything that reaches format_output_type is either None or a logits processor instance that defines neither __bool__ nor __len__, so the FalsyProcessor case is synthetic. I'd rather keep the test suite focused on cases that can happen in practice.

Per review: format_output_type only ever receives None or a real logits
processor instance (defines neither __bool__ nor __len__), so a falsy
non-None processor can't occur in practice.
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.

mlxlm: MLXLMTypeAdapter.format_output_type uses falsy check instead of identity-None check

2 participants