Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Padding-free gate tests: state that UNSLOTH_RETURN_LOGITS is unset (#11863)

Daniel Hane207e1e3aa2e
diff --git a/tests/test_padding_free_signature_gate.py b/tests/test_padding_free_signature_gate.py
index 175c8cc9327..d3213ed80de 100644
--- a/tests/test_padding_free_signature_gate.py
+++ b/tests/test_padding_free_signature_gate.py
@@ -25,6 +25,16 @@ except ImportError:
pytest.skip("unsloth.trainer is the MLX shim here", allow_module_level = True)
[email protected](autouse = True)
+def _return_logits_unset(monkeypatch):
+ """UNSLOTH_RETURN_LOGITS=1 blocks packing and padding-free outright, so with it set the
+ gate never runs and these tests see neither the refusal nor the metadata hook. Product
+ paths set it process-wide (for_inference, the eval prediction_step, zoo's compiler), and
+ an earlier test in the same xdist worker leaving it at "1" failed a different subset of
+ this file on each run. Tests that want it set still say so with monkeypatch.setenv."""
+ monkeypatch.delenv("UNSLOTH_RETURN_LOGITS", raising = False)
+
+
class _NoKwargs(nn.Module):
"""microsoft/Phi-4-reasoning-vision-15B's shape: no **kwargs, no packing."""