Instructions to use AEUPH/moss4gb with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use AEUPH/moss4gb with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("AEUPH/moss4gb", dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Draw Things
- DiffusionBee
Download tests/test_cache.py from AEUPH/moss4gb: direct link, hf CLI and curl.
- Browser
- Download file 1.5 kB
-
https://huggingface.co/AEUPH/moss4gb/resolve/main/tests/test_cache.py
- Command line
-
hf download hf://AEUPH/moss4gb/tests/test_cache.py
-
curl -L -o test_cache.py https://huggingface.co/AEUPH/moss4gb/resolve/main/tests/test_cache.py
1.5 kB
| from __future__ import annotations | |
| import pytest | |
| import torch | |
| from moss4gb import quant | |
| MODEL_DIR = "models/MOSS-Image-SFT" | |
| def test_cache_path_is_stable_and_namespaced(): | |
| first = quant.default_cache_path(MODEL_DIR) | |
| assert first == quant.default_cache_path(MODEL_DIR) | |
| # Next to the checkpoint, so it survives a CWD change and dies with a | |
| # re-downloaded model rather than being silently reused. | |
| assert first.parent.name == ".moss4gb-cache" | |
| assert first.parent.parent.name == "MOSS-Image-SFT" | |
| assert "nf4" in first.name and first.suffix == ".pt" | |
| def test_cache_path_separates_compute_dtypes(): | |
| # The packed weights are identical but compute_dtype changes the linear's | |
| # matmul dtype, so the two builds must not share a file. | |
| assert quant.default_cache_path(MODEL_DIR, torch.float16) != quant.default_cache_path( | |
| MODEL_DIR, torch.bfloat16 | |
| ) | |
| def test_cache_key_tracks_the_checkpoint(): | |
| # A different config or shard set has to produce a different name, otherwise | |
| # a stale cache would be loaded against new weights. | |
| key = quant.default_cache_path(MODEL_DIR).stem | |
| assert key.startswith("dit_nf4_float16-") and len(key.split("-")[-1]) == 12 | |
| def test_file_without_a_module_is_rejected(tmp_path): | |
| path = tmp_path / "bad.pt" | |
| torch.save({"weight": torch.zeros(2, 2)}, path) | |
| with pytest.raises(RuntimeError, match="does not contain a transformer"): | |
| quant._load_cached_transformer(path, device="cpu", verbose=False) | |