diffusion speed: make the fp16-accum kill switch case-insensitive
UNSLOTH_DISABLE_FP16_ACCUM is the documented safety escape hatch for fp16-accumulation numerical drift, but it was matched as .strip() in (1, true, yes) with no lowercasing, so UNSLOTH_DISABLE_FP16_ACCUM=TRUE (or YES / On) was silently ignored and fp16 accumulation stayed on. Lowercase before matching (the family-name check on the next line already does) and accept on. Existing 1/true/yes still match.
This commit is contained in:
parent
6154ecb618
commit
06ec3b34dc
2 changed files with 15 additions and 1 deletions
|
|
@ -374,7 +374,7 @@ def _enable_fp16_accumulation(
|
|||
process-wide flag to its prior value on unload."""
|
||||
import os
|
||||
|
||||
if os.environ.get("UNSLOTH_DISABLE_FP16_ACCUM", "").strip() in ("1", "true", "yes"):
|
||||
if os.environ.get("UNSLOTH_DISABLE_FP16_ACCUM", "").strip().lower() in ("1", "true", "yes", "on"):
|
||||
return False
|
||||
name = str(getattr(family, "name", family or "")).lower()
|
||||
if name in _FP16_ACCUM_DENY:
|
||||
|
|
|
|||
|
|
@ -427,6 +427,20 @@ def test_fp16_accum_respects_kill_switch(monkeypatch):
|
|||
assert applied["fp16_accum"] is False
|
||||
|
||||
|
||||
@pytest.mark.parametrize("value", ["TRUE", "Yes", "On", " true "])
|
||||
def test_fp16_accum_kill_switch_is_case_insensitive(monkeypatch, value):
|
||||
# The documented safety escape hatch must honor the common boolean spellings, not only
|
||||
# lowercase "1"/"true"/"yes": an operator setting UNSLOTH_DISABLE_FP16_ACCUM=TRUE to stop
|
||||
# fp16-accumulation drift would otherwise be silently ignored.
|
||||
_stub_torch_fp16_accum(monkeypatch, consumer = True)
|
||||
_stub_gguf_accel(monkeypatch)
|
||||
monkeypatch.setenv("UNSLOTH_DISABLE_FP16_ACCUM", value)
|
||||
applied = apply_speed_optims(
|
||||
_Pipe(), _target(), is_gguf = True, family = _family(), speed_mode = "default"
|
||||
)
|
||||
assert applied["fp16_accum"] is False
|
||||
|
||||
|
||||
def test_fp16_accum_respects_family_deny_list(monkeypatch):
|
||||
_stub_torch_fp16_accum(monkeypatch, consumer = True)
|
||||
_stub_gguf_accel(monkeypatch)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue