mirror of
https://github.com/unslothai/unsloth.git
synced 2026-10-19 08:54:21 +00:00
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
e9cf209141
commit
13fc5b60e6
3 changed files with 32 additions and 8 deletions
|
|
@ -9551,6 +9551,7 @@ def test_default_load_budgets_the_hosted_encoder_its_family_defaults_to(fake_run
|
|||
# the dense encoder, so that is what it budgets.
|
||||
import core.inference.diffusion_te_prequant as tpq
|
||||
from core.inference.video_families import detect_video_family
|
||||
|
||||
scale = _allow_te_prequant(monkeypatch)
|
||||
for repo in ("Wan-AI/Wan2.2-TI2V-5B-Diffusers", "Wan-AI/Wan2.1-T2V-1.3B-Diffusers"):
|
||||
fam = detect_video_family(repo)
|
||||
|
|
|
|||
|
|
@ -436,7 +436,6 @@ def test_the_builder_quantizes_a_non_gated_t5_feed_forward():
|
|||
assert not pattern.match("encoder.block.3.layer.1.DenseReluDense.wix.weight")
|
||||
|
||||
|
||||
|
||||
def test_the_transformers_builder_honours_keep_dense(tmp_path):
|
||||
import importlib.util
|
||||
from pathlib import Path
|
||||
|
|
@ -450,17 +449,39 @@ def test_the_transformers_builder_honours_keep_dense(tmp_path):
|
|||
builder = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(builder)
|
||||
config = transformers.T5Config(
|
||||
vocab_size = 32, d_model = 64, d_kv = 16, d_ff = 128, num_layers = 1, num_heads = 4,
|
||||
vocab_size = 32,
|
||||
d_model = 64,
|
||||
d_kv = 16,
|
||||
d_ff = 128,
|
||||
num_layers = 1,
|
||||
num_heads = 4,
|
||||
feed_forward_proj = "gated-gelu",
|
||||
)
|
||||
src = tmp_path / "te"
|
||||
transformers.T5EncoderModel(config).save_pretrained(src)
|
||||
out = tmp_path / "te-int8.safetensors"
|
||||
builder.main([
|
||||
"--base", "someone/t5", "--family", "flux.1", "--src", str(src), "--out", str(out),
|
||||
"--load", "transformers", "--te-class", "T5EncoderModel", "--keep-dense", "wo",
|
||||
"--group", "64", "--device", "cpu",
|
||||
])
|
||||
builder.main(
|
||||
[
|
||||
"--base",
|
||||
"someone/t5",
|
||||
"--family",
|
||||
"flux.1",
|
||||
"--src",
|
||||
str(src),
|
||||
"--out",
|
||||
str(out),
|
||||
"--load",
|
||||
"transformers",
|
||||
"--te-class",
|
||||
"T5EncoderModel",
|
||||
"--keep-dense",
|
||||
"wo",
|
||||
"--group",
|
||||
"64",
|
||||
"--device",
|
||||
"cpu",
|
||||
]
|
||||
)
|
||||
with safe_open(str(out), framework = "pt") as handle:
|
||||
keys = set(handle.keys())
|
||||
wo = handle.get_tensor("encoder.block.0.layer.1.DenseReluDense.wo.weight")
|
||||
|
|
@ -469,6 +490,7 @@ def test_the_transformers_builder_honours_keep_dense(tmp_path):
|
|||
# T5 keeps ``wo`` in float32, and a dense one is stored that way.
|
||||
assert wo.dtype == torch.float32
|
||||
|
||||
|
||||
def test_a_wan_load_claims_the_hosted_encoder_repo_while_it_fetches():
|
||||
# The hosted file lives in a third repo; without the claim the delete-cached guard admits deleting it mid-load.
|
||||
import inspect
|
||||
|
|
|
|||
|
|
@ -97,7 +97,8 @@ def test_vision_loader_wraps_patch_model_and_tokenizer():
|
|||
ctx = [
|
||||
item.context_expr.func.id
|
||||
for item in node.items
|
||||
if isinstance(item.context_expr, ast.Call) and isinstance(item.context_expr.func, ast.Name)
|
||||
if isinstance(item.context_expr, ast.Call)
|
||||
and isinstance(item.context_expr.func, ast.Name)
|
||||
]
|
||||
if "packed_4bit_as_uint8" not in ctx:
|
||||
continue
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue