Rename to Halide Preview
Browse files- README.md +12 -12
- config.json +1 -1
- mica_modeling.py → halide_modeling.py +12 -12
README.md
CHANGED
|
@@ -5,7 +5,7 @@ language:
|
|
| 5 |
pipeline_tag: text-to-image
|
| 6 |
library_name: pytorch
|
| 7 |
tags:
|
| 8 |
-
-
|
| 9 |
- text-to-image
|
| 10 |
- flow-matching
|
| 11 |
- fcdm
|
|
@@ -15,11 +15,11 @@ tags:
|
|
| 15 |
- preview
|
| 16 |
---
|
| 17 |
|
| 18 |
-
|
| 19 |
|
| 20 |
-
**
|
| 21 |
|
| 22 |
-
It is still early. Trained to step 291,000 (~4.66M image-caption samples seen),
|
| 23 |
|
| 24 |
---
|
| 25 |
|
|
@@ -27,7 +27,7 @@ It is still early. Trained to step 291,000 (~4.66M image-caption samples seen),
|
|
| 27 |
|
| 28 |
All samples below were generated directly from the released EMA weights at **768×768** (`50` Euler steps, CFG `4.0`, resolution shift `2.5`, uncurated single seed per prompt):
|
| 29 |
|
| 30 |
-
![
|
| 31 |
|
| 32 |
| Sample | Prompt |
|
| 33 |
|---|---|
|
|
@@ -46,7 +46,7 @@ All samples below were generated directly from the released EMA weights at **768
|
|
| 46 |
|
| 47 |
## Architecture & Training
|
| 48 |
|
| 49 |
-
|
| 50 |
|
| 51 |
- **Parameters:** 194,328,196 total (`192,230,532` generator + `2,097,664` text adapter, released as EMA weights `decay = 0.9995`)
|
| 52 |
- **Thinker (Global Planner):** Perceiver-style Transformer operating on a 24×24 spatial plan grid + 16 global tokens (`p_dim = 256`, `dim = 640`, 4 perceiver blocks, 3 prelude + 3 recurrent core × 4 loops + 2 coda blocks, 2D RoPE, QK-RMSNorm, multi-resolution ConvRead branch)
|
|
@@ -64,12 +64,12 @@ import torch
|
|
| 64 |
from diffusers import AutoencoderKL
|
| 65 |
from huggingface_hub import hf_hub_download
|
| 66 |
from safetensors.torch import load_file
|
| 67 |
-
from
|
| 68 |
|
| 69 |
-
repo_id = "Emergent-Knowledge/
|
| 70 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 71 |
|
| 72 |
-
model =
|
| 73 |
model.load_state_dict(load_file(hf_hub_download(repo_id, "generator.safetensors")), strict=True)
|
| 74 |
model = model.to(device).eval()
|
| 75 |
|
|
@@ -78,12 +78,12 @@ text_enc.ctx_proj.load_state_dict(load_file(hf_hub_download(repo_id, "ctx_proj.s
|
|
| 78 |
|
| 79 |
vae = AutoencoderKL.from_pretrained(VAE_REPO, torch_dtype=torch.bfloat16 if device == "cuda" else torch.float32).to(device).eval()
|
| 80 |
|
| 81 |
-
images =
|
| 82 |
model, text_enc, vae,
|
| 83 |
prompts=["A breathtaking sunrise over snow-capped Alpine peaks reflected in a calm turquoise glacial lake"],
|
| 84 |
steps=50, cfg=4.0, shift=2.5, resolution=768, seed=42, device=device,
|
| 85 |
)
|
| 86 |
-
images[0].save("
|
| 87 |
```
|
| 88 |
|
| 89 |
---
|
|
@@ -98,6 +98,6 @@ images[0].save("mica_sample.png")
|
|
| 98 |
|
| 99 |
## Acknowledgements & License
|
| 100 |
|
| 101 |
-
|
| 102 |
|
| 103 |
Released under the **Apache-2.0** license.
|
|
|
|
| 5 |
pipeline_tag: text-to-image
|
| 6 |
library_name: pytorch
|
| 7 |
tags:
|
| 8 |
+
- halide
|
| 9 |
- text-to-image
|
| 10 |
- flow-matching
|
| 11 |
- fcdm
|
|
|
|
| 15 |
- preview
|
| 16 |
---
|
| 17 |
|
| 18 |
+
# Halide Preview
|
| 19 |
|
| 20 |
+
**Halide Preview** is a small, experimental 194M-parameter English text-to-image flow-matching model trained from scratch at 768×768 resolution. It is our first working research preview from the Halide image-generation family — built to test whether a recurrent Perceiver "thinker" paired with a pure-ConvNeXt V2 renderer can produce coherent high-resolution imagery at a fraction of the parameter count of standard diffusion Transformers.
|
| 21 |
|
| 22 |
+
It is still early. Trained to step 291,000 (~4.66M image-caption samples seen), Halide Preview is not meant to rival large billion-parameter image models yet — it is a transparent, self-contained checkpoint and a starting point for what comes next.
|
| 23 |
|
| 24 |
---
|
| 25 |
|
|
|
|
| 27 |
|
| 28 |
All samples below were generated directly from the released EMA weights at **768×768** (`50` Euler steps, CFG `4.0`, resolution shift `2.5`, uncurated single seed per prompt):
|
| 29 |
|
| 30 |
+

|
| 31 |
|
| 32 |
| Sample | Prompt |
|
| 33 |
|---|---|
|
|
|
|
| 46 |
|
| 47 |
## Architecture & Training
|
| 48 |
|
| 49 |
+
Halide Preview separates global semantic planning from local spatial rendering in plain PyTorch (`halide_modeling.py`, no custom CUDA extensions required):
|
| 50 |
|
| 51 |
- **Parameters:** 194,328,196 total (`192,230,532` generator + `2,097,664` text adapter, released as EMA weights `decay = 0.9995`)
|
| 52 |
- **Thinker (Global Planner):** Perceiver-style Transformer operating on a 24×24 spatial plan grid + 16 global tokens (`p_dim = 256`, `dim = 640`, 4 perceiver blocks, 3 prelude + 3 recurrent core × 4 loops + 2 coda blocks, 2D RoPE, QK-RMSNorm, multi-resolution ConvRead branch)
|
|
|
|
| 64 |
from diffusers import AutoencoderKL
|
| 65 |
from huggingface_hub import hf_hub_download
|
| 66 |
from safetensors.torch import load_file
|
| 67 |
+
from halide_modeling import DistillT5TextEncoder, HalideConfig, HalideGenerator, VAE_REPO, sample_halide
|
| 68 |
|
| 69 |
+
repo_id = "Emergent-Knowledge/halide-preview"
|
| 70 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 71 |
|
| 72 |
+
model = HalideGenerator(HalideConfig())
|
| 73 |
model.load_state_dict(load_file(hf_hub_download(repo_id, "generator.safetensors")), strict=True)
|
| 74 |
model = model.to(device).eval()
|
| 75 |
|
|
|
|
| 78 |
|
| 79 |
vae = AutoencoderKL.from_pretrained(VAE_REPO, torch_dtype=torch.bfloat16 if device == "cuda" else torch.float32).to(device).eval()
|
| 80 |
|
| 81 |
+
images = sample_halide(
|
| 82 |
model, text_enc, vae,
|
| 83 |
prompts=["A breathtaking sunrise over snow-capped Alpine peaks reflected in a calm turquoise glacial lake"],
|
| 84 |
steps=50, cfg=4.0, shift=2.5, resolution=768, seed=42, device=device,
|
| 85 |
)
|
| 86 |
+
images[0].save("halide_sample.png")
|
| 87 |
```
|
| 88 |
|
| 89 |
---
|
|
|
|
| 98 |
|
| 99 |
## Acknowledgements & License
|
| 100 |
|
| 101 |
+
Halide Preview builds on open research and open weights from the community — including FCDM (`arXiv:2603.09408`), Agate Thinker-Renderer architectures, [`LifuWang/DistillT5`](https://huggingface.co/LifuWang/DistillT5), [`google-t5/t5-base`](https://huggingface.co/google-t5/t5-base), and [`stabilityai/sd-vae-ft-mse`](https://huggingface.co/stabilityai/sd-vae-ft-mse).
|
| 102 |
|
| 103 |
Released under the **Apache-2.0** license.
|
config.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
{
|
| 2 |
-
"model_type": "
|
| 3 |
"step": 291000,
|
| 4 |
"samples_seen": 4656000,
|
| 5 |
"ema": true,
|
|
|
|
| 1 |
{
|
| 2 |
+
"model_type": "halide_v5_fcdm_thinker2",
|
| 3 |
"step": 291000,
|
| 4 |
"samples_seen": 4656000,
|
| 5 |
"ema": true,
|
mica_modeling.py → halide_modeling.py
RENAMED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
"""
|
| 2 |
|
| 3 |
Architecture:
|
| 4 |
- 192.2M-param FCDM-Thinker2-MR (flat 768px mode, 96x96 SD-VAE latent grid)
|
|
@@ -27,13 +27,13 @@ DISTILLT5_REPO = "LifuWang/DistillT5"
|
|
| 27 |
DISTILLT5_TOKENIZER_REPO = "google-t5/t5-base"
|
| 28 |
DISTILLT5_D_MODEL = 768
|
| 29 |
DISTILLT5_OUT_DIM = 4096
|
| 30 |
-
|
| 31 |
VAE_REPO = "stabilityai/sd-vae-ft-mse"
|
| 32 |
VAE_SCALE = 0.18215
|
| 33 |
|
| 34 |
|
| 35 |
@dataclass
|
| 36 |
-
class
|
| 37 |
latent_ch: int = 4
|
| 38 |
widths: list[int] = field(default_factory=lambda: [288, 832, 1664])
|
| 39 |
depths: list[int] = field(default_factory=lambda: [4, 6, 2])
|
|
@@ -327,8 +327,8 @@ class CountCode(nn.Module):
|
|
| 327 |
return ctx + on * self.gate.to(ctx.dtype) * (code - ctx)
|
| 328 |
|
| 329 |
|
| 330 |
-
class
|
| 331 |
-
def __init__(self, cfg:
|
| 332 |
super().__init__()
|
| 333 |
self.grid, self.n_global, self.n_freq, self.rope = cfg.grid, cfg.n_global, cfg.n_freq, cfg.rope
|
| 334 |
self.loops = cfg.loops
|
|
@@ -412,14 +412,14 @@ class MicaThinker(nn.Module):
|
|
| 412 |
return out[:, :g * g].transpose(1, 2).reshape(B, -1, g, g)
|
| 413 |
|
| 414 |
|
| 415 |
-
class
|
| 416 |
-
def __init__(self, cfg:
|
| 417 |
super().__init__()
|
| 418 |
-
cfg = cfg or
|
| 419 |
self.cfg = cfg
|
| 420 |
self.native = 2 * cfg.grid
|
| 421 |
self.loops = cfg.loops
|
| 422 |
-
self.thinker =
|
| 423 |
self.mr_count = CountCode(cfg.ctx_dim)
|
| 424 |
|
| 425 |
w0, w1, w2 = cfg.widths
|
|
@@ -488,7 +488,7 @@ class MicaGenerator(nn.Module):
|
|
| 488 |
|
| 489 |
|
| 490 |
class DistillT5TextEncoder:
|
| 491 |
-
"""LifuWang/DistillT5 (with explicit key remap) + google-t5/t5-base tokenizer +
|
| 492 |
|
| 493 |
def __init__(self, device: str = "cuda", max_len: int = 512):
|
| 494 |
self.device = device
|
|
@@ -496,7 +496,7 @@ class DistillT5TextEncoder:
|
|
| 496 |
self.tokenizer = None
|
| 497 |
self.encoder = None
|
| 498 |
self.final_projection = None
|
| 499 |
-
self.ctx_proj = nn.Linear(DISTILLT5_OUT_DIM,
|
| 500 |
|
| 501 |
def load(self):
|
| 502 |
from huggingface_hub import hf_hub_download
|
|
@@ -552,7 +552,7 @@ def shift_t(t: float, shift: float) -> float:
|
|
| 552 |
|
| 553 |
|
| 554 |
@torch.no_grad()
|
| 555 |
-
def
|
| 556 |
prompts: list[str], steps: int = 50, cfg: float = 4.0,
|
| 557 |
shift: float = 2.0, resolution: int = 768, seed: int = 42,
|
| 558 |
device: str = "cuda"):
|
|
|
|
| 1 |
+
"""Halide Preview (v5, 768px): Portable PyTorch inference model & pipeline.
|
| 2 |
|
| 3 |
Architecture:
|
| 4 |
- 192.2M-param FCDM-Thinker2-MR (flat 768px mode, 96x96 SD-VAE latent grid)
|
|
|
|
| 27 |
DISTILLT5_TOKENIZER_REPO = "google-t5/t5-base"
|
| 28 |
DISTILLT5_D_MODEL = 768
|
| 29 |
DISTILLT5_OUT_DIM = 4096
|
| 30 |
+
HALIDE_CTX_DIM = 512
|
| 31 |
VAE_REPO = "stabilityai/sd-vae-ft-mse"
|
| 32 |
VAE_SCALE = 0.18215
|
| 33 |
|
| 34 |
|
| 35 |
@dataclass
|
| 36 |
+
class HalideConfig:
|
| 37 |
latent_ch: int = 4
|
| 38 |
widths: list[int] = field(default_factory=lambda: [288, 832, 1664])
|
| 39 |
depths: list[int] = field(default_factory=lambda: [4, 6, 2])
|
|
|
|
| 327 |
return ctx + on * self.gate.to(ctx.dtype) * (code - ctx)
|
| 328 |
|
| 329 |
|
| 330 |
+
class HalideThinker(nn.Module):
|
| 331 |
+
def __init__(self, cfg: HalideConfig):
|
| 332 |
super().__init__()
|
| 333 |
self.grid, self.n_global, self.n_freq, self.rope = cfg.grid, cfg.n_global, cfg.n_freq, cfg.rope
|
| 334 |
self.loops = cfg.loops
|
|
|
|
| 412 |
return out[:, :g * g].transpose(1, 2).reshape(B, -1, g, g)
|
| 413 |
|
| 414 |
|
| 415 |
+
class HalideGenerator(nn.Module):
|
| 416 |
+
def __init__(self, cfg: HalideConfig | None = None):
|
| 417 |
super().__init__()
|
| 418 |
+
cfg = cfg or HalideConfig()
|
| 419 |
self.cfg = cfg
|
| 420 |
self.native = 2 * cfg.grid
|
| 421 |
self.loops = cfg.loops
|
| 422 |
+
self.thinker = HalideThinker(cfg)
|
| 423 |
self.mr_count = CountCode(cfg.ctx_dim)
|
| 424 |
|
| 425 |
w0, w1, w2 = cfg.widths
|
|
|
|
| 488 |
|
| 489 |
|
| 490 |
class DistillT5TextEncoder:
|
| 491 |
+
"""LifuWang/DistillT5 (with explicit key remap) + google-t5/t5-base tokenizer + Halide ctx_proj."""
|
| 492 |
|
| 493 |
def __init__(self, device: str = "cuda", max_len: int = 512):
|
| 494 |
self.device = device
|
|
|
|
| 496 |
self.tokenizer = None
|
| 497 |
self.encoder = None
|
| 498 |
self.final_projection = None
|
| 499 |
+
self.ctx_proj = nn.Linear(DISTILLT5_OUT_DIM, HALIDE_CTX_DIM)
|
| 500 |
|
| 501 |
def load(self):
|
| 502 |
from huggingface_hub import hf_hub_download
|
|
|
|
| 552 |
|
| 553 |
|
| 554 |
@torch.no_grad()
|
| 555 |
+
def sample_halide(model: HalideGenerator, text_enc: DistillT5TextEncoder, vae,
|
| 556 |
prompts: list[str], steps: int = 50, cfg: float = 4.0,
|
| 557 |
shift: float = 2.0, resolution: int = 768, seed: int = 42,
|
| 558 |
device: str = "cuda"):
|