Skip to content

fix(models): use identity checks for output_type in MLXLM (#1997) - #2030

Open
Gopesh111 wants to merge 1 commit into
dottxt-ai:mainfrom
Gopesh111:fix/mlxlm-generate-batch-guard
Open

Gopesh111 wants to merge 1 commit into
dottxt-ai:mainfrom
Gopesh111:fix/mlxlm-generate-batch-guard

Conversation

@Gopesh111

Copy link
Copy Markdown

Purpose

Fixes #1997 where MLXLMTypeAdapter.format_output_type and MLXLM.generate_batch used truthiness checks (if output_type: / if not output_type:) instead of explicit identity checks (if output_type is None: / if output_type is not None:).

Using boolean truthiness checks causes falsy custom logits processors or objects (such as structures defining __len__ = 0) to be wrongly evaluated as None or skip unsupported batch argument assertions.

Test Plan

Added unit test test_mlxlm_type_adapter_format_output_type_none_and_falsy in tests/models/test_mlxlm_type_adapter.py verifying that format_output_type(None) returns None and format_output_type(falsy_obj) returns [falsy_obj].

Run pytest locally:

pytest tests/models/test_mlxlm_type_adapter.py

Signed-off-by: Gopesh111 <gopesh.22bce7700@vitapstudent.ac.in>

This branch has not been deployed

No deployments
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.generate_batch uses falsy guard (if output_type:) instead of identity check (if output_type is not None:)

1 participant