Skip to content

feat: add P-H3-Image support - #2270

Open
kgonia wants to merge 1 commit into
leejet:masterfrom
kgonia:p-h3-image
Open

kgonia wants to merge 1 commit into
leejet:masterfrom
kgonia:p-h3-image

Conversation

@kgonia

@kgonia kgonia commented Nov 4, 2026 •

Copy link
Copy Markdown

Summary

Adds P-H3-Image (Pruna AI): MiniMax-H3's 33B transformer generating a single frame, with a Qwen3-VL-4B text encoder, a text connector and a single-frame VAE image decoder. It does text-to-image and editing with 1–8 images in 8 steps, without CFG.

It reuses the MiniMax-H3 path with one latent frame:

generate_image (P-H3-Image)
  generate_video, once per batch image, video_frames = 1
    LLMEmbedder
      Qwen3-VL-4B hidden states 13, 19, 25, 31 + final norm
      PH3ImageTextConnector: standardize → Linear 12800→5120 → destandardize, sink row
    H3AVFlowDenoiser: fixed 8-step sigma grid, audio rows on the image's shift
    MiniMaxH3VideoVAE: image decoder (patch_t 1, no mask token, fixed frame position)
  • Detection: MiniMax-H3 transformer plus text_encoders.llm.text_connector.*. The connector's size is read from the weights.
  • Edits: reference images go to the VLM as <Picture i>: plus vision tokens at about 1 MP, and the prompt follows Edit <Picture 1>. . Each reference keeps its own size, scaled into 1–8 MP.
  • Server recipe p-h3-image, docs/p_h3_image.md, README entries.

Weights are in MiniMax-H3's original layout: SearchingMan/P-H3-Image-GGUF (Q4_K_M transformer, Q8_0 text encoder, F16 VAE), converted from the diffusers checkpoint. The diffusers checkpoint does not load directly.

Related Issue / Discussion

None found for P-H3-Image. Builds on MiniMax-H3 support (#1854).

Additional Information

Verified on an RTX 5090 Laptop (CUDA, 70 W power mode) with the GGUF files above, --diffusion-fa, seed 42:

sd-cli --diffusion-model p_h3_image-Q4_K_M.gguf --llm p_h3_image_text_encoder-Q8_0.gguf --vae p_h3_image_vae-F16.gguf -p "A German Expressionist oil painting of a Berlin street at night ..." -W 2048 -H 2048 --diffusion-fa
sd-cli ... -r street.png -p "Make it a snowy winter night: ... Keep the painting style, composition, figures and lamp unchanged." -W 2048 -H 2048 --diffusion-fa
Task Sampling (8 steps) VAE decode
Text-to-image 1024² 21 s 11 s
Text-to-image 2048² 43 s — (66 s end to end)
Edit 2048², one 1024² reference 62 s 19 s
p_h3_t2i_2048
  • MiniMax-H3 itself is unchanged: every new path is gated on VERSION_P_H3_IMAGE, the image decoder is picked by decoder.proj_out size, and H3 keeps its audio shift of 3.
  • Not included: the reference pipeline's Qwen3.5-9B prompt upsampler (documented; detailed prompts work best).
  • Known difference from diffusers: reference latents use the VAE posterior mean, as for MiniMax-H3, rather than a sample.

Checklist

Summary by CodeRabbit

  • New Features
    • Added support for P-H3-Image generation and image editing, including reference images and configurable model inputs.
    • Added a P-H3-Image recipe with recommended generation settings.
    • Added guidance on model setup, prompt behavior, image sizing, sampling, and usage limitations.

P-H3-Image (PrunaAI/P-H3-Image) is MiniMax-H3's transformer generating a
single frame, with a Qwen3-VL-4B text encoder, a text connector and a VAE
with a single-frame image decoder. It runs through the MiniMax-H3 video
pipeline with one latent frame; generate_image() runs one video
generation per image.

- Detected as MiniMax-H3 plus text_encoders.llm.text_connector.* tensors.
- Text connector over hidden states 13, 19, 25, 31 and the final normed
  one, with the attention-sink row replaced; its size is read from the
  weights.
- Edits: images as references, presented as "<Picture i>: " and vision
  tokens at about 1 MP, the prompt after "Edit <Picture 1>. ", each image
  kept within 1 to 8 MP.
- The checkpoint's 8-step sigma grid unless custom sigmas are passed; no
  CFG; audio rows sampled on the image's shift.
- VAE image decoder (patch_t 1, no mask token, fixed frame position).
- docs/p_h3_image.md covers model files and usage.
- Server recipe p-h3-image.
@coderabbitai

coderabbitai Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

Failed to post review comments.

GitHub was unavailable or timed out while CodeRabbit was posting the review. Please request a new review later if the pull request still needs one. This happened while posting 1 inline comment. Use @coderabbitai full review to retry the review.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 03f4a2cd-4178-4ce5-afba-e970e43a5d8a
Commits

Reviewing files that changed from the base of the PR and between 984eb06 and cfd7737.

Files selected for processing: 14
  • README.md
  • docs/p_h3_image.md
  • examples/server/recipes/defaults.md
  • examples/server/recipes/p-h3-image.json
  • src/conditioning/conditioner.hpp
  • src/model.h
  • src/model/integrations/minimax_h3.cpp
  • src/model/vae/minimax_h3_vae.hpp
  • src/model_loader.cpp
  • src/pipeline/diffusion_engine.cpp
  • src/pipeline/image.cpp
  • src/pipeline/request.cpp
  • src/pipeline/video.cpp
  • src/runtime/denoiser.hpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Additional context used
Path-based instructions: 5
Applicability reference: AGENTS.md: # Instructions for stable-diffusion.cpp `examples/server/` - server application built on top of the library.

📄 CodeRabbit inference engine (examples/server/recipes/README.md)

Files:

  • examples/server/recipes/p-h3-image.json
Source excerpt: Agents must not: Add secrets, model weights, generated binaries, local absolute paths, or machine-specific output.

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • README.md
  • examples/server/recipes/p-h3-image.json
  • src/model_loader.cpp
  • src/model/integrations/minimax_h3.cpp
  • examples/server/recipes/defaults.md
  • src/model.h
  • src/pipeline/diffusion_engine.cpp
  • src/pipeline/video.cpp
  • src/runtime/denoiser.hpp
  • docs/p_h3_image.md
  • src/model/vae/minimax_h3_vae.hpp
  • src/pipeline/image.cpp
  • src/pipeline/request.cpp
  • src/conditioning/conditioner.hpp
Applicability reference: AGENTS.md: # Instructions for stable-diffusion.cpp For general contribution rules, including PR scope, commit conventions, code style, dependency updates, security hygiene, and AI-assisted contribu...

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Files:

  • src/model.h
  • src/runtime/denoiser.hpp
  • src/model/vae/minimax_h3_vae.hpp
  • src/conditioning/conditioner.hpp
Applicability reference: AGENTS.md: # Instructions for stable-diffusion.cpp For general contribution rules, including PR scope, commit conventions, code style, dependency updates, security hygiene, and AI-assisted contribution policy, see `...

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Files:

  • README.md
  • src/model/vae/minimax_h3_vae.hpp
Source excerpt: When reading or editing repository text files: Prefer UTF-8 with LF for Markdown, frontend source, JSON, and other text-first project files unless the file already clearly uses a different encoding.

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • README.md
  • examples/server/recipes/defaults.md
markdownlint-cli2 (0.23.3)
docs/p_h3_image.md

[warning] 44-44: Spaces inside code span elements

(MD038, no-space-in-code)

Walkthrough

This change adds P-H3-Image as a MiniMax-H3 image-generation model. It adds checkpoint detection, image-specific conditioning and VAE decoding, and routes image requests through the video pipeline as single-frame runs. It also adds server recipe settings and model documentation.

Changes: P-H3-Image support

Layer / File(s) Summary
Model recognition and image decoder
src/model.h, src/model/integrations/minimax_h3.cpp, src/model_loader.cpp, src/model/vae/minimax_h3_vae.hpp
Adds the P-H3-Image version and model definition. Checkpoint loading detects the model by its text-connector projection. The MiniMax-H3 VAE runner detects image checkpoints and configures image-mode decoding.
Text connector and reference conditioning
src/conditioning/conditioner.hpp
Adds the connector model and runner, applies connector weights to encoded prompt states, and selects MiniMax-H3 hidden layers when a connector is present. P-H3-Image reference images use approximately one-megapixel prompt encoding, with specified prompt-prefix handling.
Single-frame generation and sampling
src/runtime/denoiser.hpp, src/pipeline/diffusion_engine.cpp, src/pipeline/request.cpp, src/pipeline/video.cpp, src/pipeline/image.cpp
Sets P-H3-Image guidance and sigma behavior, uses one-frame conversion, and applies image-specific audio shifts and reference sizing. Image requests run through the video pipeline once per batch item and retain the first returned frame.
Recipe and model documentation
README.md, docs/p_h3_image.md, examples/server/recipes/p-h3-image.json, examples/server/recipes/defaults.md
Adds P-H3-Image to supported model lists, documents its inputs and generation behavior, and defines a server recipe with reference-image support and sampling defaults.

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant Image as generate_image
  participant PImage as generate_p_h3_image
  participant Video as generate_video
  Image->>PImage: Dispatch P-H3-Image request
  PImage->>Video: Generate one frame per batch item
  Video-->>PImage: Return generated frames
  PImage-->>Image: Return first frame from each run
Loading

Suggested reviewers: leejet

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 11.11% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the main change: adding P-H3-Image support.
Description check Passed The description includes the required Summary, Related Issue / Discussion, Additional Information, and Checklist sections. It explains the implementation, testing, limitations, and related work in suf…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description includes the required Summary, Related Issue / Discussion, Additional Information, and Checklist sections. It explains the implementation, testing, limitations, and related work in sufficient detail.

Full details: Docstring Coverage

Explanation

Docstring coverage is 11.11% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 27 functions across 10 files. (4 skipped: 4 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

Cppcheck (2.22.0)
src/pipeline/image.cpp

Cppcheck timed out; analysis of this file is incomplete

src/pipeline/request.cpp

Cppcheck timed out; analysis of this file is incomplete

src/pipeline/diffusion_engine.cpp

Cppcheck timed out; analysis of this file is incomplete

  • 1 others

Tip

🎯 Customize your risk assessments

Guide how CodeRabbit assesses merge risk and security architecture risk. Highlight sensitive changes and explain your security boundaries using Merge Risk Instructions and Security Risk Instructions in your review settings. Security architecture risk assessments require the Advanced plan or above.

✅ Automatic approvals, with your rules

Let CodeRabbit approve pull requests once required threads are resolved, pre-merge checks pass, and your risk limits are met. Enable Automatic approvals in review settings, with overrides for teams or file paths.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant