tillknuesting/qwen-image-2.1-mlx-fast main
imports Path from pathlibimports pathlib
SHA-25621c5c8aef49ae292f5c5c835e64652ecbc801ae1ea862e6e62c5492d2af0dd22
MaleculeH(F)Md₂(In₂Pa)
Evidence
1from __future__ import annotations
2
3from pathlib import Path
4from typing import Any
5
6import mlx.core as mx
7import pytest
8from mlx import nn
9
10from qwen_mlx_poc.lora import LoRAError, LoRALinear, _module_path, apply_lora
11from qwen_mlx_poc.samplers import TurboNodeScheduler # noqa: F401 (import check)
12
13
⋯4 lines
17:51… , 8)), mx.random.normal((4, 2)), scale=0.0)
18 assert mx.array_equal(wrapped(x), base(x))
19
20
⋯4 lines
44:16… f.attn = Attention()
45
46 model = Model()
47 path = tmp_path / "lora.safetensors"
48 mx.save_safetensors(
49 str(path),
50 {
51 "transformer.attn.to_q.lora_A.weight": mx.zeros((2, 8)),
52 …
54:47… weight": mx.zeros((8, 2)),
55 },
56 )
57 assert apply_lora(model, path)["layers"] == 2
58 assert isinstance(model.attn.to_q, LoRALinear)
59 assert isinstance(model.attn.to_out[0], LoRALinear)
60 with pytest.raises(LoRAError, match="already"):
61 apply_lora(model, path)
62
63
64def test_turbo_nodes_follow_viggles_rule() -> None:
65 from qwen_mlx_poc.samplers import turbo_nodes
66
67 assert turbo_nodes(6) == (1.0, 0.9375, 0.875, 0.75, 0.5, 0.25)
68 assert turbo_nodes(5) == (1.0, 0.875, 0.75, 0.5, 0.25)
69 assert [round(node, 4) for node in turbo_nodes(7)] == [1.0, 0.9583, 0.9167, 0.875, 0.75, 0.5, 0.25]
70 assert turbo_nodes(8)[-4:] …