ci: make compiler-cache shim test order-independent (#5449)
The shim test_compile_real_modeling_module[*] was failing on all three RMSNorm families (llama / qwen3 / gemma3) on the Core 4.57.6 matrix cell because the preceding test_compile_every_transformers_ model_type sweep already invokes unsloth_compile_transformers for every model_type, which sets modeling.__UNSLOTH_PATCHED__ = True. unsloth_zoo.compiler.unsloth_compile_transformers (zoo compiler.py :3318-3324) early-returns when that marker is already set, without re-emitting the cache file. The targeted shim test then asserts the file exists and fails with "compiler did not write" against the temp cache path. Drop the unsloth-added marker (and any leftover cache file from the sweep) before invoking the compile so the test exercises a fresh emit regardless of collection order. Marker-only fix -- transformers version-agnostic (works on 4.57.6 + 5.x); does not touch zoo internals.
This commit is contained in:
parent
3f8c672636
commit
e0e606a24a
1 changed files with 14 additions and 3 deletions
17
.github/workflows/consolidated-tests-ci.yml
vendored
17
.github/workflows/consolidated-tests-ci.yml
vendored
|
|
@ -1032,16 +1032,28 @@ jobs:
|
|||
"""Spot-check on the three production-relevant families that
|
||||
the compile_every sweep also covers; this case verifies the
|
||||
emitted cache file has the model-specific RMSNorm class
|
||||
attribute, not just that the file parses + imports."""
|
||||
attribute, not just that the file parses + imports.
|
||||
|
||||
Note on test isolation: ``unsloth_compile_transformers``
|
||||
early-returns when ``modeling.__UNSLOTH_PATCHED__`` is set,
|
||||
so once an earlier test in the same collection patches the
|
||||
module the next call won't re-emit the cache file. Drop the
|
||||
marker (and any stale cache file) before invoking so this
|
||||
test is order-independent."""
|
||||
import importlib as _il
|
||||
try:
|
||||
_il.import_module(
|
||||
modeling = _il.import_module(
|
||||
f"transformers.models.{model_type}.modeling_{model_type}"
|
||||
)
|
||||
except ModuleNotFoundError:
|
||||
pytest.skip(
|
||||
f"transformers build lacks model_type={model_type}"
|
||||
)
|
||||
if hasattr(modeling, "__UNSLOTH_PATCHED__"):
|
||||
delattr(modeling, "__UNSLOTH_PATCHED__")
|
||||
combined = _CACHE / f"unsloth_compiled_module_{model_type}.py"
|
||||
if combined.exists():
|
||||
combined.unlink()
|
||||
unsloth_compile_transformers(
|
||||
model_type=model_type, fast_lora_forwards=False,
|
||||
)
|
||||
|
|
@ -1049,7 +1061,6 @@ jobs:
|
|||
f"transformers.models.{model_type}.modeling_{model_type}"
|
||||
)
|
||||
assert getattr(modeling, "__UNSLOTH_PATCHED__", False) is True
|
||||
combined = _CACHE / f"unsloth_compiled_module_{model_type}.py"
|
||||
_verify_file(combined, must_expose=[rms_class])
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue