[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-110563":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":9,"language":10,"languages":9,"totalLinesOfCode":9,"stars":11,"forks":12,"watchers":13,"openIssues":14,"contributorsCount":14,"subscribersCount":14,"size":14,"stars1d":15,"stars7d":16,"stars30d":17,"stars90d":14,"forks30d":14,"starsTrendScore":18,"compositeScore":19,"rankGlobal":9,"rankLanguage":9,"license":20,"archived":21,"fork":21,"defaultBranch":22,"hasWiki":23,"hasPages":21,"topics":24,"createdAt":9,"pushedAt":25,"updatedAt":26,"readmeContent":27,"aiSummary":28,"trendingCount":14,"starSnapshotCount":14,"syncStatus":15,"lastSyncTime":29,"discoverSource":30},110563,"pjit-21k","Linum-AI\u002Fpjit-21k","Linum-AI","2B-parameter pixel-space text-to-image model (Pyramid-JiT) trained for $21K",null,"Python",85,5,1,0,2,6,19,7,51.23,"Apache License 2.0",false,"main",true,[],"2026-11-03 20:20:34","2026-11-23 08:41:09","\u003Cdiv align=\"center\">\n\n# A Text-to-Image Model Trained for $21K\u003Cbr>(Pyramid-JiT)\n\n**[Sahil Chopra](https:\u002F\u002Fthesahilchopra.com\u002F) · [Manu Chopra](https:\u002F\u002Fwww.linkedin.com\u002Fin\u002Fmanu-chopra-50360b170\u002F)**\n\n*Linum*\n\n[![Blog post](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fblog%20post-linum.ai%2Ffield--notes%2Fpjit--21k-6b4fd8)](https:\u002F\u002Fwww.linum.ai\u002Ffield-notes\u002Fpjit-21k)\n[![Weights](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002F%F0%9F%A4%97%20weights-Linum--AI%2Fpjit--21k-ffcc4d)](https:\u002F\u002Fhuggingface.co\u002FLinum-AI\u002Fpjit-21k)\n[![License](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Flicense-Apache--2.0-blue)](LICENSE)\n\n\u003C\u002Fdiv>\n\n![Five P-JiT 21K samples: a close-up portrait of an elderly woman in a cream headscarf, a man blowing out birthday candles, a children's book illustration of a bear sharing honey with a rabbit, a giant panda in a bamboo grove, and an alpine meadow of wildflowers](assets\u002Fsamples.jpg)\n\n*Five samples from the [blog post](https:\u002F\u002Fwww.linum.ai\u002Ffield-notes\u002Fpjit-21k)'s gallery, at the\nmodel's native ~1 MP sizes. Their prompts and seeds are [below](#reproducing-the-samples).*\n\n> [!WARNING]\n> **Research checkpoint: this is an experimental research artifact, not a production model.**\n> P-JiT 21K is a 2B-parameter model trained on 660M samples for about $21K of compute, as a\n> stepping stone towards our next video model. We're releasing it because the results\n> surprised us for a model this size, and to encourage others to explore efficient training\n> methods like ours. You should expect rough edges.\n\n> [!IMPORTANT]\n> **This model cannot write text or generate posters.** It was trained on little to no images\n> of rendered text: no infographics, PDFs, pages of books, slides or posters. We filtered that\n> data out on purpose (it isn't useful for our goal of animation tools), so prompts that ask\n> for words, signs, logos, title cards or posters will not work. The prompt upsampler returns a\n> `text_requested` error for these prompts instead of a caption.\n\nP-JiT 21K is the [P-JiT](https:\u002F\u002Fwww.linum.ai\u002Ffield-notes\u002Fpyramid-jit) architecture trained for longer:\n610M samples at 512px, 50M at 1024px, then post-training with a variant of\n[Finite Difference Flow Optimization (FDFO)](https:\u002F\u002Farxiv.org\u002Fabs\u002F2603.12893). The\n[blog post](https:\u002F\u002Fwww.linum.ai\u002Ffield-notes\u002Fpjit-21k) covers the training run.\n\n## Getting started\n\n```bash\nsudo apt-get install -y build-essential python3-dev python3-venv   # Triton compiles small CUDA shims at first use\ngit clone https:\u002F\u002Fgithub.com\u002FLinum-AI\u002Fpjit-21k && cd pjit-21k\npython3 -m venv .venv && source .venv\u002Fbin\u002Factivate\npip install -e .\n```\n\nGenerate the portrait at the top left (no API key needed: the prompt is already a detailed\ncaption, so it skips the upsampler):\n\n```bash\nPROMPT=\"Close-up portrait of an elderly Middle Eastern woman looking calmly into the lens, her face filling the tall frame. A cream headscarf and the collar of a dark green cardigan frame her chin. Soft overcast daylight smooths the fine lines of her skin, and the olive grove behind melts into silvery blur.\"\npython generate.py --no_upsample --aspect_ratio tall --seeds 2 --prompt \"$PROMPT\" --out_dir outputs\n# writes outputs\u002Fseed_2.png\n```\n\nThe weights and the Qwen3.5-4B text encoder download from the Hugging Face Hub on first use.\nThe model needs a CUDA GPU: its weights are 8.7 GB in fp32 and the text encoder 8 GB in bf16,\nplus activations.\n\n### Your own prompts\n\nThe model was trained on dense captions of 50 to 80 words, and short prompts give noticeably\nworse images. So by default `generate.py` first rewrites your prompt into a caption of that\nkind with Claude Opus 5.5 through [OpenRouter](https:\u002F\u002Fopenrouter.ai), which needs an\nOpenRouter API key ([get one here](https:\u002F\u002Fopenrouter.ai\u002Fkeys)):\n\n```bash\nexport OPENROUTER_API_KEY=...\npython generate.py --prompt \"oil painting of weathered fisherman smoking a pipe\" \\\n    --aspect_ratio square --seeds 0 --out_dir outputs\n```\n\nThe upsampler turns that prompt into a caption like this one (Claude writes a slightly\ndifferent one each time):\n\n> An oil painting of a weathered fisherman in his seventies in a close head-and-shoulders\n> portrait, a curved wooden pipe held in the corner of his mouth and a thin curl of smoke rising\n> beside his face. His skin is deeply lined and ruddy, his white beard rough, and he wears a dark\n> knitted cap and a yellow oilskin jacket. Warm lamplight falls on one cheek, laid on in thick,\n> textured brushstrokes against a muted blue-grey background.\n\nThe caption the model actually saw is printed and saved to `outputs\u002Fprompt.json` beside the\nPNGs. Pass `--no_upsample` to send a caption you've written yourself as is (no key needed).\n\n### Aspect ratios\n\n`--aspect_ratio` picks one of the five ~1 MP sizes the model was trained at:\n\n| `--aspect_ratio` | Width x height |\n|---|---|\n| `square` (default) | 1024 x 1024 |\n| `tall` | 864 x 1216 |\n| `4:3` | 1152 x 864 |\n| `3:2` | 1248 x 832 |\n| `16:9` | 1280 x 720 |\n\n`--width` and `--height` set any other size (sides that aren't a multiple of 32 are padded and\ncropped back), but the model has only seen these five.\n\n## Reproducing the samples\n\nEach image above is one seed, sampled with the default settings, no upsampling (the prompts are\nalready captions) and the initial noise drawn as on an H100 SXM. The portrait is the\n[Getting started](#getting-started) command; the other four are below. The gallery images were\nsampled five seeds to a batch, and the batch size changes how the GPU rounds its matrix\nmultiplies, so one seed on its own gives the same image with pixel values that differ by\nrounding (under 1\u002F255 on average).\n\n**Birthday** (seed 0):\n\n```bash\nPROMPT=\"Cheeks puffed, a white man in his sixties leans over a birthday cake on a kitchen table and blows out a ring of thin candles, the flames bending away from him. A checked flannel shirt covers his grey t-shirt, his grey hair neatly combed. The cake has plain white frosting and fresh strawberries, and medium-format film keeps the colours warm and natural in the centred square composition.\"\npython generate.py --no_upsample --aspect_ratio square --seeds 0 --prompt \"$PROMPT\"\n```\n\n**Bear and rabbit** (seed 4):\n\n```bash\nPROMPT=\"A children's book illustration of a big brown bear sharing a jar of honey with a small white rabbit, the bear holding the jar out toward the rabbit as they sit together under a tree, drawn in soft colored pencil with warm, gentle colors. The pair sits in the center of the frame, seen from the front at eye level, with soft, grainy pencil strokes and a pale, simply sketched background that keeps the focus on their friendly exchange.\"\npython generate.py --no_upsample --aspect_ratio square --seeds 4 --prompt \"$PROMPT\"\n```\n\n**Panda** (seed 1):\n\n```bash\nPROMPT=\"Golden-hour light slants through a bamboo grove onto a giant panda sitting on mossy ground, a wide cinematic view with the bear placed left of centre. It grips a green stalk in both front paws and chews, its black-and-white fur glowing at the edges where the low sun catches it. Tall bamboo stems stretch away to the right, their leaves lit amber, and soft haze fills the gaps between them.\"\npython generate.py --no_upsample --aspect_ratio 16:9 --seeds 1 --prompt \"$PROMPT\"\n```\n\n**Meadow** (seed 1):\n\n```bash\nPROMPT=\"An alpine meadow sweeps up toward jagged grey peaks, thick with wildflowers: purple lupines, yellow arnica, white daisies and pink clover crowding the foreground. Soft overcast light keeps the colours rich and even, and low cloud drapes the higher ridges in pale wisps. A thin stream winds through the grass from the lower right, its banks lined with moss, and a scattering of dark spruce trees marks the far edge of the meadow where the slope turns to scree.\"\npython generate.py --no_upsample --aspect_ratio 3:2 --seeds 1 --prompt \"$PROMPT\"\n```\n\n## Limitations\n\nThis is a small model (a 2B-parameter DiT with a 4B text encoder), and there are areas where it\nstruggles:\n\n- Full-body shots\n- Many entities (six cars, crowds of people)\n- Interactions between several people\n- World knowledge (six strings on a guitar, the dots on a die)\n\n## Architecture\n\n| | |\n|---|---|\n| Input patch | 32x32 px, linear 3,072 -> 1,024 -> 2,944 (1,024 tokens at 1024²) |\n| Trunk | 22 single-stream DiT blocks · width 2,944 · 23 heads x 128 · SwiGLU 7,936 |\n| Refiners | 2 image + 2 text blocks before the trunk, timestep-modulated |\n| Block | Sandwich RMSNorm, low-rank AdaLN (scale-in, tanh gate-out), q\u002Fk RMSNorm, sigmoid attention gate |\n| Position | 3-D RoPE on image tokens; height and width positions x 0.5 at 1024px (Position Interpolation from the 512px stage) |\n| Text | Qwen3.5-4B (frozen), hidden layers 7, 15, 27 concatenated -> MLP · 256 tokens |\n| Parameters | 2.18B |\n\nThe training-time readout heads and the PixelREPA adapter play no part in sampling and are not\nincluded. The [pyramid-jit](https:\u002F\u002Fgithub.com\u002FLinum-AI\u002Fpyramid-jit) repository has reference\nimplementations of them and of the rest of the pretraining objective.\n\n## Sampling\n\n50 Euler steps from noise (scale 4, the 1024px noise level) to the image, with\n[adaptive projected guidance](https:\u002F\u002Farxiv.org\u002Fabs\u002F2410.02416) at scale 15 against an empty\nnegative prompt, under bf16 autocast. The state is carried in fp32 and the model sees it\nrounded to bf16, as in the sampler the release images were made with.\n\nThe initial noise is drawn exactly as `torch.randn` draws it on an H100 SXM, the GPU the model\nwas trained on ([`pjit_21k\u002Fnoise.py`](pjit_21k\u002Fnoise.py)), so a seed gives the same image on\nany NVIDIA GPU rather than one that depends on the GPU model. Pass `--native_noise` to use the\nlocal GPU's own draw. Attention runs on FlashAttention-3 when `flash_attn_interface` is\ninstalled and on PyTorch SDPA otherwise.\n\n## Citation\n\n```bibtex\n@online{chopra2026pjit21k,\n  title = {Training a Text-to-Image Model for \\$21K},\n  author = {Chopra, Sahil and Chopra, Manu},\n  year = {2026},\n  url = {https:\u002F\u002Fwww.linum.ai\u002Ffield-notes\u002Fpjit-21k}\n}\n```\n\n## Authorship\n\nThis repository was written by Claude (Anthropic's Opus 5.5 model, running in Claude Code).\nLinum asked it to extract the model and inference code from Linum's internal experiment\nrepository and to add the prompt upsampler. The model, the training, and the review of this\nrepository are Linum's.\n\n## About Linum\n\nLinum is a team of two brothers building a tiny-yet-powerful AI research lab. We train our\nown generative media models from scratch.\n\n**Subscribe to [Field Notes](https:\u002F\u002Fbuttondown.com\u002Flinum-ai)**: technical deep dives on\nbuilding generative video models from the ground up, plus updates on new releases from Linum.\n\n**Contact:** hello@linum.ai\n\n## License\n\nApache-2.0. Copyright 2026 Linum Inc. See [LICENSE](LICENSE).\n","P-JiT 21K 是一个在像素空间（pixel-space）直接生成图像的文本到图像扩散模型，参数量约20亿，训练成本仅约2.1万美元。其核心采用 Pyramid-JiT（P-JiT）分层架构，支持512px与1024px双尺度训练，并结合有限差分流优化（FDFO）提升生成质量；模型明确排除含文本图像（如海报、标题卡），专注高保真自然场景与人物肖像生成。适用于低成本AI图像研究、轻量级生成模型训练方法探索、动画前期视觉概念生成等非文本依赖型创作场景。","2026-11-24 04:39:18","CREATED_QUERY"]