Skip to content

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

Description

@harsh4vardhan

MLXLMTypeAdapter.format_output_type (line 97) uses if not output_type instead of if output_type is None:

# mlxlm.py:97
def format_output_type(self, output_type=None):
    if not output_type:   # wrong: discards any processor where bool(processor) is False
        return None
    return [output_type]

If a logits processor subclass defines __bool__ returning False, the processor is silently discarded and generation proceeds unconstrained — no error raised. Every other model file uses the correct pattern (transformers.py, vllm.py, llamacpp.py, etc.).

Minimum example:

class FalsyProcessor:
    def __bool__(self): return False

def format_output_type_buggy(output_type=None):
    if not output_type:       # exact mlxlm.py code
        return None
    return [output_type]

p = FalsyProcessor()
print(p is None)                        # False
print(format_output_type_buggy(p))     # None — processor silently dropped

Fix: replace if not output_type: with if output_type is None:, consistent with every other model backend.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions