Views
No views yet
MARIUS-V18 is not a standard quantization; it is a geometrical reconstruction of the original model using a mathematical grid-based vector format (LZR2) to run on hardware that would normally be incompatible: GTX 1060 6GB, GTX 1660, RTX 2060.
| Standard SDXL | MARIUS-V18 | |
|---|---|---|
| VRAM Required | ~12 GB | ~6 GB |
| Disk Size | ~7 GB | ~22 GB |
| Visual Quality | Standard | Lossless Reconstruction |
| Compatible GPUs | RTX 3060+ | GTX 1060 6GB+ |
| Runtime | Standard | Pure PyTorch |
.lzr2 file is not generated through standard k-means clustering or rounding. The original weights pass through a custom deterministic processing script that stabilizes the continuous signal into discrete geometry:(row, col). It is the physical manifestation of a continuous signal forced into a perfect discrete state.| Samples | Base Grid | Marius V18 | Delta | Wilcoxon p |
|---|---|---|---|---|
| 50 | 32 rem 84 | 32 rem 93 | 0 rem 9 | - |
| 100 (median) | 33 rem 24 | 33 rem 41 | 0 rem 17 | 0 rem 9735 |
| 500 | 32 rem 84 | 32 rem 91 | 0 rem 7 | - |
pip install torch diffusers transformers accelerate safetensors psutil numpyMarius_SDXL_V18.lzr2 (22 GB) — do not renamemarius_v18_loader.py (see below)marius_v18_loader.pyimport torch, struct, zlib, numpy as np, itertools, os, gc, sys, psutil
from diffusers import StableDiffusionXLPipeline
_ARTIFACT = "Marius_SDXL_V18.lzr2"
_BASE = "stabilityai/stable-diffusion-xl-base-1.0"
def _stat():
process = psutil.Process(os.getpid())
return process.memory_info().rss // (1024 ** 3)
def inject_marius(path, pipe):
if not os.path.exists(path):
raise FileNotFoundError(f"Missing artifact: {path}")
print("Initializing streaming engine...")
_opts, u = {}, pipe.unet
_g_v = lambda d: np.array(list(itertools.product([-1, 0, 1], repeat=d)), dtype=np.float32)
idx = 0
with open(path, "rb") as f:
if f.read(4) != b"LZR2":
raise ValueError("Invalid signature")
while True:
lkb = f.read(4)
if not lkb: break
key = f.read(struct.unpack('I', lkb)[0]).decode('utf-8')
ls = struct.unpack('I', f.read(4))[0]
sh = [struct.unpack('I', f.read(4))[0] for _ in range(ls)]
tf = struct.unpack('B', f.read(1))[0]
_w = None
if tf == 1:
dp, C = struct.unpack('I', f.read(4))[0], sh[0]
_a = np.frombuffer(f.read(C*dp*4), dtype=np.float32).reshape(C, dp)
_mn = np.frombuffer(f.read(C*4), dtype=np.float32)
_sc = np.frombuffer(f.read(C*4), dtype=np.float32)
lz = struct.unpack('I', f.read(4))[0]
_ix_flat = np.frombuffer(zlib.decompress(f.read(lz)), dtype=np.uint16)
n_blocks = _ix_flat.size // C
_ix = _ix_flat.reshape(C, n_blocks)
no = struct.unpack('I', f.read(4))[0]
N_feat = int(np.prod(sh[1:])) if len(sh) > 1 else 1
if dp not in _opts:
_opts[dp] = _g_v(dp)
rc = _opts[dp][_ix].reshape(C, -1) if n_blocks > 0 else np.zeros((C, 0), dtype=np.float32)
fb = np.zeros((C, N_feat), dtype=np.float32)
vw = min(rc.shape[1], N_feat)
if vw > 0:
fb[:, :vw] = rc[:, :vw]
fb = (fb + _mn[:, None]) * _sc[:, None]
if no > 0:
md = max(C, n_blocks) * dp
fmt, fsz = ('H', 8) if md < 65536 else ('I', 12)
dt = np.dtype([('r', np.uint16 if fmt=='H' else np.uint32),
('c', np.uint16 if fmt=='H' else np.uint32),
('v', np.float32)])
batch = np.frombuffer(f.read(no * fsz), dtype=dt)
m = (batch['r'] < C) & (batch['c'] < N_feat)
vb = batch[m]
fb[vb['r'], vb['c']] = vb['v']
_w = torch.from_numpy(fb.reshape(sh).astype(np.float16))
if _w is not None:
try:
t = u
pts = key.split('.')
for p in pts[:-1]:
t = getattr(t, p)
getattr(t, pts[-1]).data.copy_(_w.to(pipe.device, dtype=torch.float16))
except:
pass
del _w
idx += 1
if idx % 10 == 0:
sys.stdout.write(f"\r[STREAM] Module {idx:04d} | RAM: {_stat()}GB")
sys.stdout.flush()
if idx % 200 == 0:
gc.collect()
print(f"\nStream complete ({idx} modules loaded)")
def get_pipe():
print("Loading base architecture...")
pipe = StableDiffusionXLPipeline.from_pretrained(
_BASE,
torch_dtype=torch.float16,
variant="fp16",
use_safetensors=True
)
pipe.enable_model_cpu_offload()
inject_marius(_ARTIFACT, pipe)
return pipe1from marius_v18_loader import get_pipe
2
3pipe = get_pipe()
4print("Ready. Type 'quit' to exit.\n")
5
6img_idx = 1
7while True:
8 prompt = input(f"[{img_idx}] Prompt > ").strip()
9 if prompt.lower() in ['quit', 'exit', 'q']:
10 break
11 if not prompt:
12 continue
13 image = pipe(prompt, num_inference_steps=30).images[0]
14 filename = f"output_{img_idx:03d}.png"
15 image.save(filename)
16 print(f"Saved: {filename}\n")
17 img_idx += 1Marius_SDXL_V18.lzr2.