Run this model with HF Jobs
Run lodestones/Kromoss on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/lodestones/Kromoss. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/lodestones/Kromoss on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use lodestones/Kromoss with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use lodestones/Kromoss with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("lodestones/Kromoss", 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
Kromoss update 5000 (EMA): transformer/ + ComfyUI kromoss_bf16.safetensors + kromoss_int8_convrot.safetensors
Browse filesFiles changed (7)
- README.md+13-1
- diffusion_models/kromoss_bf16.safetensors+1-1
- diffusion_models/kromoss_int8_convrot.safetensors+2-2
- quantize_convrot.pyAdded+140
- transformer/diffusion_pytorch_model-00001-of-00003.safetensors+1-1
- transformer/diffusion_pytorch_model-00002-of-00003.safetensors+1-1
- transformer/diffusion_pytorch_model-00003-of-00003.safetensors+1-1
23 unmodified lines2425262728293036 unmodified lines67686970717212 unmodified lines85868788899023 unmodified lines| --- | --- ||  |  |Checkpoint: update 4000 of the fine-tune (EMA weights), 256k training images.## Quick start36 unmodified lines| File | Put in | Loader || --- | --- | --- || `diffusion_models/kromoss_bf16.safetensors` | `models/diffusion_models/` | Load Diffusion Model || `text_encoders/qwen3.5_9b_bf16.safetensors` | `models/text_encoders/` | Load CLIP, type `moss_image` || `vae/flux2-vae_small.safetensors` | `models/vae/` | Load VAE || `8-steps-dmd-lora.safetensors` | `models/loras/` | LoraLoaderModelOnly, strength 1 |12 unmodified linesOn MOSS-Image-SFT's `transformer/` it reproduces Comfy-Org's `moss_image_sft_bf16.safetensors` byte for byte;`--compare FILE` checks keys, shapes and dtypes against a reference file.## 8-step turbo LoRA`8-steps-dmd-lora.safetensors`: fp32, rank 128 / alpha 128 on every block's `proj.{q,k,v,o,ffn_up_gate,ffn_down}`,23 unmodified lines2425262728293036 unmodified lines6768697071727312 unmodified lines868788899091929394959697989910010110223 unmodified lines| --- | --- ||  |  |Checkpoint: update 5000 of the fine-tune (EMA weights), 320k training images.## Quick start36 unmodified lines| File | Put in | Loader || --- | --- | --- || `diffusion_models/kromoss_bf16.safetensors` | `models/diffusion_models/` | Load Diffusion Model || `diffusion_models/kromoss_int8_convrot.safetensors` | `models/diffusion_models/` | Load Diffusion Model (int8, 5.4 GB) || `text_encoders/qwen3.5_9b_bf16.safetensors` | `models/text_encoders/` | Load CLIP, type `moss_image` || `vae/flux2-vae_small.safetensors` | `models/vae/` | Load VAE || `8-steps-dmd-lora.safetensors` | `models/loras/` | LoraLoaderModelOnly, strength 1 |12 unmodified linesOn MOSS-Image-SFT's `transformer/` it reproduces Comfy-Org's `moss_image_sft_bf16.safetensors` byte for byte;`--compare FILE` checks keys, shapes and dtypes against a reference file.`kromoss_int8_convrot.safetensors` is ConvRot W8A8, the format of Comfy-Org's `moss_image_sft_int8_convrot.safetensors`.The 168 block linears (`proj.{qkv,o,ffn_up_gate,ffn_down}`) are stored as int8 with per-row scales, after a256-wide regular Hadamard rotation of the input dimension. ComfyUI rebuilds the rotation at load time and applies itto the activations online, so no rotation matrices are stored. Each block also selects ComfyUI's int8 attention.It drops in for the int8 Comfy-Org file and works with the LoRA. `quantize_convrot.py` makes it from a bf16 singlefile; on `moss_image_sft_bf16.safetensors` it reproduces Comfy-Org's int8 file byte for byte:```bashpython quantize_convrot.py my_model_bf16.safetensors my_model_int8_convrot.safetensors```## 8-step turbo LoRA`8-steps-dmd-lora.safetensors`: fp32, rank 128 / alpha 128 on every block's `proj.{q,k,v,o,ffn_up_gate,ffn_down}`,
123version https://git-lfs.github.com/spec/v1oid sha256:8b1b11e972decc03797f544381e26ad85b265ada7db86d91dc6517ae45ca1fa2size 10164655808123version https://git-lfs.github.com/spec/v1oid sha256:a55daa21ffdf386a6cda41bddb8a79ca5f1c6a97937731cc63b85cf442a7d707size 10164655808
123version https://git-lfs.github.com/spec/v1oid sha256:b08daa45bf1594735181652f03d8e3254ed76346ad7817cb52eaa5678f12e906size 5413711632123version https://git-lfs.github.com/spec/v1oid sha256:406c061a30c15e62945a6d56df16c72f605419d2ea92643d47a36fc1b5d5112csize 5413698958
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140"""ComfyUI single file (export_comfy.py) -> ConvRot W8A8, the Comfy-Org/MOSS-Image ``*_int8_convrot`` layout.
The 168 block linears (``layers.N.proj.{qkv,o,ffn_up_gate,ffn_down}``) are stored as ComfyUI's native``int8_tensorwise`` with ConvRot (arXiv 2512.03673); no rotation matrix is stored, the loader rebuilds it:
<layer>.weight int8 [out, in] W rotated per 256-wide input block by the regular Hadamard, quantized <layer>.weight_scale f32 [out, 1] per-output-row scale, absmax / 127 of the rotated row <layer>.comfy_quant uint8 JSON {"format": "int8_tensorwise", "convrot": true, "convrot_groupsize": 256} layers.N.comfy_attention.config uint8 JSON {"attention": "comfy_kitchen_int8"}
H is H4 kron H4 kron H4 kron H4 / 16 with H4 = [[1,1,1,-1],[1,1,-1,1],[1,-1,1,1],[-1,1,1,1]]: symmetric andorthogonal, so x W^T = (x H)(W H^T)^T and ComfyUI rotates activations online. Everything else (text embedder,time / modulation, norms, head) passes through unchanged; empty file metadata, as in the Comfy-Org files. The mathmirrors comfy-kitchen's int8_tensorwise (sign pattern, Kronecker order, rounding) or the file decodes to garbage.
python quantize_convrot.py kromoss_bf16.safetensors kromoss_int8_convrot.safetensors \ [--compare moss_image_sft_int8_convrot.safetensors]"""from __future__ import annotations
import os
import argparseimport jsonimport reimport time
import torchfrom safetensors import safe_openfrom safetensors.torch import save_file
BLOCK_LINEAR = re.compile(r"^layers\.(\d+)\.proj\.(qkv|o|ffn_up_gate|ffn_down)\.weight$")H4 = ((1, 1, 1, -1), (1, 1, -1, 1), (1, -1, 1, 1), (-1, 1, 1, 1))CLIP_GRID = torch.linspace(0.55, 1.0, 80)
def regular_hadamard(n, device): h = torch.tensor(H4, dtype=torch.float32, device=device) while h.shape[0] < n: h = torch.kron(h, torch.tensor(H4, dtype=torch.float32, device=device)) if h.shape[0] != n: raise ValueError(f"group size must be a power of 4, got {n}") return h / n ** 0.5
def rotate(w, gs): out_f, in_f = w.shape return (w.reshape(out_f, in_f // gs, gs) @ regular_hadamard(gs, w.device).T).reshape(out_f, in_f)
@torch.no_grad()def quantize(w, gs, mseclip=False): """fp32 rotate, then per row scale = absmax / 127 (the Comfy-Org recipe), or with ``mseclip`` the clip ratio in CLIP_GRID with the lowest reconstruction MSE.""" wf = rotate(w.float(), gs) absmax = wf.abs().amax(dim=1, keepdim=True).clamp(min=1e-30) best_mse, best_scale, best_q = torch.full_like(absmax, float("inf")), absmax / 127.0, None for a in CLIP_GRID.tolist() if mseclip else [1.0]: scale = (absmax * a / 127.0).clamp(min=1e-30) q = (wf / scale).round_().clamp_(-127, 127) mse = ((q * scale - wf) ** 2).mean(dim=1, keepdim=True) better = mse < best_mse best_mse = torch.where(better, mse, best_mse) best_scale = torch.where(better, scale, best_scale) best_q = q if best_q is None else torch.where(better, q, best_q) deq = rotate(best_q * best_scale, gs).double() cos = (deq.flatten() @ w.double().flatten() / (deq.norm() * w.double().norm())).item() return best_q.to(torch.int8), best_scale, cos
def blob(obj): return torch.tensor(list(json.dumps(obj).encode()), dtype=torch.uint8)
def convrot(path, groupsize=256, mseclip=False, int8_attention=True, device=None): """bf16 ComfyUI single file -> state dict of the ConvRot W8A8 file (save with metadata={}).""" device = device or ("cuda" if torch.cuda.is_available() else "cpu") out, start, worst = {}, time.time(), (1.0, "") with safe_open(str(path), "pt") as f: keys = list(f.keys()) blocks = sorted({int(m.group(1)) for k in keys if (m := BLOCK_LINEAR.match(k))}) for k in keys: tensor = f.get_tensor(k) if not BLOCK_LINEAR.match(k): out[k] = tensor continue q, scale, cos = quantize(tensor.to(device), groupsize, mseclip) if cos <= 0.99: raise SystemExit(f"broken quantization of {k}: cos {cos:.5f}") worst = min(worst, (cos, k)) base = k[:-len(".weight")] out[k], out[f"{base}.weight_scale"] = q.cpu(), scale.cpu() out[f"{base}.comfy_quant"] = blob({"format": "int8_tensorwise", "convrot": True, "convrot_groupsize": groupsize}) if int8_attention: for n in blocks: out[f"layers.{n}.comfy_attention.config"] = blob({"attention": "comfy_kitchen_int8"}) print(f"quantized {sum(1 for k in out if k.endswith('.comfy_quant'))} linears in {time.time() - start:.0f}s, " f"worst cos {worst[0]:.6f} ({worst[1]})", flush=True) return out
def main(): parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument("input", help="bf16 ComfyUI single file (fused proj.qkv), e.g. from export_comfy.py") parser.add_argument("output") parser.add_argument("--groupsize", type=int, default=256) parser.add_argument("--mseclip", action="store_true", help="per-row MSE-optimal clip instead of absmax " "(~1.5%% lower weight error; not how the Comfy-Org files were made)") parser.add_argument("--no-int8-attention", action="store_true", help="omit the per-block comfy_attention.config (ComfyUI then keeps bf16 attention)") parser.add_argument("--device", default="cuda" if torch.cuda.is_available() else "cpu") parser.add_argument("--compare", help="reference int8 file: require the same keys/shapes/dtypes and report " "how many int8 values and scales agree") args = parser.parse_args() out = convrot(args.input, args.groupsize, args.mseclip, not args.no_int8_attention, args.device) if args.compare: with safe_open(args.compare, "pt") as f: if set(f.keys()) != set(out): raise SystemExit(f"key sets differ: {sorted(set(f.keys()) ^ set(out))[:6]}") q_same = q_total = s_same = s_total = exact = 0 for k in f.keys(): ref = f.get_tensor(k) if ref.shape != out[k].shape or ref.dtype != out[k].dtype: raise SystemExit(f"{k}: {tuple(ref.shape)} {ref.dtype} vs {tuple(out[k].shape)} {out[k].dtype}") exact += torch.equal(ref, out[k]) if ref.dtype == torch.int8: q_same += (ref == out[k]).sum().item() q_total += ref.numel() elif k.endswith(".weight_scale"): s_same += (ref == out[k]).sum().item() s_total += ref.numel() print(f"vs {args.compare}: {exact}/{len(out)} tensors bit-identical; int8 values equal " f"{100 * q_same / q_total:.4f}%, scales equal {100 * s_same / s_total:.4f}%") save_file(out, args.output, metadata={}) print(f"{args.output}: {len(out)} tensors, {os.path.getsize(args.output) / 1e9:.2f} GB")
if __name__ == "__main__": main()123version https://git-lfs.github.com/spec/v1oid sha256:1344aadfb8a99c2dc79a1921ab2d5831163916dc8f42ab6acc1151d7560c6818size 4991978016123version https://git-lfs.github.com/spec/v1oid sha256:22ef3d846adf9803dcd362621d36aad1ce06ea0490bc2dbe94f4b61193a16c08size 4991978016
123version https://git-lfs.github.com/spec/v1oid sha256:1297408bc251cbd25e7f0facd865700f5fc940ac2561b95397a81bfa42447480size 4983137016123version https://git-lfs.github.com/spec/v1oid sha256:90527d4b7e68ad60dd4b925c6825db6df49c411d5a2ebb14ce714b6be45a803fsize 4983137016
123version https://git-lfs.github.com/spec/v1oid sha256:a67e84a066da78abbd9c51ae59df4c9781a993c9a4471896f10ec52db7604522size 189549184123version https://git-lfs.github.com/spec/v1oid sha256:d23e2f970e011e09b129100afd83b11cb256c7f30a547adf3a6e74c4963ce9afsize 189549184
README.md+13-1
diffusion_models/kromoss_bf16.safetensors+1-1
diffusion_models/kromoss_int8_convrot.safetensors+2-2
quantize_convrot.pyAdded+140
transformer/diffusion_pytorch_model-00001-of-00003.safetensors+1-1
transformer/diffusion_pytorch_model-00002-of-00003.safetensors+1-1
transformer/diffusion_pytorch_model-00003-of-00003.safetensors+1-1