# prismflow_2b Manual [Model card](README.md) · [Example gallery](GALLERY.md) · [Technical report](TECHNICAL_REPORT.md) · [Release notes](RELEASES.md) > [!WARNING] > This manual describes release 0.06, an early research preview trained at 256 > and 384 px only. Its defaults were chosen at step 190,000, verified at step > 378,000, and may change in later releases. ## Contents 1. [Installation](#installation) 2. [A first image](#a-first-image) 3. [Prompts](#prompts) 4. [JSON layouts](#json-layouts) 5. [Image sizes](#image-sizes) 6. [Sampling](#sampling) 7. [Guidance](#guidance) 8. [Python API reference](#python-api-reference) 9. [ComfyUI node reference](#comfyui-node-reference) 10. [Troubleshooting](#troubleshooting) ## Installation prismflow_2b needs Python 3.12 or later, PyTorch 2.13 with CUDA, and an NVIDIA GPU with bfloat16 support. Install a CUDA build of PyTorch first; the [PyTorch installation selector](https://pytorch.org/get-started/locally/) gives the command for your system. The repository holds the denoiser weights, the text encoder, the `prismflow` Python package and the ComfyUI nodes. The autoencoder, [dinac3_96](https://huggingface.co/data-archetype/dinac3_96) version 1.51, downloads into the Hugging Face cache, at a pinned commit, the first time the model is loaded. ### ComfyUI The repository is a ComfyUI custom-node folder. Download it into `custom_nodes` and install its requirements into ComfyUI's Python environment: ```bash cd ComfyUI/custom_nodes hf download data-archetype/prismflow_2b_research_preview --local-dir prismflow_2b_research_preview pip install -r prismflow_2b_research_preview/requirements.txt ``` Restart ComfyUI. The nodes appear under the **PrismFlow** category. Start ComfyUI with `--preview-method auto` for live previews. ### Python Download the repository and install the package from it. The install is editable, so Python runs the code in that folder: ```bash hf download data-archetype/prismflow_2b_research_preview --local-dir prismflow_2b_research_preview pip install -e prismflow_2b_research_preview ``` `diffusers` is needed only for the optional [diffusers wrapper](#diffusers-wrapper). ### Updating and older versions Each release is tagged on the Hub with its version, such as `v0.05`. [RELEASES.md](RELEASES.md) lists them, and the training-history table on the [model card](README.md#training-history) links each release's gallery and the section of the technical report measured on its weights. To update, run the download again into the same folder and reinstall the requirements. Only the files that changed are downloaded; files a newer release no longer has stay in the folder. Then restart ComfyUI: ```bash cd ComfyUI/custom_nodes hf download data-archetype/prismflow_2b_research_preview --local-dir prismflow_2b_research_preview pip install -r prismflow_2b_research_preview/requirements.txt ``` To try the weights of an older release with the installed nodes, set the PrismFlow Loader's `source` to `hub` and its `revision` to the tag, such as `v0.05`. The weights download into the Hugging Face cache. In Python, pass the tag as `revision`: ```python pipe = PrismFlowPipeline.from_pretrained( "data-archetype/prismflow_2b_research_preview", revision="v0.05" ) ``` The installed code loads the weights of the releases it lists as compatible, and says which ones when it refuses a release. A saved ComfyUI workflow keeps the loader's source and revision, and images from the Python pipeline name the release of their weights in the `model` field of their [PNG metadata](#png-metadata). To reproduce an older release's images exactly, to load weights the installed code does not accept, or to start from a clean folder, install the release whole, replacing the folder: ```bash cd ComfyUI/custom_nodes rm -rf prismflow_2b_research_preview hf download data-archetype/prismflow_2b_research_preview --revision v0.05 --local-dir prismflow_2b_research_preview pip install -r prismflow_2b_research_preview/requirements.txt ``` Keep a single copy in `custom_nodes`: ComfyUI loads every folder there, and two copies register the same nodes. For the Python package, run the same `hf download` command where the folder is; the editable install uses the new files. ### Compilation The denoiser, the text encoder and the autoencoder are compiled with `torch.compile` by default. The first generation takes about 17 seconds on an RTX 4090 while the graphs are built; after that, a 50-step 384×384 image takes about 2 seconds, with a peak of about 7 GB of VRAM. To turn compilation off, pass `compile=False` in Python or switch `compile_model` off in the PrismFlow Loader node. The model then starts at once and each image takes longer. ## A first image ### In ComfyUI Load `prismflow_2b_research_preview/comfyui/workflows/prismflow_default.json` and queue it. It uses the default settings. You can also drop any PNG from the [gallery](GALLERY.md) onto the canvas: each one carries the workflow that made it. The default graph has ten nodes, connected as follows: - **PrismFlow Loader** outputs the model, the text encoder and the autoencoder. - **PrismFlow Text Encode** takes the text encoder and the prompt. - **PrismFlow Guider** takes the model and the encoded prompt. - **PrismFlow Empty Latent** sets the image size. - **PrismFlow Sampler** feeds **PrismFlow Time Schedule**, which also takes the latent and outputs the sigmas and the sampler. - **RandomNoise** sets the seed. - **SamplerCustomAdvanced** takes the noise, the guider, the sampler, the sigmas and the latent. - **VAEDecode** takes the result and the loader's autoencoder, and **SaveImage** stores the image. RandomNoise, SamplerCustomAdvanced, VAEDecode and SaveImage are ComfyUI's own nodes. The [node reference](#comfyui-node-reference) lists every input. ### In Python ```python from prismflow.inference import GenerationSettings from prismflow.pipeline import PrismFlowPipeline pipe = PrismFlowPipeline.from_pretrained("prismflow_2b_research_preview") settings = GenerationSettings(width=384, height=384, seed=7) image = pipe("A lighthouse on a cliff at dusk.", settings).images[0] image.save("lighthouse.png", pnginfo=pipe.png_info(image)) ``` `"prismflow_2b_research_preview"` is the folder downloaded during installation. `GenerationSettings()` with no arguments is the default preset, and the seed fixes every random draw of the call. ## Prompts ### Plain captions Natural descriptive captions work best. Write what a careful caption of the finished image would say: the subject, what it is doing, the setting, the light and the medium (a photograph, an oil painting, a movie still). Full sentences work better than lists of keywords, and a long, detailed prompt is fine. The limit is 6,144 tokens, counting the few tokens the model adds; a longer prompt raises an error and is never cut short. ### Quoted text for lettering To put words in the image, write them in double quotes inside the caption: ```text A neon sign in a rainy street that reads "OPEN LATE". ``` Everything inside straight (`"…"`) or curly (`“…”`) double quotes on one line is encoded one character at a time, so the model sees the exact spelling. Use double quotes only for text that should be visible in the image. To place text precisely, use a [JSON layout](#json-layouts). ### No emphasis markup Prompts are read exactly as written. Unlike dflow_2b, prismflow_2b has no `(phrase:weight)` emphasis: parentheses, colons and numbers are ordinary text and are encoded as such. ### Negative prompts A negative prompt is the text of the unconditional pass of classifier-free guidance, described under [Guidance](#guidance). It is empty by default, which selects the model's learned null text. With the default guidance, the unconditional pass is also weakened through the model's depth routing, whether it reads a negative prompt or the null text. ## JSON layouts A layout prompt describes an image as a canvas with a list of boxes. It gives control over where things are and over the exact text that appears. Layouts suit posters, covers, title cards and other designed images. ### The stored format A layout is a JSON object with exactly three keys: `summary`, `frame` and `items`. **`summary`** describes the image as a whole. | Field | Type | Meaning | | --- | --- | --- | | `meta` | list of strings | Tags for the kind of image, such as `concert_poster` | | `canvas` | string | The canvas type; `single` in the examples here | | `caption` | string | A caption of the whole image | **`frame`** describes the canvas: the overall arrangement, style and colours. | Field | Type | Meaning | | --- | --- | --- | | `caption` | string | How the image is composed | | `tags` | list of strings | Style and composition tags | | `palette` | list of strings | Main colours as hex codes | **`items`** is a list of boxes, one per element. | Field | Type | Meaning | | --- | --- | --- | | `label` | string | `character`, `object` or `text` | | `box_2d` | four integers | The box as `[y0, x0, y1, x1]` on a 0 to 1000 scale | | `text` | string | The exact string to render; required for `text` items | | `caption` | string | A description of this element | | `tags` | list of strings | Tags for this element | | `palette` | list of strings | Its colours as hex codes | Boxes are measured from the top-left corner of the image. `y0` and `y1` are the top and bottom edges as thousandths of the image height, and `x0` and `x1` are the left and right edges as thousandths of the width. The vertical coordinate comes first. ### Optional fields The required fields are the three top-level keys and, for each item, `label` and `box_2d`, plus `text` on a text item. Every other field can be left out: training dropped the optional fields at random. Captions, tags and palettes give the model more to work with, and a layout with labels and boxes alone still works. Unknown keys raise an error. ### Compiling a layout to a size Before encoding, a layout is compiled for one image size: the frame becomes a first item, labelled `panel`, that covers the whole canvas, and every box is converted from the 0 to 1000 scale to integer pixels measured from the centre of the image. For an image \\(Y\\) pixels high, the top edge \\(y_0\\) and bottom edge \\(y_1\\) of a box become $$ y_0' = \left\lfloor \frac{y_0\,Y}{1000} \right\rfloor - \left\lfloor \frac{Y}{2} \right\rfloor, \qquad y_1' = \left\lceil \frac{y_1\,Y}{1000} \right\rceil - \left\lfloor \frac{Y}{2} \right\rfloor, $$ and the left and right edges are computed the same way from the width. At 288×448 the panel box is `[-224, -144, 224, 144]`. The result is one line of JSON with two fields naming the convention (`abs_centralized`, `yxyx`), in the format of the MOSS-Image layout prompts. The compiled boxes are in pixels, so a compiled layout belongs to one image size: the same stored layout compiles to different numbers at 288×448 and at 448×288. A compiled layout whose boxes do not fit the image size raises an error. Keep layouts in the stored format, which is independent of size, and let the code compile them: - In ComfyUI, the **PrismFlow Layout Encode** node takes the stored JSON together with `width` and `height`. Set them to the size of the latent you sample. The guider stops with a message when they differ. - In Python, pass the stored JSON as the prompt. The pipeline compiles it at the size in `GenerationSettings`. The function that does this is `prismflow.inference.resolve_prompt`, and `prismflow.layout.compile_layout` returns the compiled text if you want to inspect it. ### MOSS-Image layouts The model reads the compiled form, which is the layout prompt format of [MOSS-Image](https://github.com/OpenMOSS/MOSS-Image). MOSS-Image layouts work wherever a stored layout does, and are converted as follows: - **MOSS-Image layout prompts** (`bbox` in pixels from the centre, `abs_centralized`, `yxyx`), such as the output of ComfyUI's MOSS-Image Layout Prompt node, keep their items. Every layout the model was trained on began with a full-canvas `panel` item, so a prompt without one gets a bare panel (label and box only) put first. Every box must fit the image size. - **MOSS-Image editable drafts** (`width`, `height`, `bbox` in pixels from the top-left, `abs`, `xyxy`) are compiled the way MOSS-Image's `compile_prompt.py` compiles them, then given the panel. The draft's `width` and `height` must equal the image size. In ComfyUI, give either to PrismFlow Layout Encode. PrismFlow Text Encode passes its text as written, so the guider accepts a layout from it only when the text is already exactly what Layout Encode would produce at the image size (one line of JSON, full-canvas panel first); anything else stops with an error that points to Layout Encode. ### Worked example: a jazz festival poster This layout describes a 288×416 poster (width × height) with a sun, a saxophonist and two lines of text: ```json {"summary": { "meta": ["concert_poster", "flat_illustration", "mid_century_modern"], "canvas": "single", "caption": "A mid-century style jazz festival poster shows a saxophonist in silhouette against a large orange sun on a deep teal background. The title \"BLUE HARBOR JAZZ\" runs across the top in cream capitals and the line \"JULY 12 – 14, 1996\" sits at the bottom."}, "frame": { "caption": "The saxophonist stands in the centre, cut off at the knees, with the sun behind his shoulders. The title fills the top fifth and the date line sits in a band along the bottom edge. Flat colour shapes with a light paper grain.", "tags": ["flat_color", "centered_composition", "paper_grain"], "palette": ["#0F4C5C", "#F28C28", "#F5E9D0", "#1B1B1B"]}, "items": [ {"label": "object", "caption": "A large flat orange circle, the sun, behind the musician.", "tags": ["sun", "circle"], "palette": ["#F28C28"], "box_2d": [230, 170, 720, 830]}, {"label": "character", "caption": "A black silhouette of a man in a hat playing a tenor saxophone, facing right, leaning back slightly.", "tags": ["saxophonist", "silhouette", "hat"], "palette": ["#1B1B1B"], "box_2d": [260, 250, 880, 760]}, {"label": "text", "caption": "The title \"BLUE HARBOR JAZZ\" in bold condensed cream capitals on one line.", "text": "BLUE HARBOR JAZZ", "tags": ["title", "condensed_sans", "uppercase"], "palette": ["#F5E9D0"], "box_2d": [60, 70, 180, 930]}, {"label": "text", "caption": "The date line \"JULY 12 – 14, 1996\" in small spaced cream capitals.", "text": "JULY 12 – 14, 1996", "tags": ["date", "small_caps"], "palette": ["#F5E9D0"], "box_2d": [905, 300, 950, 700]}]} ``` Reading it from the top: - The summary caption describes the finished poster in one paragraph, as a plain prompt would, and quotes both lines of text. - The frame caption says how the canvas is arranged, and the palette lists the four colours of the design. - The sun comes first in `items` and the saxophonist second. Their boxes overlap, which is how the layout says that the figure stands in front of the sun. - The title box `[60, 70, 180, 930]` spans from 6% to 18% of the height and from 7% to 93% of the width: a wide band near the top. The `text` field holds the string to render and the caption describes the lettering. The same layout, at the same 288×416 size, ships as the workflow `comfyui/workflows/prismflow_layout_poster.json`; the Python call below renders the same image as that workflow (seed 42). In Python: ```python from pathlib import Path from prismflow.inference import GenerationSettings from prismflow.pipeline import PrismFlowPipeline pipe = PrismFlowPipeline.from_pretrained("prismflow_2b_research_preview") layout = Path("jazz_poster.json").read_text(encoding="utf-8") settings = GenerationSettings(width=288, height=416, seed=42) image = pipe(layout, settings).images[0] ``` At 288×416 the sun's box `[230, 170, 720, 830]` compiles to `[-113, -96, 92, 96]`: pixels from the image centre, top edge first. ### Tips - Write the exact characters in `text`, including capitals, punctuation and spaces. The model renders that string; the item's caption describes its style. - Keep the number of items small. A handful of well-described boxes works better than many small ones. - Boxes may overlap or contain one another. - Give each box the shape of its content. A single line of text wants a wide, short box. - At 384 px a small box is only a few dozen pixels, and text often comes out wrong in this release, so prefer short strings in generous boxes. ## Image sizes Width and height must be multiples of 16, because the autoencoder maps each 16×16 block of pixels to one latent cell. Release 0.06 has been trained on two families of aspect-ratio buckets only: 256 px, which most of its training used, and 384 px, for 10% of the batches. Use the 384-px buckets below. The default is 384×384. Every bucket has about the area of a 384×384 square, and both sides are multiples of 32. | Aspect ratio (width : height) | Landscape | Portrait | | --- | --- | --- | | 1 : 1 | 384×384 | 384×384 | | 1.09 | 384×352 | 352×384 | | 1.2 | 384×320 | 320×384 | | 1.3 | 416×320 | 320×416 | | 1.44 | 416×288 | 288×416 | | 1.56 | 448×288 | 288×448 | | 1.67 | 480×288 | 288×480 | | 1.88 | 480×256 | | | 2 | 512×256 | 256×512 | | 2.13 | 544×256 | 256×544 | | 2.57 | 576×224 | 224×576 | | 3.17 to 4 | 608×192, 640×192, 672×192, 704×192, 736×192, 768×192 | 192×608, 192×640, 192×672, 192×704, 192×736, 192×768 | The 256-px buckets, about two thirds of the side length, are also within training and give less room for detail. Larger images are outside what this release has seen, and results get worse as the area grows: 512×512 already has nearly twice the area of the largest training images. Shapes far from the buckets are also less reliable. ## Sampling Sampling starts from noise and moves to the image in a number of solver steps. Time runs from \\(t = 1\\), pure noise, to \\(t = 0\\), the finished image. Three choices define a sampling run: the solver, the schedule of times it visits, and a shift applied to that schedule. ### Solvers A solver is the numerical method that takes each step. Some are deterministic, and some are stochastic: they add fresh noise at each step. For a stochastic solver the noise scale multiplies that noise; deterministic solvers ignore it. | Name | Method | Stochastic | Noise scale | | --- | --- | --- | --- | | `euler_ancestral` (default) | Ancestral Euler: each step predicts the clean image and re-noises it to the next time, part of the noise fresh | yes | Acts as eta, from 0 to 1; 1.0 is the full ancestral step, 0 is plain Euler | | `er_sde` | Extended reverse-time SDE, three-stage | yes | 1.0 (scales only the injected noise; keep at 1.0 to stay on the marginal) | | `er_sde_bt` | The same with Brownian-tree noise, so runs with different step counts follow one noise path | yes | 1.0 | | `euler` | First-order ODE | no | ignored | | `euler_maruyama` | First-order reverse SDE | yes | 1.0 is the SDE's own noise level | | `dpmpp_2m` | DPM++ 2M, second-order multistep ODE | no | ignored | | `dpmpp_2m_sde` | DPM++ 2M SDE | yes | Acts as eta; use 0.5 | | `abm2` | Adams–Bashforth–Moulton predictor-corrector | no | ignored | `abm2` evaluates the model twice per step, so it takes about twice as long per step as the others. Plain Euler shows the clipping that guidance can cause much more than Euler ancestral does. ### Schedules The schedule sets where the solver's time points lie between noise and image, before the shift. | Name | Spacing | | --- | --- | | `beta_0_6` (default) | Quantiles of Beta(0.6, 0.6): denser at both ends (ComfyUI's "beta" scheduler) | | `linear` | Evenly spaced | | `beta_1_25` | Quantiles of a Beta(1.25, 1.25) distribution: slightly denser in the middle | | `custom_beta` | Quantiles of a Beta distribution you specify by `beta_mean` in (0, 1) and `beta_concentration` above 0 | For `custom_beta` the two Beta parameters are `beta_mean × beta_concentration` and `(1 − beta_mean) × beta_concentration`. A mean above 0.5 puts more steps near the noisy end. A concentration of 2 at mean 0.5 is the linear schedule; higher values gather steps around the mean and lower values push them to the ends. Mean 0.5 with concentration 1.2 is `beta_0_6`. ### Steps The default is 50 steps. With the default guidance each step calls the denoiser twice, once conditioned on the prompt and once unconditioned, and both calls run the whole network. ### Resolution-dependent shift A larger image needs more noise to hide the same amount of structure. The model was trained with a timestep shift that grows with the image area, and the sampler applies the same shift by default. The shift \\(s\\) is expressed in log signal-to-noise ratio. For an image of width \\(W\\) and height \\(H\\) in pixels, $$ s = \min\!\left(0,\; b - \ln\frac{W H}{256^2}\right), \qquad b = -0.25 . $$ Each schedule time \\(t\\) strictly between 0 and 1 is then moved to $$ t' = \sigma\!\left(\operatorname{logit}(t) - \tfrac{s}{2}\right), $$ where \\(\sigma\\) is the logistic function. A negative shift moves the time points towards the noisy end. | Size | Shift \\(s\\) | | --- | --- | | 256×256 | −0.25 | | 288×448, 448×288 | −0.93 | | 384×384, 768×192 | −1.06 | | 512×512 | −1.64 | Across the 384-px buckets the shift lies between −0.83 and −1.06. Two settings control the shift. `base_log_snr_shift` is \\(b\\), default −0.25. `resolution_shift` adds the size term and is on by default; with it off, the shift is \\(b\\) alone at every size. The defaults match how the model was trained. ## Guidance Guidance sharpens an image and strengthens its adherence to the prompt by comparing two predictions at each step and pushing the result away from the weaker one. ### Classifier-free guidance prismflow_2b uses classifier-free guidance (CFG). At each step it combines a conditional prediction \\(v_c\\), from the prompt, and an unconditional prediction \\(v_u\\), from the negative prompt or from the learned null text when the negative prompt is empty: $$ v = v_u + w\,(v_c - v_u) . $$ A scale \\(w\\) of 1 is no guidance. The default is 2.8. PrismFlow's trunk is dense: every layer runs on every token, so there are no layers to skip and dflow_2b's path-drop guidance is not available. ### Split-merge guidance Plain CFG follows the prompt but softens fine detail, flattens lighting and sometimes loses structural coherence. Guidance against a weaker version of the model itself behaves better. The default guidance, split-merge guidance, keeps the conditional pass as it is and makes the unconditional pass a weaker model by changing how it combines its layers. The 28 layers of the trunk form 7 blocks of 4. After each block a small attention over depth, a merge, mixes the input embedding (the latent patches and registers as they enter the first layer) and the outputs of the blocks so far. The merges are numbered 0 to 6, and merge \\(k\\) follows layers \\(4k\\) to \\(4k + 3\\), counted from 0. A **newest-slot shift** adds a negative bias to the merge's score for the block that has just run, so that the pass uses less of what that block computed. The weight taken from it goes to the other sources of the merge, in one of two ways: - **Input embedding frozen.** The weight of the input embedding stays as it was, and the earlier blocks share the rest. This keeps colour and contrast and sharpens texture. - **Input embedding not frozen.** All sources are renormalised together, and most of the weight goes to the input embedding. This calms exposure and keeps shadows and highlights from clipping, but used widely it washes out colour. The default uses both: | Merges | Shift | Input embedding | Steps | | --- | ---: | --- | --- | | 2, 3 and 4 | −1.5 | frozen | all | | 5 | −0.5 | not frozen | first 40% (steps 0 to 20 of 50) | The other merges, and every merge of the conditional pass, are unchanged. The shifts cost almost nothing, so a guided step costs two full denoiser calls, as with plain CFG. The [technical report](TECHNICAL_REPORT.md#split-merge-block-attnres-guidance) gives the formulas, and the [guidance ablation](TECHNICAL_REPORT.md#appendix-c-guidance-ablation-table) of release 0.06 the measurements behind the defaults. ### Step windows CFG has a step window: a first and a last step, both inclusive, counted from 0. Outside it only the conditional pass runs and the result is not guided. The default window covers every step. Each shift has a percent window: 0% is the first step and 100% the last. A window from \\(a\\)% to \\(b\\)% of \\(N\\) steps covers the steps with index \\(\lfloor \tfrac{a}{100}(N-1) + \tfrac12 \rfloor\\) to \\(\lfloor \tfrac{b}{100}(N-1) + \tfrac12 \rfloor\\), so 0% to 40% of 50 steps is steps 0 to 20. A shift acts only on steps where CFG runs. ### Rules for shifts - A shift names one or more merges from 0 to 6. Two shifts may not name the same merge. - Its bias is not zero and lies between −6 and 6. Negative values weaken the unconditional pass; that is the intended direction. - Shifts need CFG. To turn CFG off, remove the shifts as well. Settings that break these rules raise a `ValueError` when they are built, or, for the CFG step window and the merge numbers, when sampling starts, before the first step. ### Defaults | Setting | Default | | --- | --- | | CFG | on, scale 2.8, all steps | | Shift on merges 2, 3 and 4 | −1.5, input embedding frozen, 0% to 100% of the steps | | Shift on merge 5 | −0.5, input embedding not frozen, 0% to 40% of the steps | | Negative prompt | empty (the learned null text) | ### Recipes Each recipe changes one thing from the defaults. The Python snippets build a `GuidanceSettings` object, which goes into `GenerationSettings(guidance=...)`. They use these imports: ```python from prismflow.guidance import ( DEFAULT_NEGATIVE_SHIFTS, CfgGuidance, GuidanceSettings, NewestSlotShift, PercentWindow, StepWindow, ) ``` In ComfyUI, the **PrismFlow Guider** node switches CFG and the default shifts on and off and sets the CFG scale. **PrismFlow Guider Advanced**, which takes the guider as input, sets the CFG step window and each shift. **A different CFG scale**, with the default shifts. Lower values are softer, higher values add contrast and clipping. ```python GuidanceSettings(cfg=CfgGuidance(scale=3.2)) ``` **Plain CFG**, without split-merge (`routing_shifts` off on PrismFlow Guider). Expect softer detail and flatter lighting at the same scale. ```python GuidanceSettings(cfg=CfgGuidance(scale=3.0), negative_shifts=()) ``` **Only the frozen shift**, on every step: the sharpest images, with more clipping. ```python GuidanceSettings(negative_shifts=(DEFAULT_NEGATIVE_SHIFTS[0],)) ``` **A stronger late shift**, here −1.0 on merge 5 over the first half of the steps. ```python GuidanceSettings( negative_shifts=( DEFAULT_NEGATIVE_SHIFTS[0], NewestSlotShift( merges=(5,), bias=-1.0, freeze_v0=False, window=PercentWindow(0.0, 50.0) ), ) ) ``` **CFG on part of the run only**, here steps 0 to 39 of 50. ```python GuidanceSettings(cfg=CfgGuidance(window=StepWindow(0, 39))) ``` **No guidance** (`cfg_enabled` and `routing_shifts` off on PrismFlow Guider). One denoiser call per step; images follow the prompt much less closely. ```python GuidanceSettings(cfg=CfgGuidance(enabled=False), negative_shifts=()) ``` **A negative prompt.** It goes in `GenerationSettings(negative_prompt=...)`, or into a second PrismFlow Text Encode node connected to the guider's `negative` input. The default shifts apply to it as they do to the null text. ## Python API reference All classes below are frozen dataclasses unless noted. Their defaults are the default preset, so `GenerationSettings()` reproduces it. ### PrismFlowPipeline `prismflow.pipeline.PrismFlowPipeline` loads the model and turns prompts into images. ```python PrismFlowPipeline.from_pretrained( path_or_repository="data-archetype/prismflow_2b_research_preview", *, device="cuda", compile=True, revision=None, cache_dir=None, vae_dir=None, ) ``` | Argument | Meaning | | --- | --- | | `path_or_repository` | A local release folder, or a Hub repository id to download | | `device` | A CUDA device | | `compile` | Compile with `torch.compile`; `False` runs eagerly | | `revision` | Hub revision, such as a release tag, for a repository id; a local folder takes none | | `cache_dir` | Hugging Face cache directory; `None` for the default | | `vae_dir` | A local copy of `data-archetype/dinac3_96`, for offline use; `None` downloads the pinned commit | Calling the pipeline generates images: ```python pipe( prompt, settings=None, *, num_images=1, output_type=OutputType.PIL, image_to_image=None, callback=None, ) ``` | Argument | Meaning | | --- | --- | | `prompt` | One prompt, or a list of prompts that all have the same number of tokens | | `settings` | A `GenerationSettings`; `None` uses `pipe.default_settings` | | `num_images` | Images to make from a single prompt string | | `output_type` | What to return; see `OutputType` | | `image_to_image` | An `ImageToImage`, to start from existing latents | | `callback` | A latent callback, called after each solver step | A prompt may be a plain caption or a layout in any form that [JSON layouts](#json-layouts) describes; a compiled layout's boxes must fit the requested size. The images of one call share the seed and differ because each gets its own noise. The result is a `PrismFlowOutput` with three fields: `images`, a list of PIL images for PIL output; `tensors`, the RGB or latent tensor for the other output types; and `settings`, the settings used. ### PrismFlowComponents `prismflow.pipeline.PrismFlowComponents` holds the loaded parts and is available as `pipe.components`. `PrismFlowComponents.from_pretrained` takes the same arguments as the pipeline's. | Field | Meaning | | --- | --- | | `engine` | The denoiser and text encoder. `engine.sample(prompts, settings, *, image_to_image=None, callback=None)` returns latents | | `vae` | The autoencoder. `vae.decode(latents)` returns RGB in about [−1, 1], unclamped; `vae.encode(images)` takes RGB in [−1, 1] with sides that are multiples of 16 | | `compiled` | Whether the model was compiled | | `weights_version` | The release the loaded weights come from, such as `0.05` | Latents are float32 tensors of shape `[B, 96, height / 16, width / 16]`. ### GenerationSettings `prismflow.inference.GenerationSettings` holds everything except the prompt that defines one generation. | Field | Default | Meaning | | --- | --- | --- | | `width` | 384 | Image width, a multiple of 16 | | `height` | 384 | Image height, a multiple of 16 | | `seed` | 0 | Seed of every random draw, from 0 to 2⁶³ − 1 | | `sampling` | `SamplingSettings()` | Solver, schedule and shift | | `guidance` | `GuidanceSettings()` | CFG and its shifts | | `negative_prompt` | `""` | Text of the unconditional pass; empty selects the learned null text | The starting noise is drawn on the CPU from the seed, so a seed gives the same noise on every GPU. ### SamplingSettings `prismflow.inference.SamplingSettings`: | Field | Default | Meaning | | --- | --- | --- | | `solver` | `Solver.EULER_ANCESTRAL` | A member of `prismflow.solvers.Solver` | | `noise_scale` | 1.0 | Noise multiplier of stochastic solvers; eta for `euler_ancestral` (0 to 1) and `dpmpp_2m_sde` | | `schedule` | `TimeSchedule(kind=ScheduleKind.BETA_0_6, steps=50)` | Spacing and step count | | `base_log_snr_shift` | −0.25 | The size-independent part of the shift | | `resolution_shift` | `True` | Add the image-size term | `prismflow.schedules.TimeSchedule` has `kind` (a `ScheduleKind`), `steps` (default 50), and `beta_mean` and `beta_concentration` for `CUSTOM_BETA` (defaults 0.5 and 1.2, which is `beta_0_6`). A `TimeSchedule` built on its own defaults to `ScheduleKind.LINEAR`, so name the kind when you change the step count: ```python from prismflow.inference import GenerationSettings, SamplingSettings from prismflow.schedules import ScheduleKind, TimeSchedule from prismflow.solvers import Solver settings = GenerationSettings( width=288, height=448, seed=3, sampling=SamplingSettings( solver=Solver.DPMPP_2M, schedule=TimeSchedule(kind=ScheduleKind.BETA_0_6, steps=40), ), ) ``` ### GuidanceSettings and its parts `prismflow.guidance.GuidanceSettings`: | Field | Default | Meaning | | --- | --- | --- | | `cfg` | `CfgGuidance()` | Classifier-free guidance | | `negative_shifts` | `DEFAULT_NEGATIVE_SHIFTS` | Shifts of the unconditional pass; `()` for plain CFG | The parts, all in `prismflow.guidance`: | Class | Fields and defaults | | --- | --- | | `CfgGuidance` | `enabled=True`, `scale=2.8` (finite, at least 0), `window=StepWindow()` | | `StepWindow` | `start_step=0`, `stop_step=None` (the last step); both inclusive | | `NewestSlotShift` | `merges` (merge indices, 0 to 6), `bias` (non-zero, −6 to 6), `freeze_v0` (keep the input embedding's weight), `window=PercentWindow()`; the first three have no default | | `PercentWindow` | `start_percent=0.0`, `end_percent=100.0`; both inclusive | `DEFAULT_NEGATIVE_SHIFTS` is the pair of shifts of the [default guidance](#split-merge-guidance): merges 2, 3 and 4 at −1.5 with the input embedding frozen on every step, then merge 5 at −0.5 without freezing over the first 40% of the steps. ### ImageToImage `prismflow.inference.ImageToImage` starts sampling from existing latents, noised to the time of a later schedule step. | Field | Meaning | | --- | --- | | `latents` | `[B or 1, 96, h, w]` latents of the generation size, for example from `pipe.components.vae.encode` | | `start_step` | The step of the schedule at which sampling starts, from 0 to `steps − 1` | The schedule is built at its full step count. The latents are noised to the time of `start_step` with the seed's noise, and the remaining steps run. A later start step keeps more of the input image. Guidance step windows, and the shifts' percent windows, count over the remaining steps. ### OutputType `prismflow.pipeline.OutputType`: | Member | Result | | --- | --- | | `PIL` | `images`: PIL images that carry their generation metadata | | `TENSOR` | `tensors`: `[B, 3, H, W]` float32 RGB in [−1, 1] | | `LATENT` | `tensors`: undecoded `[B, 96, H/16, W/16]` latents | ### Previews during sampling A latent callback has the signature `callback(latents, completed, total)`. It is called after each solver step with the model's current estimate of the finished latents and the step counts. `prismflow.preview.LatentRgbPreview` is a fitted projection from those latents to a small RGB image, at one eighth of the image resolution. ```python from prismflow.preview import LatentRgbPreview, preview_images preview = LatentRgbPreview.bundled().to(pipe.components.engine.device) def show(latents, completed, total): image = preview_images(preview.project(latents))[0] image.save(f"preview_{completed:03d}.png") image = pipe("A lighthouse on a cliff at dusk.", callback=show).images[0] ``` ### PNG metadata Each PIL image returned by the pipeline carries a JSON description of how it was made in `image.info["prismflow"]`: the release of the weights (`model`, such as `prismflow_2b 0.05`), the package version (`package`), the prompt as given, the index of the image in its batch and the complete settings. To keep it in the saved file, pass it to `save`: ```python image.save("out.png", pnginfo=pipe.png_info(image)) ``` The text is stored in a PNG text chunk named `prismflow`. ### Diffusers wrapper `prismflow.diffusers_pipeline.PrismFlowDiffusersPipeline` offers the call signature of a diffusers pipeline. It requires `diffusers` to be installed and wraps a `PrismFlowPipeline`; the model, sampler and guidance are the same. ```python from prismflow.diffusers_pipeline import PrismFlowDiffusersPipeline pipe = PrismFlowDiffusersPipeline.from_pretrained("prismflow_2b_research_preview") image = pipe( "A lighthouse on a cliff at dusk.", height=384, width=384, num_inference_steps=50, guidance_scale=2.8, generator_seed=7, ).images[0] ``` | Argument | Default | Meaning | | --- | --- | --- | | `prompt` | | The prompt | | `negative_prompt` | `""` | Text of the unconditional pass; empty selects the learned null text | | `height`, `width` | 384, 384 | Image size | | `num_inference_steps` | 50 | Solver steps, on the default `beta_0_6` schedule | | `guidance_scale` | 2.8 | The CFG scale; the default shifts stay on | | `num_images_per_prompt` | 1 | Images to generate | | `generator_seed` | 0 | The seed | | `settings` | `None` | A full `GenerationSettings`; when given it replaces every argument except the prompt, the negative prompt and the image count | A negative prompt with settings whose CFG is off raises a `ValueError`, since nothing would read it. `from_pretrained` takes the path or Hub id, `device`, `compile` and `revision`. The wrapper does not support `save_pretrained` or loading through `DiffusionPipeline.from_pretrained`. ## ComfyUI node reference The nodes are in the **PrismFlow** category. Their defaults are the default preset. ### PrismFlow Loader Loads the denoiser, the text encoder and the autoencoder. Outputs: `model`, `text_encoder`, `vae`. The `vae` output works with ComfyUI's VAEDecode and VAEEncode nodes. | Input | Default | Meaning | | --- | --- | --- | | `source` | `bundled` | `bundled` reads the weights in the node folder; `local_dir` another folder; `hub` a Hugging Face repository | | `local_dir` | empty | Release folder, for the `local_dir` source | | `repository` | `data-archetype/prismflow_2b_research_preview` | Repository id, for the `hub` source | | `revision` | empty | Hub revision, such as a release tag (`v0.05`); empty for `main` | | `compile_model` | on | Compile the model with `torch.compile` | | `cache_dir` | empty | Hugging Face cache directory; empty for the default | ### PrismFlow Text Encode Encodes a plain prompt exactly as written. Output: `conditioning`. There are no emphasis inputs: prompts are read verbatim. A layout given here reaches the model only if it is already in the compiled form Layout Encode produces at the image size; otherwise the guider stops with an error. | Input | Default | Meaning | | --- | --- | --- | | `text_encoder` | | From the loader | | `text` | empty | The prompt | | `batch_size` | 1 | Copies of the prompt; must equal the latent's batch size | For a negative prompt, add a second PrismFlow Text Encode node and connect it to the guider's `negative` input. Stored layouts and MOSS-Image drafts go to PrismFlow Layout Encode, which takes the image size they are compiled for. ### PrismFlow Layout Encode Compiles a layout at the image size and encodes it. Output: `conditioning`. | Input | Default | Meaning | | --- | --- | --- | | `text_encoder` | | From the loader | | `layout_json` | empty | A stored or compiled layout, or a MOSS-Image layout prompt or draft | | `width` | 384 | Image width the layout is for | | `height` | 384 | Image height the layout is for | | `batch_size` | 1 | Copies of the prompt | `width` and `height` must equal the size of the latent that is sampled. ### PrismFlow Guider Sets classifier-free guidance and switches the [split-merge shifts](#split-merge-guidance) on or off. Output: `guider`. CFG runs on every step; PrismFlow Guider Advanced sets a step window. | Input | Default | Meaning | | --- | --- | --- | | `model` | | From the loader | | `positive` | | The prompt's conditioning | | `negative` | not connected | Optional conditioning of the unconditional pass; the learned null text when not connected | | `cfg_enabled` | on | Classifier-free guidance | | `cfg_scale` | 2.8 | CFG scale; 1 is none | | `routing_shifts` | on | The default shifts of the unconditional pass; needs CFG | ### PrismFlow Guider Advanced Takes a guider from PrismFlow Guider and returns it with its CFG step window and its two shifts replaced, whatever the guider's `routing_shifts` switch says. It is optional. Output: `guider`. | Input | Default | Meaning | | --- | --- | --- | | `guider` | | From PrismFlow Guider | | `cfg_start_step` | 0 | First CFG step | | `cfg_stop_step` | −1 | Last CFG step; −1 for the last step | | `primary_enabled` | on | Apply the first shift | | `primary_merges` | `2,3,4` | Its merges, comma-separated, from 0 to 6 | | `primary_bias` | −1.5 | Its bias, from −6 to 6, not 0 | | `primary_freeze_v0` | on | Keep the input embedding's weight | | `primary_start_percent` | 0 | Start of its window, in percent of the steps | | `primary_end_percent` | 100 | End of its window | | `secondary_enabled` | on | Apply the second shift | | `secondary_merges` | `5` | Its merges; none in common with the first shift | | `secondary_bias` | −0.5 | Its bias | | `secondary_freeze_v0` | off | Keep the input embedding's weight | | `secondary_start_percent` | 0 | Start of its window | | `secondary_end_percent` | 40 | End of its window | With both shifts disabled the guider runs plain CFG. ### PrismFlow Sampler Chooses the solver. Output: `sampler`, which goes to PrismFlow Time Schedule. | Input | Default | Meaning | | --- | --- | --- | | `solver` | `euler_ancestral` | One of the [solvers](#solvers) | | `noise_scale` | 1.0 | Noise multiplier of stochastic solvers; eta for `euler_ancestral` and `dpmpp_2m_sde` | Changing the solver in the ComfyUI interface sets `noise_scale` to that solver's recommended value. ### PrismFlow Time Schedule Builds the schedule for the size of the latent. Outputs: `sigmas` and `sampler`. | Input | Default | Meaning | | --- | --- | --- | | `sampler` | | From PrismFlow Sampler | | `latent` | | The latent that will be sampled; gives the image size | | `schedule` | `beta_0_6` | One of the [schedules](#schedules) | | `steps` | 50 | Solver steps | | `base_log_snr_shift` | −0.25 | The size-independent part of the shift | | `resolution_shift` | on | Add the image-size term | | `beta_mean` | 0.5 | `custom_beta` only | | `beta_concentration` | 1.2 | `custom_beta` only (with mean 0.5, the same spacing as `beta_0_6`) | Connect both outputs to SamplerCustomAdvanced. The `sampler` output carries the image size the sigmas were built for, and the guider checks it against the latent. With a sampler taken straight from PrismFlow Sampler, sampling stops with an error message. ### PrismFlow Empty Latent Creates an empty 96-channel latent. Output: `latent`. ComfyUI's stock empty latent nodes produce a different latent format and cannot be used. | Input | Default | Meaning | | --- | --- | --- | | `width` | 384 | Image width, a multiple of 16 | | `height` | 384 | Image height, a multiple of 16 | | `batch_size` | 1 | Images per run | ### Stock nodes Seeds come from ComfyUI's RandomNoise node. A seed gives the same starting noise in ComfyUI as in the Python package. Seeds run from 0 to 2⁶³ − 1, as in the package; RandomNoise's widget goes higher, and the guider stops with an error on a larger seed. SamplerCustomAdvanced takes the noise, the guider, the sampler and sigmas from PrismFlow Time Schedule, and the latent. VAEDecode with the loader's `vae` output turns the result into an image, and SaveImage stores it with the workflow embedded. An embedded workflow reproduces its image exactly only with `compile_model` on, as the gallery was rendered: compiled and eager kernels round differently in bfloat16. For the same latents, the package's PIL output and ComfyUI's SaveImage can differ by one 8-bit level in some pixels, because the two round the decoded image to 8 bits differently. ## Troubleshooting **"The prismflow_2b weights are not in the node folder", or a file "is a Git LFS pointer".** This happens after a `git clone` without the large files. Download them into the folder with the command the message prints, `hf download data-archetype/prismflow_2b_research_preview --local-dir `, or set the loader's `source` to `hub`. **The first image takes much longer than the following ones.** The model is being compiled. This happens once per session. **Errors during compilation.** `torch.compile` needs a working compiler toolchain and a matching PyTorch build. To check whether compilation is the cause, run eagerly: `compile=False` in Python, or `compile_model` off in PrismFlow Loader. Eager mode runs the same model at lower speed. **"Please enter a prompt."** Empty prompts are off in the release's `config.json`, so a forgotten prompt fails instead of generating freely. To allow them, set `"allow_empty_prompt": true` under `"inference"` there. **Out of memory.** A 384×384 image needs about 7 GB of VRAM at peak, and memory grows with the image area and the batch size. Generate one image at a time and close other programs that hold GPU memory. In ComfyUI, other loaded models count against the same memory. **"The prompt has N tokens; the model takes at most 6144."** Shorten the prompt. Text in double quotes and `text` fields of a layout use one token per character, so long quoted passages add up quickly. **"Prompts of one batch must have the same token count."** A list of different prompts in one Python call must have equal token counts. Run prompts of different lengths as separate calls, or use `num_images` to repeat one prompt. **"… leaves the W×H canvas …: the layout is for a larger image."** A compiled layout is being used at a smaller size than it was compiled for. Compile the stored layout again at the image size: pass the stored layout to the pipeline, or in ComfyUI set `width` and `height` on PrismFlow Layout Encode to the latent's size. **"PrismFlow Layout Encode compiled the layout for … the latent is …"** Set `width` and `height` on PrismFlow Layout Encode to the size of the latent being sampled. **"The schedule was built for … but the latent is …"** The PrismFlow Time Schedule node is connected to a different latent from the one being sampled. Connect the same latent to both. **"Connect the sampler output of PrismFlow Time Schedule …"** SamplerCustomAdvanced is receiving the sampler from PrismFlow Sampler directly. See [PrismFlow Time Schedule](#prismflow-time-schedule). **"The latent batch is … but the conditioning holds … prompts."** Set the same `batch_size` on the text encode node and on PrismFlow Empty Latent. A negative prompt's text encode node needs the same `batch_size` too. **"… must be compiled at the image size; use PrismFlow Layout Encode."** A stored layout or a MOSS-Image draft was given to PrismFlow Text Encode. Use PrismFlow Layout Encode, which takes the image size. **"This MOSS draft is for … the image is …"** A MOSS-Image editable draft names its canvas size. Generate at that size, or change the draft's `width` and `height` and its boxes. **"Negative-forward shifts need CFG enabled."** CFG was turned off while the default shifts were still set. Pass `negative_shifts=()` together with `CfgGuidance(enabled=False)`, or in ComfyUI switch `routing_shifts` off with `cfg_enabled`, and disable both shifts on PrismFlow Guider Advanced if it is connected. **"Negative shifts must target disjoint merges."** Two shifts name the same merge. Give each merge to one shift only. **"… is release X; this package (0.06) loads the weights of releases …"** The installed code does not accept those weights. Install that release whole, as described under [Updating and older versions](#updating-and-older-versions). **Images larger than 384 px lose coherence.** This release was trained at 256 and 384 px only. Use one of the [384-px sizes](#image-sizes).