---
title: flux2-bnb-4bit-modular
canonical_url: "https://www.modelscope.cn/models/hf-diffusers/flux2-bnb-4bit-modular"
md_url: "https://www.modelscope.cn/models/hf-diffusers/flux2-bnb-4bit-modular.md"
repository: hf-diffusers/flux2-bnb-4bit-modular
last_updated: 2026-03-01
pipeline_tag: text-to-image-synthesis
tasks:
  - text-to-image-synthesis
parameters: 40.7B
tensor_type:
  - F32
  - F16
  - U8
  - I64
  - BF16
library_name:
  - pytorch
  - diffusers
  - lora
  - safetensors
frameworks:
  - pytorch
downloads: 57
stars: 0
tags:
  - modular-diffusers
  - diffusers
  - flux2
  - text-to-image
---

# flux2-bnb-4bit-modular

> flux2-bnb-4bit-modular - hf-diffusers 在 ModelScope 开源的模型。Install the latest version of diffusers

- **Repository**: hf-diffusers/flux2-bnb-4bit-modular
- **Tasks**: text-to-image-synthesis
- **Parameters**: 40.7B
- **Tags**: modular-diffusers, diffusers, flux2, text-to-image
- **Downloads**: 57
- **Stars**: 0
- **Last updated**: 2026-03-01

Source: https://www.modelscope.cn/models/hf-diffusers/flux2-bnb-4bit-modular

---

## Setup

Install the latest version of `diffusers`

```shell
pip install git+https://github.com/huggingface/diffusers.git
```

Login to your Hugging Face account

```shell
hf auth login
```

## How to use

The following code snippet demonstrates how to use the [Flux2](https://huggingface.co/black-forest-labs/FLUX.2-dev) modular pipeline with a remote text encoder and a 4bit quantized version of the DiT. It requires approximately 19GB of VRAM to generate an image.

```python
import torch
from diffusers.modular_pipelines.flux2 import ALL_BLOCKS
from diffusers.modular_pipelines import SequentialPipelineBlocks

blocks = SequentialPipelineBlocks.from_blocks_dict(ALL_BLOCKS['remote'])
pipe = blocks.init_pipeline("diffusers/flux2-bnb-4bit-modular")
pipe.load_components(torch_dtype=torch.bfloat16, device_map="cuda")

prompt = "a photo of a cat"
outputs = pipe(prompt=prompt, num_inference_steps=28, output="images")
outputs[0].save("flux2-bnb-modular.png")
```
